nx-kv 0.48.0 → 0.48.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (242) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/package.json +1 -1
  3. package/src/modules/auth/actions/auth-login.ts +13 -6
  4. package/src/modules/auth/actions/auth-logout.ts +11 -6
  5. package/src/modules/auth/actions/auth-me.ts +11 -6
  6. package/src/modules/auth/actions/auth-status.ts +11 -6
  7. package/src/modules/bundled/actions/bundled-get.ts +14 -6
  8. package/src/modules/bundled/actions/bundled-groups.ts +11 -6
  9. package/src/modules/bundled/actions/bundled-install.ts +15 -6
  10. package/src/modules/bundled/actions/bundled-list.ts +11 -6
  11. package/src/modules/db/actions/db-backup.ts +12 -6
  12. package/src/modules/db/actions/db-migrate.ts +12 -6
  13. package/src/modules/db/actions/db-status.ts +11 -6
  14. package/src/modules/db/actions/db-verify.ts +11 -6
  15. package/src/modules/docs/actions/doc-add.ts +14 -6
  16. package/src/modules/docs/actions/doc-attach-note.ts +13 -6
  17. package/src/modules/docs/actions/doc-attach.ts +20 -6
  18. package/src/modules/docs/actions/doc-attachments.ts +11 -6
  19. package/src/modules/docs/actions/doc-detach.ts +13 -6
  20. package/src/modules/docs/actions/doc-get.ts +11 -6
  21. package/src/modules/docs/actions/doc-list.ts +11 -6
  22. package/src/modules/docs/actions/doc-remove.ts +11 -6
  23. package/src/modules/docs/actions/doc-update.ts +14 -6
  24. package/src/modules/docs/actions/docs-bind.ts +15 -6
  25. package/src/modules/docs/actions/docs-index.ts +11 -6
  26. package/src/modules/docs/actions/docs-link.ts +16 -6
  27. package/src/modules/docs/actions/docs-notebind.ts +15 -6
  28. package/src/modules/docs/actions/docs-seed.ts +11 -6
  29. package/src/modules/file/actions/file-content.ts +18 -10
  30. package/src/modules/file/actions/file-get.ts +12 -6
  31. package/src/modules/file/actions/file-list.ts +13 -6
  32. package/src/modules/file/actions/file-orphans.ts +11 -6
  33. package/src/modules/file/actions/file-prune.ts +12 -6
  34. package/src/modules/file/actions/file-remove.ts +12 -6
  35. package/src/modules/file/actions/file-sync.ts +15 -6
  36. package/src/modules/file/actions/file-upload.ts +17 -6
  37. package/src/modules/localtask/actions/localtask-add.ts +26 -6
  38. package/src/modules/localtask/actions/localtask-attach-note.ts +15 -6
  39. package/src/modules/localtask/actions/localtask-attach.ts +24 -6
  40. package/src/modules/localtask/actions/localtask-attachments.ts +13 -6
  41. package/src/modules/localtask/actions/localtask-cancel.ts +12 -6
  42. package/src/modules/localtask/actions/localtask-cancelMany.ts +13 -6
  43. package/src/modules/localtask/actions/localtask-chain.ts +13 -6
  44. package/src/modules/localtask/actions/localtask-claim.ts +14 -6
  45. package/src/modules/localtask/actions/localtask-clone.ts +13 -6
  46. package/src/modules/localtask/actions/localtask-closeMany.ts +15 -6
  47. package/src/modules/localtask/actions/localtask-config.ts +23 -8
  48. package/src/modules/localtask/actions/localtask-detach.ts +15 -6
  49. package/src/modules/localtask/actions/localtask-done.ts +14 -6
  50. package/src/modules/localtask/actions/localtask-events.ts +19 -9
  51. package/src/modules/localtask/actions/localtask-fork.ts +13 -6
  52. package/src/modules/localtask/actions/localtask-get.ts +13 -6
  53. package/src/modules/localtask/actions/localtask-importRemote.ts +20 -9
  54. package/src/modules/localtask/actions/localtask-list.ts +11 -6
  55. package/src/modules/localtask/actions/localtask-presence.ts +11 -6
  56. package/src/modules/localtask/actions/localtask-preview.ts +15 -6
  57. package/src/modules/localtask/actions/localtask-prune.ts +12 -6
  58. package/src/modules/localtask/actions/localtask-remove.ts +14 -6
  59. package/src/modules/localtask/actions/localtask-removeMany.ts +14 -6
  60. package/src/modules/localtask/actions/localtask-reopen.ts +22 -7
  61. package/src/modules/localtask/actions/localtask-reorder.ts +17 -6
  62. package/src/modules/localtask/actions/localtask-task-restore.ts +13 -6
  63. package/src/modules/localtask/actions/localtask-timegoalLog.ts +13 -6
  64. package/src/modules/localtask/actions/localtask-topic-add.ts +12 -6
  65. package/src/modules/localtask/actions/localtask-topic-remove.ts +13 -6
  66. package/src/modules/localtask/actions/localtask-topic-removeMany.ts +14 -6
  67. package/src/modules/localtask/actions/localtask-update.ts +24 -6
  68. package/src/modules/localtask/actions/localtask-wait.ts +15 -6
  69. package/src/modules/localtask/actions/task-move.ts +23 -6
  70. package/src/modules/repos/actions/board-add.ts +12 -6
  71. package/src/modules/repos/actions/board-assign.ts +14 -6
  72. package/src/modules/repos/actions/board-export.ts +11 -6
  73. package/src/modules/repos/actions/board-get.ts +11 -6
  74. package/src/modules/repos/actions/board-import.ts +17 -7
  75. package/src/modules/repos/actions/board-list.ts +11 -6
  76. package/src/modules/repos/actions/board-note.ts +13 -6
  77. package/src/modules/repos/actions/board-prefix.ts +12 -6
  78. package/src/modules/repos/actions/board-prune.ts +13 -6
  79. package/src/modules/repos/actions/board-rekey.ts +13 -6
  80. package/src/modules/repos/actions/board-remove.ts +11 -6
  81. package/src/modules/repos/actions/board-update.ts +13 -6
  82. package/src/modules/repos/actions/repo-add.ts +19 -6
  83. package/src/modules/repos/actions/repo-bind-topics.ts +12 -6
  84. package/src/modules/repos/actions/repo-bind.ts +14 -6
  85. package/src/modules/repos/actions/repo-clone.ts +16 -6
  86. package/src/modules/repos/actions/repo-detect.ts +11 -6
  87. package/src/modules/repos/actions/repo-doc-add.ts +17 -6
  88. package/src/modules/repos/actions/repo-doc-list.ts +11 -6
  89. package/src/modules/repos/actions/repo-doc-remove.ts +12 -6
  90. package/src/modules/repos/actions/repo-export.ts +14 -6
  91. package/src/modules/repos/actions/repo-get.ts +11 -6
  92. package/src/modules/repos/actions/repo-import-diff.ts +12 -6
  93. package/src/modules/repos/actions/repo-import.ts +16 -6
  94. package/src/modules/repos/actions/repo-key-migrate.ts +11 -6
  95. package/src/modules/repos/actions/repo-key-refresh.ts +13 -6
  96. package/src/modules/repos/actions/repo-key-set.ts +13 -6
  97. package/src/modules/repos/actions/repo-knowledge.ts +12 -6
  98. package/src/modules/repos/actions/repo-list.ts +11 -6
  99. package/src/modules/repos/actions/repo-open.ts +11 -6
  100. package/src/modules/repos/actions/repo-ref-add.ts +15 -6
  101. package/src/modules/repos/actions/repo-ref-backfill.ts +12 -6
  102. package/src/modules/repos/actions/repo-ref-check.ts +11 -6
  103. package/src/modules/repos/actions/repo-ref-clone.ts +18 -6
  104. package/src/modules/repos/actions/repo-ref-note.ts +14 -6
  105. package/src/modules/repos/actions/repo-ref-of.ts +11 -6
  106. package/src/modules/repos/actions/repo-ref-sync.ts +12 -6
  107. package/src/modules/repos/actions/repo-remote-check.ts +12 -6
  108. package/src/modules/repos/actions/repo-remote-list.ts +11 -6
  109. package/src/modules/repos/actions/repo-remote-pick.ts +12 -6
  110. package/src/modules/repos/actions/repo-remote.ts +13 -6
  111. package/src/modules/repos/actions/repo-remove.ts +11 -6
  112. package/src/modules/repos/actions/repo-scan.ts +13 -6
  113. package/src/modules/repos/actions/repo-update.ts +23 -6
  114. package/src/modules/setting/actions/setting-get.ts +11 -6
  115. package/src/modules/setting/actions/setting-set.ts +14 -6
  116. package/src/modules/system/actions/bootstrap.ts +9 -7
  117. package/src/modules/system/actions/health.ts +8 -6
  118. package/src/modules/system/actions/routes.ts +13 -6
  119. package/src/modules/system/routes.ts +1 -1
  120. package/src/modules/tasktool/actions/timegoal-check.ts +13 -6
  121. package/src/modules/tasktool/actions/timegoal-clear.ts +11 -6
  122. package/src/modules/tasktool/actions/timegoal-list.ts +11 -6
  123. package/src/modules/tasktool/actions/timegoal-log.ts +11 -6
  124. package/src/modules/tasktool/actions/timegoal-prune.ts +11 -6
  125. package/src/modules/tasktool/actions/timegoal-set.ts +13 -6
  126. package/src/modules/tasktool/actions/timegoal-show.ts +12 -6
  127. package/src/modules/tasktool/actions/timegoal-update.ts +13 -6
  128. package/src/modules/templates/actions/templates-add.ts +19 -6
  129. package/src/modules/templates/actions/templates-default.ts +15 -6
  130. package/src/modules/templates/actions/templates-list.ts +13 -6
  131. package/src/modules/templates/actions/templates-remove.ts +11 -6
  132. package/src/modules/templates/actions/templates-update.ts +17 -6
  133. package/src/modules/todo/actions/group-add.ts +12 -6
  134. package/src/modules/todo/actions/group-current.ts +11 -6
  135. package/src/modules/todo/actions/group-get.ts +11 -6
  136. package/src/modules/todo/actions/group-list.ts +11 -6
  137. package/src/modules/todo/actions/group-members.ts +11 -6
  138. package/src/modules/todo/actions/group-remove.ts +11 -6
  139. package/src/modules/todo/actions/group-update.ts +13 -6
  140. package/src/modules/todo/actions/group-use.ts +11 -6
  141. package/src/modules/todo/actions/prompt-get.ts +12 -6
  142. package/src/modules/todo/actions/prompt-remove.ts +12 -6
  143. package/src/modules/todo/actions/prompt-set.ts +13 -6
  144. package/src/modules/todo/actions/todo-add.ts +13 -6
  145. package/src/modules/todo/actions/todo-archive.ts +12 -6
  146. package/src/modules/todo/actions/todo-attach.ts +19 -6
  147. package/src/modules/todo/actions/todo-attachments.ts +14 -6
  148. package/src/modules/todo/actions/todo-done.ts +15 -6
  149. package/src/modules/todo/actions/todo-freeze.ts +14 -6
  150. package/src/modules/todo/actions/todo-get.ts +14 -6
  151. package/src/modules/todo/actions/todo-list.ts +13 -6
  152. package/src/modules/todo/actions/todo-remove.ts +14 -6
  153. package/src/modules/todo/actions/todo-unfreeze.ts +14 -6
  154. package/src/modules/todo/actions/todo-update.ts +17 -6
  155. package/src/modules/todo/actions/topic-add.ts +12 -6
  156. package/src/modules/todo/actions/topic-list.ts +11 -6
  157. package/src/modules/todo/actions/topic-remove.ts +12 -6
  158. package/src/runtime/action-base.ts +41 -1
  159. package/src/runtime/action-decorator.ts +28 -13
  160. package/src/runtime/codegen.ts +26 -41
  161. package/src/runtime/registry.ts +2 -2
  162. package/src/web/frontend/api/client.generated.ts +550 -698
  163. package/src/web/frontend/page/cloud/api.ts +99 -0
  164. package/src/web/frontend/page/cloud/index.tsx +13 -32
  165. package/src/web/frontend/page/dag/api.ts +20 -0
  166. package/src/web/frontend/page/dag/index.tsx +2 -5
  167. package/src/web/frontend/page/dir/api.ts +135 -0
  168. package/src/web/frontend/page/dir/index.tsx +37 -57
  169. package/src/web/frontend/page/dir/task-actions.ts +39 -59
  170. package/src/web/frontend/page/dir/task-chain.ts +2 -2
  171. package/src/web/frontend/page/dir/task-feedback.ts +19 -23
  172. package/src/web/frontend/page/dir/task-goal.ts +3 -3
  173. package/src/web/frontend/page/dir/task.tsx +3 -3
  174. package/src/web/frontend/page/doc/api.ts +82 -0
  175. package/src/web/frontend/page/doc/index.tsx +29 -32
  176. package/src/web/frontend/page/group/api.ts +24 -0
  177. package/src/web/frontend/page/group/index.tsx +7 -16
  178. package/src/web/frontend/page/overview/api.ts +16 -0
  179. package/src/web/frontend/page/overview/index.tsx +2 -2
  180. package/src/web/frontend/page/progress/api.ts +20 -0
  181. package/src/web/frontend/page/progress/index.tsx +3 -6
  182. package/src/web/frontend/page/refs/api.ts +14 -0
  183. package/src/web/frontend/page/refs/index.tsx +2 -4
  184. package/src/web/frontend/page/repos/api.ts +197 -0
  185. package/src/web/frontend/page/repos/bind-modals.tsx +4 -7
  186. package/src/web/frontend/page/repos/board-admin.tsx +6 -6
  187. package/src/web/frontend/page/repos/doc-search-modal.tsx +4 -4
  188. package/src/web/frontend/page/repos/index.tsx +10 -14
  189. package/src/web/frontend/page/repos/pending-section.tsx +7 -13
  190. package/src/web/frontend/page/repos/ref-panel.tsx +9 -14
  191. package/src/web/frontend/page/repos/remote-modal.tsx +4 -28
  192. package/src/web/frontend/page/repos/repo-form-modal.tsx +4 -4
  193. package/src/web/frontend/page/settings/api.ts +29 -0
  194. package/src/web/frontend/page/settings/index.tsx +3 -3
  195. package/src/web/frontend/page/settings/prompt-templates-section.tsx +4 -4
  196. package/src/web/frontend/page/settings/sidebar-section.tsx +2 -2
  197. package/src/web/public/assets/Introduction-Du_dycft.js +6 -0
  198. package/src/web/public/assets/{bar-B9WWmCpt.js → bar-B52NTf_v.js} +1 -1
  199. package/src/web/public/assets/cloud-Droja_aT.js +3 -0
  200. package/src/web/public/assets/{composer-panel-ByezS8Xv.js → composer-panel-DpiU2h50.js} +1 -1
  201. package/src/web/public/assets/dag-Ca-wjIxQ.js +1 -0
  202. package/src/web/public/assets/{deleted-panel-BcbtctNF.js → deleted-panel-K9GgfR8t.js} +1 -1
  203. package/src/web/public/assets/dir-DacRpcBt.js +5 -0
  204. package/src/web/public/assets/group-TPuU-QVc.js +2 -0
  205. package/src/web/public/assets/{index-D8MvtVAm.js → index-BkLkooKe.js} +2 -2
  206. package/src/web/public/assets/{md-history-BqZvzWiD.js → md-history-0GBWw4qr.js} +1 -1
  207. package/src/web/public/assets/overview-B3kHI66i.js +1 -0
  208. package/src/web/public/assets/progress-CdhFz0Lz.js +3 -0
  209. package/src/web/public/assets/refs-BDxfuH6R.js +1 -0
  210. package/src/web/public/assets/repos-C8jRM7wS.js +15 -0
  211. package/src/web/public/assets/{route-crumb-CWVu80du.js → route-crumb-QvahotvN.js} +1 -1
  212. package/src/web/public/assets/settings-BBcdGLTc.js +1 -0
  213. package/src/web/public/assets/{status-tag-DRl9E2Os.js → status-tag-BheHByek.js} +1 -1
  214. package/src/web/public/assets/task-CUkQaLBZ.js +11 -0
  215. package/src/web/public/assets/task-utils-_JAWRAz6.js +12 -0
  216. package/src/web/public/assets/{templates-Df__0k-F.js → templates-CbRyW3PJ.js} +1 -1
  217. package/src/web/public/assets/{tool-bar-Cv7f6p4v.js → tool-bar-BAmT-BI-.js} +1 -1
  218. package/src/web/public/index.html +1 -1
  219. package/src/modules/auth/schemas.ts +0 -27
  220. package/src/modules/bundled/schemas.ts +0 -32
  221. package/src/modules/db/schemas.ts +0 -27
  222. package/src/modules/docs/schemas.ts +0 -107
  223. package/src/modules/file/schemas.ts +0 -61
  224. package/src/modules/localtask/schemas.ts +0 -310
  225. package/src/modules/repos/schemas.ts +0 -310
  226. package/src/modules/setting/schemas.ts +0 -18
  227. package/src/modules/system/schemas.ts +0 -29
  228. package/src/modules/tasktool/schemas.ts +0 -52
  229. package/src/modules/templates/schemas.ts +0 -50
  230. package/src/modules/todo/schemas.ts +0 -177
  231. package/src/web/public/assets/Introduction-aQCeCLrV.js +0 -6
  232. package/src/web/public/assets/cloud-C4b8SU7C.js +0 -3
  233. package/src/web/public/assets/dag-jvrjx4i7.js +0 -1
  234. package/src/web/public/assets/dir-B82XBb1J.js +0 -5
  235. package/src/web/public/assets/group-BPUOO_QM.js +0 -2
  236. package/src/web/public/assets/overview-DMihuyzh.js +0 -1
  237. package/src/web/public/assets/progress-D-rMgz3w.js +0 -3
  238. package/src/web/public/assets/refs-D21jmrn6.js +0 -1
  239. package/src/web/public/assets/repos-B94tMDGs.js +0 -15
  240. package/src/web/public/assets/settings-DgTt4JG5.js +0 -1
  241. package/src/web/public/assets/task-B2x5GoV3.js +0 -11
  242. package/src/web/public/assets/task-utils-By8gLpHY.js +0 -12
@@ -0,0 +1,99 @@
1
+ // cloud 页的 API 收口:页面组件只消费这里的函数,不直接调 api()(模板约定)。
2
+ //
3
+ // 只搬调用不改语义:路径 / 方法 / body 与收口前逐字一致。
4
+ import { api } from '../../api/client.js';
5
+
6
+ /** 登录并保存 token 到本机配置(POST /api/auth/login)。 */
7
+ export function authLogin(body: { email: string; password: string }): Promise<any> {
8
+ return api('/api/auth/login', { method: 'POST', body });
9
+ }
10
+
11
+ /** 清除本机保存的 token(POST /api/auth/logout)。 */
12
+ export function authLogout(): Promise<any> {
13
+ return api('/api/auth/logout', { method: 'POST' });
14
+ }
15
+
16
+ /** 清单里的一条任务(/api/todo 三个桶的元素)。 */
17
+ export interface TodoTask {
18
+ id: number | string;
19
+ text: string;
20
+ topic?: string;
21
+ note?: string;
22
+ createdAt?: string;
23
+ doneAt?: string;
24
+ frozenAt?: string;
25
+ }
26
+
27
+ /** 清单出站形状(桶名固定三个)。 */
28
+ export interface TodoData {
29
+ open?: TodoTask[];
30
+ done?: TodoTask[];
31
+ freeze?: TodoTask[];
32
+ topics?: string[];
33
+ [k: string]: any;
34
+ }
35
+
36
+ /** 读云端清单(GET /api/todo;CLI todo list 等价)。 */
37
+ export function listTodos(): Promise<any> {
38
+ return api('/api/todo');
39
+ }
40
+
41
+ /** 读本机设置(GET /api/setting)。 */
42
+ export function getSettings(): Promise<any> {
43
+ return api('/api/setting');
44
+ }
45
+
46
+ /** 改本机设置(POST /api/setting;只改传入项,返回归一后的全量)。 */
47
+ export function saveSettings(patch: Record<string, unknown>): Promise<any> {
48
+ return api('/api/setting', { method: 'POST', body: patch });
49
+ }
50
+
51
+ /** todo 定位键:当前内容 + 可选的消歧 pick。 */
52
+ export interface TodoLocateBody {
53
+ group?: number;
54
+ // 页面按「定位键」组装 body(内容 + 可选消歧),具体形状由后端契约决定
55
+ ref?: any;
56
+ pick?: any;
57
+ [k: string]: unknown;
58
+ }
59
+
60
+ /** 完成任务(POST /api/todo/done;result 是可选的完成结果一句话)。 */
61
+ export function doneTask(body: TodoLocateBody & { result?: any }): Promise<any> {
62
+ return api('/api/todo/done', { method: 'POST', body });
63
+ }
64
+
65
+ /** 冻结任务(POST /api/todo/freeze)。 */
66
+ export function freezeTask(body: TodoLocateBody): Promise<any> {
67
+ return api('/api/todo/freeze', { method: 'POST', body });
68
+ }
69
+
70
+ /** 解冻任务(POST /api/todo/unfreeze)。 */
71
+ export function unfreezeTask(body: TodoLocateBody): Promise<any> {
72
+ return api('/api/todo/unfreeze', { method: 'POST', body });
73
+ }
74
+
75
+ /** 删除任务(DELETE /api/todo/item;按内容定位)。 */
76
+ export function removeTask(body: TodoLocateBody): Promise<any> {
77
+ return api('/api/todo/item', { method: 'DELETE', body });
78
+ }
79
+
80
+ /** 归档返回:moved=移动条数;coldKey=冷 key。 */
81
+ export interface ArchiveResult {
82
+ moved?: number;
83
+ coldKey?: string;
84
+ }
85
+
86
+ /** 归档已完成的旧记录(POST /api/todo/archive;before 是 YYYY-MM-DD)。 */
87
+ export function archiveDone(body: { before?: string; group?: number }): Promise<any> {
88
+ return api('/api/todo/archive', { method: 'POST', body });
89
+ }
90
+
91
+ /** 加任务返回:topicAdded=是否新建了主题。 */
92
+ export interface AddTodoResult {
93
+ topicAdded?: boolean;
94
+ }
95
+
96
+ /** 加任务(POST /api/todo)。 */
97
+ export function addTodo(body: { topic: string; text: string; group?: number }): Promise<any> {
98
+ return api('/api/todo', { method: 'POST', body });
99
+ }
@@ -3,7 +3,8 @@
3
3
  import RouteBreadcrumb from '../../components/layout/route-crumb.jsx';
4
4
  import { useCallback, useEffect, useMemo, useState } from 'react';
5
5
  import type { ClipboardEvent as ReactClipboardEvent, ReactNode } from 'react';
6
- import { api } from '../../api/client.js';
6
+ import { addTodo, archiveDone, authLogin, authLogout, doneTask, freezeTask, getSettings, listTodos, removeTask,
7
+ saveSettings, unfreezeTask, type TodoData, type TodoTask } from './api.js';
7
8
  import { useStore } from '../../store.jsx';
8
9
  import { Copyable } from '../../components/ui.jsx';
9
10
  import { useToast, useGuard } from '../../components/toast/index.jsx';
@@ -20,26 +21,6 @@ const BUCKETS = [
20
21
  ['freeze', '冻结'],
21
22
  ] as const;
22
23
 
23
- /** 清单里的一条任务(/api/todo 三个桶的元素)。 */
24
- interface TodoTask {
25
- id: number | string;
26
- text: string;
27
- topic?: string;
28
- note?: string;
29
- createdAt?: string;
30
- doneAt?: string;
31
- frozenAt?: string;
32
- }
33
-
34
- /** /api/todo 的出站形状(桶名固定三个)。 */
35
- interface TodoData {
36
- open?: TodoTask[];
37
- done?: TodoTask[];
38
- freeze?: TodoTask[];
39
- topics?: string[];
40
- [k: string]: any;
41
- }
42
-
43
24
  /** 登录卡的表单态。 */
44
25
  interface AcctState {
45
26
  email: string;
@@ -153,7 +134,7 @@ export default function TodoView() {
153
134
  if (!acct.password) { toast('请填密码'); return; }
154
135
  setAcct((s) => ({ ...s, busy: true }));
155
136
  try {
156
- const r = await api('/api/auth/login', { method: 'POST', body: { email: acct.email.trim(), password: acct.password } });
137
+ const r = await authLogin({ email: acct.email.trim(), password: acct.password });
157
138
  setAcct((s) => ({ ...s, password: '' })); // 用完即清,不留在组件状态里
158
139
  toast(`已登录: ${r.email}`);
159
140
  await refreshBoot();
@@ -163,7 +144,7 @@ export default function TodoView() {
163
144
  });
164
145
 
165
146
  const logout = () => guard(async () => {
166
- await api('/api/auth/logout', { method: 'POST' });
147
+ await authLogout();
167
148
  toast('已登出');
168
149
  await refreshBoot();
169
150
  });
@@ -171,7 +152,7 @@ export default function TodoView() {
171
152
  const load = useCallback(async () => {
172
153
  if (!boot?.loggedIn) return;
173
154
  try {
174
- setData(await api<TodoData>('/api/todo'));
155
+ setData(await listTodos());
175
156
  setLoadErr('');
176
157
  } catch (e) {
177
158
  setLoadErr(String((e as Error).message || e));
@@ -186,7 +167,7 @@ export default function TodoView() {
186
167
  // 设置是**本机**行为(存 ~/.nx-kv/config.json),与登录态无关,所以单独取一次。
187
168
  // 失败静默:拿不到设置不该让清单页打不开。
188
169
  useEffect(() => {
189
- api('/api/setting')
170
+ getSettings()
190
171
  .then(setSetting)
191
172
  .catch(() => {});
192
173
  }, []);
@@ -195,7 +176,7 @@ export default function TodoView() {
195
176
 
196
177
  const toggleAutoSync = () => guard(async () => {
197
178
  const next = !autoSync;
198
- const s = await api('/api/setting', { method: 'POST', body: { autoSyncAttachments: next } });
179
+ const s = await saveSettings({ autoSyncAttachments: next });
199
180
  setSetting(s);
200
181
  toast(next ? '已开启:读任务时自动下载附件到本地' : '已关闭自动下载附件');
201
182
  });
@@ -298,18 +279,18 @@ export default function TodoView() {
298
279
  if (act === 'done') {
299
280
  const result = await dialog({ title: '完成结果', message: `完成「${task.text.slice(0, 40)}」`, input: true, placeholder: '可选:写一句完成结果' });
300
281
  if (result === null) return;
301
- await api('/api/todo/done', { method: 'POST', body: { ...body, result: result || undefined } });
282
+ await doneTask({ ...body, result: result || undefined });
302
283
  toast('已完成');
303
284
  } else if (act === 'freeze') {
304
- await api('/api/todo/freeze', { method: 'POST', body });
285
+ await freezeTask(body);
305
286
  toast('已冻结');
306
287
  } else if (act === 'unfreeze') {
307
- await api('/api/todo/unfreeze', { method: 'POST', body });
288
+ await unfreezeTask(body);
308
289
  toast('已解冻');
309
290
  } else if (act === 'remove') {
310
291
  const ok = await dialog({ message: `删除「${task.text.slice(0, 40)}」?`, danger: true });
311
292
  if (!ok) return;
312
- await api('/api/todo/item', { method: 'DELETE', body });
293
+ await removeTask(body);
313
294
  toast('已删除');
314
295
  } else if (act === 'edit') {
315
296
  // 编辑现在要能上传图片、插入嵌入,单行 dialog 装不下 —— 交给编辑器弹窗。
@@ -333,7 +314,7 @@ export default function TodoView() {
333
314
  if (answer === null) return;
334
315
  // dialog 在 input 模式下返回字符串;组件尚未类型化,这里在调用边界上收窄
335
316
  const before = String(answer);
336
- const r = await api('/api/todo/archive', { method: 'POST', body: { before: before.trim() || undefined, group } });
317
+ const r = await archiveDone({ before: before.trim() || undefined, group });
337
318
  toast(r.moved ? `已归档 ${r.moved} 条 → ${r.coldKey}` : '没有需要归档的记录');
338
319
  await reload();
339
320
  });
@@ -361,7 +342,7 @@ export default function TodoView() {
361
342
  const text = form.text.trim();
362
343
  if (!topic) { toast('请填主题'); return; }
363
344
  if (!text) { toast('请填内容'); return; }
364
- const r = await api('/api/todo', { method: 'POST', body: { topic, text, group } });
345
+ const r = await addTodo({ topic, text, group });
365
346
  setForm({ topic, text: '' });
366
347
  toast(`已加入待办${r.topicAdded ? `(新主题 ${topic})` : ''}`);
367
348
  await reload();
@@ -0,0 +1,20 @@
1
+ // dag 页的 API 收口:页面组件只消费这里的函数,不直接调 api()(模板约定)。
2
+ //
3
+ // 只搬调用不改语义:路径 / 方法 / body 与收口前逐字一致。
4
+ import { api } from '../../api/client.js';
5
+ import type { DepToken } from './model.js';
6
+
7
+ /** PATCH /api/localtasks/item 的补丁形状(依赖令牌数组在 CLI 侧按逗号短写传递)。 */
8
+ export interface DagPatchBody {
9
+ blockBy?: DepToken[] | string;
10
+ gate?: boolean;
11
+ duration?: string;
12
+ clearGoal?: boolean;
13
+ }
14
+
15
+ /** 编辑单个本地任务(PATCH /api/localtasks/item;CLI localtask update 等价)。 */
16
+ export function patchTaskItem(
17
+ body: { key?: string; cwd?: string; id: number } & DagPatchBody,
18
+ ): Promise<any> {
19
+ return api('/api/localtasks/item', { method: 'PATCH', body });
20
+ }
@@ -12,7 +12,6 @@
12
12
  // (视图)、use-interactions.js(拖拽/连线的全局指针监听)。
13
13
  import { useEffect, useId, useMemo, useRef, useState } from 'react';
14
14
  import type { PointerEvent as ReactPointerEvent } from 'react';
15
- import { api } from '../../api/client.js';
16
15
  import { useApp } from '../../app-context.jsx';
17
16
  import { useToast } from '../../components/toast/index.jsx';
18
17
  import { PopMenu, useDialog } from '../../components/popup/index.jsx';
@@ -21,6 +20,7 @@ import { isGroupTask } from '../../modules/board/board-view.js';
21
20
  import { reaches } from '../../../../shared/graph.js';
22
21
  import { depToNodeKey, formatDepForTarget, isPending, nodeKeyOf, parseDep } from './model.js';
23
22
  import type { DagLinkMode, DagMode, DagNode, DagPosMap, DepToken, LinkPreview } from './model.js';
23
+ import { patchTaskItem } from './api.js';
24
24
  import { FILTER_ALL, NODE_W, PAD_X, PAD_Y, ROW_H, clearPos, defaultLayout, loadPos } from './layout.js';
25
25
  import { canvasPoint, computeEdges, cubic, portOriginOf } from './edges.js';
26
26
  import { useDagInteractions } from './use-interactions.js';
@@ -204,10 +204,7 @@ export default function DagPanel({ dirKey, groupId }: DagPanelProps) {
204
204
  const payload: { blockBy?: DepToken[] | string; gate?: boolean; duration?: string; clearGoal?: boolean } = { ...body };
205
205
  if (Array.isArray(payload.blockBy)) payload.blockBy = payload.blockBy.join(',');
206
206
  const scope = node.topicIsGlobal ? { key: node.topicKey } : { cwd: node.topicCwd };
207
- await api('/api/localtasks/item', {
208
- method: 'PATCH',
209
- body: { ...scope, id: Number(node.id), ...payload },
210
- });
207
+ await patchTaskItem({ ...scope, id: Number(node.id), ...payload });
211
208
  if (okMsg) toast(okMsg);
212
209
  if (refreshLocal) await refreshLocal();
213
210
  } catch (e) {
@@ -0,0 +1,135 @@
1
+ // dir 页的 API 收口:页面组件(index / task-actions / task-feedback / task)只消费
2
+ // 这里的函数,不直接调 api()(模板约定)。
3
+ //
4
+ // 只搬调用不改语义:路径 / 方法 / body 与收口前逐字一致。
5
+ // scope:主题定位二选一——{ cwd } 或 { key }(全局池用 key=__GLOBAL__)。
6
+ import { api } from '../../api/client.js';
7
+ import type { ChainApi, GoalLogData } from './task-utils.js';
8
+
9
+ /** 主题定位:cwd(目录主题)或 key(含全局池)。 */
10
+ export type TaskScope = { cwd?: string; key?: string };
11
+
12
+ /** 变更类返回的公共形状:task=落地后的任务;key/moved/name=落点与归属迁移提示。 */
13
+ export interface TaskMutationResult {
14
+ task?: { id?: number | string; text?: string };
15
+ id?: number | string;
16
+ key?: string;
17
+ moved?: boolean;
18
+ name?: string;
19
+ }
20
+
21
+ /** 批量操作返回:count=处理条数;skipped/missing=跳过 / 未找到的编号。 */
22
+ export interface TaskBulkResult {
23
+ count?: number;
24
+ skipped?: Array<number | string>;
25
+ missing?: Array<number | string>;
26
+ }
27
+
28
+ /** 任务链(GET /api/localtasks/chain?<q>)。 */
29
+ export function getTaskChain(query: string): Promise<ChainApi> {
30
+ return api(`/api/localtasks/chain?${query}`);
31
+ }
32
+
33
+ /** 时间目标日志(GET /api/localtasks/timegoal-log?<q>)。 */
34
+ export function getGoalLog(query: string): Promise<GoalLogData> {
35
+ return api(`/api/localtasks/timegoal-log?${query}`);
36
+ }
37
+
38
+ /** 队列内调序(PATCH /api/localtasks/reorder;beforeId / afterId 二选一)。 */
39
+ export function reorderTask(
40
+ body: TaskScope & { id: number; beforeId?: number | string; afterId?: number | string },
41
+ ): Promise<unknown> {
42
+ return api('/api/localtasks/reorder', { method: 'PATCH', body });
43
+ }
44
+
45
+ export interface PatchTaskItemBody extends TaskScope {
46
+ id: number;
47
+ text?: string;
48
+ gate?: boolean;
49
+ blockBy?: string | number[];
50
+ duration?: string;
51
+ clearGoal?: boolean;
52
+ goalPrompt?: string;
53
+ summary?: string;
54
+ [k: string]: unknown;
55
+ }
56
+
57
+ /** 编辑单个本地任务(PATCH /api/localtasks/item;CLI localtask update 等价)。 */
58
+ export function patchTaskItem(body: PatchTaskItemBody): Promise<TaskMutationResult> {
59
+ return api('/api/localtasks/item', { method: 'PATCH', body });
60
+ }
61
+
62
+ /**
63
+ * 按查询串查单条任务(GET /api/localtasks/item?<q>)。
64
+ * 找不到或出错返回 null(调用方以 null 判「没有这条」)。
65
+ */
66
+ export function findTaskItem(query: string): Promise<any> {
67
+ return api(`/api/localtasks/item?${query}`).catch(() => null);
68
+ }
69
+
70
+ export interface AddTaskBody extends TaskScope {
71
+ global?: boolean;
72
+ text: string;
73
+ forkOf?: string;
74
+ forkKind?: string;
75
+ board?: string;
76
+ project?: string;
77
+ [k: string]: unknown;
78
+ }
79
+
80
+ /** 加任务(POST /api/localtasks;CLI localtask add 等价)。 */
81
+ export function addTask(body: AddTaskBody): Promise<any> {
82
+ return api('/api/localtasks', { method: 'POST', body });
83
+ }
84
+
85
+ /** 重开 / 追加反馈(POST /api/localtasks/reopen;kind=reopen|comment)。 */
86
+ export function postReopen(body: Record<string, unknown>): Promise<TaskMutationResult> {
87
+ return api('/api/localtasks/reopen', { method: 'POST', body });
88
+ }
89
+
90
+ /** 删除单个本地任务(DELETE /api/localtasks/item;purge=true 彻底删除)。 */
91
+ export function removeTaskItem(body: TaskScope & { id: number; purge?: boolean }): Promise<unknown> {
92
+ return api('/api/localtasks/item', { method: 'DELETE', body });
93
+ }
94
+
95
+ /** 批量软删除(DELETE /api/localtasks/items)。 */
96
+ export function removeManyTasks(body: TaskScope & { ids: unknown[] }): Promise<TaskBulkResult> {
97
+ return api('/api/localtasks/items', { method: 'DELETE', body });
98
+ }
99
+
100
+ /** 批量取消(POST /api/localtasks/items/cancel)。 */
101
+ export function cancelManyTasks(body: TaskScope & { ids: unknown[] }): Promise<TaskBulkResult> {
102
+ return api('/api/localtasks/items/cancel', { method: 'POST', body });
103
+ }
104
+
105
+ /** 批量收口(POST /api/localtasks/items/close;status=done|cancelled)。 */
106
+ export function closeManyTasks(
107
+ body: TaskScope & { ids: unknown[]; status: string; summary?: string },
108
+ ): Promise<TaskBulkResult> {
109
+ return api('/api/localtasks/items/close', { method: 'POST', body });
110
+ }
111
+
112
+ /** 恢复软删除的任务(POST /api/localtasks/tasks/restore)。 */
113
+ export function restoreTaskItem(body: TaskScope & { id: number }): Promise<unknown> {
114
+ return api('/api/localtasks/tasks/restore', { method: 'POST', body });
115
+ }
116
+
117
+ /** 克隆任务(POST /api/localtasks/clone)。 */
118
+ export function cloneTask(body: { id: number; cwd?: string }): Promise<TaskMutationResult> {
119
+ return api('/api/localtasks/clone', { method: 'POST', body });
120
+ }
121
+
122
+ /** 派生任务(POST /api/localtasks/fork)。 */
123
+ export function forkTask(body: { id: number; cwd?: string }): Promise<TaskMutationResult> {
124
+ return api('/api/localtasks/fork', { method: 'POST', body });
125
+ }
126
+
127
+ /** 任务附件清单(GET /api/localtasks/attachments?<q>;返回原样透出,调用方自行取字段)。 */
128
+ export function getTaskAttachments(query: string): Promise<any> {
129
+ return api(`/api/localtasks/attachments?${query}`);
130
+ }
131
+
132
+ /** 领取预览(POST /api/localtasks/preview;不落任何状态)。 */
133
+ export function previewTask(body: Record<string, unknown>): Promise<any> {
134
+ return api('/api/localtasks/preview', { method: 'POST', body });
135
+ }
@@ -1,6 +1,17 @@
1
1
  // 目录面板 —— 简介(统一 Introduction)+ 子任务表。
2
2
  import { useMemo, useRef, useState } from 'react';
3
- import { api } from '../../api/client.js';
3
+ import {
4
+ addTask,
5
+ cancelManyTasks,
6
+ closeManyTasks,
7
+ findTaskItem,
8
+ patchTaskItem,
9
+ removeManyTasks,
10
+ removeTaskItem,
11
+ reorderTask,
12
+ postReopen,
13
+ restoreTaskItem,
14
+ } from './api.js';
4
15
  import { useToast } from '../../components/toast/index.jsx';
5
16
  import { useDialog, PopMenu } from '../../components/popup/index.jsx';
6
17
  import { GLOBAL_KEY, isGroupTask } from '../../modules/board/board-view.js';
@@ -95,20 +106,14 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
95
106
  // 拖动排序:服务端只许 pending ↔ pending 换位(已领取是固定历史),UI 侧已同口径过滤
96
107
  const moveTask = (t: { id: number }, targetId: number | string, zone: DropZone) => {
97
108
  guard(async () => {
98
- await api('/api/localtasks/reorder', {
99
- method: 'PATCH',
100
- body: { ...scopeBody(), id: t.id, ...(zone === 'before' ? { beforeId: targetId } : { afterId: targetId }) },
101
- });
109
+ await reorderTask({ ...scopeBody(), id: t.id, ...(zone === 'before' ? { beforeId: targetId } : { afterId: targetId }) });
102
110
  refreshLocal?.();
103
111
  });
104
112
  };
105
113
 
106
114
  const toggleGate = (t: LocalTask) => {
107
115
  guard(async () => {
108
- await api('/api/localtasks/item', {
109
- method: 'PATCH',
110
- body: { ...scopeBody(), id: t.id, gate: !t.blocksFollowing },
111
- });
116
+ await patchTaskItem({ ...scopeBody(), id: t.id, gate: !t.blocksFollowing });
112
117
  toast(!t.blocksFollowing ? `#${t.id} 已设为闸门——挡住所有后续待领取任务` : `#${t.id} 闸门已取消`);
113
118
  refreshLocal?.();
114
119
  });
@@ -119,7 +124,7 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
119
124
  const saveDag = async (patches: DagPatchInput[]) => {
120
125
  try {
121
126
  for (const p of patches) {
122
- await api('/api/localtasks/item', { method: 'PATCH', body: { ...scopeBody(), ...p } });
127
+ await patchTaskItem({ ...scopeBody(), ...p });
123
128
  }
124
129
  toast('编排已保存');
125
130
  refreshLocal?.();
@@ -211,7 +216,7 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
211
216
  const q = isGlobal
212
217
  ? `key=${encodeURIComponent(GLOBAL_KEY)}&id=${Number(t.id)}`
213
218
  : `cwd=${encodeURIComponent(topic?.cwd || '')}&id=${Number(t.id)}`;
214
- return api(`/api/localtasks/item?${q}`).catch(() => null);
219
+ return findTaskItem(q);
215
220
  };
216
221
 
217
222
  const reopenTask = (t: LocalTask | null) => {
@@ -255,12 +260,11 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
255
260
  toast('写一下反馈');
256
261
  return;
257
262
  }
258
- const res = await api('/api/localtasks', {
259
- method: 'POST',
260
- body: isGlobal
263
+ const res = await addTask(
264
+ isGlobal
261
265
  ? { global: true, text, forkOf: String(t.id), forkKind: 'reopen' }
262
266
  : { cwd: topic?.cwd, text, forkOf: String(t.id), forkKind: 'reopen' },
263
- });
267
+ );
264
268
  const newId = String(res?.task?.id ?? res?.id ?? '');
265
269
  const landedKey = res?.key || dirKey;
266
270
  if (newId) saveDoc(docIdOf(scopeOf(landedKey), newId), { body: text });
@@ -271,20 +275,17 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
271
275
 
272
276
  // 未完成:就地回写(#74 reopen)。#79:纯反馈不传 text——服务端把反馈段
273
277
  // 原子追加到盘上当前正文;「只重开不改正文」(无反馈)维持只翻状态。
274
- const res = await api('/api/localtasks/reopen', {
275
- method: 'POST',
276
- body: {
277
- ...scopeBody(),
278
- id: t.id,
279
- kind: 'reopen',
280
- ...(fb
281
- ? {
282
- feedback: fb,
283
- feedbackHeading: PLAIN_FEEDBACK_HEADING,
284
- feedbackBold: false,
285
- }
286
- : {}),
287
- },
278
+ const res = await postReopen({
279
+ ...scopeBody(),
280
+ id: t.id,
281
+ kind: 'reopen',
282
+ ...(fb
283
+ ? {
284
+ feedback: fb,
285
+ feedbackHeading: PLAIN_FEEDBACK_HEADING,
286
+ feedbackBold: false,
287
+ }
288
+ : {}),
288
289
  });
289
290
  const landedKey = res?.key || dirKey;
290
291
  const sameId = String(res?.task?.id ?? t.id);
@@ -309,10 +310,7 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
309
310
  });
310
311
  if (!ok) return;
311
312
  guard(async () => {
312
- await api('/api/localtasks/item', {
313
- method: 'DELETE',
314
- body: isGlobal ? { key: GLOBAL_KEY, id: t.id } : { cwd: topic?.cwd, id: t.id },
315
- });
313
+ await removeTaskItem(isGlobal ? { key: GLOBAL_KEY, id: t.id } : { cwd: topic?.cwd, id: t.id });
316
314
  toast(`已删除「${title.replace(/^#\s*/, '')}」`);
317
315
  if (model) {
318
316
  // workspace.findOpenPanel 的返回类型尚未收口(被推断成 null),按实际契约窄化
@@ -335,10 +333,7 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
335
333
  });
336
334
  if (!ok) return false;
337
335
  return guard(async () => {
338
- const res = await api('/api/localtasks/items', {
339
- method: 'DELETE',
340
- body: { ...scopeBody(), ids: list },
341
- });
336
+ const res = await removeManyTasks({ ...scopeBody(), ids: list });
342
337
  toast(`已删除 ${res?.count ?? list.length} 条任务`);
343
338
  refreshLocal?.();
344
339
  return true;
@@ -355,10 +350,7 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
355
350
  });
356
351
  if (!ok) return false;
357
352
  return guard(async () => {
358
- const res = await api('/api/localtasks/items/cancel', {
359
- method: 'POST',
360
- body: { ...scopeBody(), ids: list },
361
- });
353
+ const res = await cancelManyTasks({ ...scopeBody(), ids: list });
362
354
  const skipped = res?.skipped?.length || 0;
363
355
  toast(`已取消 ${res?.count ?? 0} 条任务${skipped ? `,跳过 ${skipped} 条` : ''}`);
364
356
  refreshLocal?.();
@@ -376,10 +368,7 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
376
368
  });
377
369
  if (!ok) return false;
378
370
  return guard(async () => {
379
- const res = await api('/api/localtasks/items/close', {
380
- method: 'POST',
381
- body: { ...scopeBody(), ids: list, status: 'done' },
382
- });
371
+ const res = await closeManyTasks({ ...scopeBody(), ids: list, status: 'done' });
383
372
  const skipped = res?.skipped?.length || 0;
384
373
  toast(`已标为完成 ${res?.count ?? 0} 条任务${skipped ? `,跳过 ${skipped} 条` : ''}`);
385
374
  refreshLocal?.();
@@ -398,10 +387,7 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
398
387
  const restoreDeleted = (t: LocalTask | null) => {
399
388
  if (!t) return;
400
389
  guard(async () => {
401
- await api('/api/localtasks/tasks/restore', {
402
- method: 'POST',
403
- body: isGlobal ? { key: GLOBAL_KEY, id: t.id } : { cwd: topic?.cwd, id: t.id },
404
- });
390
+ await restoreTaskItem(isGlobal ? { key: GLOBAL_KEY, id: t.id } : { cwd: topic?.cwd, id: t.id });
405
391
  toast(`已恢复 #${t.id}「${(t.text || '').split('\n').find((l) => l.trim())?.replace(/^#\s*/, '') || ''}」`);
406
392
  refreshLocal?.();
407
393
  });
@@ -418,10 +404,7 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
418
404
  });
419
405
  if (!ok) return;
420
406
  guard(async () => {
421
- await api('/api/localtasks/item', {
422
- method: 'DELETE',
423
- body: { ...(isGlobal ? { key: GLOBAL_KEY } : { cwd: topic?.cwd }), id: t.id, purge: true },
424
- });
407
+ await removeTaskItem({ ...(isGlobal ? { key: GLOBAL_KEY } : { cwd: topic?.cwd }), id: t.id, purge: true });
425
408
  toast(`已彻底删除 #${t.id}`);
426
409
  refreshLocal?.();
427
410
  });
@@ -453,10 +436,7 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
453
436
  const name = file.name.replace(/\.md$/i, '');
454
437
  await guard(async () => {
455
438
  const bodyText = text.startsWith('#') ? text : `# ${name}\n\n${text}`;
456
- const res = await api('/api/localtasks', {
457
- method: 'POST',
458
- body: isGlobal ? { global: true, text: bodyText } : { cwd: topic?.cwd, text: bodyText },
459
- });
439
+ const res = await addTask(isGlobal ? { global: true, text: bodyText } : { cwd: topic?.cwd, text: bodyText });
460
440
  toast(`已导入:${file.name}`);
461
441
  refreshLocal?.();
462
442
  const newId = res?.task?.id ?? res?.id;