weaver-work-cli 0.1.50 → 0.1.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/README.md +1 -1
  2. package/dist/chunks/{attachment-content-EJYIOJPH.js → attachment-content-W3TSJC3Y.js} +3 -3
  3. package/dist/chunks/{chunk-BFKLQLBK.js → chunk-2J3XY4ED.js} +7 -7
  4. package/dist/chunks/{chunk-K67FODVC.js → chunk-6GCXWKG6.js} +1 -1
  5. package/dist/chunks/{chunk-WNJUGI2F.js → chunk-76PRVYH4.js} +1 -1
  6. package/dist/chunks/{chunk-RYFRGTUV.js → chunk-DEHJ7PMA.js} +4 -4
  7. package/dist/chunks/{chunk-3NCFFHB2.js → chunk-IF33CG4V.js} +1 -1
  8. package/dist/chunks/{chunk-YB3AJYPY.js → chunk-PE334WL3.js} +4 -4
  9. package/dist/chunks/{chunk-MCZG6HPM.js → chunk-QQXMHM3J.js} +2 -2
  10. package/dist/chunks/{chunk-7ECB22G3.js → chunk-U7ROML5E.js} +23 -23
  11. package/dist/chunks/{chunk-7AYQJSFY.js → chunk-WTLQGS6D.js} +2 -2
  12. package/dist/chunks/{chunk-6T53BSWZ.js → chunk-XPQN4E5O.js} +50 -19
  13. package/dist/chunks/{chunk-HARQF5IP.js → chunk-Z4G7LLDD.js} +25 -25
  14. package/dist/chunks/{conflict-C4UDHCWV.js → conflict-57WDJWL7.js} +2 -2
  15. package/dist/chunks/{contract-VUC6JOPG.js → contract-LJRAXVZU.js} +8587 -1421
  16. package/dist/chunks/{create-flow-6OG2LYBD.js → create-flow-3FMMZBCA.js} +6 -6
  17. package/dist/chunks/{data-QO7QWOIV.js → data-WK5CQXNF.js} +17 -32
  18. package/dist/chunks/{env-WP57TF2S.js → env-JYZE3BZB.js} +2 -2
  19. package/dist/chunks/{factory-VUXI7N5C.js → factory-66SCIKW3.js} +1 -1
  20. package/dist/chunks/{group-chat-UQRGXILK.js → group-chat-MNRYMLNG.js} +3 -3
  21. package/dist/chunks/{invoice-E7GOITEU.js → invoice-V7ZTITUO.js} +725 -205
  22. package/dist/chunks/{meeting-4BBLVAWM.js → meeting-IIY4UAJL.js} +10 -10
  23. package/dist/chunks/{recruit-stage-FKWS5UQF.js → recruit-stage-XCMVEQA2.js} +718 -131
  24. package/dist/chunks/{registry-V4CHRQDI.js → registry-CJOVECZD.js} +1 -1
  25. package/dist/chunks/{registry-5CRCN2TV.js → registry-METZ2LWE.js} +10 -10
  26. package/dist/chunks/{room-recommend-AYR3UG7R.js → room-recommend-YFY7HTOF.js} +4 -4
  27. package/dist/chunks/{schedule-JZEFIXUS.js → schedule-6I63TERA.js} +4 -4
  28. package/dist/chunks/smart-extract-FOUYNIG3.js +2882 -0
  29. package/dist/chunks/{workflow-3ZAF2J5E.js → workflow-YHXFIU63.js} +1 -1
  30. package/dist/index.js +11 -6
  31. package/dist/shortcuts/contract/manifest.js +251 -0
  32. package/dist/shortcuts/contract/ooxml/docx-table.js +233 -0
  33. package/dist/shortcuts/contract/operations/card-action.js +1165 -0
  34. package/dist/shortcuts/contract/operations/card-ebdf-list.js +571 -0
  35. package/dist/shortcuts/contract/operations/card-plan.js +327 -0
  36. package/dist/shortcuts/contract/operations/card-risk-report.js +565 -0
  37. package/dist/shortcuts/contract/operations/card.js +6 -5
  38. package/dist/shortcuts/contract/operations/docx-fillfromquote.js +532 -0
  39. package/dist/shortcuts/contract/operations/docx-verify.js +258 -0
  40. package/dist/shortcuts/contract/operations/elements-build.js +761 -0
  41. package/dist/shortcuts/contract/operations/elements-spec.js +216 -0
  42. package/dist/shortcuts/contract/operations/first-screen.js +588 -0
  43. package/dist/shortcuts/contract/operations/flow.js +81 -25
  44. package/dist/shortcuts/contract/operations/ledger.js +438 -0
  45. package/dist/shortcuts/contract/operations/modeltext.js +132 -0
  46. package/dist/shortcuts/contract/operations/op-resolver.js +22 -0
  47. package/dist/shortcuts/contract/operations/performance.js +104 -3
  48. package/dist/shortcuts/contract/operations/quote.js +131 -25
  49. package/dist/shortcuts/contract/operations/quotescreen.js +529 -0
  50. package/dist/shortcuts/contract/operations/registry.js +30 -0
  51. package/dist/shortcuts/contract/operations/review.js +73 -58
  52. package/dist/shortcuts/contract/operations/summary-validate.js +293 -0
  53. package/dist/shortcuts/contract/operations/summary.js +4 -2
  54. package/dist/shortcuts/contract/operations/triage.js +1100 -0
  55. package/dist/shortcuts/contract/operations/upload.js +48 -7
  56. package/dist/shortcuts/contract/prewarm-cache.js +90 -0
  57. package/dist/shortcuts/contract/prewarm.js +88 -0
  58. package/dist/shortcuts/contract/upload-cache.js +49 -4
  59. package/dist/shortcuts/data/index.js +1 -6
  60. package/dist/shortcuts/data/manifest.js +2 -2
  61. package/dist/shortcuts/data/operations/index.js +1 -1
  62. package/dist/shortcuts/data/operations/query.js +23 -46
  63. package/dist/shortcuts/index.js +5 -0
  64. package/dist/shortcuts/invoice/index.js +0 -12
  65. package/dist/shortcuts/invoice/manifest.js +200 -49
  66. package/dist/shortcuts/invoice/operations/registry.js +4 -2
  67. package/dist/shortcuts/invoice/operations/reim-relation.js +438 -0
  68. package/dist/shortcuts/invoice/operations/shared.js +3 -19
  69. package/dist/shortcuts/invoice/operations/upload-and-validate.js +109 -73
  70. package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +4 -2
  71. package/dist/shortcuts/recruit-stage/operations/jd-create.js +6 -2
  72. package/dist/shortcuts/recruit-stage/operations/list.js +217 -1
  73. package/dist/shortcuts/recruit-stage/operations/resume-import.js +144 -158
  74. package/dist/shortcuts/recruit-stage/operations/search.js +348 -0
  75. package/dist/shortcuts/recruit-stage/shared.js +5 -0
  76. package/dist/shortcuts/recruit-stage/tag-lookup.js +136 -0
  77. package/dist/shortcuts/smart-extract/constants.js +79 -0
  78. package/dist/shortcuts/smart-extract/continuation.js +71 -0
  79. package/dist/shortcuts/smart-extract/errors.js +68 -0
  80. package/dist/shortcuts/smart-extract/host.js +191 -0
  81. package/dist/shortcuts/smart-extract/index.js +105 -0
  82. package/dist/shortcuts/smart-extract/ledger.js +70 -0
  83. package/dist/shortcuts/smart-extract/manifest.js +35 -0
  84. package/dist/shortcuts/smart-extract/operations/attachment.js +212 -0
  85. package/dist/shortcuts/smart-extract/operations/batch.js +67 -0
  86. package/dist/shortcuts/smart-extract/operations/config.js +118 -0
  87. package/dist/shortcuts/smart-extract/operations/fill.js +492 -0
  88. package/dist/shortcuts/smart-extract/operations/preview.js +174 -0
  89. package/dist/shortcuts/smart-extract/operations/registry.js +34 -0
  90. package/dist/shortcuts/smart-extract/operations/save.js +355 -0
  91. package/dist/shortcuts/smart-extract/operations/shared.js +191 -0
  92. package/dist/shortcuts/smart-extract/operations/structure.js +401 -0
  93. package/dist/shortcuts/smart-extract/operations/target.js +167 -0
  94. package/dist/shortcuts/smart-extract/operations/types.js +22 -0
  95. package/dist/shortcuts/smart-extract/operations/validate.js +454 -0
  96. package/dist/shortcuts/workflow/operations/form.js +68 -33
  97. package/dist/shortcuts/workflow/operations/read.js +19 -1
  98. package/docs/SKILL.md +1 -1
  99. package/docs/_catalog.md +3 -0
  100. package/docs/agent-invoice.md +5 -7
  101. package/docs/data.md +5 -1
  102. package/docs/fna.md +14 -1
  103. package/docs/invoice.md +7 -5
  104. package/docs/smart-extract.md +156 -0
  105. package/package.json +1 -1
  106. package/skill-template/business-info.json +16 -1
  107. package/skill-template/domains/qiyecheng.md +2 -0
  108. package/skill-template/domains/smart-extract.md +16 -0
  109. package/skill-template/domains/yepiaotong.md +2 -2
  110. package/skills/weaver-e10-data/references/scene-and-misc.md +4 -3
  111. package/skills/weaver-e10-jinchengda/SKILL.md +223 -35
  112. package/skills/weaver-e10-jinchengda/references/contract-action-card.md +47 -481
  113. package/skills/weaver-e10-jinchengda/references/contract-action-engine.md +11 -11
  114. package/skills/weaver-e10-jinchengda/references/contract-agent-entry.md +3 -3
  115. package/skills/weaver-e10-jinchengda/references/contract-ai-assistant.md +1 -1
  116. package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +32 -16
  117. package/skills/weaver-e10-jinchengda/references/contract-card-render-internals.md +478 -0
  118. package/skills/weaver-e10-jinchengda/references/contract-command-index.md +4 -4
  119. package/skills/weaver-e10-jinchengda/references/contract-disabled-capabilities.md +2 -2
  120. package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +39 -61
  121. package/skills/weaver-e10-jinchengda/references/contract-element-save-record.md +18 -13
  122. package/skills/weaver-e10-jinchengda/references/contract-execution-rules.md +2 -2
  123. package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +21 -6
  124. package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +6 -4
  125. package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +3 -3
  126. package/skills/weaver-e10-jinchengda/references/contract-ledger-catalog.md +263 -0
  127. package/skills/weaver-e10-jinchengda/references/contract-ledger-query-playbook.md +525 -0
  128. package/skills/weaver-e10-jinchengda/references/contract-ledger-rules.md +36 -0
  129. package/skills/weaver-e10-jinchengda/references/contract-modeltext-library.md +128 -0
  130. package/skills/weaver-e10-jinchengda/references/contract-multi-file.md +87 -0
  131. package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +80 -54
  132. package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +110 -14
  133. package/skills/weaver-e10-jinchengda/references/contract-template-selector.md +19 -21
  134. package/skills/weaver-e10-jinchengda/references/orchestration.md +12 -12
  135. package/skills/weaver-e10-jinchengda/references/source-manifest.json +1 -6
  136. package/skills/weaver-e10-jinchengda/scripts/fill_plan.py +2 -1
  137. package/skills/weaver-e10-qiyecheng/SKILL.md +37 -0
  138. package/skills/weaver-e10-qiyecheng/references/ai-check-audit.md +14 -0
  139. package/skills/weaver-e10-qiyecheng/references/budget.md +14 -0
  140. package/skills/weaver-e10-qiyecheng/references/catalog.md +25 -0
  141. package/skills/weaver-e10-qiyecheng/references/expense-center.md +8 -0
  142. package/skills/weaver-e10-qiyecheng/references/expense-chart.md +9 -0
  143. package/skills/weaver-e10-qiyecheng/references/invoice-writeoff.md +13 -0
  144. package/skills/weaver-e10-qiyecheng/references/loan-management.md +14 -0
  145. package/skills/weaver-e10-qiyecheng/references/self-hosted-mode.md +239 -0
  146. package/skills/weaver-e10-qiyecheng/references/source-manifest.json +34 -27
  147. package/skills/weaver-e10-recruit-stage/SKILL.md +62 -4
  148. package/skills/weaver-e10-recruit-stage/agents/openai.yaml +42 -8
  149. package/skills/weaver-e10-recruit-stage/references/env-ziyong.md +79 -0
  150. package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +11 -3
  151. package/skills/weaver-e10-recruit-stage/references/recruit-edit-interview-feedback.md +3 -2
  152. package/skills/weaver-e10-recruit-stage/references/recruit-interview-not-attended.md +153 -0
  153. package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +7 -4
  154. package/skills/weaver-e10-recruit-stage/references/recruit-match-candidates.md +1 -1
  155. package/skills/weaver-e10-recruit-stage/references/recruit-my-positions.md +66 -0
  156. package/skills/weaver-e10-recruit-stage/references/recruit-output-links.md +156 -42
  157. package/skills/weaver-e10-recruit-stage/references/recruit-resume-import-batch.md +122 -0
  158. package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +36 -8
  159. package/skills/weaver-e10-recruit-stage/references/recruit-search-by-tag.md +157 -0
  160. package/skills/weaver-e10-recruit-stage/references/recruit-utterance-glossary.md +35 -0
  161. package/skills/weaver-e10-smart-extract/SKILL.md +180 -0
  162. package/skills/weaver-e10-smart-extract/references/api-contract.md +71 -0
  163. package/skills/weaver-e10-smart-extract/references/result-format.md +102 -0
  164. package/skills/weaver-e10-smart-extract/references/troubleshooting.md +106 -0
  165. package/skills/weaver-e10-workflow/references/workflow-create.md +6 -5
  166. package/skills/weaver-e10-workflow/references/workflow-edit.md +1 -1
  167. package/skills/weaver-e10-workflow/references/workflow-query.md +1 -1
  168. package/skills/weaver-e10-workflow/references/workflow-view.md +1 -1
  169. package/skills/weaver-e10-yepiaotong/SKILL.md +46 -33
  170. package/skills/weaver-e10-yepiaotong/references/invoice-add.md +2 -0
  171. package/skills/weaver-e10-yepiaotong/references/invoice-file-upload.md +1 -1
  172. package/skills/weaver-e10-yepiaotong/references/invoice-import.md +19 -2
  173. package/skills/weaver-e10-yepiaotong/references/invoice-ocr-preview.md +8 -2
  174. package/skills/weaver-e10-yepiaotong/references/invoice-reim-relation.md +407 -0
  175. package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +12 -8
  176. package/skills/weaver-e10-yepiaotong/references/invoice-upload-and-validate.md +97 -39
  177. package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +91 -2
  178. package/skills/weaver-e10-yepiaotong/references/reim-examples.md +1 -1
  179. package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +12 -12
  180. package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +8 -4
  181. package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +136 -91
  182. package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +109 -23
  183. package/skills/weaver-e10-yepiaotong/references/source-manifest.json +110 -43
  184. package/dist/shortcuts/invoice/operations/validate-preview.js +0 -40
  185. package/skills/weaver-e10-jinchengda/scripts/plan_actions.py +0 -279
  186. package/skills/weaver-e10-jinchengda/scripts/render_action_card.py +0 -450
  187. package/skills/weaver-e10-jinchengda/scripts/render_ebdf_list_card.py +0 -265
  188. package/skills/weaver-e10-jinchengda/scripts/render_risk_report.py +0 -358
  189. package/skills/weaver-e10-jinchengda/scripts/validate_action_card.py +0 -588
  190. package/skills/weaver-e10-jinchengda/scripts/verify_docx_placeholders.py +0 -118
  191. package/skills/weaver-e10-yepiaotong/references/invoice-validation-preview.md +0 -40
@@ -0,0 +1,571 @@
1
+ import { mkdirSync, writeFileSync } from 'node:fs';
2
+ import { dirname, resolve } from 'node:path';
3
+ import { contractValidationError } from '../errors.js';
4
+ /**
5
+ * 业绩核算六菜单 ebdf 列表组件卡生成器(本地,零依赖)。
6
+ *
7
+ * 迁移自 `scripts/render_ebdf_list_card.py`(2026-11-12 第二批)。
8
+ *
9
+ * 为什么固化:这六类列表以前用外部浏览器打开,用户拿不到 E10 列表组件;
10
+ * 改造成 ebdf 列表页组件卡后,pageId / 组件名极易抄错,因此全部固化,
11
+ * 模型不再手写卡片。
12
+ *
13
+ * 语义对齐:menu/pageId 解析、别名、origin 校验、comParams 键格式与
14
+ * 12 项自检全部与 Python 版一致。
15
+ */
16
+ /** 菜单 → pageId(2026-11-10 用户确认,勿改)。用 Map 保持插入顺序,子串匹配依赖该顺序。 */
17
+ const MENU_PAGES = new Map([
18
+ ['直销合同', '881124906081886244'],
19
+ ['直销业绩', '846297265322576586'],
20
+ ['合同收款', '846297265322576589'],
21
+ ['项目验收', '846297265322576590'],
22
+ ['渠道订单', '881210951456350225'],
23
+ ['渠道订单-商务', '881211329321197671'],
24
+ ]);
25
+ const ALIASES = new Map([
26
+ ['e-cology合同', '直销合同'],
27
+ ['e-cology 合同', '直销合同'],
28
+ ['合同数据', '直销合同'],
29
+ ['直销合同数据', '直销合同'],
30
+ ['业绩', '直销业绩'],
31
+ ['个人业绩', '直销业绩'],
32
+ ['机构业绩', '直销业绩'],
33
+ ['大区业绩', '直销业绩'],
34
+ ['团队业绩', '直销业绩'],
35
+ ['合同收款信息', '合同收款'],
36
+ ['收款', '合同收款'],
37
+ ['验收', '项目验收'],
38
+ ['项目验收数据', '项目验收'],
39
+ ['渠道订单数据', '渠道订单'],
40
+ ['e-office合同', '渠道订单'],
41
+ ['e-teams合同', '渠道订单'],
42
+ ['渠道协议', '渠道订单-商务'],
43
+ ['e-office协议订单', '渠道订单-商务'],
44
+ ['商务渠道订单', '渠道订单-商务'],
45
+ ['渠道订单商务', '渠道订单-商务'],
46
+ ]);
47
+ /**
48
+ * 菜单 → 台账页(`@weapp/contract` 的 LedgerPage)默认标签 viewKey(2026-11-13 用户确认)。
49
+ *
50
+ * 台账页只有 5 个标签:e-cology 合同 / 直销合同业绩 / e-office 渠道协议 /
51
+ * e-office 渠道订单 / e-teams 渠道订单。「合同收款」「项目验收」在台账页没有对应标签,
52
+ * 不在本表内,继续用 ebdf 列表卡打开。渠道订单同时含 e-office 与 e-teams 产品数据,
53
+ * 默认落 e-teams 标签(用户确认),用户可在页面自行切换。
54
+ */
55
+ const LEDGER_VIEW_KEYS = new Map([
56
+ ['直销合同', 'ecology'],
57
+ ['直销业绩', 'directPerf'],
58
+ ['渠道订单', 'etOrder'],
59
+ ['渠道订单-商务', 'agree'],
60
+ ]);
61
+ /** 台账页 filters 可用键与值类型(来源:组件说明「默认筛选」)。 */
62
+ const LEDGER_FILTER_KINDS = {
63
+ ecology: {
64
+ khmc: 'text',
65
+ hth: 'text',
66
+ htmc: 'text',
67
+ qdrq: 'dateRange',
68
+ htzje: 'amountRange',
69
+ xslx: 'text',
70
+ xsjl2: 'text',
71
+ qy2: 'text',
72
+ hsjg: 'text',
73
+ },
74
+ directPerf: {
75
+ hth: 'text',
76
+ khmc: 'text',
77
+ yjny: 'text',
78
+ xsjl: 'text',
79
+ tdfzr: 'text',
80
+ jgfzr: 'text',
81
+ },
82
+ agree: {
83
+ dls: 'text',
84
+ xyh: 'text',
85
+ qdrq: 'dateRange',
86
+ htzje: 'amountRange',
87
+ sqjsrq: 'date',
88
+ },
89
+ eoOrder: {
90
+ khmc: 'text',
91
+ qy3: 'text',
92
+ qdrq: 'dateRange',
93
+ htzje: 'amountRange',
94
+ htzl: 'text',
95
+ syhhr: 'text',
96
+ ejsyhhr: 'text',
97
+ },
98
+ etOrder: {
99
+ khmc: 'text',
100
+ htzl: 'text',
101
+ qy3: 'text',
102
+ qdrq: 'dateRange',
103
+ htzje: 'amountRange',
104
+ syhhr: 'text',
105
+ },
106
+ };
107
+ /** 台账页路由(组件说明:src 为 <origin>/sp/contract/ledger)。 */
108
+ const LEDGER_ROUTE = '/sp/contract/ledger';
109
+ const DATE_TEXT = /^\d{4}-\d{2}-\d{2}$/u;
110
+ const AMOUNT_TEXT = /^-?\d+(\.\d+)?$/u;
111
+ const FIELD_KEY = /^field_\d+$/u;
112
+ const PAGE_ID = /^\d{6,}$/u;
113
+ const ORIGIN = /^https?:\/\/[^/]+$/u;
114
+ /** Python `str()` 的常见分支(comParams 值强制转字符串时使用)。 */
115
+ function pyStr(value) {
116
+ if (value === null || value === undefined)
117
+ return 'None';
118
+ if (value === true)
119
+ return 'True';
120
+ if (value === false)
121
+ return 'False';
122
+ if (typeof value === 'string')
123
+ return value;
124
+ if (typeof value === 'number')
125
+ return String(value);
126
+ if (Array.isArray(value))
127
+ return `[${value.map((item) => pyRepr(item)).join(', ')}]`;
128
+ if (typeof value === 'object') {
129
+ return `{${Object.entries(value)
130
+ .map(([key, val]) => `${pyRepr(key)}: ${pyRepr(val)}`)
131
+ .join(', ')}}`;
132
+ }
133
+ return String(value);
134
+ }
135
+ function pyRepr(value) {
136
+ return typeof value === 'string' ? `'${value}'` : pyStr(value);
137
+ }
138
+ /** Python `%r` 对字符串的呈现(错误信息里用)。 */
139
+ function pyReprText(value) {
140
+ return typeof value === 'string' ? `'${value}'` : pyStr(value);
141
+ }
142
+ /** Python `(raw or "").strip()`:非字符串的假值一律视为空串。 */
143
+ function stripOrEmpty(value) {
144
+ if (typeof value !== 'string') {
145
+ if (value === null || value === undefined || value === false || value === 0)
146
+ return '';
147
+ return String(value).trim();
148
+ }
149
+ return value.trim();
150
+ }
151
+ function resolveMenu(raw) {
152
+ const name = stripOrEmpty(raw);
153
+ if (MENU_PAGES.has(name)) {
154
+ return { menu: name, pageId: MENU_PAGES.get(name) };
155
+ }
156
+ if (ALIASES.has(name)) {
157
+ const real = ALIASES.get(name);
158
+ return { menu: real, pageId: MENU_PAGES.get(real) };
159
+ }
160
+ const hits = [];
161
+ for (const key of MENU_PAGES.keys()) {
162
+ if (name && (key.includes(name) || name.includes(key)))
163
+ hits.push(key);
164
+ }
165
+ if (hits.length === 1) {
166
+ return { menu: hits[0], pageId: MENU_PAGES.get(hits[0]) };
167
+ }
168
+ const options = [...MENU_PAGES.keys()].join('、');
169
+ throw contractValidationError('menu_unknown', `未知菜单 ${pyReprText(raw)},可选:${options}`);
170
+ }
171
+ function cleanOrigin(raw) {
172
+ const origin = stripOrEmpty(raw).replace(/\/+$/u, '');
173
+ if (!origin)
174
+ throw contractValidationError('origin_required', '缺少 origin');
175
+ if (origin.includes('{baseUrl}')) {
176
+ throw contractValidationError('origin_placeholder', 'origin 仍是占位符 {baseUrl}');
177
+ }
178
+ if (!ORIGIN.test(origin)) {
179
+ throw contractValidationError('origin_invalid', 'origin 只能是 scheme+host,不能带路径、query 或用户信息');
180
+ }
181
+ return origin;
182
+ }
183
+ function parseComParams(pairs, rawJson) {
184
+ const pairList = Array.isArray(pairs) ? pairs : [];
185
+ const jsonText = typeof rawJson === 'string' && rawJson.trim() ? rawJson : '';
186
+ if (pairList.length && jsonText) {
187
+ throw contractValidationError('com_params_conflict', 'comParamPairs 与 comParamsJson 只能二选一');
188
+ }
189
+ const merged = {};
190
+ if (jsonText) {
191
+ let parsed;
192
+ try {
193
+ parsed = JSON.parse(jsonText);
194
+ }
195
+ catch (error) {
196
+ const message = error instanceof Error ? error.message : String(error);
197
+ throw contractValidationError('com_params_invalid', `comParamsJson 不是合法 JSON:${message}`);
198
+ }
199
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
200
+ throw contractValidationError('com_params_invalid', 'comParamsJson 必须是对象');
201
+ }
202
+ Object.assign(merged, parsed);
203
+ }
204
+ for (const item of pairList) {
205
+ const text = typeof item === 'string' ? item : pyStr(item);
206
+ const index = text.indexOf('=');
207
+ if (index < 0) {
208
+ throw contractValidationError('com_param_invalid', `comParamPairs 需要 key=value,收到 ${pyReprText(item)}`);
209
+ }
210
+ const key = text.slice(0, index).trim();
211
+ merged[key] = text.slice(index + 1);
212
+ }
213
+ const out = {};
214
+ for (const [key, value] of Object.entries(merged)) {
215
+ if (!FIELD_KEY.test(String(key))) {
216
+ throw contractValidationError('com_param_key_invalid', `条件键必须是 field_<字段id>,收到 ${pyReprText(key)}`);
217
+ }
218
+ out[String(key)] = typeof value === 'string' ? value : pyStr(value);
219
+ }
220
+ return out;
221
+ }
222
+ function pad2(value) {
223
+ return String(value).padStart(2, '0');
224
+ }
225
+ /** 等价 Python `datetime.now().strftime('%Y%m%d%H%M')`(本地时间)。 */
226
+ function stampNow() {
227
+ const now = new Date();
228
+ return `${now.getFullYear()}${pad2(now.getMonth() + 1)}${pad2(now.getDate())}`
229
+ + `${pad2(now.getHours())}${pad2(now.getMinutes())}`;
230
+ }
231
+ function buildCard(pageId, origin, title, callId, comParams) {
232
+ const route = `/list/${pageId}`;
233
+ return {
234
+ version: 1,
235
+ callId,
236
+ toolId: 'fill_form',
237
+ arguments: {
238
+ type: 'e10',
239
+ title,
240
+ src: `${origin}/sp/ebdfpage/list/${pageId}`,
241
+ sdkRenderType: 'inline',
242
+ sdkOptions: {
243
+ compName: 'ui.CorsComponent',
244
+ routerType: 'MemoryRouter',
245
+ routerProps_pc: { initialEntries: [route] },
246
+ routerProps_mobile: { initialEntries: [route] },
247
+ params_pc: {
248
+ app: '@weapp/ebdfpage',
249
+ compName: 'TableViewList',
250
+ noMDialog: true,
251
+ },
252
+ params_mobile: {
253
+ app: '@weapp/ebdfpage',
254
+ compName: 'MTableViewList',
255
+ noMDialog: true,
256
+ },
257
+ params: {
258
+ pageId,
259
+ comParams,
260
+ },
261
+ },
262
+ },
263
+ };
264
+ }
265
+ /**
266
+ * 解析台账页 filters(来源:组件说明「默认筛选」)。
267
+ *
268
+ * 键是台账键(如 khmc / qdrq / htzje),不是 `field_<字段id>`;
269
+ * 日期区间与金额区间写两元素数组,只限一端时另一端传空串。
270
+ */
271
+ function parseLedgerFilters(pairs, rawJson, viewKey) {
272
+ const allowed = LEDGER_FILTER_KINDS[viewKey] ?? {};
273
+ const pairList = Array.isArray(pairs) ? pairs : [];
274
+ const jsonText = typeof rawJson === 'string' && rawJson.trim() ? rawJson : '';
275
+ if (pairList.length && jsonText) {
276
+ throw contractValidationError('com_params_conflict', 'comParamPairs 与 comParamsJson 只能二选一');
277
+ }
278
+ const merged = {};
279
+ if (jsonText) {
280
+ let parsed;
281
+ try {
282
+ parsed = JSON.parse(jsonText);
283
+ }
284
+ catch (error) {
285
+ const message = error instanceof Error ? error.message : String(error);
286
+ throw contractValidationError('com_params_invalid', `comParamsJson 不是合法 JSON:${message}`);
287
+ }
288
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
289
+ throw contractValidationError('com_params_invalid', 'comParamsJson 必须是对象');
290
+ }
291
+ Object.assign(merged, parsed);
292
+ }
293
+ for (const item of pairList) {
294
+ const text = typeof item === 'string' ? item : pyStr(item);
295
+ const index = text.indexOf('=');
296
+ if (index < 0) {
297
+ throw contractValidationError('com_param_invalid', `comParamPairs 需要 key=value,收到 ${pyReprText(item)}`);
298
+ }
299
+ merged[text.slice(0, index).trim()] = text.slice(index + 1);
300
+ }
301
+ const out = {};
302
+ for (const [key, raw] of Object.entries(merged)) {
303
+ const kind = allowed[key];
304
+ if (!kind) {
305
+ throw contractValidationError('ledger_filter_key_invalid', `台账标签 ${viewKey} 没有筛选键 ${pyReprText(key)},可用:${Object.keys(allowed).join('、')}`);
306
+ }
307
+ if (kind === 'dateRange' || kind === 'amountRange') {
308
+ if (!Array.isArray(raw) || raw.length !== 2) {
309
+ throw contractValidationError('ledger_filter_range_invalid', `${key} 需要 [起点, 终点] 两元素数组;只限一端时另一端传空串。`);
310
+ }
311
+ const bounds = raw.map((item) => (typeof item === 'string' ? item.trim() : pyStr(item)));
312
+ for (const bound of bounds) {
313
+ if (!bound)
314
+ continue;
315
+ if (kind === 'dateRange' && !DATE_TEXT.test(bound)) {
316
+ throw contractValidationError('ledger_filter_date_invalid', `${key} 的日期应为 YYYY-MM-DD,收到 ${bound}`);
317
+ }
318
+ if (kind === 'amountRange' && !AMOUNT_TEXT.test(bound)) {
319
+ throw contractValidationError('ledger_filter_amount_invalid', `${key} 的金额应以元为单位的纯数字,收到 ${bound}`);
320
+ }
321
+ }
322
+ out[key] = bounds;
323
+ continue;
324
+ }
325
+ if (Array.isArray(raw) || (raw !== null && typeof raw === 'object')) {
326
+ throw contractValidationError('ledger_filter_value_invalid', `${key} 需要一个字符串值。`);
327
+ }
328
+ const text = raw === null || raw === undefined ? '' : typeof raw === 'string' ? raw.trim() : pyStr(raw);
329
+ if (kind === 'date' && text && !DATE_TEXT.test(text)) {
330
+ throw contractValidationError('ledger_filter_date_invalid', `${key} 的日期应为 YYYY-MM-DD,收到 ${text}`);
331
+ }
332
+ out[key] = text;
333
+ }
334
+ return out;
335
+ }
336
+ /** 台账页组件卡:fill_form + e10 + @weapp/contract 的 LedgerPage,viewKey 决定默认标签。 */
337
+ function buildLedgerCard(viewKey, origin, title, callId, filters) {
338
+ return {
339
+ version: 1,
340
+ callId,
341
+ toolId: 'fill_form',
342
+ arguments: {
343
+ type: 'e10',
344
+ title,
345
+ src: `${origin}${LEDGER_ROUTE}`,
346
+ width: 1300,
347
+ sdkRenderType: 'inline',
348
+ sdkOptions: {
349
+ compName: 'ui.CorsComponent',
350
+ routerType: 'MemoryRouter',
351
+ routerProps_pc: { initialEntries: [LEDGER_ROUTE] },
352
+ params_pc: {
353
+ app: '@weapp/contract',
354
+ compName: 'LedgerPage',
355
+ },
356
+ params: {
357
+ viewKey,
358
+ filters: { [viewKey]: filters },
359
+ },
360
+ },
361
+ },
362
+ };
363
+ }
364
+ /** 台账页卡的逐项自检;空数组即通过。 */
365
+ function selfCheckLedger(card, viewKey) {
366
+ const bad = [];
367
+ const args = card.arguments ?? {};
368
+ const options = args.sdkOptions ?? {};
369
+ const pc = options.params_pc ?? {};
370
+ const params = options.params ?? {};
371
+ const routerPc = options.routerProps_pc ?? {};
372
+ if (card.version !== 1)
373
+ bad.push('version != 1');
374
+ if (card.toolId !== 'fill_form')
375
+ bad.push('toolId != fill_form');
376
+ if (!card.callId)
377
+ bad.push('callId 为空');
378
+ if (args.type !== 'e10')
379
+ bad.push('arguments.type != e10');
380
+ if (args.sdkRenderType !== 'inline')
381
+ bad.push('sdkRenderType != inline');
382
+ if (!String(args.src ?? '').endsWith(LEDGER_ROUTE))
383
+ bad.push('src 与台账路由不一致');
384
+ if (args.width !== 1300)
385
+ bad.push('width 应为 1300');
386
+ if (options.compName !== 'ui.CorsComponent')
387
+ bad.push('sdkOptions.compName != ui.CorsComponent');
388
+ if (options.routerType !== 'MemoryRouter')
389
+ bad.push('routerType != MemoryRouter');
390
+ if (!Array.isArray(routerPc.initialEntries) || routerPc.initialEntries[0] !== LEDGER_ROUTE) {
391
+ bad.push('initialEntries 不是台账路由');
392
+ }
393
+ if (pc.app !== '@weapp/contract' || pc.compName !== 'LedgerPage')
394
+ bad.push('params_pc 不是 @weapp/contract LedgerPage');
395
+ if (params.viewKey !== viewKey)
396
+ bad.push('params.viewKey 与菜单映射不一致');
397
+ const filters = params.filters;
398
+ if (!filters || typeof filters !== 'object' || Array.isArray(filters)) {
399
+ bad.push('params.filters 不是对象');
400
+ return bad;
401
+ }
402
+ const outerKeys = Object.keys(filters);
403
+ if (outerKeys.length !== 1 || outerKeys[0] !== viewKey)
404
+ bad.push('filters 第一层 key 必须是 viewKey');
405
+ const inner = filters[viewKey];
406
+ if (!inner || typeof inner !== 'object' || Array.isArray(inner)) {
407
+ bad.push('filters[viewKey] 不是对象');
408
+ return bad;
409
+ }
410
+ const allowed = LEDGER_FILTER_KINDS[viewKey] ?? {};
411
+ for (const [key, value] of Object.entries(inner)) {
412
+ const kind = allowed[key];
413
+ if (!kind)
414
+ bad.push(`filters 键不在 ${viewKey} 白名单:${key}`);
415
+ if (kind === 'dateRange' || kind === 'amountRange') {
416
+ if (!Array.isArray(value) || value.length !== 2 || value.some((item) => typeof item !== 'string')) {
417
+ bad.push(`filters 区间不是两段字符串:${key}`);
418
+ }
419
+ }
420
+ else if (typeof value !== 'string') {
421
+ bad.push(`filters 值不是字符串:${key}`);
422
+ }
423
+ }
424
+ return bad;
425
+ }
426
+ /** 按 validate 的 ebdf 分支逐项核对,返回问题列表(空数组即通过)。 */
427
+ function selfCheck(card, pageId) {
428
+ const bad = [];
429
+ const args = card.arguments ?? {};
430
+ const options = args.sdkOptions ?? {};
431
+ const pc = options.params_pc ?? {};
432
+ const mobile = options.params_mobile ?? {};
433
+ const params = options.params ?? {};
434
+ const routerPc = options.routerProps_pc ?? {};
435
+ const routerMobile = options.routerProps_mobile ?? {};
436
+ if (card.version !== 1)
437
+ bad.push('version != 1');
438
+ if (card.toolId !== 'fill_form')
439
+ bad.push('toolId != fill_form');
440
+ if (!card.callId)
441
+ bad.push('callId 为空');
442
+ if (args.type !== 'e10')
443
+ bad.push('arguments.type != e10');
444
+ if (args.sdkRenderType !== 'inline')
445
+ bad.push('sdkRenderType != inline');
446
+ if ('width' in args)
447
+ bad.push('ebdf 列表卡不应带 arguments.width');
448
+ if (!String(args.src ?? '').endsWith(`/sp/ebdfpage/list/${pageId}`))
449
+ bad.push('src 与 pageId 不一致');
450
+ if (options.compName !== 'ui.CorsComponent')
451
+ bad.push('sdkOptions.compName != ui.CorsComponent');
452
+ if (options.routerType !== 'MemoryRouter')
453
+ bad.push('routerType != MemoryRouter');
454
+ if (pc.app !== '@weapp/ebdfpage' || pc.compName !== 'TableViewList')
455
+ bad.push('params_pc 组件不对');
456
+ if (mobile.app !== '@weapp/ebdfpage' || mobile.compName !== 'MTableViewList')
457
+ bad.push('params_mobile 组件不对');
458
+ if (pc.noMDialog !== true || mobile.noMDialog !== true)
459
+ bad.push('noMDialog 未同时为 true');
460
+ if (params.pageId !== pageId)
461
+ bad.push('params.pageId 与 pageId 不一致');
462
+ const want = [`/list/${pageId}`];
463
+ if (JSON.stringify(routerPc.initialEntries) !== JSON.stringify(want)
464
+ || JSON.stringify(routerMobile.initialEntries) !== JSON.stringify(want)) {
465
+ bad.push('initialEntries 与 pageId 不一致');
466
+ }
467
+ const comParams = params.comParams;
468
+ if (!comParams || typeof comParams !== 'object' || Array.isArray(comParams)) {
469
+ bad.push('comParams 不是对象');
470
+ }
471
+ else {
472
+ for (const [key, value] of Object.entries(comParams)) {
473
+ if (!FIELD_KEY.test(key))
474
+ bad.push(`comParams 键格式错误:${pyReprText(key)}`);
475
+ if (typeof value !== 'string')
476
+ bad.push(`comParams 值不是字符串:${pyReprText(key)}`);
477
+ }
478
+ }
479
+ return bad;
480
+ }
481
+ /**
482
+ * 生成 ebdf 列表组件卡。
483
+ *
484
+ * 注意:returned `card` 可直接作为 `<browsertool>` 内的 JSON 使用;
485
+ * `selfCheck` 非空表示结构不达标,禁止交付。
486
+ */
487
+ export const contractCardEbdfListOperation = {
488
+ name: 'contract.card.ebdf-list',
489
+ async execute(input) {
490
+ const rawPageId = stripOrEmpty(input.pageId);
491
+ let menu;
492
+ let pageId;
493
+ if (rawPageId) {
494
+ if (!PAGE_ID.test(rawPageId)) {
495
+ throw contractValidationError('page_id_invalid', `pageId 必须是数字串,收到 ${pyReprText(rawPageId)}`);
496
+ }
497
+ pageId = rawPageId;
498
+ const menuInput = stripOrEmpty(input.menu);
499
+ menu = menuInput || pageId;
500
+ }
501
+ else {
502
+ const resolved = resolveMenu(input.menu);
503
+ menu = resolved.menu;
504
+ pageId = resolved.pageId;
505
+ }
506
+ const origin = cleanOrigin(input.origin);
507
+ const viewKey = LEDGER_VIEW_KEYS.get(menu);
508
+ const titleInput = stripOrEmpty(input.title);
509
+ const title = titleInput || menu;
510
+ if (!title)
511
+ throw contractValidationError('title_required', 'title 不能为空');
512
+ const callIdInput = stripOrEmpty(input.callId);
513
+ const callId = callIdInput
514
+ || `${viewKey ? 'ledger' : 'ebdf-list'}-${menu}-${stampNow()}-01`;
515
+ if (viewKey) {
516
+ const filters = parseLedgerFilters(input.comParamPairs, input.comParamsJson, viewKey);
517
+ const card = buildLedgerCard(viewKey, origin, title, callId, filters);
518
+ const problems = selfCheckLedger(card, viewKey);
519
+ if (problems.length) {
520
+ throw contractValidationError('self_check_failed', `台账页卡自检未通过:${problems.join(';')}`);
521
+ }
522
+ let output;
523
+ if (typeof input.out === 'string' && input.out.trim()) {
524
+ output = resolve(input.out.trim());
525
+ mkdirSync(dirname(output), { recursive: true });
526
+ writeFileSync(output, `${JSON.stringify(card, null, 2)}\n`, 'utf8');
527
+ }
528
+ return {
529
+ status: 'COMPLETE',
530
+ data: {
531
+ menu,
532
+ pageId,
533
+ variant: 'ledger',
534
+ viewKey,
535
+ callId,
536
+ filters,
537
+ card,
538
+ selfCheck: problems,
539
+ ...(output ? { output } : {}),
540
+ note: '台账页卡:viewKey 决定默认标签,filters 第一层 key 就是 viewKey;渠道订单默认 e-teams(etOrder)',
541
+ },
542
+ };
543
+ }
544
+ const comParams = parseComParams(input.comParamPairs, input.comParamsJson);
545
+ const card = buildCard(pageId, origin, title, callId, comParams);
546
+ const problems = selfCheck(card, pageId);
547
+ if (problems.length) {
548
+ throw contractValidationError('self_check_failed', `ebdf 列表卡自检未通过:${problems.join(';')}`);
549
+ }
550
+ let output;
551
+ if (typeof input.out === 'string' && input.out.trim()) {
552
+ output = resolve(input.out.trim());
553
+ mkdirSync(dirname(output), { recursive: true });
554
+ writeFileSync(output, `${JSON.stringify(card, null, 2)}\n`, 'utf8');
555
+ }
556
+ return {
557
+ status: 'COMPLETE',
558
+ data: {
559
+ menu,
560
+ pageId,
561
+ callId,
562
+ comParams,
563
+ card,
564
+ selfCheck: problems,
565
+ ...(output ? { output } : {}),
566
+ note: 'ebdf 列表卡不带 arguments.width;comParams 键必须是 field_<字段id>',
567
+ },
568
+ };
569
+ },
570
+ };
571
+ export const contractCardEbdfListOperations = [contractCardEbdfListOperation];