weaver-work-cli 0.1.32 → 0.1.33
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/README.md +2 -2
- package/dist/chunks/{archive-UMGX72K6.js → archive-FVFY6GZN.js} +2 -2
- package/dist/chunks/{archive-oa-N2IYBLF3.js → archive-oa-NW3OD4UV.js} +2 -2
- package/dist/chunks/{asset-GLEGKFG5.js → asset-7QJKMIDV.js} +2 -2
- package/dist/chunks/{attachment-content-AQNX5N3S.js → attachment-content-OSAVA6K3.js} +3 -2
- package/dist/chunks/{blog-E44OTVDA.js → blog-I7SDPNW4.js} +2 -2
- package/dist/chunks/{caizhilian-DQUFZXZL.js → caizhilian-O37ZIQNY.js} +2 -2
- package/dist/chunks/{calendar-JKPIRKFD.js → calendar-7KXE4ED3.js} +2 -2
- package/dist/chunks/{chunk-4YC43QQ4.js → chunk-2FLWXFVS.js} +4 -4
- package/dist/chunks/{chunk-QWY6PGL6.js → chunk-2LV74IWP.js} +361 -56
- package/dist/chunks/chunk-3SO6QL6U.js +73 -0
- package/dist/chunks/{chunk-DW6AUUKS.js → chunk-6ATGWRZM.js} +6 -4
- package/dist/chunks/chunk-BYATLLEF.js +68 -0
- package/dist/chunks/chunk-BYBSCN4X.js +932 -0
- package/dist/chunks/{chunk-2GA5ZIQL.js → chunk-D223PTXU.js} +1 -0
- package/dist/chunks/{chunk-H7J4DC5R.js → chunk-EEWPQE3O.js} +2 -2
- package/dist/chunks/{chunk-6RKD4DRZ.js → chunk-GFPXQIY2.js} +2 -2
- package/dist/chunks/{chunk-C6R3B2ML.js → chunk-HEL5XTYI.js} +12 -6
- package/dist/chunks/{chunk-CVZ2JOSW.js → chunk-IHUYP6LO.js} +1 -1
- package/dist/chunks/{chunk-YRVDW4WN.js → chunk-ILMBNVSG.js} +2 -2
- package/dist/chunks/{chunk-G3QJULO2.js → chunk-KAS45KNR.js} +1 -1
- package/dist/chunks/{chunk-H6XSTSLM.js → chunk-MEEFGWTM.js} +54 -196
- package/dist/chunks/{chunk-GCG2NMWR.js → chunk-MQ2I5AA3.js} +4 -2
- package/dist/chunks/chunk-NHA62QD7.js +774 -0
- package/dist/chunks/{chunk-WKI2FBIQ.js → chunk-OCU4RLHC.js} +641 -309
- package/dist/chunks/{chunk-WSKBSQ2U.js → chunk-PRHJGPMA.js} +2 -2
- package/dist/chunks/{chunk-6EFWDL7Y.js → chunk-Q6LWB5HX.js} +2 -2
- package/dist/chunks/{chunk-IURUFGZK.js → chunk-RBGOMK4Y.js} +50 -33
- package/dist/chunks/chunk-VBCFFFGT.js +226 -0
- package/dist/chunks/{ebuilder-form-V5FG2EHC.js → chunk-WRRJ4GG2.js} +22 -1148
- package/dist/chunks/{chunk-E4Z23GHM.js → chunk-WY74UBJ6.js} +264 -750
- package/dist/chunks/conflict-SFNEVJY5.js +21 -0
- package/dist/chunks/continuation-RN6PZN2M.js +11 -0
- package/dist/chunks/cowork-CKWYHXYB.js +2508 -0
- package/dist/chunks/ebuilder-form-KOLJRVZD.js +121 -0
- package/dist/chunks/{ehr-HMFY6VIL.js → ehr-WFOC3B4D.js} +1174 -20
- package/dist/chunks/{esb-ZYSVB7SG.js → esb-LJZTN663.js} +4 -4
- package/dist/chunks/{fna-B7RKPAZD.js → fna-F7QRIIZC.js} +2 -2
- package/dist/chunks/{host-45WED2KK.js → host-BCGUVEWX.js} +3 -3
- package/dist/chunks/host-BQBRHVR3.js +23 -0
- package/dist/chunks/{host-I4Z6BFYX.js → host-DGE2TZD4.js} +3 -3
- package/dist/chunks/{host-KNZ52LJZ.js → host-KXPTEWFS.js} +3 -3
- package/dist/chunks/{host-OCH2BCCV.js → host-VQ6JJXGQ.js} +3 -3
- package/dist/chunks/{hrm-2KAZGUHI.js → hrm-NI6XAKW5.js} +3 -3
- package/dist/chunks/{im-ACJJWH4U.js → im-7TRTF3KT.js} +88 -12
- package/dist/chunks/{invoice-ZK3WCX2U.js → invoice-AOXWJKYT.js} +3 -3
- package/dist/chunks/{jiuchuanhui-5PQD3IL2.js → jiuchuanhui-7NQWEZAW.js} +2 -2
- package/dist/chunks/{lazy-dispatch-JQXBW3GM.js → lazy-dispatch-RNS4EE4S.js} +4 -4
- package/dist/chunks/{mail-S2HDDXO2.js → mail-VDHJAB4O.js} +3 -3
- package/dist/chunks/{meeting-QVN3I37L.js → meeting-GA7XCNNP.js} +214 -43
- package/dist/chunks/{okr-QNG4VC2Q.js → okr-TQIRERPQ.js} +2 -2
- package/dist/chunks/operations-5QL3AECO.js +11 -0
- package/dist/chunks/{plan-A25EMW6U.js → plan-4RY4LN2P.js} +2 -2
- package/dist/chunks/{project-G6XV66DZ.js → project-D6XT2OC5.js} +2 -2
- package/dist/chunks/{registry-DC6KR3NH.js → registry-JHRIDQ3A.js} +4 -4
- package/dist/chunks/{registry-2VLUAESA.js → registry-OZSMDVPP.js} +2 -2
- package/dist/chunks/{registry-TI3CIUXF.js → registry-QKMI43Q6.js} +8 -6
- package/dist/chunks/{registry-7C5UMIPL.js → registry-VOGKFFTR.js} +2 -2
- package/dist/chunks/{room-recommend-WRTHO6Y2.js → room-recommend-D4EUOOWY.js} +4 -3
- package/dist/chunks/{schedule-KFIITGSK.js → schedule-XPFBHPCV.js} +4 -3
- package/dist/chunks/{workflow-DJ7SYWAF.js → workflow-HLBZRWIY.js} +172 -6
- package/dist/index.js +30 -25
- package/dist/internal/e10/auth-recovery.js +14 -4
- package/dist/shortcuts/contract/host.js +34 -59
- package/dist/shortcuts/cowork/continuation.js +70 -0
- package/dist/shortcuts/cowork/errors.js +59 -0
- package/dist/shortcuts/cowork/host.js +172 -0
- package/dist/shortcuts/cowork/index.js +166 -0
- package/dist/shortcuts/cowork/manifest.js +65 -0
- package/dist/shortcuts/cowork/operations/discuss-write.js +277 -0
- package/dist/shortcuts/cowork/operations/item-write.js +380 -0
- package/dist/shortcuts/cowork/operations/member-write.js +283 -0
- package/dist/shortcuts/cowork/operations/permission-write.js +286 -0
- package/dist/shortcuts/cowork/operations/read.js +423 -0
- package/dist/shortcuts/cowork/operations/registry.js +39 -0
- package/dist/shortcuts/cowork/operations/review-write.js +157 -0
- package/dist/shortcuts/cowork/operations/shared.js +215 -0
- package/dist/shortcuts/cowork/operations/types.js +24 -0
- package/dist/shortcuts/cowork/operations.js +19 -0
- package/dist/shortcuts/ehr/host.js +4 -1
- package/dist/shortcuts/ehr/operations/recruit-candidate-import.js +757 -0
- package/dist/shortcuts/ehr/operations/recruit-position.js +367 -0
- package/dist/shortcuts/ehr/operations/recruit-stats.js +133 -0
- package/dist/shortcuts/ehr/operations/recruit-write.js +8 -16
- package/dist/shortcuts/ehr/operations/recruit.js +35 -10
- package/dist/shortcuts/ehr/operations/registry.js +6 -0
- package/dist/shortcuts/im/diagnostics.js +97 -0
- package/dist/shortcuts/im/host.js +58 -31
- package/dist/shortcuts/im/index.js +7 -2
- package/dist/shortcuts/im/operations/at-mention.js +127 -0
- package/dist/shortcuts/im/operations/file-user.js +10 -2
- package/dist/shortcuts/im/operations/group-read.js +26 -5
- package/dist/shortcuts/im/operations/group-write.js +35 -28
- package/dist/shortcuts/im/operations/msg-sync.js +7 -2
- package/dist/shortcuts/im/operations/msg-write.js +76 -10
- package/dist/shortcuts/im/operations/quote-mention.js +119 -0
- package/dist/shortcuts/im/operations/session.js +1 -1
- package/dist/shortcuts/im/operations/shared.js +10 -0
- package/dist/shortcuts/im/operations/types.js +13 -0
- package/dist/shortcuts/index.js +5 -0
- package/dist/shortcuts/mail/host.js +4 -1
- package/dist/shortcuts/meeting/host.js +27 -34
- package/dist/shortcuts/meeting/operations/create.js +4 -1
- package/dist/shortcuts/meeting/operations/eb/catalog.js +5 -0
- package/dist/shortcuts/meeting/operations/eb/conflict.js +78 -7
- package/dist/shortcuts/meeting/operations/eb/create-flow.js +168 -26
- package/dist/shortcuts/meeting/operations/eb/factory.js +69 -1
- package/dist/shortcuts/meeting/operations/eb/index.js +16 -3
- package/dist/shortcuts/meeting/operations/eb/room-recommend.js +14 -3
- package/dist/shortcuts/meeting/operations/eb-fallback.js +159 -0
- package/dist/shortcuts/meeting/operations/env.js +93 -46
- package/dist/shortcuts/meeting/operations/form-fields.js +110 -0
- package/dist/shortcuts/meeting/operations/registry.js +2 -0
- package/dist/shortcuts/meeting/operations/standard-guard.js +71 -0
- package/dist/shortcuts/meeting/operations.js +16 -0
- package/dist/shortcuts/workflow/index.js +110 -1
- package/dist/shortcuts/workflow/operations/form.js +24 -3
- package/dist/shortcuts/workflow/operations/read.js +104 -23
- package/dist/shortcuts/workflow/operations/todoSmartConvert/aigroupRules.js +448 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/aigroupStore.js +106 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/businessRules.js +47 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +30 -23
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +1 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.group.js +1 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.groupSummary.js +2 -1
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +2 -4
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.smartGroup.js +138 -181
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.summary.js +12 -7
- package/docs/e10-auth.md +1 -1
- package/docs/im.md +8 -1
- package/docs/todo-smart-convert/README.md +1 -1
- package/docs/todo-smart-convert/data-contract.md +2 -2
- package/docs/todo-smart-convert/subgroup-rules.md +6 -0
- package/package.json +1 -1
- package/skill-template/domains/yimiaoban.md +3 -3
- package/skill-template/skill-template.md +1 -1
- package/skills/weaver-e10-blog/SKILL.md +5 -5
- package/skills/weaver-e10-caizhilian/SKILL.md +5 -5
- package/skills/weaver-e10-calendar/SKILL.md +5 -5
- package/skills/weaver-e10-esb/SKILL.md +5 -5
- package/skills/weaver-e10-hrm/SKILL.md +5 -5
- package/skills/weaver-e10-jinchengda/SKILL.md +2 -2
- package/skills/weaver-e10-jiuchuanhui/SKILL.md +5 -5
- package/skills/weaver-e10-jucailin/SKILL.md +18 -12
- package/skills/weaver-e10-jucailin/references/recruit-create.md +104 -0
- package/skills/weaver-e10-mail/SKILL.md +5 -5
- package/skills/weaver-e10-meeting/SKILL.md +171 -25
- package/skills/weaver-e10-meeting/references/meeting-eb.md +4 -3
- package/skills/weaver-e10-meeting/references/meeting-queries.md +9 -6
- package/skills/weaver-e10-meeting/references/meeting-verification.md +8 -6
- package/skills/weaver-e10-meeting.zip +0 -0
- package/skills/weaver-e10-okr/SKILL.md +5 -5
- package/skills/weaver-e10-okr/references/source-manifest.json +3 -3
- package/skills/weaver-e10-plan/SKILL.md +5 -5
- package/skills/weaver-e10-shared/SKILL.md +12 -12
- package/skills/weaver-e10-shared/references/e10-auth-and-session.md +4 -4
- package/skills/weaver-e10-wenshuding/SKILL.md +5 -5
- package/skills/weaver-e10-workflow/SKILL.md +29 -5
- package/skills/weaver-e10-workflow/aigroup/default.json +88 -0
- package/skills/weaver-e10-workflow/references/todo-smart-convert.md +66 -14
- package/skills/weaver-e10-workflow/references/workflow-agent-entry.md +1 -1
- package/skills/weaver-e10-workflow/references/workflow-memory.md +1 -1
- package/skills/weaver-e10-workflow/references/workflow-query.md +12 -10
- package/skills/weaver-e10-workflow/references/workflow-view.md +2 -2
- package/skills/weaver-e10-workflow/tools/todo-serve.cjs +239 -0
- package/skills/weaver-e10-workflow/{scripts → tools}/todo-summary.cjs +218 -28
- package/skills/weaver-e10-yepiaotong/SKILL.md +10 -8
- package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +7 -7
- package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +10 -10
- package/skills/weaver-e10-yepiaotong/references/reim-examples.md +40 -37
- package/skills/weaver-e10-yepiaotong/references/reim-expense-subject-rules.md +4 -4
- package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +27 -38
- package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +4 -4
- package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +37 -29
- package/skills/weaver-e10-yimiaoban/SKILL.md +156 -33
- package/skills/weaver-e10-yimiaoban/references/ding-write.md +1 -1
- package/skills/weaver-e10-yimiaoban/references/error-codes.md +5 -1
- package/skills/weaver-e10-yimiaoban/references/group-read.md +5 -1
- package/skills/weaver-e10-yimiaoban/references/group-write.md +6 -4
- package/skills/weaver-e10-yimiaoban/references/msg-read.md +1 -0
- package/skills/weaver-e10-yimiaoban/references/msg-write.md +34 -2
- package/skills/weaver-e10-yimiaoban/references/safety-boundaries.md +5 -2
- package/skills/weaver-e10-yimiaoban/references/source-manifest.json +79 -58
- package/skills/weaver-e10-yimiaoban/references/user-remind.md +2 -2
- package/skills/weaver-e10-ziguanjia/SKILL.md +5 -5
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
import { READ, SCHEMA_ID, SCHEMA_PAGE_CURRENT, SCHEMA_PAGE_SIZE, coworkSuccess, schemaOf, } from './types.js';
|
|
2
|
+
import { assertEnum, buildListBody, compact, normalizeList, toId, toPositiveInt, unwrapData, } from './shared.js';
|
|
3
|
+
/**
|
|
4
|
+
* 列表 scope → 接口路径。11 个列表结构一致(JSON + 标准列表 envelope),
|
|
5
|
+
* 因此收敛为单个 `cowork.list`:同一业务动作(查协作/事项/申请),用 scope 区分数据集,
|
|
6
|
+
* 避免 11 个几乎同参的 operation 让 Agent 选择困难。
|
|
7
|
+
*/
|
|
8
|
+
const LIST_PATHS = {
|
|
9
|
+
main: '/api/cowork/main/getCoworkMainItemList',
|
|
10
|
+
attention: '/api/cowork/attention/getCoworkAttentionItemList',
|
|
11
|
+
collect: '/api/cowork/collect/getCoworkCollectList',
|
|
12
|
+
mineDiscuss: '/api/cowork/mine/getCoworkMineDiscussList',
|
|
13
|
+
mineComment: '/api/cowork/mine/getCoworkMineCommentList',
|
|
14
|
+
mineItem: '/api/cowork/mineItem/getCoworkMineItemList',
|
|
15
|
+
related: '/api/cowork/related/relatedRecord',
|
|
16
|
+
apply: '/api/cowork/apply/getCoworkApplyList',
|
|
17
|
+
approve: '/api/cowork/apply/getCoworkApplyApproveList',
|
|
18
|
+
log: '/api/cowork/apply/getCoworkApplyLogList',
|
|
19
|
+
quit: '/api/cowork/apply/getCoworkQuitList',
|
|
20
|
+
// 审批台列表(脚本实测;接口文档未收录,但真机验证可用)
|
|
21
|
+
itemApprove: '/api/cowork/itemApprove/getCoworkItemApproveList',
|
|
22
|
+
discussApprove: '/api/cowork/discussApprove/getCoworkDiscussApproveList',
|
|
23
|
+
};
|
|
24
|
+
/** 条件元数据 scope → 接口路径。列表筛选字段以这些接口返回为准。 */
|
|
25
|
+
const CONDITION_PATHS = {
|
|
26
|
+
main: '/api/cowork/main/getCoworkMainItemSearchCondition',
|
|
27
|
+
attention: '/api/cowork/attention/getCoworkAttentionItemSearchCondition',
|
|
28
|
+
collect: '/api/cowork/collect/getCoworkDiscussCollectSearchCondition',
|
|
29
|
+
mine: '/api/cowork/mine/getCoworkMineSearchCondition',
|
|
30
|
+
mineItem: '/api/cowork/mineItem/getCoworkMineItemSearchCondition',
|
|
31
|
+
related: '/api/cowork/related/getCoworkRelatedSearchCondition',
|
|
32
|
+
apply: '/api/cowork/apply/getCoworkItemApplySearchCondition',
|
|
33
|
+
approve: '/api/cowork/apply/getCoworkApplyApproveSearchCondition',
|
|
34
|
+
log: '/api/cowork/apply/getCoworkApplyLogSearchCondition',
|
|
35
|
+
quit: '/api/cowork/apply/getCoworkQuitSearchCondition',
|
|
36
|
+
discuss: '/api/cowork/view/getCoworkDiscussSearchCondition',
|
|
37
|
+
};
|
|
38
|
+
const LIST_SCOPES = Object.keys(LIST_PATHS);
|
|
39
|
+
const CONDITION_SCOPES = Object.keys(CONDITION_PATHS);
|
|
40
|
+
const conditionField = (description) => ({
|
|
41
|
+
type: 'string',
|
|
42
|
+
enum: ['in', 'bl'],
|
|
43
|
+
description: `${description}匹配模式:in 精确 / bl 模糊`,
|
|
44
|
+
});
|
|
45
|
+
const listSchema = schemaOf({
|
|
46
|
+
scope: {
|
|
47
|
+
type: 'string',
|
|
48
|
+
enum: LIST_SCOPES,
|
|
49
|
+
description: [
|
|
50
|
+
'main=协作列表',
|
|
51
|
+
'attention=我关注的',
|
|
52
|
+
'collect=我收藏的',
|
|
53
|
+
'mineDiscuss=我的讨论',
|
|
54
|
+
'mineComment=我的评论',
|
|
55
|
+
'mineItem=我的事项(tabKey 区分我创建的/我负责的)',
|
|
56
|
+
'related=相关我',
|
|
57
|
+
'apply=申请加入列表',
|
|
58
|
+
'approve=待审批列表(加入申请)',
|
|
59
|
+
'log=审批日志',
|
|
60
|
+
'quit=退出列表',
|
|
61
|
+
'itemApprove=事项审批台列表',
|
|
62
|
+
'discussApprove=交流审批台列表',
|
|
63
|
+
].join(';'),
|
|
64
|
+
},
|
|
65
|
+
current: SCHEMA_PAGE_CURRENT,
|
|
66
|
+
pageSize: SCHEMA_PAGE_SIZE,
|
|
67
|
+
type: { type: 'string', enum: ['and', 'or'], description: '条件组合方式,默认 and' },
|
|
68
|
+
itemName: { type: 'string', description: '协作主题' },
|
|
69
|
+
itemNameCondition: conditionField('协作主题'),
|
|
70
|
+
sectionId: SCHEMA_ID,
|
|
71
|
+
sectionCondition: conditionField('版块'),
|
|
72
|
+
principal: SCHEMA_ID,
|
|
73
|
+
principalCondition: conditionField('负责人'),
|
|
74
|
+
creator: SCHEMA_ID,
|
|
75
|
+
creatorCondition: conditionField('创建人'),
|
|
76
|
+
creatorSearch: { type: 'string', description: '创建人关键字(仅 scope=main)' },
|
|
77
|
+
tagId: SCHEMA_ID,
|
|
78
|
+
tagCondition: conditionField('标签'),
|
|
79
|
+
tagCommonId: SCHEMA_ID,
|
|
80
|
+
tagCommonCondition: conditionField('公共标签'),
|
|
81
|
+
itemStatus: { type: 'string', description: '协作状态:1 进行中(默认 1)' },
|
|
82
|
+
hidden: { type: 'string', description: '是否含隐藏:0 否(默认 0)/ 1 是' },
|
|
83
|
+
tabKey: { type: 'string', description: 'mineItem 默认 mineItemCreate;mineDiscuss/mineComment 可省略' },
|
|
84
|
+
orderBy: { type: 'string', enum: ['collectTime'], description: '排序字段(仅 scope=collect)' },
|
|
85
|
+
sortOrder: { type: 'string', enum: ['asc', 'desc'], description: '排序方向(仅 scope=collect)' },
|
|
86
|
+
quickSearchDatas: { type: 'object', description: '快速搜索条件(仅 scope=collect)' },
|
|
87
|
+
discussFrom: { type: 'string', description: '来源标识,scope=related 默认 relatedMenu' },
|
|
88
|
+
applyer: SCHEMA_ID,
|
|
89
|
+
applyerCondition: conditionField('申请人(scope=approve)'),
|
|
90
|
+
applyerDept: SCHEMA_ID,
|
|
91
|
+
applyerDeptCondition: conditionField('申请人部门(scope=approve)'),
|
|
92
|
+
approver: SCHEMA_ID,
|
|
93
|
+
approverCondition: conditionField('审批人(scope=log)'),
|
|
94
|
+
applyStatus: { type: 'string', description: '申请状态(scope=log)' },
|
|
95
|
+
applyStatusCondition: conditionField('申请状态(scope=log)'),
|
|
96
|
+
dateType: { type: 'string', description: '日期类型(scope=discussApprove,默认空)' },
|
|
97
|
+
}, { required: ['scope'] });
|
|
98
|
+
const coworkList = {
|
|
99
|
+
name: 'cowork.list',
|
|
100
|
+
resource: 'cowork',
|
|
101
|
+
method: 'list',
|
|
102
|
+
action: 'cowork.list',
|
|
103
|
+
summary: '按 scope 查询协作/关注/收藏/我的事项/申请/待审批/审批日志/退出等列表(分页;筛选字段以 cowork.conditions 返回为准)',
|
|
104
|
+
risk: READ,
|
|
105
|
+
inputSchema: listSchema,
|
|
106
|
+
handler: async (args, { host }) => {
|
|
107
|
+
const scope = assertEnum(args.scope, LIST_SCOPES, 'scope');
|
|
108
|
+
const body = buildListBody(args, scope);
|
|
109
|
+
const response = await host.request({
|
|
110
|
+
method: 'POST',
|
|
111
|
+
path: LIST_PATHS[scope],
|
|
112
|
+
body,
|
|
113
|
+
operation: 'cowork.list',
|
|
114
|
+
});
|
|
115
|
+
const { data, page } = normalizeList(response);
|
|
116
|
+
return coworkSuccess('cowork.list', data, { scope, ...page });
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
const coworkConditions = {
|
|
120
|
+
name: 'cowork.conditions',
|
|
121
|
+
resource: 'cowork',
|
|
122
|
+
method: 'conditions',
|
|
123
|
+
action: 'cowork.conditions',
|
|
124
|
+
summary: '取对应列表的高级搜索条件元数据(groups/layout),是构造 cowork.list 筛选参数的唯一依据',
|
|
125
|
+
risk: READ,
|
|
126
|
+
inputSchema: schemaOf({ scope: { type: 'string', enum: CONDITION_SCOPES, description: '与 cowork.list 的 scope 对应;discuss 用于讨论列表' } }, { required: ['scope'] }),
|
|
127
|
+
handler: async (args, { host }) => {
|
|
128
|
+
const scope = assertEnum(args.scope, CONDITION_SCOPES, 'scope');
|
|
129
|
+
const response = await host.request({
|
|
130
|
+
method: 'POST',
|
|
131
|
+
path: CONDITION_PATHS[scope],
|
|
132
|
+
body: {},
|
|
133
|
+
operation: 'cowork.conditions',
|
|
134
|
+
});
|
|
135
|
+
return coworkSuccess('cowork.conditions', unwrapData(response) ?? null, { scope });
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
const coworkCount = {
|
|
139
|
+
name: 'cowork.count',
|
|
140
|
+
resource: 'cowork',
|
|
141
|
+
method: 'count',
|
|
142
|
+
action: 'cowork.count',
|
|
143
|
+
summary: '统计进行中协作总数(与 scope=main 列表口径一致)',
|
|
144
|
+
risk: READ,
|
|
145
|
+
inputSchema: schemaOf({
|
|
146
|
+
hidden: { type: 'string', description: '是否含隐藏:0 否(默认)/ 1 是' },
|
|
147
|
+
itemStatus: { type: 'string', description: '协作状态,默认 1 进行中' },
|
|
148
|
+
}),
|
|
149
|
+
handler: async (args, { host }) => {
|
|
150
|
+
const body = compact({
|
|
151
|
+
hidden: args.hidden === undefined ? '0' : String(args.hidden),
|
|
152
|
+
itemStatus: args.itemStatus === undefined ? '1' : String(args.itemStatus),
|
|
153
|
+
});
|
|
154
|
+
const response = await host.request({
|
|
155
|
+
method: 'POST',
|
|
156
|
+
path: '/api/cowork/main/countCoworkMainItem',
|
|
157
|
+
body,
|
|
158
|
+
operation: 'cowork.count',
|
|
159
|
+
});
|
|
160
|
+
return coworkSuccess('cowork.count', unwrapData(response) ?? null);
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
const coworkView = {
|
|
164
|
+
name: 'cowork.view',
|
|
165
|
+
resource: 'cowork',
|
|
166
|
+
method: 'view',
|
|
167
|
+
action: 'cowork.view',
|
|
168
|
+
summary: '查协作详情(状态/版块/权限标记 canEdit、canEnd、canReply 等)',
|
|
169
|
+
risk: READ,
|
|
170
|
+
inputSchema: schemaOf({ id: { ...SCHEMA_ID, description: '协作 id' } }, { required: ['id'] }),
|
|
171
|
+
handler: async (args, { host }) => {
|
|
172
|
+
const id = toId(args.id, 'id');
|
|
173
|
+
const response = await host.request({
|
|
174
|
+
method: 'POST',
|
|
175
|
+
path: '/api/cowork/view/viewCowork',
|
|
176
|
+
form: { id },
|
|
177
|
+
operation: 'cowork.view',
|
|
178
|
+
});
|
|
179
|
+
return coworkSuccess('cowork.view', unwrapData(response) ?? null);
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
const coworkDiscussList = {
|
|
183
|
+
name: 'cowork.discuss.list',
|
|
184
|
+
resource: 'cowork',
|
|
185
|
+
method: 'discuss.list',
|
|
186
|
+
action: 'cowork.discuss.list',
|
|
187
|
+
summary: '查某协作下的讨论/回复记录(默认按最后回复倒序)',
|
|
188
|
+
risk: READ,
|
|
189
|
+
inputSchema: schemaOf({
|
|
190
|
+
coworkId: { ...SCHEMA_ID, description: '协作 id' },
|
|
191
|
+
current: SCHEMA_PAGE_CURRENT,
|
|
192
|
+
pageSize: SCHEMA_PAGE_SIZE,
|
|
193
|
+
orderColumn: { type: 'string', description: '排序字段,默认 lastReply' },
|
|
194
|
+
orderAsc: { type: 'boolean', description: '是否升序,默认 false(倒序)' },
|
|
195
|
+
}, { required: ['coworkId'] }),
|
|
196
|
+
handler: async (args, { host }) => {
|
|
197
|
+
const coworkId = toId(args.coworkId, 'coworkId');
|
|
198
|
+
const body = compact({
|
|
199
|
+
coworkId,
|
|
200
|
+
current: toPositiveInt(args.current, 'current') ?? 1,
|
|
201
|
+
pageSize: toPositiveInt(args.pageSize, 'pageSize'),
|
|
202
|
+
orders: [{
|
|
203
|
+
column: typeof args.orderColumn === 'string' && args.orderColumn ? args.orderColumn : 'lastReply',
|
|
204
|
+
asc: args.orderAsc === true,
|
|
205
|
+
}],
|
|
206
|
+
});
|
|
207
|
+
const response = await host.request({
|
|
208
|
+
method: 'POST',
|
|
209
|
+
path: '/api/cowork/view/discussRecord',
|
|
210
|
+
body,
|
|
211
|
+
operation: 'cowork.discuss.list',
|
|
212
|
+
});
|
|
213
|
+
const { data, page } = normalizeList(response);
|
|
214
|
+
return coworkSuccess('cowork.discuss.list', data, page);
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
const PARTICIPANT_SCOPES = ['all', 'share', 'quit'];
|
|
218
|
+
const coworkParticipantList = {
|
|
219
|
+
name: 'cowork.participant.list',
|
|
220
|
+
resource: 'cowork',
|
|
221
|
+
method: 'participant.list',
|
|
222
|
+
action: 'cowork.participant.list',
|
|
223
|
+
summary: '查协作参与人:all=全部参与人 / share=共享参与人(含邮箱手机) / quit=退出记录',
|
|
224
|
+
risk: READ,
|
|
225
|
+
inputSchema: schemaOf({
|
|
226
|
+
scope: { type: 'string', enum: [...PARTICIPANT_SCOPES], description: 'all / share / quit' },
|
|
227
|
+
id: { ...SCHEMA_ID, description: '协作 id' },
|
|
228
|
+
participationFrom: { type: 'string', description: 'scope=all 时的来源标识,默认 participant' },
|
|
229
|
+
current: SCHEMA_PAGE_CURRENT,
|
|
230
|
+
pageSize: SCHEMA_PAGE_SIZE,
|
|
231
|
+
}, { required: ['scope', 'id'] }),
|
|
232
|
+
handler: async (args, { host }) => {
|
|
233
|
+
const scope = assertEnum(args.scope, PARTICIPANT_SCOPES, 'scope');
|
|
234
|
+
const id = toId(args.id, 'id');
|
|
235
|
+
if (scope === 'share') {
|
|
236
|
+
const response = await host.request({
|
|
237
|
+
method: 'POST',
|
|
238
|
+
path: '/api/cowork/view/shareParticipation',
|
|
239
|
+
form: { id },
|
|
240
|
+
operation: 'cowork.participant.list',
|
|
241
|
+
});
|
|
242
|
+
return coworkSuccess('cowork.participant.list', unwrapData(response) ?? null, { scope });
|
|
243
|
+
}
|
|
244
|
+
if (scope === 'quit') {
|
|
245
|
+
const body = compact({
|
|
246
|
+
coworkId: id,
|
|
247
|
+
current: toPositiveInt(args.current, 'current') ?? 1,
|
|
248
|
+
pageSize: toPositiveInt(args.pageSize, 'pageSize') ?? 10,
|
|
249
|
+
});
|
|
250
|
+
const response = await host.request({
|
|
251
|
+
method: 'POST',
|
|
252
|
+
path: '/api/cowork/main/getCoworkQuitList',
|
|
253
|
+
body,
|
|
254
|
+
operation: 'cowork.participant.list',
|
|
255
|
+
});
|
|
256
|
+
const { data, page } = normalizeList(response);
|
|
257
|
+
return coworkSuccess('cowork.participant.list', data, { scope, ...page });
|
|
258
|
+
}
|
|
259
|
+
const body = compact({
|
|
260
|
+
id,
|
|
261
|
+
participationFrom: typeof args.participationFrom === 'string' && args.participationFrom
|
|
262
|
+
? args.participationFrom
|
|
263
|
+
: 'participant',
|
|
264
|
+
current: toPositiveInt(args.current, 'current') ?? 1,
|
|
265
|
+
pageSize: toPositiveInt(args.pageSize, 'pageSize') ?? 10,
|
|
266
|
+
});
|
|
267
|
+
const response = await host.request({
|
|
268
|
+
method: 'POST',
|
|
269
|
+
path: '/api/cowork/view/participationAllList',
|
|
270
|
+
body,
|
|
271
|
+
operation: 'cowork.participant.list',
|
|
272
|
+
});
|
|
273
|
+
const { data, page } = normalizeList(response);
|
|
274
|
+
return coworkSuccess('cowork.participant.list', data, { scope, ...page });
|
|
275
|
+
},
|
|
276
|
+
};
|
|
277
|
+
const coworkResource = {
|
|
278
|
+
name: 'cowork.resource',
|
|
279
|
+
resource: 'cowork',
|
|
280
|
+
method: 'resource',
|
|
281
|
+
action: 'cowork.resource',
|
|
282
|
+
summary: '查协作关联资源数据(为空时返回 {})',
|
|
283
|
+
risk: READ,
|
|
284
|
+
inputSchema: schemaOf({ id: { ...SCHEMA_ID, description: '协作 id' } }, { required: ['id'] }),
|
|
285
|
+
handler: async (args, { host }) => {
|
|
286
|
+
const id = toId(args.id, 'id');
|
|
287
|
+
const response = await host.request({
|
|
288
|
+
method: 'POST',
|
|
289
|
+
path: '/api/cowork/view/resourceData',
|
|
290
|
+
form: { id },
|
|
291
|
+
operation: 'cowork.resource',
|
|
292
|
+
});
|
|
293
|
+
return coworkSuccess('cowork.resource', unwrapData(response) ?? null);
|
|
294
|
+
},
|
|
295
|
+
};
|
|
296
|
+
const coworkVoteLog = {
|
|
297
|
+
name: 'cowork.vote.log',
|
|
298
|
+
resource: 'cowork',
|
|
299
|
+
method: 'vote.log',
|
|
300
|
+
action: 'cowork.vote.log',
|
|
301
|
+
summary: '查协作投票日志(无投票时 total 为 0)',
|
|
302
|
+
risk: READ,
|
|
303
|
+
inputSchema: schemaOf({
|
|
304
|
+
id: { ...SCHEMA_ID, description: '协作 id' },
|
|
305
|
+
current: SCHEMA_PAGE_CURRENT,
|
|
306
|
+
pageSize: SCHEMA_PAGE_SIZE,
|
|
307
|
+
}, { required: ['id'] }),
|
|
308
|
+
handler: async (args, { host }) => {
|
|
309
|
+
const id = toId(args.id, 'id');
|
|
310
|
+
const body = compact({
|
|
311
|
+
id,
|
|
312
|
+
current: toPositiveInt(args.current, 'current') ?? 1,
|
|
313
|
+
pageSize: toPositiveInt(args.pageSize, 'pageSize') ?? 10,
|
|
314
|
+
});
|
|
315
|
+
const response = await host.request({
|
|
316
|
+
method: 'POST',
|
|
317
|
+
path: '/api/cowork/view/voteLog',
|
|
318
|
+
body,
|
|
319
|
+
operation: 'cowork.vote.log',
|
|
320
|
+
});
|
|
321
|
+
const { data, page } = normalizeList(response);
|
|
322
|
+
return coworkSuccess('cowork.vote.log', data, page);
|
|
323
|
+
},
|
|
324
|
+
};
|
|
325
|
+
const coworkForm = {
|
|
326
|
+
name: 'cowork.form',
|
|
327
|
+
resource: 'cowork',
|
|
328
|
+
method: 'form',
|
|
329
|
+
action: 'cowork.form',
|
|
330
|
+
summary: '取新建协作的表单元数据(groups/layout),用于确定版块 sectionId 与可选开关字段;建协作前必须先调用',
|
|
331
|
+
risk: READ,
|
|
332
|
+
inputSchema: schemaOf({ id: { ...SCHEMA_ID, description: '编辑已有协作文时传其 id;新建留空' } }),
|
|
333
|
+
handler: async (args, { host }) => {
|
|
334
|
+
const id = toId(args.id, 'id');
|
|
335
|
+
const response = await host.request({
|
|
336
|
+
method: 'POST',
|
|
337
|
+
path: '/api/cowork/main/getCoworkAddItemForm',
|
|
338
|
+
form: { id: id ?? '', type: 'new' },
|
|
339
|
+
operation: 'cowork.form',
|
|
340
|
+
});
|
|
341
|
+
return coworkSuccess('cowork.form', unwrapData(response) ?? null);
|
|
342
|
+
},
|
|
343
|
+
};
|
|
344
|
+
const META_SCOPES = ['operateAuth', 'layout'];
|
|
345
|
+
const coworkMeta = {
|
|
346
|
+
name: 'cowork.meta',
|
|
347
|
+
resource: 'cowork',
|
|
348
|
+
method: 'meta',
|
|
349
|
+
action: 'cowork.meta',
|
|
350
|
+
summary: '取协作模块的界面元数据:operateAuth=当前用户在列表可执行的操作(如批量删除)/ layout=行为布局标识',
|
|
351
|
+
risk: READ,
|
|
352
|
+
inputSchema: schemaOf({ scope: { type: 'string', enum: [...META_SCOPES], description: 'operateAuth 或 layout' } }, { required: ['scope'] }),
|
|
353
|
+
handler: async (args, { host }) => {
|
|
354
|
+
const scope = assertEnum(args.scope, META_SCOPES, 'scope');
|
|
355
|
+
if (scope === 'layout') {
|
|
356
|
+
const response = await host.request({
|
|
357
|
+
method: 'GET',
|
|
358
|
+
path: '/api/cowork/behavior/getLayout',
|
|
359
|
+
operation: 'cowork.meta',
|
|
360
|
+
});
|
|
361
|
+
return coworkSuccess('cowork.meta', unwrapData(response) ?? null, { scope });
|
|
362
|
+
}
|
|
363
|
+
const response = await host.request({
|
|
364
|
+
method: 'POST',
|
|
365
|
+
path: '/api/cowork/main/getListOperateAuth',
|
|
366
|
+
body: {},
|
|
367
|
+
operation: 'cowork.meta',
|
|
368
|
+
});
|
|
369
|
+
return coworkSuccess('cowork.meta', unwrapData(response) ?? null, { scope });
|
|
370
|
+
},
|
|
371
|
+
};
|
|
372
|
+
const coworkPermissionList = {
|
|
373
|
+
name: 'cowork.permission.list',
|
|
374
|
+
resource: 'cowork',
|
|
375
|
+
method: 'permission.list',
|
|
376
|
+
action: 'cowork.permission.list',
|
|
377
|
+
summary: '查协作的共享权限对象列表(删除共享对象前用它取得真实记录 id)',
|
|
378
|
+
risk: READ,
|
|
379
|
+
inputSchema: schemaOf({
|
|
380
|
+
coworkId: { ...SCHEMA_ID, description: '协作 id' },
|
|
381
|
+
permissionId: { ...SCHEMA_ID, description: '权限类型 id,默认 5(协作默认参与权限)' },
|
|
382
|
+
current: SCHEMA_PAGE_CURRENT,
|
|
383
|
+
pageSize: SCHEMA_PAGE_SIZE,
|
|
384
|
+
}, { required: ['coworkId'] }),
|
|
385
|
+
handler: async (args, { host }) => {
|
|
386
|
+
const coworkId = toId(args.coworkId, 'coworkId');
|
|
387
|
+
const permissionId = toId(args.permissionId, 'permissionId') ?? '5';
|
|
388
|
+
const body = {
|
|
389
|
+
sourceId: coworkId,
|
|
390
|
+
permissionId,
|
|
391
|
+
sourceType: 1,
|
|
392
|
+
current: toPositiveInt(args.current, 'current') ?? 1,
|
|
393
|
+
pageSize: toPositiveInt(args.pageSize, 'pageSize') ?? 50,
|
|
394
|
+
id: coworkId,
|
|
395
|
+
permissionFrom: permissionId,
|
|
396
|
+
};
|
|
397
|
+
const response = await host.request({
|
|
398
|
+
method: 'POST',
|
|
399
|
+
path: '/api/cowork/permission/getCoworkSharePermissionList',
|
|
400
|
+
body,
|
|
401
|
+
operation: 'cowork.permission.list',
|
|
402
|
+
});
|
|
403
|
+
const { data, page } = normalizeList(response);
|
|
404
|
+
return coworkSuccess('cowork.permission.list', data, { coworkId, permissionId, ...page });
|
|
405
|
+
},
|
|
406
|
+
};
|
|
407
|
+
export const coworkReadOperations = [
|
|
408
|
+
coworkList,
|
|
409
|
+
coworkConditions,
|
|
410
|
+
coworkCount,
|
|
411
|
+
coworkView,
|
|
412
|
+
coworkDiscussList,
|
|
413
|
+
coworkParticipantList,
|
|
414
|
+
coworkResource,
|
|
415
|
+
coworkVoteLog,
|
|
416
|
+
coworkForm,
|
|
417
|
+
coworkMeta,
|
|
418
|
+
coworkPermissionList,
|
|
419
|
+
];
|
|
420
|
+
/** 供测试与 manifest 复用的路径映射(避免测试硬编码路径与实现漂移)。 */
|
|
421
|
+
export const COWORK_LIST_PATHS = LIST_PATHS;
|
|
422
|
+
export const COWORK_CONDITION_PATHS = CONDITION_PATHS;
|
|
423
|
+
export { LIST_SCOPES, CONDITION_SCOPES };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { coworkValidationError } from '../errors.js';
|
|
2
|
+
import { coworkReadOperations } from './read.js';
|
|
3
|
+
import { coworkItemWriteOperations } from './item-write.js';
|
|
4
|
+
import { coworkDiscussWriteOperations } from './discuss-write.js';
|
|
5
|
+
import { coworkMemberWriteOperations } from './member-write.js';
|
|
6
|
+
import { coworkReviewOperations } from './review-write.js';
|
|
7
|
+
import { coworkPermissionWriteOperations } from './permission-write.js';
|
|
8
|
+
function buildRegistry() {
|
|
9
|
+
const registry = new Map();
|
|
10
|
+
const definitions = [
|
|
11
|
+
...coworkReadOperations,
|
|
12
|
+
...coworkItemWriteOperations,
|
|
13
|
+
...coworkDiscussWriteOperations,
|
|
14
|
+
...coworkMemberWriteOperations,
|
|
15
|
+
...coworkReviewOperations,
|
|
16
|
+
...coworkPermissionWriteOperations,
|
|
17
|
+
];
|
|
18
|
+
for (const definition of definitions) {
|
|
19
|
+
if (registry.has(definition.name)) {
|
|
20
|
+
throw new Error(`duplicate cowork operation: ${definition.name}`);
|
|
21
|
+
}
|
|
22
|
+
registry.set(definition.name, definition);
|
|
23
|
+
}
|
|
24
|
+
return registry;
|
|
25
|
+
}
|
|
26
|
+
const coworkOperationRegistry = buildRegistry();
|
|
27
|
+
export function coworkOperationDefinitions() {
|
|
28
|
+
return [...coworkOperationRegistry.values()];
|
|
29
|
+
}
|
|
30
|
+
export function getCoworkOperation(operation) {
|
|
31
|
+
const definition = coworkOperationRegistry.get(operation);
|
|
32
|
+
if (!definition) {
|
|
33
|
+
throw coworkValidationError('operation_unknown', `协作区不支持操作:${operation}`);
|
|
34
|
+
}
|
|
35
|
+
return definition;
|
|
36
|
+
}
|
|
37
|
+
export function hasCoworkOperation(operation) {
|
|
38
|
+
return coworkOperationRegistry.has(operation);
|
|
39
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { CoworkCliError, coworkNotFoundError, coworkPartialError, coworkValidationError } from '../errors.js';
|
|
2
|
+
import { READ_BEFORE_WRITE, WRITE, SCHEMA_ID, coworkSuccess, schemaOf, } from './types.js';
|
|
3
|
+
import { assertEnum, compact, normalizeList, requireConfirm, toId, toPositiveInt, unwrapData, verifyLease, } from './shared.js';
|
|
4
|
+
function isNetworkError(error) {
|
|
5
|
+
return error instanceof CoworkCliError && error.type === 'network';
|
|
6
|
+
}
|
|
7
|
+
const REVIEW_ACTIONS = ['approve', 'delete'];
|
|
8
|
+
const REVIEW_SPECS = {
|
|
9
|
+
item: {
|
|
10
|
+
label: '事项审批',
|
|
11
|
+
listPath: '/api/cowork/itemApprove/getCoworkItemApproveList',
|
|
12
|
+
listBody: (page) => ({
|
|
13
|
+
current: page,
|
|
14
|
+
itemNameCondition: 'in',
|
|
15
|
+
sectionCondition: 'bl',
|
|
16
|
+
itemStatus: '1',
|
|
17
|
+
principalCondition: 'bl',
|
|
18
|
+
principal: '',
|
|
19
|
+
creatorCondition: 'bl',
|
|
20
|
+
creator: '',
|
|
21
|
+
type: 'and',
|
|
22
|
+
}),
|
|
23
|
+
actionPath: {
|
|
24
|
+
approve: '/api/cowork/itemApprove/approveCoworkItem',
|
|
25
|
+
delete: '/api/cowork/itemApprove/deleteCoworkItem',
|
|
26
|
+
},
|
|
27
|
+
actionForm: (_action, id) => ({ ids: id }),
|
|
28
|
+
},
|
|
29
|
+
discuss: {
|
|
30
|
+
label: '交流审批',
|
|
31
|
+
listPath: '/api/cowork/discussApprove/getCoworkDiscussApproveList',
|
|
32
|
+
listBody: (page) => ({ current: page, type: 'and', dateType: '' }),
|
|
33
|
+
actionPath: {
|
|
34
|
+
approve: '/api/cowork/discussApprove/approveCoworkDiscuss',
|
|
35
|
+
delete: '/api/cowork/discussApprove/deleteCoworkDiscuss',
|
|
36
|
+
},
|
|
37
|
+
actionForm: (action, id) => (action === 'delete' ? { id, isDeleteAll: 1 } : { id }),
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
async function locateReviewRecord(env, domain, recordId, maxPages, pageSize) {
|
|
41
|
+
const spec = REVIEW_SPECS[domain];
|
|
42
|
+
for (let page = 1; page <= maxPages; page++) {
|
|
43
|
+
const response = await env.host.request({
|
|
44
|
+
method: 'POST',
|
|
45
|
+
path: spec.listPath,
|
|
46
|
+
body: spec.listBody(page),
|
|
47
|
+
operation: `cowork.review.${domain}.prepare`,
|
|
48
|
+
});
|
|
49
|
+
const { data } = normalizeList(response);
|
|
50
|
+
const rows = Array.isArray(data) ? data : [];
|
|
51
|
+
if (rows.length === 0)
|
|
52
|
+
return null;
|
|
53
|
+
const hit = rows.find((row) => String(row.id ?? '') === recordId);
|
|
54
|
+
if (hit)
|
|
55
|
+
return hit;
|
|
56
|
+
if (rows.length < pageSize)
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
function buildReviewOperations(domain) {
|
|
62
|
+
const spec = REVIEW_SPECS[domain];
|
|
63
|
+
const prepareName = `cowork.review.${domain}.prepare`;
|
|
64
|
+
const applyName = `cowork.review.${domain}.apply`;
|
|
65
|
+
const prepare = {
|
|
66
|
+
name: prepareName,
|
|
67
|
+
resource: 'cowork',
|
|
68
|
+
method: `review.${domain}.prepare`,
|
|
69
|
+
action: prepareName,
|
|
70
|
+
summary: `${spec.label}台的动作摘要(approve 通过 / delete 删除):先在待审列表中定位记录并回显主题,不写入`,
|
|
71
|
+
risk: READ_BEFORE_WRITE,
|
|
72
|
+
inputSchema: schemaOf({
|
|
73
|
+
action: { type: 'string', enum: [...REVIEW_ACTIONS], description: 'approve 通过 / delete 删除' },
|
|
74
|
+
id: { ...SCHEMA_ID, description: `记录 id(来自 cowork.list 的 ${domain === 'item' ? 'itemApprove' : 'discussApprove'} 列表)` },
|
|
75
|
+
maxPages: { type: 'integer', minimum: 1, maximum: 20, description: '定位记录的翻页上限,默认 5' },
|
|
76
|
+
}, { required: ['action', 'id'] }),
|
|
77
|
+
handler: async (args, env) => {
|
|
78
|
+
const action = assertEnum(args.action, REVIEW_ACTIONS, 'action');
|
|
79
|
+
const id = toId(args.id, 'id');
|
|
80
|
+
const maxPages = toPositiveInt(args.maxPages, 'maxPages') ?? 5;
|
|
81
|
+
const hit = await locateReviewRecord(env, domain, id, maxPages, 50);
|
|
82
|
+
if (!hit) {
|
|
83
|
+
throw coworkNotFoundError('record_not_found', `在前 ${maxPages} 页${spec.label}列表中未找到记录 ${id}:请先用 cowork.list 拉取对应待审列表确认,禁止对未确认的记录执行动作`);
|
|
84
|
+
}
|
|
85
|
+
const session = await env.host.getSession();
|
|
86
|
+
const continuation = await env.continuation.issue({
|
|
87
|
+
operation: applyName,
|
|
88
|
+
baseUrl: session.baseUrl,
|
|
89
|
+
profile: session.profile,
|
|
90
|
+
userId: session.userId,
|
|
91
|
+
action,
|
|
92
|
+
id,
|
|
93
|
+
});
|
|
94
|
+
return coworkSuccess(prepareName, {
|
|
95
|
+
summary: {
|
|
96
|
+
domain,
|
|
97
|
+
action,
|
|
98
|
+
id,
|
|
99
|
+
itemName: hit.itemName ?? null,
|
|
100
|
+
applyer: hit.applyerName ?? hit.creatorName ?? hit.username ?? null,
|
|
101
|
+
status: hit.applyStatus ?? hit.approvalStatus ?? null,
|
|
102
|
+
},
|
|
103
|
+
continuation,
|
|
104
|
+
});
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
const apply = {
|
|
108
|
+
name: applyName,
|
|
109
|
+
resource: 'cowork',
|
|
110
|
+
method: `review.${domain}.apply`,
|
|
111
|
+
action: applyName,
|
|
112
|
+
summary: `执行${spec.label}动作(approve / delete),需 confirm=true 与 continuation`,
|
|
113
|
+
risk: WRITE,
|
|
114
|
+
requiresConfirmation: true,
|
|
115
|
+
inputSchema: schemaOf({
|
|
116
|
+
action: { type: 'string', enum: [...REVIEW_ACTIONS] },
|
|
117
|
+
id: { ...SCHEMA_ID },
|
|
118
|
+
confirm: { type: 'boolean' },
|
|
119
|
+
continuation: { type: 'string' },
|
|
120
|
+
}, { required: ['action', 'id', 'confirm', 'continuation'] }),
|
|
121
|
+
handler: async (args, env) => {
|
|
122
|
+
requireConfirm(args, applyName);
|
|
123
|
+
const lease = await verifyLease(args, applyName, env);
|
|
124
|
+
const action = assertEnum(args.action, REVIEW_ACTIONS, 'action');
|
|
125
|
+
const id = toId(args.id, 'id');
|
|
126
|
+
if (lease.action !== action || lease.id !== id) {
|
|
127
|
+
throw coworkValidationError('target_changed', '与 prepare 时的目标不一致,请重新执行 prepare');
|
|
128
|
+
}
|
|
129
|
+
let response;
|
|
130
|
+
try {
|
|
131
|
+
response = await env.host.request({
|
|
132
|
+
method: 'POST',
|
|
133
|
+
path: spec.actionPath[action],
|
|
134
|
+
form: compact(spec.actionForm(action, id)),
|
|
135
|
+
operation: applyName,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
if (isNetworkError(error)) {
|
|
140
|
+
throw coworkPartialError(`${spec.label}动作请求已发出但未收到确定结果,禁止自动重试:请重新拉取待审列表核对`, { domain, action, id });
|
|
141
|
+
}
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
144
|
+
return coworkSuccess(applyName, {
|
|
145
|
+
domain,
|
|
146
|
+
action,
|
|
147
|
+
id,
|
|
148
|
+
result: unwrapData(response) ?? null,
|
|
149
|
+
});
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
return [prepare, apply];
|
|
153
|
+
}
|
|
154
|
+
export const coworkReviewOperations = [
|
|
155
|
+
...buildReviewOperations('item'),
|
|
156
|
+
...buildReviewOperations('discuss'),
|
|
157
|
+
];
|