weaver-work-cli 0.1.1 → 0.1.4

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 (351) hide show
  1. package/README.md +187 -76
  2. package/dist/cmd/setup/index.js +5 -5
  3. package/dist/cmd/skills/index.js +1 -1
  4. package/dist/core/hooks.js +7 -0
  5. package/dist/index.js +0 -0
  6. package/dist/internal/e10/auth/commands.js +160 -55
  7. package/dist/internal/e10/auth/crypto.js +7 -22
  8. package/dist/internal/e10/auth/session.js +1 -1
  9. package/dist/internal/e10/auth/xiaoe.js +268 -0
  10. package/dist/internal/e10/context.js +16 -2
  11. package/dist/internal/e10/index.js +1 -0
  12. package/dist/internal/e10/request-runtime.js +344 -0
  13. package/dist/internal/skills/install.js +48 -6
  14. package/dist/internal/skills/reader.js +27 -0
  15. package/dist/shortcuts/archive/continuation.js +70 -0
  16. package/dist/shortcuts/archive/errors.js +53 -0
  17. package/dist/shortcuts/archive/host.js +197 -0
  18. package/dist/shortcuts/archive/index.js +363 -0
  19. package/dist/shortcuts/archive/manifest.js +45 -0
  20. package/dist/shortcuts/archive/operations/archive-info.js +55 -0
  21. package/dist/shortcuts/archive/operations/borrow-car.js +146 -0
  22. package/dist/shortcuts/archive/operations/borrow-list.js +200 -0
  23. package/dist/shortcuts/archive/operations/confirm.js +46 -0
  24. package/dist/shortcuts/archive/operations/download.js +238 -0
  25. package/dist/shortcuts/archive/operations/flow-url.js +240 -0
  26. package/dist/shortcuts/archive/operations/fonds.js +95 -0
  27. package/dist/shortcuts/archive/operations/getPageUrl.js +137 -0
  28. package/dist/shortcuts/archive/operations/registry.js +43 -0
  29. package/dist/shortcuts/archive/operations/search.js +88 -0
  30. package/dist/shortcuts/archive/operations/shared.js +120 -0
  31. package/dist/shortcuts/archive/operations/types.js +23 -0
  32. package/dist/shortcuts/archive/operations/upload.js +182 -0
  33. package/dist/shortcuts/archive/operations.js +13 -0
  34. package/dist/shortcuts/archive/render/search-format.js +276 -0
  35. package/dist/shortcuts/archive/render/search-view.js +125 -0
  36. package/dist/shortcuts/asset/continuation.js +70 -0
  37. package/dist/shortcuts/asset/errors.js +67 -0
  38. package/dist/shortcuts/asset/host.js +438 -0
  39. package/dist/shortcuts/asset/index.js +255 -0
  40. package/dist/shortcuts/asset/manifest.js +471 -0
  41. package/dist/shortcuts/asset/operations/query.js +249 -0
  42. package/dist/shortcuts/asset/operations/registry.js +85 -0
  43. package/dist/shortcuts/asset/operations/shared.js +100 -0
  44. package/dist/shortcuts/asset/operations/type-cache.js +49 -0
  45. package/dist/shortcuts/asset/operations/types.js +1 -0
  46. package/dist/shortcuts/asset/operations/viewlink.js +117 -0
  47. package/dist/shortcuts/asset/operations/write.js +435 -0
  48. package/dist/shortcuts/asset/operations.js +9 -0
  49. package/dist/shortcuts/calendar/continuation.js +70 -0
  50. package/dist/shortcuts/calendar/errors.js +53 -0
  51. package/dist/shortcuts/calendar/host.js +148 -0
  52. package/dist/shortcuts/calendar/index.js +125 -0
  53. package/dist/shortcuts/calendar/manifest.js +26 -0
  54. package/dist/shortcuts/calendar/operations/read.js +259 -0
  55. package/dist/shortcuts/calendar/operations/registry.js +31 -0
  56. package/dist/shortcuts/calendar/operations/shared.js +132 -0
  57. package/dist/shortcuts/calendar/operations/types.js +25 -0
  58. package/dist/shortcuts/calendar/operations/write.js +439 -0
  59. package/dist/shortcuts/calendar/operations.js +8 -0
  60. package/dist/shortcuts/ehr/continuation.js +70 -0
  61. package/dist/shortcuts/ehr/errors.js +53 -0
  62. package/dist/shortcuts/ehr/host.js +213 -0
  63. package/dist/shortcuts/ehr/index.js +205 -0
  64. package/dist/shortcuts/ehr/manifest.js +47 -0
  65. package/dist/shortcuts/ehr/operations/attend-read.js +373 -0
  66. package/dist/shortcuts/ehr/operations/attend-write.js +514 -0
  67. package/dist/shortcuts/ehr/operations/hr-contact.js +363 -0
  68. package/dist/shortcuts/ehr/operations/hr-ds.js +298 -0
  69. package/dist/shortcuts/ehr/operations/hr-report.js +386 -0
  70. package/dist/shortcuts/ehr/operations/recruit-write.js +1629 -0
  71. package/dist/shortcuts/ehr/operations/recruit.js +803 -0
  72. package/dist/shortcuts/ehr/operations/registry.js +43 -0
  73. package/dist/shortcuts/ehr/operations/salary.js +319 -0
  74. package/dist/shortcuts/ehr/operations/shared.js +246 -0
  75. package/dist/shortcuts/ehr/operations/types.js +25 -0
  76. package/dist/shortcuts/ehr/operations.js +25 -0
  77. package/dist/shortcuts/esb/continuation.js +70 -0
  78. package/dist/shortcuts/esb/errors.js +65 -0
  79. package/dist/shortcuts/esb/host.js +187 -0
  80. package/dist/shortcuts/esb/index.js +112 -0
  81. package/dist/shortcuts/esb/manifest.js +91 -0
  82. package/dist/shortcuts/esb/operations/input-format.js +31 -0
  83. package/dist/shortcuts/esb/operations/registry.js +48 -0
  84. package/dist/shortcuts/esb/operations/shared.js +152 -0
  85. package/dist/shortcuts/esb/operations/trigger.js +76 -0
  86. package/dist/shortcuts/esb/operations/types.js +21 -0
  87. package/dist/shortcuts/esb/operations.js +15 -0
  88. package/dist/shortcuts/fna/continuation.js +70 -0
  89. package/dist/shortcuts/fna/errors.js +59 -0
  90. package/dist/shortcuts/fna/host.js +146 -0
  91. package/dist/shortcuts/fna/index.js +111 -0
  92. package/dist/shortcuts/fna/manifest.js +41 -0
  93. package/dist/shortcuts/fna/operations/budget.js +124 -0
  94. package/dist/shortcuts/fna/operations/expense-center.js +148 -0
  95. package/dist/shortcuts/fna/operations/invoice-writeoff.js +212 -0
  96. package/dist/shortcuts/fna/operations/loan.js +195 -0
  97. package/dist/shortcuts/fna/operations/registry.js +35 -0
  98. package/dist/shortcuts/fna/operations/shared.js +210 -0
  99. package/dist/shortcuts/fna/operations/types.js +25 -0
  100. package/dist/shortcuts/fna/operations.js +19 -0
  101. package/dist/shortcuts/hrm/errors.js +38 -0
  102. package/dist/shortcuts/hrm/host.js +156 -0
  103. package/dist/shortcuts/hrm/index.js +111 -0
  104. package/dist/shortcuts/hrm/manifest.js +32 -0
  105. package/dist/shortcuts/hrm/operations/employee.js +338 -0
  106. package/dist/shortcuts/hrm/operations/org.js +110 -0
  107. package/dist/shortcuts/hrm/operations/position.js +176 -0
  108. package/dist/shortcuts/hrm/operations/registry.js +33 -0
  109. package/dist/shortcuts/hrm/operations/shared.js +143 -0
  110. package/dist/shortcuts/hrm/operations/types.js +23 -0
  111. package/dist/shortcuts/hrm/operations.js +19 -0
  112. package/dist/shortcuts/index.js +20 -0
  113. package/dist/shortcuts/invoice/host.js +99 -94
  114. package/dist/shortcuts/invoice/index.js +65 -61
  115. package/dist/shortcuts/invoice/manifest.js +222 -14
  116. package/dist/shortcuts/invoice/operations/browse-field.js +17 -0
  117. package/dist/shortcuts/invoice/operations/issuing.js +198 -0
  118. package/dist/shortcuts/invoice/operations/ocr-preview.js +6 -3
  119. package/dist/shortcuts/invoice/operations/registry.js +17 -0
  120. package/dist/shortcuts/invoice/operations/reim.js +401 -0
  121. package/dist/shortcuts/invoice/operations/shared.js +271 -6
  122. package/dist/shortcuts/invoice/operations/validate-preview.js +1 -1
  123. package/dist/shortcuts/jiuchuanhui/cache.js +441 -0
  124. package/dist/shortcuts/jiuchuanhui/continuation.js +70 -0
  125. package/dist/shortcuts/jiuchuanhui/errors.js +59 -0
  126. package/dist/shortcuts/jiuchuanhui/host.js +159 -0
  127. package/dist/shortcuts/jiuchuanhui/index.js +109 -0
  128. package/dist/shortcuts/jiuchuanhui/manifest.js +469 -0
  129. package/dist/shortcuts/jiuchuanhui/operations/datajson.js +214 -0
  130. package/dist/shortcuts/jiuchuanhui/operations/esb.js +157 -0
  131. package/dist/shortcuts/jiuchuanhui/operations/generic.js +146 -0
  132. package/dist/shortcuts/jiuchuanhui/operations/registry.js +133 -0
  133. package/dist/shortcuts/jiuchuanhui/operations/shared.js +158 -0
  134. package/dist/shortcuts/jiuchuanhui/operations/types.js +1 -0
  135. package/dist/shortcuts/jiuchuanhui/operations.js +8 -0
  136. package/dist/shortcuts/mail/continuation.js +70 -0
  137. package/dist/shortcuts/mail/errors.js +53 -0
  138. package/dist/shortcuts/mail/host.js +182 -0
  139. package/dist/shortcuts/mail/index.js +519 -0
  140. package/dist/shortcuts/mail/manifest.js +38 -0
  141. package/dist/shortcuts/mail/operations/mail-blacklist.js +79 -0
  142. package/dist/shortcuts/mail/operations/mail-contacts.js +195 -0
  143. package/dist/shortcuts/mail/operations/mail-manage.js +335 -0
  144. package/dist/shortcuts/mail/operations/mail-read.js +508 -0
  145. package/dist/shortcuts/mail/operations/mail-send.js +474 -0
  146. package/dist/shortcuts/mail/operations/mail-sign.js +203 -0
  147. package/dist/shortcuts/mail/operations/mail-template.js +170 -0
  148. package/dist/shortcuts/mail/operations/registry.js +41 -0
  149. package/dist/shortcuts/mail/operations/shared.js +64 -0
  150. package/dist/shortcuts/mail/operations/types.js +27 -0
  151. package/dist/shortcuts/mail/operations.js +19 -0
  152. package/dist/shortcuts/plan/continuation.js +70 -0
  153. package/dist/shortcuts/plan/errors.js +70 -0
  154. package/dist/shortcuts/plan/host.js +180 -0
  155. package/dist/shortcuts/plan/index.js +150 -0
  156. package/dist/shortcuts/plan/manifest.js +53 -0
  157. package/dist/shortcuts/plan/operations/link.js +256 -0
  158. package/dist/shortcuts/plan/operations/read.js +259 -0
  159. package/dist/shortcuts/plan/operations/registry.js +33 -0
  160. package/dist/shortcuts/plan/operations/shared.js +246 -0
  161. package/dist/shortcuts/plan/operations/types.js +49 -0
  162. package/dist/shortcuts/plan/operations/version.js +49 -0
  163. package/dist/shortcuts/plan/operations/write.js +710 -0
  164. package/dist/shortcuts/plan/operations.js +8 -0
  165. package/docs/SKILL.md +11 -7
  166. package/docs/_catalog.md +23 -5
  167. package/docs/agent-invoice.md +31 -10
  168. package/docs/agent-skill-install.md +211 -0
  169. package/docs/calendar.md +87 -0
  170. package/docs/e10-auth.md +28 -9
  171. package/docs/ehr.md +186 -0
  172. package/docs/esb.md +64 -0
  173. package/docs/fna.md +72 -0
  174. package/docs/hrm.md +89 -0
  175. package/docs/invoice.md +66 -20
  176. package/docs/jiuchuanhui.md +131 -0
  177. package/docs/operation-manual.md +443 -0
  178. package/docs/plan.md +82 -0
  179. package/docs/wenshuding.md +129 -0
  180. package/docs/ziguanjia.md +89 -0
  181. package/package.json +4 -4
  182. package/scripts/package-skill.mjs +127 -34
  183. package/scripts/postbuild.mjs +13 -0
  184. package/skill-template/business-info.json +13 -2
  185. package/skill-template/domains/calendar.md +15 -0
  186. package/skill-template/domains/esb.md +13 -0
  187. package/skill-template/domains/hrm.md +16 -0
  188. package/skill-template/domains/jiuchuanhui.md +23 -0
  189. package/skill-template/domains/jucailin.md +22 -0
  190. package/skill-template/domains/mail.md +21 -0
  191. package/skill-template/domains/plan.md +17 -0
  192. package/skill-template/domains/qiyecheng.md +17 -0
  193. package/skill-template/domains/shared.md +9 -3
  194. package/skill-template/domains/skill-maker.md +10 -0
  195. package/skill-template/domains/wenshuding.md +22 -0
  196. package/skill-template/domains/{invoice.md → yepiaotong.md} +4 -0
  197. package/skill-template/domains/ziguanjia.md +21 -0
  198. package/skill-template/master-skill-template.md +12 -6
  199. package/skill-template/skill-template.md +40 -9
  200. package/skills/weaver-e10-calendar/SKILL.md +101 -0
  201. package/skills/weaver-e10-calendar/product.json +8 -0
  202. package/skills/weaver-e10-calendar/references/calendar-app-check.md +65 -0
  203. package/skills/weaver-e10-calendar/references/calendar-dict.md +55 -0
  204. package/skills/weaver-e10-calendar/references/calendar-query.md +70 -0
  205. package/skills/weaver-e10-calendar/references/calendar-write.md +97 -0
  206. package/skills/weaver-e10-calendar/references/source-manifest.json +54 -0
  207. package/skills/weaver-e10-esb/SKILL.md +102 -0
  208. package/skills/weaver-e10-esb/product.json +8 -0
  209. package/skills/weaver-e10-esb/references/input-format.md +52 -0
  210. package/skills/weaver-e10-esb/references/source-manifest.json +242 -0
  211. package/skills/weaver-e10-esb/references/trigger.md +99 -0
  212. package/skills/weaver-e10-hrm/SKILL.md +87 -0
  213. package/skills/weaver-e10-hrm/product.json +8 -0
  214. package/skills/weaver-e10-hrm/references/employee.md +109 -0
  215. package/skills/weaver-e10-hrm/references/org.md +95 -0
  216. package/skills/weaver-e10-hrm/references/position.md +95 -0
  217. package/skills/weaver-e10-hrm/references/source-manifest.json +121 -0
  218. package/skills/weaver-e10-jiuchuanhui/SKILL.md +174 -0
  219. package/skills/weaver-e10-jiuchuanhui/product.json +8 -0
  220. package/skills/weaver-e10-jiuchuanhui/references/cache.md +110 -0
  221. package/skills/weaver-e10-jiuchuanhui/references/clue.md +61 -0
  222. package/skills/weaver-e10-jiuchuanhui/references/contact-plan.md +56 -0
  223. package/skills/weaver-e10-jiuchuanhui/references/contact-records.md +48 -0
  224. package/skills/weaver-e10-jiuchuanhui/references/contact.md +56 -0
  225. package/skills/weaver-e10-jiuchuanhui/references/customer.md +69 -0
  226. package/skills/weaver-e10-jiuchuanhui/references/disabled-capabilities.md +24 -0
  227. package/skills/weaver-e10-jiuchuanhui/references/discovery-config.md +60 -0
  228. package/skills/weaver-e10-jiuchuanhui/references/general-helpers.md +59 -0
  229. package/skills/weaver-e10-jiuchuanhui/references/jiuchuanhui-entry.md +60 -0
  230. package/skills/weaver-e10-jiuchuanhui/references/sale.md +72 -0
  231. package/skills/weaver-e10-jiuchuanhui/references/source-manifest.json +2632 -0
  232. package/skills/weaver-e10-jucailin/SKILL.md +101 -0
  233. package/skills/weaver-e10-jucailin/product.json +8 -0
  234. package/skills/weaver-e10-jucailin/references/attend-read.md +73 -0
  235. package/skills/weaver-e10-jucailin/references/attend-write.md +82 -0
  236. package/skills/weaver-e10-jucailin/references/hr-contact.md +92 -0
  237. package/skills/weaver-e10-jucailin/references/hr-datasource.md +104 -0
  238. package/skills/weaver-e10-jucailin/references/hr-report.md +76 -0
  239. package/skills/weaver-e10-jucailin/references/recruit-read.md +76 -0
  240. package/skills/weaver-e10-jucailin/references/recruit-write.md +70 -0
  241. package/skills/weaver-e10-jucailin/references/safety-boundaries.md +35 -0
  242. package/skills/weaver-e10-jucailin/references/salary.md +110 -0
  243. package/skills/weaver-e10-jucailin/references/source-manifest.json +152 -0
  244. package/skills/weaver-e10-mail/SKILL.md +151 -0
  245. package/skills/weaver-e10-mail/product.json +8 -0
  246. package/skills/weaver-e10-mail/references/mail-agent-entry.md +47 -0
  247. package/skills/weaver-e10-mail/references/mail-attachment.md +30 -0
  248. package/skills/weaver-e10-mail/references/mail-blacklist.md +27 -0
  249. package/skills/weaver-e10-mail/references/mail-contacts.md +33 -0
  250. package/skills/weaver-e10-mail/references/mail-manage.md +44 -0
  251. package/skills/weaver-e10-mail/references/mail-read.md +76 -0
  252. package/skills/weaver-e10-mail/references/mail-send.md +43 -0
  253. package/skills/weaver-e10-mail/references/mail-sign.md +33 -0
  254. package/skills/weaver-e10-mail/references/mail-template.md +31 -0
  255. package/skills/weaver-e10-mail/references/safety-boundaries.md +32 -0
  256. package/skills/weaver-e10-plan/SKILL.md +139 -0
  257. package/skills/weaver-e10-plan/product.json +8 -0
  258. package/skills/weaver-e10-plan/references/plan-collect-and-compose.md +123 -0
  259. package/skills/weaver-e10-plan/references/plan-overview-and-routing.md +138 -0
  260. package/skills/weaver-e10-plan/references/plan-report-query.md +154 -0
  261. package/skills/weaver-e10-plan/references/plan-report-remind.md +104 -0
  262. package/skills/weaver-e10-plan/references/plan-report-write.md +162 -0
  263. package/skills/weaver-e10-plan/references/source-manifest.json +858 -0
  264. package/skills/weaver-e10-qiyecheng/SKILL.md +118 -0
  265. package/skills/weaver-e10-qiyecheng/product.json +8 -0
  266. package/skills/weaver-e10-qiyecheng/references/budget.md +65 -0
  267. package/skills/weaver-e10-qiyecheng/references/catalog.md +56 -0
  268. package/skills/weaver-e10-qiyecheng/references/expense-center.md +51 -0
  269. package/skills/weaver-e10-qiyecheng/references/invoice-writeoff.md +57 -0
  270. package/skills/weaver-e10-qiyecheng/references/loan-management.md +59 -0
  271. package/skills/weaver-e10-qiyecheng/references/source-manifest.json +698 -0
  272. package/skills/weaver-e10-shared/SKILL.md +86 -0
  273. package/skills/weaver-e10-shared/references/e10-auth-and-session.md +127 -0
  274. package/skills/weaver-e10-shared/references/json-output-contract.md +120 -0
  275. package/skills/weaver-e10-shared/references/weaver-e10-installation.md +110 -0
  276. package/skills/weaver-e10-skill-maker/SKILL.md +77 -0
  277. package/skills/weaver-e10-skill-maker/product.json +8 -0
  278. package/skills/weaver-e10-skill-maker/references/business-skill-generation.md +124 -0
  279. package/skills/weaver-e10-skill-maker/references/detector-validation.md +101 -0
  280. package/skills/weaver-e10-skill-maker/references/module-cli-generation.md +230 -0
  281. package/skills/weaver-e10-skill-maker/references/post-generation-install.md +105 -0
  282. package/skills/weaver-e10-skill-maker/references/source-update-detection.md +261 -0
  283. package/skills/weaver-e10-skill-maker/references/weaver-skill-style.md +141 -0
  284. package/skills/weaver-e10-wenshuding/SKILL.md +157 -0
  285. package/skills/weaver-e10-wenshuding/product.json +8 -0
  286. package/skills/weaver-e10-wenshuding/references/archive-agent-entry.md +63 -0
  287. package/skills/weaver-e10-wenshuding/references/archive-borrow-car.md +52 -0
  288. package/skills/weaver-e10-wenshuding/references/archive-borrow-list.md +52 -0
  289. package/skills/weaver-e10-wenshuding/references/archive-disabled-capabilities.md +22 -0
  290. package/skills/weaver-e10-wenshuding/references/archive-download.md +48 -0
  291. package/skills/weaver-e10-wenshuding/references/archive-flow.md +46 -0
  292. package/skills/weaver-e10-wenshuding/references/archive-fonds.md +34 -0
  293. package/skills/weaver-e10-wenshuding/references/archive-info.md +33 -0
  294. package/skills/weaver-e10-wenshuding/references/archive-search.md +52 -0
  295. package/skills/weaver-e10-wenshuding/references/archive-upload.md +41 -0
  296. package/skills/weaver-e10-wenshuding/references/source-manifest.json +517 -0
  297. package/skills/weaver-e10-yepiaotong/SKILL.md +184 -0
  298. package/skills/{weaver-work-cli-invoice → weaver-e10-yepiaotong}/references/invoice-add.md +1 -1
  299. package/skills/weaver-e10-yepiaotong/references/invoice-agent-entry.md +47 -0
  300. package/skills/weaver-e10-yepiaotong/references/invoice-browse-field-data.md +204 -0
  301. package/skills/{weaver-work-cli-invoice → weaver-e10-yepiaotong}/references/invoice-delete.md +1 -1
  302. package/skills/{weaver-work-cli-invoice → weaver-e10-yepiaotong}/references/invoice-detail.md +13 -5
  303. package/skills/weaver-e10-yepiaotong/references/invoice-disabled-capabilities.md +28 -0
  304. package/skills/weaver-e10-yepiaotong/references/invoice-download.md +31 -0
  305. package/skills/weaver-e10-yepiaotong/references/invoice-enterprise-list.md +45 -0
  306. package/skills/{weaver-work-cli-invoice → weaver-e10-yepiaotong}/references/invoice-file-upload.md +15 -4
  307. package/skills/weaver-e10-yepiaotong/references/invoice-import.md +45 -0
  308. package/skills/weaver-e10-yepiaotong/references/invoice-issuing-examples.md +120 -0
  309. package/skills/weaver-e10-yepiaotong/references/invoice-issuing-field-rules.md +161 -0
  310. package/skills/weaver-e10-yepiaotong/references/invoice-issuing.md +99 -0
  311. package/skills/{weaver-work-cli-invoice → weaver-e10-yepiaotong}/references/invoice-ocr-preview.md +14 -4
  312. package/skills/weaver-e10-yepiaotong/references/invoice-personal-list.md +58 -0
  313. package/skills/weaver-e10-yepiaotong/references/invoice-red.md +261 -0
  314. package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +97 -0
  315. package/skills/{weaver-work-cli-invoice → weaver-e10-yepiaotong}/references/invoice-update.md +1 -1
  316. package/skills/{weaver-work-cli-invoice → weaver-e10-yepiaotong}/references/invoice-validation-preview.md +10 -3
  317. package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +1340 -0
  318. package/skills/weaver-e10-yepiaotong/references/reim-examples.md +845 -0
  319. package/skills/weaver-e10-yepiaotong/references/reim-expense-subject-rules.md +94 -0
  320. package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +449 -0
  321. package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +266 -0
  322. package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +494 -0
  323. package/skills/weaver-e10-yepiaotong/references/source-manifest.json +1103 -0
  324. package/skills/weaver-e10-ziguanjia/SKILL.md +162 -0
  325. package/skills/weaver-e10-ziguanjia/product.json +8 -0
  326. package/skills/weaver-e10-ziguanjia/references/source-manifest.json +147 -0
  327. package/skills/weaver-e10-ziguanjia/references/ziguanjia-agent-entry.md +65 -0
  328. package/skills/weaver-e10-ziguanjia/references/ziguanjia-create.md +45 -0
  329. package/skills/weaver-e10-ziguanjia/references/ziguanjia-depre.md +48 -0
  330. package/skills/weaver-e10-ziguanjia/references/ziguanjia-disabled-capabilities.md +22 -0
  331. package/skills/weaver-e10-ziguanjia/references/ziguanjia-purch.md +57 -0
  332. package/skills/weaver-e10-ziguanjia/references/ziguanjia-query.md +62 -0
  333. package/skills/weaver-e10-ziguanjia/references/ziguanjia-repair.md +83 -0
  334. package/skills/weaver-e10-ziguanjia/references/ziguanjia-resolve.md +49 -0
  335. package/skills/weaver-e10-ziguanjia/references/ziguanjia-return.md +70 -0
  336. package/skills/weaver-e10-ziguanjia/references/ziguanjia-update.md +45 -0
  337. package/skills/weaver-e10-ziguanjia/references/ziguanjia-use.md +60 -0
  338. package/skills/weaver-e10-ziguanjia/references/ziguanjia-viewlink.md +81 -0
  339. package/skills/weaver-work-cli-invoice/SKILL.md +0 -103
  340. package/skills/weaver-work-cli-invoice/references/invoice-agent-entry.md +0 -38
  341. package/skills/weaver-work-cli-invoice/references/invoice-disabled-capabilities.md +0 -26
  342. package/skills/weaver-work-cli-invoice/references/invoice-download.md +0 -22
  343. package/skills/weaver-work-cli-invoice/references/invoice-enterprise-list.md +0 -35
  344. package/skills/weaver-work-cli-invoice/references/invoice-import.md +0 -28
  345. package/skills/weaver-work-cli-invoice/references/invoice-personal-list.md +0 -47
  346. package/skills/weaver-work-cli-shared/SKILL.md +0 -53
  347. package/skills/weaver-work-cli-shared/references/e10-auth-and-session.md +0 -83
  348. package/skills/weaver-work-cli-shared/references/json-output-contract.md +0 -61
  349. package/skills/weaver-work-cli-shared/references/weaver-work-cli-installation.md +0 -61
  350. /package/skills/{weaver-work-cli-shared → weaver-e10-shared}/references/high-risk-write.md +0 -0
  351. /package/skills/{weaver-work-cli-invoice → weaver-e10-yepiaotong}/product.json +0 -0
@@ -0,0 +1,195 @@
1
+ import { fnaPartialError, fnaValidationError, isFnaNetworkError } from '../errors.js';
2
+ import { fnaSuccess, READ, schemaOf, SCHEMA_INTEGER_POSITIVE, SCHEMA_STRING_NONEMPTY, WRITE } from './types.js';
3
+ import { compact, fingerprint, normalizeWeaTable, requireConfirm, requireRemindRows, summarizeRemindRows, toPositiveInt, unwrapData, verifyLease } from './shared.js';
4
+ const CONTINUATION_TTL_SECONDS = 600;
5
+ const LOAN_MENU_FIELDS = {
6
+ menuCode: { ...SCHEMA_STRING_NONEMPTY, description: '菜单编码,如 fesx_fna_borrowingManagement(与环境核对)' },
7
+ permissionSetCode: { ...SCHEMA_STRING_NONEMPTY, description: '权限集编码,如 fesx_fna_borrowingManagement.default(与环境核对)' },
8
+ departmentId: { type: 'string', description: '部门 ID,为空查全部' },
9
+ };
10
+ /**
11
+ * 借款管理:首页汇总(管理员,只读)。
12
+ * POST /api/fna/expense/loanManagementMenu/mainPage
13
+ * data: dhk(待还款)、hkz(还款中)的 { amount, costType, count };amount 为格式化字符串。
14
+ */
15
+ const fnaLoanMainPage = {
16
+ name: 'fna.loan.main.page',
17
+ resource: 'loan',
18
+ method: 'loan.main.page',
19
+ action: 'fna.loan.main.page',
20
+ summary: '借款管理首页汇总(全公司待还款/还款中金额与笔数,需管理员登录)',
21
+ capability: 'loan',
22
+ risk: READ,
23
+ inputSchema: schemaOf({
24
+ ...LOAN_MENU_FIELDS,
25
+ borrowingStatus: { type: 'string', description: '借款状态,如 waitReimbursement(待还款)' },
26
+ }, { description: '借款管理:首页汇总(body 可为空;建议带 menuCode/permissionSetCode)' }),
27
+ handler: async (args, { host }) => {
28
+ const body = compact({
29
+ borrowingStatus: args.borrowingStatus,
30
+ departmentId: args.departmentId,
31
+ menuCode: args.menuCode,
32
+ permissionSetCode: args.permissionSetCode,
33
+ });
34
+ const response = await host.request({
35
+ method: 'POST',
36
+ path: '/api/fna/expense/loanManagementMenu/mainPage',
37
+ body,
38
+ });
39
+ const summary = unwrapData(response);
40
+ return fnaSuccess('fna.loan.main.page', {
41
+ dhk: summary?.dhk ?? null,
42
+ hkz: summary?.hkz ?? null,
43
+ note: 'amount 为格式化字符串(元),count 为笔数;menuCode/permissionSetCode 环境相关,示例值需与环境核对',
44
+ });
45
+ },
46
+ };
47
+ /**
48
+ * 借款管理:首页列表(管理员,只读)。
49
+ * POST /api/fna/expense/loanManagementMenu/mainPageList
50
+ * 必填 current/pageSize/menuCode/permissionSetCode;rows 优先返回 displayData(金额已格式化、createTime 为字符串)。
51
+ */
52
+ const fnaLoanMainList = {
53
+ name: 'fna.loan.main.list',
54
+ resource: 'loan',
55
+ method: 'loan.main.list',
56
+ action: 'fna.loan.main.list',
57
+ summary: '借款管理首页列表(全员借款单分页,需管理员登录):返回 displayData 行(含 id/workflowId,可回传提醒还款)',
58
+ capability: 'loan',
59
+ risk: READ,
60
+ inputSchema: schemaOf({
61
+ current: { ...SCHEMA_INTEGER_POSITIVE, description: '当前页码(必填)' },
62
+ pageSize: { ...SCHEMA_INTEGER_POSITIVE, description: '每页条数(必填)' },
63
+ ...LOAN_MENU_FIELDS,
64
+ isBatchConfirmRepaymentSearch: { type: 'boolean', description: '是否批量确认还款搜索' },
65
+ }, { required: ['current', 'pageSize', 'menuCode', 'permissionSetCode'], description: '借款管理:首页列表' }),
66
+ handler: async (args, { host }) => {
67
+ const current = toPositiveInt(args.current, 'current');
68
+ const pageSize = toPositiveInt(args.pageSize, 'pageSize');
69
+ if (current === undefined)
70
+ throw fnaValidationError('current_required', 'current 必填(正整数页码)');
71
+ if (pageSize === undefined)
72
+ throw fnaValidationError('page_size_required', 'pageSize 必填(正整数每页条数)');
73
+ if (!args.menuCode || !args.permissionSetCode) {
74
+ throw fnaValidationError('menu_code_required', 'menuCode 与 permissionSetCode 必填(借款管理菜单编码,与环境核对)');
75
+ }
76
+ const body = compact({
77
+ current,
78
+ pageSize,
79
+ isBatchConfirmRepaymentSearch: args.isBatchConfirmRepaymentSearch,
80
+ departmentId: args.departmentId,
81
+ menuCode: args.menuCode,
82
+ permissionSetCode: args.permissionSetCode,
83
+ });
84
+ const response = await host.request({
85
+ method: 'POST',
86
+ path: '/api/fna/expense/loanManagementMenu/mainPageList',
87
+ body,
88
+ });
89
+ const table = normalizeWeaTable(unwrapData(response), { current, pageSize });
90
+ return fnaSuccess('fna.loan.main.list', table, {
91
+ hint: '提醒还款请取 rows 中 displayData 行原样回传(fna.loan.remind.repay.prepare);金额展示以 displayData 为准,data 行金额为原始精度',
92
+ });
93
+ },
94
+ };
95
+ /**
96
+ * 借款管理:提醒还款 prepare(写操作)。
97
+ * 只做本地校验与预览(条数/借款人/剩余待还合计),不发送提醒;签发 continuation 绑定行指纹。
98
+ */
99
+ const fnaLoanRemindRepayPrepare = {
100
+ name: 'fna.loan.remind.repay.prepare',
101
+ resource: 'loan',
102
+ method: 'loan.remind.repay.prepare',
103
+ action: 'fna.loan.remind.repay.prepare',
104
+ summary: '提醒还款(准备):传入 mainPageList 的 displayData 行,校验并生成预览与 continuation,不发送提醒',
105
+ capability: 'loan',
106
+ risk: WRITE,
107
+ requiresConfirmation: true,
108
+ inputSchema: schemaOf({
109
+ type: { type: 'string', description: '提醒类型,默认 batchRemindReimbursement' },
110
+ data: {
111
+ type: 'array',
112
+ items: { type: 'object', description: 'mainPageList 返回的 displayData 行(原样回传)' },
113
+ minItems: 1,
114
+ description: '提醒还款记录列表(最多 200 条)',
115
+ },
116
+ }, { required: ['data'], description: '借款管理:提醒还款(准备)' }),
117
+ handler: async (args, { host, continuation }) => {
118
+ const rows = requireRemindRows(args.data);
119
+ const session = await host.getSession();
120
+ const summary = summarizeRemindRows(rows);
121
+ const token = await continuation.issue({
122
+ operation: 'fna.loan.remind.repay.apply',
123
+ baseUrl: session.baseUrl,
124
+ profile: session.profile,
125
+ userId: session.userId,
126
+ fingerprint: fingerprint(rows),
127
+ count: rows.length,
128
+ }, CONTINUATION_TTL_SECONDS * 1000);
129
+ return fnaSuccess('fna.loan.remind.repay.prepare', {
130
+ status: 'AWAITING_CONFIRMATION',
131
+ preview: {
132
+ ...summary,
133
+ action: '向借款人发送还款提醒通知',
134
+ hint: '向用户展示条数、借款人、剩余待还合计并获得明确确认后,再调用 fna.loan.remind.repay.apply',
135
+ },
136
+ continuation: token,
137
+ expiresInSeconds: CONTINUATION_TTL_SECONDS,
138
+ });
139
+ },
140
+ };
141
+ /**
142
+ * 借款管理:提醒还款 apply(写操作,需用户明确确认)。
143
+ * 校验 confirm=true 与 continuation;行集合指纹须与 prepare 一致;POST 后网络中断按不确定结果处理,禁止自动重试。
144
+ */
145
+ const fnaLoanRemindRepayApply = {
146
+ name: 'fna.loan.remind.repay.apply',
147
+ resource: 'loan',
148
+ method: 'loan.remind.repay.apply',
149
+ action: 'fna.loan.remind.repay.apply',
150
+ summary: '提醒还款(执行):需 confirm=true 与 prepare 返回的 continuation,行集合与 prepare 一致才会发送提醒',
151
+ capability: 'loan',
152
+ risk: WRITE,
153
+ requiresConfirmation: true,
154
+ inputSchema: schemaOf({
155
+ type: { type: 'string', description: '提醒类型,默认 batchRemindReimbursement' },
156
+ data: { type: 'array', items: { type: 'object' }, minItems: 1, description: '与 prepare 相同的 displayData 行' },
157
+ confirm: { const: true },
158
+ continuation: { type: 'string', minLength: 1 },
159
+ }, { required: ['data', 'confirm', 'continuation'], description: '借款管理:提醒还款(执行)' }),
160
+ handler: async (args, env) => {
161
+ requireConfirm(args, 'fna.loan.remind.repay.apply');
162
+ const rows = requireRemindRows(args.data);
163
+ const lease = await verifyLease(args, 'fna.loan.remind.repay.apply', env);
164
+ if (fingerprint(rows) !== lease.fingerprint || rows.length !== lease.count) {
165
+ throw fnaValidationError('target_changed', '提醒记录与 prepare 时的快照不一致,请重新执行 prepare');
166
+ }
167
+ const body = { type: args.type ?? 'batchRemindReimbursement', data: rows };
168
+ let response;
169
+ try {
170
+ response = await env.host.request({
171
+ method: 'POST',
172
+ path: '/api/fna/expense/loanManagementMenu/remindRepay',
173
+ body,
174
+ });
175
+ }
176
+ catch (error) {
177
+ if (isFnaNetworkError(error)) {
178
+ throw fnaPartialError('提醒还款请求发送后连接中断,是否已发送不确定,禁止自动重试;可通过 fna.loan.main.list 回查或重新 prepare 确认', { attempted: { count: rows.length } }, { stage: 'loan.remindRepay' });
179
+ }
180
+ throw error;
181
+ }
182
+ const message = response?.data?.msg ?? '提醒还款成功';
183
+ return fnaSuccess('fna.loan.remind.repay.apply', {
184
+ msg: message,
185
+ remindedCount: rows.length,
186
+ note: '本接口只发送还款提醒,不改变借款/还款金额状态',
187
+ });
188
+ },
189
+ };
190
+ export const loanOperations = [
191
+ fnaLoanMainPage,
192
+ fnaLoanMainList,
193
+ fnaLoanRemindRepayPrepare,
194
+ fnaLoanRemindRepayApply,
195
+ ];
@@ -0,0 +1,35 @@
1
+ import { fnaValidationError } from '../errors.js';
2
+ import { budgetOperations } from './budget.js';
3
+ import { expenseCenterOperations } from './expense-center.js';
4
+ import { loanOperations } from './loan.js';
5
+ import { invoiceWriteOffOperations } from './invoice-writeoff.js';
6
+ function buildRegistry() {
7
+ const registry = new Map();
8
+ const definitions = [
9
+ ...budgetOperations,
10
+ ...expenseCenterOperations,
11
+ ...loanOperations,
12
+ ...invoiceWriteOffOperations,
13
+ ];
14
+ for (const definition of definitions) {
15
+ if (registry.has(definition.name)) {
16
+ throw new Error(`duplicate fna operation: ${definition.name}`);
17
+ }
18
+ registry.set(definition.name, definition);
19
+ }
20
+ return registry;
21
+ }
22
+ const fnaOperationRegistry = buildRegistry();
23
+ export function fnaOperationDefinitions() {
24
+ return [...fnaOperationRegistry.values()];
25
+ }
26
+ export function getFnaOperation(operation) {
27
+ const definition = fnaOperationRegistry.get(operation);
28
+ if (!definition) {
29
+ throw fnaValidationError('operation_unknown', `齐业成费控不支持操作:${operation}`);
30
+ }
31
+ return definition;
32
+ }
33
+ export function hasFnaOperation(operation) {
34
+ return fnaOperationRegistry.has(operation);
35
+ }
@@ -0,0 +1,210 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { fnaConfirmationError, fnaValidationError } from '../errors.js';
3
+ /** 原型污染防护:禁止出现在输入对象中的键。 */
4
+ const FORBIDDEN_KEYS = new Set(['__proto__', 'constructor', 'prototype']);
5
+ export function asObject(value) {
6
+ if (!value || typeof value !== 'object' || Array.isArray(value)) {
7
+ throw fnaValidationError('input_not_object', '输入必须是 JSON 对象');
8
+ }
9
+ return value;
10
+ }
11
+ export function assertNoForbiddenKeys(input) {
12
+ for (const key of Object.keys(input)) {
13
+ if (FORBIDDEN_KEYS.has(key)) {
14
+ throw fnaValidationError('forbidden_key', `输入包含非法字段:${key}`);
15
+ }
16
+ }
17
+ }
18
+ const DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
19
+ function isRealDate(value) {
20
+ const [year, month, day] = value.split('-').map(Number);
21
+ if (month < 1 || month > 12)
22
+ return false;
23
+ const daysInMonth = new Date(Date.UTC(year, month, 0)).getUTCDate();
24
+ return day >= 1 && day <= daysInMonth;
25
+ }
26
+ export function assertDate(value, field) {
27
+ if (typeof value !== 'string' || !DATE_PATTERN.test(value)) {
28
+ throw fnaValidationError('date_invalid', `${field} 必须是 YYYY-MM-DD 格式`);
29
+ }
30
+ if (!isRealDate(value)) {
31
+ throw fnaValidationError('date_invalid', `${field} 不是合法日期(月份需 01-12,日期需在该月有效范围内):${value}`);
32
+ }
33
+ return value;
34
+ }
35
+ /** 校验可选日期区间:startDate/endDate 必须成对且 start <= end。 */
36
+ export function assertDateRange(args, startField = 'startDate', endField = 'endDate') {
37
+ const start = args[startField];
38
+ const end = args[endField];
39
+ if ((start === undefined || start === null) !== (end === undefined || end === null)) {
40
+ throw fnaValidationError('date_range_incomplete', `${startField} 与 ${endField} 必须成对提供`);
41
+ }
42
+ if (start === undefined || start === null)
43
+ return {};
44
+ const startDate = assertDate(start, startField);
45
+ const endDate = assertDate(end, endField);
46
+ if (startDate > endDate) {
47
+ throw fnaValidationError('date_range_invalid', `${startField} 不得晚于 ${endField}`);
48
+ }
49
+ return { start: startDate, end: endDate };
50
+ }
51
+ export function toPositiveInt(value, field) {
52
+ if (value === undefined || value === null || value === '')
53
+ return undefined;
54
+ const numeric = Number(value);
55
+ if (!Number.isFinite(numeric)) {
56
+ throw fnaValidationError('number_invalid', `${field} 必须是数字`);
57
+ }
58
+ const truncated = Math.trunc(numeric);
59
+ if (truncated !== numeric || truncated <= 0) {
60
+ throw fnaValidationError('number_invalid', `${field} 必须是正整数`);
61
+ }
62
+ return truncated;
63
+ }
64
+ /**
65
+ * 把 ID 类字段归一化为 JSON 数字(Long 语义)。
66
+ * FNA 部分接口(费用中心借款查询实测)只接受数字 ID,字符串会静默返回空 data。
67
+ * 超过 2^53 的巨型 ID 无法被 JS 数字精确表达,返回 Number 会丢精度,此时保留字符串
68
+ * 并在结果说明中提示人工核验(真实环境 requestId 一般在安全整数内)。
69
+ */
70
+ export function numericId(value, field) {
71
+ if (value === undefined || value === null || value === '')
72
+ return undefined;
73
+ if (typeof value === 'number') {
74
+ if (!Number.isFinite(value))
75
+ throw fnaValidationError('id_invalid', `${field} 必须是数字 ID`);
76
+ return value;
77
+ }
78
+ const text = String(value).trim();
79
+ if (!/^\d+$/.test(text)) {
80
+ throw fnaValidationError('id_invalid', `${field} 必须是数字 ID`);
81
+ }
82
+ const numeric = Number(text);
83
+ return Number.isSafeInteger(numeric) ? numeric : text;
84
+ }
85
+ /** 取出响应中的业务 data。 */
86
+ export function unwrapData(response) {
87
+ if (!response || typeof response !== 'object')
88
+ return response;
89
+ return response.data;
90
+ }
91
+ /** 金额字符串安全转 float(非法或空回退 0)。 */
92
+ export function toAmount(value) {
93
+ if (value === undefined || value === null || value === '')
94
+ return 0;
95
+ const numeric = Number(String(value).replace(/,/g, ''));
96
+ return Number.isFinite(numeric) ? numeric : 0;
97
+ }
98
+ export function compact(body) {
99
+ for (const key of Object.keys(body)) {
100
+ if (body[key] === undefined)
101
+ delete body[key];
102
+ }
103
+ return body;
104
+ }
105
+ /** 内容指纹:写操作 continuation 绑定目标快照。 */
106
+ export function fingerprint(value) {
107
+ return createHash('sha256').update(JSON.stringify(value ?? null)).digest('hex').slice(0, 32);
108
+ }
109
+ /** apply 阶段必须先有用户显式确认。 */
110
+ export function requireConfirm(args, action) {
111
+ if (args.confirm !== true) {
112
+ throw fnaConfirmationError(action, { hint: '重新调用时传入 confirm=true 与 prepare 返回的 continuation' });
113
+ }
114
+ }
115
+ /** 校验 continuation 与当前登录上下文一致,避免切换租户/账号后误执行写操作。 */
116
+ export async function verifyLease(args, action, env) {
117
+ const lease = await env.continuation.verify(args.continuation, action);
118
+ const session = await env.host.getSession();
119
+ if (lease.baseUrl !== session.baseUrl || lease.profile !== session.profile || lease.userId !== session.userId) {
120
+ throw fnaValidationError('context_mismatch', '确认上下文已变化(租户或登录账号不同),请重新执行 prepare');
121
+ }
122
+ return lease;
123
+ }
124
+ const MAX_ROWS = 200;
125
+ const MAX_ROWS_BYTES = 80 * 1024;
126
+ /**
127
+ * 校验借款提醒行(displayData 行对象原样回传)。
128
+ * 每行必须含 id(数字字符串)与 workflowId(数字字符串),防止凭空构造。
129
+ */
130
+ export function requireRemindRows(value) {
131
+ if (!Array.isArray(value) || value.length === 0) {
132
+ throw fnaValidationError('rows_empty', 'data 必须是非空数组(mainPageList 返回的 displayData 行)');
133
+ }
134
+ if (value.length > MAX_ROWS) {
135
+ throw fnaValidationError('rows_too_many', `一次最多提醒 ${MAX_ROWS} 条记录`);
136
+ }
137
+ const rows = value;
138
+ for (let index = 0; index < rows.length; index += 1) {
139
+ const row = rows[index];
140
+ if (!row || typeof row !== 'object' || Array.isArray(row)) {
141
+ throw fnaValidationError('rows_invalid', `data[${index}] 必须是对象(displayData 行)`);
142
+ }
143
+ const id = String(row.id ?? '');
144
+ const workflowId = String(row.workflowId ?? row.workflowid ?? '');
145
+ if (!/^\d+$/.test(id) || !/^\d+$/.test(workflowId)) {
146
+ throw fnaValidationError('rows_invalid', `data[${index}] 缺少合法 id 与 workflowId,无法定位借款记录`);
147
+ }
148
+ }
149
+ const serialized = JSON.stringify(rows);
150
+ if (Buffer.byteLength(serialized, 'utf8') > MAX_ROWS_BYTES) {
151
+ throw fnaValidationError('rows_too_large', '提醒记录过大,请分批处理');
152
+ }
153
+ return rows;
154
+ }
155
+ /** 汇总借款提醒行:条数、借款人、剩余待还合计、记录 ID。 */
156
+ export function summarizeRemindRows(rows) {
157
+ const borrowers = [...new Set(rows.map((row) => String(row.jkrPersonName || row.createPerson || row.userId || '').trim()).filter(Boolean))];
158
+ const totalDhk = rows.reduce((sum, row) => sum + toAmount(row.dhkAmount), 0);
159
+ const ids = rows.map((row) => String(row.id));
160
+ return {
161
+ count: rows.length,
162
+ borrowers,
163
+ totalDhkAmount: totalDhk.toFixed(2),
164
+ ids,
165
+ };
166
+ }
167
+ /**
168
+ * 归一化 WeaTable 分页表格响应(借款列表/发票核销列表同构):
169
+ * 统一输出 total/current/pageSize/hasMore/pageUid/pageSizeFromPageUid/columns/operates/rows,
170
+ * rows 优先取 displayData(金额已格式化、时间已转字符串),否则取 data。
171
+ */
172
+ export function normalizeWeaTable(table, defaults) {
173
+ const payload = table ?? {};
174
+ const displayRows = Array.isArray(payload.displayData) ? payload.displayData : null;
175
+ const rawRows = Array.isArray(payload.data) ? payload.data : [];
176
+ return {
177
+ pageUid: payload.pageUid ?? '',
178
+ total: payload.total ?? 0,
179
+ current: payload.current ?? defaults.current,
180
+ pageSize: payload.pageSize ?? defaults.pageSize,
181
+ hasMore: payload.hasMore ?? false,
182
+ pageSizeFromPageUid: payload.pageSizeFromPageUid ?? defaults.pageSize,
183
+ columns: Array.isArray(payload.columns) ? payload.columns : [],
184
+ operates: Array.isArray(payload.operates) ? payload.operates : [],
185
+ rows: displayRows ?? rawRows,
186
+ };
187
+ }
188
+ /**
189
+ * 校验催票 requestids(writeOffList 返回行的 requestId / id)。
190
+ * 只允许数字字符串,防止凭空构造或混入非流程 ID。
191
+ */
192
+ export function requireRequestIds(value) {
193
+ if (!Array.isArray(value) || value.length === 0) {
194
+ throw fnaValidationError('requestids_empty', 'requestids 必须是非空数组(writeOffList 返回行的 requestId)');
195
+ }
196
+ if (value.length > MAX_ROWS) {
197
+ throw fnaValidationError('requestids_too_many', `一次最多催票 ${MAX_ROWS} 条记录`);
198
+ }
199
+ const ids = value.map((item, index) => {
200
+ if (item === undefined || item === null || item === '') {
201
+ throw fnaValidationError('requestids_invalid', `requestids[${index}] 不能为空`);
202
+ }
203
+ const text = String(item).trim();
204
+ if (!/^\d+$/.test(text)) {
205
+ throw fnaValidationError('requestids_invalid', `requestids[${index}] 必须是数字流程 ID`);
206
+ }
207
+ return text;
208
+ });
209
+ return ids;
210
+ }
@@ -0,0 +1,25 @@
1
+ export const READ = 'read';
2
+ export const WRITE = 'write';
3
+ export function fnaSuccess(action, data, meta) {
4
+ const payload = { ok: true, action, data };
5
+ if (meta && Object.keys(meta).length > 0)
6
+ payload.meta = meta;
7
+ return payload;
8
+ }
9
+ /** 构造「对象类型 + 严格禁止额外字段」的 JSON Schema。 */
10
+ export function schemaOf(properties, options = {}) {
11
+ return {
12
+ type: 'object',
13
+ additionalProperties: false,
14
+ properties,
15
+ ...(options.required?.length ? { required: options.required } : {}),
16
+ ...(options.description ? { description: options.description } : {}),
17
+ };
18
+ }
19
+ export const SCHEMA_INTEGER_POSITIVE = { type: 'integer', minimum: 1 };
20
+ export const SCHEMA_NUMBER_POSITIVE = { type: 'number', exclusiveMinimum: 0 };
21
+ export const SCHEMA_DATE = { type: 'string', pattern: '^\\d{4}-\\d{2}-\\d{2}$' };
22
+ export const SCHEMA_ID = { oneOf: [{ type: 'integer' }, { type: 'string', pattern: '^\\d+$' }] };
23
+ export const SCHEMA_ID_LIST = { type: 'array', items: SCHEMA_ID };
24
+ export const SCHEMA_STRING_LIST = { type: 'array', items: { type: 'string' } };
25
+ export const SCHEMA_STRING_NONEMPTY = { type: 'string', minLength: 1 };
@@ -0,0 +1,19 @@
1
+ import { getFnaOperation } from './operations/registry.js';
2
+ import { assertNoForbiddenKeys, asObject } from './operations/shared.js';
3
+ export async function executeFnaOperation(operation, rawInput, context) {
4
+ const definition = getFnaOperation(operation);
5
+ const input = asObject(rawInput);
6
+ assertNoForbiddenKeys(input);
7
+ const host = {
8
+ request(request) {
9
+ return context.host.request({
10
+ ...request,
11
+ operation: request.operation || operation,
12
+ });
13
+ },
14
+ getSession() {
15
+ return context.host.getSession();
16
+ },
17
+ };
18
+ return definition.handler(input, { ...context, host });
19
+ }
@@ -0,0 +1,38 @@
1
+ import { CliError, ExitCode } from '../../core/errors.js';
2
+ export class HrmCliError extends CliError {
3
+ type;
4
+ subtype;
5
+ code;
6
+ retryable;
7
+ stage;
8
+ details;
9
+ constructor(type, subtype, message, options = {}) {
10
+ super(message, options.exitCode ?? ExitCode.InternalError);
11
+ this.name = 'HrmCliError';
12
+ this.type = type;
13
+ this.subtype = subtype;
14
+ this.code = options.code;
15
+ this.retryable = options.retryable ?? false;
16
+ this.stage = options.stage;
17
+ this.details = options.details;
18
+ }
19
+ }
20
+ export function hrmValidationError(subtype, message, details) {
21
+ return new HrmCliError('validation', subtype, message, {
22
+ details,
23
+ exitCode: ExitCode.UsageError,
24
+ });
25
+ }
26
+ export function hrmAuthError(subtype, message, details) {
27
+ return new HrmCliError('authentication', subtype, message, {
28
+ details,
29
+ exitCode: ExitCode.AuthError,
30
+ });
31
+ }
32
+ export function hrmNetworkError(subtype, message, options = {}) {
33
+ return new HrmCliError('network', subtype, message, {
34
+ ...options,
35
+ retryable: options.retryable ?? true,
36
+ exitCode: ExitCode.NetworkError,
37
+ });
38
+ }