weaver-work-cli 0.1.38 → 0.1.40
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 +7 -3
- package/dist/chunks/{archive-PDV724YK.js → archive-JHTONRST.js} +556 -66
- package/dist/chunks/{archive-oa-4XE4MNXQ.js → archive-oa-FCHLCPHC.js} +2 -2
- package/dist/chunks/{asset-PDL2QE2N.js → asset-RLIHC7DB.js} +2 -2
- package/dist/chunks/asset-idle-KVOFTLCP.js +670 -0
- package/dist/chunks/{attachment-content-MDDGOE5E.js → attachment-content-RZYDB3MB.js} +3 -3
- package/dist/chunks/{blog-UYR3EUXW.js → blog-42OZTJNP.js} +2 -2
- package/dist/chunks/{caizhilian-LG2X5NMF.js → caizhilian-KRK547K5.js} +2 -2
- package/dist/chunks/{calendar-FG4BAZHE.js → calendar-RTWAMKHD.js} +2 -2
- package/dist/chunks/{chunk-J7USS3ED.js → chunk-4CTESSKI.js} +4 -4
- package/dist/chunks/{chunk-OJQUJZQF.js → chunk-4TEDNCON.js} +45 -5
- package/dist/chunks/chunk-57IECMWX.js +487 -0
- package/dist/chunks/{chunk-ELYDWBZJ.js → chunk-7BRU4EFH.js} +13 -7
- package/dist/chunks/{chunk-6LTFIFLM.js → chunk-7E6MUOEK.js} +2 -2
- package/dist/chunks/{chunk-KKRL3REV.js → chunk-7U577Q7U.js} +2 -2
- package/dist/chunks/{chunk-UJJD4QWF.js → chunk-CAQNBBQA.js} +2 -2
- package/dist/chunks/{chunk-CORFRD7Q.js → chunk-CXRQWOZ5.js} +2 -2
- package/dist/chunks/{chunk-GGJFMNJM.js → chunk-FLS4DPGP.js} +110 -16
- package/dist/chunks/{chunk-JSMFPO43.js → chunk-I566ZYNF.js} +1 -1
- package/dist/chunks/{chunk-6FTTSA45.js → chunk-IZSSVYAG.js} +2 -2
- package/dist/chunks/{chunk-XJY7G4DD.js → chunk-JWRZM2H2.js} +3 -3
- package/dist/chunks/{chunk-NI6GIPIM.js → chunk-LFMSDBZN.js} +529 -395
- package/dist/chunks/{chunk-VRYHGG6O.js → chunk-LN447PY2.js} +92 -51
- package/dist/chunks/{chunk-NR6RKXPA.js → chunk-NETCCARD.js} +4 -2
- package/dist/chunks/{chunk-Z32KWY6G.js → chunk-NJKREDA3.js} +1 -1
- package/dist/chunks/{chunk-FUWVHMVV.js → chunk-SPRHHSVC.js} +2 -2
- package/dist/chunks/{chunk-IZUDA353.js → chunk-T6EGVBKU.js} +1 -1
- package/dist/chunks/{chunk-DMV2TOMH.js → chunk-VNBU55SL.js} +428 -145
- package/dist/chunks/{chunk-UZZBA6PV.js → chunk-WFFNM65B.js} +47 -6
- package/dist/chunks/{chunk-EG6ZU444.js → chunk-ZUX3P6BQ.js} +10 -5
- package/dist/chunks/{conflict-BQZEQ4SP.js → conflict-VR55AOOO.js} +2 -2
- package/dist/chunks/{contract-XIRAFTEV.js → contract-HI4FNPYE.js} +2 -2
- package/dist/chunks/{cowork-BLG62BL2.js → cowork-HJLI353D.js} +12 -5
- package/dist/chunks/{ebuilder-form-NUKG5QW4.js → ebuilder-form-HTGI63UU.js} +3 -3
- package/dist/chunks/{ehr-2STW5ILH.js → ehr-GYXIYH3A.js} +2 -2
- package/dist/chunks/env-DW3G4HUO.js +19 -0
- package/dist/chunks/{esb-UUDQUNKY.js → esb-I5INCEFE.js} +4 -4
- package/dist/chunks/factory-TKXGXS6L.js +30 -0
- package/dist/chunks/{fna-6RCY4NU5.js → fna-K2MHTQ24.js} +2 -2
- package/dist/chunks/group-chat-VYBNMJLG.js +18 -0
- package/dist/chunks/{host-FWDOSRH5.js → host-256GVCAH.js} +3 -3
- package/dist/chunks/{host-EJZFROU3.js → host-D5SERMAJ.js} +3 -3
- package/dist/chunks/{host-RHM3NPXV.js → host-JM4YVHFM.js} +3 -3
- package/dist/chunks/{host-7RXEDMAH.js → host-L3VLITMT.js} +3 -3
- package/dist/chunks/{host-UFF33TWJ.js → host-ZUQTJYYK.js} +3 -3
- package/dist/chunks/{hrm-PKJ6ELSH.js → hrm-VLRBKTZB.js} +3 -3
- package/dist/chunks/{im-YJAXS7CO.js → im-QK3VTLXK.js} +8 -8
- package/dist/chunks/{invoice-HWVSXGX6.js → invoice-T5JTA32H.js} +3 -3
- package/dist/chunks/{jiuchuanhui-L7VKILZB.js → jiuchuanhui-P2FNEQVZ.js} +2 -2
- package/dist/chunks/{lazy-dispatch-NMYEIHRH.js → lazy-dispatch-XRRI46M6.js} +5 -5
- package/dist/chunks/{mail-B42RRU7G.js → mail-3Y7MJ6PS.js} +9 -4
- package/dist/chunks/{meeting-CFYVBJSS.js → meeting-M7LTXGJE.js} +11 -10
- package/dist/chunks/{okr-GCLF6V7W.js → okr-OBC6S67L.js} +2 -2
- package/dist/chunks/{plan-ZVL7GBRI.js → plan-5H6I53SK.js} +2 -2
- package/dist/chunks/{project-4YWAAE2K.js → project-L75QZV4S.js} +2 -2
- package/dist/chunks/{registry-EP4VTHZS.js → registry-KMHCPAAD.js} +9 -8
- package/dist/chunks/{registry-OZSMDVPP.js → registry-QGHFNUWS.js} +2 -2
- package/dist/chunks/{registry-FRJ6H7BT.js → registry-RXPN6BBT.js} +4 -4
- package/dist/chunks/{registry-SG2PGVCF.js → registry-UGRBCBHO.js} +3 -3
- package/dist/chunks/{room-recommend-R3JVUUAC.js → room-recommend-A3UDC3CA.js} +4 -4
- package/dist/chunks/{schedule-NIJBTYDO.js → schedule-5GCACCK7.js} +4 -4
- package/dist/chunks/{workflow-BB24DFBY.js → workflow-M5ZJ7DWF.js} +11 -8
- package/dist/core/output.js +16 -6
- package/dist/index.js +33 -28
- package/dist/internal/e10/auth/commands.js +109 -56
- package/dist/internal/e10/auth/messages.js +1 -0
- package/dist/internal/e10/auth/session.js +11 -1
- package/dist/internal/e10/auth/xiaoe.js +29 -4
- package/dist/internal/e10/auth-recovery.js +13 -6
- package/dist/internal/e10/client.js +13 -0
- package/dist/internal/e10/context.js +24 -3
- package/dist/internal/e10/request-runtime.js +12 -1
- package/dist/shortcuts/archive/host.js +2 -0
- package/dist/shortcuts/archive/manifest.js +1 -1
- package/dist/shortcuts/archive/operations/borrow-list.js +13 -1
- package/dist/shortcuts/archive/operations/flow-url.js +1 -1
- package/dist/shortcuts/archive/operations/prelib.js +472 -0
- package/dist/shortcuts/archive/operations/registry.js +2 -0
- package/dist/shortcuts/archive/operations/upload.js +1 -1
- package/dist/shortcuts/asset-idle/errors.js +44 -0
- package/dist/shortcuts/asset-idle/host.js +161 -0
- package/dist/shortcuts/asset-idle/index.js +114 -0
- package/dist/shortcuts/asset-idle/manifest.js +159 -0
- package/dist/shortcuts/asset-idle/operations/idle.js +47 -0
- package/dist/shortcuts/asset-idle/operations/registry.js +33 -0
- package/dist/shortcuts/asset-idle/operations/shared.js +142 -0
- package/dist/shortcuts/asset-idle/operations/types.js +9 -0
- package/dist/shortcuts/asset-idle/operations.js +15 -0
- package/dist/shortcuts/cowork/operations/item-write.js +10 -2
- package/dist/shortcuts/index.js +5 -0
- package/dist/shortcuts/mail/operations/mail-send.js +8 -2
- package/dist/shortcuts/meeting/operations/eb/catalog.js +5 -1
- package/dist/shortcuts/meeting/operations/eb/create-flow.js +381 -104
- package/dist/shortcuts/meeting/operations/eb/crm-search.js +87 -5
- package/dist/shortcuts/meeting/operations/eb/flow-memory.js +49 -0
- package/dist/shortcuts/meeting/operations/eb/group-chat.js +583 -0
- package/dist/shortcuts/meeting/operations/eb/index.js +2 -0
- package/dist/shortcuts/meeting/operations/eb/room-recommend.js +19 -3
- package/dist/shortcuts/meeting/operations/eb/room-summary.js +2 -0
- package/dist/shortcuts/meeting/operations/eb/usage-cache.js +99 -0
- package/dist/shortcuts/meeting/operations/from-group-chat.js +35 -12
- package/dist/shortcuts/workflow/host.js +3 -0
- package/dist/shortcuts/workflow/index.js +1 -1
- package/dist/shortcuts/workflow/operations/form.js +65 -171
- package/dist/shortcuts/workflow/operations/todoSmartConvert/aigroupRules.js +129 -27
- package/dist/shortcuts/workflow/operations/todoSmartConvert/aigroupStore.js +6 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/summaryCache.js +60 -117
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoDetailCache.js +44 -7
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoDetailFetcher.js +37 -29
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +48 -8
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +1 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.detail.js +22 -18
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.group.js +17 -9
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.groupSummary.js +34 -10
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +5 -2
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.smartGroup.js +9 -2
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.summary.js +122 -20
- package/docs/_catalog.md +3 -0
- package/docs/asset-idle.md +45 -0
- package/docs/e10-auth.md +16 -1
- package/docs/todo-smart-convert/subgroup-rules.md +1 -1
- package/package.json +1 -1
- package/scripts/mcp-meeting.mjs +234 -0
- package/scripts/package-skill.mjs +2 -0
- package/skill-template/business-info.json +14 -1
- package/skill-template/domains/asset-idle.md +13 -0
- package/skill-template/domains/wenshuding.md +3 -0
- package/skills/weaver-e10-archive-oa/SKILL.md +1 -0
- package/skills/weaver-e10-archive-oa/references/my-borrow.md +49 -0
- package/skills/weaver-e10-asset-idle/SKILL.md +73 -0
- package/skills/weaver-e10-asset-idle/references/idle-list.md +62 -0
- package/skills/weaver-e10-asset-idle/references/idle-stats-and-charts.md +65 -0
- package/skills/weaver-e10-asset-idle/references/source-manifest.json +193 -0
- package/skills/weaver-e10-asset-idle/references/widget-style.md +205 -0
- package/skills/weaver-e10-caizhilian/SKILL.md +29 -11
- package/skills/weaver-e10-caizhilian/references/auth-and-install.md +12 -0
- package/skills/weaver-e10-caizhilian/references/files.md +1 -1
- package/skills/weaver-e10-caizhilian/references/setting-encrypt.md +1 -1
- package/skills/weaver-e10-caizhilian/references/source-manifest.json +45 -45
- package/skills/weaver-e10-cowork/SKILL.md +2 -0
- package/skills/weaver-e10-cowork/references/cowork-write.md +1 -1
- package/skills/weaver-e10-jucailin/SKILL.md +2 -0
- package/skills/weaver-e10-jucailin/references/recruit-read.md +2 -0
- package/skills/weaver-e10-jucailin/references/recruit-write.md +1 -1
- package/skills/weaver-e10-mail/SKILL.md +3 -0
- package/skills/weaver-e10-mail/references/mail-send.md +2 -0
- package/skills/weaver-e10-meeting/SKILL.md +88 -25
- package/skills/weaver-e10-meeting/references/meeting-minute-file.md +25 -11
- package/skills/weaver-e10-meeting.zip +0 -0
- package/skills/weaver-e10-shared/SKILL.md +5 -5
- package/skills/weaver-e10-shared/references/e10-auth-and-session.md +3 -3
- package/skills/weaver-e10-wenshuding/SKILL.md +29 -6
- package/skills/weaver-e10-wenshuding/references/archive-borrow-list.md +14 -0
- package/skills/weaver-e10-wenshuding/references/archive-download.md +2 -0
- package/skills/weaver-e10-wenshuding/references/archive-flow.md +1 -1
- package/skills/weaver-e10-wenshuding/references/archive-prelib-arrange.md +76 -0
- package/skills/weaver-e10-wenshuding/references/archive-prelib-list.md +107 -0
- package/skills/weaver-e10-wenshuding/references/archive-prelib-open.md +59 -0
- package/skills/weaver-e10-wenshuding/references/archive-upload.md +4 -1
- package/skills/weaver-e10-wenshuding/references/source-manifest.json +108 -65
- package/skills/weaver-e10-workflow/SKILL.md +9 -2
- package/skills/weaver-e10-workflow/aigroup/default.json +166 -19
- package/skills/weaver-e10-workflow/references/todo-smart-convert.md +72 -34
- package/skills/weaver-e10-workflow/tools/todo-serve.cjs +113 -25
- package/skills/weaver-e10-workflow/tools/todo-summary.cjs +350 -50
- package/dist/chunks/{chunk-2LV74IWP.js → chunk-E7OK5WD5.js} +5 -5
|
@@ -74,14 +74,51 @@ function unwrapRow(value) {
|
|
|
74
74
|
const main = asRecord(record.mainTable);
|
|
75
75
|
return main ?? record;
|
|
76
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* 「列式」输出转行:动作流把 `mainTable` 按字段铺成平行数组时
|
|
79
|
+
* (2026-11-02 实测:`mc` 10 个客户名、`sjID` 10 个 id、`lxr` 4 条扁平联系人),
|
|
80
|
+
* 整体会被当成"一行",于是 `mc` 是数组、取不到名称 → 客户端判定"没匹配到客户"。
|
|
81
|
+
* 这里按索引把 id / 名称配成多行,至少能把这批客户列出来给用户选。
|
|
82
|
+
*
|
|
83
|
+
* ⚠️ 只配 id + 名称:`lxr` 是**跨客户的扁平汇总**,里面没有客户归属字段,
|
|
84
|
+
* 硬按索引分会把 A 家联系人挂到 B 家名下 —— 宁可不带,也不臆造。
|
|
85
|
+
*/
|
|
86
|
+
function columnarCustomerRows(record) {
|
|
87
|
+
const idKey = ID_KEYS.find((key) => Array.isArray(record[key]));
|
|
88
|
+
const nameKey = NAME_KEYS.find((key) => Array.isArray(record[key]));
|
|
89
|
+
if (!idKey && !nameKey)
|
|
90
|
+
return [];
|
|
91
|
+
const idValues = (idKey ? record[idKey] : []);
|
|
92
|
+
const nameValues = (nameKey ? record[nameKey] : []);
|
|
93
|
+
const size = Math.max(idValues.length, nameValues.length);
|
|
94
|
+
if (size <= 1)
|
|
95
|
+
return [];
|
|
96
|
+
const rows = [];
|
|
97
|
+
for (let index = 0; index < size; index += 1) {
|
|
98
|
+
const row = {};
|
|
99
|
+
if (idKey)
|
|
100
|
+
row[idKey] = idValues[index];
|
|
101
|
+
if (nameKey)
|
|
102
|
+
row[nameKey] = nameValues[index];
|
|
103
|
+
rows.push(row);
|
|
104
|
+
}
|
|
105
|
+
return rows;
|
|
106
|
+
}
|
|
77
107
|
/** 从 customData 里挖出所有可能承载客户行的候选数组。 */
|
|
78
108
|
function collectCandidateLists(customData) {
|
|
79
109
|
const found = [];
|
|
80
110
|
const main = asRecord(customData.mainTable);
|
|
81
111
|
if (main) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
112
|
+
const columnar = columnarCustomerRows(main);
|
|
113
|
+
if (columnar.length > 1) {
|
|
114
|
+
// 列式:一行一个客户,但没有联系人(见 columnarCustomerRows 的说明)
|
|
115
|
+
found.push({ source: 'customData.mainTable.columns', rows: columnar });
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
// ① 单条:mainTable 自己就是一行。即使 mc/sjID 都是空串也放进来,
|
|
119
|
+
// 让 normalizeCustomers 丢掉后落到「没有匹配到客户」,而不是误报「结构不认识」
|
|
120
|
+
found.push({ source: 'customData.mainTable', rows: [main] });
|
|
121
|
+
}
|
|
85
122
|
// ② mainTable 里再套一层列表
|
|
86
123
|
for (const key of LIST_KEYS) {
|
|
87
124
|
const value = main[key];
|
|
@@ -95,6 +132,27 @@ function collectCandidateLists(customData) {
|
|
|
95
132
|
if (Array.isArray(value))
|
|
96
133
|
found.push({ source: `customData.${key}`, rows: value });
|
|
97
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* ④ customData 下**任意**数组字段:动作流经常用表单字段 id 当 key
|
|
137
|
+
* (2026-11-02 实测:`customData["1173221220888059964"] = [客户1, 客户2, …]`)。
|
|
138
|
+
* 以前只认 LIST_KEYS 白名单,这类 key 直接被忽略 —— 于是「模糊查一个词命中 10 个客户」
|
|
139
|
+
* 只会返回第 1 个,用户看到的候选永远只有一个。
|
|
140
|
+
* 只收「元素看起来像客户行」(能取到 id 或名称)的数组,避免把别的明细当客户。
|
|
141
|
+
*/
|
|
142
|
+
for (const [key, value] of Object.entries(customData)) {
|
|
143
|
+
if (LIST_KEYS.includes(key))
|
|
144
|
+
continue;
|
|
145
|
+
if (!Array.isArray(value) || value.length === 0)
|
|
146
|
+
continue;
|
|
147
|
+
const looksLikeCustomers = value.some((raw) => {
|
|
148
|
+
const row = unwrapRow(raw);
|
|
149
|
+
if (!row)
|
|
150
|
+
return false;
|
|
151
|
+
return pickFirst(row, ID_KEYS) !== '' || pickFirst(row, NAME_KEYS) !== '';
|
|
152
|
+
});
|
|
153
|
+
if (looksLikeCustomers)
|
|
154
|
+
found.push({ source: `customData.${key}`, rows: value });
|
|
155
|
+
}
|
|
98
156
|
return found;
|
|
99
157
|
}
|
|
100
158
|
/** 客户行里「联系人明细 / 地址明细」的候选字段名(ESB 动作流输出)。 */
|
|
@@ -202,6 +260,30 @@ export function parseCrmAddresses(raw) {
|
|
|
202
260
|
return out;
|
|
203
261
|
}
|
|
204
262
|
/** 把任意行数组转成客户数组(去重、丢空行)。 */
|
|
263
|
+
/**
|
|
264
|
+
* 取客户行里的「联系人明细」数组。
|
|
265
|
+
*
|
|
266
|
+
* 先按已知 key(`lxr` 等)找;找不到再按**内容特征**扫描 —— 动作流用表单字段 id 当 key 时
|
|
267
|
+
* (`1173221220888060716`),靠 key 名永远匹配不上,但里面每行都带姓名/手机号字段,
|
|
268
|
+
* 用 CONTACT_NAME_KEYS / CONTACT_MOBILE_KEYS 一认就知道是不是联系人子表。
|
|
269
|
+
*/
|
|
270
|
+
function pickContactArray(row) {
|
|
271
|
+
const direct = pickRawList(row, CONTACT_LIST_KEYS);
|
|
272
|
+
if (direct !== undefined)
|
|
273
|
+
return direct;
|
|
274
|
+
for (const value of Object.values(row)) {
|
|
275
|
+
if (!Array.isArray(value) || value.length === 0)
|
|
276
|
+
continue;
|
|
277
|
+
const first = asRecord(value[0]);
|
|
278
|
+
if (!first)
|
|
279
|
+
continue;
|
|
280
|
+
const hasName = CONTACT_NAME_KEYS.some((key) => String(first[key] ?? '').trim() !== '');
|
|
281
|
+
const hasMobile = CONTACT_MOBILE_KEYS.some((key) => String(first[key] ?? '').trim() !== '');
|
|
282
|
+
if (hasName || hasMobile)
|
|
283
|
+
return value;
|
|
284
|
+
}
|
|
285
|
+
return undefined;
|
|
286
|
+
}
|
|
205
287
|
export function normalizeCustomers(rows, limit) {
|
|
206
288
|
const seen = new Map();
|
|
207
289
|
for (const raw of rows) {
|
|
@@ -218,7 +300,7 @@ export function normalizeCustomers(rows, limit) {
|
|
|
218
300
|
if (seen.has(key))
|
|
219
301
|
continue;
|
|
220
302
|
// 联系人与地址是客户行里的明细数组(lxr / khdz),不是客户列表本身 —— 别被 collectCandidateLists 当行用
|
|
221
|
-
const contacts = parseCrmContacts(
|
|
303
|
+
const contacts = parseCrmContacts(pickContactArray(row));
|
|
222
304
|
const addresses = parseCrmAddresses(pickRawList(row, ADDRESS_LIST_KEYS));
|
|
223
305
|
seen.set(key, {
|
|
224
306
|
customerId,
|
|
@@ -412,7 +494,7 @@ const ebCrmSearch = {
|
|
|
412
494
|
minLength: 1,
|
|
413
495
|
description: '客户名称,走动作流入参 custom_name(包含匹配):给全称最稳,片段只回首个匹配',
|
|
414
496
|
},
|
|
415
|
-
limit: { type: 'number', description: '返回条数上限,默认 10
|
|
497
|
+
limit: { type: 'number', description: '返回条数上限,默认 10。动作流是模糊查,可能命中多个近名客户;列式输出(mc/sjID 平行数组)会按索引拆成多行返回' },
|
|
416
498
|
flowId: { type: 'string', description: '覆盖 ESB 动作流 id(默认 904205116264026112)' },
|
|
417
499
|
employeeId: { type: 'string', description: '覆盖触发人员 id(默认当前登录用户)' },
|
|
418
500
|
includeRaw: { type: 'boolean', description: 'true=附带 ESB 原始返回,便于排查输出结构' },
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { readCache, writeCache, cacheScopeSuffix } from './cache.js';
|
|
2
|
+
const FLOW_PICK_TTL_MS = 30 * 24 * 60 * 60 * 1000;
|
|
3
|
+
function flowPickKey(scope) {
|
|
4
|
+
return `flow-pick-${scope}`;
|
|
5
|
+
}
|
|
6
|
+
/** 读当前登录人上次成功用的建会流程(换账号/换租户自动失效)。 */
|
|
7
|
+
export async function readFlowPick(env) {
|
|
8
|
+
const scope = await cacheScopeSuffix(env);
|
|
9
|
+
const hit = await readCache(env, flowPickKey(scope), { ttlMs: FLOW_PICK_TTL_MS });
|
|
10
|
+
if (!hit?.data?.workflowId)
|
|
11
|
+
return null;
|
|
12
|
+
try {
|
|
13
|
+
const session = await env.host.getSession();
|
|
14
|
+
const userId = String(session?.userId ?? '');
|
|
15
|
+
if (hit.data.userId && userId && hit.data.userId !== userId)
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
// 会话取不到就不做账号二次校验(缓存层已按租户隔离)
|
|
20
|
+
}
|
|
21
|
+
return hit.data;
|
|
22
|
+
}
|
|
23
|
+
/** 记住这次成功提交用的流程(提交成功后调用;失败不记)。 */
|
|
24
|
+
export async function rememberFlowPick(env, workflowId, name) {
|
|
25
|
+
const id = String(workflowId ?? '').trim();
|
|
26
|
+
if (id === '')
|
|
27
|
+
return;
|
|
28
|
+
let userId = '';
|
|
29
|
+
try {
|
|
30
|
+
const session = await env.host.getSession();
|
|
31
|
+
userId = String(session?.userId ?? '');
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
// 取不到就空着(读侧只在有值时才比对)
|
|
35
|
+
}
|
|
36
|
+
const scope = await cacheScopeSuffix(env);
|
|
37
|
+
await writeCache(env, flowPickKey(scope), {
|
|
38
|
+
workflowId: id,
|
|
39
|
+
...(name ? { name: String(name) } : {}),
|
|
40
|
+
...(userId ? { userId } : {}),
|
|
41
|
+
savedAt: Date.now(),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/** 纯函数:从可发起列表里挑出记忆命中的那条(没有/不命中 → null)。 */
|
|
45
|
+
export function pickRememberedFlow(launchable, remembered) {
|
|
46
|
+
if (!remembered?.workflowId)
|
|
47
|
+
return null;
|
|
48
|
+
return launchable.find((probe) => probe.workflowId === remembered.workflowId) ?? null;
|
|
49
|
+
}
|