weaver-work-cli 0.1.44 → 0.1.45
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 +9 -5
- package/dist/chunks/{archive-P6TBQGKL.js → archive-ZQ4A4TV6.js} +388 -44
- package/dist/chunks/{archive-oa-7TQ2NXOH.js → archive-oa-BBDP7AKJ.js} +2 -2
- package/dist/chunks/{asset-3ELRG37G.js → asset-ZOJVBWZH.js} +2 -2
- package/dist/chunks/{asset-idle-WIGMUFMD.js → asset-idle-XGB5IPGT.js} +2 -2
- package/dist/chunks/{attachment-content-E3276UOV.js → attachment-content-CE3GMWTS.js} +3 -3
- package/dist/chunks/{blog-C5NMZAAC.js → blog-QSHLZSFW.js} +2 -2
- package/dist/chunks/caizhilian-KCQYFH72.js +204 -0
- package/dist/chunks/{calendar-FI2WNSBO.js → calendar-DLGMRJQA.js} +2 -2
- package/dist/chunks/{chunk-CWYGFU5B.js → chunk-3WBIQLMB.js} +2 -2
- package/dist/chunks/{chunk-PUQS5MWL.js → chunk-3YV7PKRL.js} +1 -1
- package/dist/chunks/{chunk-PC7VKEB5.js → chunk-3ZMAQQ3W.js} +161 -33
- package/dist/chunks/{chunk-GM6J7Q4B.js → chunk-4EXOIQDI.js} +40 -10
- package/dist/chunks/{chunk-ETNJSKMM.js → chunk-6NXT4ICB.js} +148 -21
- package/dist/chunks/chunk-762M5XJS.js +215 -0
- package/dist/chunks/{chunk-GAMZLAG2.js → chunk-77YP6I52.js} +1 -1
- package/dist/chunks/{chunk-WSF4NNMR.js → chunk-CZNZKOHR.js} +2 -2
- package/dist/chunks/{chunk-Z7VYWPZV.js → chunk-DGMYACGJ.js} +1 -1
- package/dist/chunks/{chunk-TA7FXXJD.js → chunk-DLY5GUXX.js} +1 -1
- package/dist/chunks/{chunk-BCVYBYYT.js → chunk-GR76ZDDX.js} +2 -2
- package/dist/chunks/{chunk-GRDRG6HP.js → chunk-HFXK54M4.js} +2 -2
- package/dist/chunks/{chunk-XNIK66I4.js → chunk-JB34OE7R.js} +790 -77
- package/dist/chunks/{chunk-QVSWRLLU.js → chunk-JWWTI63L.js} +55 -5
- package/dist/chunks/{chunk-FRZKBMSW.js → chunk-LGKWL4OH.js} +176 -39
- package/dist/chunks/{chunk-XHK4MDR5.js → chunk-LRCPNDZA.js} +38 -6
- package/dist/chunks/{chunk-OF4S23UB.js → chunk-LXFVWZLM.js} +4 -4
- package/dist/chunks/{chunk-D4ADSZ7H.js → chunk-O6CMPO65.js} +24 -1
- package/dist/chunks/{chunk-N4M2DDFE.js → chunk-OAE3AZBQ.js} +11 -11
- package/dist/chunks/chunk-P5GQRWDC.js +60 -0
- package/dist/chunks/{caizhilian-5XSM2DFP.js → chunk-PGO4ILMQ.js} +41 -521
- package/dist/chunks/{chunk-HIT4Y6OI.js → chunk-T4MWQAQB.js} +7 -5
- package/dist/chunks/{chunk-F4E4EM35.js → chunk-TGAGQV4I.js} +2 -2
- package/dist/chunks/{chunk-UFIT2UU3.js → chunk-U6R6FZHD.js} +168 -14
- package/dist/chunks/{chunk-FAZTGX7S.js → chunk-VIMCY4DI.js} +5 -5
- package/dist/chunks/chunk-VRPH24IC.js +76 -0
- package/dist/chunks/{chunk-3YBDYOC4.js → chunk-YIKSL36S.js} +2 -2
- package/dist/chunks/{chunk-IAZ3UPY6.js → chunk-Z6UUBY37.js} +2 -2
- package/dist/chunks/{conflict-ARLSZJ6V.js → conflict-IYJETSGT.js} +2 -2
- package/dist/chunks/continuation-GW6PRWK3.js +12 -0
- package/dist/chunks/{contract-DNIIW5VJ.js → contract-3QLAGYQL.js} +5793 -4591
- package/dist/chunks/{cowork-GMLRGVIW.js → cowork-3ACICHDQ.js} +2 -2
- package/dist/chunks/{create-flow-J22BO65E.js → create-flow-7JLC7UID.js} +6 -6
- package/dist/chunks/{ebuilder-form-ANV2FHYV.js → ebuilder-form-GWDTKEI2.js} +5 -5
- package/dist/chunks/{ehr-GSTGAIY3.js → ehr-MYRDCHZ4.js} +121 -49
- package/dist/chunks/{employee-22BGJ3QS.js → employee-NOHNXC46.js} +1 -1
- package/dist/chunks/{env-BX3VRFS7.js → env-3MBHAWBL.js} +2 -2
- package/dist/chunks/{esb-ATAIASX2.js → esb-4BQHNP5C.js} +4 -4
- package/dist/chunks/{factory-PETTFME6.js → factory-TZEVU4DU.js} +1 -1
- package/dist/chunks/{fna-YEKBSFSX.js → fna-ZVB2IILI.js} +2 -2
- package/dist/chunks/{group-chat-BFVXAYFX.js → group-chat-KL3HFKRM.js} +3 -3
- package/dist/chunks/{host-WIKN2EJ5.js → host-3TNBMDTR.js} +3 -3
- package/dist/chunks/host-7NTIBSPK.js +25 -0
- package/dist/chunks/{host-SZGV4UNT.js → host-7OWWPLM4.js} +3 -3
- package/dist/chunks/{host-HRBXEPDQ.js → host-G3VU7SDW.js} +3 -3
- package/dist/chunks/{host-LR55CTHP.js → host-M4XP5URR.js} +3 -3
- package/dist/chunks/{host-SUOY6VYQ.js → host-TUOIOEMC.js} +3 -3
- package/dist/chunks/{hrm-NRDO4W5G.js → hrm-UNKCCCGP.js} +5 -5
- package/dist/chunks/{im-IQ2HN23S.js → im-NJB7ZYMH.js} +3 -3
- package/dist/chunks/{invoice-MNRW76PP.js → invoice-OQP3TMKQ.js} +3 -3
- package/dist/chunks/{jiuchuanhui-DTRBAX4N.js → jiuchuanhui-ASFZBMPU.js} +2 -2
- package/dist/chunks/{lazy-dispatch-ZVWAI25B.js → lazy-dispatch-UH6HGK2I.js} +4 -4
- package/dist/chunks/{mail-ZVAUXOJA.js → mail-M3HJF5ER.js} +2 -2
- package/dist/chunks/{meeting-FEVPZ67S.js → meeting-C67EHQ4Z.js} +12 -12
- package/dist/chunks/{okr-SDH3E5RA.js → okr-EVX7FB5G.js} +2 -2
- package/dist/chunks/operations-J7PUIVWZ.js +15 -0
- package/dist/chunks/{plan-E35JFDI7.js → plan-2QJQEPBO.js} +2 -2
- package/dist/chunks/{project-73QXBAB2.js → project-XELELW2T.js} +2 -2
- package/dist/chunks/{reception-UWZVACBN.js → reception-5WITA44R.js} +2 -2
- package/dist/chunks/{recruit-stage-4MAOCKFY.js → recruit-stage-AHY5QAMF.js} +450 -117
- package/dist/chunks/{registry-JDUS4E7D.js → registry-AQVGHUM6.js} +2 -2
- package/dist/chunks/{registry-KNKSCJNT.js → registry-QJCZ2GVG.js} +4 -4
- package/dist/chunks/{registry-PO7SI256.js → registry-VWXWPVAG.js} +2 -2
- package/dist/chunks/{registry-IM5G23LS.js → registry-XPWPGHYE.js} +10 -10
- package/dist/chunks/{room-recommend-H7KLXA5R.js → room-recommend-CNWE5WQK.js} +6 -4
- package/dist/chunks/{schedule-ESZIBAUO.js → schedule-YYNYBQIE.js} +4 -4
- package/dist/chunks/{workflow-CWJFJLQU.js → workflow-BSYT5TGL.js} +6 -4
- package/dist/index.js +30 -30
- package/dist/internal/e10/auth/commands.js +32 -0
- package/dist/internal/e10/auth/error-log.js +156 -26
- package/dist/internal/e10/auth/xiaoe.js +176 -13
- package/dist/internal/e10/context.js +12 -1
- package/dist/shortcuts/archive/operations/borrow-list.js +105 -14
- package/dist/shortcuts/archive/operations/flow-url.js +182 -22
- package/dist/shortcuts/archive/operations/getPageUrl.js +75 -0
- package/dist/shortcuts/archive/operations/prelib.js +33 -4
- package/dist/shortcuts/archive/operations/shared.js +52 -0
- package/dist/shortcuts/contract/host.js +111 -4
- package/dist/shortcuts/contract/index.js +19 -0
- package/dist/shortcuts/contract/manifest.js +125 -0
- package/dist/shortcuts/contract/ooxml/clause-insert.js +249 -0
- package/dist/shortcuts/contract/operations/clause-insert.js +56 -0
- package/dist/shortcuts/contract/operations/customer.js +192 -0
- package/dist/shortcuts/contract/operations/file-download.js +75 -0
- package/dist/shortcuts/contract/operations/flow.js +44 -2
- package/dist/shortcuts/contract/operations/form-info.js +162 -62
- package/dist/shortcuts/contract/operations/registry.js +8 -0
- package/dist/shortcuts/contract/operations/review.js +116 -1
- package/dist/shortcuts/contract/operations/summary.js +177 -0
- package/dist/shortcuts/contract/operations/upload.js +64 -4
- package/dist/shortcuts/contract/upload-cache.js +104 -0
- package/dist/shortcuts/ehr/operations/recruit-candidate-import.js +4 -2
- package/dist/shortcuts/ehr/operations/recruit-position.js +136 -35
- package/dist/shortcuts/ehr/operations/recruit-write.js +17 -18
- package/dist/shortcuts/ehr/operations/recruit.js +17 -5
- package/dist/shortcuts/hrm/operations/employee.js +29 -1
- package/dist/shortcuts/meeting/operations/eb/create-flow.js +182 -58
- package/dist/shortcuts/meeting/operations/eb/draft-memory.js +56 -0
- package/dist/shortcuts/meeting/operations/eb/factory.js +58 -3
- package/dist/shortcuts/meeting/operations/eb/person-cache.js +2 -2
- package/dist/shortcuts/meeting/operations/eb/room-recommend.js +47 -5
- package/dist/shortcuts/meeting/operations/invitation-publish.js +132 -0
- package/dist/shortcuts/meeting/operations/registry.js +2 -0
- package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +86 -16
- package/dist/shortcuts/recruit-stage/operations/interview-feedback.js +6 -4
- package/dist/shortcuts/recruit-stage/operations/jd-create.js +208 -56
- package/dist/shortcuts/recruit-stage/operations/resume-import.js +42 -16
- package/dist/shortcuts/recruit-stage/shared.js +161 -18
- package/dist/shortcuts/workflow/index.js +2 -0
- package/dist/shortcuts/workflow/operations/read.js +8 -3
- package/dist/shortcuts/workflow/operations/todoSmartConvert/aigroupRules.js +92 -5
- package/dist/shortcuts/workflow/operations/todoSmartConvert/priorityExpr.js +509 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoListRows.js +22 -1
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +32 -6
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +57 -11
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.group.js +165 -52
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +57 -14
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.smartGroup.js +44 -18
- package/docs/contract.md +1 -0
- package/docs/e10-auth.md +4 -2
- package/docs/todo-smart-convert/data-contract.md +7 -0
- package/package.json +1 -1
- package/skill-template/domains/jinchengda.md +2 -0
- package/skills/weaver-e10-jinchengda/SKILL.md +198 -205
- package/skills/weaver-e10-jinchengda/references/contract-action-card.md +759 -0
- package/skills/weaver-e10-jinchengda/references/contract-action-engine.md +250 -0
- package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +146 -7
- package/skills/weaver-e10-jinchengda/references/contract-clause-insert.md +178 -0
- package/skills/weaver-e10-jinchengda/references/contract-command-index.md +75 -0
- package/skills/weaver-e10-jinchengda/references/contract-compare-report-template.html +137 -0
- package/skills/weaver-e10-jinchengda/references/contract-compare-report.md +163 -0
- package/skills/weaver-e10-jinchengda/references/contract-credit-page.md +52 -3
- package/skills/weaver-e10-jinchengda/references/contract-doc-compare.md +92 -5
- package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +602 -0
- package/skills/weaver-e10-jinchengda/references/contract-element-extract.md +209 -0
- package/skills/weaver-e10-jinchengda/references/contract-execution-rules.md +126 -0
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +312 -0
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +555 -0
- package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +47 -12
- package/skills/weaver-e10-jinchengda/references/contract-object-detect.md +469 -0
- package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +154 -1
- package/skills/weaver-e10-jinchengda/references/contract-type-fingerprints.md +224 -0
- package/skills/weaver-e10-jinchengda/references/orchestration.md +355 -0
- package/skills/weaver-e10-jucailin/references/recruit-create.md +5 -3
- package/skills/weaver-e10-jucailin/references/recruit-write.md +2 -2
- package/skills/weaver-e10-meeting/SKILL.md +57 -9
- package/skills/weaver-e10-recruit-stage/SKILL.md +11 -6
- package/skills/weaver-e10-recruit-stage/agents/openai.yaml +10 -2
- package/skills/weaver-e10-recruit-stage/references/position-templates.md +3 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +13 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +19 -18
- package/skills/weaver-e10-recruit-stage/references/recruit-output-links.md +27 -14
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +7 -1
- package/skills/weaver-e10-shared/references/e10-auth-and-session.md +4 -2
- package/skills/weaver-e10-wenshuding/SKILL.md +17 -7
- package/skills/weaver-e10-wenshuding/references/archive-borrow-list.md +28 -0
- package/skills/weaver-e10-wenshuding/references/archive-flow.md +24 -8
- package/skills/weaver-e10-wenshuding/references/archive-prelib-list.md +3 -0
- package/skills/weaver-e10-wenshuding/references/archive-prelib-open.md +4 -0
- package/skills/weaver-e10-wenshuding/references/archive-search.md +3 -1
- package/skills/weaver-e10-workflow/SKILL.md +19 -17
- package/skills/weaver-e10-workflow/aigroup/default.json +10 -6
- package/skills/weaver-e10-workflow/references/todo-smart-convert.md +36 -3
- package/skills/weaver-e10-workflow/references/workflow-memory.md +1 -1
- package/skills/weaver-e10-workflow/references/workflow-query.md +9 -6
- package/skills/weaver-e10-workflow/tools/todo-summary.cjs +152 -1
- package/skills/weaver-e10-yimiaoban/SKILL.md +17 -5
- package/skills/weaver-e10-yimiaoban/references/msg-write.md +30 -0
- package/skills/weaver-e10-yimiaoban/references/session-sysmsg.md +72 -0
- package/skills/weaver-e10-yimiaoban/references/source-manifest.json +7 -7
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 「建议优先处理的流程」规则表达式(2026-11-05 用户定稿)。
|
|
3
|
+
*
|
|
4
|
+
* 为什么要一个表达式:原来的入选口径是两条硬编码规则(`overdue` 超时 + `levelFallback`
|
|
5
|
+
* 紧急程度降级链),只能组合出固定的两种形态。用户要「按 getTodoListData 的原始字段判断、
|
|
6
|
+
* 支持任意嵌套的 and/or」,于是把口径外置成一条字符串表达式,写在
|
|
7
|
+
* `generalRules.priorityGroup.rule` 里,由本模块解析 + 求值。
|
|
8
|
+
*
|
|
9
|
+
* 语法(大小写不敏感,AND/OR/NOT 与「且/或/非」等价):
|
|
10
|
+
* ```
|
|
11
|
+
* 表达式 := 或表达式
|
|
12
|
+
* 或表达式 := 与表达式 (OR 与表达式)*
|
|
13
|
+
* 与表达式 := 非表达式 (AND 非表达式)*
|
|
14
|
+
* 非表达式 := NOT? 原子
|
|
15
|
+
* 原子 := '(' 表达式 ')' | 条件
|
|
16
|
+
* 条件 := 字段 比较符 值
|
|
17
|
+
* 比较符 := = | == | != | > | >= | < | <=
|
|
18
|
+
* | 包含 | 不包含 | in | not in | 为空 | 不为空
|
|
19
|
+
* 值 := 数字 | '字符串' | "字符串" | true | false
|
|
20
|
+
* | 今天 | 昨天 | 明天 | 今天+N天 | 今天-N天 (N 为非负整数,`天` 可省)
|
|
21
|
+
* | '(' 列表 ')'
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* 日期一律**只比到「日」**:字段值里的时分秒(`2026-11-05 23:59:59`)不参与比较。
|
|
25
|
+
*
|
|
26
|
+
* 例:
|
|
27
|
+
* ```
|
|
28
|
+
* overTime = true OR (requestlevel >= 2 AND curUserOverTime <= 今天)
|
|
29
|
+
* curUserOverTime = 今天+1天 ← 明天到期
|
|
30
|
+
* curUserOverTime >= 今天-3天 AND curUserOverTime <= 今天 ← 最近三天到期
|
|
31
|
+
* isremark not in (20, 21, 30, 31, 40, 41, 50, 51, 60, 61, 70, 71, 80, 81) AND requestlevel >= 1
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* 求值约定(与现有 focusKeyword 一致):**字段缺失/空串一律不命中**,不猜。
|
|
35
|
+
* 日期只比到「日」,时间部分忽略;只写月日(`11-04`)按当前年补齐、跨年回退上一年,
|
|
36
|
+
* 与 `isExpiredUserOverTime` 同一套口径。
|
|
37
|
+
*/
|
|
38
|
+
/** 解析失败:带字符位置,便于在 default.json 里直接定位。 */
|
|
39
|
+
export class PriorityExprError extends Error {
|
|
40
|
+
position;
|
|
41
|
+
constructor(message, position) {
|
|
42
|
+
super(`${message}(第 ${position + 1} 个字符)`);
|
|
43
|
+
this.name = 'PriorityExprError';
|
|
44
|
+
this.position = position;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// `+` / `-` 只用于日期偏移(`今天+1天`),不会与比较符冲突(`>=` 等先匹配)。
|
|
48
|
+
const OP_TOKENS = ['>=', '<=', '!=', '==', '=', '>', '<', '+', '-'];
|
|
49
|
+
/** 连续的中文/字母/下划线/数字/点都当标识符,中文关键字(且/或/包含/为空…)靠这里整体切出来。 */
|
|
50
|
+
function isIdentChar(char) {
|
|
51
|
+
return /[A-Za-z0-9_.\u4e00-\u9fa5]/u.test(char);
|
|
52
|
+
}
|
|
53
|
+
function tokenize(source) {
|
|
54
|
+
const tokens = [];
|
|
55
|
+
let index = 0;
|
|
56
|
+
while (index < source.length) {
|
|
57
|
+
const char = source[index];
|
|
58
|
+
if (/\s/u.test(char)) {
|
|
59
|
+
index += 1;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (char === '(') {
|
|
63
|
+
tokens.push({ type: 'lparen', value: char, pos: index });
|
|
64
|
+
index += 1;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (char === ')') {
|
|
68
|
+
tokens.push({ type: 'rparen', value: char, pos: index });
|
|
69
|
+
index += 1;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (char === ',') {
|
|
73
|
+
tokens.push({ type: 'comma', value: char, pos: index });
|
|
74
|
+
index += 1;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (char === "'" || char === '"') {
|
|
78
|
+
const quote = char;
|
|
79
|
+
const start = index;
|
|
80
|
+
index += 1;
|
|
81
|
+
let text = '';
|
|
82
|
+
while (index < source.length && source[index] !== quote) {
|
|
83
|
+
if (source[index] === '\\' && index + 1 < source.length) {
|
|
84
|
+
text += source[index + 1];
|
|
85
|
+
index += 2;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
text += source[index];
|
|
89
|
+
index += 1;
|
|
90
|
+
}
|
|
91
|
+
if (index >= source.length)
|
|
92
|
+
throw new PriorityExprError('字符串缺少结束引号', start);
|
|
93
|
+
index += 1;
|
|
94
|
+
tokens.push({ type: 'string', value: text, pos: start });
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const opToken = OP_TOKENS.find((token) => source.startsWith(token, index));
|
|
98
|
+
if (opToken) {
|
|
99
|
+
tokens.push({ type: 'op', value: opToken, pos: index });
|
|
100
|
+
index += opToken.length;
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (/\d/u.test(char)) {
|
|
104
|
+
const start = index;
|
|
105
|
+
while (index < source.length && /[\d.]/u.test(source[index]))
|
|
106
|
+
index += 1;
|
|
107
|
+
const text = source.slice(start, index);
|
|
108
|
+
if (!/^\d+(?:\.\d+)?$/u.test(text))
|
|
109
|
+
throw new PriorityExprError(`数字写法不合法:「${text}」`, start);
|
|
110
|
+
tokens.push({ type: 'number', value: text, pos: start });
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if (isIdentChar(char)) {
|
|
114
|
+
const start = index;
|
|
115
|
+
while (index < source.length && isIdentChar(source[index]))
|
|
116
|
+
index += 1;
|
|
117
|
+
tokens.push({ type: 'ident', value: source.slice(start, index), pos: start });
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
throw new PriorityExprError(`无法识别的字符「${char}」`, index);
|
|
121
|
+
}
|
|
122
|
+
return tokens;
|
|
123
|
+
}
|
|
124
|
+
/** 关键字归一(大小写不敏感;中文别名等价)。 */
|
|
125
|
+
function keywordOf(token) {
|
|
126
|
+
if (token.type !== 'ident')
|
|
127
|
+
return null;
|
|
128
|
+
const text = token.value.toLowerCase();
|
|
129
|
+
const map = {
|
|
130
|
+
and: 'and', '且': 'and',
|
|
131
|
+
or: 'or', '或': 'or',
|
|
132
|
+
not: 'not', '非': 'not',
|
|
133
|
+
in: 'in', '属于': 'in',
|
|
134
|
+
true: 'true', 'false': 'false',
|
|
135
|
+
'今天': 'today', '昨天': 'yesterday', '明天': 'tomorrow',
|
|
136
|
+
'包含': 'contains', '不包含': 'notContains',
|
|
137
|
+
'为空': 'isEmpty', '不为空': 'isNotEmpty',
|
|
138
|
+
};
|
|
139
|
+
return map[text] ?? null;
|
|
140
|
+
}
|
|
141
|
+
class Parser {
|
|
142
|
+
tokens;
|
|
143
|
+
source;
|
|
144
|
+
index = 0;
|
|
145
|
+
constructor(source) {
|
|
146
|
+
this.source = source;
|
|
147
|
+
this.tokens = tokenize(source);
|
|
148
|
+
}
|
|
149
|
+
parse() {
|
|
150
|
+
if (this.tokens.length === 0)
|
|
151
|
+
throw new PriorityExprError('规则表达式不能为空', 0);
|
|
152
|
+
const expr = this.parseOr();
|
|
153
|
+
const rest = this.peek();
|
|
154
|
+
if (rest)
|
|
155
|
+
throw new PriorityExprError(`多余的内容「${this.source.slice(rest.pos)}」`, rest.pos);
|
|
156
|
+
return expr;
|
|
157
|
+
}
|
|
158
|
+
peek() {
|
|
159
|
+
return this.tokens[this.index];
|
|
160
|
+
}
|
|
161
|
+
next() {
|
|
162
|
+
const token = this.tokens[this.index];
|
|
163
|
+
if (!token) {
|
|
164
|
+
const end = this.tokens[this.tokens.length - 1]?.pos ?? 0;
|
|
165
|
+
throw new PriorityExprError('表达式在此处意外结束', end);
|
|
166
|
+
}
|
|
167
|
+
this.index += 1;
|
|
168
|
+
return token;
|
|
169
|
+
}
|
|
170
|
+
matchKeyword(word) {
|
|
171
|
+
const token = this.peek();
|
|
172
|
+
if (token && keywordOf(token) === word) {
|
|
173
|
+
this.index += 1;
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
parseOr() {
|
|
179
|
+
const children = [this.parseAnd()];
|
|
180
|
+
while (this.matchKeyword('or'))
|
|
181
|
+
children.push(this.parseAnd());
|
|
182
|
+
return children.length === 1 ? children[0] : { kind: 'or', children };
|
|
183
|
+
}
|
|
184
|
+
parseAnd() {
|
|
185
|
+
const children = [this.parseNot()];
|
|
186
|
+
while (this.matchKeyword('and'))
|
|
187
|
+
children.push(this.parseNot());
|
|
188
|
+
return children.length === 1 ? children[0] : { kind: 'and', children };
|
|
189
|
+
}
|
|
190
|
+
parseNot() {
|
|
191
|
+
if (this.matchKeyword('not'))
|
|
192
|
+
return { kind: 'not', child: this.parseNot() };
|
|
193
|
+
return this.parseAtom();
|
|
194
|
+
}
|
|
195
|
+
parseAtom() {
|
|
196
|
+
const token = this.peek();
|
|
197
|
+
if (!token) {
|
|
198
|
+
const end = this.tokens[this.tokens.length - 1]?.pos ?? 0;
|
|
199
|
+
throw new PriorityExprError('表达式在此处意外结束', end);
|
|
200
|
+
}
|
|
201
|
+
if (token.type === 'lparen') {
|
|
202
|
+
this.index += 1;
|
|
203
|
+
const inner = this.parseOr();
|
|
204
|
+
const close = this.peek();
|
|
205
|
+
if (!close || close.type !== 'rparen')
|
|
206
|
+
throw new PriorityExprError('括号没有闭合', token.pos);
|
|
207
|
+
this.index += 1;
|
|
208
|
+
return inner;
|
|
209
|
+
}
|
|
210
|
+
return this.parseCondition();
|
|
211
|
+
}
|
|
212
|
+
parseCondition() {
|
|
213
|
+
const start = this.peek();
|
|
214
|
+
if (!start)
|
|
215
|
+
throw new PriorityExprError('缺少字段名', 0);
|
|
216
|
+
if (keywordOf(start)) {
|
|
217
|
+
throw new PriorityExprError(`「${start.value}」是关键字,此处应为字段名`, start.pos);
|
|
218
|
+
}
|
|
219
|
+
if (start.type !== 'ident' && start.type !== 'number') {
|
|
220
|
+
throw new PriorityExprError(`此处应为字段名,收到「${start.value}」`, start.pos);
|
|
221
|
+
}
|
|
222
|
+
this.index += 1;
|
|
223
|
+
const field = start.value;
|
|
224
|
+
const opToken = this.peek();
|
|
225
|
+
if (!opToken)
|
|
226
|
+
throw new PriorityExprError(`字段「${field}」后面缺少比较符`, start.pos);
|
|
227
|
+
let op;
|
|
228
|
+
if (opToken.type === 'op') {
|
|
229
|
+
this.index += 1;
|
|
230
|
+
const map = {
|
|
231
|
+
'=': 'eq', '==': 'eq', '!=': 'ne', '>': 'gt', '>=': 'gte', '<': 'lt', '<=': 'lte',
|
|
232
|
+
};
|
|
233
|
+
const mapped = map[opToken.value];
|
|
234
|
+
if (!mapped) {
|
|
235
|
+
// `+` / `-` 只在日期偏移里合法(`今天+1天`),跑到比较符位置就是写错了
|
|
236
|
+
throw new PriorityExprError(`比较符「${opToken.value}」不合法(可用:= != > >= < <= 包含 不包含 in not in 为空 不为空)`, opToken.pos);
|
|
237
|
+
}
|
|
238
|
+
op = mapped;
|
|
239
|
+
}
|
|
240
|
+
else if (keywordOf(opToken) === 'not' && this.tokens[this.index + 1] && keywordOf(this.tokens[this.index + 1]) === 'in') {
|
|
241
|
+
this.index += 2;
|
|
242
|
+
op = 'notIn';
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
const keyword = keywordOf(opToken);
|
|
246
|
+
const map = {
|
|
247
|
+
in: 'in', contains: 'contains', notContains: 'notContains',
|
|
248
|
+
isEmpty: 'isEmpty', isNotEmpty: 'isNotEmpty',
|
|
249
|
+
};
|
|
250
|
+
if (!keyword || !(keyword in map)) {
|
|
251
|
+
throw new PriorityExprError(`字段「${field}」后面的比较符「${opToken.value}」不支持`, opToken.pos);
|
|
252
|
+
}
|
|
253
|
+
this.index += 1;
|
|
254
|
+
op = map[keyword];
|
|
255
|
+
}
|
|
256
|
+
const text = this.source.slice(start.pos, this.tokens[Math.max(0, this.index - 1)].pos
|
|
257
|
+
+ String(this.tokens[Math.max(0, this.index - 1)].value).length);
|
|
258
|
+
if (op === 'isEmpty' || op === 'isNotEmpty')
|
|
259
|
+
return { kind: 'condition', field, op, text };
|
|
260
|
+
const operand = this.parseOperand(op === 'in' || op === 'notIn');
|
|
261
|
+
return { kind: 'condition', field, op, operand, text };
|
|
262
|
+
}
|
|
263
|
+
parseOperand(isList) {
|
|
264
|
+
if (isList) {
|
|
265
|
+
const open = this.peek();
|
|
266
|
+
if (!open || open.type !== 'lparen') {
|
|
267
|
+
throw new PriorityExprError('in / not in 后面必须是括号列表,如 (20, 21, 30)', open?.pos ?? 0);
|
|
268
|
+
}
|
|
269
|
+
this.index += 1;
|
|
270
|
+
const items = [];
|
|
271
|
+
for (;;) {
|
|
272
|
+
items.push(this.parseScalarLiteral());
|
|
273
|
+
const token = this.peek();
|
|
274
|
+
if (token && token.type === 'comma') {
|
|
275
|
+
this.index += 1;
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
if (token && token.type === 'rparen') {
|
|
279
|
+
this.index += 1;
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
282
|
+
throw new PriorityExprError('列表缺少右括号', token?.pos ?? 0);
|
|
283
|
+
}
|
|
284
|
+
if (items.length === 0)
|
|
285
|
+
throw new PriorityExprError('列表不能为空', open.pos);
|
|
286
|
+
return { kind: 'list', items };
|
|
287
|
+
}
|
|
288
|
+
return this.parseScalarLiteral();
|
|
289
|
+
}
|
|
290
|
+
parseScalarLiteral() {
|
|
291
|
+
const token = this.next();
|
|
292
|
+
if (token.type === 'number')
|
|
293
|
+
return { kind: 'number', value: Number(token.value) };
|
|
294
|
+
if (token.type === 'string')
|
|
295
|
+
return { kind: 'string', value: token.value };
|
|
296
|
+
const keyword = keywordOf(token);
|
|
297
|
+
if (keyword === 'true')
|
|
298
|
+
return { kind: 'boolean', value: true };
|
|
299
|
+
if (keyword === 'false')
|
|
300
|
+
return { kind: 'boolean', value: false };
|
|
301
|
+
if (keyword === 'today')
|
|
302
|
+
return this.parseDateOffset('今天');
|
|
303
|
+
if (keyword === 'yesterday')
|
|
304
|
+
return this.parseDateOffset('昨天');
|
|
305
|
+
if (keyword === 'tomorrow')
|
|
306
|
+
return this.parseDateOffset('明天');
|
|
307
|
+
throw new PriorityExprError(`「${token.value}」不是合法取值:字符串请加引号(如 '已超时'),日期可用 今天 / 昨天 / 明天,或用 今天+1天 / 今天-3天 做偏移`, token.pos);
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* 日期字面量的可选天数偏移(2026-11-05 用户定:`今天+n天` 调规则,n 可正可负)。
|
|
311
|
+
*
|
|
312
|
+
* 写法:`今天` / `今天+1天` / `今天-3天` / `今天+2`(`天` 可省;空格随意)。
|
|
313
|
+
* 只算到「日」,时分秒在求值阶段整体忽略。
|
|
314
|
+
*/
|
|
315
|
+
parseDateOffset(base) {
|
|
316
|
+
const token = this.peek();
|
|
317
|
+
if (!token || token.type !== 'op' || (token.value !== '+' && token.value !== '-')) {
|
|
318
|
+
return { kind: 'date', value: base, offsetDays: 0 };
|
|
319
|
+
}
|
|
320
|
+
this.index += 1;
|
|
321
|
+
const num = this.next();
|
|
322
|
+
if (num.type !== 'number' || !/^\d+$/u.test(num.value)) {
|
|
323
|
+
throw new PriorityExprError('日期偏移必须是整数天数,如 今天+1天 / 今天-3天', num.pos);
|
|
324
|
+
}
|
|
325
|
+
const tail = this.peek();
|
|
326
|
+
if (tail && tail.type === 'ident' && tail.value === '天')
|
|
327
|
+
this.index += 1;
|
|
328
|
+
const days = Number(num.value);
|
|
329
|
+
return { kind: 'date', value: base, offsetDays: token.value === '-' ? -days : days };
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
/** 解析规则表达式;语法错误抛 `PriorityExprError`(带字符位置)。 */
|
|
333
|
+
export function parsePriorityRule(source) {
|
|
334
|
+
return new Parser(source).parse();
|
|
335
|
+
}
|
|
336
|
+
/** 表达式里引用到的字段名(小写去重),供取数阶段做「按需保留原始字段」。 */
|
|
337
|
+
export function collectPriorityFields(expr, into = new Set()) {
|
|
338
|
+
switch (expr.kind) {
|
|
339
|
+
case 'and':
|
|
340
|
+
case 'or':
|
|
341
|
+
for (const child of expr.children)
|
|
342
|
+
collectPriorityFields(child, into);
|
|
343
|
+
break;
|
|
344
|
+
case 'not':
|
|
345
|
+
collectPriorityFields(expr.child, into);
|
|
346
|
+
break;
|
|
347
|
+
case 'condition':
|
|
348
|
+
into.add(expr.field.toLowerCase());
|
|
349
|
+
break;
|
|
350
|
+
}
|
|
351
|
+
return into;
|
|
352
|
+
}
|
|
353
|
+
const YEAR_WINDOW_MS = 180 * 24 * 60 * 60 * 1000;
|
|
354
|
+
/** 解析字段值为「年月日」;只比到日,时间部分忽略。识别不了返回 null(不猜)。 */
|
|
355
|
+
function parseDateYmd(value, now) {
|
|
356
|
+
const text = String(value ?? '').trim();
|
|
357
|
+
if (!text)
|
|
358
|
+
return null;
|
|
359
|
+
const full = /^(\d{4})[-/](\d{1,2})[-/](\d{1,2})/u.exec(text);
|
|
360
|
+
if (full) {
|
|
361
|
+
const [, y, m, d] = full;
|
|
362
|
+
const stamp = new Date(Number(y), Number(m) - 1, Number(d));
|
|
363
|
+
if (Number.isNaN(stamp.getTime()))
|
|
364
|
+
return null;
|
|
365
|
+
return { key: stamp.getTime() };
|
|
366
|
+
}
|
|
367
|
+
const short = /^(\d{1,2})[-/](\d{1,2})/u.exec(text);
|
|
368
|
+
if (short) {
|
|
369
|
+
const [, m, d] = short;
|
|
370
|
+
const month = Number(m);
|
|
371
|
+
const day = Number(d);
|
|
372
|
+
if (month < 1 || month > 12 || day < 1 || day > 31)
|
|
373
|
+
return null;
|
|
374
|
+
let stamp = new Date(now.getFullYear(), month - 1, day).getTime();
|
|
375
|
+
if (stamp - now.getTime() > YEAR_WINDOW_MS) {
|
|
376
|
+
stamp = new Date(now.getFullYear() - 1, month - 1, day).getTime();
|
|
377
|
+
}
|
|
378
|
+
return { key: stamp };
|
|
379
|
+
}
|
|
380
|
+
return null;
|
|
381
|
+
}
|
|
382
|
+
/** 日期字面量的目标日(**只到年月日**,时分秒丢弃);`offsetDays` 是用户写的 `+n天` / `-n天`。 */
|
|
383
|
+
function dateTokenYmd(which, offsetDays, now) {
|
|
384
|
+
const base = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
|
385
|
+
const baseOffset = which === '昨天' ? -1 : which === '明天' ? 1 : 0;
|
|
386
|
+
base.setDate(base.getDate() + baseOffset + offsetDays);
|
|
387
|
+
return base.getTime();
|
|
388
|
+
}
|
|
389
|
+
function asNumber(value) {
|
|
390
|
+
if (typeof value === 'number')
|
|
391
|
+
return Number.isFinite(value) ? value : null;
|
|
392
|
+
const text = String(value ?? '').trim();
|
|
393
|
+
if (!text)
|
|
394
|
+
return null;
|
|
395
|
+
const parsed = Number(text);
|
|
396
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
397
|
+
}
|
|
398
|
+
function asBoolean(value) {
|
|
399
|
+
if (typeof value === 'boolean')
|
|
400
|
+
return value;
|
|
401
|
+
const text = String(value ?? '').trim().toLowerCase();
|
|
402
|
+
if (text === 'true' || text === '1' || text === '是')
|
|
403
|
+
return true;
|
|
404
|
+
if (text === 'false' || text === '0' || text === '否')
|
|
405
|
+
return false;
|
|
406
|
+
return null;
|
|
407
|
+
}
|
|
408
|
+
function isEmptyValue(value) {
|
|
409
|
+
return value === undefined || value === null || String(value).trim() === '';
|
|
410
|
+
}
|
|
411
|
+
/** 单条条件求值。字段取不到 / 类型对不上 ⇒ false(不猜)。 */
|
|
412
|
+
function evaluateCondition(condition, raw, now) {
|
|
413
|
+
if (condition.op === 'isEmpty')
|
|
414
|
+
return isEmptyValue(raw);
|
|
415
|
+
if (condition.op === 'isNotEmpty')
|
|
416
|
+
return !isEmptyValue(raw);
|
|
417
|
+
if (isEmptyValue(raw))
|
|
418
|
+
return false;
|
|
419
|
+
const operand = condition.operand;
|
|
420
|
+
if (!operand)
|
|
421
|
+
return false;
|
|
422
|
+
switch (condition.op) {
|
|
423
|
+
case 'contains':
|
|
424
|
+
return String(raw).includes(String(operand.kind === 'list' ? '' : operand.value));
|
|
425
|
+
case 'notContains':
|
|
426
|
+
return !String(raw).includes(String(operand.kind === 'list' ? '' : operand.value));
|
|
427
|
+
case 'in':
|
|
428
|
+
case 'notIn': {
|
|
429
|
+
if (operand.kind !== 'list')
|
|
430
|
+
return false;
|
|
431
|
+
const left = String(raw).trim();
|
|
432
|
+
const hit = operand.items.some((item) => String(item.kind === 'list' ? '' : item.value).trim() === left);
|
|
433
|
+
return condition.op === 'in' ? hit : !hit;
|
|
434
|
+
}
|
|
435
|
+
default:
|
|
436
|
+
break;
|
|
437
|
+
}
|
|
438
|
+
// 日期字面量:两边都按「年月日」比(时分秒一律不参与,2026-11-05 用户明确)
|
|
439
|
+
if (operand.kind === 'date') {
|
|
440
|
+
const left = parseDateYmd(raw, now);
|
|
441
|
+
if (!left)
|
|
442
|
+
return false;
|
|
443
|
+
const right = dateTokenYmd(operand.value, operand.offsetDays, now);
|
|
444
|
+
switch (condition.op) {
|
|
445
|
+
case 'eq': return left.key === right;
|
|
446
|
+
case 'ne': return left.key !== right;
|
|
447
|
+
case 'gt': return left.key > right;
|
|
448
|
+
case 'gte': return left.key >= right;
|
|
449
|
+
case 'lt': return left.key < right;
|
|
450
|
+
case 'lte': return left.key <= right;
|
|
451
|
+
default: return false;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
if (operand.kind === 'number') {
|
|
455
|
+
const left = asNumber(raw);
|
|
456
|
+
if (left === null)
|
|
457
|
+
return false;
|
|
458
|
+
const right = operand.value;
|
|
459
|
+
switch (condition.op) {
|
|
460
|
+
case 'eq': return left === right;
|
|
461
|
+
case 'ne': return left !== right;
|
|
462
|
+
case 'gt': return left > right;
|
|
463
|
+
case 'gte': return left >= right;
|
|
464
|
+
case 'lt': return left < right;
|
|
465
|
+
case 'lte': return left <= right;
|
|
466
|
+
default: return false;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
if (operand.kind === 'boolean') {
|
|
470
|
+
const left = asBoolean(raw);
|
|
471
|
+
if (left === null)
|
|
472
|
+
return false;
|
|
473
|
+
if (condition.op === 'eq')
|
|
474
|
+
return left === operand.value;
|
|
475
|
+
if (condition.op === 'ne')
|
|
476
|
+
return left !== operand.value;
|
|
477
|
+
return false;
|
|
478
|
+
}
|
|
479
|
+
if (operand.kind === 'string') {
|
|
480
|
+
const left = String(raw).trim();
|
|
481
|
+
const right = operand.value.trim();
|
|
482
|
+
switch (condition.op) {
|
|
483
|
+
case 'eq': return left === right;
|
|
484
|
+
case 'ne': return left !== right;
|
|
485
|
+
case 'gt': return left > right;
|
|
486
|
+
case 'gte': return left >= right;
|
|
487
|
+
case 'lt': return left < right;
|
|
488
|
+
case 'lte': return left <= right;
|
|
489
|
+
default: return false;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
return false;
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* 对整个表达式求值。`resolve` 负责按字段名取值(大小写不敏感由调用方保证)。
|
|
496
|
+
* 只要有一条路径能求成 true 就算命中。
|
|
497
|
+
*/
|
|
498
|
+
export function evaluatePriorityRule(expr, resolve, now = new Date()) {
|
|
499
|
+
switch (expr.kind) {
|
|
500
|
+
case 'and':
|
|
501
|
+
return expr.children.every((child) => evaluatePriorityRule(child, resolve, now));
|
|
502
|
+
case 'or':
|
|
503
|
+
return expr.children.some((child) => evaluatePriorityRule(child, resolve, now));
|
|
504
|
+
case 'not':
|
|
505
|
+
return !evaluatePriorityRule(expr.child, resolve, now);
|
|
506
|
+
case 'condition':
|
|
507
|
+
return evaluateCondition(expr, resolve(expr.field), now);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
@@ -34,18 +34,28 @@ const DISPLAY_ROW_FIELDS = [
|
|
|
34
34
|
'receivedatetime', 'operatedatetime',
|
|
35
35
|
// 最后反馈时间:`getTodoListData.displayData` 里的原始键是全小写,大小写变体一并保留。
|
|
36
36
|
'lastfeedbackdatetime', 'lastFeedbackDateTime',
|
|
37
|
+
// 计划完成时间(2026-11-05 补):接口原始键是**驼峰** `planFinishDatetime`,且与
|
|
38
|
+
// `minOverDateTime` / `curUserOverTime` 三者同值(实测 5 条:`2026-11-06 14:21:23`)。
|
|
39
|
+
// 之前漏在白名单外 ⇒ `rowFromAny` 虽然写了 pick 也永远取不到,优先组规则想按到期时间判断就成了空谈。
|
|
40
|
+
'planFinishDatetime', 'planfinishdatetime',
|
|
37
41
|
];
|
|
38
42
|
/**
|
|
39
43
|
* 只保留 `displayData`(且逐行白名单)的原始行。
|
|
40
44
|
*
|
|
41
45
|
* 取值路径**不**回落到 `record.data.list` / `record.list`:那两个键在 `getTodoListData` 里
|
|
42
46
|
* 指向技术字段行;宁可返回空数组,也不把非显示列当显示列。
|
|
47
|
+
*
|
|
48
|
+
* `extraFields`(2026-11-05):优先组表达式引用到的字段名(**小写**)。这些字段可能在白名单外,
|
|
49
|
+
* 但规则要用它判断,所以按需保留——不传或空集时行为与历史完全一致。
|
|
50
|
+
* 匹配大小写不敏感(displayData 的键大小写混杂,如 `requestlevel` / `overTime`),
|
|
51
|
+
* 但保留**原始键名**回去,免得下游还要猜拼写。
|
|
43
52
|
*/
|
|
44
|
-
export function projectDisplayRows(response) {
|
|
53
|
+
export function projectDisplayRows(response, extraFields) {
|
|
45
54
|
const record = responseData(response);
|
|
46
55
|
const raw = record?.data?.displayData ?? record?.displayData ?? [];
|
|
47
56
|
const rows = Array.isArray(raw) ? raw : [];
|
|
48
57
|
const projected = [];
|
|
58
|
+
const extra = extraFields && extraFields.size > 0 ? extraFields : null;
|
|
49
59
|
for (const row of rows) {
|
|
50
60
|
if (!row || typeof row !== 'object' || Array.isArray(row))
|
|
51
61
|
continue;
|
|
@@ -57,6 +67,17 @@ export function projectDisplayRows(response) {
|
|
|
57
67
|
picked[key] = value;
|
|
58
68
|
}
|
|
59
69
|
}
|
|
70
|
+
if (extra) {
|
|
71
|
+
for (const [key, value] of Object.entries(source)) {
|
|
72
|
+
if (key in picked)
|
|
73
|
+
continue;
|
|
74
|
+
if (!extra.has(key.toLowerCase()))
|
|
75
|
+
continue;
|
|
76
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
77
|
+
picked[key] = value;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
60
81
|
if (Object.keys(picked).length > 0)
|
|
61
82
|
projected.push(picked);
|
|
62
83
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { activeRuleFor, generalRules } from './aigroupRules.js';
|
|
1
|
+
import { activeRuleFor, generalRules, priorityRuleFields } from './aigroupRules.js';
|
|
2
2
|
import { writeFileSync } from 'node:fs';
|
|
3
3
|
import { tmpdir } from 'node:os';
|
|
4
4
|
import { join } from 'node:path';
|
|
@@ -11,10 +11,13 @@ import { openSummaryCache, promptTagOf, SUMMARY_CACHE_FILE_NAME } from './summar
|
|
|
11
11
|
import { openDetailCache, detailMaterialTagOf } from './todoDetailCache.js';
|
|
12
12
|
import { fetchDetailFacts, stampsOfRows } from './todoSmartConvert.detail.js';
|
|
13
13
|
import { GROUP_MIN_ITEMS_FOR_SUBGROUP, isExpiringTodayRow, isOverdueRow, runGroup, } from './todoSmartConvert.group.js';
|
|
14
|
-
import { DEFAULT_TABID, FETCH_PAGE_SIZE, LIST_ENDPOINT_BY_CATEGORY, MAX_FETCH_LIMIT, MAX_FETCH_PAGES, guardListOnlyHost, readBoundedInt, readCategory, readFetchLimit, readPageSize, rowFromAny, } from './todoSmartConvert.core.js';
|
|
14
|
+
import { COLLECT_FILTER_KEYS, COLLECT_ORDER_KEYS, DEFAULT_TABID, FETCH_PAGE_SIZE, LIST_ENDPOINT_BY_CATEGORY, MAX_FETCH_LIMIT, MAX_FETCH_PAGES, guardListOnlyHost, readBoundedInt, readCategory, readFetchLimit, readPageSize, rowFromAny, } from './todoSmartConvert.core.js';
|
|
15
15
|
const DEFAULT_REQUEST_SUMMARY_MAX = 50;
|
|
16
16
|
export async function collectRawTodos(args, env) {
|
|
17
17
|
const category = readCategory(args.category);
|
|
18
|
+
// 优先组表达式引用到的原始字段(2026-11-05):只保留这些字段,其余照旧按白名单丢弃。
|
|
19
|
+
// 空集 = 规则没配 / 没引用白名单外的字段 ⇒ 取数行为与历史完全一致。
|
|
20
|
+
const priorityFields = priorityRuleFields();
|
|
18
21
|
const { limit, cappedFrom } = readFetchLimit(args.limit);
|
|
19
22
|
const pageSize = readPageSize(limit);
|
|
20
23
|
// 条数 → 请求次数;按页取,不按条数精确裁剪。
|
|
@@ -22,7 +25,11 @@ export async function collectRawTodos(args, env) {
|
|
|
22
25
|
// 取数阶段只允许 getTodoListData,getTodo* 分页/统计接口一律拦掉。
|
|
23
26
|
const listEnv = guardListOnlyHost(env);
|
|
24
27
|
const searchArgs = { category };
|
|
25
|
-
|
|
28
|
+
// 筛选条件 + 排序白名单与 `workflow.search` 对齐(`COLLECT_FILTER_KEYS` / `COLLECT_ORDER_KEYS`,
|
|
29
|
+
// 2026-11-06):编号 / 状态 / 节点 / 发起时间 / 表单字段 / 排序此前只存在于 search,汇总链路拿不到,
|
|
30
|
+
// 导致「同样的诉求查得出来、汇总不出来」。取值仍交给同一个 `buildSearchQuery`,
|
|
31
|
+
// 所以校验、名称澄清、条件与 sortParams 的报文形态与 search 完全一致。
|
|
32
|
+
for (const key of [...COLLECT_FILTER_KEYS, ...COLLECT_ORDER_KEYS]) {
|
|
26
33
|
const value = args[key];
|
|
27
34
|
if (value !== undefined && value !== null && value !== '')
|
|
28
35
|
searchArgs[key] = value;
|
|
@@ -54,6 +61,14 @@ export async function collectRawTodos(args, env) {
|
|
|
54
61
|
warnings.push(`单页条数已按 limit 推导为 ${pageSize}(最多 ${MAX_FETCH_PAGES} 次请求),`
|
|
55
62
|
+ `忽略传入的 pageSize=${String(requestedPageSize)}`);
|
|
56
63
|
}
|
|
64
|
+
// 自定义排序(2026-11-06):与 workflow.search 同口径透传,每页带同一份 sortParams。
|
|
65
|
+
// 翻页是按 current 递增找服务端要的,排序键同值较多时相邻页边界可能重复/漏项——
|
|
66
|
+
// 这里只如实提示,不擅自改排序或去掉用户要的顺序。
|
|
67
|
+
const sortText = String(searchArgs.sort ?? '').trim();
|
|
68
|
+
if (sortText) {
|
|
69
|
+
warnings.push(`已按自定义排序取数(sort=${sortText});跨页按 requestId 去重,`
|
|
70
|
+
+ '排序键同值较多时相邻页可能重复或漏项,建议配合时间 / 工作流条件缩小范围');
|
|
71
|
+
}
|
|
57
72
|
const seen = new Set();
|
|
58
73
|
const items = [];
|
|
59
74
|
let duplicateCount = 0;
|
|
@@ -83,6 +98,15 @@ export async function collectRawTodos(args, env) {
|
|
|
83
98
|
body: query,
|
|
84
99
|
});
|
|
85
100
|
pages += 1;
|
|
101
|
+
// 调试留痕(环境变量开启才写):把列表接口的**原始响应**原样落盘。
|
|
102
|
+
// 与上面的 DUMP_LIST_BODY 对称:那个查"我们发出去什么",这个查"接口到底给了哪些字段",
|
|
103
|
+
// 排查「规则写了某个字段却不生效」时,只有原始响应能证明字段在不在、值是什么类型。
|
|
104
|
+
if (process.env.WEAVER_WORK_CLI_DUMP_LIST_RESP) {
|
|
105
|
+
try {
|
|
106
|
+
writeFileSync(join(tmpdir(), `weaver-list-resp-page${pageNo}.json`), JSON.stringify(response, null, 2));
|
|
107
|
+
}
|
|
108
|
+
catch { /* 留痕失败不影响主流程 */ }
|
|
109
|
+
}
|
|
86
110
|
if (totalAvailable === null) {
|
|
87
111
|
// 列表接口的 total 字段不稳定(实测 `data.total` 可能是 0 或缺失)。取数按页驱动、不依赖总数,
|
|
88
112
|
// 所以这里**只做展示用**:拿不到正数就当未知,不让 0 冒充「共 0 条」。
|
|
@@ -96,8 +120,8 @@ export async function collectRawTodos(args, env) {
|
|
|
96
120
|
}
|
|
97
121
|
}
|
|
98
122
|
}
|
|
99
|
-
const pageRows = projectDisplayRows(response)
|
|
100
|
-
.map((row) => rowFromAny(row))
|
|
123
|
+
const pageRows = projectDisplayRows(response, priorityFields)
|
|
124
|
+
.map((row) => rowFromAny(row, priorityFields))
|
|
101
125
|
.filter((row) => row !== undefined);
|
|
102
126
|
if (pageRows.length === 0) {
|
|
103
127
|
stoppedEarly = true;
|
|
@@ -341,7 +365,9 @@ export async function collectRawTodos(args, env) {
|
|
|
341
365
|
totalAvailable,
|
|
342
366
|
/** 取数只用了这一个接口(照实写出来,便于核对「有没有偷偷调别的」) */
|
|
343
367
|
endpoint: listPath,
|
|
344
|
-
|
|
368
|
+
/** 自定义排序原文(不在 filters 里:它是排序不是筛选条件) */
|
|
369
|
+
...(sortText ? { sort: sortText } : {}),
|
|
370
|
+
filters: Object.fromEntries(Object.entries(searchArgs).filter(([key]) => !['category', 'tabid', 'sort'].includes(key))),
|
|
345
371
|
},
|
|
346
372
|
fetched: items.length,
|
|
347
373
|
items,
|