weaver-work-cli 0.1.8 → 0.1.20

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 (263) hide show
  1. package/README.md +11 -11
  2. package/dist/cmd/action.js +76 -0
  3. package/dist/cmd/index.js +2 -0
  4. package/dist/cmd/refs/index.js +103 -0
  5. package/dist/cmd/register.js +31 -0
  6. package/dist/cmd/root.js +1 -0
  7. package/dist/cmd/setup/index.js +25 -5
  8. package/dist/cmd/skills/index.js +37 -5
  9. package/dist/core/connector.js +54 -0
  10. package/dist/core/context.js +2 -1
  11. package/dist/core/input.js +48 -0
  12. package/dist/core/output.js +298 -3
  13. package/dist/core/refs.js +432 -0
  14. package/dist/core/state.js +26 -0
  15. package/dist/internal/e10/auth/commands.js +2 -2
  16. package/dist/internal/e10/auth/session.js +14 -0
  17. package/dist/internal/e10/auth/xiaoe.js +116 -51
  18. package/dist/internal/e10/request-runtime.js +5 -0
  19. package/dist/internal/skills/install.js +148 -28
  20. package/dist/internal/skills/reader.js +12 -9
  21. package/dist/shortcuts/blog/continuation.js +74 -0
  22. package/dist/shortcuts/blog/errors.js +60 -0
  23. package/dist/shortcuts/blog/host.js +175 -0
  24. package/dist/shortcuts/blog/index.js +324 -0
  25. package/dist/shortcuts/blog/manifest.js +415 -0
  26. package/dist/shortcuts/blog/operations/comment.js +125 -0
  27. package/dist/shortcuts/blog/operations/comments.js +31 -0
  28. package/dist/shortcuts/blog/operations/edit.js +131 -0
  29. package/dist/shortcuts/blog/operations/export.js +46 -0
  30. package/dist/shortcuts/blog/operations/like.js +80 -0
  31. package/dist/shortcuts/blog/operations/publish.js +157 -0
  32. package/dist/shortcuts/blog/operations/query-user.js +58 -0
  33. package/dist/shortcuts/blog/operations/query.js +96 -0
  34. package/dist/shortcuts/blog/operations/registry.js +54 -0
  35. package/dist/shortcuts/blog/operations/remind.js +176 -0
  36. package/dist/shortcuts/blog/operations/shared.js +330 -0
  37. package/dist/shortcuts/blog/operations/types.js +16 -0
  38. package/dist/shortcuts/blog/operations.js +9 -0
  39. package/dist/shortcuts/caizhilian/continuation.js +70 -0
  40. package/dist/shortcuts/caizhilian/errors.js +53 -0
  41. package/dist/shortcuts/caizhilian/host.js +190 -0
  42. package/dist/shortcuts/caizhilian/index.js +186 -0
  43. package/dist/shortcuts/caizhilian/manifest.js +42 -0
  44. package/dist/shortcuts/caizhilian/operations/api.js +801 -0
  45. package/dist/shortcuts/caizhilian/operations/confirm.js +75 -0
  46. package/dist/shortcuts/caizhilian/operations/files.js +306 -0
  47. package/dist/shortcuts/caizhilian/operations/form.js +170 -0
  48. package/dist/shortcuts/caizhilian/operations/handlers/collab.js +611 -0
  49. package/dist/shortcuts/caizhilian/operations/handlers/document.js +890 -0
  50. package/dist/shortcuts/caizhilian/operations/handlers/file-collection.js +346 -0
  51. package/dist/shortcuts/caizhilian/operations/handlers/file-upload.js +192 -0
  52. package/dist/shortcuts/caizhilian/operations/handlers/fileops.js +570 -0
  53. package/dist/shortcuts/caizhilian/operations/handlers/folder.js +969 -0
  54. package/dist/shortcuts/caizhilian/operations/handlers/search.js +318 -0
  55. package/dist/shortcuts/caizhilian/operations/handlers/setting-attach.js +294 -0
  56. package/dist/shortcuts/caizhilian/operations/handlers/setting-backup.js +423 -0
  57. package/dist/shortcuts/caizhilian/operations/handlers/setting-encrypt.js +238 -0
  58. package/dist/shortcuts/caizhilian/operations/handlers/setting-storage.js +364 -0
  59. package/dist/shortcuts/caizhilian/operations/handlers/system.js +106 -0
  60. package/dist/shortcuts/caizhilian/operations/registry.js +151 -0
  61. package/dist/shortcuts/caizhilian/operations/shared.js +408 -0
  62. package/dist/shortcuts/caizhilian/operations/specs.js +623 -0
  63. package/dist/shortcuts/caizhilian/operations/types.js +57 -0
  64. package/dist/shortcuts/caizhilian/operations.js +21 -0
  65. package/dist/shortcuts/contract/continuation.js +70 -0
  66. package/dist/shortcuts/contract/errors.js +62 -0
  67. package/dist/shortcuts/contract/host.js +205 -0
  68. package/dist/shortcuts/contract/index.js +318 -0
  69. package/dist/shortcuts/contract/manifest.js +596 -0
  70. package/dist/shortcuts/contract/operations/clause-reference.js +78 -0
  71. package/dist/shortcuts/contract/operations/form-info.js +371 -0
  72. package/dist/shortcuts/contract/operations/read.js +118 -0
  73. package/dist/shortcuts/contract/operations/registry.js +43 -0
  74. package/dist/shortcuts/contract/operations/request.js +300 -0
  75. package/dist/shortcuts/contract/operations/shared.js +133 -0
  76. package/dist/shortcuts/contract/operations/subject.js +157 -0
  77. package/dist/shortcuts/contract/operations/template.js +81 -0
  78. package/dist/shortcuts/contract/operations/types.js +7 -0
  79. package/dist/shortcuts/contract/operations/workflow.js +52 -0
  80. package/dist/shortcuts/contract/operations/write.js +131 -0
  81. package/dist/shortcuts/contract/operations.js +8 -0
  82. package/dist/shortcuts/hrm/index.js +83 -2
  83. package/dist/shortcuts/hrm/operations/employee.js +160 -30
  84. package/dist/shortcuts/hrm/operations/org.js +17 -3
  85. package/dist/shortcuts/hrm/operations/position.js +18 -2
  86. package/dist/shortcuts/index.js +5 -1
  87. package/dist/shortcuts/invoice/index.js +74 -36
  88. package/dist/shortcuts/invoice/manifest.js +674 -4
  89. package/dist/shortcuts/invoice/markdown.js +172 -0
  90. package/dist/shortcuts/invoice/operations/add.js +3 -3
  91. package/dist/shortcuts/invoice/operations/delete.js +2 -2
  92. package/dist/shortcuts/invoice/operations/get.js +10 -2
  93. package/dist/shortcuts/invoice/operations/import.js +2 -2
  94. package/dist/shortcuts/invoice/operations/registry.js +8 -1
  95. package/dist/shortcuts/invoice/operations/reim-auto.js +719 -0
  96. package/dist/shortcuts/invoice/operations/reim.js +85 -2
  97. package/dist/shortcuts/invoice/operations/shared.js +75 -8
  98. package/dist/shortcuts/invoice/operations/update.js +2 -2
  99. package/dist/shortcuts/invoice/operations/upload-and-validate.js +93 -0
  100. package/dist/shortcuts/invoice/operations/validate-preview.js +2 -1
  101. package/dist/shortcuts/invoice/projection.js +328 -0
  102. package/dist/shortcuts/meeting/host.js +18 -1
  103. package/dist/shortcuts/meeting/manifest.js +30 -18
  104. package/dist/shortcuts/meeting/operations/eb/catalog.js +390 -0
  105. package/dist/shortcuts/meeting/operations/eb/conflict.js +389 -0
  106. package/dist/shortcuts/meeting/operations/eb/factory.js +389 -0
  107. package/dist/shortcuts/meeting/operations/eb/index.js +22 -0
  108. package/dist/shortcuts/meeting/operations/env.js +8 -1
  109. package/dist/shortcuts/meeting/operations/registry.js +2 -0
  110. package/dist/shortcuts/meeting/operations/signs.js +216 -2
  111. package/dist/shortcuts/workflow/endpoints.js +2 -1
  112. package/dist/shortcuts/workflow/errors.js +8 -2
  113. package/dist/shortcuts/workflow/host.js +6 -3
  114. package/dist/shortcuts/workflow/operations/form.js +931 -589
  115. package/dist/shortcuts/workflow/operations/read.js +128 -205
  116. package/dist/shortcuts/workflow/operations/shared.js +21 -0
  117. package/dist/shortcuts/workflow/operations/write.js +750 -52
  118. package/dist/shortcuts/workflow/operations.js +36 -10
  119. package/docs/_catalog.md +6 -0
  120. package/docs/agent-invoice.md +5 -1
  121. package/docs/agent-io-channel-design.md +468 -0
  122. package/docs/agent-skill-install.md +9 -4
  123. package/docs/blog.md +123 -0
  124. package/docs/caizhilian.md +304 -0
  125. package/docs/contract.md +91 -0
  126. package/docs/e10-auth.md +2 -2
  127. package/docs/hrm.md +19 -9
  128. package/docs/invoice.md +5 -1
  129. package/docs/meeting.md +1 -1
  130. package/docs/operation-manual.md +15 -3
  131. package/docs/skill-review-2026-09-19.md +2 -2
  132. package/package.json +2 -2
  133. package/scripts/package-skill.mjs +32 -20
  134. package/skill-template/business-info.json +113 -14
  135. package/skill-template/domains/blog.md +24 -0
  136. package/skill-template/domains/caizhilian.md +22 -0
  137. package/skill-template/domains/jinchengda.md +23 -0
  138. package/skill-template/domains/meeting.md +1 -1
  139. package/skill-template/domains/workflow.md +1 -1
  140. package/skill-template/skill-template.md +1 -1
  141. package/skills/weaver-e10-blog/SKILL.md +111 -0
  142. package/skills/weaver-e10-blog/references/blog-comment.md +51 -0
  143. package/skills/weaver-e10-blog/references/blog-comments.md +39 -0
  144. package/skills/weaver-e10-blog/references/blog-default-permission.md +38 -0
  145. package/skills/weaver-e10-blog/references/blog-disabled-capabilities.md +11 -0
  146. package/skills/weaver-e10-blog/references/blog-edit.md +51 -0
  147. package/skills/weaver-e10-blog/references/blog-export.md +42 -0
  148. package/skills/weaver-e10-blog/references/blog-like.md +50 -0
  149. package/skills/weaver-e10-blog/references/blog-publish.md +52 -0
  150. package/skills/weaver-e10-blog/references/blog-query-user.md +45 -0
  151. package/skills/weaver-e10-blog/references/blog-query.md +49 -0
  152. package/skills/weaver-e10-blog/references/blog-remind.md +51 -0
  153. package/skills/weaver-e10-blog/references/blog-resolve-users.md +38 -0
  154. package/skills/weaver-e10-blog/references/source-manifest.json +1540 -0
  155. package/skills/weaver-e10-caizhilian/SKILL.md +216 -0
  156. package/skills/weaver-e10-caizhilian/references/agent-entry.md +106 -0
  157. package/skills/weaver-e10-caizhilian/references/collaboration.md +112 -0
  158. package/skills/weaver-e10-caizhilian/references/document.md +111 -0
  159. package/skills/weaver-e10-caizhilian/references/file-collection.md +136 -0
  160. package/skills/weaver-e10-caizhilian/references/file-upload.md +309 -0
  161. package/skills/weaver-e10-caizhilian/references/files.md +120 -0
  162. package/skills/weaver-e10-caizhilian/references/folder.md +118 -0
  163. package/skills/weaver-e10-caizhilian/references/org-browser.md +104 -0
  164. package/skills/weaver-e10-caizhilian/references/setting-attach.md +410 -0
  165. package/skills/weaver-e10-caizhilian/references/setting-backup.md +372 -0
  166. package/skills/weaver-e10-caizhilian/references/setting-encrypt.md +399 -0
  167. package/skills/weaver-e10-caizhilian/references/setting-storage.md +603 -0
  168. package/skills/weaver-e10-caizhilian/references/source-manifest.json +5079 -0
  169. package/skills/weaver-e10-caizhilian/references/withheld.md +93 -0
  170. package/skills/weaver-e10-caizhilian/references/write-protocol.md +120 -0
  171. package/skills/weaver-e10-calendar/SKILL.md +4 -3
  172. package/skills/weaver-e10-ebuilder-form/SKILL.md +4 -9
  173. package/skills/weaver-e10-ebuilder-form/references/context-routing.md +0 -9
  174. package/skills/weaver-e10-ebuilder-form/references/custom-api.md +1 -5
  175. package/skills/weaver-e10-ebuilder-form/references/fields-browser.md +1 -5
  176. package/skills/weaver-e10-ebuilder-form/references/list-nlist.md +1 -5
  177. package/skills/weaver-e10-ebuilder-form/references/openapi-read.md +1 -5
  178. package/skills/weaver-e10-ebuilder-form/references/openapi-write.md +1 -5
  179. package/skills/weaver-e10-esb/SKILL.md +2 -2
  180. package/skills/weaver-e10-esb/references/source-manifest.json +9 -9
  181. package/skills/weaver-e10-hrm/SKILL.md +54 -6
  182. package/skills/weaver-e10-hrm/references/employee.md +89 -15
  183. package/skills/weaver-e10-hrm/references/org.md +7 -4
  184. package/skills/weaver-e10-hrm/references/position.md +14 -7
  185. package/skills/weaver-e10-hrm/references/source-manifest.json +1 -1
  186. package/skills/weaver-e10-jinchengda/SKILL.md +166 -0
  187. package/skills/weaver-e10-jinchengda/references/contract-agent-entry.md +82 -0
  188. package/skills/weaver-e10-jinchengda/references/contract-clause-recommender.md +69 -0
  189. package/skills/weaver-e10-jinchengda/references/contract-clause-reference-save.md +78 -0
  190. package/skills/weaver-e10-jinchengda/references/contract-disabled-capabilities.md +27 -0
  191. package/skills/weaver-e10-jinchengda/references/contract-request-status.md +71 -0
  192. package/skills/weaver-e10-jinchengda/references/contract-request-write.md +94 -0
  193. package/skills/weaver-e10-jinchengda/references/contract-signing-subjects.md +89 -0
  194. package/skills/weaver-e10-jinchengda/references/contract-subject-create.md +77 -0
  195. package/skills/weaver-e10-jinchengda/references/contract-template-selector.md +66 -0
  196. package/skills/weaver-e10-jinchengda/references/contract-workflow-discovery.md +94 -0
  197. package/skills/weaver-e10-jinchengda/references/source-manifest.json +259 -0
  198. package/skills/weaver-e10-jiuchuanhui/SKILL.md +5 -11
  199. package/skills/weaver-e10-jucailin/SKILL.md +4 -3
  200. package/skills/weaver-e10-mail/SKILL.md +4 -11
  201. package/skills/weaver-e10-meeting/SKILL.md +66 -32
  202. package/skills/weaver-e10-meeting/references/meeting-change.md +5 -2
  203. package/skills/weaver-e10-meeting/references/meeting-create.md +2 -1
  204. package/skills/weaver-e10-meeting/references/meeting-eb.md +114 -0
  205. package/skills/weaver-e10-meeting/references/meeting-lifecycle.md +9 -8
  206. package/skills/weaver-e10-meeting/references/meeting-receipts-signs.md +35 -7
  207. package/skills/weaver-e10-meeting/references/meeting-update.md +1 -1
  208. package/skills/weaver-e10-okr/SKILL.md +6 -11
  209. package/skills/weaver-e10-okr/references/source-manifest.json +3 -3
  210. package/skills/weaver-e10-plan/SKILL.md +3 -3
  211. package/skills/weaver-e10-plan/references/plan-collect-and-compose.md +1 -1
  212. package/skills/weaver-e10-plan/references/plan-overview-and-routing.md +1 -1
  213. package/skills/weaver-e10-plan/references/source-manifest.json +13 -13
  214. package/skills/weaver-e10-qiyecheng/SKILL.md +4 -10
  215. package/skills/weaver-e10-qiyecheng/references/source-manifest.json +9 -9
  216. package/skills/weaver-e10-shared/SKILL.md +36 -25
  217. package/skills/weaver-e10-shared/references/e10-auth-and-session.md +10 -31
  218. package/skills/weaver-e10-shared/references/json-output-contract.md +20 -11
  219. package/skills/weaver-e10-shijingran/SKILL.md +2 -1
  220. package/skills/weaver-e10-shijingran/references/source-manifest.json +9 -9
  221. package/skills/weaver-e10-skill-maker/SKILL.md +4 -10
  222. package/skills/weaver-e10-skill-maker/references/business-skill-generation.md +5 -3
  223. package/skills/weaver-e10-skill-maker/references/module-cli-generation.md +12 -27
  224. package/skills/weaver-e10-skill-maker/references/module-gap-audit-and-repair.md +17 -5
  225. package/skills/weaver-e10-skill-maker/references/source-update-detection.md +4 -27
  226. package/skills/weaver-e10-wenshuding/SKILL.md +5 -16
  227. package/skills/weaver-e10-wenshuding/references/source-manifest.json +7 -7
  228. package/skills/weaver-e10-workflow/SKILL.md +32 -37
  229. package/skills/weaver-e10-workflow/references/source-manifest.json +39 -75
  230. package/skills/weaver-e10-workflow/references/workflow-batch.md +90 -29
  231. package/skills/weaver-e10-workflow/references/workflow-create.md +79 -109
  232. package/skills/weaver-e10-workflow/references/workflow-memory.md +19 -9
  233. package/skills/weaver-e10-workflow/references/workflow-operate.md +2 -2
  234. package/skills/weaver-e10-workflow/references/workflow-query.md +38 -20
  235. package/skills/weaver-e10-workflow/references/workflow-share.md +18 -2
  236. package/skills/weaver-e10-workflow/references/workflow-view.md +3 -4
  237. package/skills/weaver-e10-yepiaotong/SKILL.md +75 -39
  238. package/skills/weaver-e10-yepiaotong/references/invoice-detail.md +22 -1
  239. package/skills/weaver-e10-yepiaotong/references/invoice-enterprise-list.md +3 -1
  240. package/skills/weaver-e10-yepiaotong/references/invoice-output-view.md +135 -0
  241. package/skills/weaver-e10-yepiaotong/references/invoice-personal-list.md +15 -3
  242. package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +1 -1
  243. package/skills/weaver-e10-yepiaotong/references/invoice-summarize.py +217 -0
  244. package/skills/weaver-e10-yepiaotong/references/invoice-upload-and-validate.md +88 -0
  245. package/skills/weaver-e10-yepiaotong/references/invoice-validation-preview.md +7 -2
  246. package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +89 -9
  247. package/skills/weaver-e10-yepiaotong/references/reim-examples.md +1 -0
  248. package/skills/weaver-e10-yepiaotong/references/reim-expense-subject-rules.md +70 -49
  249. package/skills/weaver-e10-yepiaotong/references/reim-fast-path.md +119 -0
  250. package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +55 -36
  251. package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +4 -0
  252. package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +149 -0
  253. package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +125 -5
  254. package/skills/weaver-e10-yepiaotong/references/source-manifest.json +430 -63
  255. package/skills/weaver-e10-yimiaoban/SKILL.md +4 -12
  256. package/skills/weaver-e10-yimiaoban/references/source-manifest.json +3 -3
  257. package/skills/weaver-e10-ziguanjia/SKILL.md +2 -1
  258. package/skills/weaver-e10-ziguanjia/references/ziguanjia-agent-entry.md +3 -3
  259. package/tools/weaver-skill-detector-1.0.13/SKILL.md +9 -9
  260. package/tools/weaver-skill-detector-1.0.13/references/checklist.md +3 -3
  261. package/tools/weaver-skill-detector-1.0.13/scripts/__pycache__/validate_skill.cpython-313.pyc +0 -0
  262. package/tools/weaver-skill-detector-1.0.13/scripts/validate_skill.py +98 -91
  263. package/scripts/sync-connector-skills.mjs +0 -172
@@ -1,3 +1,29 @@
1
+ import { DETAIL_ITEM_FIELDS, OUTPUT_VIEWS, SUMMARY_ITEM_FIELDS } from './projection.js';
2
+ import { OUTPUT_FORMATS } from './markdown.js';
3
+ function objectSchema(properties, required = [], additionalProperties = false) {
4
+ return {
5
+ type: 'object',
6
+ additionalProperties,
7
+ properties,
8
+ ...(required.length ? { required } : {}),
9
+ };
10
+ }
11
+ function arrayOf(items, options = {}) {
12
+ return { type: 'array', items, ...options };
13
+ }
14
+ /**
15
+ * 时间筛选字段既接受秒级 epoch(E10 `/api/inc/sync` 的原生格式),也接受 `YYYY-MM-DD`(按东八区零点换算)。
16
+ * 两种写法由 `shared.ts` 的 `epochSeconds()` 归一,因此契约必须同时声明,否则 schema 与实现不一致。
17
+ */
18
+ function epochDateProperty(label) {
19
+ return {
20
+ oneOf: [
21
+ { type: 'integer', minimum: 0 },
22
+ { type: 'string', pattern: '^\\d{4}-\\d{2}-\\d{2}$' },
23
+ ],
24
+ description: `${label}。可传 YYYY-MM-DD(按东八区零点换算)或秒级时间戳。`,
25
+ };
26
+ }
1
27
  const listProperties = {
2
28
  page_size: { type: 'integer', minimum: 1, maximum: 200 },
3
29
  start_pos: { type: 'integer', minimum: 0 },
@@ -6,10 +32,10 @@ const listProperties = {
6
32
  mext: { type: 'integer', minimum: 0 },
7
33
  content: { type: 'string' },
8
34
  types: { type: 'array', items: { type: 'integer' } },
9
- date_begin: { type: 'integer', minimum: 0 },
10
- date_end: { type: 'integer', minimum: 0 },
11
- create_tm_begin: { type: 'integer', minimum: 0 },
12
- create_tm_end: { type: 'integer', minimum: 0 },
35
+ date_begin: epochDateProperty('开票日期起(含)'),
36
+ date_end: epochDateProperty('开票日期止(含)'),
37
+ create_tm_begin: epochDateProperty('创建时间起(含)'),
38
+ create_tm_end: epochDateProperty('创建时间止(含)'),
13
39
  payer_company: { type: 'string' },
14
40
  buyer_company: { type: 'string' },
15
41
  payer_taxno: { type: 'string' },
@@ -142,6 +168,511 @@ const reimFlowUpdateProperties = {
142
168
  need_user_confirm: { type: 'array', items: reimNeedUserConfirm, description: '需用户确认的字段。' },
143
169
  unable_to_fill: { type: 'array', items: reimUnableToFill, description: '无法自动填写的字段。' },
144
170
  };
171
+ const rawValue = { description: '服务端原始字段,类型随接口返回而定。' };
172
+ const rawObject = objectSchema({}, [], true);
173
+ const rawArray = arrayOf(rawObject);
174
+ const stringOrNumber = { type: ['string', 'number'] };
175
+ const workflowSchema = objectSchema({
176
+ workflow: { type: 'string' },
177
+ version: { type: 'integer', const: 1 },
178
+ state: { type: 'string' },
179
+ }, ['workflow', 'version', 'state']);
180
+ const retSchema = objectSchema({
181
+ ret: { type: 'integer' },
182
+ message: { type: 'string' },
183
+ lang: { type: 'string' },
184
+ }, ['ret'], true);
185
+ const responseBaseSchema = objectSchema({
186
+ ret: { type: 'integer' },
187
+ message: { type: 'string' },
188
+ code: { type: 'integer' },
189
+ lang: { type: 'string' },
190
+ }, [], true);
191
+ const invoicePartySchema = objectSchema({
192
+ company: { type: 'string' },
193
+ tcode: { type: 'string' },
194
+ }, [], true);
195
+ const invoiceInfoSchema = objectSchema({
196
+ id: { type: 'string' },
197
+ fid: { type: 'string' },
198
+ code: { type: 'string' },
199
+ number: { type: 'string' },
200
+ comm_info: objectSchema({
201
+ pro: objectSchema({
202
+ type: { type: 'integer' },
203
+ cname: { type: 'string' },
204
+ date: { type: 'string', pattern: '^\\d{4}-\\d{2}-\\d{2}$' },
205
+ valid: { type: 'integer', enum: [0, 1, 2, 3, 4, 5] },
206
+ sreim: { type: 'integer', enum: [0, 1, 2, 3, 4] },
207
+ status: { type: 'integer', enum: [0, 1, 2, 3, 4, 5, 7, 8] },
208
+ }, [], true),
209
+ price: objectSchema({
210
+ amount: { type: 'string' },
211
+ total: { type: 'string' },
212
+ dtax: { type: 'string' },
213
+ reimingMoney: { type: 'string' },
214
+ reimedMoney: { type: 'string' },
215
+ }, [], true),
216
+ buyer: invoicePartySchema,
217
+ payer: invoicePartySchema,
218
+ }, [], true),
219
+ modify_info: objectSchema({
220
+ source: { type: 'integer' },
221
+ fileType: { type: 'string', enum: ['1', '2', '3', '4', '5', '6'] },
222
+ del: { type: 'integer' },
223
+ createDate: { type: 'string' },
224
+ modifyDate: { type: 'string' },
225
+ }, [], true),
226
+ flist: arrayOf(objectSchema({
227
+ id: { type: 'string' },
228
+ fileId: { type: 'string' },
229
+ name: { type: 'string' },
230
+ type: { type: 'string' },
231
+ }, [], true)),
232
+ ext: {
233
+ type: 'string',
234
+ description: 'JSON 字符串形式的票种扩展信息;解析后可包含 ttax、products 等字段。',
235
+ },
236
+ currency: { type: 'string' },
237
+ currencyName: { type: 'string' },
238
+ fylx: { type: 'string' },
239
+ }, [], true);
240
+ const invoiceResultItemSchema = objectSchema({
241
+ info: invoiceInfoSchema,
242
+ ret: retSchema,
243
+ }, ['info', 'ret'], true);
244
+ const invoiceDetailOutputSchema = objectSchema({
245
+ infos: arrayOf(invoiceResultItemSchema),
246
+ res_base: responseBaseSchema,
247
+ }, ['infos', 'res_base'], true);
248
+ const invoicePreviewSchema = objectSchema({
249
+ fid: { type: 'string' },
250
+ code: { type: 'string' },
251
+ number: { type: 'string' },
252
+ date: { type: 'string' },
253
+ total: { type: 'string' },
254
+ buyer: { type: 'string' },
255
+ payer: { type: 'string' },
256
+ valid: { type: 'integer' },
257
+ reimbursement: { type: 'integer' },
258
+ status: { type: 'integer' },
259
+ }, ['fid', 'code', 'number', 'date', 'total', 'buyer', 'payer']);
260
+ const addPreviewSchema = objectSchema({
261
+ ...invoicePreviewSchema.properties,
262
+ type: { type: 'integer' },
263
+ scope: { type: 'string', enum: ['personal', 'enterprise'] },
264
+ }, ['fid', 'number', 'type', 'scope']);
265
+ const uploadSchema = objectSchema({
266
+ id: { type: 'string' },
267
+ ids: arrayOf({ type: 'string' }),
268
+ fileType: { type: 'string', enum: ['pdf', 'ofd', 'xml', 'png', 'jpg', 'jpeg'] },
269
+ fileName: { type: 'string' },
270
+ totalPages: { type: 'integer', minimum: 1 },
271
+ hasFanWei: { type: 'boolean' },
272
+ ocrMap: { type: 'string' },
273
+ fail: { const: false },
274
+ }, ['id', 'ids', 'fileType', 'totalPages', 'hasFanWei', 'fail']);
275
+ const browseFieldItemSchema = objectSchema({
276
+ optionId: { type: 'string' },
277
+ id: { type: 'string' },
278
+ fid: { type: 'string' },
279
+ type: { type: 'integer' },
280
+ typeName: { type: 'string' },
281
+ number: { type: 'string' },
282
+ code: { type: 'string' },
283
+ content: { type: 'string' },
284
+ name: { type: 'string' },
285
+ total: { type: 'string' },
286
+ ttax: { type: 'string' },
287
+ seller: { type: 'string' },
288
+ sellerId: { type: 'string' },
289
+ buyer: { type: 'string' },
290
+ buyerId: { type: 'string' },
291
+ incDate: { type: 'string' },
292
+ incDateTimestamp: { type: 'integer' },
293
+ validStatus: { type: 'string' },
294
+ source: { type: 'string' },
295
+ invoiceStatus: { type: 'integer' },
296
+ del: { type: 'integer' },
297
+ currency: { type: 'string' },
298
+ currencyName: { type: 'string' },
299
+ taxRate: { type: 'string' },
300
+ consumeContent: { type: 'string' },
301
+ fylx: { type: 'string' },
302
+ inputDate: { type: 'string' },
303
+ incTotal: { type: 'number' },
304
+ reimingMoney: { type: 'string' },
305
+ reimedMoney: { type: 'string' },
306
+ notReimMoney: { type: 'string' },
307
+ reimDate: { type: 'string' },
308
+ reimProcess: { type: 'string' },
309
+ }, ['optionId', 'id', 'fid', 'type', 'typeName', 'number', 'content', 'name', 'total']);
310
+ const browseFieldErrorSchema = objectSchema({
311
+ fid: { type: 'string' },
312
+ ret: { type: 'integer' },
313
+ message: { type: 'string' },
314
+ }, ['ret', 'message']);
315
+ const continuationSchema = { type: 'string', minLength: 1 };
316
+ const continuationPreviewOutput = (previewSchema, extra = {}) => objectSchema({
317
+ preview: previewSchema,
318
+ continuation: continuationSchema,
319
+ expiresInSeconds: { type: 'integer', minimum: 1 },
320
+ workflow: workflowSchema,
321
+ ...extra,
322
+ }, ['preview', 'continuation', 'expiresInSeconds', 'workflow']);
323
+ const resultEnvelopeOutput = (dataSchema = rawValue) => objectSchema({
324
+ result: rawObject,
325
+ data: dataSchema,
326
+ workflow: workflowSchema,
327
+ }, ['result', 'data', 'workflow']);
328
+ const listOutputSchema = objectSchema({
329
+ items: arrayOf(invoiceInfoSchema),
330
+ total: { type: 'integer' },
331
+ totalAmount: { type: 'string' },
332
+ totalAmountExcludingTax: { type: 'string' },
333
+ hasMore: { type: 'boolean' },
334
+ scope: { type: 'string', enum: ['personal', 'enterprise'] },
335
+ }, ['items', 'total', 'totalAmount', 'totalAmountExcludingTax', 'hasMore', 'scope']);
336
+ /**
337
+ * 列表类 operation 支持 `--view summary`:把 40+ 字段的原始发票裁成语义平表,
338
+ * 调用方一次调用就能读到清单,不必再写脚本解析完整 envelope。
339
+ */
340
+ const summaryOutputView = {
341
+ name: 'summary',
342
+ description: '语义化平表,省略空值字段;列表级汇总在前、items 在后,并附 itemCount。用 CLI 的 --view summary 启用。',
343
+ itemFields: SUMMARY_ITEM_FIELDS,
344
+ };
345
+ const detailOutputView = {
346
+ name: 'detail',
347
+ description: '单张发票的语义详情:summary 字段,外加 attachments(附件清单)、expenseNote(费用说明)、issuer(开票人)、checkState(查验标记,0=未查验,与票面 valid 不是一个口径)。用 CLI 的 --view detail 启用。',
348
+ itemFields: DETAIL_ITEM_FIELDS,
349
+ };
350
+ const uploadOutputSchema = objectSchema({
351
+ upload: uploadSchema,
352
+ workflow: workflowSchema,
353
+ }, ['upload', 'workflow']);
354
+ const ocrPreviewOutputSchema = objectSchema({
355
+ saved: { const: false },
356
+ verified: { const: false },
357
+ upload: uploadSchema,
358
+ invoices: arrayOf(invoiceResultItemSchema),
359
+ results: rawArray,
360
+ workflow: workflowSchema,
361
+ }, ['saved', 'verified', 'upload', 'invoices', 'results', 'workflow']);
362
+ const validationPreviewOutputSchema = objectSchema({
363
+ preview: objectSchema({
364
+ ...invoicePreviewSchema.properties,
365
+ targetFid: { type: 'string' },
366
+ resultFid: { type: 'string' },
367
+ scope: { type: 'string', enum: ['personal', 'enterprise'] },
368
+ validation: { type: 'integer' },
369
+ invoiceStatus: { type: 'integer' },
370
+ saved: { const: false },
371
+ }, ['fid', 'targetFid', 'resultFid', 'scope', 'saved']),
372
+ info: invoiceInfoSchema,
373
+ saved: { const: false },
374
+ result: rawObject,
375
+ workflow: workflowSchema,
376
+ }, ['preview', 'info', 'saved', 'result', 'workflow']);
377
+ const validationItemSchema = objectSchema({
378
+ ...invoicePreviewSchema.properties,
379
+ targetFid: { type: 'string' },
380
+ resultFid: { type: 'string' },
381
+ scope: { type: 'string', enum: ['personal', 'enterprise'] },
382
+ validation: { type: 'integer' },
383
+ invoiceStatus: { type: 'integer' },
384
+ saved: { const: false },
385
+ }, ['fid', 'scope', 'saved']);
386
+ const uploadAndValidateOutputSchema = objectSchema({
387
+ upload: uploadSchema,
388
+ ocrCount: { type: 'integer', minimum: 0 },
389
+ invoices: arrayOf(invoiceResultItemSchema),
390
+ validations: arrayOf(validationItemSchema),
391
+ validationErrors: arrayOf(objectSchema({ fid: { type: ['string', 'null'] }, error: { type: 'string' } }, ['error'])),
392
+ results: rawArray,
393
+ workflow: workflowSchema,
394
+ }, ['upload', 'ocrCount', 'invoices', 'validations', 'validationErrors', 'results', 'workflow']);
395
+ const importPreviewSchema = objectSchema({
396
+ source: { type: 'string', enum: ['file', 'url'] },
397
+ name: { type: 'string' },
398
+ size: { type: 'integer', minimum: 0 },
399
+ sha256: { type: 'string' },
400
+ url: { type: 'string' },
401
+ validate: { type: 'boolean' },
402
+ validationSkipped: { type: 'boolean' },
403
+ syncToOa: { type: 'boolean' },
404
+ fieldKey: { type: 'string' },
405
+ filedMap: rawObject,
406
+ targetScope: { type: 'string', enum: ['personal'] },
407
+ }, ['source', 'validate', 'validationSkipped', 'syncToOa', 'targetScope']);
408
+ const importCompleteOutputSchema = objectSchema({
409
+ imported: arrayOf(objectSchema({
410
+ fid: { type: 'string' },
411
+ preview: invoicePreviewSchema,
412
+ }, ['fid', 'preview'])),
413
+ validationRequested: { type: 'boolean' },
414
+ validationSkipped: { type: 'boolean' },
415
+ syncToOa: { type: 'boolean' },
416
+ verified: { const: true },
417
+ result: rawObject,
418
+ workflow: workflowSchema,
419
+ }, ['imported', 'validationRequested', 'validationSkipped', 'syncToOa', 'verified', 'result', 'workflow']);
420
+ const addPrepareOutputSchema = continuationPreviewOutput(addPreviewSchema, { normalizedInfo: invoiceInfoSchema });
421
+ const addApplyOutputSchema = objectSchema({
422
+ fid: { type: 'string' },
423
+ scope: { type: 'string', enum: ['personal', 'enterprise'] },
424
+ saved: { const: true },
425
+ verified: { const: true },
426
+ info: invoiceInfoSchema,
427
+ result: rawObject,
428
+ workflow: workflowSchema,
429
+ }, ['fid', 'scope', 'saved', 'verified', 'info', 'result', 'workflow']);
430
+ const changePreviewSchema = objectSchema({
431
+ field: { type: 'string' },
432
+ from: rawValue,
433
+ to: rawValue,
434
+ }, ['field', 'to']);
435
+ const updatePrepareOutputSchema = objectSchema({
436
+ invoice: invoicePreviewSchema,
437
+ changes: arrayOf(changePreviewSchema),
438
+ continuation: continuationSchema,
439
+ expiresInSeconds: { type: 'integer', minimum: 1 },
440
+ workflow: workflowSchema,
441
+ }, ['invoice', 'changes', 'continuation', 'expiresInSeconds', 'workflow']);
442
+ const updateApplyOutputSchema = objectSchema({
443
+ fid: { type: 'string' },
444
+ scope: { type: 'string', enum: ['personal', 'enterprise'] },
445
+ updated: { const: true },
446
+ verified: { const: true },
447
+ changes: arrayOf(changePreviewSchema),
448
+ info: invoiceInfoSchema,
449
+ result: rawObject,
450
+ workflow: workflowSchema,
451
+ }, ['fid', 'scope', 'updated', 'verified', 'changes', 'info', 'result', 'workflow']);
452
+ const deleteApplyOutputSchema = objectSchema({
453
+ deleted: arrayOf({ type: 'string' }),
454
+ verified: { const: true },
455
+ result: rawObject,
456
+ workflow: workflowSchema,
457
+ }, ['deleted', 'verified', 'result', 'workflow']);
458
+ const downloadOutputSchema = objectSchema({
459
+ fid: { type: 'string' },
460
+ fileId: { type: 'string' },
461
+ output: { type: 'string' },
462
+ size: { type: 'integer', minimum: 0 },
463
+ contentType: { type: 'string' },
464
+ }, ['fid', 'fileId', 'output', 'size', 'contentType']);
465
+ const reimFileOcrItemSchema = objectSchema({
466
+ status: { type: 'string' },
467
+ invoiceId: { type: 'string' },
468
+ fid: { type: 'string' },
469
+ info: invoiceInfoSchema,
470
+ errorMsg: { type: 'string' },
471
+ }, [], true);
472
+ const reimFileOcrOutputSchema = objectSchema({
473
+ items: arrayOf(reimFileOcrItemSchema),
474
+ failed: arrayOf(reimFileOcrItemSchema),
475
+ result: rawObject,
476
+ workflow: workflowSchema,
477
+ }, ['items', 'failed', 'result', 'workflow']);
478
+ const requestListDataSchema = arrayOf(objectSchema({
479
+ requestid: { type: 'string' },
480
+ workflowid: { type: 'string' },
481
+ requestname: { type: 'string' },
482
+ requestnametitle: { type: 'string' },
483
+ flowStatus: { type: 'integer' },
484
+ creatorId: { type: 'string' },
485
+ creatorName: { type: 'string' },
486
+ creatorDepartmentId: { type: 'string' },
487
+ nodeid: { type: 'string' },
488
+ createTime: { type: 'string' },
489
+ }, ['requestid', 'workflowid', 'requestname'], true));
490
+ const workflowResolveDataSchema = objectSchema({
491
+ requestWorkflowMap: objectSchema({}, [], objectSchema({
492
+ workFlowId: { type: 'string' },
493
+ workFlowName: { type: 'string' },
494
+ }, ['workFlowId', 'workFlowName'])),
495
+ candidateWorkflows: arrayOf(objectSchema({
496
+ workFlowId: { type: 'string' },
497
+ workFlowName: { type: 'string' },
498
+ }, ['workFlowId', 'workFlowName'])),
499
+ }, [], true);
500
+ const reimFieldOptionSchema = objectSchema({
501
+ optionId: { type: 'string' },
502
+ optionName: { type: 'string' },
503
+ optionValue: { type: 'string' },
504
+ }, [], true);
505
+ const reimFormFieldSchema = objectSchema({
506
+ fieldId: { type: 'string' },
507
+ fieldName: { type: 'string' },
508
+ fieldType: { type: 'string' },
509
+ single: { type: 'boolean' },
510
+ marked: { type: 'boolean' },
511
+ options: arrayOf(reimFieldOptionSchema),
512
+ }, ['fieldId', 'fieldName', 'fieldType'], true);
513
+ const formStructureDataSchema = objectSchema({
514
+ mainFormId: { type: 'string' },
515
+ mainFields: arrayOf(reimFormFieldSchema),
516
+ subTables: arrayOf(objectSchema({
517
+ subFormId: { type: 'string' },
518
+ subFormName: { type: 'string' },
519
+ subFields: arrayOf(reimFormFieldSchema),
520
+ }, ['subFormId', 'subFields'], true)),
521
+ }, ['mainFormId', 'mainFields', 'subTables'], true);
522
+ const rowInfoDataSchema = objectSchema({
523
+ date: { type: 'string' },
524
+ fysm: { type: 'string' },
525
+ itinerary: { type: 'string' },
526
+ subjectId: { type: 'string' },
527
+ }, [], true);
528
+ const employeeSchema = objectSchema({
529
+ id: { type: 'string' },
530
+ name: { type: 'string' },
531
+ }, ['id', 'name'], true);
532
+ const employeeSuperiorsDataSchema = objectSchema({
533
+ currentEmployee: employeeSchema,
534
+ allSuperiors: arrayOf(employeeSchema),
535
+ }, ['currentEmployee', 'allSuperiors'], true);
536
+ const fieldSearchDataSchema = arrayOf(objectSchema({
537
+ id: { type: 'string' },
538
+ name: { type: 'string' },
539
+ value: { type: 'string' },
540
+ }, ['id', 'name'], true));
541
+ const flowPreviewOutputSchema = objectSchema({
542
+ requestName: { type: 'string' },
543
+ workflowId: { type: 'string' },
544
+ mainFormId: { type: 'string' },
545
+ mainFieldCount: { type: 'integer' },
546
+ detailRowCount: { type: 'integer' },
547
+ }, ['requestName', 'workflowId', 'mainFormId', 'mainFieldCount', 'detailRowCount']);
548
+ const flowUpdatePreviewOutputSchema = objectSchema({
549
+ requestId: { type: 'string' },
550
+ mainFormId: { type: 'string' },
551
+ mainFieldCount: { type: 'integer' },
552
+ detailRowCount: { type: 'integer' },
553
+ deleteDetailRowCount: { type: 'integer' },
554
+ }, ['requestId', 'mainFormId', 'mainFieldCount', 'detailRowCount', 'deleteDetailRowCount']);
555
+ const flowCreateApplyOutputSchema = objectSchema({
556
+ requestId: { type: 'string' },
557
+ requestName: { type: 'string' },
558
+ viewUrl: { type: 'string', format: 'uri' },
559
+ result: rawObject,
560
+ workflow: workflowSchema,
561
+ }, ['requestId', 'requestName', 'viewUrl', 'result', 'workflow']);
562
+ const flowUpdateApplyOutputSchema = objectSchema({
563
+ requestId: { type: 'string' },
564
+ result: rawObject,
565
+ workflow: workflowSchema,
566
+ }, ['requestId', 'result', 'workflow']);
567
+ const reimCandidateItemSchema = objectSchema({
568
+ fid: { type: 'string' },
569
+ number: { type: 'string' },
570
+ date: { type: 'string' },
571
+ total: { type: 'string' },
572
+ buyer: { type: 'string' },
573
+ payer: { type: 'string' },
574
+ typeName: { type: 'string' },
575
+ status: { type: 'integer' },
576
+ valid: { type: 'integer' },
577
+ reimRequests: arrayOf({ type: 'string' }),
578
+ }, ['fid', 'number', 'total'], true);
579
+ const reimCandidatesOutputSchema = objectSchema({
580
+ total: { type: 'integer' },
581
+ fetched: { type: 'integer' },
582
+ hasMore: { type: 'boolean' },
583
+ available: arrayOf(reimCandidateItemSchema),
584
+ assigned: arrayOf(reimCandidateItemSchema),
585
+ redReversed: arrayOf(reimCandidateItemSchema),
586
+ summary: objectSchema({
587
+ availableCount: { type: 'integer' },
588
+ assignedCount: { type: 'integer' },
589
+ redReversedCount: { type: 'integer' },
590
+ availableAmount: { type: 'string' },
591
+ assignedAmount: { type: 'string' },
592
+ redReversedAmount: { type: 'string' },
593
+ filteredRedReversedCount: { type: 'integer' },
594
+ }, ['availableCount', 'assignedCount', 'redReversedCount', 'availableAmount', 'assignedAmount', 'redReversedAmount', 'filteredRedReversedCount']),
595
+ warnings: arrayOf({ type: 'string' }),
596
+ workflow: workflowSchema,
597
+ }, ['total', 'fetched', 'hasMore', 'available', 'assigned', 'redReversed', 'summary', 'warnings', 'workflow']);
598
+ const reimTemplateInputProperties = {
599
+ invoiceIds: { type: 'array', minItems: 1, maxItems: 100, items: positiveId, description: '用于报销的发票 fid 列表,将作为明细行顺序。' },
600
+ requestName: { type: 'string', minLength: 1, maxLength: 100, description: '报销单标题。' },
601
+ workflowId: { ...positiveId, description: `目标报销流程工作流 ID。不传时自动解析唯一候选;当前模板固化映射对应的流程为 ${'100003460000000060'}(总部费用报销)。` },
602
+ reason: { type: 'string', maxLength: 500, description: '报销事由,缺省使用 requestName。' },
603
+ relatedCustomerId: { ...positiveId, description: '相关客户 ID(非出差场景)。缺省留空并产生 warning。' },
604
+ relatedCustomerName: { type: 'string', minLength: 1, maxLength: 200, description: '相关客户名称。只传名称时会反查 ID;与 relatedCustomerId 同时传时只用于渲染预览中文名,不额外请求。' },
605
+ contractNo: { type: 'string', minLength: 1, maxLength: 100, description: '合同号。未传入时默认使用 "20260999",不再留空。' },
606
+ };
607
+ const reimPreviewLabeledFieldSchema = objectSchema({
608
+ fieldId: { type: 'string' },
609
+ fieldName: { type: 'string' },
610
+ value: { type: 'string' },
611
+ optionValue: { type: 'string' },
612
+ text: { type: 'string', description: '已渲染的「中文(id)」文本,可直接展示。' },
613
+ });
614
+ const reimPreviewLabeledRowSchema = objectSchema({
615
+ dataIndex: { type: 'integer' },
616
+ invoiceId: { type: 'string' },
617
+ invoiceNumber: { type: 'string' },
618
+ amount: { type: 'string' },
619
+ expenseNote: { type: 'string' },
620
+ subject: { type: 'string', description: '费用科目,已渲染成「中文(id)」。' },
621
+ currency: { type: 'string', description: '币种,已渲染成「中文(id)」。' },
622
+ });
623
+ const reimTemplatePreviewSchema = objectSchema({
624
+ ...flowPreviewOutputSchema.properties,
625
+ totalAmount: { type: 'string' },
626
+ invoiceCount: { type: 'integer' },
627
+ mainFields: arrayOf(reimPreviewLabeledFieldSchema, { description: '主表字段的可读渲染,字典类 ID 已带中文名。' }),
628
+ detailRows: arrayOf(reimPreviewLabeledRowSchema, { description: '明细行的可读渲染,科目/币种已带中文名。' }),
629
+ unresolvedLabels: arrayOf({ type: 'string' }, { description: '未能取到中文名的 ID 清单。' }),
630
+ }, ['requestName', 'workflowId', 'mainFormId', 'mainFieldCount', 'detailRowCount', 'totalAmount', 'invoiceCount', 'mainFields', 'detailRows', 'unresolvedLabels']);
631
+ const reimTemplatePayloadSchema = objectSchema(reimFlowCreateProperties, [...reimFlowCreateRequired]);
632
+ const reimLabelsSchema = objectSchema({
633
+ workflow: objectSchema({ id: { type: 'string' }, name: { type: 'string' } }),
634
+ mainFormId: { type: 'string' },
635
+ detailSubForm: objectSchema({ id: { type: 'string' }, name: { type: 'string' } }),
636
+ employees: { type: 'object', additionalProperties: { type: 'string' } },
637
+ subjects: { type: 'object', additionalProperties: { type: 'string' } },
638
+ currencies: { type: 'object', additionalProperties: { type: 'string' } },
639
+ customers: { type: 'object', additionalProperties: { type: 'string' } },
640
+ selectOptions: { type: 'object', additionalProperties: { type: 'object', additionalProperties: { type: 'string' } } },
641
+ customer: { type: ['object', 'null'], additionalProperties: true },
642
+ unresolved: arrayOf({ type: 'string' }),
643
+ }, ['workflow', 'employees', 'subjects', 'currencies', 'customers', 'selectOptions', 'unresolved']);
644
+ const reimTemplateBuildOutputSchema = objectSchema({
645
+ payload: reimTemplatePayloadSchema,
646
+ preview: reimTemplatePreviewSchema,
647
+ labels: reimLabelsSchema,
648
+ warnings: arrayOf({ type: 'string' }),
649
+ workflow: workflowSchema,
650
+ }, ['payload', 'preview', 'labels', 'warnings', 'workflow']);
651
+ const reimAutoPrepareOutputSchema = continuationPreviewOutput(reimTemplatePreviewSchema, {
652
+ payload: reimTemplatePayloadSchema,
653
+ labels: reimLabelsSchema,
654
+ warnings: arrayOf({ type: 'string' }),
655
+ });
656
+ const makeInvoicePreviewSchema = objectSchema({
657
+ mode: { type: 'string', enum: ['issue', 'ledger'] },
658
+ purchaserName: { type: 'string' },
659
+ purchaserTaxNo: { type: 'string' },
660
+ invoiceType: { type: 'string', enum: ['7', '8', '9', '10'] },
661
+ externalDocumentNo: { type: 'string' },
662
+ totalAmount: stringOrNumber,
663
+ taxAmount: stringOrNumber,
664
+ totalAmountWithTax: stringOrNumber,
665
+ detailCount: { type: 'integer' },
666
+ }, ['mode', 'purchaserName', 'invoiceType', 'externalDocumentNo', 'totalAmount', 'taxAmount', 'totalAmountWithTax', 'detailCount']);
667
+ const issuingPrepareOutputSchema = continuationPreviewOutput(makeInvoicePreviewSchema, { normalizedPayload: requestPayload });
668
+ const issuingApplyOutputSchema = objectSchema({
669
+ mode: { type: 'string', enum: ['issue', 'ledger'] },
670
+ serialNo: { type: 'string' },
671
+ orderNo: { type: 'string' },
672
+ ledgerOnly: { type: 'boolean' },
673
+ result: rawObject,
674
+ workflow: workflowSchema,
675
+ }, ['mode', 'ledgerOnly', 'result', 'workflow']);
145
676
  export const invoiceOperations = [
146
677
  {
147
678
  name: 'invoice.list',
@@ -149,6 +680,8 @@ export const invoiceOperations = [
149
680
  scope: 'personal',
150
681
  fixed: { flag: 0, defaultSreim: '3', defaultBillType: 0 },
151
682
  inputSchema: { type: 'object', additionalProperties: false, properties: listProperties },
683
+ outputSchema: listOutputSchema,
684
+ outputViews: [summaryOutputView],
152
685
  },
153
686
  {
154
687
  name: 'invoice.enterprise.list',
@@ -156,6 +689,8 @@ export const invoiceOperations = [
156
689
  scope: 'enterprise',
157
690
  fixed: { flag: 6, defaultSreim: '3', defaultBillType: 0 },
158
691
  inputSchema: { type: 'object', additionalProperties: false, properties: listProperties },
692
+ outputSchema: listOutputSchema,
693
+ outputViews: [summaryOutputView],
159
694
  },
160
695
  {
161
696
  name: 'invoice.get',
@@ -169,6 +704,8 @@ export const invoiceOperations = [
169
704
  },
170
705
  oneOf: [{ required: ['fid'] }, { required: ['number'] }],
171
706
  },
707
+ outputSchema: invoiceDetailOutputSchema,
708
+ outputViews: [detailOutputView],
172
709
  },
173
710
  {
174
711
  name: 'invoice.upload',
@@ -183,6 +720,7 @@ export const invoiceOperations = [
183
720
  },
184
721
  oneOf: [{ required: ['file'] }, { required: ['url'] }],
185
722
  },
723
+ outputSchema: uploadOutputSchema,
186
724
  },
187
725
  {
188
726
  name: 'invoice.ocr.preview',
@@ -199,6 +737,7 @@ export const invoiceOperations = [
199
737
  },
200
738
  oneOf: [{ required: ['file'] }, { required: ['url'] }, { required: ['upload'] }],
201
739
  },
740
+ outputSchema: ocrPreviewOutputSchema,
202
741
  },
203
742
  {
204
743
  name: 'invoice.validate.preview',
@@ -213,6 +752,24 @@ export const invoiceOperations = [
213
752
  },
214
753
  required: ['fid', 'scope'],
215
754
  },
755
+ outputSchema: validationPreviewOutputSchema,
756
+ },
757
+ {
758
+ name: 'invoice.upload-and-validate',
759
+ risk: 'read-with-upload',
760
+ fixed: { ocr: 1, flag: 100, is_save: 1, needLog: true },
761
+ inputSchema: {
762
+ type: 'object',
763
+ additionalProperties: false,
764
+ properties: {
765
+ file: { type: 'string', minLength: 1 },
766
+ url: { type: 'string', format: 'uri' },
767
+ scope: { type: 'string', enum: ['personal', 'enterprise'] },
768
+ },
769
+ required: ['scope'],
770
+ oneOf: [{ required: ['file'] }, { required: ['url'] }],
771
+ },
772
+ outputSchema: uploadAndValidateOutputSchema,
216
773
  },
217
774
  {
218
775
  name: 'invoice.import.prepare',
@@ -238,6 +795,7 @@ export const invoiceOperations = [
238
795
  required: ['validate', 'syncToOa'],
239
796
  oneOf: [{ required: ['file'] }, { required: ['url'] }],
240
797
  },
798
+ outputSchema: continuationPreviewOutput(importPreviewSchema),
241
799
  },
242
800
  {
243
801
  name: 'invoice.import.apply',
@@ -259,6 +817,7 @@ export const invoiceOperations = [
259
817
  required: ['continuation', 'confirm'],
260
818
  oneOf: [{ required: ['file'] }, { required: ['url'] }],
261
819
  },
820
+ outputSchema: importCompleteOutputSchema,
262
821
  },
263
822
  {
264
823
  name: 'invoice.add.prepare',
@@ -272,6 +831,7 @@ export const invoiceOperations = [
272
831
  },
273
832
  required: ['info', 'scope'],
274
833
  },
834
+ outputSchema: addPrepareOutputSchema,
275
835
  },
276
836
  {
277
837
  name: 'invoice.add.apply',
@@ -286,6 +846,7 @@ export const invoiceOperations = [
286
846
  },
287
847
  required: ['info', 'continuation', 'confirm'],
288
848
  },
849
+ outputSchema: addApplyOutputSchema,
289
850
  },
290
851
  {
291
852
  name: 'invoice.update.prepare',
@@ -319,6 +880,7 @@ export const invoiceOperations = [
319
880
  },
320
881
  required: ['fid', 'scope', 'changes'],
321
882
  },
883
+ outputSchema: updatePrepareOutputSchema,
322
884
  },
323
885
  {
324
886
  name: 'invoice.update.apply',
@@ -332,6 +894,7 @@ export const invoiceOperations = [
332
894
  },
333
895
  required: ['continuation', 'confirm'],
334
896
  },
897
+ outputSchema: updateApplyOutputSchema,
335
898
  },
336
899
  {
337
900
  name: 'invoice.download',
@@ -346,6 +909,7 @@ export const invoiceOperations = [
346
909
  },
347
910
  required: ['fid', 'fileId', 'output'],
348
911
  },
912
+ outputSchema: downloadOutputSchema,
349
913
  },
350
914
  {
351
915
  name: 'invoice.delete.prepare',
@@ -359,6 +923,7 @@ export const invoiceOperations = [
359
923
  },
360
924
  required: ['fid'],
361
925
  },
926
+ outputSchema: continuationPreviewOutput(invoicePreviewSchema),
362
927
  },
363
928
  {
364
929
  name: 'invoice.delete.apply',
@@ -372,6 +937,7 @@ export const invoiceOperations = [
372
937
  },
373
938
  required: ['continuation', 'confirm'],
374
939
  },
940
+ outputSchema: deleteApplyOutputSchema,
375
941
  },
376
942
  {
377
943
  name: 'invoice.browse-field.data',
@@ -387,6 +953,11 @@ export const invoiceOperations = [
387
953
  },
388
954
  oneOf: [{ required: ['fid'] }, { required: ['fids'] }, { required: ['detail'] }],
389
955
  },
956
+ outputSchema: objectSchema({
957
+ items: arrayOf(browseFieldItemSchema),
958
+ errors: arrayOf(browseFieldErrorSchema),
959
+ workflow: workflowSchema,
960
+ }, ['items', 'errors', 'workflow']),
390
961
  },
391
962
  {
392
963
  name: 'invoice.reim.file-ocr.preview',
@@ -401,6 +972,7 @@ export const invoiceOperations = [
401
972
  },
402
973
  oneOf: [{ required: ['fileId'] }, { required: ['fileIds'] }],
403
974
  },
975
+ outputSchema: reimFileOcrOutputSchema,
404
976
  },
405
977
  {
406
978
  name: 'invoice.reim.requests.list',
@@ -417,6 +989,7 @@ export const invoiceOperations = [
417
989
  cusCreateDateEnd: { type: 'string', pattern: '^\\d{4}-\\d{2}-\\d{2}$' },
418
990
  },
419
991
  },
992
+ outputSchema: resultEnvelopeOutput(requestListDataSchema),
420
993
  },
421
994
  {
422
995
  name: 'invoice.reim.workflow.resolve',
@@ -429,6 +1002,7 @@ export const invoiceOperations = [
429
1002
  requestIds: { type: 'array', maxItems: 100, items: positiveId, default: [] },
430
1003
  },
431
1004
  },
1005
+ outputSchema: resultEnvelopeOutput(workflowResolveDataSchema),
432
1006
  },
433
1007
  {
434
1008
  name: 'invoice.reim.form.structure',
@@ -443,6 +1017,7 @@ export const invoiceOperations = [
443
1017
  },
444
1018
  required: ['workflowId'],
445
1019
  },
1020
+ outputSchema: resultEnvelopeOutput(formStructureDataSchema),
446
1021
  },
447
1022
  {
448
1023
  name: 'invoice.reim.row-info',
@@ -458,6 +1033,34 @@ export const invoiceOperations = [
458
1033
  },
459
1034
  required: ['invoiceId'],
460
1035
  },
1036
+ outputSchema: resultEnvelopeOutput(rowInfoDataSchema),
1037
+ },
1038
+ {
1039
+ name: 'invoice.reim.row-info-batch',
1040
+ risk: 'read',
1041
+ fixed: { path: '/api/secondev/fna/expense/dataInfo/getRowInfo', sf_request_type: 'fetch', concurrency: 4 },
1042
+ inputSchema: {
1043
+ type: 'object',
1044
+ additionalProperties: false,
1045
+ properties: {
1046
+ invoiceIds: positiveIdArray,
1047
+ requestid: { type: 'string' },
1048
+ cdzt: positiveId,
1049
+ },
1050
+ required: ['invoiceIds'],
1051
+ },
1052
+ outputSchema: objectSchema({
1053
+ results: arrayOf(objectSchema({
1054
+ invoiceId: { type: 'string' },
1055
+ status: { type: 'string', enum: ['success', 'fail'] },
1056
+ data: rowInfoDataSchema,
1057
+ error: { type: 'string' },
1058
+ }, ['invoiceId', 'status'])),
1059
+ succeeded: { type: 'integer' },
1060
+ failed: { type: 'integer' },
1061
+ total: { type: 'integer' },
1062
+ workflow: workflowSchema,
1063
+ }, ['results', 'succeeded', 'failed', 'total', 'workflow']),
461
1064
  },
462
1065
  {
463
1066
  name: 'invoice.reim.employee-superiors',
@@ -468,6 +1071,7 @@ export const invoiceOperations = [
468
1071
  additionalProperties: false,
469
1072
  properties: {},
470
1073
  },
1074
+ outputSchema: resultEnvelopeOutput(employeeSuperiorsDataSchema),
471
1075
  },
472
1076
  {
473
1077
  name: 'invoice.reim.field.search',
@@ -484,6 +1088,7 @@ export const invoiceOperations = [
484
1088
  },
485
1089
  required: ['keywords', 'fieldId', 'workflowId'],
486
1090
  },
1091
+ outputSchema: resultEnvelopeOutput(fieldSearchDataSchema),
487
1092
  },
488
1093
  {
489
1094
  name: 'invoice.reim.flow.create.prepare',
@@ -495,6 +1100,7 @@ export const invoiceOperations = [
495
1100
  properties: reimFlowCreateProperties,
496
1101
  required: reimFlowCreateRequired,
497
1102
  },
1103
+ outputSchema: continuationPreviewOutput(flowPreviewOutputSchema),
498
1104
  },
499
1105
  {
500
1106
  name: 'invoice.reim.flow.create.apply',
@@ -509,6 +1115,7 @@ export const invoiceOperations = [
509
1115
  },
510
1116
  required: [...reimFlowCreateRequired, 'continuation', 'confirm'],
511
1117
  },
1118
+ outputSchema: flowCreateApplyOutputSchema,
512
1119
  },
513
1120
  {
514
1121
  name: 'invoice.reim.flow.update.prepare',
@@ -521,6 +1128,7 @@ export const invoiceOperations = [
521
1128
  required: ['requestId', 'mainFormId'],
522
1129
  anyOf: [{ required: ['main_fields'] }, { required: ['detail_rows'] }, { required: ['deleteDetailRows'] }],
523
1130
  },
1131
+ outputSchema: continuationPreviewOutput(flowUpdatePreviewOutputSchema),
524
1132
  },
525
1133
  {
526
1134
  name: 'invoice.reim.flow.update.apply',
@@ -536,6 +1144,46 @@ export const invoiceOperations = [
536
1144
  required: ['requestId', 'mainFormId', 'continuation', 'confirm'],
537
1145
  anyOf: [{ required: ['main_fields'] }, { required: ['detail_rows'] }, { required: ['deleteDetailRows'] }],
538
1146
  },
1147
+ outputSchema: flowUpdateApplyOutputSchema,
1148
+ },
1149
+ {
1150
+ name: 'invoice.reim.candidates.list',
1151
+ risk: 'read',
1152
+ fixed: { path: '/api/inc/sync', sreim: '3', billType: 0 },
1153
+ inputSchema: {
1154
+ type: 'object',
1155
+ additionalProperties: false,
1156
+ properties: {
1157
+ date_begin: { type: 'string', pattern: '^\\d{4}-\\d{2}-\\d{2}$', description: '开票日期起(YYYY-MM-DD,含)。' },
1158
+ date_end: { type: 'string', pattern: '^\\d{4}-\\d{2}-\\d{2}$', description: '开票日期止(YYYY-MM-DD,含)。' },
1159
+ page_size: { type: 'integer', minimum: 10, maximum: 200, default: 50, description: '单页条数。' },
1160
+ max_items: { type: 'integer', minimum: 1, maximum: 500, default: 200, description: '最多拉取条数(不含被过滤的红冲票),超出截断并产生 warning。' },
1161
+ include_red_reversed: { type: 'boolean', default: false, description: '是否在结果中保留全额红冲(status=8)发票。默认 false —— 报销场景直接过滤掉,过滤张数由 summary.filteredRedReversedCount 告知,不会静默丢失。' },
1162
+ },
1163
+ },
1164
+ outputSchema: reimCandidatesOutputSchema,
1165
+ },
1166
+ {
1167
+ name: 'invoice.reim.template.build',
1168
+ risk: 'read',
1169
+ inputSchema: {
1170
+ type: 'object',
1171
+ additionalProperties: false,
1172
+ properties: reimTemplateInputProperties,
1173
+ required: ['invoiceIds', 'requestName'],
1174
+ },
1175
+ outputSchema: reimTemplateBuildOutputSchema,
1176
+ },
1177
+ {
1178
+ name: 'invoice.reim.flow.create.auto-prepare',
1179
+ risk: 'read-before-write',
1180
+ inputSchema: {
1181
+ type: 'object',
1182
+ additionalProperties: false,
1183
+ properties: reimTemplateInputProperties,
1184
+ required: ['invoiceIds', 'requestName'],
1185
+ },
1186
+ outputSchema: reimAutoPrepareOutputSchema,
539
1187
  },
540
1188
  {
541
1189
  name: 'invoice.issuing.make.prepare',
@@ -554,6 +1202,7 @@ export const invoiceOperations = [
554
1202
  },
555
1203
  required: ['mode', 'payload'],
556
1204
  },
1205
+ outputSchema: issuingPrepareOutputSchema,
557
1206
  },
558
1207
  {
559
1208
  name: 'invoice.issuing.make.apply',
@@ -568,6 +1217,7 @@ export const invoiceOperations = [
568
1217
  },
569
1218
  required: ['payload', 'continuation', 'confirm'],
570
1219
  },
1220
+ outputSchema: issuingApplyOutputSchema,
571
1221
  },
572
1222
  ];
573
1223
  export const invoiceManifest = {
@@ -578,6 +1228,26 @@ export const invoiceManifest = {
578
1228
  host: 'e10-invoice',
579
1229
  status: 'builtin',
580
1230
  sourceSkill: 'weaver-e10-yepiaotong',
1231
+ /**
1232
+ * CLI 侧的输出投影参数。它们不属于任何 operation 的 inputSchema(不参与请求体),
1233
+ * 而是裁剪返回的 envelope.data,用于替代"调用方自己写脚本解析完整 JSON"。
1234
+ */
1235
+ projectionOptions: {
1236
+ '--view': {
1237
+ values: OUTPUT_VIEWS,
1238
+ default: 'full',
1239
+ description: `输出视图。full=完整包络;summary=${SUMMARY_ITEM_FIELDS.length} 个语义字段的平表,仅 invoice.list / invoice.enterprise.list 支持;detail=${DETAIL_ITEM_FIELDS.length} 个字段的单张发票详情(含附件、费用说明、查验标记),仅 invoice.get 支持。`,
1240
+ },
1241
+ '--format': {
1242
+ values: OUTPUT_FORMATS,
1243
+ default: 'json',
1244
+ description: '输出格式。json=标准 envelope(默认,供程序消费);markdown=人读渲染(票夹列表/发票详情两类模板,内置列顺序与单位),仅 invoice.list / invoice.enterprise.list / invoice.get 支持,且与 --json、--fields 互斥。markdown 档自带字段口径(list→summary、get→detail),不必再传 --view。',
1245
+ },
1246
+ '--fields': {
1247
+ description: '逗号分隔的点路径列表,按原结构投影,例如 --fields number,detailUrl。所有 operation 可用;未命中的路径会出现在 meta.projection.missingFields 里。⚠️ 不要用裸 total 取金额:发票顶层 total 是 E10 的独立字段(实测恒为 0),价税合计在 comm_info.price.total,不含税金额在 comm_info.price.amount。',
1248
+ },
1249
+ note: '--view 与 --fields 互斥;--format markdown 与 --json/--fields 互斥。投影只影响输出,不改变任何请求参数;meta.projection 会说明本次裁剪结果。',
1250
+ },
581
1251
  operations: invoiceOperations,
582
1252
  withheldOperations: [
583
1253
  {