weaver-work-cli 0.1.50 → 0.1.52

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 (167) hide show
  1. package/README.md +1 -1
  2. package/dist/chunks/{attachment-content-EJYIOJPH.js → attachment-content-MBYYSQIX.js} +3 -3
  3. package/dist/chunks/{chunk-RYFRGTUV.js → chunk-7UOXOGFL.js} +4 -4
  4. package/dist/chunks/{chunk-BFKLQLBK.js → chunk-D3TDNRFE.js} +7 -7
  5. package/dist/chunks/{chunk-3NCFFHB2.js → chunk-DZOC77ZD.js} +1 -1
  6. package/dist/chunks/{chunk-K67FODVC.js → chunk-IRMA3GVP.js} +1 -1
  7. package/dist/chunks/{chunk-WNJUGI2F.js → chunk-KLZ3ULQQ.js} +1 -1
  8. package/dist/chunks/{chunk-6T53BSWZ.js → chunk-LALWNK6M.js} +9 -0
  9. package/dist/chunks/{chunk-HARQF5IP.js → chunk-LM2H7SZI.js} +25 -25
  10. package/dist/chunks/{chunk-YB3AJYPY.js → chunk-LTRLF6MM.js} +4 -4
  11. package/dist/chunks/{chunk-7ECB22G3.js → chunk-RPRFIG6I.js} +23 -23
  12. package/dist/chunks/{chunk-MCZG6HPM.js → chunk-RWFRZSIP.js} +2 -2
  13. package/dist/chunks/{chunk-7AYQJSFY.js → chunk-ZRHKGQRQ.js} +2 -2
  14. package/dist/chunks/{conflict-C4UDHCWV.js → conflict-D2HYKBMH.js} +2 -2
  15. package/dist/chunks/{contract-VUC6JOPG.js → contract-MFOFMM2J.js} +3837 -262
  16. package/dist/chunks/{create-flow-6OG2LYBD.js → create-flow-7ZATJVTM.js} +6 -6
  17. package/dist/chunks/{data-QO7QWOIV.js → data-WK5CQXNF.js} +17 -32
  18. package/dist/chunks/{env-WP57TF2S.js → env-5DO4YENS.js} +2 -2
  19. package/dist/chunks/{factory-VUXI7N5C.js → factory-3M7D7WJC.js} +1 -1
  20. package/dist/chunks/{group-chat-UQRGXILK.js → group-chat-B2HT5NEO.js} +3 -3
  21. package/dist/chunks/{invoice-E7GOITEU.js → invoice-V7ZTITUO.js} +725 -205
  22. package/dist/chunks/{meeting-4BBLVAWM.js → meeting-HZOX3CBB.js} +10 -10
  23. package/dist/chunks/{recruit-stage-FKWS5UQF.js → recruit-stage-XCMVEQA2.js} +718 -131
  24. package/dist/chunks/{registry-V4CHRQDI.js → registry-KYPFFQIH.js} +1 -1
  25. package/dist/chunks/{registry-5CRCN2TV.js → registry-SJHSBO5G.js} +10 -10
  26. package/dist/chunks/{room-recommend-AYR3UG7R.js → room-recommend-5AHR4YQV.js} +4 -4
  27. package/dist/chunks/{schedule-JZEFIXUS.js → schedule-KZPJUPC2.js} +4 -4
  28. package/dist/chunks/smart-extract-IXHCZE4R.js +2846 -0
  29. package/dist/chunks/{workflow-3ZAF2J5E.js → workflow-UHKCZJMY.js} +1 -1
  30. package/dist/index.js +11 -6
  31. package/dist/shortcuts/contract/manifest.js +151 -0
  32. package/dist/shortcuts/contract/operations/card-action.js +585 -0
  33. package/dist/shortcuts/contract/operations/card-ebdf-list.js +315 -0
  34. package/dist/shortcuts/contract/operations/card-plan.js +327 -0
  35. package/dist/shortcuts/contract/operations/card-risk-report.js +565 -0
  36. package/dist/shortcuts/contract/operations/elements-build.js +714 -0
  37. package/dist/shortcuts/contract/operations/elements-spec.js +216 -0
  38. package/dist/shortcuts/contract/operations/first-screen.js +563 -0
  39. package/dist/shortcuts/contract/operations/flow.js +81 -25
  40. package/dist/shortcuts/contract/operations/modeltext.js +132 -0
  41. package/dist/shortcuts/contract/operations/op-resolver.js +22 -0
  42. package/dist/shortcuts/contract/operations/quote.js +131 -25
  43. package/dist/shortcuts/contract/operations/registry.js +20 -0
  44. package/dist/shortcuts/contract/operations/review.js +73 -58
  45. package/dist/shortcuts/contract/operations/summary-validate.js +293 -0
  46. package/dist/shortcuts/contract/operations/summary.js +4 -2
  47. package/dist/shortcuts/contract/operations/upload.js +48 -7
  48. package/dist/shortcuts/contract/prewarm-cache.js +90 -0
  49. package/dist/shortcuts/contract/prewarm.js +88 -0
  50. package/dist/shortcuts/contract/upload-cache.js +49 -4
  51. package/dist/shortcuts/data/index.js +1 -6
  52. package/dist/shortcuts/data/manifest.js +2 -2
  53. package/dist/shortcuts/data/operations/index.js +1 -1
  54. package/dist/shortcuts/data/operations/query.js +23 -46
  55. package/dist/shortcuts/index.js +5 -0
  56. package/dist/shortcuts/invoice/index.js +0 -12
  57. package/dist/shortcuts/invoice/manifest.js +200 -49
  58. package/dist/shortcuts/invoice/operations/registry.js +4 -2
  59. package/dist/shortcuts/invoice/operations/reim-relation.js +438 -0
  60. package/dist/shortcuts/invoice/operations/shared.js +3 -19
  61. package/dist/shortcuts/invoice/operations/upload-and-validate.js +109 -73
  62. package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +4 -2
  63. package/dist/shortcuts/recruit-stage/operations/jd-create.js +6 -2
  64. package/dist/shortcuts/recruit-stage/operations/list.js +217 -1
  65. package/dist/shortcuts/recruit-stage/operations/resume-import.js +144 -158
  66. package/dist/shortcuts/recruit-stage/operations/search.js +348 -0
  67. package/dist/shortcuts/recruit-stage/shared.js +5 -0
  68. package/dist/shortcuts/recruit-stage/tag-lookup.js +136 -0
  69. package/dist/shortcuts/smart-extract/constants.js +79 -0
  70. package/dist/shortcuts/smart-extract/continuation.js +71 -0
  71. package/dist/shortcuts/smart-extract/errors.js +68 -0
  72. package/dist/shortcuts/smart-extract/host.js +191 -0
  73. package/dist/shortcuts/smart-extract/index.js +105 -0
  74. package/dist/shortcuts/smart-extract/ledger.js +70 -0
  75. package/dist/shortcuts/smart-extract/manifest.js +35 -0
  76. package/dist/shortcuts/smart-extract/operations/attachment.js +212 -0
  77. package/dist/shortcuts/smart-extract/operations/batch.js +67 -0
  78. package/dist/shortcuts/smart-extract/operations/config.js +118 -0
  79. package/dist/shortcuts/smart-extract/operations/fill.js +489 -0
  80. package/dist/shortcuts/smart-extract/operations/preview.js +174 -0
  81. package/dist/shortcuts/smart-extract/operations/registry.js +34 -0
  82. package/dist/shortcuts/smart-extract/operations/save.js +355 -0
  83. package/dist/shortcuts/smart-extract/operations/shared.js +191 -0
  84. package/dist/shortcuts/smart-extract/operations/structure.js +401 -0
  85. package/dist/shortcuts/smart-extract/operations/target.js +167 -0
  86. package/dist/shortcuts/smart-extract/operations/types.js +22 -0
  87. package/dist/shortcuts/smart-extract/operations/validate.js +408 -0
  88. package/dist/shortcuts/workflow/operations/read.js +19 -1
  89. package/docs/SKILL.md +1 -1
  90. package/docs/_catalog.md +3 -0
  91. package/docs/agent-invoice.md +5 -7
  92. package/docs/data.md +5 -1
  93. package/docs/fna.md +14 -1
  94. package/docs/invoice.md +7 -5
  95. package/docs/smart-extract.md +156 -0
  96. package/package.json +1 -1
  97. package/skill-template/business-info.json +16 -1
  98. package/skill-template/domains/qiyecheng.md +2 -0
  99. package/skill-template/domains/smart-extract.md +16 -0
  100. package/skill-template/domains/yepiaotong.md +2 -2
  101. package/skills/weaver-e10-data/references/scene-and-misc.md +4 -3
  102. package/skills/weaver-e10-jinchengda/SKILL.md +159 -11
  103. package/skills/weaver-e10-jinchengda/references/contract-action-card.md +8 -3
  104. package/skills/weaver-e10-jinchengda/references/contract-action-engine.md +4 -3
  105. package/skills/weaver-e10-jinchengda/references/contract-element-save-record.md +8 -7
  106. package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +21 -6
  107. package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +3 -1
  108. package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +1 -1
  109. package/skills/weaver-e10-jinchengda/references/contract-modeltext-library.md +128 -0
  110. package/skills/weaver-e10-jinchengda/references/contract-multi-file.md +90 -0
  111. package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +124 -5
  112. package/skills/weaver-e10-jinchengda/scripts/contract_first_screen.py +200 -0
  113. package/skills/weaver-e10-jinchengda/scripts/fill_contract_from_quote.py +572 -0
  114. package/skills/weaver-e10-jinchengda/scripts/quote_screen.py +560 -0
  115. package/skills/weaver-e10-jinchengda/scripts/triage_contract.py +894 -0
  116. package/skills/weaver-e10-jinchengda/scripts/validate_action_card.py +10 -0
  117. package/skills/weaver-e10-qiyecheng/SKILL.md +37 -0
  118. package/skills/weaver-e10-qiyecheng/references/ai-check-audit.md +14 -0
  119. package/skills/weaver-e10-qiyecheng/references/budget.md +14 -0
  120. package/skills/weaver-e10-qiyecheng/references/catalog.md +25 -0
  121. package/skills/weaver-e10-qiyecheng/references/expense-center.md +8 -0
  122. package/skills/weaver-e10-qiyecheng/references/expense-chart.md +9 -0
  123. package/skills/weaver-e10-qiyecheng/references/invoice-writeoff.md +13 -0
  124. package/skills/weaver-e10-qiyecheng/references/loan-management.md +14 -0
  125. package/skills/weaver-e10-qiyecheng/references/self-hosted-mode.md +239 -0
  126. package/skills/weaver-e10-qiyecheng/references/source-manifest.json +34 -27
  127. package/skills/weaver-e10-recruit-stage/SKILL.md +62 -4
  128. package/skills/weaver-e10-recruit-stage/agents/openai.yaml +42 -8
  129. package/skills/weaver-e10-recruit-stage/references/env-ziyong.md +79 -0
  130. package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +11 -3
  131. package/skills/weaver-e10-recruit-stage/references/recruit-edit-interview-feedback.md +3 -2
  132. package/skills/weaver-e10-recruit-stage/references/recruit-interview-not-attended.md +153 -0
  133. package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +7 -4
  134. package/skills/weaver-e10-recruit-stage/references/recruit-match-candidates.md +1 -1
  135. package/skills/weaver-e10-recruit-stage/references/recruit-my-positions.md +66 -0
  136. package/skills/weaver-e10-recruit-stage/references/recruit-output-links.md +156 -42
  137. package/skills/weaver-e10-recruit-stage/references/recruit-resume-import-batch.md +122 -0
  138. package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +36 -8
  139. package/skills/weaver-e10-recruit-stage/references/recruit-search-by-tag.md +157 -0
  140. package/skills/weaver-e10-recruit-stage/references/recruit-utterance-glossary.md +35 -0
  141. package/skills/weaver-e10-smart-extract/SKILL.md +169 -0
  142. package/skills/weaver-e10-smart-extract/references/api-contract.md +71 -0
  143. package/skills/weaver-e10-smart-extract/references/result-format.md +102 -0
  144. package/skills/weaver-e10-smart-extract/references/troubleshooting.md +105 -0
  145. package/skills/weaver-e10-workflow/references/workflow-query.md +1 -1
  146. package/skills/weaver-e10-workflow/references/workflow-view.md +1 -1
  147. package/skills/weaver-e10-yepiaotong/SKILL.md +46 -33
  148. package/skills/weaver-e10-yepiaotong/references/invoice-add.md +2 -0
  149. package/skills/weaver-e10-yepiaotong/references/invoice-file-upload.md +1 -1
  150. package/skills/weaver-e10-yepiaotong/references/invoice-import.md +19 -2
  151. package/skills/weaver-e10-yepiaotong/references/invoice-ocr-preview.md +8 -2
  152. package/skills/weaver-e10-yepiaotong/references/invoice-reim-relation.md +407 -0
  153. package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +12 -8
  154. package/skills/weaver-e10-yepiaotong/references/invoice-upload-and-validate.md +97 -39
  155. package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +91 -2
  156. package/skills/weaver-e10-yepiaotong/references/reim-examples.md +1 -1
  157. package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +12 -12
  158. package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +8 -4
  159. package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +136 -91
  160. package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +109 -23
  161. package/skills/weaver-e10-yepiaotong/references/source-manifest.json +110 -43
  162. package/dist/shortcuts/invoice/operations/validate-preview.js +0 -40
  163. package/skills/weaver-e10-jinchengda/scripts/plan_actions.py +0 -279
  164. package/skills/weaver-e10-jinchengda/scripts/render_action_card.py +0 -450
  165. package/skills/weaver-e10-jinchengda/scripts/render_ebdf_list_card.py +0 -265
  166. package/skills/weaver-e10-jinchengda/scripts/render_risk_report.py +0 -358
  167. package/skills/weaver-e10-yepiaotong/references/invoice-validation-preview.md +0 -40
@@ -684,39 +684,37 @@ var ocrPreviewOutputSchema = objectSchema({
684
684
  results: rawArray,
685
685
  workflow: workflowSchema
686
686
  }, ["saved", "verified", "upload", "invoices", "results", "workflow"]);
687
- var validationPreviewOutputSchema = objectSchema({
688
- preview: objectSchema({
689
- ...invoicePreviewSchema.properties,
690
- targetFid: { type: "string" },
691
- resultFid: { type: "string" },
692
- scope: { type: "string", enum: ["personal", "enterprise"] },
693
- validation: { type: "integer" },
694
- invoiceStatus: { type: "integer" },
695
- saved: { const: false }
696
- }, ["fid", "targetFid", "resultFid", "scope", "saved"]),
697
- info: invoiceInfoSchema,
698
- saved: { const: false },
699
- result: rawObject,
700
- workflow: workflowSchema
701
- }, ["preview", "info", "saved", "result", "workflow"]);
702
- var validationItemSchema = objectSchema({
703
- ...invoicePreviewSchema.properties,
704
- targetFid: { type: "string" },
705
- resultFid: { type: "string" },
706
- scope: { type: "string", enum: ["personal", "enterprise"] },
707
- validation: { type: "integer" },
708
- invoiceStatus: { type: "integer" },
709
- saved: { const: false }
710
- }, ["fid", "scope", "saved"]);
687
+ var uploadAndValidateItemSchema = objectSchema({
688
+ fid: { type: "string", description: "\u4E3A\u7A7A\u8868\u793A\u8FD9\u5F20\u6CA1\u8FDB\u7968\u5939\uFF1B\u975E\u7A7A\u5373\u5DF2\u8FDB\u4E2A\u4EBA\u7968\u5939\uFF08\u542B\u67E5\u9A8C\u6CA1\u901A\u8FC7\u7684\uFF09\u3002" },
689
+ code: { type: "string", description: "\u53D1\u7968\u4EE3\u7801\uFF0C\u5168\u7535\u53D1\u7968\u4E3A\u7A7A\u4E32\u3002" },
690
+ number: { type: "string", description: "\u53D1\u7968\u53F7\u7801\u3002" },
691
+ cname: { type: "string", description: "\u7968\u79CD\u540D\u79F0\uFF08comm_info.pro.cname\uFF09\u3002" },
692
+ type: { type: "integer", description: "\u7968\u79CD\u4EE3\u7801\uFF08comm_info.pro.type\uFF09\u300217/18/57/58 \u662F\u76F8\u5173\u51ED\u8BC1\uFF08\u5C0F\u7968/\u6C34\u5355\u3001\u6EF4\u6EF4\u7B49\u884C\u7A0B\u5355\u3001\u652F\u4ED8\u51ED\u8BC1\u3001\u5176\u4ED6\u7968\u636E\u51ED\u8BC1\uFF09\uFF0C\u62A5\u9500\u65F6\u4E0D\u5355\u72EC\u6210\u884C\uFF1B16/48 \u662F\u822A\u7A7A\u8FD0\u8F93\u7535\u5B50\u5BA2\u7968\u884C\u7A0B\u5355\uFF0C\u7B97\u53D1\u7968\u3002" },
693
+ kind: { type: "string", description: "\u6D88\u8D39\u7C7B\u522B\uFF08comm_info.pro.kind\uFF09\uFF0C\u7A7A\u503C\u7701\u952E\u3002" },
694
+ date: { type: "string", description: "\u5F00\u7968\u65E5\u671F YYYY-MM-DD\u3002" },
695
+ amount: { type: "string", description: "\u4E0D\u542B\u7A0E\u91D1\u989D\u3002" },
696
+ total: { type: "string", description: "\u4EF7\u7A0E\u5408\u8BA1\u3002" },
697
+ dtax: { type: "string", description: "\u7A0E\u989D\u3002" },
698
+ buyer: invoicePartySchema,
699
+ payer: invoicePartySchema,
700
+ ext: {
701
+ ...jsonObject,
702
+ description: "\u5DF2\u89E3\u6790\u7684\u7968\u9762 ext\uFF0C\u53BB\u6389 null / \u7A7A\u503C\u548C\u5370\u7AE0\u3001\u5927\u5199\u91D1\u989D\u7B49\u7248\u5F0F\u6807\u8BB0\uFF1B\u5E38\u89C1\u952E\uFF1Attax \u7A0E\u989D\u3001trate \u7A0E\u7387\u3001content \u6D88\u8D39\u5185\u5BB9\u3001comment \u5907\u6CE8\u3001city / province\u3001issuer \u5F00\u7968\u4EBA\u3001service_name \u670D\u52A1\u7C7B\u578B\u3001products[]\uFF08name \u540D\u79F0\u3001smodel \u89C4\u683C\u3001muint \u5355\u4F4D\u3001qty \u6570\u91CF\u3001price \u5355\u4EF7\u3001amount \u91D1\u989D\u3001trate \u7A0E\u7387\u3001tprice \u7A0E\u989D\uFF09\u3002"
703
+ },
704
+ ret: objectSchema({
705
+ ret: { type: "integer", description: "0=\u8BC6\u522B\u5E76\u67E5\u9A8C\u6210\u529F\uFF1B\u975E 0 \u89C1 message\u3002" },
706
+ message: { type: "string" }
707
+ }, ["ret"]),
708
+ validated: { type: "boolean", description: "ret.ret === 0\u3002" },
709
+ detailUrl: { type: "string", description: "\u53D1\u7968\u8BE6\u60C5\u9875\u94FE\u63A5\uFF0Cfid \u4E3A\u7A7A\u65F6\u7701\u952E\u3002" }
710
+ }, ["fid", "code", "number", "cname", "type", "date", "amount", "total", "dtax", "buyer", "payer", "ext", "ret", "validated"]);
711
711
  var uploadAndValidateOutputSchema = objectSchema({
712
- upload: uploadSchema,
713
- ocrCount: { type: "integer", minimum: 0 },
714
- invoices: arrayOf(invoiceResultItemSchema),
715
- validations: arrayOf(validationItemSchema),
716
- validationErrors: arrayOf(objectSchema({ fid: { type: ["string", "null"] }, error: { type: "string" } }, ["error"])),
717
- results: rawArray,
712
+ fileName: { type: "string", description: "\u672C\u6B21\u4E0A\u4F20\u7684\u6587\u4EF6\u540D\uFF08url \u6765\u6E90\u65F6\u4E3A url\uFF09\u3002" },
713
+ count: { type: "integer", minimum: 1, description: "\u8BC6\u522B\u51FA\u7684\u7968\u636E\u5F20\u6570\uFF0C\u53D1\u7968\u548C\u884C\u7A0B\u5355\u90FD\u7B97\u3002" },
714
+ validatedCount: { type: "integer", minimum: 0, description: "\u8BC6\u522B\u5E76\u67E5\u9A8C\u6210\u529F\uFF08ret.ret=0\uFF09\u7684\u5F20\u6570\u3002" },
715
+ invoices: arrayOf(uploadAndValidateItemSchema),
718
716
  workflow: workflowSchema
719
- }, ["upload", "ocrCount", "invoices", "validations", "validationErrors", "results", "workflow"]);
717
+ }, ["fileName", "count", "validatedCount", "invoices", "workflow"]);
720
718
  var importPreviewSchema = objectSchema({
721
719
  source: { type: "string", enum: ["file", "url"] },
722
720
  name: { type: "string" },
@@ -861,6 +859,88 @@ var reimCandidatesOutputSchema = objectSchema({
861
859
  workflow: workflowSchema
862
860
  }, ["total", "fetched", "hasMore", "available", "assigned", "summary", "warnings", "workflow"]);
863
861
  var nullableText = { type: ["string", "null"] };
862
+ var relationIdNameSchema = {
863
+ type: ["object", "null"],
864
+ additionalProperties: false,
865
+ required: ["id", "name", "value"],
866
+ properties: {
867
+ id: { type: "string" },
868
+ name: { type: "string" },
869
+ value: { type: "string", description: "\u540D\u79F0(ID)\uFF0C\u5199\u62A5\u9500\u5355\u6D4F\u89C8\u6309\u94AE\u65F6\u539F\u6837\u4F7F\u7528" }
870
+ }
871
+ };
872
+ var relationPreApprovalSchema = {
873
+ type: ["object", "null"],
874
+ additionalProperties: false,
875
+ required: ["requestId", "requestName", "value", "displayName", "createTime"],
876
+ properties: {
877
+ requestId: { type: "string", description: "\u4E8B\u524D\u7533\u8BF7\u6D41\u7A0B requestid" },
878
+ requestName: { type: "string", description: "\u4E8B\u524D\u7533\u8BF7\u6D41\u7A0B\u6807\u9898\uFF08\u5DF2\u53BB\u6389\u6D4F\u89C8\u6309\u94AE\u672B\u5C3E\u7684\u300C (\u76F8\u5173\u5BA2\u6237:\u2026)\u300D\u6458\u8981\uFF09" },
879
+ value: { type: "string", description: "{requestName}({requestId})\uFF0C\u5199\u660E\u7EC6\u300C\u76F8\u5173\u6D41\u7A0B\u300D\u65F6\u539F\u6837\u4F7F\u7528" },
880
+ displayName: { type: "string", description: "\u6D4F\u89C8\u6309\u94AE\u539F\u59CB\u5C55\u793A\u540D" },
881
+ createTime: nullableText
882
+ }
883
+ };
884
+ var relationGroupsSchema = arrayOf(objectSchema({
885
+ value: { type: "string" },
886
+ fids: arrayOf({ type: "string" })
887
+ }, ["value", "fids"]));
888
+ var relationSearchItemSchema = objectSchema({
889
+ id: { type: "string", description: "\u76F8\u5173\u5BA2\u6237 / \u76F8\u5173\u9879\u76EE ID\uFF0C\u767B\u8BB0\u65F6\u4F20 customerId / projectId" },
890
+ name: { type: "string", description: "\u76F8\u5173\u5BA2\u6237 / \u76F8\u5173\u9879\u76EE\u540D\u79F0\uFF0C\u767B\u8BB0\u65F6\u4F20 customerName / projectName" }
891
+ }, ["id", "name"]);
892
+ var relationSearchOutputSchema = objectSchema({
893
+ target: { type: "string", enum: ["customer", "project"] },
894
+ keywords: { type: "string" },
895
+ match: { type: "string", enum: ["unique", "multiple", "none"] },
896
+ items: arrayOf(relationSearchItemSchema),
897
+ selected: {
898
+ anyOf: [relationSearchItemSchema, { type: "null" }],
899
+ description: "\u53EA\u641C\u5230\u4E00\u6761\uFF0C\u6216\u6709\u4E00\u6761\u540D\u79F0\u4E0E keywords \u5B8C\u5168\u4E00\u81F4\u65F6\u7ED9\u51FA\uFF1B\u5426\u5219\u4E3A null\uFF0C\u8BA9\u7528\u6237\u4ECE items \u91CC\u9009"
900
+ },
901
+ workflow: workflowSchema
902
+ }, ["target", "keywords", "match", "items", "selected", "workflow"]);
903
+ var relationSaveOutputSchema = objectSchema({
904
+ saved: { type: "boolean", description: "\u5168\u90E8\u53D1\u7968\u90FD\u8FD4\u56DE\u300C\u5173\u8054\u6210\u529F\u300D\u65F6\u4E3A true" },
905
+ savedCount: { type: "integer" },
906
+ failedCount: { type: "integer" },
907
+ results: arrayOf(objectSchema({
908
+ fid: { type: "string" },
909
+ saved: { type: "boolean" },
910
+ message: { type: "string", description: "\u52A8\u4F5C\u6D41\u8FD4\u56DE\u7684 msg\uFF0C\u6216\u5931\u8D25\u539F\u56E0" }
911
+ }, ["fid", "saved", "message"])),
912
+ relation: objectSchema({
913
+ customerId: { type: "string" },
914
+ customerName: { type: "string" },
915
+ projectId: { type: "string" },
916
+ projectName: { type: "string" },
917
+ flowId: { type: "string" }
918
+ }, ["customerId", "customerName", "projectId", "projectName", "flowId"]),
919
+ workflow: workflowSchema
920
+ }, ["saved", "savedCount", "failedCount", "results", "relation", "workflow"]);
921
+ var relationListOutputSchema = objectSchema({
922
+ items: arrayOf(objectSchema({
923
+ fid: { type: "string" },
924
+ found: { type: "boolean", description: "\u4E0A\u4F20\u65F6\u767B\u8BB0\u8FC7\u5173\u8054\u4FE1\u606F\u4E3A true\uFF1B\u4E3A true \u4F46 project \u4E3A null \u8868\u793A\u5F53\u65F6\u6CA1\u586B\u9879\u76EE" },
925
+ customer: relationIdNameSchema,
926
+ project: relationIdNameSchema,
927
+ preApproval: relationPreApprovalSchema,
928
+ recordedAt: { ...nullableText, description: "\u767B\u8BB0\u65F6\u95F4" }
929
+ }, ["fid", "found", "customer", "project", "preApproval", "recordedAt"])),
930
+ groups: objectSchema({
931
+ customers: relationGroupsSchema,
932
+ projects: relationGroupsSchema,
933
+ preApprovals: relationGroupsSchema
934
+ }, ["customers", "projects", "preApprovals"]),
935
+ failed: arrayOf(objectSchema({ fid: { type: "string" }, error: { type: "string" } }, ["fid", "error"])),
936
+ summary: objectSchema({
937
+ requested: { type: "integer" },
938
+ found: { type: "integer" },
939
+ notFound: { type: "integer" },
940
+ failed: { type: "integer" }
941
+ }, ["requested", "found", "notFound", "failed"]),
942
+ workflow: workflowSchema
943
+ }, ["items", "groups", "failed", "summary", "workflow"]);
864
944
  var issuingContractsOutputSchema = objectSchema({
865
945
  cards: arrayOf(objectSchema({
866
946
  requestId: { type: "string", description: "\u5408\u540C\u5BA1\u6279\u6D41\u7A0B\u7684 requestId" },
@@ -968,34 +1048,16 @@ var invoiceOperations = [
968
1048
  },
969
1049
  outputSchema: ocrPreviewOutputSchema
970
1050
  },
971
- {
972
- name: "invoice.validate.preview",
973
- risk: "external-read",
974
- fixed: { flag: 100, is_save: 1, needLog: true },
975
- inputSchema: {
976
- type: "object",
977
- additionalProperties: false,
978
- properties: {
979
- fid: { type: "string", pattern: "^[1-9]\\d*$" },
980
- scope: { type: "string", enum: ["personal", "enterprise"] }
981
- },
982
- required: ["fid", "scope"]
983
- },
984
- outputSchema: validationPreviewOutputSchema
985
- },
986
1051
  {
987
1052
  name: "invoice.upload-and-validate",
988
1053
  risk: "read-with-upload",
989
- fixed: { ocr: 1, flag: 100, is_save: 1, needLog: true },
990
1054
  inputSchema: {
991
1055
  type: "object",
992
1056
  additionalProperties: false,
993
1057
  properties: {
994
1058
  file: { type: "string", minLength: 1 },
995
- url: { type: "string", format: "uri" },
996
- scope: { type: "string", enum: ["personal", "enterprise"] }
1059
+ url: { type: "string", format: "uri" }
997
1060
  },
998
- required: ["scope"],
999
1061
  oneOf: [{ required: ["file"] }, { required: ["url"] }]
1000
1062
  },
1001
1063
  outputSchema: uploadAndValidateOutputSchema
@@ -1293,6 +1355,89 @@ var invoiceOperations = [
1293
1355
  workflow: workflowSchema
1294
1356
  }, ["result", "data", "keywords", "match", "items", "workflow"])
1295
1357
  },
1358
+ {
1359
+ name: "invoice.reim.relation.search",
1360
+ risk: "read",
1361
+ fixed: {
1362
+ customer: {
1363
+ path: "/api/ebuilder/coms/nlist/getData",
1364
+ headers: { ebbusinessid: "1218181956452048911" },
1365
+ pageId: "1218181956452048911",
1366
+ compId: "c39b9e14c0034336adf9e9bc39aeed75",
1367
+ workflowId: "100003460000000060",
1368
+ isCreate: "1",
1369
+ filter: "\u5BA2\u6237\u8868\u300C\u540D\u79F0\u300D\u5B57\u6BB5 field_1173221220888062665 \u6A21\u7CCA\u5339\u914D keywords",
1370
+ output: "data.list[]\uFF1Aid \u2192 id\uFF0C1173221220888062665 \u2192 name"
1371
+ },
1372
+ project: {
1373
+ path: "/api/ebuilder/form/common/browser/data/ebuilder",
1374
+ quickSearchDatas: "field_1020275734718578690\uFF08\u9879\u76EE\u540D\u79F0\uFF09= keywords",
1375
+ formParam: { formId: "100003660000000007", layoutId: "925333107626672135", fieldId: "100003720000006720", module: "workflow" },
1376
+ output: "data.data[]\uFF1Aid \u2192 id\uFF0Ccontent \u2192 name\uFF1Bdisabled=true \u7684\u4E0D\u8FD4\u56DE"
1377
+ },
1378
+ pageSize: 20,
1379
+ note: "\u4E0A\u4F20\u53D1\u7968\u767B\u8BB0\u5173\u8054\u4FE1\u606F\u65F6\u7528\uFF0C\u4E0D\u9700\u8981\u62A5\u9500\u8868\u5355\uFF1B\u53EA\u4FDD\u7559\u6BCF\u6761\u7684 id \u548C\u540D\u79F0"
1380
+ },
1381
+ inputSchema: {
1382
+ type: "object",
1383
+ additionalProperties: false,
1384
+ properties: {
1385
+ target: { type: "string", enum: ["customer", "project"], description: "customer=\u76F8\u5173\u5BA2\u6237\uFF0Cproject=\u76F8\u5173\u9879\u76EE" },
1386
+ keywords: { type: "string", minLength: 1, description: "\u7528\u6237\u8BF4\u7684\u5BA2\u6237 / \u9879\u76EE\u540D\u79F0\u539F\u8BDD\uFF0C\u53EF\u4EE5\u662F\u6A21\u7CCA\u540D\u79F0" }
1387
+ },
1388
+ required: ["target", "keywords"]
1389
+ },
1390
+ outputSchema: relationSearchOutputSchema
1391
+ },
1392
+ {
1393
+ name: "invoice.reim.relation.save",
1394
+ risk: "write",
1395
+ fixed: {
1396
+ path: "/api/esb/server/event/triggerActionFlow",
1397
+ esbFlowId: "908258457763844096",
1398
+ moduleSource: "-1",
1399
+ customParams: "mainTable = {customerId, customerName, invoiceId(=fid), projectName, projectId, flowId}\uFF0C\u6CA1\u63D0\u4F9B\u7684\u9879\u4F20\u7A7A\u5B57\u7B26\u4E32\uFF1B\u6BCF\u5F20\u53D1\u7968\u89E6\u53D1\u4E00\u6B21",
1400
+ note: "\u5C3D\u529B\u800C\u4E3A\uFF1A\u5931\u8D25\u4E0D\u629B\u9519\u3001\u4E0D\u91CD\u8BD5\uFF0C\u53EA\u5728 results[].saved=false \u91CC\u8BF4\u660E\uFF1B\u52A8\u4F5C\u6D41\u8FD4\u56DE msg\u300C\u5173\u8054\u6210\u529F\u300D\u624D\u7B97\u4FDD\u5B58\u6210\u529F"
1401
+ },
1402
+ inputSchema: {
1403
+ type: "object",
1404
+ additionalProperties: false,
1405
+ properties: {
1406
+ fid: { ...positiveId, description: "\u5355\u5F20\u53D1\u7968 fid\uFF1B\u4E0E fids \u4E8C\u9009\u4E00" },
1407
+ fids: { ...positiveIdArray, description: "\u540C\u4E00\u6279\u4E0A\u4F20\u6210\u529F\u7684\u53D1\u7968 fid\uFF1B\u4E0E fid \u4E8C\u9009\u4E00" },
1408
+ customerId: { ...positiveId, description: "\u76F8\u5173\u5BA2\u6237 ID\uFF08invoice.reim.relation.search target=customer \u9009\u5B9A\u90A3\u6761\u7684 id\uFF09\uFF0C\u4E0E customerName \u540C\u65F6\u63D0\u4F9B" },
1409
+ customerName: { type: "string", minLength: 1, description: "\u76F8\u5173\u5BA2\u6237\u540D\u79F0\uFF0C\u4E0E customerId \u540C\u65F6\u63D0\u4F9B" },
1410
+ projectId: { ...positiveId, description: "\u76F8\u5173\u9879\u76EE ID\uFF08invoice.reim.relation.search target=project \u9009\u5B9A\u90A3\u6761\u7684 id\uFF09\uFF0C\u4E0E projectName \u540C\u65F6\u63D0\u4F9B" },
1411
+ projectName: { type: "string", minLength: 1, description: "\u76F8\u5173\u9879\u76EE\u540D\u79F0\uFF0C\u4E0E projectId \u540C\u65F6\u63D0\u4F9B" },
1412
+ flowId: { ...positiveId, description: "\u4E8B\u524D\u7533\u8BF7\u6D41\u7A0B\u7684 requestid\uFF08invoice.reim.requests.list \u8FD4\u56DE\uFF09" }
1413
+ },
1414
+ oneOf: [{ required: ["fid"] }, { required: ["fids"] }]
1415
+ },
1416
+ outputSchema: relationSaveOutputSchema
1417
+ },
1418
+ {
1419
+ name: "invoice.reim.relation.list",
1420
+ risk: "read",
1421
+ fixed: {
1422
+ path: "/api/ebuilder/form/eblist/getData",
1423
+ source: "\u53D1\u7968\u9644\u52A0\u4FE1\u606F\u8868\uFF08\u6309\u300C\u5355\u5B50\u53D1\u7968ID\u300D\u8FC7\u6EE4\uFF0C\u6BCF\u5F20\u53D1\u7968\u67E5\u4E00\u6B21\uFF09",
1424
+ headers: { ebbusinessid: "1336156118298222893" },
1425
+ pageId: "1336156118298222893",
1426
+ compId: "deb95f0098754d498843187dcbe50093",
1427
+ tableuid: "ef3603435af34e8aa635374c6610d8ab",
1428
+ note: "\u540C\u4E00\u5F20\u53D1\u7968\u767B\u8BB0\u8FC7\u591A\u6B21\u53D6 create_time \u6700\u65B0\u7684\u4E00\u6761\uFF1B\u5355\u5F20\u67E5\u8BE2\u5931\u8D25\u8BB0\u5728 failed \u91CC\uFF0C\u4E0D\u629B\u9519"
1429
+ },
1430
+ inputSchema: {
1431
+ type: "object",
1432
+ additionalProperties: false,
1433
+ properties: {
1434
+ fid: positiveId,
1435
+ fids: { ...positiveIdArray, description: "\u672C\u6B21\u62A5\u9500\u5DF2\u786E\u8BA4\u7684\u53D1\u7968 fid" }
1436
+ },
1437
+ oneOf: [{ required: ["fid"] }, { required: ["fids"] }]
1438
+ },
1439
+ outputSchema: relationListOutputSchema
1440
+ },
1296
1441
  {
1297
1442
  name: "invoice.reim.candidates.list",
1298
1443
  risk: "read",
@@ -1420,6 +1565,7 @@ var invoiceOperations = [
1420
1565
  ];
1421
1566
  var REIM_REFERENCE = "references/invoice-reim.md";
1422
1567
  var ISSUING_REFERENCE = "references/invoice-issuing-workflow.md";
1568
+ var UPLOAD_AND_VALIDATE_REFERENCE = "references/invoice-upload-and-validate.md";
1423
1569
  var invoiceRetiredOperations = [
1424
1570
  {
1425
1571
  name: "invoice.reim.form.structure",
@@ -1470,6 +1616,11 @@ var invoiceRetiredOperations = [
1470
1616
  name: "invoice.issuing.qys.list",
1471
1617
  replacement: "\u6539\u4E3A workflow.search \u67E5\u5408\u540C\u5BA1\u6279\u6D41\u7A0B \u2192 \u628A data.cards \u4F20\u7ED9 invoice.issuing.contracts.list \u5217\u51FA\u5F85\u5F00\u7968\u5408\u540C \u2192 \u9009\u5B9A\u540E\u7528 invoice.issuing.contract.detail \u53D6\u5BA2\u6237\u548C\u5408\u540C\u6587\u6863",
1472
1618
  reference: ISSUING_REFERENCE
1619
+ },
1620
+ {
1621
+ name: "invoice.validate.preview",
1622
+ replacement: "\u53D1\u7968\u6587\u4EF6\u6539\u7528 invoice.upload-and-validate\uFF0C\u4E00\u6B21\u5B8C\u6210\u4E0A\u4F20\u3001\u8BC6\u522B\u3001\u67E5\u9A8C\uFF1B\u7968\u5939\u91CC\u5DF2\u6709\u7684\u53D1\u7968\u4E0D\u518D\u5355\u72EC\u67E5\u9A8C",
1623
+ reference: UPLOAD_AND_VALIDATE_REFERENCE
1473
1624
  }
1474
1625
  ];
1475
1626
  var invoiceManifest = {
@@ -1682,9 +1833,8 @@ function normalizeFids(input) {
1682
1833
  if (input.fid !== void 0) return [asPositiveString(String(input.fid), "fid")];
1683
1834
  return normalizeIdList(input.fids, "fids");
1684
1835
  }
1685
- function reqBase({ numericTrace = false } = {}) {
1686
- const trace = Date.now();
1687
- return { trace: numericTrace ? trace : String(trace), dev: 1 };
1836
+ function reqBase() {
1837
+ return { trace: String(Date.now()), dev: 1 };
1688
1838
  }
1689
1839
  function canonicalJson(value) {
1690
1840
  if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
@@ -1833,21 +1983,6 @@ function preview(info, baseUrl) {
1833
1983
  ...baseUrl && fid ? { detailUrl: invoiceDetailUrl(baseUrl, fid) } : {}
1834
1984
  };
1835
1985
  }
1836
- function validationPreview(info, scope, targetFid, baseUrl) {
1837
- const p = info?.comm_info?.pro || {};
1838
- const item = preview(info, baseUrl);
1839
- return {
1840
- ...item,
1841
- fid: targetFid,
1842
- targetFid,
1843
- resultFid: item.fid,
1844
- scope,
1845
- validation: p.valid,
1846
- invoiceStatus: p.status,
1847
- saved: false,
1848
- ...baseUrl && targetFid ? { detailUrl: invoiceDetailUrl(baseUrl, targetFid) } : {}
1849
- };
1850
- }
1851
1986
  function workflow(name, state) {
1852
1987
  return { workflow: name, version: 1, state };
1853
1988
  }
@@ -1882,8 +2017,8 @@ function contentFor(typeName, number) {
1882
2017
  }
1883
2018
  function cents(value) {
1884
2019
  if (value === void 0 || value === null || value === "") return 0;
1885
- const text3 = String(value);
1886
- const match = /^(-?\d+)(?:\.(\d{1,2}))?$/u.exec(text3);
2020
+ const text5 = String(value);
2021
+ const match = /^(-?\d+)(?:\.(\d{1,2}))?$/u.exec(text5);
1887
2022
  if (!match) return null;
1888
2023
  const whole = Number(match[1]);
1889
2024
  const fraction = Number((match[2] || "").padEnd(2, "0"));
@@ -2257,15 +2392,15 @@ function epochSeconds(value, name, options = {}) {
2257
2392
  if (Number.isInteger(value) && value >= 0) return value;
2258
2393
  throw invoiceValidationError("input_invalid", `${name} \u5FC5\u987B\u662F YYYY-MM-DD \u6216\u79D2\u7EA7\u65F6\u95F4\u6233`);
2259
2394
  }
2260
- const text3 = typeof value === "string" ? value.trim() : "";
2261
- if (DATE_PATTERN.test(text3)) {
2395
+ const text5 = typeof value === "string" ? value.trim() : "";
2396
+ if (DATE_PATTERN.test(text5)) {
2262
2397
  const clock = options.endOfDay ? "T23:59:59+08:00" : "T00:00:00+08:00";
2263
- const seconds = Math.floor(Date.parse(`${text3}${clock}`) / 1e3);
2398
+ const seconds = Math.floor(Date.parse(`${text5}${clock}`) / 1e3);
2264
2399
  if (!Number.isFinite(seconds)) throw invoiceValidationError("input_invalid", `${name} \u4E0D\u662F\u6709\u6548\u65E5\u671F`);
2265
2400
  return seconds;
2266
2401
  }
2267
- if (/^\d+$/u.test(text3)) {
2268
- const seconds = Number(text3);
2402
+ if (/^\d+$/u.test(text5)) {
2403
+ const seconds = Number(text5);
2269
2404
  if (Number.isSafeInteger(seconds)) return seconds;
2270
2405
  }
2271
2406
  throw invoiceValidationError("input_invalid", `${name} \u5FC5\u987B\u662F YYYY-MM-DD \u6216\u79D2\u7EA7\u65F6\u95F4\u6233`);
@@ -2815,8 +2950,8 @@ var CUSTOMER_FIELD_TITLES = ["\u5BA2\u6237\u540D\u79F0", "\u6700\u7EC8\u7528\u62
2815
2950
  var CONTRACT_FILE_FIELD_TITLE = "\u5408\u540C\u6B63\u6587\u53CA\u9644\u4EF6";
2816
2951
  function textValue(value) {
2817
2952
  if (value === void 0 || value === null) return null;
2818
- const text3 = String(value).trim();
2819
- return text3 === "" ? null : text3;
2953
+ const text5 = String(value).trim();
2954
+ return text5 === "" ? null : text5;
2820
2955
  }
2821
2956
  function mainFields(data) {
2822
2957
  const details = data?.formData?.dataDetails;
@@ -2944,8 +3079,8 @@ function contractFilter(requestId) {
2944
3079
  }
2945
3080
  function textValue2(value) {
2946
3081
  if (value === void 0 || value === null) return null;
2947
- const text3 = String(value).trim();
2948
- return text3 === "" ? null : text3;
3082
+ const text5 = String(value).trim();
3083
+ return text5 === "" ? null : text5;
2949
3084
  }
2950
3085
  function firstText2(rows, field) {
2951
3086
  for (const row of rows) {
@@ -2963,12 +3098,12 @@ function sellerName(rows) {
2963
3098
  return null;
2964
3099
  }
2965
3100
  function amountCents(value, requestId) {
2966
- const text3 = textValue2(value)?.replace(/,/g, "") ?? null;
2967
- if (text3 === null) return 0;
2968
- if (!/^-?\d+(?:\.\d+)?$/u.test(text3)) {
2969
- throw new InvoiceCliError("api", "issuing_amount_invalid", `\u5408\u540C\u6D41\u7A0B ${requestId} \u7684\u5F00\u7968\u91D1\u989D\u4E0D\u662F\u6570\u5B57\uFF1A${text3}`, { exitCode: 1 });
3101
+ const text5 = textValue2(value)?.replace(/,/g, "") ?? null;
3102
+ if (text5 === null) return 0;
3103
+ if (!/^-?\d+(?:\.\d+)?$/u.test(text5)) {
3104
+ throw new InvoiceCliError("api", "issuing_amount_invalid", `\u5408\u540C\u6D41\u7A0B ${requestId} \u7684\u5F00\u7968\u91D1\u989D\u4E0D\u662F\u6570\u5B57\uFF1A${text5}`, { exitCode: 1 });
2970
3105
  }
2971
- return Math.round(Number(text3) * 100);
3106
+ return Math.round(Number(text5) * 100);
2972
3107
  }
2973
3108
  function formatCents(cents2) {
2974
3109
  return (cents2 / 100).toFixed(2);
@@ -3159,12 +3294,12 @@ function optionalString(value, name) {
3159
3294
  return asNonEmptyString(value, name);
3160
3295
  }
3161
3296
  function optionalDate(value, name) {
3162
- const text3 = optionalString(value, name);
3163
- if (text3 === void 0) return void 0;
3164
- if (!/^\d{4}-\d{2}-\d{2}$/u.test(text3)) {
3297
+ const text5 = optionalString(value, name);
3298
+ if (text5 === void 0) return void 0;
3299
+ if (!/^\d{4}-\d{2}-\d{2}$/u.test(text5)) {
3165
3300
  throw invoiceValidationError("input_invalid", `${name} \u5FC5\u987B\u662F YYYY-MM-DD`);
3166
3301
  }
3167
- return text3;
3302
+ return text5;
3168
3303
  }
3169
3304
  function formatUtcDate(date) {
3170
3305
  const y = date.getUTCFullYear();
@@ -3235,8 +3370,8 @@ function projectRequestListResult(value) {
3235
3370
  return { ...record, data: record.data.map(projectRequestListItem) };
3236
3371
  }
3237
3372
  var UNSAFE_JSON_INTEGER_ID = /("id"\s*:\s*)(-?\d{16,})(?=\s*[,}\]])/g;
3238
- function quoteEmployeeIdsInJsonText(text3) {
3239
- return text3.replace(UNSAFE_JSON_INTEGER_ID, '$1"$2"');
3373
+ function quoteEmployeeIdsInJsonText(text5) {
3374
+ return text5.replace(UNSAFE_JSON_INTEGER_ID, '$1"$2"');
3240
3375
  }
3241
3376
  function employeeIdString(value) {
3242
3377
  if (typeof value === "bigint") return value.toString();
@@ -3558,6 +3693,402 @@ var InvoiceReimCandidatesListOperation = class {
3558
3693
  }
3559
3694
  };
3560
3695
 
3696
+ // src/shortcuts/invoice/operations/reim-relation.ts
3697
+ var RELATION_SAVE_PATH = "/api/esb/server/event/triggerActionFlow";
3698
+ var RELATION_SAVE_FLOW_ID = "908258457763844096";
3699
+ var RELATION_SAVE_TIMEOUT_MS = 15e3;
3700
+ var RELATION_SAVED_MESSAGE = "\u5173\u8054\u6210\u529F";
3701
+ var RELATION_LIST_PATH = "/api/ebuilder/form/eblist/getData";
3702
+ var RELATION_PAGE_ID = "1336156118298222893";
3703
+ var RELATION_COMP_ID = "deb95f0098754d498843187dcbe50093";
3704
+ var RELATION_TABLE_UID = "ef3603435af34e8aa635374c6610d8ab";
3705
+ var RELATION_PAGE_SIZE = 10;
3706
+ var RELATION_CONCURRENCY = 4;
3707
+ var RELATION_FIELD = {
3708
+ fid: "1336536987380547612",
3709
+ customerId: "1336526894274510993",
3710
+ customerName: "1336526894274510994",
3711
+ projectId: "1336526894274510991",
3712
+ projectName: "1336526894274510992",
3713
+ preApproval: "1336156560590790875"
3714
+ };
3715
+ var RELATION_SEARCH_PAGE_SIZE = 20;
3716
+ var CUSTOMER_SEARCH_PATH = "/api/ebuilder/coms/nlist/getData";
3717
+ var CUSTOMER_SEARCH_PAGE_ID = "1218181956452048911";
3718
+ var CUSTOMER_SEARCH_COMP_ID = "c39b9e14c0034336adf9e9bc39aeed75";
3719
+ var CUSTOMER_SEARCH_WORKFLOW_ID = "100003460000000060";
3720
+ var CUSTOMER_OBJ_ID = "1173221220888059964";
3721
+ var CUSTOMER_NAME_FIELD = "1173221220888062665";
3722
+ var PROJECT_SEARCH_PATH = "/api/ebuilder/form/common/browser/data/ebuilder";
3723
+ var PROJECT_NAME_FIELD = "1020275734718578690";
3724
+ var PROJECT_FORM_PARAM = JSON.stringify({
3725
+ formId: "100003660000000007",
3726
+ layoutId: "925333107626672135",
3727
+ fieldId: "100003720000006720",
3728
+ filterItems: [],
3729
+ module: "workflow",
3730
+ dataDetails: [],
3731
+ templateId: ""
3732
+ });
3733
+ var BROWSE_SUMMARY_SUFFIX = /\s+\([^()]*[::][^()]*\)\s*$/u;
3734
+ function asRecord3(value) {
3735
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
3736
+ }
3737
+ function text3(value) {
3738
+ if (value === void 0 || value === null || typeof value === "object") return "";
3739
+ return String(value).trim();
3740
+ }
3741
+ function errorMessage(error) {
3742
+ return error instanceof Error ? error.message : String(error);
3743
+ }
3744
+ function optionalText(value, name) {
3745
+ if (value === void 0 || value === null || value === "") return "";
3746
+ if (typeof value !== "string" || !value.trim()) throw invoiceValidationError("input_invalid", `${name} \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32`);
3747
+ return value.trim();
3748
+ }
3749
+ function optionalId(value, name) {
3750
+ if (value === void 0 || value === null || value === "") return "";
3751
+ return asPositiveString(typeof value === "number" ? String(value) : value, name);
3752
+ }
3753
+ function idNamePair(input, idKey, nameKey) {
3754
+ const id = optionalId(input[idKey], idKey);
3755
+ const name = optionalText(input[nameKey], nameKey);
3756
+ if (Boolean(id) !== Boolean(name)) {
3757
+ throw invoiceValidationError("input_invalid", `${idKey} \u4E0E ${nameKey} \u5FC5\u987B\u540C\u65F6\u63D0\u4F9B`);
3758
+ }
3759
+ return [id, name];
3760
+ }
3761
+ function relationValues(input) {
3762
+ const [customerId, customerName] = idNamePair(input, "customerId", "customerName");
3763
+ const [projectId, projectName] = idNamePair(input, "projectId", "projectName");
3764
+ const flowId = optionalId(input.flowId, "flowId");
3765
+ if (!customerId && !projectId && !flowId) {
3766
+ throw invoiceValidationError("input_invalid", "\u76F8\u5173\u5BA2\u6237\u3001\u76F8\u5173\u9879\u76EE\u3001\u4E8B\u524D\u7533\u8BF7\uFF08flowId\uFF09\u81F3\u5C11\u63D0\u4F9B\u4E00\u9879");
3767
+ }
3768
+ return { customerId, customerName, projectId, projectName, flowId };
3769
+ }
3770
+ async function mapInOrder(items, fn) {
3771
+ const results = new Array(items.length);
3772
+ if (items.length === 0) return results;
3773
+ results[0] = await fn(items[0]);
3774
+ let next = 1;
3775
+ const workers = Array.from({ length: Math.min(RELATION_CONCURRENCY, items.length - 1) }, async () => {
3776
+ while (next < items.length) {
3777
+ const index = next;
3778
+ next += 1;
3779
+ results[index] = await fn(items[index]);
3780
+ }
3781
+ });
3782
+ await Promise.all(workers);
3783
+ return results;
3784
+ }
3785
+ function saveOutcome(value) {
3786
+ const record = asRecord3(value);
3787
+ const message = text3(asRecord3(asRecord3(asRecord3(asRecord3(record.actionData).responseData).customData).mainTable).msg);
3788
+ if (Number(record.resultCode) === 200 && message.includes(RELATION_SAVED_MESSAGE)) return { saved: true, message };
3789
+ return {
3790
+ saved: false,
3791
+ message: message || text3(record.resultMsg) || `\u52A8\u4F5C\u6D41\u6CA1\u6709\u8FD4\u56DE\u300C${RELATION_SAVED_MESSAGE}\u300D\uFF08resultCode=${text3(record.resultCode) || "\u65E0"}\uFF09`
3792
+ };
3793
+ }
3794
+ var InvoiceReimRelationSaveOperation = class {
3795
+ name = "invoice.reim.relation.save";
3796
+ async execute(input, { host }) {
3797
+ const fids = normalizeFids(input);
3798
+ const values = relationValues(input);
3799
+ const results = await mapInOrder(fids, async (fid) => {
3800
+ try {
3801
+ const result = await host.invoiceRequest({
3802
+ path: RELATION_SAVE_PATH,
3803
+ method: "POST",
3804
+ headers: { "X-Requested-With": "XMLHttpRequest" },
3805
+ body: {
3806
+ customParams: {
3807
+ mainTable: {
3808
+ customerId: values.customerId,
3809
+ customerName: values.customerName,
3810
+ invoiceId: fid,
3811
+ projectName: values.projectName,
3812
+ projectId: values.projectId,
3813
+ flowId: values.flowId
3814
+ }
3815
+ },
3816
+ moduleSource: "-1",
3817
+ esbFlowId: RELATION_SAVE_FLOW_ID
3818
+ },
3819
+ timeoutMs: RELATION_SAVE_TIMEOUT_MS,
3820
+ operation: this.name
3821
+ });
3822
+ return { fid, ...saveOutcome(result) };
3823
+ } catch (error) {
3824
+ return { fid, saved: false, message: errorMessage(error) };
3825
+ }
3826
+ });
3827
+ const savedCount = results.filter((item) => item.saved).length;
3828
+ const state = savedCount === results.length ? "COMPLETE" : "PARTIAL";
3829
+ return {
3830
+ status: state,
3831
+ data: {
3832
+ saved: savedCount === results.length,
3833
+ savedCount,
3834
+ failedCount: results.length - savedCount,
3835
+ results,
3836
+ relation: values,
3837
+ workflow: workflow(this.name, state)
3838
+ }
3839
+ };
3840
+ }
3841
+ };
3842
+ function relationFilter(fid) {
3843
+ return [
3844
+ {
3845
+ conditionType: "or",
3846
+ dataType: "field",
3847
+ id: "a695d8dd7e0044bd872c51aa7911aa3d",
3848
+ conditionComId: `${RELATION_COMP_ID}_quick_EXCLUDECACHE`,
3849
+ filterFields: [{
3850
+ compId: RELATION_COMP_ID,
3851
+ compType: "Text",
3852
+ dataset: {
3853
+ isPhysical: true,
3854
+ ebuilderDataConfig: { dataSetup: {}, type: "FORM" },
3855
+ detailTable: false,
3856
+ groupId: "weaver-ebuilder-form-service",
3857
+ usage: "all",
3858
+ appId: "1120921709084680312",
3859
+ id: "1336156113810318140",
3860
+ text: "\u53D1\u7968\u9644\u52A0\u4FE1\u606F\u8868",
3861
+ type: "LOGIC",
3862
+ objType: "physical"
3863
+ },
3864
+ fieldName: `field_${RELATION_FIELD.fid}`,
3865
+ id: RELATION_FIELD.fid,
3866
+ objId: "1336156113810318140",
3867
+ type: "String",
3868
+ text: "\u5355\u5B50\u53D1\u7968ID"
3869
+ }],
3870
+ value: fid
3871
+ },
3872
+ {
3873
+ conditionComId: `${RELATION_COMP_ID}_filter_EXCLUDECACHE`,
3874
+ conditionType: "and",
3875
+ dataType: "classification",
3876
+ id: "a8c660ee7bf942148dc44efd5ac498d0",
3877
+ useConfig: true
3878
+ }
3879
+ ];
3880
+ }
3881
+ function idNameOf(row, idField, nameField) {
3882
+ const id = text3(row[idField]);
3883
+ if (!/^\d+$/u.test(id)) return null;
3884
+ const name = text3(row[nameField]);
3885
+ return { id, name, value: name ? `${name}(${id})` : id };
3886
+ }
3887
+ function stripBrowseSummary(name) {
3888
+ return name.replace(BROWSE_SUMMARY_SUFFIX, "").trim();
3889
+ }
3890
+ function preApprovalOf(value) {
3891
+ const item = asRecord3(Array.isArray(value) ? value[0] : value);
3892
+ const requestId = text3(item.id);
3893
+ if (!/^\d+$/u.test(requestId)) return null;
3894
+ const displayName = text3(item.name);
3895
+ const requestName = stripBrowseSummary(displayName);
3896
+ return {
3897
+ requestId,
3898
+ requestName,
3899
+ value: requestName ? `${requestName}(${requestId})` : requestId,
3900
+ displayName,
3901
+ createTime: text3(asRecord3(item.custom).createDateTime) || null
3902
+ };
3903
+ }
3904
+ function relationItemFromRows(fid, rows) {
3905
+ const matched = rows.map(asRecord3).filter((row2) => text3(row2[RELATION_FIELD.fid]) === fid).sort((a, b) => text3(b.create_time).localeCompare(text3(a.create_time)));
3906
+ const row = matched[0];
3907
+ if (!row) return { fid, found: false, customer: null, project: null, preApproval: null, recordedAt: null };
3908
+ return {
3909
+ fid,
3910
+ found: true,
3911
+ customer: idNameOf(row, RELATION_FIELD.customerId, RELATION_FIELD.customerName),
3912
+ project: idNameOf(row, RELATION_FIELD.projectId, RELATION_FIELD.projectName),
3913
+ preApproval: preApprovalOf(row[RELATION_FIELD.preApproval]),
3914
+ recordedAt: text3(row.create_time) || null
3915
+ };
3916
+ }
3917
+ function groupByValue(items, pick) {
3918
+ const groups = /* @__PURE__ */ new Map();
3919
+ for (const item of items) {
3920
+ const value = pick(item)?.value;
3921
+ if (!value) continue;
3922
+ groups.set(value, [...groups.get(value) ?? [], item.fid]);
3923
+ }
3924
+ return [...groups.entries()].map(([value, fids]) => ({ value, fids }));
3925
+ }
3926
+ async function relationRows(host, fid, operation) {
3927
+ const result = await host.invoiceMultipartRequest({
3928
+ path: RELATION_LIST_PATH,
3929
+ method: "POST",
3930
+ headers: { ebbusinessid: RELATION_PAGE_ID },
3931
+ fields: {
3932
+ filter: relationFilter(fid),
3933
+ compId: RELATION_COMP_ID,
3934
+ pageId: RELATION_PAGE_ID,
3935
+ pageNo: "1",
3936
+ pageSize: String(RELATION_PAGE_SIZE),
3937
+ tableuid: RELATION_TABLE_UID
3938
+ },
3939
+ operation
3940
+ });
3941
+ assertBusinessSuccess(result, "reim_relation_query_failed", `\u67E5\u8BE2\u53D1\u7968 ${fid} \u7684\u5173\u8054\u4FE1\u606F\u5931\u8D25`);
3942
+ const list = asRecord3(asRecord3(result).data).list;
3943
+ if (!Array.isArray(list)) throw new Error(`\u53D1\u7968 ${fid} \u7684\u5173\u8054\u4FE1\u606F\u8FD4\u56DE\u7F3A\u5C11 data.list`);
3944
+ return list;
3945
+ }
3946
+ function relationSearchTarget(value) {
3947
+ if (value === "customer" || value === "project") return value;
3948
+ throw invoiceValidationError("input_invalid", "target \u53EA\u80FD\u662F customer\uFF08\u76F8\u5173\u5BA2\u6237\uFF09\u6216 project\uFF08\u76F8\u5173\u9879\u76EE\uFF09");
3949
+ }
3950
+ function customerFilter(keywords) {
3951
+ return [
3952
+ {
3953
+ conditionType: "or",
3954
+ dataType: "field",
3955
+ id: "d030a0a7b33e48e697277d30086126dc",
3956
+ conditionComId: `${CUSTOMER_SEARCH_COMP_ID}_quick_EXCLUDECACHE`,
3957
+ filterFields: [{
3958
+ compId: CUSTOMER_SEARCH_COMP_ID,
3959
+ compType: "Text",
3960
+ dataset: {
3961
+ isPhysical: true,
3962
+ ebuilderDataConfig: { dataSetup: {}, type: "FORM" },
3963
+ detailTable: false,
3964
+ groupId: "weaver-ebuilder-form-service",
3965
+ usage: "all",
3966
+ appId: "980180677416657173",
3967
+ id: CUSTOMER_OBJ_ID,
3968
+ text: "\u5BA2\u6237",
3969
+ type: "LOGIC",
3970
+ objType: "physical"
3971
+ },
3972
+ fieldName: `field_${CUSTOMER_NAME_FIELD}`,
3973
+ id: CUSTOMER_NAME_FIELD,
3974
+ objId: CUSTOMER_OBJ_ID,
3975
+ type: "String",
3976
+ text: "\u540D\u79F0"
3977
+ }],
3978
+ value: keywords
3979
+ },
3980
+ {
3981
+ conditionComId: `${CUSTOMER_SEARCH_COMP_ID}_filter_EXCLUDECACHE`,
3982
+ conditionType: "and",
3983
+ dataType: "classification",
3984
+ id: "f27488c792f44756b7ef1065f7735fc1",
3985
+ useConfig: true
3986
+ }
3987
+ ];
3988
+ }
3989
+ async function searchCustomers(host, keywords, operation) {
3990
+ const result = await host.invoiceMultipartRequest({
3991
+ path: CUSTOMER_SEARCH_PATH,
3992
+ method: "POST",
3993
+ headers: { ebbusinessid: CUSTOMER_SEARCH_PAGE_ID },
3994
+ fields: {
3995
+ workflowId: CUSTOMER_SEARCH_WORKFLOW_ID,
3996
+ isCreate: "1",
3997
+ filter: customerFilter(keywords),
3998
+ compId: CUSTOMER_SEARCH_COMP_ID,
3999
+ pageId: CUSTOMER_SEARCH_PAGE_ID,
4000
+ pageNo: "1",
4001
+ pageSize: String(RELATION_SEARCH_PAGE_SIZE)
4002
+ },
4003
+ operation
4004
+ });
4005
+ assertBusinessSuccess(result, "reim_relation_search_failed", "\u641C\u7D22\u76F8\u5173\u5BA2\u6237\u5931\u8D25");
4006
+ const list = asRecord3(asRecord3(result).data).list;
4007
+ return (Array.isArray(list) ? list : []).map((row) => {
4008
+ const record = asRecord3(row);
4009
+ return { id: text3(record.id), name: text3(record[CUSTOMER_NAME_FIELD]) };
4010
+ });
4011
+ }
4012
+ async function searchProjects(host, keywords, operation) {
4013
+ const result = await host.invoiceRequest({
4014
+ path: PROJECT_SEARCH_PATH,
4015
+ method: "POST",
4016
+ body: {
4017
+ browserMultiple: false,
4018
+ current: 1,
4019
+ pageSize: RELATION_SEARCH_PAGE_SIZE,
4020
+ quickSearchDatas: { [`field_${PROJECT_NAME_FIELD}`]: keywords },
4021
+ formParam: PROJECT_FORM_PARAM
4022
+ },
4023
+ operation
4024
+ });
4025
+ assertBusinessSuccess(result, "reim_relation_search_failed", "\u641C\u7D22\u76F8\u5173\u9879\u76EE\u5931\u8D25");
4026
+ const rows = asRecord3(asRecord3(result).data).data;
4027
+ return (Array.isArray(rows) ? rows : []).map(asRecord3).filter((row) => row.disabled !== true).map((row) => ({ id: text3(row.id), name: text3(row.content) || text3(row[PROJECT_NAME_FIELD]) }));
4028
+ }
4029
+ function uniqueValidItems(items) {
4030
+ const seen = /* @__PURE__ */ new Set();
4031
+ return items.filter((item) => {
4032
+ if (!/^\d+$/u.test(item.id) || !item.name || seen.has(item.id)) return false;
4033
+ seen.add(item.id);
4034
+ return true;
4035
+ });
4036
+ }
4037
+ var InvoiceReimRelationSearchOperation = class {
4038
+ name = "invoice.reim.relation.search";
4039
+ async execute(input, { host }) {
4040
+ const target = relationSearchTarget(input.target);
4041
+ const keywords = optionalText(input.keywords, "keywords");
4042
+ if (!keywords) throw invoiceValidationError("input_invalid", "keywords \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32");
4043
+ const found = target === "customer" ? await searchCustomers(host, keywords, this.name) : await searchProjects(host, keywords, this.name);
4044
+ const items = uniqueValidItems(found);
4045
+ const exact = items.filter((item) => item.name === keywords);
4046
+ const match = items.length === 0 ? "none" : items.length === 1 ? "unique" : "multiple";
4047
+ return {
4048
+ status: "COMPLETE",
4049
+ data: {
4050
+ target,
4051
+ keywords,
4052
+ match,
4053
+ items,
4054
+ selected: items.length === 1 ? items[0] : exact.length === 1 ? exact[0] : null,
4055
+ workflow: workflow(this.name, "COMPLETE")
4056
+ }
4057
+ };
4058
+ }
4059
+ };
4060
+ var InvoiceReimRelationListOperation = class {
4061
+ name = "invoice.reim.relation.list";
4062
+ async execute(input, { host }) {
4063
+ const fids = normalizeFids(input);
4064
+ const queried = await mapInOrder(fids, async (fid) => {
4065
+ try {
4066
+ return { ok: true, item: relationItemFromRows(fid, await relationRows(host, fid, this.name)) };
4067
+ } catch (error) {
4068
+ return { ok: false, failure: { fid, error: errorMessage(error) } };
4069
+ }
4070
+ });
4071
+ const items = queried.flatMap((entry) => entry.ok ? [entry.item] : []);
4072
+ const failed = queried.flatMap((entry) => entry.ok ? [] : [entry.failure]);
4073
+ const found = items.filter((item) => item.found).length;
4074
+ const state = failed.length ? "PARTIAL" : "COMPLETE";
4075
+ return {
4076
+ status: state,
4077
+ data: {
4078
+ items,
4079
+ groups: {
4080
+ customers: groupByValue(items, (item) => item.customer),
4081
+ projects: groupByValue(items, (item) => item.project),
4082
+ preApprovals: groupByValue(items, (item) => item.preApproval)
4083
+ },
4084
+ failed,
4085
+ summary: { requested: fids.length, found, notFound: items.length - found, failed: failed.length },
4086
+ workflow: workflow(this.name, state)
4087
+ }
4088
+ };
4089
+ }
4090
+ };
4091
+
3561
4092
  // src/shortcuts/invoice/operations/reim-subsidy.ts
3562
4093
  var SUBSIDY_SUBMIT_PATH = "/api/secondev/fna/expense/reimbursement/aiCreateWf";
3563
4094
  var DEFAULT_CUSTOMER_ID = "100504500000311504";
@@ -3565,13 +4096,13 @@ function longId(id) {
3565
4096
  const rawJSON = JSON.rawJSON;
3566
4097
  return typeof rawJSON === "function" ? rawJSON(id) : id;
3567
4098
  }
3568
- function optionalId(value, name) {
4099
+ function optionalId2(value, name) {
3569
4100
  return value === void 0 || value === null || value === "" ? "" : asPositiveString(value, name);
3570
4101
  }
3571
4102
  function amountCents2(value, name) {
3572
4103
  if (value === void 0 || value === null || value === "") return null;
3573
- const text3 = typeof value === "number" ? String(value) : value;
3574
- const match = typeof text3 === "string" ? /^(\d+)(?:\.(\d{1,2}))?$/u.exec(text3.trim()) : null;
4104
+ const text5 = typeof value === "number" ? String(value) : value;
4105
+ const match = typeof text5 === "string" ? /^(\d+)(?:\.(\d{1,2}))?$/u.exec(text5.trim()) : null;
3575
4106
  const cents2 = match ? Number(match[1]) * 100 + Number((match[2] ?? "").padEnd(2, "0")) : NaN;
3576
4107
  if (!Number.isSafeInteger(cents2) || cents2 <= 0) {
3577
4108
  throw invoiceValidationError("input_invalid", `${name} \u5FC5\u987B\u662F\u5927\u4E8E 0\u3001\u6700\u591A\u4E24\u4F4D\u5C0F\u6570\u7684\u91D1\u989D`);
@@ -3606,8 +4137,8 @@ var InvoiceReimSubsidySubmitOperation = class {
3606
4137
  const reason = asNonEmptyString(input.reason, "reason");
3607
4138
  const relatedProcessId = asPositiveString(input.relatedProcessId, "relatedProcessId");
3608
4139
  const invoices = normalizeInvoices(input.invoices);
3609
- const customerId = optionalId(input.customerId, "customerId") || DEFAULT_CUSTOMER_ID;
3610
- const projectId = optionalId(input.projectId, "projectId");
4140
+ const customerId = optionalId2(input.customerId, "customerId") || DEFAULT_CUSTOMER_ID;
4141
+ const projectId = optionalId2(input.projectId, "projectId");
3611
4142
  const allowanceCents = amountCents2(input.monthlyAllowance, "monthlyAllowance");
3612
4143
  let remainingCents = allowanceCents ?? Number.POSITIVE_INFINITY;
3613
4144
  const details = [];
@@ -3819,120 +4350,115 @@ var InvoiceUploadOperation = class {
3819
4350
  };
3820
4351
 
3821
4352
  // src/shortcuts/invoice/operations/upload-and-validate.ts
4353
+ var EXT_NOISE_KEYS = /* @__PURE__ */ new Set([
4354
+ "totalBig",
4355
+ "hdlist",
4356
+ "corp_seal",
4357
+ "company_seal_mark",
4358
+ "agent_mark",
4359
+ "form_type",
4360
+ "code_confirm",
4361
+ "vehicle_mark"
4362
+ ]);
4363
+ function asRecord4(value) {
4364
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
4365
+ }
4366
+ function text4(value) {
4367
+ return value === void 0 || value === null ? "" : String(value).trim();
4368
+ }
4369
+ function compact(value) {
4370
+ if (value === null || value === void 0) return void 0;
4371
+ if (typeof value === "string") return value.trim() ? value : void 0;
4372
+ if (Array.isArray(value)) {
4373
+ const items = value.map(compact).filter((item) => item !== void 0);
4374
+ return items.length ? items : void 0;
4375
+ }
4376
+ if (typeof value === "object") {
4377
+ const entries = Object.entries(value).map(([key, item]) => [key, compact(item)]).filter(([, item]) => item !== void 0);
4378
+ return entries.length ? Object.fromEntries(entries) : void 0;
4379
+ }
4380
+ return value;
4381
+ }
4382
+ function usefulExt(rawExt, cname) {
4383
+ const ext = { ...parseInvoiceExt(rawExt) };
4384
+ for (const key of EXT_NOISE_KEYS) delete ext[key];
4385
+ for (const key of ["title", "category"]) {
4386
+ if (text4(ext[key]) === cname) delete ext[key];
4387
+ }
4388
+ return asRecord4(compact(ext));
4389
+ }
4390
+ function party(value) {
4391
+ const record = asRecord4(value);
4392
+ return { company: text4(record.company), tcode: text4(record.tcode) };
4393
+ }
4394
+ function invoiceResult(item, baseUrl) {
4395
+ const entry = asRecord4(item);
4396
+ const info = asRecord4(entry.info);
4397
+ const comm = asRecord4(info.comm_info);
4398
+ const pro = asRecord4(comm.pro);
4399
+ const price = asRecord4(comm.price);
4400
+ const ret = asRecord4(entry.ret);
4401
+ const fid = text4(info.fid ?? info.id);
4402
+ const cname = text4(pro.cname);
4403
+ const kind = text4(pro.kind);
4404
+ return {
4405
+ fid,
4406
+ code: text4(info.code),
4407
+ number: text4(info.number),
4408
+ cname,
4409
+ type: numberOrZero(pro.type),
4410
+ ...kind ? { kind } : {},
4411
+ date: text4(pro.date),
4412
+ amount: text4(price.amount),
4413
+ total: text4(price.total),
4414
+ dtax: text4(price.dtax),
4415
+ buyer: party(comm.buyer),
4416
+ payer: party(comm.payer),
4417
+ ext: usefulExt(info.ext, cname),
4418
+ ret: { ret: ret.ret, message: text4(ret.message) },
4419
+ validated: ret.ret === 0,
4420
+ ...fid ? { detailUrl: invoiceDetailUrl(baseUrl, fid) } : {}
4421
+ };
4422
+ }
3822
4423
  var InvoiceUploadAndValidateOperation = class {
3823
4424
  name = "invoice.upload-and-validate";
3824
4425
  async execute(input, { host }) {
3825
- const scope = normalizeScope(input.scope);
4426
+ const source = await importSource(input);
3826
4427
  const session = await host.getSession();
3827
- let upload;
4428
+ const fileName = source.kind === "file" ? source.file.name : source.url;
4429
+ let result;
3828
4430
  try {
3829
- upload = await uploadInvoiceFile(input, host, { ocr: true });
3830
- } catch (error) {
3831
- throw new InvoiceCliError("api", "upload_failed", `\u4E0A\u4F20\u5931\u8D25\uFF1A${error.message}`, {
3832
- details: { stage: "upload" },
3833
- exitCode: 1
4431
+ result = await host.invoiceMultipartRequest({
4432
+ path: "/api/inc/biz/addInvoiceByFile",
4433
+ fields: source.fields,
4434
+ file: source.kind === "file" ? source.file : void 0,
4435
+ timeoutMs: 9e4
3834
4436
  });
3835
- }
3836
- let ocr;
3837
- try {
3838
- ocr = await previewOcr(upload, host);
3839
4437
  } catch (error) {
3840
- const cause = toErrorEnvelope(error);
3841
- throw new InvoiceCliError("partial", "artifact_uploaded", `\u6587\u4EF6\u5DF2\u4E0A\u4F20\u4F46 OCR \u5931\u8D25\uFF1A${cause.message}`, {
3842
- code: cause.code,
3843
- partialData: { upload, workflow: workflow(this.name, "OCR_FAILED") },
3844
- details: { stage: "ocr", cause },
3845
- exitCode: 11
3846
- });
3847
- }
3848
- const validations = [];
3849
- const validationErrors = [];
3850
- for (const item of ocr.invoices) {
3851
- const info = item?.info;
3852
- const fid = info?.fid ?? info?.id;
3853
- if (!fid) {
3854
- validationErrors.push({ fid: null, error: "OCR \u7ED3\u679C\u4E2D\u7F3A\u5C11 fid" });
3855
- continue;
3856
- }
3857
- try {
3858
- const detail = await getDetail({ fid: String(fid) }, host);
3859
- const detailData = detailInfo(detail);
3860
- const result = await host.invoiceRequest({
3861
- path: "/api/inc/valid",
3862
- method: "POST",
3863
- body: {
3864
- info: detailData,
3865
- flag: 100,
3866
- is_cut: 0,
3867
- is_save: 1,
3868
- operate_type: operateType(scope),
3869
- needLog: true,
3870
- req_base: reqBase({ numericTrace: true })
3871
- }
3872
- });
3873
- if (!result?.info) {
3874
- validationErrors.push({ fid: String(fid), error: "\u67E5\u9A8C\u63A5\u53E3\u672A\u8FD4\u56DE\u53D1\u7968\u4FE1\u606F" });
3875
- continue;
3876
- }
3877
- if (identityFingerprint(result.info) !== identityFingerprint(detailData)) {
3878
- validationErrors.push({ fid: String(fid), error: "\u67E5\u9A8C\u8FD4\u56DE\u7684\u7968\u9762\u8EAB\u4EFD\u5B57\u6BB5\u4E0E\u76EE\u6807\u53D1\u7968\u4E0D\u4E00\u81F4" });
3879
- continue;
3880
- }
3881
- validations.push(validationPreview(result.info, scope, String(fid), session.baseUrl));
3882
- } catch (error) {
3883
- validationErrors.push({ fid: String(fid), error: error.message });
3884
- }
3885
- }
3886
- return {
3887
- status: "COMPLETE",
3888
- data: {
3889
- upload,
3890
- ocrCount: ocr.invoices.length,
3891
- invoices: ocr.invoices,
3892
- validations,
3893
- validationErrors,
3894
- results: ocr.results,
3895
- workflow: workflow(this.name, "COMPLETE")
3896
- }
3897
- };
3898
- }
3899
- };
3900
-
3901
- // src/shortcuts/invoice/operations/validate-preview.ts
3902
- var InvoiceValidatePreviewOperation = class {
3903
- name = "invoice.validate.preview";
3904
- async execute(input, { host }) {
3905
- const scope = normalizeScope(input.scope);
3906
- const session = await host.getSession();
3907
- const detail = await getDetail({ fid: input.fid }, host);
3908
- const info = detailInfo(detail);
3909
- const result = await host.invoiceRequest({
3910
- path: "/api/inc/valid",
3911
- method: "POST",
3912
- body: {
3913
- info,
3914
- flag: 100,
3915
- is_cut: 0,
3916
- is_save: 1,
3917
- operate_type: operateType(scope),
3918
- needLog: true,
3919
- req_base: reqBase({ numericTrace: true })
4438
+ if (isInvoiceNetworkError(error)) {
4439
+ throw invoicePartialError("\u4E0A\u4F20\u8BC6\u522B\u8BF7\u6C42\u53D1\u51FA\u540E\u8FDE\u63A5\u4E2D\u65AD\uFF0C\u53D1\u7968\u53EF\u80FD\u5DF2\u8FDB\u7968\u5939\uFF0C\u7ED3\u679C\u4E0D\u786E\u5B9A\uFF0C\u7981\u6B62\u81EA\u52A8\u91CD\u8BD5", {
4440
+ fileName,
4441
+ workflow: workflow(this.name, "EXECUTING")
4442
+ }, { stage: "upload-and-validate" });
3920
4443
  }
3921
- });
3922
- if (!result?.info) {
3923
- throw new InvoiceCliError("api", "validation_empty", "\u67E5\u9A8C\u63A5\u53E3\u672A\u8FD4\u56DE\u53D1\u7968\u4FE1\u606F", { details: { result }, exitCode: 1 });
4444
+ throw error;
3924
4445
  }
3925
- if (identityFingerprint(result.info) !== identityFingerprint(info)) {
3926
- throw new InvoiceCliError("api", "validation_target_mismatch", "\u67E5\u9A8C\u8FD4\u56DE\u7684\u7968\u9762\u8EAB\u4EFD\u5B57\u6BB5\u4E0E\u76EE\u6807\u53D1\u7968\u4E0D\u4E00\u81F4", { exitCode: 1 });
4446
+ const items = Array.isArray(result?.infos) ? result.infos : [];
4447
+ if (!items.length) {
4448
+ throw new InvoiceCliError("api", "recognize_empty", "\u4E0A\u4F20\u6210\u529F\u4F46\u6CA1\u6709\u8BC6\u522B\u51FA\u4EFB\u4F55\u53D1\u7968\u6216\u884C\u7A0B\u5355", {
4449
+ details: { fileName, res_base: result?.res_base },
4450
+ exitCode: 1
4451
+ });
3927
4452
  }
4453
+ const invoices = items.map((item) => invoiceResult(item, session.baseUrl));
3928
4454
  return {
3929
4455
  status: "COMPLETE",
3930
4456
  data: {
3931
- preview: validationPreview(result.info, scope, input.fid, session.baseUrl),
3932
- info: result.info,
3933
- saved: false,
3934
- result,
3935
- workflow: workflow("invoice.validate.preview", "COMPLETE")
4457
+ fileName,
4458
+ count: invoices.length,
4459
+ validatedCount: invoices.filter((item) => item.validated).length,
4460
+ invoices,
4461
+ workflow: workflow(this.name, "COMPLETE")
3936
4462
  }
3937
4463
  };
3938
4464
  }
@@ -3947,7 +4473,6 @@ function buildRegistry() {
3947
4473
  new InvoiceGetOperation(),
3948
4474
  new InvoiceUploadOperation(),
3949
4475
  new InvoiceOcrPreviewOperation(),
3950
- new InvoiceValidatePreviewOperation(),
3951
4476
  new InvoiceUploadAndValidateOperation(),
3952
4477
  new InvoiceImportPrepareOperation(),
3953
4478
  new InvoiceImportApplyOperation(),
@@ -3965,6 +4490,9 @@ function buildRegistry() {
3965
4490
  new InvoiceReimCandidatesListOperation(),
3966
4491
  new InvoiceReimEmployeeSuperiorsOperation(),
3967
4492
  new InvoiceReimFieldSearchOperation(),
4493
+ new InvoiceReimRelationSearchOperation(),
4494
+ new InvoiceReimRelationSaveOperation(),
4495
+ new InvoiceReimRelationListOperation(),
3968
4496
  new InvoiceReimSubsidySubmitOperation(),
3969
4497
  new InvoiceIssuingContractsListOperation(),
3970
4498
  new InvoiceIssuingContractDetailOperation()
@@ -4173,14 +4701,6 @@ var invoiceShortcut = {
4173
4701
  url: opts.url
4174
4702
  }), projectionFrom(options));
4175
4703
  }));
4176
- const validate = invoice.command("validate").description("Invoice validation commands");
4177
- withInvoiceOptions(validate.command("preview").description("Validate an existing invoice without saving validation result").option("--fid <fid>", "invoice fid").option("--scope <scope>", "personal or enterprise")).action(action(async (ctx, options) => {
4178
- const opts = asOptions(options);
4179
- await executeAndPrint(ctx, "invoice.validate.preview", await inputFrom(options, {
4180
- fid: opts.fid,
4181
- scope: opts.scope
4182
- }), projectionFrom(options));
4183
- }));
4184
4704
  const importCommand = invoice.command("import").description("Invoice file import commands");
4185
4705
  withInvoiceOptions(importCommand.command("prepare").description("Prepare a confirmed invoice file import").option("--file <path>", "local invoice file").option("--validate", "request validation before import").option("--no-validate", "skip validation before import").option("--sync-to-oa", "sync imported invoice to OA where supported").option("--no-sync-to-oa", "do not sync imported invoice to OA where supported")).action(action(async (ctx, options) => {
4186
4706
  const opts = asOptions(options);