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.
- package/CHANGELOG.md +43 -0
- package/package.json +1 -1
- package/src/modules/auth/actions/auth-login.ts +13 -6
- package/src/modules/auth/actions/auth-logout.ts +11 -6
- package/src/modules/auth/actions/auth-me.ts +11 -6
- package/src/modules/auth/actions/auth-status.ts +11 -6
- package/src/modules/bundled/actions/bundled-get.ts +14 -6
- package/src/modules/bundled/actions/bundled-groups.ts +11 -6
- package/src/modules/bundled/actions/bundled-install.ts +15 -6
- package/src/modules/bundled/actions/bundled-list.ts +11 -6
- package/src/modules/db/actions/db-backup.ts +12 -6
- package/src/modules/db/actions/db-migrate.ts +12 -6
- package/src/modules/db/actions/db-status.ts +11 -6
- package/src/modules/db/actions/db-verify.ts +11 -6
- package/src/modules/docs/actions/doc-add.ts +14 -6
- package/src/modules/docs/actions/doc-attach-note.ts +13 -6
- package/src/modules/docs/actions/doc-attach.ts +20 -6
- package/src/modules/docs/actions/doc-attachments.ts +11 -6
- package/src/modules/docs/actions/doc-detach.ts +13 -6
- package/src/modules/docs/actions/doc-get.ts +11 -6
- package/src/modules/docs/actions/doc-list.ts +11 -6
- package/src/modules/docs/actions/doc-remove.ts +11 -6
- package/src/modules/docs/actions/doc-update.ts +14 -6
- package/src/modules/docs/actions/docs-bind.ts +15 -6
- package/src/modules/docs/actions/docs-index.ts +11 -6
- package/src/modules/docs/actions/docs-link.ts +16 -6
- package/src/modules/docs/actions/docs-notebind.ts +15 -6
- package/src/modules/docs/actions/docs-seed.ts +11 -6
- package/src/modules/file/actions/file-content.ts +18 -10
- package/src/modules/file/actions/file-get.ts +12 -6
- package/src/modules/file/actions/file-list.ts +13 -6
- package/src/modules/file/actions/file-orphans.ts +11 -6
- package/src/modules/file/actions/file-prune.ts +12 -6
- package/src/modules/file/actions/file-remove.ts +12 -6
- package/src/modules/file/actions/file-sync.ts +15 -6
- package/src/modules/file/actions/file-upload.ts +17 -6
- package/src/modules/localtask/actions/localtask-add.ts +26 -6
- package/src/modules/localtask/actions/localtask-attach-note.ts +15 -6
- package/src/modules/localtask/actions/localtask-attach.ts +24 -6
- package/src/modules/localtask/actions/localtask-attachments.ts +13 -6
- package/src/modules/localtask/actions/localtask-cancel.ts +12 -6
- package/src/modules/localtask/actions/localtask-cancelMany.ts +13 -6
- package/src/modules/localtask/actions/localtask-chain.ts +13 -6
- package/src/modules/localtask/actions/localtask-claim.ts +14 -6
- package/src/modules/localtask/actions/localtask-clone.ts +13 -6
- package/src/modules/localtask/actions/localtask-closeMany.ts +15 -6
- package/src/modules/localtask/actions/localtask-config.ts +23 -8
- package/src/modules/localtask/actions/localtask-detach.ts +15 -6
- package/src/modules/localtask/actions/localtask-done.ts +14 -6
- package/src/modules/localtask/actions/localtask-events.ts +19 -9
- package/src/modules/localtask/actions/localtask-fork.ts +13 -6
- package/src/modules/localtask/actions/localtask-get.ts +13 -6
- package/src/modules/localtask/actions/localtask-importRemote.ts +20 -9
- package/src/modules/localtask/actions/localtask-list.ts +11 -6
- package/src/modules/localtask/actions/localtask-presence.ts +11 -6
- package/src/modules/localtask/actions/localtask-preview.ts +15 -6
- package/src/modules/localtask/actions/localtask-prune.ts +12 -6
- package/src/modules/localtask/actions/localtask-remove.ts +14 -6
- package/src/modules/localtask/actions/localtask-removeMany.ts +14 -6
- package/src/modules/localtask/actions/localtask-reopen.ts +22 -7
- package/src/modules/localtask/actions/localtask-reorder.ts +17 -6
- package/src/modules/localtask/actions/localtask-task-restore.ts +13 -6
- package/src/modules/localtask/actions/localtask-timegoalLog.ts +13 -6
- package/src/modules/localtask/actions/localtask-topic-add.ts +12 -6
- package/src/modules/localtask/actions/localtask-topic-remove.ts +13 -6
- package/src/modules/localtask/actions/localtask-topic-removeMany.ts +14 -6
- package/src/modules/localtask/actions/localtask-update.ts +24 -6
- package/src/modules/localtask/actions/localtask-wait.ts +15 -6
- package/src/modules/localtask/actions/task-move.ts +23 -6
- package/src/modules/repos/actions/board-add.ts +12 -6
- package/src/modules/repos/actions/board-assign.ts +14 -6
- package/src/modules/repos/actions/board-export.ts +11 -6
- package/src/modules/repos/actions/board-get.ts +11 -6
- package/src/modules/repos/actions/board-import.ts +17 -7
- package/src/modules/repos/actions/board-list.ts +11 -6
- package/src/modules/repos/actions/board-note.ts +13 -6
- package/src/modules/repos/actions/board-prefix.ts +12 -6
- package/src/modules/repos/actions/board-prune.ts +13 -6
- package/src/modules/repos/actions/board-rekey.ts +13 -6
- package/src/modules/repos/actions/board-remove.ts +11 -6
- package/src/modules/repos/actions/board-update.ts +13 -6
- package/src/modules/repos/actions/repo-add.ts +19 -6
- package/src/modules/repos/actions/repo-bind-topics.ts +12 -6
- package/src/modules/repos/actions/repo-bind.ts +14 -6
- package/src/modules/repos/actions/repo-clone.ts +16 -6
- package/src/modules/repos/actions/repo-detect.ts +11 -6
- package/src/modules/repos/actions/repo-doc-add.ts +17 -6
- package/src/modules/repos/actions/repo-doc-list.ts +11 -6
- package/src/modules/repos/actions/repo-doc-remove.ts +12 -6
- package/src/modules/repos/actions/repo-export.ts +14 -6
- package/src/modules/repos/actions/repo-get.ts +11 -6
- package/src/modules/repos/actions/repo-import-diff.ts +12 -6
- package/src/modules/repos/actions/repo-import.ts +16 -6
- package/src/modules/repos/actions/repo-key-migrate.ts +11 -6
- package/src/modules/repos/actions/repo-key-refresh.ts +13 -6
- package/src/modules/repos/actions/repo-key-set.ts +13 -6
- package/src/modules/repos/actions/repo-knowledge.ts +12 -6
- package/src/modules/repos/actions/repo-list.ts +11 -6
- package/src/modules/repos/actions/repo-open.ts +11 -6
- package/src/modules/repos/actions/repo-ref-add.ts +15 -6
- package/src/modules/repos/actions/repo-ref-backfill.ts +12 -6
- package/src/modules/repos/actions/repo-ref-check.ts +11 -6
- package/src/modules/repos/actions/repo-ref-clone.ts +18 -6
- package/src/modules/repos/actions/repo-ref-note.ts +14 -6
- package/src/modules/repos/actions/repo-ref-of.ts +11 -6
- package/src/modules/repos/actions/repo-ref-sync.ts +12 -6
- package/src/modules/repos/actions/repo-remote-check.ts +12 -6
- package/src/modules/repos/actions/repo-remote-list.ts +11 -6
- package/src/modules/repos/actions/repo-remote-pick.ts +12 -6
- package/src/modules/repos/actions/repo-remote.ts +13 -6
- package/src/modules/repos/actions/repo-remove.ts +11 -6
- package/src/modules/repos/actions/repo-scan.ts +13 -6
- package/src/modules/repos/actions/repo-update.ts +23 -6
- package/src/modules/setting/actions/setting-get.ts +11 -6
- package/src/modules/setting/actions/setting-set.ts +14 -6
- package/src/modules/system/actions/bootstrap.ts +9 -7
- package/src/modules/system/actions/health.ts +8 -6
- package/src/modules/system/actions/routes.ts +13 -6
- package/src/modules/system/routes.ts +1 -1
- package/src/modules/tasktool/actions/timegoal-check.ts +13 -6
- package/src/modules/tasktool/actions/timegoal-clear.ts +11 -6
- package/src/modules/tasktool/actions/timegoal-list.ts +11 -6
- package/src/modules/tasktool/actions/timegoal-log.ts +11 -6
- package/src/modules/tasktool/actions/timegoal-prune.ts +11 -6
- package/src/modules/tasktool/actions/timegoal-set.ts +13 -6
- package/src/modules/tasktool/actions/timegoal-show.ts +12 -6
- package/src/modules/tasktool/actions/timegoal-update.ts +13 -6
- package/src/modules/templates/actions/templates-add.ts +19 -6
- package/src/modules/templates/actions/templates-default.ts +15 -6
- package/src/modules/templates/actions/templates-list.ts +13 -6
- package/src/modules/templates/actions/templates-remove.ts +11 -6
- package/src/modules/templates/actions/templates-update.ts +17 -6
- package/src/modules/todo/actions/group-add.ts +12 -6
- package/src/modules/todo/actions/group-current.ts +11 -6
- package/src/modules/todo/actions/group-get.ts +11 -6
- package/src/modules/todo/actions/group-list.ts +11 -6
- package/src/modules/todo/actions/group-members.ts +11 -6
- package/src/modules/todo/actions/group-remove.ts +11 -6
- package/src/modules/todo/actions/group-update.ts +13 -6
- package/src/modules/todo/actions/group-use.ts +11 -6
- package/src/modules/todo/actions/prompt-get.ts +12 -6
- package/src/modules/todo/actions/prompt-remove.ts +12 -6
- package/src/modules/todo/actions/prompt-set.ts +13 -6
- package/src/modules/todo/actions/todo-add.ts +13 -6
- package/src/modules/todo/actions/todo-archive.ts +12 -6
- package/src/modules/todo/actions/todo-attach.ts +19 -6
- package/src/modules/todo/actions/todo-attachments.ts +14 -6
- package/src/modules/todo/actions/todo-done.ts +15 -6
- package/src/modules/todo/actions/todo-freeze.ts +14 -6
- package/src/modules/todo/actions/todo-get.ts +14 -6
- package/src/modules/todo/actions/todo-list.ts +13 -6
- package/src/modules/todo/actions/todo-remove.ts +14 -6
- package/src/modules/todo/actions/todo-unfreeze.ts +14 -6
- package/src/modules/todo/actions/todo-update.ts +17 -6
- package/src/modules/todo/actions/topic-add.ts +12 -6
- package/src/modules/todo/actions/topic-list.ts +11 -6
- package/src/modules/todo/actions/topic-remove.ts +12 -6
- package/src/runtime/action-base.ts +41 -1
- package/src/runtime/action-decorator.ts +28 -13
- package/src/runtime/codegen.ts +26 -41
- package/src/runtime/registry.ts +2 -2
- package/src/web/frontend/api/client.generated.ts +550 -698
- package/src/web/frontend/page/cloud/api.ts +99 -0
- package/src/web/frontend/page/cloud/index.tsx +13 -32
- package/src/web/frontend/page/dag/api.ts +20 -0
- package/src/web/frontend/page/dag/index.tsx +2 -5
- package/src/web/frontend/page/dir/api.ts +135 -0
- package/src/web/frontend/page/dir/index.tsx +37 -57
- package/src/web/frontend/page/dir/task-actions.ts +39 -59
- package/src/web/frontend/page/dir/task-chain.ts +2 -2
- package/src/web/frontend/page/dir/task-feedback.ts +19 -23
- package/src/web/frontend/page/dir/task-goal.ts +3 -3
- package/src/web/frontend/page/dir/task.tsx +3 -3
- package/src/web/frontend/page/doc/api.ts +82 -0
- package/src/web/frontend/page/doc/index.tsx +29 -32
- package/src/web/frontend/page/group/api.ts +24 -0
- package/src/web/frontend/page/group/index.tsx +7 -16
- package/src/web/frontend/page/overview/api.ts +16 -0
- package/src/web/frontend/page/overview/index.tsx +2 -2
- package/src/web/frontend/page/progress/api.ts +20 -0
- package/src/web/frontend/page/progress/index.tsx +3 -6
- package/src/web/frontend/page/refs/api.ts +14 -0
- package/src/web/frontend/page/refs/index.tsx +2 -4
- package/src/web/frontend/page/repos/api.ts +197 -0
- package/src/web/frontend/page/repos/bind-modals.tsx +4 -7
- package/src/web/frontend/page/repos/board-admin.tsx +6 -6
- package/src/web/frontend/page/repos/doc-search-modal.tsx +4 -4
- package/src/web/frontend/page/repos/index.tsx +10 -14
- package/src/web/frontend/page/repos/pending-section.tsx +7 -13
- package/src/web/frontend/page/repos/ref-panel.tsx +9 -14
- package/src/web/frontend/page/repos/remote-modal.tsx +4 -28
- package/src/web/frontend/page/repos/repo-form-modal.tsx +4 -4
- package/src/web/frontend/page/settings/api.ts +29 -0
- package/src/web/frontend/page/settings/index.tsx +3 -3
- package/src/web/frontend/page/settings/prompt-templates-section.tsx +4 -4
- package/src/web/frontend/page/settings/sidebar-section.tsx +2 -2
- package/src/web/public/assets/Introduction-Du_dycft.js +6 -0
- package/src/web/public/assets/{bar-B9WWmCpt.js → bar-B52NTf_v.js} +1 -1
- package/src/web/public/assets/cloud-Droja_aT.js +3 -0
- package/src/web/public/assets/{composer-panel-ByezS8Xv.js → composer-panel-DpiU2h50.js} +1 -1
- package/src/web/public/assets/dag-Ca-wjIxQ.js +1 -0
- package/src/web/public/assets/{deleted-panel-BcbtctNF.js → deleted-panel-K9GgfR8t.js} +1 -1
- package/src/web/public/assets/dir-DacRpcBt.js +5 -0
- package/src/web/public/assets/group-TPuU-QVc.js +2 -0
- package/src/web/public/assets/{index-D8MvtVAm.js → index-BkLkooKe.js} +2 -2
- package/src/web/public/assets/{md-history-BqZvzWiD.js → md-history-0GBWw4qr.js} +1 -1
- package/src/web/public/assets/overview-B3kHI66i.js +1 -0
- package/src/web/public/assets/progress-CdhFz0Lz.js +3 -0
- package/src/web/public/assets/refs-BDxfuH6R.js +1 -0
- package/src/web/public/assets/repos-C8jRM7wS.js +15 -0
- package/src/web/public/assets/{route-crumb-CWVu80du.js → route-crumb-QvahotvN.js} +1 -1
- package/src/web/public/assets/settings-BBcdGLTc.js +1 -0
- package/src/web/public/assets/{status-tag-DRl9E2Os.js → status-tag-BheHByek.js} +1 -1
- package/src/web/public/assets/task-CUkQaLBZ.js +11 -0
- package/src/web/public/assets/task-utils-_JAWRAz6.js +12 -0
- package/src/web/public/assets/{templates-Df__0k-F.js → templates-CbRyW3PJ.js} +1 -1
- package/src/web/public/assets/{tool-bar-Cv7f6p4v.js → tool-bar-BAmT-BI-.js} +1 -1
- package/src/web/public/index.html +1 -1
- package/src/modules/auth/schemas.ts +0 -27
- package/src/modules/bundled/schemas.ts +0 -32
- package/src/modules/db/schemas.ts +0 -27
- package/src/modules/docs/schemas.ts +0 -107
- package/src/modules/file/schemas.ts +0 -61
- package/src/modules/localtask/schemas.ts +0 -310
- package/src/modules/repos/schemas.ts +0 -310
- package/src/modules/setting/schemas.ts +0 -18
- package/src/modules/system/schemas.ts +0 -29
- package/src/modules/tasktool/schemas.ts +0 -52
- package/src/modules/templates/schemas.ts +0 -50
- package/src/modules/todo/schemas.ts +0 -177
- package/src/web/public/assets/Introduction-aQCeCLrV.js +0 -6
- package/src/web/public/assets/cloud-C4b8SU7C.js +0 -3
- package/src/web/public/assets/dag-jvrjx4i7.js +0 -1
- package/src/web/public/assets/dir-B82XBb1J.js +0 -5
- package/src/web/public/assets/group-BPUOO_QM.js +0 -2
- package/src/web/public/assets/overview-DMihuyzh.js +0 -1
- package/src/web/public/assets/progress-D-rMgz3w.js +0 -3
- package/src/web/public/assets/refs-D21jmrn6.js +0 -1
- package/src/web/public/assets/repos-B94tMDGs.js +0 -15
- package/src/web/public/assets/settings-DgTt4JG5.js +0 -1
- package/src/web/public/assets/task-B2x5GoV3.js +0 -11
- package/src/web/public/assets/task-utils-By8gLpHY.js +0 -12
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,49 @@
|
|
|
2
2
|
|
|
3
3
|
本文件记录对外可见的变更。格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/)。
|
|
4
4
|
|
|
5
|
+
## [0.48.2] - 2026-11-12 zod 契约内联进 action 文件(#178 第 4 轮)
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- **不再有独立的 `schemas.ts`**:每条 action 的 zod 契约(运行期契约)直接声明在
|
|
10
|
+
自己的 action 文件里,模块私有、就在类上方,命名为 `input`。12 个 `schemas.ts`
|
|
11
|
+
(1201 行)随之删除,154 个 action 文件各带一份契约。
|
|
12
|
+
契约内容**逐字保留**——`.describe()` 是 CLI 用法串与 help 文案的来源,动了就改口径。
|
|
13
|
+
- **前端入参类型改为从 action 类反推**(`z.input<InstanceType<typeof XAction>['_input']>`):
|
|
14
|
+
类型经基类泛型模板流到前端,契约常量降级为「文件内的实现细节」,
|
|
15
|
+
生成物不再 import 后端契约文件。
|
|
16
|
+
- **删掉 `<camelCase(actionId)>Input` 命名约定**:旧方案靠约定拼 import 名,
|
|
17
|
+
约定破了会生成指向不存在符号的代码;现在约定不再存在,也就没有破的可能。
|
|
18
|
+
|
|
19
|
+
### Notes
|
|
20
|
+
|
|
21
|
+
- 纯结构调整,对外行为不变(契约内容与位置语义不变:字段、用法串、help 文案均不变)。
|
|
22
|
+
- 验证:node 侧 strict 0 错误 / 生成物及传递依赖 web 编译 0 错误 / eslint 0 error /
|
|
23
|
+
unit 906 / smoke 194。
|
|
24
|
+
|
|
25
|
+
## [0.48.1] - 2026-11-11 action 入参泛型化(#177 第 3 轮)
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- **action 入参类型走基类泛型模板**:`ActionBase<TInput>` 绑定 schema,
|
|
30
|
+
handler 统一写 `override run(ctx: ActionInput<this['_input']>)`——入参类型由类上的
|
|
31
|
+
类型实参推导,**schema 只声明一次**,154 个 action 文件不再手写 `z.output<typeof …>`、
|
|
32
|
+
也不再落 `ctx: any`(迁移器生成的那 151 条全部清掉)。
|
|
33
|
+
- **方法名统一为 `run`**(原按动作语义各叫各的):`@action` 装饰器只收元数据,
|
|
34
|
+
运行期分派本来就是走 run 闭包,方法名不外泄(`client.generated.ts` 的类型锚点
|
|
35
|
+
随之从 `['get']` 之类改为 `['run']`,重新 `pnpm gen` 即可)。
|
|
36
|
+
- **类型化顺带抓出 6 处「读未声明键」的死路径**(zod 会剥掉未声明键,这些读取恒为
|
|
37
|
+
undefined):`localtask.config` 的 camel 读法、`localtask.importRemote` 的 `refs`、
|
|
38
|
+
`localtask.reopen` 的 `attachments`、`board.import` 的 `json`。
|
|
39
|
+
**本次只保证运行期行为不变**(收敛到 kebab 或局部 cast + 注释);是否给 schema
|
|
40
|
+
补键以复活这些路径,留给后续裁决。
|
|
41
|
+
|
|
42
|
+
### Notes
|
|
43
|
+
|
|
44
|
+
- 本轮为纯类型层重构,对外行为不变(smoke 194 / unit 906 全绿)。
|
|
45
|
+
- 已知约束:TS 对类成员声明没有上下文类型注入通路(override 与装饰器都试过),
|
|
46
|
+
因此注解必须存在——但它是全项目统一样板,不再重述 schema 结构。
|
|
47
|
+
|
|
5
48
|
## [0.48.0] - 2026-11-11 全仓 TypeScript 毕业(#175)
|
|
6
49
|
|
|
7
50
|
### Changed
|
package/package.json
CHANGED
|
@@ -1,24 +1,31 @@
|
|
|
1
1
|
// auth.login —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
|
|
2
2
|
//
|
|
3
|
-
//
|
|
3
|
+
// 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
|
|
4
4
|
import { action } from '../../../runtime/action-decorator.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
|
|
7
7
|
import { configPathFromEnv as _configPathFromEnv } from '../../../core/config.js';
|
|
8
8
|
import { doLogin } from '../support.js';
|
|
9
9
|
const configPathFromEnv: any = _configPathFromEnv;
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/** auth.login 的入参契约(CLI 与 HTTP 共用同一份)。 */
|
|
12
|
+
const input = z.object({
|
|
13
|
+
email: z.string(),
|
|
14
|
+
password: z.string().optional().describe("密码(省略则交互式隐藏输入)"),
|
|
15
|
+
baseUrl: z.string().optional().describe("后端地址,覆盖默认"),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export class AuthLoginAction extends ActionBase<typeof input> {
|
|
12
19
|
@action({
|
|
13
20
|
id: 'auth.login',
|
|
14
21
|
cli: ['auth', 'login'],
|
|
15
22
|
http: ['POST', '/api/auth/login'],
|
|
16
23
|
summary: '登录并保存 token 到本机配置',
|
|
17
24
|
args: ['email'],
|
|
18
|
-
input
|
|
25
|
+
input,
|
|
19
26
|
render: (d: any) => `已登录: ${d.email}(userId=${d.userId})\n配置: ${configPathFromEnv()}`,
|
|
20
27
|
})
|
|
21
|
-
async
|
|
28
|
+
override async run(ctx: ActionInput<this['_input']>) {
|
|
22
29
|
return doLogin(ctx);
|
|
23
30
|
}
|
|
24
31
|
}
|
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
// auth.logout —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
|
|
2
2
|
//
|
|
3
|
-
//
|
|
3
|
+
// 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
|
|
4
4
|
import { action } from '../../../runtime/action-decorator.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
|
|
7
7
|
import { loadConfig as _loadConfig, saveConfig as _saveConfig } from '../../../core/config.js';
|
|
8
8
|
const loadConfig: any = _loadConfig;
|
|
9
9
|
const saveConfig: any = _saveConfig;
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/** auth.logout 的入参契约(CLI 与 HTTP 共用同一份)。 */
|
|
12
|
+
const input = z.object({
|
|
13
|
+
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export class AuthLogoutAction extends ActionBase<typeof input> {
|
|
12
17
|
@action({
|
|
13
18
|
id: 'auth.logout',
|
|
14
19
|
cli: ['auth', 'logout'],
|
|
15
20
|
http: ['POST', '/api/auth/logout'],
|
|
16
21
|
summary: '清除本机保存的 token',
|
|
17
|
-
input
|
|
22
|
+
input,
|
|
18
23
|
render: (d: any) => (d.was ? `已登出(原账号 ${d.was})` : '本就未登录'),
|
|
19
24
|
})
|
|
20
|
-
async
|
|
25
|
+
override async run(_ctx: ActionInput<this['_input']>) {
|
|
21
26
|
|
|
22
27
|
const before: any = await loadConfig();
|
|
23
28
|
// 只清登录态,保留 baseUrl 与当前工作空间选择
|
|
@@ -1,24 +1,29 @@
|
|
|
1
1
|
// auth.me —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
|
|
2
2
|
//
|
|
3
|
-
//
|
|
3
|
+
// 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
|
|
4
4
|
import { action } from '../../../runtime/action-decorator.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
|
|
7
7
|
import { requireAuth as _requireAuth } from '../../../core/config.js';
|
|
8
8
|
import { userInfo as _userInfo } from '../../../core/kvapi.js';
|
|
9
9
|
const requireAuth: any = _requireAuth;
|
|
10
10
|
const userInfo: any = _userInfo;
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
/** auth.me 的入参契约(CLI 与 HTTP 共用同一份)。 */
|
|
13
|
+
const input = z.object({
|
|
14
|
+
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export class AuthMeAction extends ActionBase<typeof input> {
|
|
13
18
|
@action({
|
|
14
19
|
id: 'auth.me',
|
|
15
20
|
cli: ['auth', 'me'],
|
|
16
21
|
http: ['GET', '/api/auth/me'],
|
|
17
22
|
summary: '向后端确认身份(验证 token 是否仍有效)',
|
|
18
|
-
input
|
|
23
|
+
input,
|
|
19
24
|
render: (d: any) => JSON.stringify(d, null, 2),
|
|
20
25
|
})
|
|
21
|
-
async
|
|
26
|
+
override async run(_ctx: ActionInput<this['_input']>) {
|
|
22
27
|
|
|
23
28
|
await requireAuth();
|
|
24
29
|
const info: any = await userInfo();
|
|
@@ -1,26 +1,31 @@
|
|
|
1
1
|
// auth.status —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
|
|
2
2
|
//
|
|
3
|
-
//
|
|
3
|
+
// 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
|
|
4
4
|
import { action } from '../../../runtime/action-decorator.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
|
|
7
7
|
import { loadConfig as _loadConfig, configPathFromEnv as _configPathFromEnv } from '../../../core/config.js';
|
|
8
8
|
const loadConfig: any = _loadConfig;
|
|
9
9
|
const configPathFromEnv: any = _configPathFromEnv;
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/** auth.status 的入参契约(CLI 与 HTTP 共用同一份)。 */
|
|
12
|
+
const input = z.object({
|
|
13
|
+
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export class AuthStatusAction extends ActionBase<typeof input> {
|
|
12
17
|
@action({
|
|
13
18
|
id: 'auth.status',
|
|
14
19
|
cli: ['auth', 'status'],
|
|
15
20
|
http: ['GET', '/api/auth'],
|
|
16
21
|
summary: '查看本机登录态(不请求后端,离线可用)',
|
|
17
|
-
input
|
|
22
|
+
input,
|
|
18
23
|
render: (d: any) =>
|
|
19
24
|
d.loggedIn
|
|
20
25
|
? `已登录: ${d.email}(userId=${d.userId})\n后端: ${d.baseUrl}\n工作空间: ${d.groupId > 0 ? d.groupId : '默认组'}`
|
|
21
26
|
: `未登录(nx-kv auth login <email>)\n后端: ${d.baseUrl}`,
|
|
22
27
|
})
|
|
23
|
-
async
|
|
28
|
+
override async run(_ctx: ActionInput<this['_input']>) {
|
|
24
29
|
|
|
25
30
|
const cfg: any = await loadConfig();
|
|
26
31
|
return {
|
|
@@ -1,26 +1,34 @@
|
|
|
1
1
|
// bundled.get —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
|
|
2
2
|
//
|
|
3
|
-
//
|
|
3
|
+
// 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
|
|
4
4
|
import { action } from '../../../runtime/action-decorator.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
|
|
7
7
|
import * as serviceNs from '../service.js';
|
|
8
8
|
import { exclusive, renderContent } from '../support.js';
|
|
9
9
|
const service: any = serviceNs;
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/** bundled.get 的入参契约(CLI 与 HTTP 共用同一份)。 */
|
|
12
|
+
const input = z.object({
|
|
13
|
+
name: z.string().optional(),
|
|
14
|
+
ref: z.string().optional(),
|
|
15
|
+
group: z.string().optional().describe("groups.json 里的组名(与 <name> 互斥)"),
|
|
16
|
+
to: z.string().optional(),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export class BundledGetAction extends ActionBase<typeof input> {
|
|
12
20
|
@action({
|
|
13
21
|
id: 'bundled.get',
|
|
14
22
|
cli: ['skill', 'get'],
|
|
15
23
|
http: ['GET', '/api/bundled/content'],
|
|
16
24
|
summary: '输出内置 skill 全文(prefix + sentinel + 正文 + install 状态),并顺手装到本机',
|
|
17
25
|
args: ['name', 'ref'],
|
|
18
|
-
input
|
|
26
|
+
input,
|
|
19
27
|
render: (d: any) => (d.group
|
|
20
28
|
? d.skills.map(renderContent).join('\n\n' + '─'.repeat(60) + '\n\n')
|
|
21
29
|
: renderContent(d)),
|
|
22
30
|
})
|
|
23
|
-
async
|
|
31
|
+
override async run(ctx: ActionInput<this['_input']>) {
|
|
24
32
|
|
|
25
33
|
exclusive(ctx, 'skill get');
|
|
26
34
|
return service.bundledSkillContent({ name: ctx.name, group: ctx.group, ref: ctx.ref, to: ctx.to });
|
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
// bundled.groups —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
|
|
2
2
|
//
|
|
3
|
-
//
|
|
3
|
+
// 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
|
|
4
4
|
import { action } from '../../../runtime/action-decorator.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
|
|
7
7
|
import * as serviceNs from '../service.js';
|
|
8
8
|
const service: any = serviceNs;
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
/** bundled.groups 的入参契约(CLI 与 HTTP 共用同一份)。 */
|
|
11
|
+
const input = z.object({
|
|
12
|
+
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export class BundledGroupsAction extends ActionBase<typeof input> {
|
|
11
16
|
@action({
|
|
12
17
|
id: 'bundled.groups',
|
|
13
18
|
cli: [['skill', 'groups'], ['bundled', 'groups']],
|
|
14
19
|
http: ['GET', '/api/bundled/groups'],
|
|
15
20
|
summary: '列出可装的 group(groups.json 的组名 → 它包含哪些 skill)',
|
|
16
|
-
input
|
|
21
|
+
input,
|
|
17
22
|
render: (d: any) => {
|
|
18
23
|
const head: any = `可装的 group(来源: ${d.source}${d.defaultGroup ? ` · 默认组: ${d.defaultGroup}` : ''}):`;
|
|
19
24
|
const lines: any = [head];
|
|
@@ -25,7 +30,7 @@ export class BundledGroupsAction extends ActionBase {
|
|
|
25
30
|
return lines.join('\n');
|
|
26
31
|
},
|
|
27
32
|
})
|
|
28
|
-
async
|
|
33
|
+
override async run(_ctx: ActionInput<this['_input']>) {
|
|
29
34
|
|
|
30
35
|
return service.groupsInfo();
|
|
31
36
|
|
|
@@ -1,21 +1,30 @@
|
|
|
1
1
|
// bundled.install —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
|
|
2
2
|
//
|
|
3
|
-
//
|
|
3
|
+
// 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
|
|
4
4
|
import { action } from '../../../runtime/action-decorator.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
|
|
7
7
|
import * as serviceNs from '../service.js';
|
|
8
8
|
import { exclusive, renderScoped } from '../support.js';
|
|
9
9
|
const service: any = serviceNs;
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/** bundled.install 的入参契约(CLI 与 HTTP 共用同一份)。 */
|
|
12
|
+
const input = z.object({
|
|
13
|
+
name: z.string().optional(),
|
|
14
|
+
group: z.string().optional().describe("groups.json 里的组名(与 <name> 互斥)"),
|
|
15
|
+
to: z.string().optional(),
|
|
16
|
+
force: z.boolean().optional(),
|
|
17
|
+
all: z.boolean().optional().describe("装 assets/ 下的全部内置 skill(隐式覆盖,不需要 --force)"),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export class BundledInstallAction extends ActionBase<typeof input> {
|
|
12
21
|
@action({
|
|
13
22
|
id: 'bundled.install',
|
|
14
23
|
cli: ['skill', 'install'],
|
|
15
24
|
http: ['POST', '/api/bundled/install'],
|
|
16
25
|
summary: '安装内置 skill 到 skills 目录(默认 nx-kv → ~/.claude/skills;--group <key> 一键装一组;--all 装全部并直接覆盖)',
|
|
17
26
|
args: ['name'],
|
|
18
|
-
input
|
|
27
|
+
input,
|
|
19
28
|
render: (d: any) => {
|
|
20
29
|
// 聚合形状用**显式字段**判别,不做形状嗅探(B04 §实现要点):先 group 后 all
|
|
21
30
|
if (d.group) return renderScoped(`group ${d.group}`, d);
|
|
@@ -28,7 +37,7 @@ export class BundledInstallAction extends ActionBase {
|
|
|
28
37
|
return `${d.replaced ? '已更新' : '已安装'} ${d.name}(${d.files} 个文件)-> ${d.path}`;
|
|
29
38
|
},
|
|
30
39
|
})
|
|
31
|
-
async
|
|
40
|
+
override async run(ctx: ActionInput<this['_input']>) {
|
|
32
41
|
|
|
33
42
|
exclusive(ctx, 'skill install');
|
|
34
43
|
return service.installBundledSkill({
|
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
// bundled.list —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
|
|
2
2
|
//
|
|
3
|
-
//
|
|
3
|
+
// 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
|
|
4
4
|
import { action } from '../../../runtime/action-decorator.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { ActionBase, type ActionInput, type ActionRunMeta } from '../../../runtime/action-base.js';
|
|
7
7
|
import * as serviceNs from '../service.js';
|
|
8
8
|
import { renderList } from '../support.js';
|
|
9
9
|
const service: any = serviceNs;
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/** bundled.list 的入参契约(CLI 与 HTTP 共用同一份)。 */
|
|
12
|
+
const input = z.object({
|
|
13
|
+
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export class BundledListAction extends ActionBase<typeof input> {
|
|
12
17
|
@action({
|
|
13
18
|
id: 'bundled.list',
|
|
14
19
|
cli: [['skill', 'list'], ['skill', 'install', '--list'], ['bundled', 'list']],
|
|
15
20
|
http: ['GET', '/api/bundled'],
|
|
16
21
|
summary: '列出包内自带 skill(含文件数与描述)+ 默认装哪个 + 有哪些 group',
|
|
17
|
-
input
|
|
22
|
+
input,
|
|
18
23
|
render: renderList,
|
|
19
24
|
})
|
|
20
|
-
async
|
|
25
|
+
override async run(__ctx: ActionInput<this['_input']>, meta: ActionRunMeta = {}) {
|
|
21
26
|
|
|
22
27
|
const info: any = await service.groupsInfo();
|
|
23
28
|
if (meta.transport !== 'http') return info;
|
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
// db.backup —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
|
|
2
2
|
//
|
|
3
|
-
//
|
|
3
|
+
// 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
|
|
4
4
|
import { action } from '../../../runtime/action-decorator.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
|
|
7
7
|
import * as serviceNs from '../service.js';
|
|
8
8
|
const service: any = serviceNs;
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
/** db.backup 的入参契约(CLI 与 HTTP 共用同一份)。 */
|
|
11
|
+
const input = z.object({
|
|
12
|
+
dir: z.string().optional().describe("备份目录(缺省 ~/.nx-kv/backups/)"),
|
|
13
|
+
keep: z.number().default(5).describe("保留最近几份(0 = 不清理)"),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export class DbBackupAction extends ActionBase<typeof input> {
|
|
11
17
|
@action({
|
|
12
18
|
id: 'db.backup',
|
|
13
19
|
cli: ['db', 'backup'],
|
|
14
20
|
http: null,
|
|
15
21
|
summary: 'VACUUM INTO 备份(WAL 下不能直接 copy .db;保留最近 5 份)',
|
|
16
|
-
input
|
|
22
|
+
input,
|
|
17
23
|
render: (d: any) => service.renderBackup(d),
|
|
18
24
|
})
|
|
19
|
-
async
|
|
25
|
+
override async run(ctx: ActionInput<this['_input']>) {
|
|
20
26
|
|
|
21
27
|
return service.backup({ dir: ctx.dir, keep: ctx.keep });
|
|
22
28
|
|
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
// db.migrate —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
|
|
2
2
|
//
|
|
3
|
-
//
|
|
3
|
+
// 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
|
|
4
4
|
import { action } from '../../../runtime/action-decorator.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
|
|
7
7
|
import * as serviceNs from '../service.js';
|
|
8
8
|
const service: any = serviceNs;
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
/** db.migrate 的入参契约(CLI 与 HTTP 共用同一份)。 */
|
|
11
|
+
const input = z.object({
|
|
12
|
+
'dry-run': z.boolean().optional().describe("演练:事务末尾回滚,库与 JSON 都不改"),
|
|
13
|
+
apply: z.boolean().optional().describe("显式执行(默认就是执行,此标志让脚本自证意图)"),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export class DbMigrateAction extends ActionBase<typeof input> {
|
|
11
17
|
@action({
|
|
12
18
|
id: 'db.migrate',
|
|
13
19
|
cli: ['db', 'migrate'],
|
|
14
20
|
http: null,
|
|
15
21
|
summary: '迁移:无标志 = 从 legacy JSON 全量导入;版本落后 = 走升级链(含 --dry-run 演练)',
|
|
16
|
-
input
|
|
22
|
+
input,
|
|
17
23
|
render: (d: any) => service.renderMigrate(d),
|
|
18
24
|
})
|
|
19
|
-
async
|
|
25
|
+
override async run(ctx: ActionInput<this['_input']>) {
|
|
20
26
|
|
|
21
27
|
return service.migrate({ dryRun: ctx['dry-run'] === true, apply: ctx.apply === true });
|
|
22
28
|
|
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
// db.status —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
|
|
2
2
|
//
|
|
3
|
-
//
|
|
3
|
+
// 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
|
|
4
4
|
import { action } from '../../../runtime/action-decorator.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
|
|
7
7
|
import * as serviceNs from '../service.js';
|
|
8
8
|
const service: any = serviceNs;
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
/** db.status 的入参契约(CLI 与 HTTP 共用同一份)。 */
|
|
11
|
+
const input = z.object({
|
|
12
|
+
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export class DbStatusAction extends ActionBase<typeof input> {
|
|
11
16
|
@action({
|
|
12
17
|
id: 'db.status',
|
|
13
18
|
cli: ['db', 'status'],
|
|
14
19
|
http: null,
|
|
15
20
|
summary: '库状态:路径、user_version、各表行数、任务状态分布(只读,不升级)',
|
|
16
|
-
input
|
|
21
|
+
input,
|
|
17
22
|
render: (d: any) => service.renderStatus(d),
|
|
18
23
|
})
|
|
19
|
-
async
|
|
24
|
+
override async run(_ctx: ActionInput<this['_input']>) {
|
|
20
25
|
|
|
21
26
|
return service.status();
|
|
22
27
|
|
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
// db.verify —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
|
|
2
2
|
//
|
|
3
|
-
//
|
|
3
|
+
// 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
|
|
4
4
|
import { action } from '../../../runtime/action-decorator.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
|
|
7
7
|
import * as serviceNs from '../service.js';
|
|
8
8
|
const service: any = serviceNs;
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
/** db.verify 的入参契约(CLI 与 HTTP 共用同一份)。 */
|
|
11
|
+
const input = z.object({
|
|
12
|
+
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export class DbVerifyAction extends ActionBase<typeof input> {
|
|
11
16
|
@action({
|
|
12
17
|
id: 'db.verify',
|
|
13
18
|
cli: ['db', 'verify'],
|
|
14
19
|
http: null,
|
|
15
20
|
summary: '逐项校验:版本/行数/状态分布/正文哈希/seq 对应/外键/完整性',
|
|
16
|
-
input
|
|
21
|
+
input,
|
|
17
22
|
render: (d: any) => service.renderVerify(d),
|
|
18
23
|
})
|
|
19
|
-
async
|
|
24
|
+
override async run(_ctx: ActionInput<this['_input']>) {
|
|
20
25
|
|
|
21
26
|
return service.verify();
|
|
22
27
|
|
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
// doc.add —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
|
|
2
2
|
//
|
|
3
|
-
//
|
|
3
|
+
// 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
|
|
4
4
|
import { action } from '../../../runtime/action-decorator.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { ActionBase, type ActionInput, type ActionRunMeta } from '../../../runtime/action-base.js';
|
|
7
7
|
import { addDoc as _addDoc } from '../service.js';
|
|
8
8
|
import { renderWritten as _renderWritten } from '../render.js';
|
|
9
9
|
const addDoc: any = _addDoc;
|
|
10
10
|
const renderWritten: any = _renderWritten;
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
/** doc.add 的入参契约(CLI 与 HTTP 共用同一份)。 */
|
|
13
|
+
const input = z.object({
|
|
14
|
+
rel: z.string(),
|
|
15
|
+
body: z.string().optional().describe("Markdown 正文"),
|
|
16
|
+
bodyFile: z.string().optional().describe("从文件读正文(--body 优先);`-` = 读标准输入"),
|
|
17
|
+
'body-file': z.string().optional().describe("同 --bodyFile(连字符写法)"),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export class DocAddAction extends ActionBase<typeof input> {
|
|
13
21
|
@action({
|
|
14
22
|
id: 'doc.add',
|
|
15
23
|
cli: ['docs', 'add'],
|
|
16
24
|
http: ['POST', '/api/docs/item'],
|
|
17
25
|
summary: '新建自有文档(--body 给 Markdown 正文;--body-file <文件> / - 读管道;已存在则报冲突)',
|
|
18
26
|
args: ['rel'],
|
|
19
|
-
input
|
|
27
|
+
input,
|
|
20
28
|
render: renderWritten,
|
|
21
29
|
})
|
|
22
|
-
async
|
|
30
|
+
override async run(ctx: ActionInput<this['_input']>, opts: ActionRunMeta = {}) {
|
|
23
31
|
|
|
24
32
|
return addDoc(
|
|
25
33
|
{ rel: ctx.rel, body: ctx.body, bodyFile: opts && opts.transport === 'http' ? undefined : (ctx.bodyFile ?? ctx['body-file']) },
|
|
@@ -1,23 +1,30 @@
|
|
|
1
1
|
// doc.attach-note —— 由 .tool/migrate-module.mjs 从 legacy 形态迁来(模板形态:一条 action 一个文件)。
|
|
2
2
|
//
|
|
3
|
-
//
|
|
3
|
+
// 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
|
|
4
4
|
import { action } from '../../../runtime/action-decorator.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
|
|
7
7
|
import { noteOnDoc as _noteOnDoc } from '../attach.js';
|
|
8
8
|
const noteOnDoc: any = _noteOnDoc;
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
/** doc.attach-note 的入参契约(CLI 与 HTTP 共用同一份)。 */
|
|
11
|
+
const input = z.object({
|
|
12
|
+
ref: z.string(),
|
|
13
|
+
attachment: z.string().describe("资源 id(见 docs attachments)"),
|
|
14
|
+
note: z.string().optional().describe("说明文字(留空 = 清掉)"),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export class DocAttachNoteAction extends ActionBase<typeof input> {
|
|
11
18
|
@action({
|
|
12
19
|
id: 'doc.attach-note',
|
|
13
20
|
cli: ['docs', 'attach-note'],
|
|
14
21
|
http: ['PATCH', '/api/docs/attach-note'],
|
|
15
22
|
summary: '改一条附件绑定的说明(desc):--attachment <资源 id> --note <说明>(只动说明,角色/位置不变)',
|
|
16
23
|
args: ['ref'],
|
|
17
|
-
input
|
|
24
|
+
input,
|
|
18
25
|
render: (d: any) => `已更新 ${d.attachment} 的说明:${d.note || '(清空)'}`,
|
|
19
26
|
})
|
|
20
|
-
async
|
|
27
|
+
override async run(ctx: ActionInput<this['_input']>) {
|
|
21
28
|
|
|
22
29
|
return noteOnDoc({ ref: ctx.ref, attachment: ctx.attachment, note: ctx.note });
|
|
23
30
|
|