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.
- package/README.md +1 -1
- package/dist/chunks/{attachment-content-EJYIOJPH.js → attachment-content-MBYYSQIX.js} +3 -3
- package/dist/chunks/{chunk-RYFRGTUV.js → chunk-7UOXOGFL.js} +4 -4
- package/dist/chunks/{chunk-BFKLQLBK.js → chunk-D3TDNRFE.js} +7 -7
- package/dist/chunks/{chunk-3NCFFHB2.js → chunk-DZOC77ZD.js} +1 -1
- package/dist/chunks/{chunk-K67FODVC.js → chunk-IRMA3GVP.js} +1 -1
- package/dist/chunks/{chunk-WNJUGI2F.js → chunk-KLZ3ULQQ.js} +1 -1
- package/dist/chunks/{chunk-6T53BSWZ.js → chunk-LALWNK6M.js} +9 -0
- package/dist/chunks/{chunk-HARQF5IP.js → chunk-LM2H7SZI.js} +25 -25
- package/dist/chunks/{chunk-YB3AJYPY.js → chunk-LTRLF6MM.js} +4 -4
- package/dist/chunks/{chunk-7ECB22G3.js → chunk-RPRFIG6I.js} +23 -23
- package/dist/chunks/{chunk-MCZG6HPM.js → chunk-RWFRZSIP.js} +2 -2
- package/dist/chunks/{chunk-7AYQJSFY.js → chunk-ZRHKGQRQ.js} +2 -2
- package/dist/chunks/{conflict-C4UDHCWV.js → conflict-D2HYKBMH.js} +2 -2
- package/dist/chunks/{contract-VUC6JOPG.js → contract-MFOFMM2J.js} +3837 -262
- package/dist/chunks/{create-flow-6OG2LYBD.js → create-flow-7ZATJVTM.js} +6 -6
- package/dist/chunks/{data-QO7QWOIV.js → data-WK5CQXNF.js} +17 -32
- package/dist/chunks/{env-WP57TF2S.js → env-5DO4YENS.js} +2 -2
- package/dist/chunks/{factory-VUXI7N5C.js → factory-3M7D7WJC.js} +1 -1
- package/dist/chunks/{group-chat-UQRGXILK.js → group-chat-B2HT5NEO.js} +3 -3
- package/dist/chunks/{invoice-E7GOITEU.js → invoice-V7ZTITUO.js} +725 -205
- package/dist/chunks/{meeting-4BBLVAWM.js → meeting-HZOX3CBB.js} +10 -10
- package/dist/chunks/{recruit-stage-FKWS5UQF.js → recruit-stage-XCMVEQA2.js} +718 -131
- package/dist/chunks/{registry-V4CHRQDI.js → registry-KYPFFQIH.js} +1 -1
- package/dist/chunks/{registry-5CRCN2TV.js → registry-SJHSBO5G.js} +10 -10
- package/dist/chunks/{room-recommend-AYR3UG7R.js → room-recommend-5AHR4YQV.js} +4 -4
- package/dist/chunks/{schedule-JZEFIXUS.js → schedule-KZPJUPC2.js} +4 -4
- package/dist/chunks/smart-extract-IXHCZE4R.js +2846 -0
- package/dist/chunks/{workflow-3ZAF2J5E.js → workflow-UHKCZJMY.js} +1 -1
- package/dist/index.js +11 -6
- package/dist/shortcuts/contract/manifest.js +151 -0
- package/dist/shortcuts/contract/operations/card-action.js +585 -0
- package/dist/shortcuts/contract/operations/card-ebdf-list.js +315 -0
- package/dist/shortcuts/contract/operations/card-plan.js +327 -0
- package/dist/shortcuts/contract/operations/card-risk-report.js +565 -0
- package/dist/shortcuts/contract/operations/elements-build.js +714 -0
- package/dist/shortcuts/contract/operations/elements-spec.js +216 -0
- package/dist/shortcuts/contract/operations/first-screen.js +563 -0
- package/dist/shortcuts/contract/operations/flow.js +81 -25
- package/dist/shortcuts/contract/operations/modeltext.js +132 -0
- package/dist/shortcuts/contract/operations/op-resolver.js +22 -0
- package/dist/shortcuts/contract/operations/quote.js +131 -25
- package/dist/shortcuts/contract/operations/registry.js +20 -0
- package/dist/shortcuts/contract/operations/review.js +73 -58
- package/dist/shortcuts/contract/operations/summary-validate.js +293 -0
- package/dist/shortcuts/contract/operations/summary.js +4 -2
- package/dist/shortcuts/contract/operations/upload.js +48 -7
- package/dist/shortcuts/contract/prewarm-cache.js +90 -0
- package/dist/shortcuts/contract/prewarm.js +88 -0
- package/dist/shortcuts/contract/upload-cache.js +49 -4
- package/dist/shortcuts/data/index.js +1 -6
- package/dist/shortcuts/data/manifest.js +2 -2
- package/dist/shortcuts/data/operations/index.js +1 -1
- package/dist/shortcuts/data/operations/query.js +23 -46
- package/dist/shortcuts/index.js +5 -0
- package/dist/shortcuts/invoice/index.js +0 -12
- package/dist/shortcuts/invoice/manifest.js +200 -49
- package/dist/shortcuts/invoice/operations/registry.js +4 -2
- package/dist/shortcuts/invoice/operations/reim-relation.js +438 -0
- package/dist/shortcuts/invoice/operations/shared.js +3 -19
- package/dist/shortcuts/invoice/operations/upload-and-validate.js +109 -73
- package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +4 -2
- package/dist/shortcuts/recruit-stage/operations/jd-create.js +6 -2
- package/dist/shortcuts/recruit-stage/operations/list.js +217 -1
- package/dist/shortcuts/recruit-stage/operations/resume-import.js +144 -158
- package/dist/shortcuts/recruit-stage/operations/search.js +348 -0
- package/dist/shortcuts/recruit-stage/shared.js +5 -0
- package/dist/shortcuts/recruit-stage/tag-lookup.js +136 -0
- package/dist/shortcuts/smart-extract/constants.js +79 -0
- package/dist/shortcuts/smart-extract/continuation.js +71 -0
- package/dist/shortcuts/smart-extract/errors.js +68 -0
- package/dist/shortcuts/smart-extract/host.js +191 -0
- package/dist/shortcuts/smart-extract/index.js +105 -0
- package/dist/shortcuts/smart-extract/ledger.js +70 -0
- package/dist/shortcuts/smart-extract/manifest.js +35 -0
- package/dist/shortcuts/smart-extract/operations/attachment.js +212 -0
- package/dist/shortcuts/smart-extract/operations/batch.js +67 -0
- package/dist/shortcuts/smart-extract/operations/config.js +118 -0
- package/dist/shortcuts/smart-extract/operations/fill.js +489 -0
- package/dist/shortcuts/smart-extract/operations/preview.js +174 -0
- package/dist/shortcuts/smart-extract/operations/registry.js +34 -0
- package/dist/shortcuts/smart-extract/operations/save.js +355 -0
- package/dist/shortcuts/smart-extract/operations/shared.js +191 -0
- package/dist/shortcuts/smart-extract/operations/structure.js +401 -0
- package/dist/shortcuts/smart-extract/operations/target.js +167 -0
- package/dist/shortcuts/smart-extract/operations/types.js +22 -0
- package/dist/shortcuts/smart-extract/operations/validate.js +408 -0
- package/dist/shortcuts/workflow/operations/read.js +19 -1
- package/docs/SKILL.md +1 -1
- package/docs/_catalog.md +3 -0
- package/docs/agent-invoice.md +5 -7
- package/docs/data.md +5 -1
- package/docs/fna.md +14 -1
- package/docs/invoice.md +7 -5
- package/docs/smart-extract.md +156 -0
- package/package.json +1 -1
- package/skill-template/business-info.json +16 -1
- package/skill-template/domains/qiyecheng.md +2 -0
- package/skill-template/domains/smart-extract.md +16 -0
- package/skill-template/domains/yepiaotong.md +2 -2
- package/skills/weaver-e10-data/references/scene-and-misc.md +4 -3
- package/skills/weaver-e10-jinchengda/SKILL.md +159 -11
- package/skills/weaver-e10-jinchengda/references/contract-action-card.md +8 -3
- package/skills/weaver-e10-jinchengda/references/contract-action-engine.md +4 -3
- package/skills/weaver-e10-jinchengda/references/contract-element-save-record.md +8 -7
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +21 -6
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +3 -1
- package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-modeltext-library.md +128 -0
- package/skills/weaver-e10-jinchengda/references/contract-multi-file.md +90 -0
- package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +124 -5
- package/skills/weaver-e10-jinchengda/scripts/contract_first_screen.py +200 -0
- package/skills/weaver-e10-jinchengda/scripts/fill_contract_from_quote.py +572 -0
- package/skills/weaver-e10-jinchengda/scripts/quote_screen.py +560 -0
- package/skills/weaver-e10-jinchengda/scripts/triage_contract.py +894 -0
- package/skills/weaver-e10-jinchengda/scripts/validate_action_card.py +10 -0
- package/skills/weaver-e10-qiyecheng/SKILL.md +37 -0
- package/skills/weaver-e10-qiyecheng/references/ai-check-audit.md +14 -0
- package/skills/weaver-e10-qiyecheng/references/budget.md +14 -0
- package/skills/weaver-e10-qiyecheng/references/catalog.md +25 -0
- package/skills/weaver-e10-qiyecheng/references/expense-center.md +8 -0
- package/skills/weaver-e10-qiyecheng/references/expense-chart.md +9 -0
- package/skills/weaver-e10-qiyecheng/references/invoice-writeoff.md +13 -0
- package/skills/weaver-e10-qiyecheng/references/loan-management.md +14 -0
- package/skills/weaver-e10-qiyecheng/references/self-hosted-mode.md +239 -0
- package/skills/weaver-e10-qiyecheng/references/source-manifest.json +34 -27
- package/skills/weaver-e10-recruit-stage/SKILL.md +62 -4
- package/skills/weaver-e10-recruit-stage/agents/openai.yaml +42 -8
- package/skills/weaver-e10-recruit-stage/references/env-ziyong.md +79 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +11 -3
- package/skills/weaver-e10-recruit-stage/references/recruit-edit-interview-feedback.md +3 -2
- package/skills/weaver-e10-recruit-stage/references/recruit-interview-not-attended.md +153 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +7 -4
- package/skills/weaver-e10-recruit-stage/references/recruit-match-candidates.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-my-positions.md +66 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-output-links.md +156 -42
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-import-batch.md +122 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +36 -8
- package/skills/weaver-e10-recruit-stage/references/recruit-search-by-tag.md +157 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-utterance-glossary.md +35 -0
- package/skills/weaver-e10-smart-extract/SKILL.md +169 -0
- package/skills/weaver-e10-smart-extract/references/api-contract.md +71 -0
- package/skills/weaver-e10-smart-extract/references/result-format.md +102 -0
- package/skills/weaver-e10-smart-extract/references/troubleshooting.md +105 -0
- package/skills/weaver-e10-workflow/references/workflow-query.md +1 -1
- package/skills/weaver-e10-workflow/references/workflow-view.md +1 -1
- package/skills/weaver-e10-yepiaotong/SKILL.md +46 -33
- package/skills/weaver-e10-yepiaotong/references/invoice-add.md +2 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-file-upload.md +1 -1
- package/skills/weaver-e10-yepiaotong/references/invoice-import.md +19 -2
- package/skills/weaver-e10-yepiaotong/references/invoice-ocr-preview.md +8 -2
- package/skills/weaver-e10-yepiaotong/references/invoice-reim-relation.md +407 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +12 -8
- package/skills/weaver-e10-yepiaotong/references/invoice-upload-and-validate.md +97 -39
- package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +91 -2
- package/skills/weaver-e10-yepiaotong/references/reim-examples.md +1 -1
- package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +12 -12
- package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +8 -4
- package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +136 -91
- package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +109 -23
- package/skills/weaver-e10-yepiaotong/references/source-manifest.json +110 -43
- package/dist/shortcuts/invoice/operations/validate-preview.js +0 -40
- package/skills/weaver-e10-jinchengda/scripts/plan_actions.py +0 -279
- package/skills/weaver-e10-jinchengda/scripts/render_action_card.py +0 -450
- package/skills/weaver-e10-jinchengda/scripts/render_ebdf_list_card.py +0 -265
- package/skills/weaver-e10-jinchengda/scripts/render_risk_report.py +0 -358
- package/skills/weaver-e10-yepiaotong/references/invoice-validation-preview.md +0 -40
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
import "./chunk-BUSC6UAE.js";
|
|
26
26
|
|
|
27
27
|
// src/shortcuts/contract/index.ts
|
|
28
|
-
import { readFile as
|
|
28
|
+
import { readFile as readFile6 } from "node:fs/promises";
|
|
29
29
|
|
|
30
30
|
// src/shortcuts/contract/continuation.ts
|
|
31
31
|
import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
|
|
@@ -122,9 +122,9 @@ function signature(payload, key) {
|
|
|
122
122
|
}
|
|
123
123
|
function createContractContinuationSigner(ctx) {
|
|
124
124
|
return {
|
|
125
|
-
async issue(payload,
|
|
125
|
+
async issue(payload, ttlMs3 = CONTINUATION_TTL_MS) {
|
|
126
126
|
const issuedAt = Date.now();
|
|
127
|
-
const body = encode({ ...payload, issuedAt, expiresAt: issuedAt +
|
|
127
|
+
const body = encode({ ...payload, issuedAt, expiresAt: issuedAt + ttlMs3 });
|
|
128
128
|
const sig = signature(body, await loadKey(ctx));
|
|
129
129
|
return `${body}.${sig}`;
|
|
130
130
|
},
|
|
@@ -921,6 +921,137 @@ var quoteContracts = [
|
|
|
921
921
|
["data", "out"]
|
|
922
922
|
)
|
|
923
923
|
},
|
|
924
|
+
{
|
|
925
|
+
name: "contract.card.plan",
|
|
926
|
+
risk: "read",
|
|
927
|
+
fixed: { local: true, kind: "card-plan" },
|
|
928
|
+
inputSchema: readSchema({
|
|
929
|
+
context: {
|
|
930
|
+
type: "object",
|
|
931
|
+
description: "\u4E0A\u4E0B\u6587\u72B6\u6001\u5BF9\u8C61\uFF08scene / docType / flowKey / reviewed / submitted \u7B49\uFF09\uFF1B\u4F18\u5148\u4E8E contextFile / contextJson"
|
|
932
|
+
},
|
|
933
|
+
contextFile: { type: "string", minLength: 1, maxLength: 4096, description: "\u4E0A\u4E0B\u6587\u72B6\u6001 JSON \u6587\u4EF6\u8DEF\u5F84" },
|
|
934
|
+
contextJson: { type: "string", minLength: 1, description: "\u4E0A\u4E0B\u6587\u72B6\u6001 JSON \u5B57\u7B26\u4E32" }
|
|
935
|
+
})
|
|
936
|
+
},
|
|
937
|
+
{
|
|
938
|
+
name: "contract.card.ebdf-list",
|
|
939
|
+
risk: "local-file-write",
|
|
940
|
+
fixed: { local: true, kind: "ebdf-list-card" },
|
|
941
|
+
inputSchema: readSchema({
|
|
942
|
+
menu: { type: "string", description: "\u83DC\u5355\u540D\u6216\u522B\u540D\uFF08\u76F4\u9500\u5408\u540C/\u76F4\u9500\u4E1A\u7EE9/\u5408\u540C\u6536\u6B3E/\u9879\u76EE\u9A8C\u6536/\u6E20\u9053\u8BA2\u5355/\u6E20\u9053\u8BA2\u5355-\u5546\u52A1\uFF09" },
|
|
943
|
+
pageId: { type: "string", pattern: "^\\d{6,}$", description: "\u76F4\u63A5\u7ED9 pageId\uFF1B\u4E0E menu \u4E8C\u9009\u4E00\uFF0C\u540C\u65F6\u7ED9\u65F6\u4EE5 pageId \u4E3A\u51C6" },
|
|
944
|
+
origin: { type: "string", minLength: 1, description: "\u5FC5\u586B\uFF1Ascheme+host\uFF0C\u4E0D\u5E26\u8DEF\u5F84\u6216 query\uFF0C\u4E0D\u542B {baseUrl}" },
|
|
945
|
+
title: { type: "string", description: "\u5361\u7247\u6807\u9898\uFF0C\u9ED8\u8BA4\u53D6\u83DC\u5355\u540D" },
|
|
946
|
+
callId: { type: "string", description: "\u9ED8\u8BA4 ebdf-list-<\u83DC\u5355>-<YYYYMMDDHHmm>-01" },
|
|
947
|
+
comParamPairs: { type: "array", items: { type: "string" }, description: "\u5F62\u5982 field_<\u5B57\u6BB5id>=<\u503C>\uFF0C\u53EF\u591A\u6761\uFF1B\u4E0E comParamsJson \u4E92\u65A5" },
|
|
948
|
+
comParamsJson: { type: "string", description: "comParams \u5BF9\u8C61\u7684 JSON \u5B57\u7B26\u4E32\uFF1B\u4E0E comParamPairs \u4E92\u65A5" },
|
|
949
|
+
out: { type: "string", maxLength: 4096, description: "\u53EF\u9009\uFF1A\u5361\u7247 JSON \u8F93\u51FA\u8DEF\u5F84" }
|
|
950
|
+
}, ["origin"])
|
|
951
|
+
},
|
|
952
|
+
{
|
|
953
|
+
name: "contract.card.risk-report",
|
|
954
|
+
risk: "local-file-write",
|
|
955
|
+
fixed: { local: true, kind: "risk-report-card" },
|
|
956
|
+
inputSchema: readSchema({
|
|
957
|
+
ref: { type: "string", maxLength: 4096, description: "CLI \u843D\u76D8\u7684\u5BA1\u67E5\u7ED3\u679C JSON\uFF08\u542B envelope\uFF09\uFF1B\u4E0E data \u4E8C\u9009\u4E00" },
|
|
958
|
+
data: { type: "string", maxLength: 4096, description: "\u5DF2\u5F52\u4E00\u5316\u7684 report_data.json\uFF1B\u4E0E ref \u4E8C\u9009\u4E00" },
|
|
959
|
+
out: { type: "string", maxLength: 4096, description: "\u53EF\u9009\uFF1AHTML \u8F93\u51FA\u8DEF\u5F84\uFF08\u4E0D\u4F20\u5219\u4E0D\u843D\u76D8\uFF0C\u62A5\u544A\u4EC5\u4F5C\u5361\u7247\u4EA4\u4ED8\uFF09" },
|
|
960
|
+
payload: { type: "string", maxLength: 4096, description: "\u53EF\u9009\uFF1A\u540C\u65F6\u8F93\u51FA browsertool payload JSON \u7684\u8DEF\u5F84" },
|
|
961
|
+
dumpData: { type: "string", maxLength: 4096, description: "\u53EF\u9009\uFF1A\u53EA\u62BD\u53D6\u6570\u636E\u5E76\u4FDD\u5B58\u5230\u6B64\u8DEF\u5F84" },
|
|
962
|
+
template: { type: "string", maxLength: 4096, description: "\u53EF\u9009\uFF1A\u81EA\u5B9A\u4E49\u6A21\u677F\u8DEF\u5F84\uFF1B\u7F3A\u7701\u7528\u5185\u7F6E\u6A21\u677F" },
|
|
963
|
+
contract: { type: "string", description: "\u5408\u540C\u540D\u79F0" },
|
|
964
|
+
partyA: { type: "string", description: "\u7532\u65B9" },
|
|
965
|
+
partyB: { type: "string", description: "\u4E59\u65B9" },
|
|
966
|
+
reviewDate: { type: "string", description: "\u5BA1\u67E5\u65E5\u671F" },
|
|
967
|
+
fileId: { type: "string", description: "\u5BA1\u67E5 fileId\uFF08\u6253\u5F00\u8BE6\u60C5\u7528\uFF09" },
|
|
968
|
+
fileName: { type: "string", description: "\u5BA1\u67E5\u6587\u4EF6\u540D" },
|
|
969
|
+
aiid: { type: "string", description: "\u5BA1\u67E5\u52A9\u624B id\uFF0C\u9ED8\u8BA4 1326842382967570463" },
|
|
970
|
+
baseUrl: { type: "string", maxLength: 2048, description: "E10 \u5730\u5740\uFF0C\u9ED8\u8BA4 https://www.e-cology.com.cn" },
|
|
971
|
+
cardId: { type: "string", description: "\u5361\u7247\u552F\u4E00 id" },
|
|
972
|
+
callId: { type: "string", description: "payload callId" },
|
|
973
|
+
title: { type: "string", description: "\u5361\u7247\u6807\u9898" }
|
|
974
|
+
})
|
|
975
|
+
},
|
|
976
|
+
{
|
|
977
|
+
name: "contract.card.action",
|
|
978
|
+
risk: "local-file-write",
|
|
979
|
+
fixed: { local: true, kind: "action-card-render" },
|
|
980
|
+
inputSchema: readSchema({
|
|
981
|
+
context: { type: "object", description: "\u4E0A\u4E0B\u6587\u72B6\u6001\u5BF9\u8C61\uFF08scene / docType / flowKey / reviewed / submitted \u7B49\uFF09\uFF1B\u4F18\u5148\u4E8E contextFile / contextJson" },
|
|
982
|
+
contextFile: { type: "string", maxLength: 4096, description: "\u4E0A\u4E0B\u6587\u72B6\u6001 JSON \u6587\u4EF6\u8DEF\u5F84\uFF1B\u90FD\u7F3A\u7701\u65F6\u6309\u4EA7\u7269\u76EE\u5F55\u627E card_context.json / first_screen_result.json" },
|
|
983
|
+
contextJson: { type: "string", description: "\u4E0A\u4E0B\u6587\u72B6\u6001 JSON \u5B57\u7B26\u4E32" },
|
|
984
|
+
fileId: { type: "string", description: "\u5BA1\u67E5/\u6D41\u7A0B\u7528\u7684 fileId" },
|
|
985
|
+
fileName: { type: "string", description: "\u5408\u540C\u6587\u4EF6\u540D\uFF08\u6253\u5F00\u5BA1\u67E5\u8BE6\u60C5\u7528\uFF09" },
|
|
986
|
+
flowKey: { type: "string", enum: ["\u5951\u7EA6\u9501", "\u65B0\u5BA2\u6237", "\u5E38\u89C4\u4E8C\u6B21\u9500\u552E", "\u8001\u5BA2\u6237\u589E\u503C"], description: "\u5408\u540C\u6D41\u7A0B\u7C7B\u578B\uFF1B\u51B3\u5B9A\u300C\u53D1\u8D77\u6D41\u7A0B\u300D\u5361\u662F\u5426\u751F\u6210" },
|
|
987
|
+
companyName: { type: "string", description: "\u5BF9\u65B9\u4F01\u4E1A\u5168\u79F0\uFF1B\u51B3\u5B9A\u300C\u67E5\u5BF9\u65B9\u8D44\u4FE1\u300D\u5361\u662F\u5426\u751F\u6210" },
|
|
988
|
+
summaryHtml: { type: "string", maxLength: 4096, description: "\u6458\u8981 HTML \u6587\u4EF6\u8DEF\u5F84\uFF08\u5185\u5D4C\u4E3A\u300C\u67E5\u770B\u5408\u540C\u6458\u8981\u300D\u5185\u5BB9\uFF09" },
|
|
989
|
+
reportHtml: { type: "string", maxLength: 4096, description: "\u5BA1\u67E5\u62A5\u544A HTML \u6587\u4EF6\u8DEF\u5F84\uFF08\u5185\u5D4C\u4E3A\u300C\u5BFC\u51FA\u5BA1\u67E5\u62A5\u544A\u300D\u5185\u5BB9\uFF09" },
|
|
990
|
+
compareHtml: { type: "string", maxLength: 4096, description: "\u6BD4\u5BF9\u62A5\u544A HTML \u6587\u4EF6\u8DEF\u5F84\uFF08\u5185\u5D4C\u4E3A\u300C\u751F\u6210\u6BD4\u5BF9\u62A5\u544A\u300D\u5185\u5BB9\uFF09" },
|
|
991
|
+
aiExtraId: { type: "string", description: "\u8981\u7D20\u9884\u586B\u8BC6\u522B\u8BB0\u5F55 ID\uFF1B\u7F3A\u7701\u4ECE context \u7684 aiExtraId \u53D6" },
|
|
992
|
+
attachmentFieldId: { type: "string", description: "\u5408\u540C\u6587\u4EF6\u5728\u8868\u5355\u4E0A\u7684\u9644\u4EF6\u5B57\u6BB5 ID\uFF1B\u7F3A\u7701\u4ECE context \u53D6" },
|
|
993
|
+
baseUrl: { type: "string", maxLength: 2048, description: "E10 \u5730\u5740\uFF0C\u9ED8\u8BA4 https://www.e-cology.com.cn" },
|
|
994
|
+
aiid: { type: "string", description: "\u5BA1\u67E5\u52A9\u624B id\uFF0C\u9ED8\u8BA4 1326842382967570463" },
|
|
995
|
+
cardId: { type: "string", description: "\u5361\u7247\u552F\u4E00 id\uFF0C\u9ED8\u8BA4 card-<YYYYMMDDHHmm>" },
|
|
996
|
+
callId: { type: "string", description: "payload callId\uFF0C\u9ED8\u8BA4 contract-card-<stamp>-01" },
|
|
997
|
+
title: { type: "string", description: "\u5361\u7247\u6807\u9898\uFF0C\u9ED8\u8BA4\u300C\u53EF\u505A\u7684 N \u4EF6\u4E8B\u300D" },
|
|
998
|
+
only: { type: "string", description: "\u53EA\u8F93\u51FA\u6307\u5B9A\u52A8\u4F5C\uFF0C\u9017\u53F7\u5206\u9694\uFF08\u5982 launch-flow\uFF09\uFF1B\u4ECD\u7531\u672C\u64CD\u4F5C\u751F\u6210" },
|
|
999
|
+
template: { type: "string", maxLength: 4096, description: "\u53EF\u9009\uFF1A\u81EA\u5B9A\u4E49\u6A21\u677F\u8DEF\u5F84\uFF1B\u7F3A\u7701\u7528\u5185\u7F6E\u6A21\u677F" },
|
|
1000
|
+
out: { type: "string", maxLength: 4096, description: "\u53EF\u9009\uFF1A\u5199\u5165 browsertool \u6587\u4EF6\uFF1B\u4E0D\u4F20\u5219\u53EA\u5728\u7ED3\u679C\u4E2D\u8FD4\u56DE" }
|
|
1001
|
+
})
|
|
1002
|
+
},
|
|
1003
|
+
{
|
|
1004
|
+
name: "contract.elements.build",
|
|
1005
|
+
risk: "local-file-write",
|
|
1006
|
+
fixed: { local: true, kind: "elements-build" },
|
|
1007
|
+
inputSchema: readSchema({
|
|
1008
|
+
triage: { type: "string", minLength: 1, maxLength: 4096, description: "triage.json \u8DEF\u5F84\uFF08\u62BD\u6B63\u6587\u4E0E\u8981\u7D20\u7684\u4EA7\u7269\uFF09" },
|
|
1009
|
+
fileId: { type: "string", minLength: 1, description: "flow.launch \u8FD4\u56DE\u7684 workflow fileId" },
|
|
1010
|
+
flow: { type: "string", minLength: 1, description: "\u65B0\u5BA2\u6237 / \u5951\u7EA6\u9501 / \u5E38\u89C4\u4E8C\u6B21\u9500\u552E / \u8001\u5BA2\u6237\u589E\u503C" },
|
|
1011
|
+
sourceText: { type: "string", maxLength: 4096, description: "\u5408\u540C\u6B63\u6587\u7EAF\u6587\u672C\u8DEF\u5F84\uFF1B\u7F3A\u7701\u53D6 triage \u540C\u76EE\u5F55 contract_text.txt" },
|
|
1012
|
+
fileIds: { type: "array", items: { type: "string" }, description: "\u591A\u6587\u4EF6\u65F6\u7684\u9644\u4EF6 ID \u5217\u8868\uFF08\u4E0E text_sources.json \u6587\u4EF6\u6570\u4E00\u81F4\u624D\u7528\u4E8E origin \u5F52\u5C5E\uFF09" },
|
|
1013
|
+
workflowId: { type: "string", description: "\u6D41\u7A0B ID\uFF1B\u65E0\u5185\u7F6E\u5B57\u6BB5\u8868\u65F6\u914D\u5408 attachmentFieldId \u51FA\u6700\u5C0F\u8BB0\u5F55" },
|
|
1014
|
+
attachmentFieldId: { type: "string", description: "\u5408\u540C\u6587\u4EF6\u5B57\u6BB5 ID\uFF1B\u65E0\u5185\u7F6E\u5B57\u6BB5\u8868\u65F6\u5FC5\u586B\uFF0C\u4EC5\u767B\u8BB0\u9644\u4EF6\u515C\u5E95" },
|
|
1015
|
+
out: { type: "string", maxLength: 4096, description: "\u53EF\u9009\uFF1Arecognize.json \u8F93\u51FA\u8DEF\u5F84" }
|
|
1016
|
+
}, ["triage", "fileId", "flow"])
|
|
1017
|
+
},
|
|
1018
|
+
{
|
|
1019
|
+
name: "contract.firstscreen.run",
|
|
1020
|
+
risk: "local-file-write",
|
|
1021
|
+
fixed: { local: true, kind: "first-screen-orchestration" },
|
|
1022
|
+
inputSchema: readSchema({
|
|
1023
|
+
file: { type: "string", minLength: 1, maxLength: 4096, description: "\u4E3B\u5408\u540C\u6587\u4EF6\u7EDD\u5BF9\u8DEF\u5F84" },
|
|
1024
|
+
outDir: { type: "string", minLength: 1, maxLength: 4096, description: "\u4EA7\u7269\u76EE\u5F55\uFF08\u653E\u4E2D\u95F4 JSON\u3001summary.html\u3001card.html\uFF09" },
|
|
1025
|
+
attach: { type: "array", items: { type: "string" }, description: "\u968F\u9644\u6587\u4EF6\uFF08\u534F\u8BAE/\u8865\u5145\u534F\u8BAE/\u6E05\u5355\uFF09\uFF1B\u9884\u5BA1\u4E00\u5E76\u4E0A\u4F20\uFF0C\u53D1\u8D77\u6D41\u7A0B\u7684\u9644\u4EF6\u5B57\u6BB5\u53EA\u6302\u4E3B\u6587\u4EF6" },
|
|
1026
|
+
flow: { type: "string", enum: ["\u5951\u7EA6\u9501", "\u65B0\u5BA2\u6237", "\u5E38\u89C4\u4E8C\u6B21\u9500\u552E", "\u8001\u5BA2\u6237\u589E\u503C"], description: "\u7559\u7A7A\u5219\u4ECE triage.json \u7684 flowKey \u8BFB\u53D6" },
|
|
1027
|
+
triage: { type: "string", maxLength: 4096, description: "triage.json \u8DEF\u5F84\uFF1B\u7F3A\u7701\u53D6 outDir/triage.json" },
|
|
1028
|
+
aiFill: { type: "string", maxLength: 4096, description: "ai_fill.json\uFF08elements + summary \u5408\u5E76\uFF09\uFF1B\u7ED9\u4E86\u5C31\u81EA\u52A8\u62C6\u51FA summary_data.json" },
|
|
1029
|
+
summaryData: { type: "string", maxLength: 4096, description: "summary_data.json \u8DEF\u5F84\uFF1B\u4E0D\u4F20\u5219\u8DF3\u8FC7\u6458\u8981\u6E32\u67D3" },
|
|
1030
|
+
recognizeFile: { type: "string", maxLength: 4096, description: "recognizeResult \u7684 JSON \u6587\u4EF6\uFF1B\u4E0D\u4F20\u5219\u7528\u5185\u7F6E\u5B57\u6BB5\u8868\u81EA\u52A8\u7EC4\u88C5\uFF0C\u62FF\u4E0D\u5230\u5C31\u964D\u7EA7" },
|
|
1031
|
+
companyName: { type: "string", description: "\u5BF9\u65B9\u4E3B\u4F53\u5168\u79F0\uFF0C\u7528\u4E8E\u8D44\u4FE1\u5361" },
|
|
1032
|
+
counterparty: { type: "boolean", description: "\u662F\u5426\u5B58\u5728\u53EF\u67E5\u7684\u5BF9\u65B9\u4E3B\u4F53" },
|
|
1033
|
+
skipUpload: { type: "boolean", description: "\u8DF3\u8FC7\u9884\u5BA1\u4E0A\u4F20\uFF08\u4EC5\u9700\u6D41\u7A0B\u9875\u65F6\uFF09" },
|
|
1034
|
+
baseUrl: { type: "string", maxLength: 2048, description: "E10 \u5730\u5740\uFF0C\u9ED8\u8BA4 https://www.e-cology.com.cn" },
|
|
1035
|
+
aiid: { type: "string", description: "\u5BA1\u67E5\u52A9\u624B id\uFF08\u900F\u4F20\u7ED9\u5361\u7247\uFF09" },
|
|
1036
|
+
printCard: { type: "boolean", description: "\u628A\u6210\u54C1\u5361\u7247 HTML \u4E00\u5E76\u8FD4\u56DE\uFF08data.cardHtmlContent\uFF09" }
|
|
1037
|
+
}, ["file", "outDir"])
|
|
1038
|
+
},
|
|
1039
|
+
{
|
|
1040
|
+
name: "contract.summary.validate",
|
|
1041
|
+
risk: "local-file-write",
|
|
1042
|
+
fixed: { local: true, kind: "summary-validate" },
|
|
1043
|
+
inputSchema: readSchema(
|
|
1044
|
+
{
|
|
1045
|
+
summary: { type: "string", minLength: 1, maxLength: 4096, description: "\u6A21\u578B\u751F\u6210\u7684 summary_data.json \u8DEF\u5F84" },
|
|
1046
|
+
text: { type: "string", maxLength: 4096, description: "\u53EF\u9009\uFF1Acontract_text.txt\uFF0C\u7528\u4E8E\u91D1\u989D\u56DE\u67E5" },
|
|
1047
|
+
triage: { type: "string", maxLength: 4096, description: "\u53EF\u9009\uFF1Atriage.json\uFF1B\u914D\u5408 elements \u5408\u6D41\u8981\u7D20" },
|
|
1048
|
+
elements: { type: "string", maxLength: 4096, description: "\u53EF\u9009\uFF1A\u6A21\u578B\u8BED\u4E49\u63D0\u53D6\u7684 elements.json" },
|
|
1049
|
+
outSummary: { type: "string", maxLength: 4096, description: "\u53EF\u9009\uFF1A\u6821\u9A8C\u901A\u8FC7\u540E\u843D\u5730\u7684 summary_data.json \u8DEF\u5F84" },
|
|
1050
|
+
strict: { type: "boolean", description: "\u53EF\u9009\uFF1AWARN \u4E5F\u89C6\u4E3A\u4E0D\u901A\u8FC7\uFF08\u4EC5\u5F71\u54CD data.pass\uFF0C\u4E0D\u6539\u53D8 fails\uFF09" }
|
|
1051
|
+
},
|
|
1052
|
+
["summary"]
|
|
1053
|
+
)
|
|
1054
|
+
},
|
|
924
1055
|
{
|
|
925
1056
|
name: "contract.file.download",
|
|
926
1057
|
risk: "local-file-write",
|
|
@@ -1055,6 +1186,29 @@ var contractOperations = [
|
|
|
1055
1186
|
fixed: { method: "GET", path: "/api/ebd/contract/tplinfo/getById" },
|
|
1056
1187
|
inputSchema: readSchema({ id: idString }, ["id"])
|
|
1057
1188
|
},
|
|
1189
|
+
{
|
|
1190
|
+
// 范文库(「合同范文管理」EB 表单)。本技能内「模板」== 「范文」,
|
|
1191
|
+
// 与合同模板库 tplinfo(contract.template.*)是互不相通的两个对象。
|
|
1192
|
+
name: "contract.modeltext.list",
|
|
1193
|
+
risk: "read",
|
|
1194
|
+
auth: AUTH,
|
|
1195
|
+
fixed: {
|
|
1196
|
+
method: "POST",
|
|
1197
|
+
path: "/api/ebuilder/form/list/getListDatas",
|
|
1198
|
+
defaults: {
|
|
1199
|
+
passid: "1290191829260230657",
|
|
1200
|
+
cid: "1290191829260230657",
|
|
1201
|
+
listId: "1290191833571975256"
|
|
1202
|
+
},
|
|
1203
|
+
headers: { ebbusinessid: "1290191833571975256" },
|
|
1204
|
+
note: "\u5206\u9875\u4EE5 body.current \u4F20\u9875\u7801\uFF1B\u771F\u5B9E\u603B\u6570\u53D6 pagination.mainRecordTotal"
|
|
1205
|
+
},
|
|
1206
|
+
inputSchema: readSchema({
|
|
1207
|
+
pageNo: { type: "integer", minimum: 1, default: 1 },
|
|
1208
|
+
pageSize: { type: "integer", minimum: 1, maximum: 200, default: 50 },
|
|
1209
|
+
tableuid: { type: "string", description: "\u6570\u636E\u8868 uid\uFF1B\u7701\u7565\u65F6\u7531\u670D\u52A1\u7AEF\u6309\u89C6\u56FE\u89E3\u6790" }
|
|
1210
|
+
})
|
|
1211
|
+
},
|
|
1058
1212
|
{
|
|
1059
1213
|
name: "contract.clause.tree",
|
|
1060
1214
|
risk: "read",
|
|
@@ -2511,7 +2665,7 @@ var AI_MARKS = [
|
|
|
2511
2665
|
"termComponent",
|
|
2512
2666
|
"keywordComponent"
|
|
2513
2667
|
];
|
|
2514
|
-
var sleep = (ms) => new Promise((
|
|
2668
|
+
var sleep = (ms) => new Promise((resolve16) => setTimeout(resolve16, ms));
|
|
2515
2669
|
function dataOf(value) {
|
|
2516
2670
|
return value?.data ?? {};
|
|
2517
2671
|
}
|
|
@@ -5014,10 +5168,11 @@ function renderSummaryHtml(data) {
|
|
|
5014
5168
|
);
|
|
5015
5169
|
}
|
|
5016
5170
|
const badge = esc(data.badge ?? "\u5408\u540C");
|
|
5017
|
-
const
|
|
5171
|
+
const label = String(data.summaryLabel ?? "\u5408\u540C\u6458\u8981");
|
|
5172
|
+
const title = esc(data.title ?? label);
|
|
5018
5173
|
const meta = esc(data.meta ?? "");
|
|
5019
5174
|
const body = sections.map((section) => sectionHtml(section)).join("");
|
|
5020
|
-
return `<!DOCTYPE html><html lang="zh-CN"><head><meta charset="UTF-8"><title
|
|
5175
|
+
return `<!DOCTYPE html><html lang="zh-CN"><head><meta charset="UTF-8"><title>${label} - ${title}</title><style>${CSS}</style></head><body><div class="w"><div class="hd"><span class="bd">${badge}</span><h1>${title}</h1><div class="mt">${meta}</div></div>${body}</div></body></html>`;
|
|
5021
5176
|
}
|
|
5022
5177
|
var contractSummaryOperations = [
|
|
5023
5178
|
{
|
|
@@ -5258,153 +5413,1787 @@ var contractCardOperations = [
|
|
|
5258
5413
|
}
|
|
5259
5414
|
];
|
|
5260
5415
|
|
|
5261
|
-
// src/shortcuts/contract/operations/
|
|
5262
|
-
import {
|
|
5263
|
-
import {
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
|
|
5285
|
-
|
|
5416
|
+
// src/shortcuts/contract/operations/card-plan.ts
|
|
5417
|
+
import { readFileSync as readFileSync5 } from "node:fs";
|
|
5418
|
+
import { resolve as resolve5 } from "node:path";
|
|
5419
|
+
var MAX_CARDS = 4;
|
|
5420
|
+
var EMPTY_HINT = "\u6309 contract-action-engine.md \xA77 \u7A7A\u7ED3\u679C\u5904\u7406\uFF1A\u4E0D\u51FA\u5361\u7247\uFF0C\u8BF4\u660E\u7F3A\u4EC0\u4E48\u4E0E\u8865\u6CD5";
|
|
5421
|
+
var ACTIONS = [
|
|
5422
|
+
{
|
|
5423
|
+
id: "generate-contract",
|
|
5424
|
+
title: "\u6309\u62A5\u4EF7\u5355\u751F\u6210\u5408\u540C",
|
|
5425
|
+
weight: 100,
|
|
5426
|
+
walk: "sendQuestion",
|
|
5427
|
+
desc: "\u7528\u771F\u5B9E\u6A21\u677F\u628A\u6807\u7684\u4E0E\u91D1\u989D\u586B\u6210\u5408\u540C docx \uFF5C \u7F3A .docx \u6A21\u677F \uFF5C 3~5 \u6B65 \xB7 \u786E\u8BA4 1 \u6B21",
|
|
5428
|
+
requires: { docType: ["quote", "tender"] },
|
|
5429
|
+
blocked: ["generatedDocx"]
|
|
5430
|
+
},
|
|
5431
|
+
{
|
|
5432
|
+
id: "launch-flow",
|
|
5433
|
+
title: "\u53D1\u8D77\u300C{flowKey}\u300D\u5408\u540C\u6D41\u7A0B",
|
|
5434
|
+
weight: 100,
|
|
5435
|
+
walk: "e10Sdk",
|
|
5436
|
+
desc: "\u751F\u6210\u6B63\u5F0F\u5BA1\u6279\u5355\u5E76\u8FDB\u5165\u6D41\u8F6C \uFF5C \u8BC1\u636E\u9F50 \uFF5C 4~7 \u6B65 \xB7 \u786E\u8BA4 2 \u6B21",
|
|
5437
|
+
requires: { flowKey: "set", hasFileId: true },
|
|
5438
|
+
blocked: ["submitted"]
|
|
5439
|
+
},
|
|
5440
|
+
{
|
|
5441
|
+
id: "review",
|
|
5442
|
+
title: "\u5408\u540C\u9884\u5BA1",
|
|
5443
|
+
weight: 92,
|
|
5444
|
+
walk: "sendQuestion",
|
|
5445
|
+
desc: "\u53D1\u6D88\u606F\u8BA9 AI \u51FA\u98CE\u9669\u6761\u6B3E\u4E0E\u4FEE\u6539\u5EFA\u8BAE \uFF5C \u53EA\u8BFB\uFF0C\u4E0D\u6539\u539F\u6587",
|
|
5446
|
+
requires: { hasFileId: true },
|
|
5447
|
+
// 已经触发过审查(reviewStarted)就不再给「合同预审」,避免重复触发
|
|
5448
|
+
blocked: ["reviewed", "reviewStarted"]
|
|
5449
|
+
},
|
|
5450
|
+
{
|
|
5451
|
+
id: "export-review",
|
|
5452
|
+
title: "\u5BFC\u51FA\u5BA1\u67E5\u62A5\u544A",
|
|
5453
|
+
weight: 84,
|
|
5454
|
+
walk: "artifact",
|
|
5455
|
+
desc: "\u67E5\u770B\u98CE\u9669\u6761\u6B3E\u3001\u95EE\u9898\u8BF4\u660E\u4E0E\u5EFA\u8BAE\u4FEE\u6539 \uFF5C \u53EA\u8BFB \uFF5C \u70B9\u5F00\u5373\u770B",
|
|
5456
|
+
// 只有「已拿到审查结果」才允许导出;reviewStarted 但无结果时不得出现
|
|
5457
|
+
requires: { reviewed: true },
|
|
5458
|
+
blocked: []
|
|
5459
|
+
},
|
|
5460
|
+
{
|
|
5461
|
+
id: "view-compare",
|
|
5462
|
+
title: "\u67E5\u770B\u6BD4\u5BF9\u8BE6\u60C5",
|
|
5463
|
+
weight: 82,
|
|
5464
|
+
walk: "e10Sdk",
|
|
5465
|
+
desc: "\u5DE6\u53F3\u5BF9\u7167\u770B\u4E24\u7248\u5DEE\u5F02 \uFF5C \u53EA\u8BFB\uFF0C\u4EC5\u5F00\u9875\u9762",
|
|
5466
|
+
requires: { compared: true },
|
|
5467
|
+
blocked: []
|
|
5468
|
+
},
|
|
5469
|
+
{
|
|
5470
|
+
id: "view-review",
|
|
5471
|
+
title: "\u67E5\u770B\u5BA1\u67E5\u8BE6\u60C5",
|
|
5472
|
+
weight: 80,
|
|
5473
|
+
walk: "e10Sdk",
|
|
5474
|
+
desc: "\u6253\u5F00 AI \u5BA1\u67E5\u9875\u770B\u9010\u6761\u5224\u5B9A\u4E0E\u539F\u6587\u5B9A\u4F4D \uFF5C \u53EA\u8BFB\uFF0C\u4E0D\u6539\u539F\u6587",
|
|
5475
|
+
// 审查进行中(reviewStarted)与已出结果(reviewed)两种情况都要给:
|
|
5476
|
+
// 前者是用户稍后回来看进度的唯一入口,后者可看逐条判定
|
|
5477
|
+
requires: {},
|
|
5478
|
+
any_of: [{ reviewed: true }, { reviewStarted: true }],
|
|
5479
|
+
blocked: []
|
|
5480
|
+
},
|
|
5481
|
+
{
|
|
5482
|
+
id: "export-compare-report",
|
|
5483
|
+
title: "\u751F\u6210\u6BD4\u5BF9\u62A5\u544A",
|
|
5484
|
+
weight: 78,
|
|
5485
|
+
walk: "artifact",
|
|
5486
|
+
desc: "\u51FA\u56DB\u6307\u6807\u7EDF\u8BA1\u4E0E\u5DEE\u5F02\u6E05\u5355 \uFF5C \u53EA\u8BFB \uFF5C \u70B9\u5F00\u5373\u770B",
|
|
5487
|
+
requires: { compared: true },
|
|
5488
|
+
blocked: []
|
|
5489
|
+
},
|
|
5490
|
+
{
|
|
5491
|
+
id: "credit",
|
|
5492
|
+
title: "\u67E5\u5BF9\u65B9\u8D44\u4FE1",
|
|
5493
|
+
weight: 72,
|
|
5494
|
+
walk: "e10Sdk",
|
|
5495
|
+
desc: "\u770B\u8BC9\u8BBC\uFF0F\u88AB\u6267\u884C\uFF0F\u5DE5\u5546\u53D8\u66F4 \uFF5C \u53EA\u5F00\u9875\u9762\uFF0C\u53EA\u8BFB",
|
|
5496
|
+
requires: { hasCounterparty: true },
|
|
5497
|
+
blocked: []
|
|
5498
|
+
},
|
|
5499
|
+
{
|
|
5500
|
+
id: "request-status",
|
|
5501
|
+
title: "\u67E5\u8FD9\u4EFD\u5408\u540C\u7684\u5BA1\u6279\u8FDB\u5EA6",
|
|
5502
|
+
weight: 70,
|
|
5503
|
+
walk: "sendQuestion",
|
|
5504
|
+
desc: "\u770B\u5F53\u524D\u8282\u70B9\u4E0E\u5BA1\u6279\u610F\u89C1 \uFF5C \u53EA\u8BFB \uFF5C 1~2 \u6B65",
|
|
5505
|
+
requires: { submitted: true, requestId: "set" },
|
|
5506
|
+
blocked: []
|
|
5507
|
+
},
|
|
5508
|
+
{
|
|
5509
|
+
id: "compare",
|
|
5510
|
+
title: "\u6BD4\u5BF9\u4E24\u4EFD\u5408\u540C",
|
|
5511
|
+
weight: 60,
|
|
5512
|
+
walk: "e10Sdk",
|
|
5513
|
+
desc: "\u9010\u6761\u6BD4\u5DEE\u5F02 \uFF5C \u9700\u4E24\u4EFD\u6587\u4EF6 \uFF5C 2~3 \u6B65",
|
|
5514
|
+
requires: { otherVersionAvailable: true },
|
|
5515
|
+
blocked: ["compared"]
|
|
5516
|
+
},
|
|
5517
|
+
{
|
|
5518
|
+
id: "clause-rewrite",
|
|
5519
|
+
title: "\u6309\u5EFA\u8BAE\u6539\u6761\u6B3E",
|
|
5520
|
+
weight: 56,
|
|
5521
|
+
walk: "sendQuestion",
|
|
5522
|
+
desc: "\u628A\u5EFA\u8BAE\u6761\u6B3E\u5199\u56DE\u5408\u540C \uFF5C \u4F1A\u6539\u539F\u6587 \uFF5C \u9700\u786E\u8BA4 2 \u6B21",
|
|
5523
|
+
requires: { reviewed: true },
|
|
5524
|
+
blocked: []
|
|
5525
|
+
},
|
|
5526
|
+
{
|
|
5527
|
+
id: "summary",
|
|
5528
|
+
title: "\u67E5\u770B\u5408\u540C\u6458\u8981",
|
|
5529
|
+
weight: 28,
|
|
5530
|
+
walk: "artifact",
|
|
5531
|
+
desc: "\u8981\u7D20\u3001\u6807\u7684\u4E0E\u5173\u952E\u6761\u6B3E \uFF5C \u53EA\u8BFB \uFF5C \u70B9\u5F00\u5373\u770B",
|
|
5532
|
+
requires: { summaryReady: true },
|
|
5533
|
+
blocked: []
|
|
5534
|
+
}
|
|
5535
|
+
];
|
|
5536
|
+
var QUERY_ACTIONS = [
|
|
5537
|
+
{
|
|
5538
|
+
id: "query-contracts",
|
|
5539
|
+
title: "\u67E5\u6211\u8D1F\u8D23\u7684\u5408\u540C",
|
|
5540
|
+
weight: 100,
|
|
5541
|
+
walk: "sendQuestion",
|
|
5542
|
+
desc: "\u6309\u8D1F\u8D23\u4EBA\u67E5\u5408\u540C\u5217\u8868 \uFF5C \u53EA\u8BFB",
|
|
5543
|
+
requires: {},
|
|
5544
|
+
blocked: []
|
|
5545
|
+
},
|
|
5546
|
+
{
|
|
5547
|
+
id: "query-performance",
|
|
5548
|
+
title: "\u67E5\u76F4\u9500\u4E1A\u7EE9",
|
|
5549
|
+
weight: 90,
|
|
5550
|
+
walk: "sendQuestion",
|
|
5551
|
+
desc: "\u6309\u671F\u95F4\u6C47\u603B\u76F4\u9500\u4E1A\u7EE9 \uFF5C \u53EA\u8BFB",
|
|
5552
|
+
requires: {},
|
|
5553
|
+
blocked: []
|
|
5554
|
+
},
|
|
5555
|
+
{
|
|
5556
|
+
id: "query-receipts",
|
|
5557
|
+
title: "\u67E5\u5408\u540C\u6536\u6B3E",
|
|
5558
|
+
weight: 80,
|
|
5559
|
+
walk: "sendQuestion",
|
|
5560
|
+
desc: "\u6309\u5408\u540C\u53F7\u67E5\u6536\u6B3E\u53F0\u8D26 \uFF5C \u53EA\u8BFB",
|
|
5561
|
+
requires: {},
|
|
5562
|
+
blocked: []
|
|
5563
|
+
},
|
|
5564
|
+
{
|
|
5565
|
+
id: "query-channel",
|
|
5566
|
+
title: "\u67E5\u6E20\u9053\u8BA2\u5355",
|
|
5567
|
+
weight: 70,
|
|
5568
|
+
walk: "sendQuestion",
|
|
5569
|
+
desc: "\u6309\u6E20\u9053\u67E5\u8BA2\u5355 \uFF5C \u53EA\u8BFB",
|
|
5570
|
+
requires: {},
|
|
5571
|
+
blocked: []
|
|
5572
|
+
}
|
|
5573
|
+
];
|
|
5574
|
+
function pyTruthy(value) {
|
|
5575
|
+
if (value === null || value === void 0 || value === false) return false;
|
|
5576
|
+
if (value === true) return true;
|
|
5577
|
+
if (typeof value === "number") return value !== 0 && !Number.isNaN(value);
|
|
5578
|
+
if (typeof value === "string") return value.length > 0;
|
|
5579
|
+
if (Array.isArray(value)) return value.length > 0;
|
|
5580
|
+
if (typeof value === "object") return Object.keys(value).length > 0;
|
|
5581
|
+
return true;
|
|
5582
|
+
}
|
|
5583
|
+
function pyEq(left, right) {
|
|
5584
|
+
const toNum2 = (value) => {
|
|
5585
|
+
if (typeof value === "boolean") return value ? 1 : 0;
|
|
5586
|
+
if (typeof value === "number") return value;
|
|
5587
|
+
return null;
|
|
5588
|
+
};
|
|
5589
|
+
const ln = toNum2(left);
|
|
5590
|
+
const rn = toNum2(right);
|
|
5591
|
+
if (ln !== null && rn !== null) return ln === rn;
|
|
5592
|
+
if (left === null || left === void 0) return right === null || right === void 0;
|
|
5593
|
+
return left === right;
|
|
5594
|
+
}
|
|
5595
|
+
function matchOne(cond, ctx) {
|
|
5596
|
+
for (const [key, expect] of Object.entries(cond)) {
|
|
5597
|
+
const actual = ctx[key];
|
|
5598
|
+
if (expect === "set") {
|
|
5599
|
+
if (actual === null || actual === void 0 || actual === "" || actual === false) return false;
|
|
5600
|
+
if (typeof actual === "number" && actual === 0) return false;
|
|
5601
|
+
continue;
|
|
5602
|
+
}
|
|
5603
|
+
if (Array.isArray(expect)) {
|
|
5604
|
+
if (!expect.some((item) => pyEq(actual, item))) return false;
|
|
5605
|
+
continue;
|
|
5606
|
+
}
|
|
5607
|
+
if (pyTruthy(actual) !== pyTruthy(expect)) return false;
|
|
5608
|
+
}
|
|
5609
|
+
return true;
|
|
5286
5610
|
}
|
|
5287
|
-
function
|
|
5288
|
-
|
|
5611
|
+
function matches(action, ctx) {
|
|
5612
|
+
if (!matchOne(action.requires ?? {}, ctx)) return false;
|
|
5613
|
+
const anyOf = action.any_of;
|
|
5614
|
+
if (anyOf && anyOf.length) {
|
|
5615
|
+
if (!anyOf.some((cond) => matchOne(cond, ctx))) return false;
|
|
5616
|
+
}
|
|
5617
|
+
return true;
|
|
5289
5618
|
}
|
|
5290
|
-
function
|
|
5291
|
-
|
|
5619
|
+
function suppressed(action, ctx) {
|
|
5620
|
+
for (const key of action.blocked ?? []) {
|
|
5621
|
+
if (pyTruthy(ctx[key])) return true;
|
|
5622
|
+
}
|
|
5623
|
+
return ctx.lastAction === action.id;
|
|
5292
5624
|
}
|
|
5293
|
-
function
|
|
5294
|
-
|
|
5625
|
+
function planActions(ctx) {
|
|
5626
|
+
const rawScene = ctx.scene;
|
|
5627
|
+
const scene = pyTruthy(rawScene) ? String(rawScene) : "doc";
|
|
5628
|
+
const pool = scene === "query" || scene === "config" ? QUERY_ACTIONS : ACTIONS;
|
|
5629
|
+
const scored = pool.filter((action) => matches(action, ctx) && !suppressed(action, ctx));
|
|
5630
|
+
scored.sort((left, right) => {
|
|
5631
|
+
if (right.weight !== left.weight) return right.weight - left.weight;
|
|
5632
|
+
if (left.id < right.id) return -1;
|
|
5633
|
+
if (left.id > right.id) return 1;
|
|
5634
|
+
return 0;
|
|
5635
|
+
});
|
|
5636
|
+
const picked = scored.slice(0, MAX_CARDS);
|
|
5637
|
+
const flowKey = pyTruthy(ctx.flowKey) ? String(ctx.flowKey) : "";
|
|
5638
|
+
const cards = picked.map((action) => ({
|
|
5639
|
+
id: action.id,
|
|
5640
|
+
title: action.title.split("{flowKey}").join(flowKey),
|
|
5641
|
+
weight: action.weight,
|
|
5642
|
+
walk: action.walk,
|
|
5643
|
+
desc: action.desc
|
|
5644
|
+
}));
|
|
5645
|
+
return {
|
|
5646
|
+
scene,
|
|
5647
|
+
count: cards.length,
|
|
5648
|
+
title: `\u53EF\u505A\u7684 ${cards.length} \u4EF6\u4E8B`,
|
|
5649
|
+
cards,
|
|
5650
|
+
dropped: scored.slice(MAX_CARDS).map((action) => action.id),
|
|
5651
|
+
hint: cards.length ? "" : EMPTY_HINT
|
|
5652
|
+
};
|
|
5295
5653
|
}
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
5654
|
+
function resolveContext(input) {
|
|
5655
|
+
const direct = input.context;
|
|
5656
|
+
if (direct && typeof direct === "object" && !Array.isArray(direct)) {
|
|
5657
|
+
return direct;
|
|
5658
|
+
}
|
|
5659
|
+
const file = typeof input.contextFile === "string" && input.contextFile.trim() ? input.contextFile.trim() : "";
|
|
5660
|
+
const inline = typeof input.contextJson === "string" && input.contextJson.trim() ? input.contextJson.trim() : "";
|
|
5661
|
+
if (!file && !inline) {
|
|
5662
|
+
throw contractValidationError(
|
|
5663
|
+
"context_required",
|
|
5664
|
+
"\u5FC5\u987B\u63D0\u4F9B\u4E0A\u4E0B\u6587\uFF1Acontext\uFF08\u5BF9\u8C61\uFF09\u3001contextFile\uFF08JSON \u6587\u4EF6\u8DEF\u5F84\uFF09\u6216 contextJson\uFF08JSON \u5B57\u7B26\u4E32\uFF09\u4E09\u9009\u4E00"
|
|
5665
|
+
);
|
|
5666
|
+
}
|
|
5667
|
+
let raw;
|
|
5668
|
+
if (file) {
|
|
5669
|
+
try {
|
|
5670
|
+
raw = readFileSync5(resolve5(file), "utf8").replace(/^\uFEFF/u, "");
|
|
5671
|
+
} catch (error) {
|
|
5672
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
5673
|
+
throw contractValidationError("context_unreadable", `\u65E0\u6CD5\u8BFB\u53D6\u4E0A\u4E0B\u6587 JSON\uFF1A${message}`);
|
|
5302
5674
|
}
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
return { version: CACHE_VERSION, entries: {} };
|
|
5675
|
+
} else {
|
|
5676
|
+
raw = inline;
|
|
5306
5677
|
}
|
|
5307
|
-
|
|
5308
|
-
async function writeCache(cache) {
|
|
5678
|
+
let parsed;
|
|
5309
5679
|
try {
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5680
|
+
parsed = JSON.parse(raw);
|
|
5681
|
+
} catch (error) {
|
|
5682
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
5683
|
+
throw contractValidationError("context_invalid", `\u4E0A\u4E0B\u6587\u4E0D\u662F\u5408\u6CD5 JSON\uFF1A${message}`);
|
|
5314
5684
|
}
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
if (!isCacheEnabled()) return null;
|
|
5318
|
-
const cache = await readCache();
|
|
5319
|
-
const entry = cache.entries[key];
|
|
5320
|
-
if (!entry) return null;
|
|
5321
|
-
const age = Date.now() - entry.updatedAt;
|
|
5322
|
-
if (age > ttlMs()) {
|
|
5323
|
-
delete cache.entries[key];
|
|
5324
|
-
await writeCache(cache);
|
|
5325
|
-
return null;
|
|
5685
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
5686
|
+
throw contractValidationError("context_invalid", "\u4E0A\u4E0B\u6587\u5FC5\u987B\u662F JSON \u5BF9\u8C61");
|
|
5326
5687
|
}
|
|
5327
|
-
|
|
5328
|
-
await writeCache(cache);
|
|
5329
|
-
return entry;
|
|
5688
|
+
return parsed;
|
|
5330
5689
|
}
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
...entry,
|
|
5337
|
-
updatedAt: Date.now(),
|
|
5338
|
-
hits: previous?.hits ?? 0
|
|
5339
|
-
};
|
|
5340
|
-
const keys = Object.keys(cache.entries);
|
|
5341
|
-
if (keys.length > MAX_ENTRIES) {
|
|
5342
|
-
keys.sort((a, b) => cache.entries[a].updatedAt - cache.entries[b].updatedAt).slice(0, keys.length - MAX_ENTRIES).forEach((stale) => delete cache.entries[stale]);
|
|
5690
|
+
var contractCardPlanOperation = {
|
|
5691
|
+
name: "contract.card.plan",
|
|
5692
|
+
async execute(input) {
|
|
5693
|
+
const ctx = resolveContext(input);
|
|
5694
|
+
return { status: "COMPLETE", data: planActions(ctx) };
|
|
5343
5695
|
}
|
|
5344
|
-
|
|
5345
|
-
|
|
5696
|
+
};
|
|
5697
|
+
var contractCardPlanOperations = [contractCardPlanOperation];
|
|
5346
5698
|
|
|
5347
|
-
// src/shortcuts/contract/operations/
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
var
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5699
|
+
// src/shortcuts/contract/operations/card-ebdf-list.ts
|
|
5700
|
+
import { mkdirSync, writeFileSync as writeFileSync4 } from "node:fs";
|
|
5701
|
+
import { dirname as dirname2, resolve as resolve6 } from "node:path";
|
|
5702
|
+
var MENU_PAGES = /* @__PURE__ */ new Map([
|
|
5703
|
+
["\u76F4\u9500\u5408\u540C", "881124906081886244"],
|
|
5704
|
+
["\u76F4\u9500\u4E1A\u7EE9", "846297265322576586"],
|
|
5705
|
+
["\u5408\u540C\u6536\u6B3E", "846297265322576589"],
|
|
5706
|
+
["\u9879\u76EE\u9A8C\u6536", "846297265322576590"],
|
|
5707
|
+
["\u6E20\u9053\u8BA2\u5355", "881210951456350225"],
|
|
5708
|
+
["\u6E20\u9053\u8BA2\u5355-\u5546\u52A1", "881211329321197671"]
|
|
5709
|
+
]);
|
|
5710
|
+
var ALIASES = /* @__PURE__ */ new Map([
|
|
5711
|
+
["e-cology\u5408\u540C", "\u76F4\u9500\u5408\u540C"],
|
|
5712
|
+
["e-cology \u5408\u540C", "\u76F4\u9500\u5408\u540C"],
|
|
5713
|
+
["\u5408\u540C\u6570\u636E", "\u76F4\u9500\u5408\u540C"],
|
|
5714
|
+
["\u76F4\u9500\u5408\u540C\u6570\u636E", "\u76F4\u9500\u5408\u540C"],
|
|
5715
|
+
["\u4E1A\u7EE9", "\u76F4\u9500\u4E1A\u7EE9"],
|
|
5716
|
+
["\u4E2A\u4EBA\u4E1A\u7EE9", "\u76F4\u9500\u4E1A\u7EE9"],
|
|
5717
|
+
["\u673A\u6784\u4E1A\u7EE9", "\u76F4\u9500\u4E1A\u7EE9"],
|
|
5718
|
+
["\u5927\u533A\u4E1A\u7EE9", "\u76F4\u9500\u4E1A\u7EE9"],
|
|
5719
|
+
["\u56E2\u961F\u4E1A\u7EE9", "\u76F4\u9500\u4E1A\u7EE9"],
|
|
5720
|
+
["\u5408\u540C\u6536\u6B3E\u4FE1\u606F", "\u5408\u540C\u6536\u6B3E"],
|
|
5721
|
+
["\u6536\u6B3E", "\u5408\u540C\u6536\u6B3E"],
|
|
5722
|
+
["\u9A8C\u6536", "\u9879\u76EE\u9A8C\u6536"],
|
|
5723
|
+
["\u9879\u76EE\u9A8C\u6536\u6570\u636E", "\u9879\u76EE\u9A8C\u6536"],
|
|
5724
|
+
["\u6E20\u9053\u8BA2\u5355\u6570\u636E", "\u6E20\u9053\u8BA2\u5355"],
|
|
5725
|
+
["e-office\u5408\u540C", "\u6E20\u9053\u8BA2\u5355"],
|
|
5726
|
+
["e-teams\u5408\u540C", "\u6E20\u9053\u8BA2\u5355"],
|
|
5727
|
+
["\u6E20\u9053\u534F\u8BAE", "\u6E20\u9053\u8BA2\u5355-\u5546\u52A1"],
|
|
5728
|
+
["e-office\u534F\u8BAE\u8BA2\u5355", "\u6E20\u9053\u8BA2\u5355-\u5546\u52A1"],
|
|
5729
|
+
["\u5546\u52A1\u6E20\u9053\u8BA2\u5355", "\u6E20\u9053\u8BA2\u5355-\u5546\u52A1"],
|
|
5730
|
+
["\u6E20\u9053\u8BA2\u5355\u5546\u52A1", "\u6E20\u9053\u8BA2\u5355-\u5546\u52A1"]
|
|
5731
|
+
]);
|
|
5732
|
+
var FIELD_KEY = /^field_\d+$/u;
|
|
5733
|
+
var PAGE_ID = /^\d{6,}$/u;
|
|
5734
|
+
var ORIGIN = /^https?:\/\/[^/]+$/u;
|
|
5735
|
+
function pyStr(value) {
|
|
5736
|
+
if (value === null || value === void 0) return "None";
|
|
5737
|
+
if (value === true) return "True";
|
|
5738
|
+
if (value === false) return "False";
|
|
5739
|
+
if (typeof value === "string") return value;
|
|
5740
|
+
if (typeof value === "number") return String(value);
|
|
5741
|
+
if (Array.isArray(value)) return `[${value.map((item) => pyRepr(item)).join(", ")}]`;
|
|
5742
|
+
if (typeof value === "object") {
|
|
5743
|
+
return `{${Object.entries(value).map(([key, val]) => `${pyRepr(key)}: ${pyRepr(val)}`).join(", ")}}`;
|
|
5744
|
+
}
|
|
5745
|
+
return String(value);
|
|
5746
|
+
}
|
|
5747
|
+
function pyRepr(value) {
|
|
5748
|
+
return typeof value === "string" ? `'${value}'` : pyStr(value);
|
|
5749
|
+
}
|
|
5750
|
+
function pyReprText(value) {
|
|
5751
|
+
return typeof value === "string" ? `'${value}'` : pyStr(value);
|
|
5752
|
+
}
|
|
5753
|
+
function stripOrEmpty(value) {
|
|
5754
|
+
if (typeof value !== "string") {
|
|
5755
|
+
if (value === null || value === void 0 || value === false || value === 0) return "";
|
|
5756
|
+
return String(value).trim();
|
|
5757
|
+
}
|
|
5758
|
+
return value.trim();
|
|
5759
|
+
}
|
|
5760
|
+
function resolveMenu(raw) {
|
|
5761
|
+
const name = stripOrEmpty(raw);
|
|
5762
|
+
if (MENU_PAGES.has(name)) {
|
|
5763
|
+
return { menu: name, pageId: MENU_PAGES.get(name) };
|
|
5764
|
+
}
|
|
5765
|
+
if (ALIASES.has(name)) {
|
|
5766
|
+
const real = ALIASES.get(name);
|
|
5767
|
+
return { menu: real, pageId: MENU_PAGES.get(real) };
|
|
5768
|
+
}
|
|
5769
|
+
const hits = [];
|
|
5770
|
+
for (const key of MENU_PAGES.keys()) {
|
|
5771
|
+
if (name && (key.includes(name) || name.includes(key))) hits.push(key);
|
|
5772
|
+
}
|
|
5773
|
+
if (hits.length === 1) {
|
|
5774
|
+
return { menu: hits[0], pageId: MENU_PAGES.get(hits[0]) };
|
|
5775
|
+
}
|
|
5776
|
+
const options = [...MENU_PAGES.keys()].join("\u3001");
|
|
5777
|
+
throw contractValidationError("menu_unknown", `\u672A\u77E5\u83DC\u5355 ${pyReprText(raw)}\uFF0C\u53EF\u9009\uFF1A${options}`);
|
|
5778
|
+
}
|
|
5779
|
+
function cleanOrigin(raw) {
|
|
5780
|
+
const origin = stripOrEmpty(raw).replace(/\/+$/u, "");
|
|
5781
|
+
if (!origin) throw contractValidationError("origin_required", "\u7F3A\u5C11 origin");
|
|
5782
|
+
if (origin.includes("{baseUrl}")) {
|
|
5783
|
+
throw contractValidationError("origin_placeholder", "origin \u4ECD\u662F\u5360\u4F4D\u7B26 {baseUrl}");
|
|
5784
|
+
}
|
|
5785
|
+
if (!ORIGIN.test(origin)) {
|
|
5786
|
+
throw contractValidationError("origin_invalid", "origin \u53EA\u80FD\u662F scheme+host\uFF0C\u4E0D\u80FD\u5E26\u8DEF\u5F84\u3001query \u6216\u7528\u6237\u4FE1\u606F");
|
|
5787
|
+
}
|
|
5788
|
+
return origin;
|
|
5789
|
+
}
|
|
5790
|
+
function parseComParams(pairs, rawJson) {
|
|
5791
|
+
const pairList = Array.isArray(pairs) ? pairs : [];
|
|
5792
|
+
const jsonText = typeof rawJson === "string" && rawJson.trim() ? rawJson : "";
|
|
5793
|
+
if (pairList.length && jsonText) {
|
|
5794
|
+
throw contractValidationError("com_params_conflict", "comParamPairs \u4E0E comParamsJson \u53EA\u80FD\u4E8C\u9009\u4E00");
|
|
5795
|
+
}
|
|
5796
|
+
const merged = {};
|
|
5797
|
+
if (jsonText) {
|
|
5798
|
+
let parsed;
|
|
5799
|
+
try {
|
|
5800
|
+
parsed = JSON.parse(jsonText);
|
|
5801
|
+
} catch (error) {
|
|
5802
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
5803
|
+
throw contractValidationError("com_params_invalid", `comParamsJson \u4E0D\u662F\u5408\u6CD5 JSON\uFF1A${message}`);
|
|
5804
|
+
}
|
|
5805
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
5806
|
+
throw contractValidationError("com_params_invalid", "comParamsJson \u5FC5\u987B\u662F\u5BF9\u8C61");
|
|
5807
|
+
}
|
|
5808
|
+
Object.assign(merged, parsed);
|
|
5364
5809
|
}
|
|
5365
|
-
|
|
5366
|
-
|
|
5810
|
+
for (const item of pairList) {
|
|
5811
|
+
const text4 = typeof item === "string" ? item : pyStr(item);
|
|
5812
|
+
const index = text4.indexOf("=");
|
|
5813
|
+
if (index < 0) {
|
|
5814
|
+
throw contractValidationError("com_param_invalid", `comParamPairs \u9700\u8981 key=value\uFF0C\u6536\u5230 ${pyReprText(item)}`);
|
|
5815
|
+
}
|
|
5816
|
+
const key = text4.slice(0, index).trim();
|
|
5817
|
+
merged[key] = text4.slice(index + 1);
|
|
5367
5818
|
}
|
|
5368
|
-
|
|
5369
|
-
|
|
5819
|
+
const out = {};
|
|
5820
|
+
for (const [key, value] of Object.entries(merged)) {
|
|
5821
|
+
if (!FIELD_KEY.test(String(key))) {
|
|
5822
|
+
throw contractValidationError("com_param_key_invalid", `\u6761\u4EF6\u952E\u5FC5\u987B\u662F field_<\u5B57\u6BB5id>\uFF0C\u6536\u5230 ${pyReprText(key)}`);
|
|
5823
|
+
}
|
|
5824
|
+
out[String(key)] = typeof value === "string" ? value : pyStr(value);
|
|
5370
5825
|
}
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
|
|
5386
|
-
|
|
5387
|
-
|
|
5388
|
-
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
|
|
5826
|
+
return out;
|
|
5827
|
+
}
|
|
5828
|
+
function pad2(value) {
|
|
5829
|
+
return String(value).padStart(2, "0");
|
|
5830
|
+
}
|
|
5831
|
+
function stampNow() {
|
|
5832
|
+
const now = /* @__PURE__ */ new Date();
|
|
5833
|
+
return `${now.getFullYear()}${pad2(now.getMonth() + 1)}${pad2(now.getDate())}${pad2(now.getHours())}${pad2(now.getMinutes())}`;
|
|
5834
|
+
}
|
|
5835
|
+
function buildCard(pageId, origin, title, callId, comParams) {
|
|
5836
|
+
const route = `/list/${pageId}`;
|
|
5837
|
+
return {
|
|
5838
|
+
version: 1,
|
|
5839
|
+
callId,
|
|
5840
|
+
toolId: "fill_form",
|
|
5841
|
+
arguments: {
|
|
5842
|
+
type: "e10",
|
|
5843
|
+
title,
|
|
5844
|
+
src: `${origin}/sp/ebdfpage/list/${pageId}`,
|
|
5845
|
+
sdkRenderType: "inline",
|
|
5846
|
+
sdkOptions: {
|
|
5847
|
+
compName: "ui.CorsComponent",
|
|
5848
|
+
routerType: "MemoryRouter",
|
|
5849
|
+
routerProps_pc: { initialEntries: [route] },
|
|
5850
|
+
routerProps_mobile: { initialEntries: [route] },
|
|
5851
|
+
params_pc: {
|
|
5852
|
+
app: "@weapp/ebdfpage",
|
|
5853
|
+
compName: "TableViewList",
|
|
5854
|
+
noMDialog: true
|
|
5855
|
+
},
|
|
5856
|
+
params_mobile: {
|
|
5857
|
+
app: "@weapp/ebdfpage",
|
|
5858
|
+
compName: "MTableViewList",
|
|
5859
|
+
noMDialog: true
|
|
5860
|
+
},
|
|
5861
|
+
params: {
|
|
5862
|
+
pageId,
|
|
5863
|
+
comParams
|
|
5864
|
+
}
|
|
5397
5865
|
}
|
|
5398
|
-
} catch {
|
|
5399
|
-
reuseKey = null;
|
|
5400
5866
|
}
|
|
5401
|
-
}
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5867
|
+
};
|
|
5868
|
+
}
|
|
5869
|
+
function selfCheck(card, pageId) {
|
|
5870
|
+
const bad = [];
|
|
5871
|
+
const args = card.arguments ?? {};
|
|
5872
|
+
const options = args.sdkOptions ?? {};
|
|
5873
|
+
const pc = options.params_pc ?? {};
|
|
5874
|
+
const mobile = options.params_mobile ?? {};
|
|
5875
|
+
const params = options.params ?? {};
|
|
5876
|
+
const routerPc = options.routerProps_pc ?? {};
|
|
5877
|
+
const routerMobile = options.routerProps_mobile ?? {};
|
|
5878
|
+
if (card.version !== 1) bad.push("version != 1");
|
|
5879
|
+
if (card.toolId !== "fill_form") bad.push("toolId != fill_form");
|
|
5880
|
+
if (!card.callId) bad.push("callId \u4E3A\u7A7A");
|
|
5881
|
+
if (args.type !== "e10") bad.push("arguments.type != e10");
|
|
5882
|
+
if (args.sdkRenderType !== "inline") bad.push("sdkRenderType != inline");
|
|
5883
|
+
if ("width" in args) bad.push("ebdf \u5217\u8868\u5361\u4E0D\u5E94\u5E26 arguments.width");
|
|
5884
|
+
if (!String(args.src ?? "").endsWith(`/sp/ebdfpage/list/${pageId}`)) bad.push("src \u4E0E pageId \u4E0D\u4E00\u81F4");
|
|
5885
|
+
if (options.compName !== "ui.CorsComponent") bad.push("sdkOptions.compName != ui.CorsComponent");
|
|
5886
|
+
if (options.routerType !== "MemoryRouter") bad.push("routerType != MemoryRouter");
|
|
5887
|
+
if (pc.app !== "@weapp/ebdfpage" || pc.compName !== "TableViewList") bad.push("params_pc \u7EC4\u4EF6\u4E0D\u5BF9");
|
|
5888
|
+
if (mobile.app !== "@weapp/ebdfpage" || mobile.compName !== "MTableViewList") bad.push("params_mobile \u7EC4\u4EF6\u4E0D\u5BF9");
|
|
5889
|
+
if (pc.noMDialog !== true || mobile.noMDialog !== true) bad.push("noMDialog \u672A\u540C\u65F6\u4E3A true");
|
|
5890
|
+
if (params.pageId !== pageId) bad.push("params.pageId \u4E0E pageId \u4E0D\u4E00\u81F4");
|
|
5891
|
+
const want = [`/list/${pageId}`];
|
|
5892
|
+
if (JSON.stringify(routerPc.initialEntries) !== JSON.stringify(want) || JSON.stringify(routerMobile.initialEntries) !== JSON.stringify(want)) {
|
|
5893
|
+
bad.push("initialEntries \u4E0E pageId \u4E0D\u4E00\u81F4");
|
|
5894
|
+
}
|
|
5895
|
+
const comParams = params.comParams;
|
|
5896
|
+
if (!comParams || typeof comParams !== "object" || Array.isArray(comParams)) {
|
|
5897
|
+
bad.push("comParams \u4E0D\u662F\u5BF9\u8C61");
|
|
5898
|
+
} else {
|
|
5899
|
+
for (const [key, value] of Object.entries(comParams)) {
|
|
5900
|
+
if (!FIELD_KEY.test(key)) bad.push(`comParams \u952E\u683C\u5F0F\u9519\u8BEF\uFF1A${pyReprText(key)}`);
|
|
5901
|
+
if (typeof value !== "string") bad.push(`comParams \u503C\u4E0D\u662F\u5B57\u7B26\u4E32\uFF1A${pyReprText(key)}`);
|
|
5902
|
+
}
|
|
5903
|
+
}
|
|
5904
|
+
return bad;
|
|
5905
|
+
}
|
|
5906
|
+
var contractCardEbdfListOperation = {
|
|
5907
|
+
name: "contract.card.ebdf-list",
|
|
5908
|
+
async execute(input) {
|
|
5909
|
+
const rawPageId = stripOrEmpty(input.pageId);
|
|
5910
|
+
let menu;
|
|
5911
|
+
let pageId;
|
|
5912
|
+
if (rawPageId) {
|
|
5913
|
+
if (!PAGE_ID.test(rawPageId)) {
|
|
5914
|
+
throw contractValidationError("page_id_invalid", `pageId \u5FC5\u987B\u662F\u6570\u5B57\u4E32\uFF0C\u6536\u5230 ${pyReprText(rawPageId)}`);
|
|
5915
|
+
}
|
|
5916
|
+
pageId = rawPageId;
|
|
5917
|
+
const menuInput = stripOrEmpty(input.menu);
|
|
5918
|
+
menu = menuInput || pageId;
|
|
5919
|
+
} else {
|
|
5920
|
+
const resolved = resolveMenu(input.menu);
|
|
5921
|
+
menu = resolved.menu;
|
|
5922
|
+
pageId = resolved.pageId;
|
|
5923
|
+
}
|
|
5924
|
+
const origin = cleanOrigin(input.origin);
|
|
5925
|
+
const comParams = parseComParams(input.comParamPairs, input.comParamsJson);
|
|
5926
|
+
const titleInput = stripOrEmpty(input.title);
|
|
5927
|
+
const title = titleInput || menu;
|
|
5928
|
+
if (!title) throw contractValidationError("title_required", "title \u4E0D\u80FD\u4E3A\u7A7A");
|
|
5929
|
+
const callIdInput = stripOrEmpty(input.callId);
|
|
5930
|
+
const callId = callIdInput || `ebdf-list-${menu}-${stampNow()}-01`;
|
|
5931
|
+
const card = buildCard(pageId, origin, title, callId, comParams);
|
|
5932
|
+
const problems = selfCheck(card, pageId);
|
|
5933
|
+
if (problems.length) {
|
|
5934
|
+
throw contractValidationError("self_check_failed", `ebdf \u5217\u8868\u5361\u81EA\u68C0\u672A\u901A\u8FC7\uFF1A${problems.join("\uFF1B")}`);
|
|
5935
|
+
}
|
|
5936
|
+
let output;
|
|
5937
|
+
if (typeof input.out === "string" && input.out.trim()) {
|
|
5938
|
+
output = resolve6(input.out.trim());
|
|
5939
|
+
mkdirSync(dirname2(output), { recursive: true });
|
|
5940
|
+
writeFileSync4(output, `${JSON.stringify(card, null, 2)}
|
|
5941
|
+
`, "utf8");
|
|
5942
|
+
}
|
|
5943
|
+
return {
|
|
5944
|
+
status: "COMPLETE",
|
|
5945
|
+
data: {
|
|
5946
|
+
menu,
|
|
5947
|
+
pageId,
|
|
5948
|
+
callId,
|
|
5949
|
+
comParams,
|
|
5950
|
+
card,
|
|
5951
|
+
selfCheck: problems,
|
|
5952
|
+
...output ? { output } : {},
|
|
5953
|
+
note: "ebdf \u5217\u8868\u5361\u4E0D\u5E26 arguments.width\uFF1BcomParams \u952E\u5FC5\u987B\u662F field_<\u5B57\u6BB5id>"
|
|
5954
|
+
}
|
|
5955
|
+
};
|
|
5956
|
+
}
|
|
5957
|
+
};
|
|
5958
|
+
var contractCardEbdfListOperations = [contractCardEbdfListOperation];
|
|
5959
|
+
|
|
5960
|
+
// src/shortcuts/contract/operations/card-risk-report.ts
|
|
5961
|
+
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync6, statSync, writeFileSync as writeFileSync5 } from "node:fs";
|
|
5962
|
+
import { dirname as dirname3, resolve as resolve7 } from "node:path";
|
|
5963
|
+
var DEFAULT_AIID = "1326842382967570463";
|
|
5964
|
+
var DEFAULT_SRC_PATH = "/sp/contract/business/ai-contract";
|
|
5965
|
+
var DEFAULT_BASE = "https://www.e-cology.com.cn";
|
|
5966
|
+
var DEFAULT_TEMPLATE = `<section id='{{CARD_ID}}' style='padding:16px 18px;font-family:sans-serif;background:#fafbfd;border-radius:12px'>
|
|
5967
|
+
|
|
5968
|
+
<div style='display:flex;align-items:center;justify-content:space-between;margin-bottom:16px'>
|
|
5969
|
+
<div>
|
|
5970
|
+
<div style='font-size:17px;font-weight:700;color:#1f2430'>\u5408\u540C\u98CE\u9669\u5BA1\u67E5\u62A5\u544A</div>
|
|
5971
|
+
<div style='font-size:12px;color:#7a8497;margin-top:4px'>{{CONTRACT_NAME}}</div>
|
|
5972
|
+
</div>
|
|
5973
|
+
<div style='flex:0 0 auto;display:flex;align-items:center;gap:8px'>
|
|
5974
|
+
<button type='button' data-act='download' style='background:#fff;color:#1d6fd8;border:1px solid #1d6fd8;border-radius:8px;padding:8px 16px;font-size:13px;font-weight:600;cursor:pointer;font-family:inherit'>\u4E0B\u8F7D\u62A5\u544A</button>
|
|
5975
|
+
<button type='button' data-act='detail' style='background:#1d6fd8;color:#fff;border:none;border-radius:8px;padding:9px 18px;font-size:13px;font-weight:600;cursor:pointer;font-family:inherit'>\u67E5\u770B\u5BA1\u67E5\u8BE6\u60C5</button>
|
|
5976
|
+
</div>
|
|
5977
|
+
</div>
|
|
5978
|
+
|
|
5979
|
+
<div style='background:#fff;border:1px solid #e8ebf2;border-radius:12px;padding:16px;margin-bottom:14px'>
|
|
5980
|
+
<div style='font-size:14px;font-weight:700;color:#1f2430;margin-bottom:12px'>\u5BA1\u67E5\u57FA\u672C\u4FE1\u606F</div>
|
|
5981
|
+
<table style='border-collapse:collapse;width:100%;font-size:13px'>{{TINFO}}</table>
|
|
5982
|
+
</div>
|
|
5983
|
+
|
|
5984
|
+
<div style='font-size:14px;font-weight:700;color:#1f2430;margin:0 0 10px 2px'>\u5BA1\u67E5\u7EDF\u8BA1</div>
|
|
5985
|
+
<div style='display:flex;gap:12px;margin-bottom:18px;flex-wrap:wrap'>
|
|
5986
|
+
<div style='flex:1;min-width:130px;background:#fff;border:1px solid #e8ebf2;border-radius:12px;padding:16px;text-align:center'>
|
|
5987
|
+
<div style='font-size:26px;font-weight:700;color:#1f2430'>{{STAT_TOTAL}}</div>
|
|
5988
|
+
<div style='font-size:12px;color:#7a8497;margin-top:4px'>\u5BA1\u67E5\u89C4\u5219\u603B\u6570</div>
|
|
5989
|
+
</div>
|
|
5990
|
+
<div style='flex:1;min-width:130px;background:#fff;border:1px solid #e8ebf2;border-radius:12px;padding:16px;text-align:center'>
|
|
5991
|
+
<div style='font-size:26px;font-weight:700;color:#1a9c5b'>{{STAT_NO_RISK}}</div>
|
|
5992
|
+
<div style='font-size:12px;color:#7a8497;margin-top:4px'>\u5224\u5B9A\u65E0\u98CE\u9669</div>
|
|
5993
|
+
</div>
|
|
5994
|
+
<div style='flex:1;min-width:130px;background:#fff;border:1px solid #e8ebf2;border-radius:12px;padding:16px;text-align:center'>
|
|
5995
|
+
<div style='font-size:26px;font-weight:700;color:#c0392b'>{{STAT_RISK}}</div>
|
|
5996
|
+
<div style='font-size:12px;color:#7a8497;margin-top:4px'>\u5224\u5B9A\u6709\u98CE\u9669</div>
|
|
5997
|
+
</div>
|
|
5998
|
+
</div>
|
|
5999
|
+
|
|
6000
|
+
<div style='font-size:14px;font-weight:700;color:#1f2430;margin:18px 0 10px 2px'>\u98CE\u9669\u8BE6\u60C5\uFF08{{RISK_COUNT}} \u6761\uFF09</div>
|
|
6001
|
+
{{RISK_ITEMS}}
|
|
6002
|
+
|
|
6003
|
+
<div style='background:#fff;border:1px solid #e8ebf2;border-radius:12px;padding:16px;margin-top:6px'>
|
|
6004
|
+
<div style='font-size:14px;font-weight:700;color:#1f2430;margin-bottom:4px'>\u5BA1\u67E5\u901A\u8FC7\uFF08{{PASS_COUNT}} \u6761\uFF09</div>
|
|
6005
|
+
<div style='font-size:12px;color:#7a8497;margin-bottom:12px'>\u4EE5\u4E0B\u89C4\u5219\u5DF2\u6267\u884C\u5224\u5B9A\uFF0C\u672A\u53D1\u73B0\u4E0E\u89C4\u5219\u51B2\u7A81\u7684\u6761\u6B3E</div>
|
|
6006
|
+
{{PASS_TAGS}}
|
|
6007
|
+
</div>
|
|
6008
|
+
|
|
6009
|
+
<p data-status style='margin:10px 0 0;color:#b45309;font-size:12px'></p>
|
|
6010
|
+
</section>
|
|
6011
|
+
<script>
|
|
6012
|
+
(function () {
|
|
6013
|
+
var CARD_ID = '{{CARD_ID}}';
|
|
6014
|
+
var FILE_BASE = '{{FILE_BASE}}';
|
|
6015
|
+
|
|
6016
|
+
function getRoot() {
|
|
6017
|
+
var el = null;
|
|
6018
|
+
var sc = document.currentScript;
|
|
6019
|
+
if (sc && sc.previousElementSibling && sc.previousElementSibling.id === CARD_ID) {
|
|
6020
|
+
el = sc.previousElementSibling;
|
|
6021
|
+
}
|
|
6022
|
+
if (!el) { el = document.getElementById(CARD_ID); }
|
|
6023
|
+
if (!el && document.querySelector) { el = document.querySelector('#' + CARD_ID); }
|
|
6024
|
+
return el;
|
|
6025
|
+
}
|
|
6026
|
+
|
|
6027
|
+
var root = getRoot();
|
|
6028
|
+
if (!root) { return; }
|
|
6029
|
+
|
|
6030
|
+
var statusEl = root.querySelector('[data-status]');
|
|
6031
|
+
function say(m) { if (statusEl) { statusEl.textContent = m; } }
|
|
6032
|
+
|
|
6033
|
+
function getPlugin() {
|
|
6034
|
+
if (window.xiaoePlugin) { return window.xiaoePlugin; }
|
|
6035
|
+
if (window.rawWindow && window.rawWindow.xiaoePlugin) { return window.rawWindow.xiaoePlugin; }
|
|
6036
|
+
return null;
|
|
6037
|
+
}
|
|
6038
|
+
|
|
6039
|
+
var DETAIL_CFG = {{DETAIL_CFG}};
|
|
6040
|
+
|
|
6041
|
+
function openDetail() {
|
|
6042
|
+
var plugin = getPlugin();
|
|
6043
|
+
if (!plugin || !plugin.rightPanel || typeof plugin.rightPanel.open !== 'function') {
|
|
6044
|
+
say('\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u6253\u5F00\u53F3\u4FA7\u9762\u677F\uFF0C\u8BF7\u5728\u5C0Fe\u5BA2\u6237\u7AEF\u5185\u67E5\u770B');
|
|
6045
|
+
return;
|
|
6046
|
+
}
|
|
6047
|
+
say('\u6B63\u5728\u6253\u5F00\u5BA1\u67E5\u8BE6\u60C5\u2026');
|
|
6048
|
+
try {
|
|
6049
|
+
plugin.rightPanel.open(DETAIL_CFG);
|
|
6050
|
+
say('');
|
|
6051
|
+
} catch (err) {
|
|
6052
|
+
say('\u5BA1\u67E5\u8BE6\u60C5\u6253\u5F00\u5931\u8D25\uFF0C\u8BF7\u786E\u8BA4\u53F3\u4FA7\u9762\u677F\u5DF2\u6302\u8F7D');
|
|
6053
|
+
}
|
|
6054
|
+
}
|
|
6055
|
+
|
|
6056
|
+
// \u5BFC\u51FA\u524D\u5148\u514B\u9686\uFF0C\u53BB\u6389\u811A\u672C\u3001\u6309\u94AE\u4E0E\u63D0\u793A\u4F4D\uFF0C\u5F97\u5230\u5E72\u51C0\u7684\u9759\u6001\u62A5\u544A
|
|
6057
|
+
function cleanClone() {
|
|
6058
|
+
var clone = root.cloneNode(true);
|
|
6059
|
+
var nodes = clone.querySelectorAll('script, [data-act], [data-status]');
|
|
6060
|
+
var i;
|
|
6061
|
+
for (i = nodes.length - 1; i >= 0; i--) {
|
|
6062
|
+
if (nodes[i].parentNode) { nodes[i].parentNode.removeChild(nodes[i]); }
|
|
6063
|
+
}
|
|
6064
|
+
return clone;
|
|
6065
|
+
}
|
|
6066
|
+
|
|
6067
|
+
function downloadReport() {
|
|
6068
|
+
var doc = root.ownerDocument || document;
|
|
6069
|
+
var clone = cleanClone();
|
|
6070
|
+
var html = '<!DOCTYPE html><html><head><meta charset=\\'utf-8\\'>'
|
|
6071
|
+
+ '<title>' + FILE_BASE + '</title>'
|
|
6072
|
+
+ '<style>body{margin:0;padding:16px;background:#fafbfd;font-family:sans-serif}'
|
|
6073
|
+
+ '@media print{body{background:#fff}}</style></head><body>'
|
|
6074
|
+
+ clone.outerHTML + '</body></html>';
|
|
6075
|
+
|
|
6076
|
+
if (!window.Blob || !window.URL || typeof window.URL.createObjectURL !== 'function') {
|
|
6077
|
+
say('\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u6587\u4EF6\u4E0B\u8F7D\uFF0C\u8BF7\u5728\u5C0Fe\u5BA2\u6237\u7AEF\u5185\u4F7F\u7528');
|
|
6078
|
+
return;
|
|
6079
|
+
}
|
|
6080
|
+
|
|
6081
|
+
var url;
|
|
6082
|
+
try {
|
|
6083
|
+
url = window.URL.createObjectURL(new Blob([html], { type: 'text/html;charset=utf-8' }));
|
|
6084
|
+
} catch (err) {
|
|
6085
|
+
say('\u62A5\u544A\u751F\u6210\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5');
|
|
6086
|
+
return;
|
|
6087
|
+
}
|
|
6088
|
+
|
|
6089
|
+
var a = doc.createElement('a');
|
|
6090
|
+
a.href = url;
|
|
6091
|
+
a.download = FILE_BASE + '.html';
|
|
6092
|
+
a.style.display = 'none';
|
|
6093
|
+
if (doc.body && doc.body.appendChild) { doc.body.appendChild(a); }
|
|
6094
|
+
a.click();
|
|
6095
|
+
if (a.parentNode) { a.parentNode.removeChild(a); }
|
|
6096
|
+
setTimeout(function () { window.URL.revokeObjectURL(url); }, 1500);
|
|
6097
|
+
say('\u62A5\u544A\u5DF2\u5F00\u59CB\u4E0B\u8F7D\uFF1A' + FILE_BASE + '.html');
|
|
6098
|
+
}
|
|
6099
|
+
|
|
6100
|
+
// \u4E8B\u4EF6\u59D4\u6258\uFF1A\u7ED1\u5B9A\u5728\u62A5\u544A\u6839\u8282\u70B9\u4E0A\uFF0C\u907F\u514D\u5B50\u5143\u7D20\u53D6\u4E0D\u5230\u5BFC\u81F4\u70B9\u51FB\u65E0\u54CD\u5E94
|
|
6101
|
+
root.addEventListener('click', function (e) {
|
|
6102
|
+
var t = e.target;
|
|
6103
|
+
var act = null;
|
|
6104
|
+
while (t && t !== root) {
|
|
6105
|
+
if (t.getAttribute) {
|
|
6106
|
+
act = t.getAttribute('data-act');
|
|
6107
|
+
if (act) { break; }
|
|
6108
|
+
}
|
|
6109
|
+
t = t.parentNode;
|
|
6110
|
+
}
|
|
6111
|
+
if (act === 'detail') { openDetail(); return; }
|
|
6112
|
+
if (act === 'download') { downloadReport(); return; }
|
|
6113
|
+
});
|
|
6114
|
+
|
|
6115
|
+
root.addEventListener('mouseover', function (e) {
|
|
6116
|
+
var t = e.target;
|
|
6117
|
+
var act = null;
|
|
6118
|
+
while (t && t !== root) {
|
|
6119
|
+
if (t.getAttribute) {
|
|
6120
|
+
act = t.getAttribute('data-act');
|
|
6121
|
+
if (act) { break; }
|
|
6122
|
+
}
|
|
6123
|
+
t = t.parentNode;
|
|
6124
|
+
}
|
|
6125
|
+
if (act === 'detail') { t.style.background = '#1659b8'; }
|
|
6126
|
+
if (act === 'download') { t.style.background = '#eef4fd'; }
|
|
6127
|
+
});
|
|
6128
|
+
|
|
6129
|
+
root.addEventListener('mouseout', function (e) {
|
|
6130
|
+
var t = e.target;
|
|
6131
|
+
var act = null;
|
|
6132
|
+
while (t && t !== root) {
|
|
6133
|
+
if (t.getAttribute) {
|
|
6134
|
+
act = t.getAttribute('data-act');
|
|
6135
|
+
if (act) { break; }
|
|
6136
|
+
}
|
|
6137
|
+
t = t.parentNode;
|
|
6138
|
+
}
|
|
6139
|
+
if (act === 'detail') { t.style.background = '#1d6fd8'; }
|
|
6140
|
+
if (act === 'download') { t.style.background = '#fff'; }
|
|
6141
|
+
});
|
|
6142
|
+
})();
|
|
6143
|
+
</script>
|
|
6144
|
+
`;
|
|
6145
|
+
function truthyText(value) {
|
|
6146
|
+
if (value === null || value === void 0 || value === false || value === "" || value === 0) return "";
|
|
6147
|
+
return String(value);
|
|
6148
|
+
}
|
|
6149
|
+
function esc2(value) {
|
|
6150
|
+
const text4 = truthyText(value);
|
|
6151
|
+
return text4.replace(/&/gu, "&").replace(/</gu, "<").replace(/>/gu, ">").replace(/"/gu, "'").replace(/'/gu, "'");
|
|
6152
|
+
}
|
|
6153
|
+
function readJson(path) {
|
|
6154
|
+
const raw = readFileSync6(path, "utf8").replace(/^\uFEFF/u, "");
|
|
6155
|
+
const parsed = JSON.parse(raw);
|
|
6156
|
+
if (!parsed || typeof parsed !== "object") throw new Error("JSON \u6839\u8282\u70B9\u4E0D\u662F\u5BF9\u8C61");
|
|
6157
|
+
return parsed;
|
|
6158
|
+
}
|
|
6159
|
+
function isFile(path) {
|
|
6160
|
+
try {
|
|
6161
|
+
return existsSync2(path) && statSync(path).isFile();
|
|
6162
|
+
} catch {
|
|
6163
|
+
return false;
|
|
6164
|
+
}
|
|
6165
|
+
}
|
|
6166
|
+
function ruleName(title) {
|
|
6167
|
+
const text4 = truthyText(title);
|
|
6168
|
+
for (const line of text4.split("\n")) {
|
|
6169
|
+
if (line.includes("\u89C4\u5219\u540D\u79F0")) {
|
|
6170
|
+
return line.split("\u3010\u89C4\u5219\u540D\u79F0\u3011").join("").trim();
|
|
6171
|
+
}
|
|
6172
|
+
}
|
|
6173
|
+
return text4.split("\n")[0].slice(0, 60);
|
|
6174
|
+
}
|
|
6175
|
+
function safeName(value, fallback = "\u5408\u540C\u98CE\u9669\u5BA1\u67E5\u62A5\u544A") {
|
|
6176
|
+
const base = truthyText(value).trim() || fallback;
|
|
6177
|
+
let out = base;
|
|
6178
|
+
for (const bad of ["\\", "/", ":", "*", "?", '"', "<", ">", "|", "'", "\r", "\n"]) {
|
|
6179
|
+
out = out.split(bad).join("_");
|
|
6180
|
+
}
|
|
6181
|
+
return out.slice(0, 80);
|
|
6182
|
+
}
|
|
6183
|
+
function extractFromRef(path) {
|
|
6184
|
+
const top = readJson(path);
|
|
6185
|
+
const env = top.envelope && typeof top.envelope === "object" ? top.envelope : top;
|
|
6186
|
+
const data = env.data && typeof env.data === "object" ? env.data : {};
|
|
6187
|
+
const records = Array.isArray(data.records) ? data.records : [];
|
|
6188
|
+
if (!records.length) {
|
|
6189
|
+
throw contractValidationError(
|
|
6190
|
+
"records_empty",
|
|
6191
|
+
"\u8BE5\u7ED3\u679C\u6CA1\u6709\u5BA1\u67E5\u8BB0\u5F55\uFF0C\u65E0\u6CD5\u751F\u6210\u62A5\u544A\uFF08status \u53EF\u80FD\u4E3A EMPTY\uFF09"
|
|
6192
|
+
);
|
|
6193
|
+
}
|
|
6194
|
+
const scnr = records[0].scnr;
|
|
6195
|
+
let obj;
|
|
6196
|
+
if (typeof scnr === "string") {
|
|
6197
|
+
try {
|
|
6198
|
+
obj = JSON.parse(scnr);
|
|
6199
|
+
} catch (error) {
|
|
6200
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
6201
|
+
throw contractValidationError("scnr_invalid", `\u5BA1\u67E5\u8BB0\u5F55 scnr \u4E0D\u662F\u5408\u6CD5 JSON\uFF1A${message}`);
|
|
6202
|
+
}
|
|
6203
|
+
} else if (scnr && typeof scnr === "object") {
|
|
6204
|
+
obj = scnr;
|
|
6205
|
+
} else {
|
|
6206
|
+
obj = {};
|
|
6207
|
+
}
|
|
6208
|
+
let roleKey = obj.entryRole || "partyB";
|
|
6209
|
+
const byRole = obj.resultsByRole && typeof obj.resultsByRole === "object" ? obj.resultsByRole : {};
|
|
6210
|
+
let items = Array.isArray(byRole[roleKey]) ? byRole[roleKey] : [];
|
|
6211
|
+
if (!items.length) {
|
|
6212
|
+
for (const [key, value] of Object.entries(byRole)) {
|
|
6213
|
+
if (Array.isArray(value) && value.length) {
|
|
6214
|
+
roleKey = key;
|
|
6215
|
+
items = value;
|
|
6216
|
+
break;
|
|
6217
|
+
}
|
|
6218
|
+
}
|
|
6219
|
+
}
|
|
6220
|
+
const rules = obj.rules && typeof obj.rules === "object" ? obj.rules : {};
|
|
6221
|
+
const selected = Array.isArray(rules.selected) ? rules.selected : [];
|
|
6222
|
+
const risks = [];
|
|
6223
|
+
const passed = [];
|
|
6224
|
+
for (const item of items) {
|
|
6225
|
+
if (!item || typeof item !== "object") continue;
|
|
6226
|
+
const record = item;
|
|
6227
|
+
const name = ruleName(record.title);
|
|
6228
|
+
if (record.customRuleNoRisk === true) {
|
|
6229
|
+
passed.push({ name });
|
|
6230
|
+
} else {
|
|
6231
|
+
risks.push({
|
|
6232
|
+
name,
|
|
6233
|
+
original: truthyText(record.originalContent).trim(),
|
|
6234
|
+
suggestion: truthyText(record.suggestion).trim(),
|
|
6235
|
+
explanation: truthyText(record.explanation).trim(),
|
|
6236
|
+
status: truthyText(record.ruleStatus)
|
|
6237
|
+
});
|
|
6238
|
+
}
|
|
6239
|
+
}
|
|
6240
|
+
return {
|
|
6241
|
+
role: roleKey,
|
|
6242
|
+
ruleTotal: selected.length ? selected.length : items.length,
|
|
6243
|
+
judged: items.length,
|
|
6244
|
+
noRisk: passed.length,
|
|
6245
|
+
risk: risks.length,
|
|
6246
|
+
risks,
|
|
6247
|
+
passed
|
|
6248
|
+
};
|
|
6249
|
+
}
|
|
6250
|
+
function mergeMeta(data, meta) {
|
|
6251
|
+
const setDefault = (key, value) => {
|
|
6252
|
+
if (!(key in data) || data[key] === void 0) data[key] = value;
|
|
6253
|
+
};
|
|
6254
|
+
setDefault("contract", truthyText(meta.contract) || "\u5408\u540C\u98CE\u9669\u5BA1\u67E5\u62A5\u544A");
|
|
6255
|
+
setDefault("partyA", truthyText(meta.partyA));
|
|
6256
|
+
setDefault("partyB", truthyText(meta.partyB));
|
|
6257
|
+
setDefault("reviewDate", truthyText(meta.reviewDate));
|
|
6258
|
+
data.fileId = truthyText(meta.fileId) || truthyText(data.fileId);
|
|
6259
|
+
data.fileName = truthyText(meta.fileName) || truthyText(data.fileName);
|
|
6260
|
+
data.aiid = truthyText(meta.aiid) || DEFAULT_AIID;
|
|
6261
|
+
data.base = truthyText(meta.baseUrl) || DEFAULT_BASE;
|
|
6262
|
+
data.cardId = truthyText(meta.cardId) || truthyText(data.cardId) || `cr-report-${truthyText(data.stamp) || "000"}`;
|
|
6263
|
+
const datePart = truthyText(data.reviewDate).split("-").join("") || "report";
|
|
6264
|
+
data.fileBase = safeName(`\u98CE\u9669\u5BA1\u67E5\u62A5\u544A_${truthyText(data.contract)}_${datePart}`);
|
|
6265
|
+
return data;
|
|
6266
|
+
}
|
|
6267
|
+
function infoRows(d) {
|
|
6268
|
+
const rows = [
|
|
6269
|
+
["\u5408\u540C\u540D\u79F0", truthyText(d.contract)],
|
|
6270
|
+
["\u7532\u65B9\uFF08\u7528\u6237\uFF09", truthyText(d.partyA)],
|
|
6271
|
+
["\u4E59\u65B9\uFF08\u4F9B\u65B9\uFF09", truthyText(d.partyB)],
|
|
6272
|
+
["\u5BA1\u67E5\u7ACB\u573A", d.role === "partyB" ? "\u4E59\u65B9\uFF08partyB\uFF09" : truthyText(d.role)],
|
|
6273
|
+
["\u5BA1\u67E5\u7C7B\u578B", "\u98CE\u9669\u5BA1\u67E5\uFF08\u5408\u540C\u9884\u5BA1\uFF09"],
|
|
6274
|
+
["\u5BA1\u67E5\u65E5\u671F", truthyText(d.reviewDate)]
|
|
6275
|
+
];
|
|
6276
|
+
const out = [];
|
|
6277
|
+
for (const [key, value] of rows) {
|
|
6278
|
+
if (!value) continue;
|
|
6279
|
+
out.push(
|
|
6280
|
+
"<tr><td style='padding:7px 10px;background:#f7f9fc;width:110px;color:#7a8497;border-radius:6px'>" + esc2(key) + "</td><td style='padding:7px 10px'>" + esc2(value) + "</td></tr>"
|
|
6281
|
+
);
|
|
6282
|
+
}
|
|
6283
|
+
return out.join("");
|
|
6284
|
+
}
|
|
6285
|
+
function riskItems(d) {
|
|
6286
|
+
const out = [];
|
|
6287
|
+
(d.risks ?? []).forEach((risk, index) => {
|
|
6288
|
+
const no = index + 1;
|
|
6289
|
+
out.push(
|
|
6290
|
+
"<div style='background:#fff;border:1px solid #e8ebf2;border-left:3px solid #c0392b;border-radius:10px;padding:14px 16px;margin-bottom:12px'><div style='display:flex;align-items:center;gap:8px;margin-bottom:10px'><span style='background:#fdecea;color:#c0392b;border-radius:10px;padding:2px 8px;font-size:11px'>\u5F85\u6574\u6539</span><span style='font-size:14px;font-weight:700;color:#1f2430'>" + String(no) + ". " + esc2(risk.name) + "</span></div><div style='font-size:12px;color:#7a8497;margin-bottom:4px'>\u5408\u540C\u539F\u6587</div><div style='background:#f7f9fc;border-radius:6px;padding:10px;font-size:13px;color:#3c4453;line-height:1.7;margin-bottom:10px'>" + esc2(risk.original) + "</div><div style='font-size:12px;color:#7a8497;margin-bottom:4px'>\u95EE\u9898\u8BF4\u660E</div><div style='font-size:13px;color:#b45309;line-height:1.7;margin-bottom:10px'>" + esc2(risk.explanation) + "</div><div style='font-size:12px;color:#7a8497;margin-bottom:4px'>\u5EFA\u8BAE\u4FEE\u6539\u4E3A</div><div style='background:#f0f9f4;border:1px solid #cfeadd;border-radius:6px;padding:10px;font-size:13px;color:#1a6b45;line-height:1.7'>" + esc2(risk.suggestion) + "</div></div>"
|
|
6291
|
+
);
|
|
6292
|
+
});
|
|
6293
|
+
return out.join("");
|
|
6294
|
+
}
|
|
6295
|
+
function passTags(d) {
|
|
6296
|
+
const out = [];
|
|
6297
|
+
(d.passed ?? []).forEach((item, index) => {
|
|
6298
|
+
out.push(
|
|
6299
|
+
"<span style='display:inline-block;background:#f0f9f4;border:1px solid #cfeadd;color:#1a6b45;border-radius:8px;padding:5px 10px;font-size:12px;margin:0 8px 8px 0'>" + String(index + 1) + ". " + esc2(item.name) + "</span>"
|
|
6300
|
+
);
|
|
6301
|
+
});
|
|
6302
|
+
return out.join("");
|
|
6303
|
+
}
|
|
6304
|
+
function detailCfg(d) {
|
|
6305
|
+
const cfg = {
|
|
6306
|
+
type: "e10Sdk",
|
|
6307
|
+
width: 1200,
|
|
6308
|
+
contentProps: {
|
|
6309
|
+
src: `${truthyText(d.base)}${DEFAULT_SRC_PATH}`,
|
|
6310
|
+
sdkOptions: {
|
|
6311
|
+
compName: "ui.CorsComponent",
|
|
6312
|
+
routerType: "MemoryRouter",
|
|
6313
|
+
routerProps: { initialEntries: [DEFAULT_SRC_PATH] },
|
|
6314
|
+
params: {
|
|
6315
|
+
app: "@weapp/contract",
|
|
6316
|
+
compName: "AIContractV2",
|
|
6317
|
+
aiProps: {
|
|
6318
|
+
aiid: truthyText(d.aiid),
|
|
6319
|
+
fileId: truthyText(d.fileId),
|
|
6320
|
+
fileName: truthyText(d.fileName)
|
|
6321
|
+
}
|
|
6322
|
+
}
|
|
6323
|
+
}
|
|
6324
|
+
}
|
|
6325
|
+
};
|
|
6326
|
+
return JSON.stringify(cfg).replace(/"/gu, "'");
|
|
6327
|
+
}
|
|
6328
|
+
function renderRiskReport(d, template) {
|
|
6329
|
+
const cardId = truthyText(d.cardId) || `cr-report-${truthyText(d.stamp) || "000"}`;
|
|
6330
|
+
return template.split("{{CARD_ID}}").join(cardId).split("{{FILE_BASE}}").join(safeName(d.fileBase || "\u5408\u540C\u98CE\u9669\u5BA1\u67E5\u62A5\u544A")).split("{{CONTRACT_NAME}}").join(esc2(d.contract)).split("{{TINFO}}").join(infoRows(d)).split("{{STAT_TOTAL}}").join(String(d.ruleTotal ?? 0)).split("{{STAT_NO_RISK}}").join(String(d.noRisk ?? 0)).split("{{STAT_RISK}}").join(String(d.risk ?? 0)).split("{{RISK_COUNT}}").join(String(d.risk ?? 0)).split("{{RISK_ITEMS}}").join(riskItems(d)).split("{{PASS_COUNT}}").join(String(d.noRisk ?? 0)).split("{{PASS_TAGS}}").join(passTags(d)).split("{{DETAIL_CFG}}").join(detailCfg(d));
|
|
6331
|
+
}
|
|
6332
|
+
function buildRiskPayload(html, d, callId) {
|
|
6333
|
+
return {
|
|
6334
|
+
version: 1,
|
|
6335
|
+
callId,
|
|
6336
|
+
toolId: "fill_form",
|
|
6337
|
+
arguments: {
|
|
6338
|
+
type: "e10",
|
|
6339
|
+
title: truthyText(d.title) || "\u5408\u540C\u98CE\u9669\u5BA1\u67E5\u62A5\u544A",
|
|
6340
|
+
src: `${truthyText(d.base)}/sp/contract/xiaoe-custom-page`,
|
|
6341
|
+
width: 1200,
|
|
6342
|
+
sdkRenderType: "inline",
|
|
6343
|
+
sdkOptions: {
|
|
6344
|
+
compName: "ui.CorsComponent",
|
|
6345
|
+
routerType: "MemoryRouter",
|
|
6346
|
+
routerProps_pc: { initialEntries: ["/sp/contract/xiaoe-custom-page"] },
|
|
6347
|
+
params_pc: {
|
|
6348
|
+
app: "@weapp/contract",
|
|
6349
|
+
compName: "xiaoeCustomPage",
|
|
6350
|
+
customParams: { html }
|
|
6351
|
+
}
|
|
6352
|
+
}
|
|
6353
|
+
}
|
|
6354
|
+
};
|
|
6355
|
+
}
|
|
6356
|
+
function lintRiskHtml(html) {
|
|
6357
|
+
const problems = [];
|
|
6358
|
+
const doubleQuotes = (html.match(/"/gu) ?? []).length;
|
|
6359
|
+
if (doubleQuotes) problems.push(`html \u5185\u542B ${doubleQuotes} \u4E2A\u53CC\u5F15\u53F7\uFF08\u5FC5\u987B\u4E3A 0\uFF09`);
|
|
6360
|
+
for (const bad of ["=>", "const ", "let ", "??", "?.", "`"]) {
|
|
6361
|
+
if (html.includes(bad)) problems.push(`html \u5185\u51FA\u73B0 ES5 \u7981\u7528\u8BED\u6CD5: ${bad}`);
|
|
6362
|
+
}
|
|
6363
|
+
const start = html.indexOf("<script>");
|
|
6364
|
+
const end = html.lastIndexOf("</script>");
|
|
6365
|
+
const js = start >= 0 && end > start ? html.slice(start + 8, end) : "";
|
|
6366
|
+
return { problems, js };
|
|
6367
|
+
}
|
|
6368
|
+
var META_KEYS = [
|
|
6369
|
+
"contract",
|
|
6370
|
+
"partyA",
|
|
6371
|
+
"partyB",
|
|
6372
|
+
"reviewDate",
|
|
6373
|
+
"fileId",
|
|
6374
|
+
"fileName",
|
|
6375
|
+
"aiid",
|
|
6376
|
+
"baseUrl",
|
|
6377
|
+
"cardId",
|
|
6378
|
+
"callId",
|
|
6379
|
+
"title"
|
|
6380
|
+
];
|
|
6381
|
+
var contractCardRiskReportOperation = {
|
|
6382
|
+
name: "contract.card.risk-report",
|
|
6383
|
+
async execute(input) {
|
|
6384
|
+
const refPath = typeof input.ref === "string" && input.ref.trim() ? resolve7(input.ref.trim()) : "";
|
|
6385
|
+
const dataPath = typeof input.data === "string" && input.data.trim() ? resolve7(input.data.trim()) : "";
|
|
6386
|
+
if (!refPath && !dataPath) {
|
|
6387
|
+
throw contractValidationError("source_required", "\u5FC5\u987B\u63D0\u4F9B ref\uFF08CLI \u843D\u76D8\u5BA1\u67E5\u7ED3\u679C\uFF09\u6216 data\uFF08\u5DF2\u5F52\u4E00\u5316 report_data.json\uFF09");
|
|
6388
|
+
}
|
|
6389
|
+
if (!isFile(refPath || dataPath)) {
|
|
6390
|
+
throw contractValidationError("source_not_found", `\u8F93\u5165\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${refPath || dataPath}`);
|
|
6391
|
+
}
|
|
6392
|
+
let data;
|
|
6393
|
+
if (refPath) {
|
|
6394
|
+
data = extractFromRef(refPath);
|
|
6395
|
+
} else {
|
|
6396
|
+
data = readJson(dataPath);
|
|
6397
|
+
if (!data || typeof data !== "object") {
|
|
6398
|
+
throw contractValidationError("data_invalid", "report_data \u5FC5\u987B\u662F JSON \u5BF9\u8C61");
|
|
6399
|
+
}
|
|
6400
|
+
}
|
|
6401
|
+
const meta = {};
|
|
6402
|
+
for (const key of META_KEYS) {
|
|
6403
|
+
if (input[key] !== void 0 && input[key] !== null && input[key] !== "") meta[key] = input[key];
|
|
6404
|
+
}
|
|
6405
|
+
data = mergeMeta(data, meta);
|
|
6406
|
+
const templatePath = typeof input.template === "string" && input.template.trim() ? resolve7(input.template.trim()) : "";
|
|
6407
|
+
let template = DEFAULT_TEMPLATE;
|
|
6408
|
+
if (templatePath) {
|
|
6409
|
+
if (!isFile(templatePath)) {
|
|
6410
|
+
throw contractValidationError("template_not_found", `\u6A21\u677F\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${templatePath}`);
|
|
6411
|
+
}
|
|
6412
|
+
template = readFileSync6(templatePath, "utf8");
|
|
6413
|
+
}
|
|
6414
|
+
const html = renderRiskReport(data, template);
|
|
6415
|
+
const { problems, js } = lintRiskHtml(html);
|
|
6416
|
+
const dumpPath = typeof input.dumpData === "string" && input.dumpData.trim() ? resolve7(input.dumpData.trim()) : "";
|
|
6417
|
+
let dumpDataOut;
|
|
6418
|
+
if (dumpPath) {
|
|
6419
|
+
mkdirSync2(dirname3(dumpPath), { recursive: true });
|
|
6420
|
+
writeFileSync5(dumpPath, JSON.stringify(data, null, 2), "utf8");
|
|
6421
|
+
dumpDataOut = dumpPath;
|
|
6422
|
+
}
|
|
6423
|
+
let htmlOut;
|
|
6424
|
+
if (typeof input.out === "string" && input.out.trim()) {
|
|
6425
|
+
htmlOut = resolve7(input.out.trim());
|
|
6426
|
+
mkdirSync2(dirname3(htmlOut), { recursive: true });
|
|
6427
|
+
writeFileSync5(htmlOut, html, "utf8");
|
|
6428
|
+
}
|
|
6429
|
+
let payloadOut;
|
|
6430
|
+
let payload;
|
|
6431
|
+
if (typeof input.payload === "string" && input.payload.trim()) {
|
|
6432
|
+
const callId = truthyText(input.callId) || `contract-risk-report-${truthyText(data.stamp) || "000"}`;
|
|
6433
|
+
payload = buildRiskPayload(html, data, callId);
|
|
6434
|
+
payloadOut = resolve7(input.payload.trim());
|
|
6435
|
+
mkdirSync2(dirname3(payloadOut), { recursive: true });
|
|
6436
|
+
writeFileSync5(payloadOut, JSON.stringify(payload, null, 2), "utf8");
|
|
6437
|
+
}
|
|
6438
|
+
return {
|
|
6439
|
+
status: "COMPLETE",
|
|
6440
|
+
data: {
|
|
6441
|
+
ruleTotal: data.ruleTotal,
|
|
6442
|
+
noRisk: data.noRisk,
|
|
6443
|
+
risk: data.risk,
|
|
6444
|
+
htmlLength: html.length,
|
|
6445
|
+
lint: problems.length ? "FAIL" : "OK",
|
|
6446
|
+
lintProblems: problems,
|
|
6447
|
+
...js ? { scriptLength: js.length } : {},
|
|
6448
|
+
...dumpDataOut ? { dumpData: dumpDataOut } : {},
|
|
6449
|
+
...htmlOut ? { output: htmlOut } : {},
|
|
6450
|
+
...payloadOut && payload ? { payload: payloadOut, callId: payload.callId } : {},
|
|
6451
|
+
note: htmlOut ? "" : "\u672A\u4F20 out\uFF1A\u6309\u7EA6\u5B9A\u62A5\u544A\u53EA\u4F5C\u4E3A\u5361\u7247\u4EA4\u4ED8\uFF0C\u4E0D\u843D\u76D8"
|
|
6452
|
+
}
|
|
6453
|
+
};
|
|
6454
|
+
}
|
|
6455
|
+
};
|
|
6456
|
+
var contractCardRiskReportOperations = [contractCardRiskReportOperation];
|
|
6457
|
+
|
|
6458
|
+
// src/shortcuts/contract/operations/card-action.ts
|
|
6459
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync7, statSync as statSync2, writeFileSync as writeFileSync6 } from "node:fs";
|
|
6460
|
+
import { dirname as dirname4, join, resolve as resolve8 } from "node:path";
|
|
6461
|
+
import { Script } from "node:vm";
|
|
6462
|
+
var DEFAULT_BASE2 = "https://www.e-cology.com.cn";
|
|
6463
|
+
var DEFAULT_AIID2 = "1326842382967570463";
|
|
6464
|
+
var WIDTH = 1200;
|
|
6465
|
+
var FLOW_IDS = /* @__PURE__ */ new Map([
|
|
6466
|
+
["\u5951\u7EA6\u9501", "100003460000002066"],
|
|
6467
|
+
["\u65B0\u5BA2\u6237", "1269716062340284522"],
|
|
6468
|
+
["\u8001\u5BA2\u6237\u589E\u503C", "1283761429944369334"],
|
|
6469
|
+
["\u5E38\u89C4\u4E8C\u6B21\u9500\u552E", "1283761687634100307"]
|
|
6470
|
+
]);
|
|
6471
|
+
var SVG = {
|
|
6472
|
+
launch: "<svg width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='#7b8cf0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><path d='M22 2 11 13'/><path d='M22 2 15 22l-4-9-9-4z'/></svg>",
|
|
6473
|
+
doc: "<svg width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='#7b8cf0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><path d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/><path d='M14 3v5h5'/><path d='M9 13h6'/><path d='M9 17h4'/></svg>",
|
|
6474
|
+
eye: "<svg width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='#7b8cf0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><path d='M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z'/><circle cx='12' cy='12' r='3'/></svg>",
|
|
6475
|
+
search: "<svg width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='#7b8cf0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><path d='M16.5 16.5 21 21'/></svg>",
|
|
6476
|
+
list: "<svg width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='#7b8cf0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><rect x='4' y='3' width='16' height='18' rx='2'/><path d='M8 8h8'/><path d='M8 12h8'/><path d='M8 16h5'/></svg>",
|
|
6477
|
+
swap: "<svg width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='#7b8cf0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><path d='M7 4v16'/><path d='M4 17l3 3 3-3'/><path d='M17 20V4'/><path d='M14 7l3-3 3 3'/></svg>",
|
|
6478
|
+
edit: "<svg width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='#7b8cf0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><path d='M12 20h9'/><path d='M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z'/></svg>"
|
|
6479
|
+
};
|
|
6480
|
+
var ACTION_META = /* @__PURE__ */ new Map([
|
|
6481
|
+
["launch-flow", ["launch", "launch", "e10Sdk"]],
|
|
6482
|
+
["generate-contract", ["gen", "doc", "sendQuestion"]],
|
|
6483
|
+
["review", ["review", "doc", "sendQuestion"]],
|
|
6484
|
+
["export-review", ["report", "list", "artifact"]],
|
|
6485
|
+
["view-review", ["detail", "eye", "e10Sdk"]],
|
|
6486
|
+
["credit", ["credit", "search", "e10Sdk"]],
|
|
6487
|
+
["view-compare", ["cmpview", "eye", "e10Sdk"]],
|
|
6488
|
+
["export-compare-report", ["cmpreport", "list", "artifact"]],
|
|
6489
|
+
["compare", ["cmp", "swap", "sendQuestion"]],
|
|
6490
|
+
["clause-rewrite", ["rewrite", "edit", "sendQuestion"]],
|
|
6491
|
+
["request-status", ["status", "search", "sendQuestion"]],
|
|
6492
|
+
["summary", ["summary", "list", "artifact"]],
|
|
6493
|
+
["element-extract", ["extract", "doc", "sendQuestion"]],
|
|
6494
|
+
["supervise", ["supervise", "launch", "sendQuestion"]],
|
|
6495
|
+
["template-recommend", ["tpl", "doc", "sendQuestion"]],
|
|
6496
|
+
["performance", ["perf", "list", "sendQuestion"]],
|
|
6497
|
+
["retry-upload", ["retry", "doc", "sendQuestion"]]
|
|
6498
|
+
]);
|
|
6499
|
+
var SEND_TEXT = /* @__PURE__ */ new Map([
|
|
6500
|
+
["generate-contract", "\u6309\u8FD9\u4EFD\u62A5\u4EF7\u5355\u751F\u6210\u5408\u540C"],
|
|
6501
|
+
["review", "\u5BF9\u8FD9\u4EFD\u5408\u540C\u505A\u5408\u540C\u9884\u5BA1\uFF0C\u8F93\u51FA\u98CE\u9669\u6761\u6B3E\u4E0E\u4FEE\u6539\u5EFA\u8BAE"],
|
|
6502
|
+
["clause-rewrite", "\u6309\u9884\u5BA1\u5EFA\u8BAE\u4FEE\u6539\u5408\u540C\u6761\u6B3E"],
|
|
6503
|
+
["request-status", "\u67E5\u4E00\u4E0B\u8FD9\u4EFD\u5408\u540C\u7684\u5BA1\u6279\u8FDB\u5EA6"],
|
|
6504
|
+
["compare", "\u6BD4\u5BF9\u8FD9\u4E24\u4EFD\u5408\u540C\u7684\u5DEE\u5F02"],
|
|
6505
|
+
["element-extract", "\u4ECE\u8FD9\u4EFD\u5408\u540C\u91CC\u62BD\u53D6\u8981\u7D20"],
|
|
6506
|
+
["supervise", "\u50AC\u529E\u4E00\u4E0B\u5F53\u524D\u5408\u540C\u7684\u5BA1\u6279"],
|
|
6507
|
+
["template-recommend", "\u63A8\u8350\u51E0\u4E2A\u9002\u5408\u7684\u5408\u540C\u6A21\u677F"],
|
|
6508
|
+
["performance", "\u67E5\u4E00\u4E0B\u8FD9\u4EFD\u5408\u540C\u7684\u4E1A\u7EE9\u6838\u7B97"],
|
|
6509
|
+
["retry-upload", "\u6362\u4E00\u4EFD\u6587\u4EF6\u91CD\u65B0\u89E3\u6790"]
|
|
6510
|
+
]);
|
|
6511
|
+
var CARD_TPL = "<div id='{dom_id}' role='button' tabindex='0' style='display:flex;align-items:center;gap:12px;background:#fff;border:1px solid #e8ebf2;border-radius:12px;padding:16px;{mb}cursor:pointer'><span style='flex:0 0 auto;width:44px;height:44px;border-radius:10px;background:#eef1fb;display:flex;align-items:center;justify-content:center'>{icon}</span><span style='min-width:0'><span style='display:block;font-size:15px;font-weight:700;color:#1f2430;margin-bottom:6px'>{title}{badge}</span><span style='display:block;font-size:13px;color:#7a8497;line-height:1.5'>{desc}</span></span></div>";
|
|
6512
|
+
var BADGE = "<span style='font-size:11px;color:#3b6fe0;background:#eaf0fe;border-radius:10px;padding:2px 8px;line-height:1.4;margin-left:8px'>\u63A8\u8350</span>";
|
|
6513
|
+
var JS_BASE = "var P=window.xiaoePlugin||(window.rawWindow&&window.rawWindow.xiaoePlugin);var tip=document.getElementById('tip');function say(m){if(tip){tip.textContent=m;}}function hasP(){if(!P||!P.rightPanel||typeof P.rightPanel.open!=='function'){say('\u5F53\u524D\u73AF\u5883\u6CA1\u6709\u5C0Fe\u53F3\u4FA7\u9762\u677F');return false;}return true;}function op(cfg){if(!hasP()){return;}try{P.rightPanel.open(cfg);say('\u5DF2\u6253\u5F00');}catch(e){say('\u9762\u677F\u6253\u5F00\u5931\u8D25\uFF0C\u8BF7\u786E\u8BA4\u53F3\u4FA7\u9762\u677F\u5DF2\u6302\u8F7D');}}function send(q){if(!P||!P.session||typeof P.session.sendQuestion!=='function'){say('\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u53D1\u9001\u4F1A\u8BDD\u6D88\u606F');return;}try{P.session.sendQuestion({question:q,files:[]});say('\u5DF2\u53D1\u9001\uFF0C\u6B63\u5728\u5904\u7406\u2026');}catch(e){say('\u53D1\u9001\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5');}}function art(html,title,key){if(!hasP()){return;}if(!html){say('\u5185\u5BB9\u4E3A\u7A7A');return;}try{P.rightPanel.open({type:'artifact',width:__W__,title:title,contentProps:{artifacts:[{id:key,name:title,fileType:'html',raw:{html:html}}],initialArtifactKeys:[key]}});}catch(e){say('\u9762\u677F\u6253\u5F00\u5931\u8D25\uFF0C\u8BF7\u786E\u8BA4\u53F3\u4FA7\u9762\u677F\u5DF2\u6302\u8F7D');}}function bind(id,fn){var el=document.getElementById(id);if(!el){return;}el.onclick=fn;el.onmouseenter=function(){el.style.borderColor='#1d6fd8';el.style.boxShadow='0 2px 8px rgba(29,111,216,.12)';};el.onmouseleave=function(){el.style.borderColor='#e8ebf2';el.style.boxShadow='none';};el.onkeydown=function(e){if(e.key==='Enter'||e.key===' '){e.preventDefault();fn();}};}";
|
|
6514
|
+
var CARD_TEMPLATE = `<!--
|
|
6515
|
+
\u884C\u4E3A\u5361\u7247\u5185\u5C42\u6A21\u677F\uFF08contract-action-card-template.html\uFF09
|
|
6516
|
+
2026-11-09 \u91CD\u5199\uFF1A\u7531\u300C\u53EF\u7167\u6284\u7684\u6837\u4F8B\u300D\u6539\u4E3A\u300C\u4F9B render_action_card.py \u586B\u5145\u7684\u771F\u6A21\u677F\u300D
|
|
6517
|
+
|
|
6518
|
+
\u65E7\u7248\u95EE\u9898\uFF1A\u5361\u7247\u4E0E handler \u5168\u90E8\u5199\u6B7B\u3001button \u5E03\u5C40\u4E0D\u7B26\u5408\u6807\u51C6\u5361\u3001\u53EA\u7ED1 click \u65E0 hover\u3001
|
|
6519
|
+
review \u7F3A params.compName\u3001\u6B8B\u7559\u8C03\u8BD5\u6587\u6848\u3002\u7167\u6284\u5FC5\u9519\u3002
|
|
6520
|
+
|
|
6521
|
+
\u5360\u4F4D\u7B26\uFF08\u5168\u90E8\u7531 render_action_card.py \u66FF\u6362\uFF09\uFF1A
|
|
6522
|
+
{{CARD_ID}} {{CARDS}} {{SUMMARY_JS}} {{COMPARE_JS}} {{REPORT_JS}} {{BODY}}
|
|
6523
|
+
|
|
6524
|
+
\u6CE8\u610F\uFF1A\u672C\u6CE8\u91CA\u5757\u5728\u6E32\u67D3\u65F6\u4F1A\u88AB\u4E22\u5F03\uFF0C\u811A\u672C\u6309\u300Csection \u5F00\u6807\u7B7E\u542B id \u5C5E\u6027\u300D\u5B9A\u4F4D\u6B63\u6587\u8D77\u70B9\u3002
|
|
6525
|
+
-->
|
|
6526
|
+
<section id='{{CARD_ID}}' style='padding:4px 2px;font-family:Microsoft YaHei,PingFang SC,sans-serif'>
|
|
6527
|
+
{{CARDS}}
|
|
6528
|
+
<p id='tip' style='margin:8px 0 0;color:#b45309;font-size:12px'></p>
|
|
6529
|
+
</section>
|
|
6530
|
+
<script>(function(){var S={{SUMMARY_JS}};var C={{COMPARE_JS}};var R={{REPORT_JS}};{{BODY}}})();</script>
|
|
6531
|
+
`;
|
|
6532
|
+
function truthyText2(value) {
|
|
6533
|
+
if (value === null || value === void 0 || value === false || value === "" || value === 0) return "";
|
|
6534
|
+
return String(value);
|
|
6535
|
+
}
|
|
6536
|
+
function pad22(value) {
|
|
6537
|
+
return String(value).padStart(2, "0");
|
|
6538
|
+
}
|
|
6539
|
+
function stampNow2() {
|
|
6540
|
+
const now = /* @__PURE__ */ new Date();
|
|
6541
|
+
return `${now.getFullYear()}${pad22(now.getMonth() + 1)}${pad22(now.getDate())}${pad22(now.getHours())}${pad22(now.getMinutes())}`;
|
|
6542
|
+
}
|
|
6543
|
+
function jsStr(text4) {
|
|
6544
|
+
let s = truthyText2(text4);
|
|
6545
|
+
s = s.split("\r\n").join(" ").split("\n").join(" ").split("\r").join(" ");
|
|
6546
|
+
s = s.replace(/ {2,}/gu, " ");
|
|
6547
|
+
s = s.split("</script>").join("<\\/script>");
|
|
6548
|
+
s = s.split('"').join("'");
|
|
6549
|
+
s = s.split("\\").join("\\\\");
|
|
6550
|
+
s = s.split("<\\\\/script>").join("<\\/script>");
|
|
6551
|
+
s = s.split("'").join("\\'");
|
|
6552
|
+
return `'${s}'`;
|
|
6553
|
+
}
|
|
6554
|
+
function safeInline(value) {
|
|
6555
|
+
return truthyText2(value).split("'").join("").split("\\").join("");
|
|
6556
|
+
}
|
|
6557
|
+
function buildHandler(action, cfg) {
|
|
6558
|
+
const aid = String(action.id ?? "");
|
|
6559
|
+
const meta = ACTION_META.get(aid) ?? [aid, "doc", "sendQuestion"];
|
|
6560
|
+
const dom = `c-${meta[0]}`;
|
|
6561
|
+
if (aid === "launch-flow") {
|
|
6562
|
+
const wid = FLOW_IDS.get(cfg.flow_key || "");
|
|
6563
|
+
if (!wid) return { dom, body: null };
|
|
6564
|
+
let src = `${cfg.base}/sp/workflow/flowpage/create/${wid}?workflowId=${wid}&isCreate=1`;
|
|
6565
|
+
if (cfg.file_id) src += `&fileId=${cfg.file_id}`;
|
|
6566
|
+
let rawKeys = cfg.field_assign_keys || "";
|
|
6567
|
+
if (Array.isArray(rawKeys)) rawKeys = rawKeys.map((item) => String(item)).join(",");
|
|
6568
|
+
let keyStr = String(rawKeys ?? "").split(",").map((item) => item.trim()).filter((item) => item.length > 0).join(",");
|
|
6569
|
+
if (!keyStr && cfg.attachment_field_id) keyStr = safeInline(cfg.attachment_field_id);
|
|
6570
|
+
const cp = [];
|
|
6571
|
+
const extraQ = [];
|
|
6572
|
+
if (cfg.ai_extra_id) {
|
|
6573
|
+
cp.push(`aiExtraId:'${safeInline(cfg.ai_extra_id)}'`);
|
|
6574
|
+
cp.push("openSource:'xiaoE'");
|
|
6575
|
+
extraQ.push(`aiExtraId=${safeInline(cfg.ai_extra_id)}`);
|
|
6576
|
+
extraQ.push("openSource=xiaoE");
|
|
6577
|
+
if (cfg.attachment_field_id && cfg.file_id) {
|
|
6578
|
+
cp.push(`'${safeInline(cfg.attachment_field_id)}':'${safeInline(cfg.file_id)}'`);
|
|
6579
|
+
extraQ.push(`${safeInline(cfg.attachment_field_id)}=${safeInline(cfg.file_id)}`);
|
|
6580
|
+
}
|
|
6581
|
+
if (keyStr) {
|
|
6582
|
+
cp.push(`fieldAssignKeys:'${keyStr}'`);
|
|
6583
|
+
cp.push("initialCovertName:1");
|
|
6584
|
+
extraQ.push(`fieldAssignKeys=${keyStr}`);
|
|
6585
|
+
extraQ.push("initialCovertName=1");
|
|
6586
|
+
}
|
|
6587
|
+
}
|
|
6588
|
+
if (extraQ.length) src += `&${extraQ.join("&")}`;
|
|
6589
|
+
let params = "params_pc:{app:'@weapp/workflow',compName:'Comp.WffpRoute'},params_mobile:{app:'@weapp/workflow',compName:'Comp.MWffpRoute',noMDialog:true}";
|
|
6590
|
+
if (cp.length) params += `,params:{customParams:{${cp.join(",")}}}`;
|
|
6591
|
+
const body = `function(){op({type:'e10Sdk',width:__W__,contentProps:{src:'${src}',sdkOptions:{compName:'ui.CorsComponent',routerType:'MemoryRouter',routerProps_pc:{initialEntries:['/flowpage/create/${wid}']},routerProps_mobile:{initialEntries:['/flowpage/create/${wid}']},${params}}}});}`;
|
|
6592
|
+
return { dom, body };
|
|
6593
|
+
}
|
|
6594
|
+
if (aid === "view-review") {
|
|
6595
|
+
const fileName = (cfg.file_name || "").split("'").join("");
|
|
6596
|
+
const body = `function(){op({type:'e10Sdk',width:__W__,contentProps:{src:'${cfg.base}/sp/contract/business/ai-contract',sdkOptions:{compName:'ui.CorsComponent',routerType:'MemoryRouter',routerProps:{initialEntries:['/sp/contract/business/ai-contract']},params:{app:'@weapp/contract',compName:'AIContractV2',aiProps:{aiid:'${cfg.aiid}',fileId:'${cfg.file_id || ""}',fileName:'${fileName}'}}}}});}`;
|
|
6597
|
+
return { dom, body };
|
|
6598
|
+
}
|
|
6599
|
+
if (aid === "credit") {
|
|
6600
|
+
const company = cfg.company_name;
|
|
6601
|
+
if (!company) return { dom, body: null };
|
|
6602
|
+
const body = `function(){op({type:'e10Sdk',width:__W__,contentProps:{src:'${cfg.base}/sp/contract/business/credit',sdkOptions:{compName:'ui.CorsComponent',routerType:'MemoryRouter',routerProps:{initialEntries:['/sp/contract/business/credit']},params:{app:'@weapp/contract',compName:'ContractCreditDetail',companyName:['${company.split("'").join("")}']}}}});}`;
|
|
6603
|
+
return { dom, body };
|
|
6604
|
+
}
|
|
6605
|
+
if (aid === "view-compare") {
|
|
6606
|
+
const body = `function(){op({type:'e10Sdk',width:__W__,contentProps:{src:'${cfg.base}/sp/contract/business/doc-compare',sdkOptions:{compName:'ui.CorsComponent',routerType:'MemoryRouter',routerProps:{initialEntries:['/sp/contract/business/doc-compare']},params:{app:'@weapp/contract',compName:'AIDocCompare'}}}});}`;
|
|
6607
|
+
return { dom, body };
|
|
6608
|
+
}
|
|
6609
|
+
if (aid === "export-review") {
|
|
6610
|
+
return { dom, body: "function(){art(R,'\u5408\u540C\u98CE\u9669\u5BA1\u67E5\u62A5\u544A.html','report-1');}" };
|
|
6611
|
+
}
|
|
6612
|
+
if (aid === "summary") {
|
|
6613
|
+
return { dom, body: "function(){art(S,'\u5408\u540C\u6458\u8981.html','summary-1');}" };
|
|
6614
|
+
}
|
|
6615
|
+
if (aid === "export-compare-report") {
|
|
6616
|
+
return { dom, body: "function(){art(C,'\u5408\u540C\u6BD4\u5BF9\u62A5\u544A.html','compare-1');}" };
|
|
6617
|
+
}
|
|
6618
|
+
const text4 = SEND_TEXT.get(aid) || String(action.title ?? "");
|
|
6619
|
+
return { dom, body: `function(){send('${text4.split("'").join("")}');}` };
|
|
6620
|
+
}
|
|
6621
|
+
function renderActionCard(ctx, cfg, template) {
|
|
6622
|
+
const plan = planActions(ctx);
|
|
6623
|
+
let cards = plan.cards;
|
|
6624
|
+
if (cfg.only.length) {
|
|
6625
|
+
cards = cards.filter((card) => cfg.only.includes(String(card.id)));
|
|
6626
|
+
}
|
|
6627
|
+
const parts = [];
|
|
6628
|
+
const handlers = [];
|
|
6629
|
+
cards.forEach((card, index) => {
|
|
6630
|
+
const meta = ACTION_META.get(String(card.id)) ?? [String(card.id), "doc", "sendQuestion"];
|
|
6631
|
+
const { dom, body: body2 } = buildHandler(card, cfg);
|
|
6632
|
+
if (body2 === null) return;
|
|
6633
|
+
parts.push(
|
|
6634
|
+
CARD_TPL.split("{dom_id}").join(dom).split("{mb}").join(index === cards.length - 1 ? "" : "margin-bottom:12px;").split("{icon}").join(SVG[meta[1]] ?? SVG.doc).split("{title}").join(String(card.title ?? "")).split("{badge}").join(index === 0 ? BADGE : "").split("{desc}").join(String(card.desc ?? ""))
|
|
6635
|
+
);
|
|
6636
|
+
handlers.push({ dom, body: body2 });
|
|
6637
|
+
});
|
|
6638
|
+
if (!parts.length) {
|
|
6639
|
+
return { payload: null, planned: cards.map((card) => String(card.id)), cardCount: 0, hint: plan.hint };
|
|
6640
|
+
}
|
|
6641
|
+
let bodyJs = JS_BASE;
|
|
6642
|
+
handlers.forEach((handler, index) => {
|
|
6643
|
+
bodyJs += `var h${index}=${handler.body};`;
|
|
6644
|
+
});
|
|
6645
|
+
handlers.forEach((handler, index) => {
|
|
6646
|
+
bodyJs += `bind('${handler.dom}',h${index});`;
|
|
6647
|
+
});
|
|
6648
|
+
bodyJs += `say('\u5C31\u7EEA\uFF0C\u5171 ${handlers.length} \u4E2A\u52A8\u4F5C');`;
|
|
6649
|
+
bodyJs = bodyJs.split("__W__").join(String(WIDTH));
|
|
6650
|
+
const summaryJs = jsStr(cfg.summary_html || "");
|
|
6651
|
+
const reportJs = jsStr(cfg.report_html || "");
|
|
6652
|
+
const compareJs = jsStr(cfg.compare_html || "");
|
|
6653
|
+
const match = /<section\s+id=/u.exec(template);
|
|
6654
|
+
if (!match) {
|
|
6655
|
+
throw contractValidationError("template_invalid", "\u6A21\u677F\u7F3A\u5C11\u5E26 id \u7684 section\uFF0C\u65E0\u6CD5\u6E32\u67D3");
|
|
6656
|
+
}
|
|
6657
|
+
const body = template.slice(match.index);
|
|
6658
|
+
const html = body.split("{{CARD_ID}}").join(cfg.card_id).split("{{CARDS}}").join(parts.join("\n")).split("{{SUMMARY_JS}}").join(summaryJs).split("{{COMPARE_JS}}").join(compareJs).split("{{REPORT_JS}}").join(reportJs).split("{{BODY}}").join(bodyJs);
|
|
6659
|
+
const count = handlers.length;
|
|
6660
|
+
let title = cfg.title ? cfg.title : `\u53EF\u505A\u7684 ${count} \u4EF6\u4E8B`;
|
|
6661
|
+
title = title.replace(/[\\/:*?"<>|]/gu, " ");
|
|
6662
|
+
const payload = {
|
|
6663
|
+
version: 1,
|
|
6664
|
+
callId: cfg.call_id,
|
|
6665
|
+
toolId: "fill_form",
|
|
6666
|
+
arguments: {
|
|
6667
|
+
type: "e10",
|
|
6668
|
+
title,
|
|
6669
|
+
src: `${cfg.base}/sp/contract/xiaoe-custom-page`,
|
|
6670
|
+
width: WIDTH,
|
|
6671
|
+
sdkRenderType: "inline",
|
|
6672
|
+
sdkOptions: {
|
|
6673
|
+
compName: "ui.CorsComponent",
|
|
6674
|
+
routerType: "MemoryRouter",
|
|
6675
|
+
routerProps_pc: { initialEntries: ["/sp/contract/xiaoe-custom-page"] },
|
|
6676
|
+
params_pc: {
|
|
6677
|
+
app: "@weapp/contract",
|
|
6678
|
+
compName: "xiaoeCustomPage",
|
|
6679
|
+
customParams: { html }
|
|
6680
|
+
}
|
|
6681
|
+
}
|
|
6682
|
+
}
|
|
6683
|
+
};
|
|
6684
|
+
return { payload, planned: cards.map((card) => String(card.id)), cardCount: count };
|
|
6685
|
+
}
|
|
6686
|
+
function selfCheckActionCard(payload) {
|
|
6687
|
+
const problems = [];
|
|
6688
|
+
const html = String(payload.arguments?.sdkOptions?.params_pc?.customParams?.html ?? "");
|
|
6689
|
+
const doubleQuotes = (html.match(/"/gu) ?? []).length;
|
|
6690
|
+
if (doubleQuotes !== 0) problems.push(`html \u5185\u53CC\u5F15\u53F7 ${doubleQuotes} \u4E2A\uFF08\u5E94\u4E3A 0\uFF09`);
|
|
6691
|
+
const unsafe = (html.match(/\\(?!\/script>|')/gu) ?? []).length;
|
|
6692
|
+
if (unsafe) problems.push(`\u975E\u5B89\u5168\u8F6C\u4E49\u53CD\u659C\u6760 ${unsafe} \u5904`);
|
|
6693
|
+
const scriptMatch = /<script>([\s\S]*)<\/script>/u.exec(html);
|
|
6694
|
+
const jsCode = scriptMatch ? scriptMatch[1] : html;
|
|
6695
|
+
const placeholders = jsCode.split("__W__").length - 1;
|
|
6696
|
+
if (placeholders) problems.push(`\u6B8B\u7559\u672A\u66FF\u6362\u7684\u5BBD\u5EA6\u5360\u4F4D\u7B26 __W__ ${placeholders} \u5904\uFF08\u70B9\u51FB\u4F1A ReferenceError\uFF09`);
|
|
6697
|
+
const esPatterns = [
|
|
6698
|
+
[/=>/u, "arrow"],
|
|
6699
|
+
[/\bconst\b/u, "const"],
|
|
6700
|
+
[/\blet\b/u, "let"],
|
|
6701
|
+
[/\?\?/u, "??"],
|
|
6702
|
+
[/\?\./u, "?."]
|
|
6703
|
+
];
|
|
6704
|
+
for (const [pattern, name] of esPatterns) {
|
|
6705
|
+
if (pattern.test(jsCode)) problems.push(`ES5 \u8FDD\u89C4\uFF1A${name}`);
|
|
6706
|
+
}
|
|
6707
|
+
if (!jsCode.includes("mouseenter")) problems.push("\u7F3A\u5C11 hover \u7ED1\u5B9A\uFF08mouseenter\uFF09");
|
|
6708
|
+
if (!scriptMatch) {
|
|
6709
|
+
problems.push("\u672A\u627E\u5230 script");
|
|
6710
|
+
} else {
|
|
6711
|
+
try {
|
|
6712
|
+
new Script(jsCode);
|
|
6713
|
+
} catch (error) {
|
|
6714
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
6715
|
+
problems.push(`node --check \u5931\u8D25\uFF1A${message.split("\n").slice(0, 3).join(" / ")}`);
|
|
6716
|
+
}
|
|
6717
|
+
}
|
|
6718
|
+
const cardCount = (html.match(/role='button'/gu) ?? []).length;
|
|
6719
|
+
return { problems, cardCount, htmlLength: html.length };
|
|
6720
|
+
}
|
|
6721
|
+
function isFile2(path) {
|
|
6722
|
+
try {
|
|
6723
|
+
return existsSync3(path) && statSync2(path).isFile();
|
|
6724
|
+
} catch {
|
|
6725
|
+
return false;
|
|
6726
|
+
}
|
|
6727
|
+
}
|
|
6728
|
+
function readTextOrThrow(path, label) {
|
|
6729
|
+
if (!path) return "";
|
|
6730
|
+
if (!isFile2(path)) {
|
|
6731
|
+
throw contractValidationError("file_not_found", `${label} \u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${path}`);
|
|
6732
|
+
}
|
|
6733
|
+
return readFileSync7(path, "utf8");
|
|
6734
|
+
}
|
|
6735
|
+
function loadContext(input) {
|
|
6736
|
+
const direct = input.context;
|
|
6737
|
+
if (direct && typeof direct === "object" && !Array.isArray(direct)) {
|
|
6738
|
+
return { ctx: direct, source: "context" };
|
|
6739
|
+
}
|
|
6740
|
+
const inline = typeof input.contextJson === "string" && input.contextJson.trim() ? input.contextJson.trim() : "";
|
|
6741
|
+
const file = typeof input.contextFile === "string" && input.contextFile.trim() ? resolve8(input.contextFile.trim()) : "";
|
|
6742
|
+
if (file) {
|
|
6743
|
+
if (!isFile2(file)) throw contractValidationError("context_unreadable", `\u4E0A\u4E0B\u6587\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${file}`);
|
|
6744
|
+
try {
|
|
6745
|
+
const parsed = JSON.parse(readFileSync7(file, "utf8").replace(/^\uFEFF/u, ""));
|
|
6746
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
6747
|
+
throw new Error("\u4E0A\u4E0B\u6587\u5FC5\u987B\u662F JSON \u5BF9\u8C61");
|
|
6748
|
+
}
|
|
6749
|
+
return { ctx: parsed, source: file };
|
|
6750
|
+
} catch (error) {
|
|
6751
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
6752
|
+
throw contractValidationError("context_invalid", `\u4E0A\u4E0B\u6587\u4E0D\u662F\u5408\u6CD5 JSON \u5BF9\u8C61\uFF1A${message}`);
|
|
6753
|
+
}
|
|
6754
|
+
}
|
|
6755
|
+
if (inline) {
|
|
6756
|
+
try {
|
|
6757
|
+
const parsed = JSON.parse(inline);
|
|
6758
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
6759
|
+
throw new Error("\u4E0A\u4E0B\u6587\u5FC5\u987B\u662F JSON \u5BF9\u8C61");
|
|
6760
|
+
}
|
|
6761
|
+
return { ctx: parsed, source: "contextJson" };
|
|
6762
|
+
} catch (error) {
|
|
6763
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
6764
|
+
throw contractValidationError("context_invalid", `\u4E0A\u4E0B\u6587\u4E0D\u662F\u5408\u6CD5 JSON \u5BF9\u8C61\uFF1A${message}`);
|
|
6765
|
+
}
|
|
6766
|
+
}
|
|
6767
|
+
const dirs = [];
|
|
6768
|
+
for (const key of ["out", "summaryHtml", "reportHtml", "compareHtml"]) {
|
|
6769
|
+
const value = input[key];
|
|
6770
|
+
if (typeof value === "string" && value.trim()) dirs.push(dirname4(resolve8(value.trim())));
|
|
6771
|
+
}
|
|
6772
|
+
dirs.push(process.cwd());
|
|
6773
|
+
const seen = /* @__PURE__ */ new Set();
|
|
6774
|
+
for (const dir of dirs) {
|
|
6775
|
+
if (!dir || seen.has(dir) || !existsSync3(dir)) continue;
|
|
6776
|
+
seen.add(dir);
|
|
6777
|
+
for (const name of ["card_context.json", "first_screen_result.json"]) {
|
|
6778
|
+
const path = join(dir, name);
|
|
6779
|
+
if (!isFile2(path)) continue;
|
|
6780
|
+
try {
|
|
6781
|
+
let parsed = JSON.parse(readFileSync7(path, "utf8").replace(/^\uFEFF/u, ""));
|
|
6782
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) continue;
|
|
6783
|
+
if (name === "first_screen_result.json") {
|
|
6784
|
+
const ctx = { scene: "doc", docType: "contract" };
|
|
6785
|
+
if (parsed.workflowFileId || parsed.reviewFileId) ctx.hasFileId = true;
|
|
6786
|
+
if (parsed.flow) ctx.flowKey = parsed.flow;
|
|
6787
|
+
if (parsed.summaryHtml) ctx.summaryReady = true;
|
|
6788
|
+
if (parsed.reportHtml) ctx.reviewed = true;
|
|
6789
|
+
parsed = ctx;
|
|
6790
|
+
}
|
|
6791
|
+
return { ctx: parsed, source: path };
|
|
6792
|
+
} catch {
|
|
6793
|
+
continue;
|
|
6794
|
+
}
|
|
6795
|
+
}
|
|
6796
|
+
}
|
|
6797
|
+
return { ctx: {}, source: "minimal" };
|
|
6798
|
+
}
|
|
6799
|
+
var contractCardActionOperation = {
|
|
6800
|
+
name: "contract.card.action",
|
|
6801
|
+
async execute(input) {
|
|
6802
|
+
const { ctx, source } = loadContext(input);
|
|
6803
|
+
const fileId = truthyText2(input.fileId);
|
|
6804
|
+
const flowKey = truthyText2(input.flowKey);
|
|
6805
|
+
const companyName = truthyText2(input.companyName);
|
|
6806
|
+
const summaryPath = truthyText2(input.summaryHtml);
|
|
6807
|
+
const reportPath = truthyText2(input.reportHtml);
|
|
6808
|
+
const comparePath = truthyText2(input.compareHtml);
|
|
6809
|
+
const setDefault = (key, value) => {
|
|
6810
|
+
if (!(key in ctx) || ctx[key] === void 0 || ctx[key] === null) ctx[key] = value;
|
|
6811
|
+
};
|
|
6812
|
+
if (fileId) {
|
|
6813
|
+
setDefault("hasFileId", true);
|
|
6814
|
+
setDefault("fileId", fileId);
|
|
6815
|
+
}
|
|
6816
|
+
if (flowKey) setDefault("flowKey", flowKey);
|
|
6817
|
+
if (companyName) setDefault("hasCounterparty", true);
|
|
6818
|
+
if (summaryPath) setDefault("summaryReady", true);
|
|
6819
|
+
if (reportPath) setDefault("reviewed", true);
|
|
6820
|
+
if (comparePath) setDefault("compared", true);
|
|
6821
|
+
setDefault("scene", "doc");
|
|
6822
|
+
const stamp = stampNow2();
|
|
6823
|
+
const cfg = {
|
|
6824
|
+
file_id: fileId || void 0,
|
|
6825
|
+
file_name: truthyText2(input.fileName) || void 0,
|
|
6826
|
+
flow_key: flowKey || truthyText2(ctx.flowKey) || void 0,
|
|
6827
|
+
company_name: companyName || void 0,
|
|
6828
|
+
summary_html: readTextOrThrow(summaryPath, "summaryHtml"),
|
|
6829
|
+
report_html: readTextOrThrow(reportPath, "reportHtml"),
|
|
6830
|
+
compare_html: readTextOrThrow(comparePath, "compareHtml"),
|
|
6831
|
+
base: (truthyText2(input.baseUrl) || DEFAULT_BASE2).replace(/\/+$/u, ""),
|
|
6832
|
+
aiid: truthyText2(input.aiid) || DEFAULT_AIID2,
|
|
6833
|
+
ai_extra_id: truthyText2(input.aiExtraId) || truthyText2(ctx.aiExtraId) || "",
|
|
6834
|
+
attachment_field_id: truthyText2(input.attachmentFieldId) || truthyText2(ctx.attachmentFieldId) || "",
|
|
6835
|
+
field_assign_keys: ctx.fieldAssignKeys || "",
|
|
6836
|
+
card_id: truthyText2(input.cardId) || `card-${stamp}`,
|
|
6837
|
+
call_id: truthyText2(input.callId) || `contract-card-${stamp}-01`,
|
|
6838
|
+
title: truthyText2(input.title) || void 0,
|
|
6839
|
+
only: truthyText2(input.only).split(",").map((item) => item.trim()).filter((item) => item.length > 0)
|
|
6840
|
+
};
|
|
6841
|
+
const templatePath = truthyText2(input.template);
|
|
6842
|
+
const template = templatePath ? readTextOrThrow(resolve8(templatePath), "template") : CARD_TEMPLATE;
|
|
6843
|
+
const { payload, planned, cardCount, hint } = renderActionCard(ctx, cfg, template);
|
|
6844
|
+
if (!payload) {
|
|
6845
|
+
return {
|
|
6846
|
+
status: "COMPLETE",
|
|
6847
|
+
data: {
|
|
6848
|
+
noCard: true,
|
|
6849
|
+
planned,
|
|
6850
|
+
cardCount: 0,
|
|
6851
|
+
contextSource: source,
|
|
6852
|
+
hint: hint || "\u8FC7\u6EE4\u540E\u65E0\u53EF\u7528\u52A8\u4F5C\uFF08\u6309 contract-action-engine.md \xA77 \u5904\u7406\uFF09"
|
|
6853
|
+
}
|
|
6854
|
+
};
|
|
6855
|
+
}
|
|
6856
|
+
const check = selfCheckActionCard(payload);
|
|
6857
|
+
const text4 = `<browsertool>
|
|
6858
|
+
${JSON.stringify(payload, null, 1)}
|
|
6859
|
+
</browsertool>`;
|
|
6860
|
+
let output;
|
|
6861
|
+
const outPath = truthyText2(input.out);
|
|
6862
|
+
if (outPath) {
|
|
6863
|
+
output = resolve8(outPath);
|
|
6864
|
+
mkdirSync3(dirname4(output), { recursive: true });
|
|
6865
|
+
writeFileSync6(output, text4, "utf8");
|
|
6866
|
+
}
|
|
6867
|
+
return {
|
|
6868
|
+
status: "COMPLETE",
|
|
6869
|
+
data: {
|
|
6870
|
+
noCard: false,
|
|
6871
|
+
planned,
|
|
6872
|
+
cardCount,
|
|
6873
|
+
contextSource: source,
|
|
6874
|
+
title: payload.arguments.title,
|
|
6875
|
+
callId: payload.callId,
|
|
6876
|
+
htmlLength: check.htmlLength,
|
|
6877
|
+
selfCheck: check.problems,
|
|
6878
|
+
selfCheckPassed: check.problems.length === 0,
|
|
6879
|
+
bytes: Buffer.byteLength(text4, "utf8"),
|
|
6880
|
+
...output ? { output, browsertool: text4 } : { browsertool: text4 },
|
|
6881
|
+
note: check.problems.length ? "\u81EA\u68C0\u672A\u901A\u8FC7\uFF0C\u7981\u6B62\u4EA4\u4ED8\uFF1B\u8BF7\u6309 selfCheck \u4FEE\u6B63\u540E\u91CD\u8DD1" : "browsertool \u53EF\u76F4\u63A5\u88F8\u8F93\u51FA\uFF1B\u7981\u6B62\u518D\u624B\u5199\u5361\u7247 HTML"
|
|
6882
|
+
}
|
|
6883
|
+
};
|
|
6884
|
+
}
|
|
6885
|
+
};
|
|
6886
|
+
var contractCardActionOperations = [contractCardActionOperation];
|
|
6887
|
+
|
|
6888
|
+
// src/shortcuts/contract/operations/upload.ts
|
|
6889
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
6890
|
+
import { readFile as readFile5, stat } from "node:fs/promises";
|
|
6891
|
+
import { basename as basename4, resolve as resolve11 } from "node:path";
|
|
6892
|
+
|
|
6893
|
+
// src/shortcuts/contract/upload-cache.ts
|
|
6894
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
6895
|
+
import { mkdir as mkdir3, readFile as readFile3, writeFile as writeFile3 } from "node:fs/promises";
|
|
6896
|
+
import { homedir as homedir2 } from "node:os";
|
|
6897
|
+
import { dirname as dirname5, resolve as resolve9 } from "node:path";
|
|
6898
|
+
var CACHE_VERSION = 1;
|
|
6899
|
+
var MAX_ENTRIES = 200;
|
|
6900
|
+
var MAX_FILE_MODULES = 500;
|
|
6901
|
+
var DEFAULT_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
6902
|
+
function cacheRoot() {
|
|
6903
|
+
const home = process.env.WEAVER_WORK_CLI_HOME || process.env.WORK_CLI_HOME || resolve9(homedir2(), ".weaver-work-cli");
|
|
6904
|
+
return resolve9(home, "contract");
|
|
6905
|
+
}
|
|
6906
|
+
function cacheFilePath() {
|
|
6907
|
+
return resolve9(cacheRoot(), "upload-cache.json");
|
|
6908
|
+
}
|
|
6909
|
+
function ttlMs() {
|
|
6910
|
+
const raw = process.env.WEAVER_CONTRACT_UPLOAD_CACHE_TTL_MS;
|
|
6911
|
+
if (raw === void 0) return DEFAULT_TTL_MS;
|
|
6912
|
+
const parsed = Number(raw);
|
|
6913
|
+
return Number.isFinite(parsed) && parsed >= 0 ? parsed : DEFAULT_TTL_MS;
|
|
6914
|
+
}
|
|
6915
|
+
function isCacheEnabled() {
|
|
6916
|
+
return ttlMs() > 0;
|
|
6917
|
+
}
|
|
6918
|
+
function fingerprintKey(input) {
|
|
6919
|
+
return createHash2("sha256").update(`${input.sha256}|${input.module}|${input.baseUrl}|${input.userId}`).digest("hex");
|
|
6920
|
+
}
|
|
6921
|
+
function sha256Of(buffer) {
|
|
6922
|
+
return createHash2("sha256").update(buffer).digest("hex");
|
|
6923
|
+
}
|
|
6924
|
+
async function readCache() {
|
|
6925
|
+
try {
|
|
6926
|
+
const raw = (await readFile3(cacheFilePath(), "utf8")).replace(/^\uFEFF/u, "");
|
|
6927
|
+
const parsed = JSON.parse(raw);
|
|
6928
|
+
if (!parsed || parsed.version !== CACHE_VERSION || typeof parsed.entries !== "object") {
|
|
6929
|
+
return { version: CACHE_VERSION, entries: {}, fileModules: {} };
|
|
6930
|
+
}
|
|
6931
|
+
return {
|
|
6932
|
+
version: CACHE_VERSION,
|
|
6933
|
+
entries: parsed.entries ?? {},
|
|
6934
|
+
// 旧版本缓存文件没有这个字段,读出来时补空对象即可。
|
|
6935
|
+
fileModules: parsed.fileModules && typeof parsed.fileModules === "object" ? parsed.fileModules : {}
|
|
6936
|
+
};
|
|
6937
|
+
} catch {
|
|
6938
|
+
return { version: CACHE_VERSION, entries: {}, fileModules: {} };
|
|
6939
|
+
}
|
|
6940
|
+
}
|
|
6941
|
+
async function writeCache(cache) {
|
|
6942
|
+
try {
|
|
6943
|
+
const path = cacheFilePath();
|
|
6944
|
+
await mkdir3(dirname5(path), { recursive: true });
|
|
6945
|
+
await writeFile3(path, JSON.stringify(cache), "utf8");
|
|
6946
|
+
} catch {
|
|
6947
|
+
}
|
|
6948
|
+
}
|
|
6949
|
+
async function lookupUpload(key) {
|
|
6950
|
+
if (!isCacheEnabled()) return null;
|
|
6951
|
+
const cache = await readCache();
|
|
6952
|
+
const entry = cache.entries[key];
|
|
6953
|
+
if (!entry) return null;
|
|
6954
|
+
const age = Date.now() - entry.updatedAt;
|
|
6955
|
+
if (age > ttlMs()) {
|
|
6956
|
+
delete cache.entries[key];
|
|
6957
|
+
await writeCache(cache);
|
|
6958
|
+
return null;
|
|
6959
|
+
}
|
|
6960
|
+
entry.hits = (entry.hits ?? 0) + 1;
|
|
6961
|
+
await writeCache(cache);
|
|
6962
|
+
return entry;
|
|
6963
|
+
}
|
|
6964
|
+
async function rememberUpload(key, entry) {
|
|
6965
|
+
if (!isCacheEnabled()) return;
|
|
6966
|
+
const cache = await readCache();
|
|
6967
|
+
const previous = cache.entries[key];
|
|
6968
|
+
cache.entries[key] = {
|
|
6969
|
+
...entry,
|
|
6970
|
+
updatedAt: Date.now(),
|
|
6971
|
+
hits: previous?.hits ?? 0
|
|
6972
|
+
};
|
|
6973
|
+
const keys = Object.keys(cache.entries);
|
|
6974
|
+
if (keys.length > MAX_ENTRIES) {
|
|
6975
|
+
keys.sort((a, b) => cache.entries[a].updatedAt - cache.entries[b].updatedAt).slice(0, keys.length - MAX_ENTRIES).forEach((stale) => delete cache.entries[stale]);
|
|
6976
|
+
}
|
|
6977
|
+
await writeCache(cache);
|
|
6978
|
+
}
|
|
6979
|
+
async function rememberFileModule(input) {
|
|
6980
|
+
if (!isCacheEnabled() || !input.fileId) return;
|
|
6981
|
+
const cache = await readCache();
|
|
6982
|
+
cache.fileModules[`${input.baseUrl}|${input.userId}|${input.fileId}`] = {
|
|
6983
|
+
module: input.module,
|
|
6984
|
+
updatedAt: Date.now()
|
|
6985
|
+
};
|
|
6986
|
+
const keys = Object.keys(cache.fileModules);
|
|
6987
|
+
if (keys.length > MAX_FILE_MODULES) {
|
|
6988
|
+
keys.sort((a, b) => cache.fileModules[a].updatedAt - cache.fileModules[b].updatedAt).slice(0, keys.length - MAX_FILE_MODULES).forEach((stale) => delete cache.fileModules[stale]);
|
|
6989
|
+
}
|
|
6990
|
+
await writeCache(cache);
|
|
6991
|
+
}
|
|
6992
|
+
async function lookupFileModule(input) {
|
|
6993
|
+
if (!isCacheEnabled() || !input.fileId) return null;
|
|
6994
|
+
const cache = await readCache();
|
|
6995
|
+
const entry = cache.fileModules[`${input.baseUrl}|${input.userId}|${input.fileId}`];
|
|
6996
|
+
if (!entry) return null;
|
|
6997
|
+
if (Date.now() - entry.updatedAt > ttlMs()) {
|
|
6998
|
+
delete cache.fileModules[`${input.baseUrl}|${input.userId}|${input.fileId}`];
|
|
6999
|
+
await writeCache(cache);
|
|
7000
|
+
return null;
|
|
7001
|
+
}
|
|
7002
|
+
return entry.module;
|
|
7003
|
+
}
|
|
7004
|
+
|
|
7005
|
+
// src/shortcuts/contract/prewarm-cache.ts
|
|
7006
|
+
import { mkdir as mkdir4, readFile as readFile4, writeFile as writeFile4 } from "node:fs/promises";
|
|
7007
|
+
import { homedir as homedir3 } from "node:os";
|
|
7008
|
+
import { dirname as dirname6, resolve as resolve10 } from "node:path";
|
|
7009
|
+
var CACHE_VERSION2 = 1;
|
|
7010
|
+
var MAX_ENTRIES2 = 500;
|
|
7011
|
+
var DEFAULT_TTL_MS2 = 2 * 60 * 60 * 1e3;
|
|
7012
|
+
function cacheRoot2() {
|
|
7013
|
+
const home = process.env.WEAVER_WORK_CLI_HOME || process.env.WORK_CLI_HOME || resolve10(homedir3(), ".weaver-work-cli");
|
|
7014
|
+
return resolve10(home, "contract");
|
|
7015
|
+
}
|
|
7016
|
+
function prewarmCacheFilePath() {
|
|
7017
|
+
return resolve10(cacheRoot2(), "prewarm-cache.json");
|
|
7018
|
+
}
|
|
7019
|
+
function ttlMs2() {
|
|
7020
|
+
const raw = process.env.WEAVER_CONTRACT_PREWARM_CACHE_TTL_MS;
|
|
7021
|
+
if (raw === void 0) return DEFAULT_TTL_MS2;
|
|
7022
|
+
const parsed = Number(raw);
|
|
7023
|
+
return Number.isFinite(parsed) && parsed >= 0 ? parsed : DEFAULT_TTL_MS2;
|
|
7024
|
+
}
|
|
7025
|
+
function isPrewarmCacheEnabled() {
|
|
7026
|
+
return ttlMs2() > 0;
|
|
7027
|
+
}
|
|
7028
|
+
function prewarmKey(input) {
|
|
7029
|
+
return `${input.baseUrl}|${input.userId}|${input.fileId}`;
|
|
7030
|
+
}
|
|
7031
|
+
async function readCache2() {
|
|
7032
|
+
try {
|
|
7033
|
+
const raw = (await readFile4(prewarmCacheFilePath(), "utf8")).replace(/^\uFEFF/u, "");
|
|
7034
|
+
const parsed = JSON.parse(raw);
|
|
7035
|
+
if (!parsed || parsed.version !== CACHE_VERSION2 || typeof parsed.entries !== "object") {
|
|
7036
|
+
return { version: CACHE_VERSION2, entries: {} };
|
|
7037
|
+
}
|
|
7038
|
+
return parsed;
|
|
7039
|
+
} catch {
|
|
7040
|
+
return { version: CACHE_VERSION2, entries: {} };
|
|
7041
|
+
}
|
|
7042
|
+
}
|
|
7043
|
+
async function writeCache2(cache) {
|
|
7044
|
+
try {
|
|
7045
|
+
const path = prewarmCacheFilePath();
|
|
7046
|
+
await mkdir4(dirname6(path), { recursive: true });
|
|
7047
|
+
await writeFile4(path, JSON.stringify(cache), "utf8");
|
|
7048
|
+
} catch {
|
|
7049
|
+
}
|
|
7050
|
+
}
|
|
7051
|
+
async function wasPrewarmed(key) {
|
|
7052
|
+
if (!isPrewarmCacheEnabled()) return false;
|
|
7053
|
+
const cache = await readCache2();
|
|
7054
|
+
const at = cache.entries[key];
|
|
7055
|
+
if (at === void 0) return false;
|
|
7056
|
+
if (Date.now() - at > ttlMs2()) {
|
|
7057
|
+
delete cache.entries[key];
|
|
7058
|
+
await writeCache2(cache);
|
|
7059
|
+
return false;
|
|
7060
|
+
}
|
|
7061
|
+
return true;
|
|
7062
|
+
}
|
|
7063
|
+
async function markPrewarmed(key) {
|
|
7064
|
+
if (!isPrewarmCacheEnabled()) return;
|
|
7065
|
+
const cache = await readCache2();
|
|
7066
|
+
cache.entries[key] = Date.now();
|
|
7067
|
+
const keys = Object.keys(cache.entries);
|
|
7068
|
+
if (keys.length > MAX_ENTRIES2) {
|
|
7069
|
+
keys.sort((a, b) => cache.entries[a] - cache.entries[b]).slice(0, keys.length - MAX_ENTRIES2).forEach((stale) => delete cache.entries[stale]);
|
|
7070
|
+
}
|
|
7071
|
+
await writeCache2(cache);
|
|
7072
|
+
}
|
|
7073
|
+
|
|
7074
|
+
// src/shortcuts/contract/prewarm.ts
|
|
7075
|
+
var AI_REVIEW_PREWARM_FLOW_ID = "1269716062340284522";
|
|
7076
|
+
var PREWARM_PATH = "/api/ebd/contract/ai/saveInternalRecord";
|
|
7077
|
+
var PREWARM_TIMEOUT_MS = 3e4;
|
|
7078
|
+
async function prewarmOne(host, fileId) {
|
|
7079
|
+
try {
|
|
7080
|
+
await host.contractRequest({
|
|
7081
|
+
method: "POST",
|
|
7082
|
+
path: PREWARM_PATH,
|
|
7083
|
+
body: { flowId: AI_REVIEW_PREWARM_FLOW_ID, fileId },
|
|
7084
|
+
timeoutMs: PREWARM_TIMEOUT_MS,
|
|
7085
|
+
// 触发型接口:成功时响应体为空,代表"预审已在执行"。
|
|
7086
|
+
// 不能走业务码判定,否则空体会被判成业务失败。
|
|
7087
|
+
okOnHttpSuccess: true
|
|
7088
|
+
});
|
|
7089
|
+
return { fileId, ok: true };
|
|
7090
|
+
} catch (error) {
|
|
7091
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
7092
|
+
const structured = error;
|
|
7093
|
+
const code = structured?.code === void 0 ? "" : ` code=${String(structured.code)}`;
|
|
7094
|
+
const raw = typeof structured?.details?.raw === "string" ? ` raw=${String(structured.details.raw).slice(0, 300)}` : "";
|
|
7095
|
+
return { fileId, ok: false, error: `${message}${code}${raw}` };
|
|
7096
|
+
}
|
|
7097
|
+
}
|
|
7098
|
+
async function ensurePrewarmed(host, fileIds, options = {}) {
|
|
7099
|
+
const unique = Array.from(new Set(fileIds.map((item) => String(item).trim()).filter(Boolean)));
|
|
7100
|
+
const force = options.force === true;
|
|
7101
|
+
let baseUrl = "";
|
|
7102
|
+
let userId = "";
|
|
7103
|
+
try {
|
|
7104
|
+
const session = await host.getSession();
|
|
7105
|
+
baseUrl = session.baseUrl ?? "";
|
|
7106
|
+
userId = session.userId ?? "";
|
|
7107
|
+
} catch {
|
|
7108
|
+
}
|
|
7109
|
+
const results = await Promise.all(unique.map(async (fileId) => {
|
|
7110
|
+
if (!force && isPrewarmCacheEnabled() && baseUrl) {
|
|
7111
|
+
const key = prewarmKey({ fileId, baseUrl, userId });
|
|
7112
|
+
if (await wasPrewarmed(key)) {
|
|
7113
|
+
return { fileId, ok: true, skipped: true };
|
|
7114
|
+
}
|
|
7115
|
+
}
|
|
7116
|
+
const result = await prewarmOne(host, fileId);
|
|
7117
|
+
if (result.ok && isPrewarmCacheEnabled() && baseUrl) {
|
|
7118
|
+
await markPrewarmed(prewarmKey({ fileId, baseUrl, userId }));
|
|
7119
|
+
}
|
|
7120
|
+
return result;
|
|
7121
|
+
}));
|
|
7122
|
+
return {
|
|
7123
|
+
flowId: AI_REVIEW_PREWARM_FLOW_ID,
|
|
7124
|
+
enabled: true,
|
|
7125
|
+
okCount: results.filter((item) => item.ok).length,
|
|
7126
|
+
failCount: results.filter((item) => !item.ok).length,
|
|
7127
|
+
skippedCount: results.filter((item) => item.skipped === true).length,
|
|
7128
|
+
results
|
|
7129
|
+
};
|
|
7130
|
+
}
|
|
7131
|
+
async function prewarmAll(host, fileIds) {
|
|
7132
|
+
const unique = Array.from(new Set(fileIds.map((item) => String(item).trim()).filter(Boolean)));
|
|
7133
|
+
return Promise.all(unique.map((fileId) => prewarmOne(host, fileId)));
|
|
7134
|
+
}
|
|
7135
|
+
|
|
7136
|
+
// src/shortcuts/contract/operations/upload.ts
|
|
7137
|
+
var MAX_FILE_BYTES = 200 * 1024 * 1024;
|
|
7138
|
+
var DEFAULT_UPLOAD_TIMEOUT_MS = 12e4;
|
|
7139
|
+
var DOC_EXTENSIONS = /* @__PURE__ */ new Set([".doc", ".docx"]);
|
|
7140
|
+
function text(value) {
|
|
7141
|
+
if (typeof value === "string" && value.trim()) return value;
|
|
7142
|
+
if (typeof value === "number" && Number.isFinite(value)) return String(value);
|
|
7143
|
+
return void 0;
|
|
7144
|
+
}
|
|
7145
|
+
function pickFileId(payload) {
|
|
7146
|
+
return text(payload.fileid) ?? text(payload.fileId) ?? text(payload.uploadModuleDto?.fileid) ?? text(payload.uploadModuleDto?.fileId);
|
|
7147
|
+
}
|
|
7148
|
+
async function uploadFile(host, options) {
|
|
7149
|
+
const absolutePath = resolve11(options.path);
|
|
7150
|
+
const info = await stat(absolutePath).catch(() => null);
|
|
7151
|
+
if (!info || !info.isFile()) {
|
|
7152
|
+
throw contractValidationError("file_not_found", `\u6587\u4EF6\u4E0D\u5B58\u5728\u6216\u4E0D\u662F\u666E\u901A\u6587\u4EF6\uFF1A${options.path}`);
|
|
7153
|
+
}
|
|
7154
|
+
if (info.size === 0) {
|
|
7155
|
+
throw contractValidationError("file_empty", `\u6587\u4EF6\u5185\u5BB9\u4E3A\u7A7A\uFF1A${options.path}`);
|
|
7156
|
+
}
|
|
7157
|
+
if (info.size > MAX_FILE_BYTES) {
|
|
7158
|
+
throw contractValidationError("file_too_large", `\u6587\u4EF6\u8D85\u8FC7 ${MAX_FILE_BYTES / 1024 / 1024}MB \u4E0A\u9650\uFF1A${options.path}`);
|
|
7159
|
+
}
|
|
7160
|
+
const name = basename4(absolutePath);
|
|
7161
|
+
const buffer = await readFile5(absolutePath);
|
|
7162
|
+
const md5 = createHash3("md5").update(buffer).digest("hex");
|
|
7163
|
+
const modified = String(Math.trunc(info.mtimeMs));
|
|
7164
|
+
const sha256 = sha256Of(buffer);
|
|
7165
|
+
let reuseKey = null;
|
|
7166
|
+
if (isCacheEnabled()) {
|
|
7167
|
+
try {
|
|
7168
|
+
const session = await host.getSession();
|
|
7169
|
+
reuseKey = fingerprintKey({
|
|
7170
|
+
sha256,
|
|
7171
|
+
module: options.module,
|
|
7172
|
+
baseUrl: session.baseUrl,
|
|
7173
|
+
userId: session.userId ?? ""
|
|
7174
|
+
});
|
|
7175
|
+
const hit = await lookupUpload(reuseKey);
|
|
7176
|
+
if (hit) {
|
|
7177
|
+
return await finish({
|
|
7178
|
+
fileId: hit.fileId,
|
|
7179
|
+
docId: hit.docId,
|
|
7180
|
+
name: hit.name || name,
|
|
7181
|
+
size: hit.size,
|
|
7182
|
+
md5: hit.md5,
|
|
7183
|
+
sha256,
|
|
7184
|
+
reused: true
|
|
7185
|
+
});
|
|
7186
|
+
}
|
|
7187
|
+
} catch {
|
|
7188
|
+
reuseKey = null;
|
|
7189
|
+
}
|
|
7190
|
+
}
|
|
7191
|
+
const form = {
|
|
7192
|
+
compressImg: "false",
|
|
7193
|
+
module: options.module,
|
|
7194
|
+
...options.module === "ebContract" ? { createDoc: "true" } : {},
|
|
7195
|
+
...options.extraFields ?? {},
|
|
7196
|
+
size: String(buffer.length),
|
|
5408
7197
|
name,
|
|
5409
7198
|
MD5: md5,
|
|
5410
7199
|
lastModified: modified,
|
|
@@ -5434,7 +7223,7 @@ async function uploadFile(host, options) {
|
|
|
5434
7223
|
sha256
|
|
5435
7224
|
});
|
|
5436
7225
|
}
|
|
5437
|
-
return {
|
|
7226
|
+
return await finish({
|
|
5438
7227
|
fileId: secondUploadId,
|
|
5439
7228
|
docId: reusedDocId,
|
|
5440
7229
|
name: reusedName,
|
|
@@ -5442,7 +7231,7 @@ async function uploadFile(host, options) {
|
|
|
5442
7231
|
md5,
|
|
5443
7232
|
sha256,
|
|
5444
7233
|
reused: false
|
|
5445
|
-
};
|
|
7234
|
+
});
|
|
5446
7235
|
}
|
|
5447
7236
|
const preUploadId = text(precheckData.preUploadId);
|
|
5448
7237
|
const uploadType = text(precheckData.uploadType) ?? "common";
|
|
@@ -5489,7 +7278,7 @@ async function uploadFile(host, options) {
|
|
|
5489
7278
|
sha256
|
|
5490
7279
|
});
|
|
5491
7280
|
}
|
|
5492
|
-
return {
|
|
7281
|
+
return await finish({
|
|
5493
7282
|
fileId,
|
|
5494
7283
|
docId: finalDocId,
|
|
5495
7284
|
name: finalName,
|
|
@@ -5497,7 +7286,34 @@ async function uploadFile(host, options) {
|
|
|
5497
7286
|
md5,
|
|
5498
7287
|
sha256,
|
|
5499
7288
|
reused: false
|
|
5500
|
-
};
|
|
7289
|
+
});
|
|
7290
|
+
async function finish(file) {
|
|
7291
|
+
file.module = options.module;
|
|
7292
|
+
const prewarmEnabled = options.prewarm !== false;
|
|
7293
|
+
if (!prewarmEnabled) return file;
|
|
7294
|
+
try {
|
|
7295
|
+
const session = await host.getSession();
|
|
7296
|
+
await rememberFileModule({
|
|
7297
|
+
fileId: file.fileId,
|
|
7298
|
+
module: options.module,
|
|
7299
|
+
baseUrl: session.baseUrl,
|
|
7300
|
+
userId: session.userId ?? ""
|
|
7301
|
+
});
|
|
7302
|
+
} catch {
|
|
7303
|
+
}
|
|
7304
|
+
try {
|
|
7305
|
+
const summary = await ensurePrewarmed(host, [file.fileId]);
|
|
7306
|
+
const result = summary.results[0];
|
|
7307
|
+
const ok = result?.ok === true;
|
|
7308
|
+
file.prewarmed = ok;
|
|
7309
|
+
file.prewarmSkipped = result?.skipped === true;
|
|
7310
|
+
if (!ok) file.prewarmError = result?.error ?? "\u672A\u77E5\u539F\u56E0";
|
|
7311
|
+
} catch (error) {
|
|
7312
|
+
file.prewarmed = false;
|
|
7313
|
+
file.prewarmError = error instanceof Error ? error.message : String(error);
|
|
7314
|
+
}
|
|
7315
|
+
return file;
|
|
7316
|
+
}
|
|
5501
7317
|
}
|
|
5502
7318
|
function assertContractDocument(path) {
|
|
5503
7319
|
const lower = path.toLowerCase();
|
|
@@ -6289,6 +8105,750 @@ var contractCustomerOperations = [
|
|
|
6289
8105
|
contractCustomerBrowserOperation
|
|
6290
8106
|
];
|
|
6291
8107
|
|
|
8108
|
+
// src/shortcuts/contract/operations/elements-build.ts
|
|
8109
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync4, readFileSync as readFileSync8, statSync as statSync3, writeFileSync as writeFileSync7 } from "node:fs";
|
|
8110
|
+
import { basename as basename5, dirname as dirname7, extname, join as join2, resolve as resolve12 } from "node:path";
|
|
8111
|
+
|
|
8112
|
+
// src/shortcuts/contract/operations/elements-spec.ts
|
|
8113
|
+
var NEW_CUSTOMER = {
|
|
8114
|
+
workflowId: "1269716062340284522",
|
|
8115
|
+
attachmentFieldId: "1269716066559755048",
|
|
8116
|
+
// 合同正文及附件
|
|
8117
|
+
fields: {
|
|
8118
|
+
attachment: "1269716066559755048#\u5408\u540C\u6B63\u6587\u53CA\u9644\u4EF6",
|
|
8119
|
+
buyMode: "1269716066559755042#\u8D2D\u4E70\u65B9\u5F0F",
|
|
8120
|
+
totalAmount: "1269716066559755354#\u5408\u540C\u603B\u91D1\u989D",
|
|
8121
|
+
ourCompany: "1269716066559755399#\u6211\u65B9\u7B7E\u7EA6\u516C\u53F8",
|
|
8122
|
+
background: "1269716066559755317#\u5408\u540C\u80CC\u666F\u8BF4\u660E",
|
|
8123
|
+
title: "1298271934046470226#\u6D41\u7A0B\u6807\u9898\uFF08new\uFF09",
|
|
8124
|
+
finalUser: "1269716066559755356#\u6700\u7EC8\u7528\u6237\u5361\u7247",
|
|
8125
|
+
solution: "1269716066559755429#\u4E13\u9879\u65B9\u6848",
|
|
8126
|
+
solutionAmt: "1269716066559755433#\u4E13\u9879\u91D1\u989D",
|
|
8127
|
+
signForm: "1269716066559755369#\u7B7E\u7EA6\u5F62\u5F0F",
|
|
8128
|
+
signDate: "1269716066559754975#\u5408\u540C\u7B7E\u7F72\u65E5\u671F",
|
|
8129
|
+
signWay: "1269716066559755076#\u5408\u540C\u7B7E\u8BA2\u65B9\u5F0F",
|
|
8130
|
+
partner: "1269716066559755360#\u4F19\u4F34\u540D\u79F0",
|
|
8131
|
+
address: "1269716066559755085#\u5408\u540C\u90AE\u5BC4\u5730\u5740",
|
|
8132
|
+
receiver: "1269716066559755079#\u5408\u540C\u6536\u4EF6\u4EBA",
|
|
8133
|
+
mobile: "1269716066559755081#\u6536\u4EF6\u4EBA\u79FB\u52A8\u7535\u8BDD",
|
|
8134
|
+
designatedDate: "1269716066559755286#\u6307\u5B9A\u7B7E\u7F72\u65E5\u671F"
|
|
8135
|
+
},
|
|
8136
|
+
subFormId: "1269716066559754943",
|
|
8137
|
+
subFormName: "\u4E13\u9879\u8D2D\u4E70\u4FE1\u606F",
|
|
8138
|
+
options: {
|
|
8139
|
+
buyMode: { \u76F4\u7B7E: "0", \u901A\u8FC7\u4F19\u4F34\u7B7E\u7F72: "1" },
|
|
8140
|
+
ourCompany: {
|
|
8141
|
+
\u6CDB\u5FAE\u7F51\u7EDC: "0",
|
|
8142
|
+
\u6CDB\u5FAE\u7F51\u7EDC\u79D1\u6280\u80A1\u4EFD\u6709\u9650\u516C\u53F8: "0",
|
|
8143
|
+
\u6CDB\u5FAE\u8F6F\u4EF6: "1",
|
|
8144
|
+
\u4E0A\u6D77\u6CDB\u5FAE\u8F6F\u4EF6\u6709\u9650\u516C\u53F8: "1",
|
|
8145
|
+
\u6CDB\u5FAE\u65B0\u52A0\u5761: "2",
|
|
8146
|
+
\u6210\u90FD\u6CDB\u5FAE: "3",
|
|
8147
|
+
\u6CDB\u5FAE\u9A6C\u6765\u897F\u4E9A: "4",
|
|
8148
|
+
\u6CDB\u5FAE\u5370\u5C3C: "5",
|
|
8149
|
+
\u6D59\u6C5F\u6CDB\u5FAE: "6"
|
|
8150
|
+
},
|
|
8151
|
+
signForm: {
|
|
8152
|
+
\u53CC\u65B9\u7535\u5B50\u7B7E\u7F72\u5BA2\u6237\u7535\u5B50\u7B7E\u5E73\u53F0\u53CC\u65B9\u7535\u5B50\u7B7E: "0",
|
|
8153
|
+
\u53CC\u65B9\u7535\u5B50\u7B7E\u7F72: "0",
|
|
8154
|
+
\u9632\u4F2A\u6253\u5370\u7B7E\u7F72: "1",
|
|
8155
|
+
\u7EB8\u8D28\u7B7E\u7F72: "2",
|
|
8156
|
+
\u5355\u65B9\u7535\u5B50\u7B7E\u7F72: "3",
|
|
8157
|
+
\u53CC\u65B9\u7535\u5B50\u7B7E\u7F72\u6CDB\u5FAE\u5951\u7EA6\u9501\u5E73\u53F0\u53CC\u65B9\u7535\u5B50\u7B7E: "4",
|
|
8158
|
+
\u65E0\u9700\u7528\u5370: "5"
|
|
8159
|
+
},
|
|
8160
|
+
signDate: {
|
|
8161
|
+
\u662F: "0",
|
|
8162
|
+
\u5426: "1",
|
|
8163
|
+
\u9ED8\u8BA4\u5408\u540C\u529E\u7406\u5F53\u5929: "2",
|
|
8164
|
+
\u6307\u5B9A\u7B7E\u7F72\u65E5\u671F: "3",
|
|
8165
|
+
\u6682\u4E0D\u586B\u5199: "4"
|
|
8166
|
+
},
|
|
8167
|
+
signWay: { \u6211\u65B9\u5148\u76D6\u7AE0: "0", \u5BA2\u6237\u65B9\u5148\u76D6\u7AE0: "1", \u7B49\u5F85\u786E\u8BA4: "2" }
|
|
8168
|
+
},
|
|
8169
|
+
defaults: { signForm: "2", signDate: "2", signWay: "0" }
|
|
8170
|
+
};
|
|
8171
|
+
var QIYUESUO = {
|
|
8172
|
+
workflowId: "100003460000002066",
|
|
8173
|
+
attachmentFieldId: "100003720000025579",
|
|
8174
|
+
// 合同正文及附件
|
|
8175
|
+
fields: {
|
|
8176
|
+
attachment: "100003720000025579#\u5408\u540C\u6B63\u6587\u53CA\u9644\u4EF6",
|
|
8177
|
+
title: "1315748387847675960#\u6D41\u7A0B\u6807\u9898\uFF08new\uFF09",
|
|
8178
|
+
contractName: "100003720000028023#\u5408\u540C\u540D\u79F0",
|
|
8179
|
+
totalAmount: "100003720000025527#\u5408\u540C\u603B\u91D1\u989D",
|
|
8180
|
+
receiver: "100003720000025492#\u5408\u540C\u6536\u4EF6\u4EBA",
|
|
8181
|
+
mobile: "100003720000025493#\u6536\u4EF6\u4EBA\u79FB\u52A8\u7535\u8BDD",
|
|
8182
|
+
address: "100003720000025495#\u5408\u540C\u90AE\u5BC4\u5730\u5740",
|
|
8183
|
+
partySigner: "100003720000032878#\u5BF9\u65B9\u7B7E\u7F72\u4EBA\u59D3\u540D",
|
|
8184
|
+
partyContact: "100003720000032879#\u5BF9\u65B9\u7B7E\u7F72\u4EBA\u8054\u7CFB\u65B9\u5F0F"
|
|
8185
|
+
},
|
|
8186
|
+
selects: {
|
|
8187
|
+
buyMode: "100003720000025514#\u8D2D\u4E70\u65B9\u5F0F",
|
|
8188
|
+
ourCompany: "100003720000053778#\u7B7E\u7EA6\u516C\u53F8\uFF08\u53D1\u7968\u5F00\u5177\u4E13\u7528\uFF09",
|
|
8189
|
+
signForm: "100003720000026071#\u7B7E\u7EA6\u5F62\u5F0F",
|
|
8190
|
+
signDateType: "1024078670684487911#\u5408\u540C\u7B7E\u7F72\u65E5\u671F",
|
|
8191
|
+
signWay: "100003720000025491#\u5408\u540C\u7B7E\u8BA2\u65B9\u5F0F",
|
|
8192
|
+
implParty: "100003720000034686#\u5B9E\u65BD\u65B9",
|
|
8193
|
+
relatedProduct: "100003720000025529#\u76F8\u5173\u4EA7\u54C1",
|
|
8194
|
+
contractType: "100003720000025526#\u5408\u540C\u7C7B\u578B",
|
|
8195
|
+
isXinChuang: "991689488975806681#\u662F\u5426\u4FE1\u521B",
|
|
8196
|
+
finalUser: "100003720000025524#\u5BA2\u6237\u540D\u79F0\uFF08\u6700\u7EC8\u7528\u6237\uFF09",
|
|
8197
|
+
partner: "100003720000025582#\u4F19\u4F34\u516C\u53F8\u540D\u79F0"
|
|
8198
|
+
}
|
|
8199
|
+
};
|
|
8200
|
+
var RESALE = {
|
|
8201
|
+
workflowId: "1283761687634100307",
|
|
8202
|
+
attachmentFieldId: "100003720000029309",
|
|
8203
|
+
// 合同正文及附件
|
|
8204
|
+
fields: {
|
|
8205
|
+
attachment: "100003720000029309#\u5408\u540C\u6B63\u6587\u53CA\u9644\u4EF6",
|
|
8206
|
+
title: "1298278337779310598#\u6D41\u7A0B\u6807\u9898new",
|
|
8207
|
+
contractName: "100003720000007045#\u5408\u540C\u540D\u79F0",
|
|
8208
|
+
totalAmount: "100003720000001201#\u5408\u540C\u603B\u91D1\u989D",
|
|
8209
|
+
background: "100003720000001211#\u672C\u6B21\u5408\u540C\u7B7E\u8BA2\u7684\u80CC\u666F\u8BF4\u660E",
|
|
8210
|
+
receiver: "100003720000001233#\u5408\u540C\u6536\u4EF6\u4EBA",
|
|
8211
|
+
mobile: "100003720000001235#\u6536\u4EF6\u4EBA\u79FB\u52A8\u7535\u8BDD",
|
|
8212
|
+
address: "100003720000001234#\u5408\u540C\u90AE\u5BC4\u5730\u5740",
|
|
8213
|
+
purchase: "100003720000111953#\u5408\u540C\u8D2D\u4E70\u5185\u5BB9"
|
|
8214
|
+
},
|
|
8215
|
+
selects: {
|
|
8216
|
+
buyMode: "100003720000011577#\u8D2D\u4E70\u65B9\u5F0F",
|
|
8217
|
+
ourCompany: "100003720000020599#\u7B7E\u7EA6\u516C\u53F8\uFF08\u6211\u65B9\uFF09",
|
|
8218
|
+
signForm: "100003720000033806#\u7B7E\u7EA6\u5F62\u5F0F",
|
|
8219
|
+
signDateType: "100003720000015727#\u5408\u540C\u7B7E\u7F72\u65E5\u671F",
|
|
8220
|
+
signWay: "100003720000001232#\u5408\u540C\u7B7E\u8BA2\u65B9\u5F0F",
|
|
8221
|
+
contractType: "100003720000001200#\u5408\u540C\u7C7B\u578B",
|
|
8222
|
+
finalUser: "100003720000001199#\u5BA2\u6237\u540D\u79F0\uFF08\u6700\u7EC8\u7528\u6237\uFF09",
|
|
8223
|
+
partner: "1291602365099327623#\u4F19\u4F34\u540D\u79F0\uFF08\u6587\u672C\u5907\u4EFD\uFF09"
|
|
8224
|
+
},
|
|
8225
|
+
checkbox: {
|
|
8226
|
+
fieldKey: "purchase",
|
|
8227
|
+
options: { \u7EF4\u62A4: "0", \u7528\u6237\u6570: "1", \u7B2C\u4E09\u65B9\u8F6F\u786C\u4EF6: "2", \u5951\u7EA6\u9501: "3", \u5B9E\u65BD\u5F00\u53D1: "4" }
|
|
8228
|
+
}
|
|
8229
|
+
};
|
|
8230
|
+
var UPSALE = {
|
|
8231
|
+
workflowId: "1283761429944369334",
|
|
8232
|
+
attachmentFieldId: "100003720000039590",
|
|
8233
|
+
// 合同正文及附件
|
|
8234
|
+
fields: {
|
|
8235
|
+
attachment: "100003720000039590#\u5408\u540C\u6B63\u6587\u53CA\u9644\u4EF6",
|
|
8236
|
+
title: "1298277938348532028#\u6D41\u7A0B\u6807\u9898new",
|
|
8237
|
+
contractName: "100003720000027572#\u5408\u540C\u540D\u79F0\uFF08new\uFF09",
|
|
8238
|
+
totalAmount: "100003720000001290#\u5408\u540C\u603B\u91D1\u989D",
|
|
8239
|
+
background: "100003720000001297#\u5408\u540C\u80CC\u666F\u8BF4\u660E",
|
|
8240
|
+
receiver: "100003720000001320#\u5408\u540C\u6536\u4EF6\u4EBA",
|
|
8241
|
+
mobile: "100003720000001322#\u6536\u4EF6\u4EBA\u79FB\u52A8\u7535\u8BDD",
|
|
8242
|
+
address: "100003720000001321#\u5408\u540C\u90AE\u5BC4\u5730\u5740",
|
|
8243
|
+
purchase: "1286420538647650492#\u5408\u540C\u8D2D\u4E70\u5185\u5BB9"
|
|
8244
|
+
},
|
|
8245
|
+
selects: {
|
|
8246
|
+
buyMode: "100003720000011578#\u8D2D\u4E70\u65B9\u5F0F",
|
|
8247
|
+
ourCompany: "100003720000020601#\u7B7E\u7EA6\u516C\u53F8\uFF08\u6211\u65B9\uFF09",
|
|
8248
|
+
signForm: "100003720000033807#\u7B7E\u7EA6\u5F62\u5F0F",
|
|
8249
|
+
signDateType: "100003720000015728#\u5408\u540C\u7B7E\u7F72\u65E5\u671F",
|
|
8250
|
+
signWay: "100003720000001319#\u5408\u540C\u7B7E\u8BA2\u65B9\u5F0F",
|
|
8251
|
+
contractType: "100003720000001289#\u5408\u540C\u7C7B\u578B",
|
|
8252
|
+
finalUser: "100003720000001287#\u5BA2\u6237\u540D\u79F0\uFF08\u6700\u7EC8\u7528\u6237\uFF09",
|
|
8253
|
+
partner: "1291612552921137531#\u4F19\u4F34\u540D\u79F0\uFF08\u6587\u672C\u5907\u4EFD\uFF09"
|
|
8254
|
+
},
|
|
8255
|
+
// 合同购买内容选项 ID 与常规二次销售不同,禁止互抄
|
|
8256
|
+
checkbox: {
|
|
8257
|
+
fieldKey: "purchase",
|
|
8258
|
+
options: {
|
|
8259
|
+
\u529F\u80FD\u6A21\u5757: "0",
|
|
8260
|
+
\u5B9E\u65BD\u5F00\u53D1: "1",
|
|
8261
|
+
\u5347\u7EA7: "2",
|
|
8262
|
+
\u7B2C\u4E09\u65B9\u8F6F\u786C\u4EF6: "3",
|
|
8263
|
+
\u5951\u7EA6\u9501: "4",
|
|
8264
|
+
\u91CD\u65B0\u90E8\u7F72: "5"
|
|
8265
|
+
}
|
|
8266
|
+
}
|
|
8267
|
+
};
|
|
8268
|
+
var BUILTIN = {
|
|
8269
|
+
\u65B0\u5BA2\u6237: NEW_CUSTOMER,
|
|
8270
|
+
\u5951\u7EA6\u9501: QIYUESUO,
|
|
8271
|
+
\u5E38\u89C4\u4E8C\u6B21\u9500\u552E: RESALE,
|
|
8272
|
+
\u8001\u5BA2\u6237\u589E\u503C: UPSALE
|
|
8273
|
+
};
|
|
8274
|
+
var COMPANY_OPTIONS = [
|
|
8275
|
+
["\u6D59\u6C5F\u6CDB\u5FAE", ["\u6D59\u6C5F\u6CDB\u5FAE"]],
|
|
8276
|
+
["\u6210\u90FD\u6CDB\u5FAE", ["\u6210\u90FD\u6CDB\u5FAE"]],
|
|
8277
|
+
["\u6CDB\u5FAE\u65B0\u52A0\u5761", ["\u6CDB\u5FAE\u65B0\u52A0\u5761", "WEAVERSINGAPORE"]],
|
|
8278
|
+
["\u6CDB\u5FAE\u9A6C\u6765\u897F\u4E9A", ["\u6CDB\u5FAE\u9A6C\u6765\u897F\u4E9A", "WEAVERMALAYSIA"]],
|
|
8279
|
+
["\u6CDB\u5FAE\u5370\u5C3C", ["\u6CDB\u5FAE\u5370\u5C3C", "WEAVERINDONESIA"]],
|
|
8280
|
+
["\u6CDB\u5FAE\u8F6F\u4EF6", ["\u4E0A\u6D77\u6CDB\u5FAE\u8F6F\u4EF6", "\u6CDB\u5FAE\u8F6F\u4EF6"]],
|
|
8281
|
+
["\u6CDB\u5FAE\u7F51\u7EDC", ["\u6CDB\u5FAE\u7F51\u7EDC", "\u6CDB\u5FAE\u7F51\u7EDC\u79D1\u6280"]]
|
|
8282
|
+
];
|
|
8283
|
+
var CHECKBOX_HINTS_RESALE = [
|
|
8284
|
+
["\u7EF4\u62A4", ["\u7EF4\u62A4", "\u7EF4\u4FDD"]],
|
|
8285
|
+
["\u7528\u6237\u6570", ["\u7528\u6237\u6570", "\u5E76\u53D1", "\u8BB8\u53EF\u6570"]],
|
|
8286
|
+
["\u7B2C\u4E09\u65B9\u8F6F\u786C\u4EF6", ["\u7B2C\u4E09\u65B9\u8F6F\u786C\u4EF6", "\u786C\u4EF6\u91C7\u8D2D"]],
|
|
8287
|
+
["\u5951\u7EA6\u9501", ["\u5951\u7EA6\u9501"]],
|
|
8288
|
+
["\u5B9E\u65BD\u5F00\u53D1", ["\u5B9E\u65BD\u5F00\u53D1", "\u4E8C\u6B21\u5F00\u53D1", "\u5B9E\u65BD\u670D\u52A1"]]
|
|
8289
|
+
];
|
|
8290
|
+
var CHECKBOX_HINTS_UPSALE = [
|
|
8291
|
+
["\u529F\u80FD\u6A21\u5757", ["\u529F\u80FD\u6A21\u5757", "\u6A21\u5757\u8D2D\u4E70"]],
|
|
8292
|
+
["\u5B9E\u65BD\u5F00\u53D1", ["\u5B9E\u65BD\u5F00\u53D1", "\u4E8C\u6B21\u5F00\u53D1", "\u5B9E\u65BD\u670D\u52A1"]],
|
|
8293
|
+
["\u5347\u7EA7", ["\u5347\u7EA7", "\u7248\u672C\u5347\u7EA7"]],
|
|
8294
|
+
["\u7B2C\u4E09\u65B9\u8F6F\u786C\u4EF6", ["\u7B2C\u4E09\u65B9\u8F6F\u786C\u4EF6", "\u786C\u4EF6\u91C7\u8D2D"]],
|
|
8295
|
+
["\u5951\u7EA6\u9501", ["\u5951\u7EA6\u9501"]],
|
|
8296
|
+
["\u91CD\u65B0\u90E8\u7F72", ["\u91CD\u65B0\u90E8\u7F72", "\u8FC1\u79FB\u90E8\u7F72"]]
|
|
8297
|
+
];
|
|
8298
|
+
|
|
8299
|
+
// src/shortcuts/contract/operations/elements-build.ts
|
|
8300
|
+
var NUM_PREFIX = /^\s*(?:第[〇零一二三四五六七八九十百0-9]+[章节条款项编部]|[((][〇零一二三四五六七八九十百0-9]+[))]|[〇零一二三四五六七八九十]+、|[0-9]+(?:\.[0-9]+)+[、..]?|[0-9]+[、..]\s*)/u;
|
|
8301
|
+
function pyTruthy2(value) {
|
|
8302
|
+
if (value === null || value === void 0 || value === false) return false;
|
|
8303
|
+
if (value === true) return true;
|
|
8304
|
+
if (typeof value === "number") return value !== 0 && !Number.isNaN(value);
|
|
8305
|
+
if (typeof value === "string") return value.length > 0;
|
|
8306
|
+
if (Array.isArray(value)) return value.length > 0;
|
|
8307
|
+
if (typeof value === "object") return Object.keys(value).length > 0;
|
|
8308
|
+
return true;
|
|
8309
|
+
}
|
|
8310
|
+
function truthyText3(value) {
|
|
8311
|
+
return pyTruthy2(value) ? String(value) : "";
|
|
8312
|
+
}
|
|
8313
|
+
function orElse(value, fallback) {
|
|
8314
|
+
return pyTruthy2(value) ? value : fallback;
|
|
8315
|
+
}
|
|
8316
|
+
function isEmptyScalar(value) {
|
|
8317
|
+
return value === null || value === void 0 || value === "";
|
|
8318
|
+
}
|
|
8319
|
+
function norm(input) {
|
|
8320
|
+
const text4 = String(input ?? "");
|
|
8321
|
+
const chars = [];
|
|
8322
|
+
for (const ch of text4) {
|
|
8323
|
+
const code = ch.codePointAt(0) ?? 0;
|
|
8324
|
+
if (code === 12288) chars.push(" ");
|
|
8325
|
+
else if (code >= 65281 && code <= 65374) chars.push(String.fromCodePoint(code - 65248));
|
|
8326
|
+
else chars.push(ch);
|
|
8327
|
+
}
|
|
8328
|
+
return chars.join("").replace(/[\s()()·・]/gu, "");
|
|
8329
|
+
}
|
|
8330
|
+
function stripNumber(input) {
|
|
8331
|
+
let out = truthyText3(input);
|
|
8332
|
+
let prev = null;
|
|
8333
|
+
while (out && out !== prev) {
|
|
8334
|
+
prev = out;
|
|
8335
|
+
const match = NUM_PREFIX.exec(out);
|
|
8336
|
+
if (match && match.index === 0) {
|
|
8337
|
+
out = out.slice(match[0].length).trim();
|
|
8338
|
+
} else {
|
|
8339
|
+
break;
|
|
8340
|
+
}
|
|
8341
|
+
}
|
|
8342
|
+
return out;
|
|
8343
|
+
}
|
|
8344
|
+
function isCell(line) {
|
|
8345
|
+
return truthyText3(line).trim().startsWith("|");
|
|
8346
|
+
}
|
|
8347
|
+
function cellText(line) {
|
|
8348
|
+
let text4 = truthyText3(line).trim();
|
|
8349
|
+
if (text4.startsWith("|")) text4 = text4.replace(/^\|+/u, "").trim();
|
|
8350
|
+
return text4.replace(/\s+/gu, " ");
|
|
8351
|
+
}
|
|
8352
|
+
function loadSourceLines(path) {
|
|
8353
|
+
if (!path || !isFile3(path)) return [];
|
|
8354
|
+
return readFileSync8(path, "utf8").split("\n").map((line) => line.replace(/\r$/u, ""));
|
|
8355
|
+
}
|
|
8356
|
+
function loadSourceMap(outDir) {
|
|
8357
|
+
if (!outDir) return null;
|
|
8358
|
+
const path = join2(outDir, "text_sources.json");
|
|
8359
|
+
if (!isFile3(path)) return null;
|
|
8360
|
+
try {
|
|
8361
|
+
const data = JSON.parse(readFileSync8(path, "utf8").replace(/^\uFEFF/u, ""));
|
|
8362
|
+
const files = Array.isArray(data.files) ? data.files : [];
|
|
8363
|
+
const lineMap = Array.isArray(data.lineMap) ? data.lineMap : [];
|
|
8364
|
+
if (!files.length || !lineMap.length) return null;
|
|
8365
|
+
return { files, lineMap };
|
|
8366
|
+
} catch {
|
|
8367
|
+
return null;
|
|
8368
|
+
}
|
|
8369
|
+
}
|
|
8370
|
+
function pickFileId2(sourceMap, fileIds, lineIndex, fallback) {
|
|
8371
|
+
if (!sourceMap || !fileIds || !fileIds.length) return fallback;
|
|
8372
|
+
const lineMap = sourceMap.lineMap ?? [];
|
|
8373
|
+
if (lineIndex >= 0 && lineIndex < lineMap.length) {
|
|
8374
|
+
const fileIndex = lineMap[lineIndex];
|
|
8375
|
+
if (fileIndex >= 0 && fileIndex < fileIds.length && fileIds[fileIndex]) return fileIds[fileIndex];
|
|
8376
|
+
}
|
|
8377
|
+
return fallback;
|
|
8378
|
+
}
|
|
8379
|
+
function rowSnippet(lines, index) {
|
|
8380
|
+
if (!isCell(lines[index])) return stripNumber(truthyText3(lines[index]).trim());
|
|
8381
|
+
let start = index;
|
|
8382
|
+
while (start > 0 && isCell(lines[start - 1])) start -= 1;
|
|
8383
|
+
if (start > 0 && truthyText3(lines[start - 1]).trim() && !isCell(lines[start - 1])) start -= 1;
|
|
8384
|
+
let end = index;
|
|
8385
|
+
while (end + 1 < lines.length && isCell(lines[end + 1])) end += 1;
|
|
8386
|
+
let cells = [];
|
|
8387
|
+
for (let i = start; i <= end; i += 1) cells.push(cellText(lines[i]));
|
|
8388
|
+
cells = cells.filter((cell) => cell);
|
|
8389
|
+
while (cells.length && /^[0-9]+$/u.test(cells[0])) cells.shift();
|
|
8390
|
+
return stripNumber(cells.join(""));
|
|
8391
|
+
}
|
|
8392
|
+
function fragments(needle, minLength = 4) {
|
|
8393
|
+
const parts = truthyText3(needle).split(/[,。;、,;::;||//\s()()#【】[\]]+/u);
|
|
8394
|
+
return parts.filter((part) => part.length >= minLength);
|
|
8395
|
+
}
|
|
8396
|
+
function numberVariants(value) {
|
|
8397
|
+
const text4 = truthyText3(value).trim();
|
|
8398
|
+
const match = /^[¥¥$]?\s*(\d{1,3}(?:,\d{3})+|\d+)(\.\d+)?$/u.exec(text4);
|
|
8399
|
+
if (!match) return [];
|
|
8400
|
+
const intPart = match[1];
|
|
8401
|
+
const dec = match[2] ?? "";
|
|
8402
|
+
const digits = intPart.split(",").join("").replace(/^0+(?=\d)/u, "");
|
|
8403
|
+
if (!digits) return [];
|
|
8404
|
+
const grouped = groupThousands(digits) + dec;
|
|
8405
|
+
const out = [];
|
|
8406
|
+
for (const candidate of [grouped, digits + dec]) {
|
|
8407
|
+
if (candidate && !out.includes(candidate)) out.push(candidate);
|
|
8408
|
+
}
|
|
8409
|
+
return out;
|
|
8410
|
+
}
|
|
8411
|
+
function groupThousands(digits) {
|
|
8412
|
+
let out = "";
|
|
8413
|
+
let count = 0;
|
|
8414
|
+
for (let i = digits.length - 1; i >= 0; i -= 1) {
|
|
8415
|
+
out = digits[i] + out;
|
|
8416
|
+
count += 1;
|
|
8417
|
+
if (count % 3 === 0 && i > 0) out = `,${out}`;
|
|
8418
|
+
}
|
|
8419
|
+
return out;
|
|
8420
|
+
}
|
|
8421
|
+
function buildNeedles(value) {
|
|
8422
|
+
if (isEmptyScalar(value)) return null;
|
|
8423
|
+
const values = Array.isArray(value) ? value : [value];
|
|
8424
|
+
const out = [];
|
|
8425
|
+
for (const item of values) {
|
|
8426
|
+
if (isEmptyScalar(item)) continue;
|
|
8427
|
+
const text4 = String(item);
|
|
8428
|
+
out.push(text4);
|
|
8429
|
+
const stripped = text4.replace(/[((][^))]*[))]/gu, "").trim();
|
|
8430
|
+
if (stripped && stripped !== text4) out.push(stripped);
|
|
8431
|
+
for (const candidate of numberVariants(text4)) {
|
|
8432
|
+
if (!out.includes(candidate)) out.push(candidate);
|
|
8433
|
+
}
|
|
8434
|
+
if (stripped && stripped !== text4) {
|
|
8435
|
+
for (const candidate of numberVariants(stripped)) {
|
|
8436
|
+
if (!out.includes(candidate)) out.push(candidate);
|
|
8437
|
+
}
|
|
8438
|
+
}
|
|
8439
|
+
}
|
|
8440
|
+
return out.length ? out : null;
|
|
8441
|
+
}
|
|
8442
|
+
function resolveOrigin(lines, needles, attachmentId, sourceMap, fileIds) {
|
|
8443
|
+
if (!lines || !lines.length || !pyTruthy2(needles)) return null;
|
|
8444
|
+
const needleList = Array.isArray(needles) ? needles : [needles];
|
|
8445
|
+
const candidates = [];
|
|
8446
|
+
for (const needle of needleList) {
|
|
8447
|
+
if (!pyTruthy2(needle)) continue;
|
|
8448
|
+
const normalized = norm(needle);
|
|
8449
|
+
if (!normalized) continue;
|
|
8450
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
8451
|
+
if (!truthyText3(lines[i]).trim()) continue;
|
|
8452
|
+
if (norm(lines[i]).includes(normalized)) {
|
|
8453
|
+
const snippet = rowSnippet(lines, i);
|
|
8454
|
+
if (snippet) candidates.push({ index: i, snippet });
|
|
8455
|
+
}
|
|
8456
|
+
}
|
|
8457
|
+
if (candidates.length) break;
|
|
8458
|
+
}
|
|
8459
|
+
if (!candidates.length) {
|
|
8460
|
+
for (const needle of needleList) {
|
|
8461
|
+
for (const fragment of fragments(needle)) {
|
|
8462
|
+
const normalized = norm(fragment);
|
|
8463
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
8464
|
+
if (!truthyText3(lines[i]).trim()) continue;
|
|
8465
|
+
if (normalized && norm(lines[i]).includes(normalized)) {
|
|
8466
|
+
const snippet = rowSnippet(lines, i);
|
|
8467
|
+
if (snippet) candidates.push({ index: i, snippet });
|
|
8468
|
+
}
|
|
8469
|
+
}
|
|
8470
|
+
if (candidates.length) break;
|
|
8471
|
+
}
|
|
8472
|
+
if (candidates.length) break;
|
|
8473
|
+
}
|
|
8474
|
+
}
|
|
8475
|
+
if (!candidates.length) return null;
|
|
8476
|
+
let best = candidates[0];
|
|
8477
|
+
for (const candidate of candidates) {
|
|
8478
|
+
if (candidate.snippet.length < best.snippet.length) best = candidate;
|
|
8479
|
+
}
|
|
8480
|
+
return [`${pickFileId2(sourceMap, fileIds, best.index, attachmentId)}#${best.snippet}`];
|
|
8481
|
+
}
|
|
8482
|
+
function mapCompany(value) {
|
|
8483
|
+
const normalized = norm(value);
|
|
8484
|
+
if (!normalized) return "";
|
|
8485
|
+
for (const [name, keys] of COMPANY_OPTIONS) {
|
|
8486
|
+
for (const key of keys) {
|
|
8487
|
+
if (normalized.includes(norm(key))) return name;
|
|
8488
|
+
}
|
|
8489
|
+
}
|
|
8490
|
+
return "";
|
|
8491
|
+
}
|
|
8492
|
+
function pickOption(table, value) {
|
|
8493
|
+
if (!pyTruthy2(value)) return null;
|
|
8494
|
+
const normalized = norm(value);
|
|
8495
|
+
for (const [name, optionId] of Object.entries(table)) {
|
|
8496
|
+
const candidate = norm(name);
|
|
8497
|
+
if (normalized === candidate || candidate.includes(normalized) || normalized.includes(candidate)) {
|
|
8498
|
+
return optionId;
|
|
8499
|
+
}
|
|
8500
|
+
}
|
|
8501
|
+
return null;
|
|
8502
|
+
}
|
|
8503
|
+
function fileStem(triage) {
|
|
8504
|
+
if (!triage) return "";
|
|
8505
|
+
const candidates = [];
|
|
8506
|
+
const meta = triage.file;
|
|
8507
|
+
if (meta && typeof meta === "object" && !Array.isArray(meta)) {
|
|
8508
|
+
candidates.push(truthyText3(meta.name));
|
|
8509
|
+
candidates.push(truthyText3(meta.path));
|
|
8510
|
+
}
|
|
8511
|
+
for (const item of Array.isArray(triage.sourceFiles) ? triage.sourceFiles : []) {
|
|
8512
|
+
if (item && typeof item === "object" && !Array.isArray(item)) {
|
|
8513
|
+
candidates.push(truthyText3(item.name));
|
|
8514
|
+
}
|
|
8515
|
+
}
|
|
8516
|
+
for (const candidate of candidates) {
|
|
8517
|
+
if (!candidate) continue;
|
|
8518
|
+
const stem = basename5(candidate).slice(0, basename5(candidate).length - extname(basename5(candidate)).length).trim();
|
|
8519
|
+
if (stem) return stem;
|
|
8520
|
+
}
|
|
8521
|
+
return "";
|
|
8522
|
+
}
|
|
8523
|
+
function amountOf(value) {
|
|
8524
|
+
if (isEmptyScalar(value)) return "";
|
|
8525
|
+
const match = /(\d[\d,,]*(?:\.\d+)?)/u.exec(String(value));
|
|
8526
|
+
if (!match) return "";
|
|
8527
|
+
return match[1].split(",").join("").split("\uFF0C").join("");
|
|
8528
|
+
}
|
|
8529
|
+
function makePayload(spec, flow, fileId, results, subtables = []) {
|
|
8530
|
+
return {
|
|
8531
|
+
flow,
|
|
8532
|
+
workflowId: spec.workflowId,
|
|
8533
|
+
attachmentIds: fileId,
|
|
8534
|
+
attachmentFieldId: spec.attachmentFieldId,
|
|
8535
|
+
attachmentFileId: fileId,
|
|
8536
|
+
recognizeResult: {
|
|
8537
|
+
isSuccess: true,
|
|
8538
|
+
mainTable: { rows: [{ mainDataId: 1, fieldResults: results }] },
|
|
8539
|
+
subTables: subtables
|
|
8540
|
+
}
|
|
8541
|
+
};
|
|
8542
|
+
}
|
|
8543
|
+
function buildNewCustomer({ triage, fileId, flow, lines, sourceMap, fileIds }) {
|
|
8544
|
+
const spec = NEW_CUSTOMER;
|
|
8545
|
+
const fields = spec.fields;
|
|
8546
|
+
const elements = triage.elements && typeof triage.elements === "object" ? triage.elements : {};
|
|
8547
|
+
const results = [];
|
|
8548
|
+
const ro = (needles) => resolveOrigin(lines, needles, fileId, sourceMap, fileIds);
|
|
8549
|
+
const add = (key, value, reason, origin) => {
|
|
8550
|
+
if (isEmptyScalar(value)) return;
|
|
8551
|
+
results.push({ fieldInfo: fields[key], reason, value: String(value), origin: ro(origin) });
|
|
8552
|
+
};
|
|
8553
|
+
const partnerName = orElse(elements.partyC, elements.partyA);
|
|
8554
|
+
const finalUserOf = orElse(elements.finalUser, elements.partyA);
|
|
8555
|
+
const isPartnerSign = pyTruthy2(elements.partyC) || pyTruthy2(elements.finalUser) && pyTruthy2(elements.partyA) && norm(elements.finalUser) !== norm(elements.partyA);
|
|
8556
|
+
if (isPartnerSign) {
|
|
8557
|
+
add("buyMode", spec.options?.buyMode["\u901A\u8FC7\u4F19\u4F34\u7B7E\u7F72"], "\u7B7E\u7EA6\u76F8\u5BF9\u65B9\u4E0E\u6700\u7EC8\u7528\u6237\u4E0D\u662F\u540C\u4E00\u4E3B\u4F53\uFF0C\u5C5E\u901A\u8FC7\u4F19\u4F34\u7B7E\u7F72", buildNeedles(partnerName));
|
|
8558
|
+
} else {
|
|
8559
|
+
add("buyMode", spec.options?.buyMode["\u76F4\u7B7E"], "\u6CDB\u5FAE\u4E0E\u5B9E\u9645\u4F7F\u7528\u65B9\u76F4\u63A5\u7B7E\u7F72", buildNeedles(elements.partyA));
|
|
8560
|
+
}
|
|
8561
|
+
if (pyTruthy2(elements.title)) {
|
|
8562
|
+
add("title", elements.title, "\u53D6\u5408\u540C\u6807\u9898", buildNeedles(elements.title));
|
|
8563
|
+
} else {
|
|
8564
|
+
add("title", fileStem(triage), "\u53D6\u5408\u540C\u6587\u4EF6\u540D\uFF08\u53BB\u540E\u7F00\uFF09", null);
|
|
8565
|
+
}
|
|
8566
|
+
const finalUser = finalUserOf;
|
|
8567
|
+
add("finalUser", finalUser, "\u53D6\u5408\u540C\u6700\u7EC8\u7528\u6237\u5168\u79F0", buildNeedles(finalUser));
|
|
8568
|
+
if (isPartnerSign) {
|
|
8569
|
+
add("partner", partnerName, "\u53D6\u7B7E\u7EA6\u4F19\u4F34\uFF08\u7B7E\u7EA6\u76F8\u5BF9\u65B9\uFF09\u5168\u79F0", buildNeedles(partnerName));
|
|
8570
|
+
}
|
|
8571
|
+
add("totalAmount", elements.totalAmount, "\u53D6\u5408\u540C\u603B\u989D", buildNeedles(amountOf(elements.totalAmount)));
|
|
8572
|
+
add("background", elements.background, "\u7531\u7B7E\u7EA6\u4E3B\u4F53\u3001\u6700\u7EC8\u7528\u6237\u4E0E\u91C7\u8D2D\u6807\u7684\u5F52\u7EB3", buildNeedles(elements.background));
|
|
8573
|
+
const optionId = pickOption(spec.options?.ourCompany ?? {}, elements.partyB);
|
|
8574
|
+
if (optionId) {
|
|
8575
|
+
add("ourCompany", optionId, "\u4E59\u65B9\u7B7E\u7EA6\u4E3B\u4F53\u6620\u5C04", `\u4E59\u65B9\uFF1A${truthyText3(elements.partyB)}`);
|
|
8576
|
+
}
|
|
8577
|
+
add("address", elements.address, "\u53D6\u5408\u540C\u7EA6\u5B9A\u8054\u7CFB/\u9001\u8FBE\u5730\u5740", orElse(elements.address, "\u5730\u5740"));
|
|
8578
|
+
add("receiver", elements.contact, "\u53D6\u5408\u540C\u8054\u7CFB\u4EBA", orElse(elements.contact, "\u8054\u7CFB\u4EBA"));
|
|
8579
|
+
add("mobile", elements.phone, "\u53D6\u5408\u540C\u8054\u7CFB\u7535\u8BDD", orElse(elements.phone, "\u7535\u8BDD"));
|
|
8580
|
+
let signForm = spec.defaults?.signForm ?? "2";
|
|
8581
|
+
const rawSign = norm(orElse(elements.rawSign, ""));
|
|
8582
|
+
if (rawSign.includes("\u7535\u5B50\u7B7E") && rawSign.includes("\u5951\u7EA6\u9501")) signForm = "4";
|
|
8583
|
+
add("signForm", signForm, "\u5408\u540C\u672A\u7279\u522B\u7EA6\u5B9A\uFF0C\u6309\u7EB8\u8D28\u7B7E\u7F72\uFF08\u9ED8\u8BA4\u503C\uFF09", buildNeedles("\u76D6\u7AE0") ?? buildNeedles("\u7535\u5B50\u7B7E"));
|
|
8584
|
+
if (pyTruthy2(elements.signDate)) {
|
|
8585
|
+
add("signDate", spec.options?.signDate["\u6307\u5B9A\u7B7E\u7F72\u65E5\u671F"], "\u5408\u540C\u8F7D\u660E\u7B7E\u8BA2\u65E5\u671F\uFF0C\u6309\u6307\u5B9A\u7B7E\u7F72\u65E5\u671F", buildNeedles(elements.signDate));
|
|
8586
|
+
add("designatedDate", elements.signDate, "\u5408\u540C\u7B7E\u8BA2\u65F6\u95F4", buildNeedles(elements.signDate));
|
|
8587
|
+
} else {
|
|
8588
|
+
add("signDate", spec.defaults?.signDate ?? "2", "\u5408\u540C\u672A\u8F7D\u660E\u7B7E\u7F72\u65E5\u671F\uFF0C\u6309\u9ED8\u8BA4\u5408\u540C\u529E\u7406\u5F53\u5929", null);
|
|
8589
|
+
}
|
|
8590
|
+
add("signWay", spec.defaults?.signWay ?? "0", "\u672A\u7279\u522B\u7EA6\u5B9A\u7B7E\u7F72\u987A\u5E8F\uFF0C\u6309\u6211\u65B9\u5148\u76D6\u7AE0", null);
|
|
8591
|
+
const subtables = [];
|
|
8592
|
+
const solutions = Array.isArray(elements.solutions) ? elements.solutions : [];
|
|
8593
|
+
if (solutions.length && spec.subFormId) {
|
|
8594
|
+
const rows = [];
|
|
8595
|
+
solutions.forEach((item) => {
|
|
8596
|
+
const name = truthyText3(item?.name);
|
|
8597
|
+
if (!name) return;
|
|
8598
|
+
const amount = amountOf(item?.amount) || "0";
|
|
8599
|
+
const origin = ro(buildNeedles(name));
|
|
8600
|
+
rows.push({
|
|
8601
|
+
subDataId: rows.length + 1,
|
|
8602
|
+
mainDataId: 1,
|
|
8603
|
+
reasons: ["\u5408\u540C\u6807\u7684\u5217\u660E\u8BE5\u4E13\u9879", "\u6309\u6298\u6263\u540E\u5B9E\u9645\u91D1\u989D\u8BA1\uFF0C\u65E0\u4E13\u5C5E\u8BA1\u4EF7\u586B 0"],
|
|
8604
|
+
values: [name, amount],
|
|
8605
|
+
origins: [origin ?? null, origin ?? null]
|
|
8606
|
+
});
|
|
8607
|
+
});
|
|
8608
|
+
if (rows.length) {
|
|
8609
|
+
subtables.push({
|
|
8610
|
+
subFormId: spec.subFormId,
|
|
8611
|
+
subFormName: spec.subFormName,
|
|
8612
|
+
fields: [fields.solution, fields.solutionAmt],
|
|
8613
|
+
rows
|
|
8614
|
+
});
|
|
8615
|
+
}
|
|
8616
|
+
}
|
|
8617
|
+
return makePayload(spec, flow, fileId, results, subtables);
|
|
8618
|
+
}
|
|
8619
|
+
function buildGeneric({ triage, fileId, flow, lines, sourceMap, fileIds }) {
|
|
8620
|
+
const spec = BUILTIN[flow];
|
|
8621
|
+
const fields = spec.fields;
|
|
8622
|
+
const selects = spec.selects ?? {};
|
|
8623
|
+
const elements = triage.elements && typeof triage.elements === "object" ? triage.elements : {};
|
|
8624
|
+
const results = [];
|
|
8625
|
+
const ro = (needles) => resolveOrigin(lines, needles, fileId, sourceMap, fileIds);
|
|
8626
|
+
const add = (key, value, reason, origin) => {
|
|
8627
|
+
const fieldInfo = fields[key];
|
|
8628
|
+
if (!fieldInfo || isEmptyScalar(value)) return;
|
|
8629
|
+
results.push({ fieldInfo, reason, value: String(value), origin: ro(origin) });
|
|
8630
|
+
};
|
|
8631
|
+
const addSelect = (key, value, reason, origin) => {
|
|
8632
|
+
const fieldInfo = selects[key];
|
|
8633
|
+
if (!fieldInfo || isEmptyScalar(value)) return;
|
|
8634
|
+
results.push({ fieldInfo, reason, value: String(value), origin: ro(origin) });
|
|
8635
|
+
};
|
|
8636
|
+
const title = orElse(elements.title, elements.contractName);
|
|
8637
|
+
if (pyTruthy2(title)) {
|
|
8638
|
+
add("title", title, "\u53D6\u5408\u540C\u6807\u9898", buildNeedles(title));
|
|
8639
|
+
} else {
|
|
8640
|
+
add("title", fileStem(triage), "\u53D6\u5408\u540C\u6587\u4EF6\u540D\uFF08\u53BB\u540E\u7F00\uFF09", null);
|
|
8641
|
+
}
|
|
8642
|
+
const contractName = orElse(elements.contractName, elements.title);
|
|
8643
|
+
add("contractName", contractName, "\u53D6\u5408\u540C\u540D\u79F0", buildNeedles(contractName));
|
|
8644
|
+
const amount = amountOf(elements.totalAmount);
|
|
8645
|
+
add("totalAmount", amount, "\u53D6\u5408\u540C\u603B\u989D\u5E76\u5F52\u4E00\u4E3A\u6570\u5B57", buildNeedles(amount) ?? buildNeedles(elements.totalAmount));
|
|
8646
|
+
add("address", elements.address, "\u53D6\u5408\u540C\u7EA6\u5B9A\u8054\u7CFB/\u9001\u8FBE\u5730\u5740", buildNeedles(elements.address));
|
|
8647
|
+
add("receiver", elements.contact, "\u53D6\u5408\u540C\u8054\u7CFB\u4EBA", buildNeedles(elements.contact));
|
|
8648
|
+
add("mobile", elements.phone, "\u53D6\u5408\u540C\u8054\u7CFB\u7535\u8BDD", buildNeedles(elements.phone));
|
|
8649
|
+
add("background", elements.background, "\u53D6\u5408\u540C\u80CC\u666F\u8BF4\u660E", buildNeedles(elements.background));
|
|
8650
|
+
add("partySigner", elements.partySigner, "\u53D6\u5BF9\u65B9\u7B7E\u7F72\u4EBA", buildNeedles(elements.partySigner));
|
|
8651
|
+
add("partyContact", elements.partyContact, "\u53D6\u5BF9\u65B9\u7B7E\u7F72\u4EBA\u8054\u7CFB\u65B9\u5F0F", buildNeedles(elements.partyContact));
|
|
8652
|
+
addSelect(
|
|
8653
|
+
"buyMode",
|
|
8654
|
+
orElse(elements.buyMode, pyTruthy2(elements.partyC) ? "\u901A\u8FC7\u4F19\u4F34\u7B7E\u7F72" : "\u76F4\u7B7E"),
|
|
8655
|
+
"\u6309\u5408\u540C\u7B7E\u7EA6\u7ED3\u6784\u5224\u5B9A\u8D2D\u4E70\u65B9\u5F0F",
|
|
8656
|
+
buildNeedles(elements.partyC)
|
|
8657
|
+
);
|
|
8658
|
+
const company = mapCompany(orElse(elements.ourCompany, elements.partyB));
|
|
8659
|
+
addSelect("ourCompany", company, `\u4E59\u65B9\u7B7E\u7EA6\u4E3B\u4F53\u6620\u5C04\u4E3A\u4E0B\u62C9\u9009\u9879\uFF1A${company || "\u672A\u5339\u914D"}`, buildNeedles(elements.partyB));
|
|
8660
|
+
addSelect("finalUser", orElse(elements.finalUser, elements.partyA), "\u53D6\u5408\u540C\u7532\u65B9\uFF08\u6700\u7EC8\u7528\u6237\uFF09\u4F01\u4E1A\u5168\u79F0", buildNeedles(elements.partyA));
|
|
8661
|
+
addSelect("partner", orElse(elements.partner, elements.partyC), "\u53D6\u5408\u540C\u4E19\u65B9\uFF08\u4F19\u4F34\uFF09\u4F01\u4E1A\u5168\u79F0", buildNeedles(elements.partyC));
|
|
8662
|
+
let signForm = elements.signForm;
|
|
8663
|
+
if (!pyTruthy2(signForm)) {
|
|
8664
|
+
const raw = norm(orElse(elements.rawSign, ""));
|
|
8665
|
+
if (raw.includes("\u5951\u7EA6\u9501") && raw.includes("\u7535\u5B50\u7B7E")) signForm = "\u53CC\u65B9\u7535\u5B50\u7B7E\u7F72\uFF08\u6CDB\u5FAE\u5951\u7EA6\u9501\u5E73\u53F0\u53CC\u65B9\u7535\u5B50\u7B7E\uFF09";
|
|
8666
|
+
else if (raw.includes("\u7535\u5B50\u7B7E")) signForm = "\u53CC\u65B9\u7535\u5B50\u7B7E\u7F72";
|
|
8667
|
+
else signForm = "\u7EB8\u8D28\u7B7E\u7F72";
|
|
8668
|
+
}
|
|
8669
|
+
addSelect("signForm", signForm, "\u6309\u5408\u540C\u7B7E\u7F72\u7AE0\u8282\u5224\u5B9A\u7B7E\u7EA6\u5F62\u5F0F", ["\u672C\u5408\u540C\u7ECF\u7532\u4E59\u53CC\u65B9\u76D6\u7AE0\u540E\u751F\u6548", "\u76D6\u7AE0"]);
|
|
8670
|
+
const signDateNeedles = [...buildNeedles(elements.signDate) ?? [], "\u7B7E\u8BA2\u65F6\u95F4"];
|
|
8671
|
+
addSelect(
|
|
8672
|
+
"signDateType",
|
|
8673
|
+
orElse(elements.signDateType, pyTruthy2(elements.signDate) ? "\u6307\u5B9A\u7B7E\u7F72\u65E5\u671F" : "\u9ED8\u8BA4\u5408\u540C\u529E\u7406\u5F53\u5929"),
|
|
8674
|
+
"\u5408\u540C\u8F7D\u660E\u7B7E\u8BA2\u65E5\u671F\u5219\u6307\u5B9A\uFF0C\u5426\u5219\u9ED8\u8BA4\u5408\u540C\u529E\u7406\u5F53\u5929",
|
|
8675
|
+
signDateNeedles
|
|
8676
|
+
);
|
|
8677
|
+
addSelect("signWay", orElse(elements.signWay, "\u6211\u65B9\u5148\u76D6\u7AE0"), "\u5408\u540C\u672A\u7279\u522B\u7EA6\u5B9A\u7B7E\u7F72\u987A\u5E8F\uFF0C\u6309\u6211\u65B9\u5148\u76D6\u7AE0", null);
|
|
8678
|
+
addSelect("contractType", elements.contractType, "\u6309\u5408\u540C\u6807\u7684\u4EA7\u54C1\u7EBF\u5224\u5B9A\u5408\u540C\u7C7B\u578B", buildNeedles(elements.contractType));
|
|
8679
|
+
addSelect("implParty", elements.implParty, "\u6309\u5408\u540C\u5B9E\u65BD\u4E3B\u4F53\u5224\u5B9A\u5B9E\u65BD\u65B9", buildNeedles(elements.implParty));
|
|
8680
|
+
addSelect("relatedProduct", elements.relatedProduct, "\u6309\u5408\u540C\u6807\u7684\u5224\u5B9A\u76F8\u5173\u4EA7\u54C1", buildNeedles(elements.relatedProduct));
|
|
8681
|
+
addSelect("isXinChuang", elements.isXinChuang, "\u5408\u540C\u672A\u6D89\u53CA\u4FE1\u521B\u5185\u5BB9\u5219\u4E0D\u586B", buildNeedles(elements.isXinChuang));
|
|
8682
|
+
const checkbox = spec.checkbox;
|
|
8683
|
+
if (checkbox) {
|
|
8684
|
+
const hints = flow === "\u5E38\u89C4\u4E8C\u6B21\u9500\u552E" ? CHECKBOX_HINTS_RESALE : CHECKBOX_HINTS_UPSALE;
|
|
8685
|
+
const items = Array.isArray(elements.items) ? elements.items : [];
|
|
8686
|
+
const itemNames = items.map((item) => truthyText3(item?.name));
|
|
8687
|
+
const blobParts = [
|
|
8688
|
+
elements.title,
|
|
8689
|
+
elements.contractName,
|
|
8690
|
+
elements.background,
|
|
8691
|
+
elements.serviceScope,
|
|
8692
|
+
itemNames.join(" ")
|
|
8693
|
+
].filter((part) => pyTruthy2(part)).map((part) => String(part));
|
|
8694
|
+
const blob = blobParts.join(" ");
|
|
8695
|
+
const picked = [];
|
|
8696
|
+
const hit = [];
|
|
8697
|
+
for (const [name, keywords] of hints) {
|
|
8698
|
+
if (keywords.some((keyword) => blob.includes(keyword))) {
|
|
8699
|
+
picked.push(checkbox.options[name]);
|
|
8700
|
+
hit.push(name);
|
|
8701
|
+
}
|
|
8702
|
+
}
|
|
8703
|
+
if (picked.length) {
|
|
8704
|
+
add(
|
|
8705
|
+
checkbox.fieldKey,
|
|
8706
|
+
picked.join(","),
|
|
8707
|
+
`\u6309\u5408\u540C\u6807\u7684\u5173\u952E\u8BCD\u547D\u4E2D\uFF1A${hit.join("\u3001")}`,
|
|
8708
|
+
buildNeedles(itemNames) ?? buildNeedles(hit)
|
|
8709
|
+
);
|
|
8710
|
+
}
|
|
8711
|
+
}
|
|
8712
|
+
return makePayload(spec, flow, fileId, results);
|
|
8713
|
+
}
|
|
8714
|
+
function buildMinimal(fileId, flow, workflowId, attachmentFieldId) {
|
|
8715
|
+
return {
|
|
8716
|
+
flow,
|
|
8717
|
+
workflowId,
|
|
8718
|
+
attachmentIds: fileId,
|
|
8719
|
+
attachmentFieldId,
|
|
8720
|
+
attachmentFileId: fileId,
|
|
8721
|
+
recognizeResult: {
|
|
8722
|
+
isSuccess: true,
|
|
8723
|
+
mainTable: { rows: [{ mainDataId: 1, fieldResults: [] }] },
|
|
8724
|
+
subTables: []
|
|
8725
|
+
}
|
|
8726
|
+
};
|
|
8727
|
+
}
|
|
8728
|
+
function checkOrigins(payload, attachmentId) {
|
|
8729
|
+
const warns = [];
|
|
8730
|
+
const rows = payload.recognizeResult.mainTable.rows ?? [];
|
|
8731
|
+
for (const row of rows) {
|
|
8732
|
+
for (const result of row.fieldResults ?? []) {
|
|
8733
|
+
const fieldInfo = result.fieldInfo || "";
|
|
8734
|
+
const origins = result.origin;
|
|
8735
|
+
if (origins === null || origins === void 0) continue;
|
|
8736
|
+
if (!Array.isArray(origins) || !origins.length) {
|
|
8737
|
+
warns.push(`${fieldInfo}: origin \u5FC5\u987B\u662F\u975E\u7A7A\u6570\u7EC4\u6216 null`);
|
|
8738
|
+
continue;
|
|
8739
|
+
}
|
|
8740
|
+
for (const origin of origins) {
|
|
8741
|
+
if (origin === null || origin === void 0) {
|
|
8742
|
+
warns.push(`${fieldInfo}: \u7981\u6B62\u8F93\u51FA [null]`);
|
|
8743
|
+
continue;
|
|
8744
|
+
}
|
|
8745
|
+
const text4 = String(origin);
|
|
8746
|
+
const sepIndex = text4.indexOf("#");
|
|
8747
|
+
const sideId = sepIndex >= 0 ? text4.slice(0, sepIndex) : text4;
|
|
8748
|
+
const snippet = sepIndex >= 0 ? text4.slice(sepIndex + 1) : "";
|
|
8749
|
+
if (sideId === "att001") {
|
|
8750
|
+
warns.push(`${fieldInfo}: \u524D\u7F00\u5199\u6B7B att001\uFF0C\u5E94\u4E3A\u5B9E\u9645\u9644\u4EF6 ID`);
|
|
8751
|
+
} else if (attachmentId && sideId !== String(attachmentId)) {
|
|
8752
|
+
warns.push(`${fieldInfo}: \u524D\u7F00\u5E94\u4E3A\u5B9E\u9645\u9644\u4EF6 ID`);
|
|
8753
|
+
}
|
|
8754
|
+
if (!snippet.trim()) warns.push(`${fieldInfo}: \u539F\u6587\u7247\u6BB5\u4E3A\u7A7A`);
|
|
8755
|
+
if (snippet.includes("...") || snippet.includes("\u2026")) warns.push(`${fieldInfo}: \u539F\u6587\u7247\u6BB5\u88AB\u622A\u65AD`);
|
|
8756
|
+
if (NUM_PREFIX.test(snippet)) warns.push(`${fieldInfo}: \u539F\u6587\u7247\u6BB5\u4EE5\u5E8F\u53F7\u5F00\u5934`);
|
|
8757
|
+
}
|
|
8758
|
+
}
|
|
8759
|
+
}
|
|
8760
|
+
return warns;
|
|
8761
|
+
}
|
|
8762
|
+
function buildPayload(args) {
|
|
8763
|
+
const { flow } = args;
|
|
8764
|
+
if (!Object.prototype.hasOwnProperty.call(BUILTIN, flow)) {
|
|
8765
|
+
throw contractValidationError("flow_not_builtin", `\u6D41\u7A0B\u300C${flow}\u300D\u65E0\u5185\u7F6E\u5B57\u6BB5\u8868\uFF1A${Object.keys(BUILTIN).join(" / ")}`);
|
|
8766
|
+
}
|
|
8767
|
+
const payload = flow === "\u65B0\u5BA2\u6237" ? buildNewCustomer(args) : buildGeneric(args);
|
|
8768
|
+
const warns = checkOrigins(payload, args.fileId);
|
|
8769
|
+
return { payload, warns };
|
|
8770
|
+
}
|
|
8771
|
+
function isFile3(path) {
|
|
8772
|
+
try {
|
|
8773
|
+
return existsSync4(path) && statSync3(path).isFile();
|
|
8774
|
+
} catch {
|
|
8775
|
+
return false;
|
|
8776
|
+
}
|
|
8777
|
+
}
|
|
8778
|
+
var contractElementsBuildOperation = {
|
|
8779
|
+
name: "contract.elements.build",
|
|
8780
|
+
async execute(input) {
|
|
8781
|
+
const triagePath = resolve12(String(input.triage ?? "").trim());
|
|
8782
|
+
if (!isFile3(triagePath)) {
|
|
8783
|
+
throw contractValidationError("triage_not_found", `triage.json \u4E0D\u5B58\u5728\uFF1A${triagePath}`);
|
|
8784
|
+
}
|
|
8785
|
+
let triage;
|
|
8786
|
+
try {
|
|
8787
|
+
const parsed = JSON.parse(readFileSync8(triagePath, "utf8").replace(/^\uFEFF/u, ""));
|
|
8788
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error("\u6839\u8282\u70B9\u5FC5\u987B\u662F\u5BF9\u8C61");
|
|
8789
|
+
triage = parsed;
|
|
8790
|
+
} catch (error) {
|
|
8791
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
8792
|
+
throw contractValidationError("triage_invalid", `triage.json \u65E0\u6CD5\u89E3\u6790\uFF1A${message}`);
|
|
8793
|
+
}
|
|
8794
|
+
const fileId = String(input.fileId ?? "").trim();
|
|
8795
|
+
if (!fileId) throw contractValidationError("file_id_required", "\u7F3A\u5C11 fileId\uFF08flow.launch \u8FD4\u56DE\u7684 workflow fileId\uFF09");
|
|
8796
|
+
const flow = String(input.flow ?? "").trim();
|
|
8797
|
+
if (!flow) throw contractValidationError("flow_required", "\u7F3A\u5C11 flow\uFF08\u65B0\u5BA2\u6237 / \u5951\u7EA6\u9501 / \u5E38\u89C4\u4E8C\u6B21\u9500\u552E / \u8001\u5BA2\u6237\u589E\u503C\uFF09");
|
|
8798
|
+
const sourceText = String(input.sourceText ?? "").trim() ? resolve12(String(input.sourceText).trim()) : join2(dirname7(triagePath), "contract_text.txt");
|
|
8799
|
+
const lines = loadSourceLines(sourceText);
|
|
8800
|
+
const outDir = dirname7(triagePath);
|
|
8801
|
+
let sourceMap = loadSourceMap(outDir);
|
|
8802
|
+
let fileIds = Array.isArray(input.fileIds) && input.fileIds.length ? input.fileIds.map((item) => String(item)) : null;
|
|
8803
|
+
if (sourceMap && fileIds && fileIds.length !== (sourceMap.files ?? []).length) {
|
|
8804
|
+
sourceMap = null;
|
|
8805
|
+
fileIds = null;
|
|
8806
|
+
}
|
|
8807
|
+
const attachmentFieldId = String(input.attachmentFieldId ?? "").trim();
|
|
8808
|
+
const workflowId = String(input.workflowId ?? "").trim();
|
|
8809
|
+
let payload;
|
|
8810
|
+
let warns = [];
|
|
8811
|
+
let mode;
|
|
8812
|
+
if (Object.prototype.hasOwnProperty.call(BUILTIN, flow)) {
|
|
8813
|
+
const built = buildPayload({ triage, fileId, flow, lines, sourceMap, fileIds });
|
|
8814
|
+
payload = built.payload;
|
|
8815
|
+
warns = built.warns;
|
|
8816
|
+
mode = "builtin";
|
|
8817
|
+
} else if (attachmentFieldId) {
|
|
8818
|
+
payload = buildMinimal(fileId, flow, workflowId, attachmentFieldId);
|
|
8819
|
+
mode = "minimal";
|
|
8820
|
+
} else {
|
|
8821
|
+
throw contractValidationError(
|
|
8822
|
+
"no_builtin_table",
|
|
8823
|
+
`\u6D41\u7A0B\u300C${flow}\u300D\u6682\u65E0\u5185\u7F6E\u5B57\u6BB5\u8868\uFF1B\u8BF7\u6539\u7528 recognizeFile \u63D0\u4F9B recognizeResult\uFF0C\u6216\u8865 attachmentFieldId \u8D70\u9644\u4EF6\u515C\u5E95`
|
|
8824
|
+
);
|
|
8825
|
+
}
|
|
8826
|
+
let output;
|
|
8827
|
+
const outPath = String(input.out ?? "").trim();
|
|
8828
|
+
if (outPath) {
|
|
8829
|
+
output = resolve12(outPath);
|
|
8830
|
+
mkdirSync4(dirname7(output), { recursive: true });
|
|
8831
|
+
writeFileSync7(output, JSON.stringify(payload), "utf8");
|
|
8832
|
+
}
|
|
8833
|
+
return {
|
|
8834
|
+
status: "COMPLETE",
|
|
8835
|
+
data: {
|
|
8836
|
+
ok: true,
|
|
8837
|
+
flow,
|
|
8838
|
+
mode,
|
|
8839
|
+
fieldCount: payload.recognizeResult.mainTable.rows[0].fieldResults.length,
|
|
8840
|
+
attachmentFieldId: payload.attachmentFieldId,
|
|
8841
|
+
sourceLines: lines.length,
|
|
8842
|
+
originWarnings: warns,
|
|
8843
|
+
payload,
|
|
8844
|
+
...output ? { output } : {},
|
|
8845
|
+
note: mode === "minimal" ? "\u65E0\u5185\u7F6E\u5B57\u6BB5\u8868\uFF1AfieldResults \u4E3A\u7A7A\uFF0C\u8C03\u7528\u65B9\u5E94\u8DF3\u8FC7 save-recognize-record\uFF0C\u9644\u4EF6\u7531 customParams \u900F\u4F20" : "\u9644\u4EF6\u5B57\u6BB5\u4E0D\u5199\u5165 recognizeResult\uFF1B\u9876\u5C42 attachmentIds/attachmentFieldId \u4EC5\u4F9B customParams \u4F7F\u7528"
|
|
8846
|
+
}
|
|
8847
|
+
};
|
|
8848
|
+
}
|
|
8849
|
+
};
|
|
8850
|
+
var contractElementsBuildOperations = [contractElementsBuildOperation];
|
|
8851
|
+
|
|
6292
8852
|
// src/shortcuts/contract/operations/file-download.ts
|
|
6293
8853
|
var SUPPORTED_MODULES = ["ebContract", "workflow", "docCompared", "ebuilderform"];
|
|
6294
8854
|
var DEFAULT_MODULE = "ebContract";
|
|
@@ -6356,10 +8916,506 @@ var contractFileDownloadOperations = [
|
|
|
6356
8916
|
contentType: result.contentType,
|
|
6357
8917
|
note: "\u6587\u4EF6\u5DF2\u4E0B\u8F7D\u5230\u672C\u5730\uFF1B\u4E8C\u8FDB\u5236\u5185\u5BB9\u4E0D\u8FDB\u5165\u5927\u6A21\u578B\u4E0A\u4E0B\u6587\uFF0C\u53EA\u56DE\u4F20\u8DEF\u5F84\u4E0E\u5143\u6570\u636E"
|
|
6358
8918
|
}
|
|
6359
|
-
};
|
|
8919
|
+
};
|
|
8920
|
+
}
|
|
8921
|
+
}
|
|
8922
|
+
];
|
|
8923
|
+
|
|
8924
|
+
// src/shortcuts/contract/operations/first-screen.ts
|
|
8925
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync5, readFileSync as readFileSync9, statSync as statSync4, writeFileSync as writeFileSync8 } from "node:fs";
|
|
8926
|
+
import { basename as basename6, join as join3, resolve as resolve13 } from "node:path";
|
|
8927
|
+
|
|
8928
|
+
// src/shortcuts/contract/operations/op-resolver.ts
|
|
8929
|
+
var resolver = null;
|
|
8930
|
+
function setOperationResolver(fn) {
|
|
8931
|
+
resolver = fn;
|
|
8932
|
+
}
|
|
8933
|
+
function resolveOperation(name) {
|
|
8934
|
+
if (!resolver) {
|
|
8935
|
+
throw new Error(`contract operation resolver \u5C1A\u672A\u6CE8\u5165\uFF1A${name}`);
|
|
8936
|
+
}
|
|
8937
|
+
return resolver(name);
|
|
8938
|
+
}
|
|
8939
|
+
|
|
8940
|
+
// src/shortcuts/contract/operations/first-screen.ts
|
|
8941
|
+
var DEFAULT_BASE3 = "https://www.e-cology.com.cn";
|
|
8942
|
+
var ATTACHMENT_FIELD_SUFFIX = "#\u5408\u540C\u6B63\u6587\u53CA\u9644\u4EF6";
|
|
8943
|
+
function pyTruthy3(value) {
|
|
8944
|
+
if (value === null || value === void 0 || value === false) return false;
|
|
8945
|
+
if (value === true) return true;
|
|
8946
|
+
if (typeof value === "number") return value !== 0 && !Number.isNaN(value);
|
|
8947
|
+
if (typeof value === "string") return value.length > 0;
|
|
8948
|
+
if (Array.isArray(value)) return value.length > 0;
|
|
8949
|
+
if (typeof value === "object") return Object.keys(value).length > 0;
|
|
8950
|
+
return true;
|
|
8951
|
+
}
|
|
8952
|
+
function truthyText4(value) {
|
|
8953
|
+
return pyTruthy3(value) ? String(value) : "";
|
|
8954
|
+
}
|
|
8955
|
+
function isFile4(path) {
|
|
8956
|
+
try {
|
|
8957
|
+
return existsSync5(path) && statSync4(path).isFile();
|
|
8958
|
+
} catch {
|
|
8959
|
+
return false;
|
|
8960
|
+
}
|
|
8961
|
+
}
|
|
8962
|
+
function readJson2(path) {
|
|
8963
|
+
const parsed = JSON.parse(readFileSync9(path, "utf8").replace(/^\uFEFF/u, ""));
|
|
8964
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
8965
|
+
throw new Error("JSON \u6839\u8282\u70B9\u5FC5\u987B\u662F\u5BF9\u8C61");
|
|
8966
|
+
}
|
|
8967
|
+
return parsed;
|
|
8968
|
+
}
|
|
8969
|
+
async function callOperation(name, input, context) {
|
|
8970
|
+
const operation = resolveOperation(name);
|
|
8971
|
+
const result = await operation.execute(input, context);
|
|
8972
|
+
return result?.data ?? {};
|
|
8973
|
+
}
|
|
8974
|
+
var contractFirstScreenOperation = {
|
|
8975
|
+
name: "contract.firstscreen.run",
|
|
8976
|
+
async execute(input, context) {
|
|
8977
|
+
const filePath = resolve13(truthyText4(input.file));
|
|
8978
|
+
if (!filePath || !isFile4(filePath)) {
|
|
8979
|
+
throw contractValidationError("file_not_found", `\u5408\u540C\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${truthyText4(input.file)}`);
|
|
8980
|
+
}
|
|
8981
|
+
const outDirInput = truthyText4(input.outDir);
|
|
8982
|
+
if (!outDirInput) {
|
|
8983
|
+
throw contractValidationError("out_dir_required", "\u7F3A\u5C11 outDir\uFF08\u4EA7\u7269\u76EE\u5F55\uFF09");
|
|
8984
|
+
}
|
|
8985
|
+
const outDir = resolve13(outDirInput);
|
|
8986
|
+
mkdirSync5(outDir, { recursive: true });
|
|
8987
|
+
const attachInput = Array.isArray(input.attach) ? input.attach : [];
|
|
8988
|
+
const attach = attachInput.map((item) => resolve13(String(item))).filter((item) => item);
|
|
8989
|
+
for (const one of attach) {
|
|
8990
|
+
if (!isFile4(one)) {
|
|
8991
|
+
throw contractValidationError("attach_not_found", `\u968F\u9644\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${one}`);
|
|
8992
|
+
}
|
|
8993
|
+
}
|
|
8994
|
+
const steps = [];
|
|
8995
|
+
const warnings = [];
|
|
8996
|
+
const step = (name, ok, note = "") => steps.push({ step: name, ok, note });
|
|
8997
|
+
let summaryData = truthyText4(input.summaryData) ? resolve13(truthyText4(input.summaryData)) : "";
|
|
8998
|
+
const aiFillPath = truthyText4(input.aiFill) ? resolve13(truthyText4(input.aiFill)) : "";
|
|
8999
|
+
if (aiFillPath) {
|
|
9000
|
+
if (isFile4(aiFillPath)) {
|
|
9001
|
+
try {
|
|
9002
|
+
const fill = readJson2(aiFillPath);
|
|
9003
|
+
const elements = fill.elements;
|
|
9004
|
+
const summary = fill.summary;
|
|
9005
|
+
if (elements && typeof elements === "object" && !Array.isArray(elements)) {
|
|
9006
|
+
writeFileSync8(join3(outDir, "elements.json"), JSON.stringify(elements, null, 2), "utf8");
|
|
9007
|
+
}
|
|
9008
|
+
if (summary && typeof summary === "object" && !Array.isArray(summary) && !summaryData) {
|
|
9009
|
+
const target = join3(outDir, "summary_data.json");
|
|
9010
|
+
writeFileSync8(target, JSON.stringify(summary, null, 2), "utf8");
|
|
9011
|
+
summaryData = target;
|
|
9012
|
+
}
|
|
9013
|
+
} catch (error) {
|
|
9014
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
9015
|
+
warnings.push(`ai_fill.json \u8BFB\u53D6\u5931\u8D25\uFF1A${message.slice(0, 120)}`);
|
|
9016
|
+
}
|
|
9017
|
+
} else {
|
|
9018
|
+
warnings.push(`ai_fill.json \u4E0D\u5B58\u5728\uFF1A${aiFillPath}`);
|
|
9019
|
+
}
|
|
9020
|
+
}
|
|
9021
|
+
const triagePath = truthyText4(input.triage) ? resolve13(truthyText4(input.triage)) : join3(outDir, "triage.json");
|
|
9022
|
+
let triageData = {};
|
|
9023
|
+
let triageErr = "";
|
|
9024
|
+
if (isFile4(triagePath)) {
|
|
9025
|
+
try {
|
|
9026
|
+
triageData = readJson2(triagePath);
|
|
9027
|
+
} catch (error) {
|
|
9028
|
+
triageErr = (error instanceof Error ? error.message : String(error)).slice(0, 120);
|
|
9029
|
+
}
|
|
9030
|
+
}
|
|
9031
|
+
let flow = (truthyText4(input.flow) || truthyText4(triageData.flowKey)).trim();
|
|
9032
|
+
if (!flow) {
|
|
9033
|
+
throw contractValidationError(
|
|
9034
|
+
"flow_unknown",
|
|
9035
|
+
"\u672A\u6307\u5B9A flow \u4E14 triage.json \u65E0 flowKey\uFF0C\u8BF7\u5148\u8DD1\u9636\u6BB51\u786E\u8BA4\u5408\u540C\u7C7B\u578B"
|
|
9036
|
+
);
|
|
9037
|
+
}
|
|
9038
|
+
let company = (truthyText4(input.companyName) || truthyText4(triageData.counterparty)).trim();
|
|
9039
|
+
let hasCounterparty = input.counterparty === true || Boolean(company);
|
|
9040
|
+
const baseUrl = (truthyText4(input.baseUrl) || DEFAULT_BASE3).replace(/\/+$/u, "");
|
|
9041
|
+
const aiid = truthyText4(input.aiid);
|
|
9042
|
+
const result = {
|
|
9043
|
+
ok: false,
|
|
9044
|
+
file: filePath,
|
|
9045
|
+
flow,
|
|
9046
|
+
reviewFileId: null,
|
|
9047
|
+
workflowFileId: null,
|
|
9048
|
+
workflowUrl: null,
|
|
9049
|
+
aiExtraId: null,
|
|
9050
|
+
attachmentFieldId: null,
|
|
9051
|
+
summaryHtml: null,
|
|
9052
|
+
cardHtml: null,
|
|
9053
|
+
prefill: false,
|
|
9054
|
+
warnings,
|
|
9055
|
+
steps,
|
|
9056
|
+
parallel: {}
|
|
9057
|
+
};
|
|
9058
|
+
if (triageErr) warnings.push(`triage.json \u89E3\u6790\u5931\u8D25\uFF1A${triageErr}`);
|
|
9059
|
+
const uploadTask = async () => {
|
|
9060
|
+
if (input.skipUpload === true) return { skip: true };
|
|
9061
|
+
const paths = [filePath, ...attach];
|
|
9062
|
+
try {
|
|
9063
|
+
const data = await callOperation("contract.review.upload", { paths }, context);
|
|
9064
|
+
const files = Array.isArray(data.files) ? data.files : [];
|
|
9065
|
+
const fileIds = files.map((item) => truthyText4(item?.fileId)).filter((id) => id);
|
|
9066
|
+
return {
|
|
9067
|
+
skip: false,
|
|
9068
|
+
ok: true,
|
|
9069
|
+
fileId: fileIds[0],
|
|
9070
|
+
fileIds,
|
|
9071
|
+
count: paths.length,
|
|
9072
|
+
err: ""
|
|
9073
|
+
};
|
|
9074
|
+
} catch (error) {
|
|
9075
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
9076
|
+
return { skip: false, ok: false, fileId: void 0, fileIds: [], count: paths.length, err: message.slice(0, 200) };
|
|
9077
|
+
}
|
|
9078
|
+
};
|
|
9079
|
+
const launchTask = async () => {
|
|
9080
|
+
const targets = [filePath, ...attach];
|
|
9081
|
+
const fileIds = [];
|
|
9082
|
+
const errs = [];
|
|
9083
|
+
let first = {};
|
|
9084
|
+
for (let i = 0; i < targets.length; i += 1) {
|
|
9085
|
+
try {
|
|
9086
|
+
const data = await callOperation("contract.flow.launch", { flow, path: targets[i] }, context);
|
|
9087
|
+
if (i === 0) first = data;
|
|
9088
|
+
const fileId = truthyText4(data.file?.fileId);
|
|
9089
|
+
if (fileId) fileIds.push(fileId);
|
|
9090
|
+
else errs.push(`${basename6(targets[i])}: \u672A\u8FD4\u56DE fileId`);
|
|
9091
|
+
} catch (error) {
|
|
9092
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
9093
|
+
errs.push(`${basename6(targets[i])}: ${message.slice(0, 120)}`);
|
|
9094
|
+
}
|
|
9095
|
+
}
|
|
9096
|
+
return {
|
|
9097
|
+
ok: fileIds.length > 0 && fileIds.length === targets.length,
|
|
9098
|
+
d: first,
|
|
9099
|
+
fileIds,
|
|
9100
|
+
err: errs.join("\uFF1B").slice(0, 400)
|
|
9101
|
+
};
|
|
9102
|
+
};
|
|
9103
|
+
const triageTask = async () => {
|
|
9104
|
+
if (isFile4(triagePath)) return { state: "exists" };
|
|
9105
|
+
return { state: "missing" };
|
|
9106
|
+
};
|
|
9107
|
+
const [rUp, rLc, rTg] = await Promise.all([uploadTask(), launchTask(), triageTask()]);
|
|
9108
|
+
result.parallel.batchA = ["review.upload", "flow.launch", "triage.extract"];
|
|
9109
|
+
if (rTg.state === "missing") {
|
|
9110
|
+
warnings.push("\u672A\u627E\u5230 triage.json\uFF1A\u8BF7\u5148\u8DD1\u9636\u6BB51\uFF08Python \u62BD\u6B63\u6587\uFF09\u518D\u6267\u884C\u672C\u547D\u4EE4");
|
|
9111
|
+
} else {
|
|
9112
|
+
step("triage.extract", true, "triage.json \u5DF2\u5B58\u5728");
|
|
9113
|
+
}
|
|
9114
|
+
if (rUp.skip) {
|
|
9115
|
+
step("review.upload", true, "skipped: skipUpload");
|
|
9116
|
+
} else if (rUp.ok && rUp.fileId) {
|
|
9117
|
+
result.reviewFileId = rUp.fileId;
|
|
9118
|
+
result.reviewFileIds = rUp.fileIds;
|
|
9119
|
+
let note = String(rUp.fileId);
|
|
9120
|
+
if (rUp.count > 1) note = `${note} (${rUp.count} files)`;
|
|
9121
|
+
step("review.upload", true, note);
|
|
9122
|
+
} else {
|
|
9123
|
+
step("review.upload", false, rUp.err);
|
|
9124
|
+
warnings.push("\u9884\u5BA1\u4E0A\u4F20\u5931\u8D25\uFF0C\u9884\u5BA1\u5361\u5C06\u4E0D\u53EF\u7528\uFF08\u4E0D\u5F71\u54CD\u53D1\u8D77\u6D41\u7A0B\uFF09");
|
|
9125
|
+
}
|
|
9126
|
+
const launchData = rLc.d ?? {};
|
|
9127
|
+
const launchFileId = truthyText4(launchData.file?.fileId);
|
|
9128
|
+
if (launchFileId) {
|
|
9129
|
+
result.workflowFileId = launchFileId;
|
|
9130
|
+
result.workflowFileIds = rLc.fileIds?.length ? rLc.fileIds : [launchFileId];
|
|
9131
|
+
result.workflowUrl = launchData.url;
|
|
9132
|
+
result.attachmentFieldId = launchData.fieldId;
|
|
9133
|
+
result.workflowId = launchData.workflowId;
|
|
9134
|
+
const count = result.workflowFileIds.length;
|
|
9135
|
+
step("flow.launch", true, count === 1 ? launchFileId : `${launchFileId} (${count} files)`);
|
|
9136
|
+
if (!rLc.ok) warnings.push(`\u90E8\u5206\u968F\u9644\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25\uFF1A${rLc.err}`);
|
|
9137
|
+
if (launchData.fieldIdSource && launchData.fieldIdSource !== "preset") {
|
|
9138
|
+
warnings.push(`\u8BE5\u6D41\u7A0B\u9884\u8BBE\u4E0A\u4F20\u5B57\u6BB5\u5DF2\u5931\u6548\uFF0C\u5DF2\u6539\u7528\u5E03\u5C40\u4E2D\u7684 ${launchData.fieldId}`);
|
|
9139
|
+
}
|
|
9140
|
+
} else {
|
|
9141
|
+
step("flow.launch", false, rLc.err);
|
|
9142
|
+
warnings.push("\u53D1\u8D77\u6D41\u7A0B\u9875\u5931\u8D25\uFF0C\u65E0\u6CD5\u51FA\u300C\u53D1\u8D77\u6D41\u7A0B\u300D\u5361\u7247");
|
|
9143
|
+
}
|
|
9144
|
+
const recordTask = async () => {
|
|
9145
|
+
const out = { ok: false, aiExtraId: null, fieldId: null, steps: [], warn: [] };
|
|
9146
|
+
let recPath = truthyText4(input.recognizeFile) ? resolve13(truthyText4(input.recognizeFile)) : "";
|
|
9147
|
+
const hasBuiltin = Object.prototype.hasOwnProperty.call(BUILTIN, flow);
|
|
9148
|
+
if (!recPath && isFile4(triagePath) && result.workflowFileId) {
|
|
9149
|
+
try {
|
|
9150
|
+
const spec = hasBuiltin ? BUILTIN[flow] : void 0;
|
|
9151
|
+
const attField = truthyText4(result.attachmentFieldId) || truthyText4(spec?.attachmentFieldId);
|
|
9152
|
+
if (attField) result.attachmentFieldId = attField;
|
|
9153
|
+
let payload2 = null;
|
|
9154
|
+
let note = "";
|
|
9155
|
+
if (spec) {
|
|
9156
|
+
const triage = readJson2(triagePath);
|
|
9157
|
+
const elementsPath = join3(outDir, "elements.json");
|
|
9158
|
+
if (isFile4(elementsPath)) {
|
|
9159
|
+
try {
|
|
9160
|
+
const extracted = readJson2(elementsPath);
|
|
9161
|
+
if (extracted && typeof extracted === "object" && !Array.isArray(extracted)) {
|
|
9162
|
+
const base = triage.elements && typeof triage.elements === "object" && !Array.isArray(triage.elements) ? triage.elements : {};
|
|
9163
|
+
triage.elements = { ...base, ...extracted };
|
|
9164
|
+
}
|
|
9165
|
+
} catch (error) {
|
|
9166
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
9167
|
+
out.warn.push(`elements.json \u65E0\u6CD5\u89E3\u6790\uFF0C\u8981\u7D20\u9884\u586B\u964D\u7EA7\u4E3A\u9AA8\u67B6\u503C\uFF1A${message.slice(0, 100)}`);
|
|
9168
|
+
}
|
|
9169
|
+
} else {
|
|
9170
|
+
out.warn.push("\u672A\u627E\u5230 elements.json\uFF08ai_fill.elements \u672A\u843D\u76D8\uFF09\uFF0C\u8981\u7D20\u9884\u586B\u4EC5\u542B\u9ED8\u8BA4\u503C");
|
|
9171
|
+
}
|
|
9172
|
+
const reviewIds = Array.isArray(result.reviewFileIds) ? result.reviewFileIds : [];
|
|
9173
|
+
let fileIds = [String(result.workflowFileId), ...reviewIds.slice(1).filter((id) => id)];
|
|
9174
|
+
let sourceMap = loadSourceMap(outDir);
|
|
9175
|
+
if (!sourceMap) {
|
|
9176
|
+
fileIds = null;
|
|
9177
|
+
} else if (fileIds.length !== (sourceMap.files ?? []).length) {
|
|
9178
|
+
sourceMap = null;
|
|
9179
|
+
fileIds = null;
|
|
9180
|
+
}
|
|
9181
|
+
const built = buildPayload({
|
|
9182
|
+
triage,
|
|
9183
|
+
fileId: String(result.workflowFileId),
|
|
9184
|
+
flow,
|
|
9185
|
+
// origin 必须逐字取自正文;缺 contract_text.txt 时为空,下游记 null,不编造
|
|
9186
|
+
lines: loadSourceLines(join3(outDir, "contract_text.txt")),
|
|
9187
|
+
sourceMap,
|
|
9188
|
+
fileIds
|
|
9189
|
+
});
|
|
9190
|
+
payload2 = built.payload;
|
|
9191
|
+
const count = built.payload.recognizeResult.mainTable.rows[0].fieldResults.length;
|
|
9192
|
+
note = `${count} fields (builtin table)`;
|
|
9193
|
+
} else if (attField) {
|
|
9194
|
+
payload2 = buildMinimal(
|
|
9195
|
+
String(result.workflowFileId),
|
|
9196
|
+
flow,
|
|
9197
|
+
truthyText4(result.workflowId),
|
|
9198
|
+
attField
|
|
9199
|
+
);
|
|
9200
|
+
note = "no elements; attachment via customParams";
|
|
9201
|
+
}
|
|
9202
|
+
if (payload2) {
|
|
9203
|
+
payload2.attachmentFieldId = payload2.attachmentFieldId || attField;
|
|
9204
|
+
recPath = join3(outDir, "recognize_auto.json");
|
|
9205
|
+
writeFileSync8(recPath, JSON.stringify(payload2), "utf8");
|
|
9206
|
+
out.steps.push(["fill_elements", true, note]);
|
|
9207
|
+
} else {
|
|
9208
|
+
out.steps.push(["fill_elements", false, `NO_BUILTIN_TABLE: ${flow}`]);
|
|
9209
|
+
out.warn.push(`\u6D41\u7A0B\u300C${flow}\u300D\u65E0\u5185\u7F6E\u5B57\u6BB5\u8868\u4E14\u672A\u89E3\u6790\u5230\u9644\u4EF6\u5B57\u6BB5\uFF0C\u8981\u7D20\u9884\u586B\u8DF3\u8FC7\uFF1B\u5982\u9700\u9884\u586B\u8BF7\u7528 recognizeFile`);
|
|
9210
|
+
}
|
|
9211
|
+
} catch (error) {
|
|
9212
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
9213
|
+
out.steps.push(["fill_elements", false, message.slice(0, 150)]);
|
|
9214
|
+
out.warn.push(`\u8981\u7D20\u81EA\u52A8\u7EC4\u88C5\u5931\u8D25\uFF1A${message.slice(0, 120)}`);
|
|
9215
|
+
}
|
|
9216
|
+
}
|
|
9217
|
+
if (!(recPath && isFile4(recPath))) {
|
|
9218
|
+
out.steps.push(["save-recognize-record", true, "skipped: \u672A\u63D0\u4F9B recognizeResult"]);
|
|
9219
|
+
out.warn.push("\u672A\u63D0\u4F9B recognizeResult\uFF0C\u5361\u7247\u4E0D\u542B\u8981\u7D20\u9884\u586B");
|
|
9220
|
+
return out;
|
|
9221
|
+
}
|
|
9222
|
+
let payload;
|
|
9223
|
+
try {
|
|
9224
|
+
payload = readJson2(recPath);
|
|
9225
|
+
} catch (error) {
|
|
9226
|
+
out.warn.push(`recognizeResult \u6587\u4EF6\u65E0\u6CD5\u89E3\u6790\uFF1A${error instanceof Error ? error.message : String(error)}`);
|
|
9227
|
+
return out;
|
|
9228
|
+
}
|
|
9229
|
+
if (result.workflowFileId) {
|
|
9230
|
+
const allIds = Array.isArray(result.workflowFileIds) && result.workflowFileIds.length ? result.workflowFileIds : [String(result.workflowFileId)];
|
|
9231
|
+
payload.attachmentIds = allIds.join(",");
|
|
9232
|
+
payload.attachmentFileId = result.workflowFileId;
|
|
9233
|
+
}
|
|
9234
|
+
try {
|
|
9235
|
+
const rows2 = payload.recognizeResult?.mainTable?.rows ?? [];
|
|
9236
|
+
for (const row of rows2) {
|
|
9237
|
+
const list = Array.isArray(row.fieldResults) ? row.fieldResults : [];
|
|
9238
|
+
row.fieldResults = list.filter((item) => !String(item?.fieldInfo ?? "").endsWith(ATTACHMENT_FIELD_SUFFIX));
|
|
9239
|
+
}
|
|
9240
|
+
} catch {
|
|
9241
|
+
}
|
|
9242
|
+
const rows = payload.recognizeResult?.mainTable?.rows ?? [];
|
|
9243
|
+
const hasFields = rows.length > 0 && Array.isArray(rows[0].fieldResults) && rows[0].fieldResults.length > 0;
|
|
9244
|
+
if (!hasFields) {
|
|
9245
|
+
out.steps.push(["save-recognize-record", true, "skipped: \u65E0\u8981\u7D20\u5B57\u6BB5\uFF0C\u9644\u4EF6\u8D70 customParams"]);
|
|
9246
|
+
out.warn.push("\u672C\u6B21\u65E0\u53EF\u5B58\u8981\u7D20\uFF0C\u5DF2\u8DF3\u8FC7\u8BC6\u522B\u8BB0\u5F55\uFF1B\u9644\u4EF6\u5B57\u6BB5\u7531\u6D41\u7A0B\u7EC4\u4EF6\u53C2\u6570\u900F\u4F20");
|
|
9247
|
+
return out;
|
|
9248
|
+
}
|
|
9249
|
+
try {
|
|
9250
|
+
const data = await callOperation("contract.flow.save-recognize-record", payload, context);
|
|
9251
|
+
const aiExtraId = truthyText4(data.aiExtraId);
|
|
9252
|
+
if (aiExtraId) {
|
|
9253
|
+
out.ok = true;
|
|
9254
|
+
out.aiExtraId = aiExtraId;
|
|
9255
|
+
out.fieldId = truthyText4(data.attachmentFieldId) || null;
|
|
9256
|
+
out.steps.push(["save-recognize-record", true, aiExtraId]);
|
|
9257
|
+
} else {
|
|
9258
|
+
out.steps.push(["save-recognize-record", false, "\u672A\u8FD4\u56DE aiExtraId"]);
|
|
9259
|
+
out.warn.push("\u8981\u7D20\u9884\u586B\u4E0D\u53EF\u7528\uFF08\u672A\u8FD4\u56DE aiExtraId\uFF09\u3002\u5DF2\u964D\u7EA7\u4E3A\u300C\u53EA\u6253\u5F00\u6D41\u7A0B\u9875\u300D\uFF0C\u8868\u5355\u9700\u4EBA\u5DE5\u586B\u5199\u3002");
|
|
9260
|
+
}
|
|
9261
|
+
} catch (error) {
|
|
9262
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
9263
|
+
const short = message.slice(0, 200);
|
|
9264
|
+
out.steps.push(["save-recognize-record", false, short]);
|
|
9265
|
+
out.warn.push(`\u8981\u7D20\u9884\u586B\u4E0D\u53EF\u7528\uFF08${short.slice(0, 120)}\uFF09\u3002\u5DF2\u964D\u7EA7\u4E3A\u300C\u53EA\u6253\u5F00\u6D41\u7A0B\u9875\u300D\uFF0C\u8868\u5355\u9700\u4EBA\u5DE5\u586B\u5199\u3002`);
|
|
9266
|
+
}
|
|
9267
|
+
return out;
|
|
9268
|
+
};
|
|
9269
|
+
const summaryTask = async () => {
|
|
9270
|
+
const out = { html: null, steps: [], warn: [] };
|
|
9271
|
+
if (!(summaryData && isFile4(summaryData))) {
|
|
9272
|
+
out.steps.push(["summary.render", true, "skipped: \u672A\u63D0\u4F9B summary_data.json"]);
|
|
9273
|
+
return out;
|
|
9274
|
+
}
|
|
9275
|
+
const textPath = join3(outDir, "contract_text.txt");
|
|
9276
|
+
try {
|
|
9277
|
+
const validated = await callOperation(
|
|
9278
|
+
"contract.summary.validate",
|
|
9279
|
+
{
|
|
9280
|
+
summary: summaryData,
|
|
9281
|
+
...isFile4(textPath) ? { text: textPath } : {}
|
|
9282
|
+
},
|
|
9283
|
+
context
|
|
9284
|
+
);
|
|
9285
|
+
const fails = Array.isArray(validated.fails) ? validated.fails : [];
|
|
9286
|
+
if (validated.ok === false || fails.length) {
|
|
9287
|
+
const note = fails.length ? fails.join("; ") : "\u6458\u8981\u6821\u9A8C\u672A\u901A\u8FC7";
|
|
9288
|
+
out.steps.push(["summary.validate", false, note]);
|
|
9289
|
+
out.warn.push(`\u6458\u8981\u6821\u9A8C\u672A\u901A\u8FC7\uFF0C\u5DF2\u963B\u65AD\u6E32\u67D3\uFF1A${note.slice(0, 300)}`);
|
|
9290
|
+
return out;
|
|
9291
|
+
}
|
|
9292
|
+
const warns = Array.isArray(validated.warns) ? validated.warns : [];
|
|
9293
|
+
out.steps.push(["summary.validate", true, `warn=${warns.length}`]);
|
|
9294
|
+
} catch (error) {
|
|
9295
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
9296
|
+
out.steps.push(["summary.validate", false, message.slice(0, 200)]);
|
|
9297
|
+
out.warn.push(`\u6458\u8981\u6821\u9A8C\u672A\u901A\u8FC7\uFF0C\u5DF2\u963B\u65AD\u6E32\u67D3\uFF1A${message.slice(0, 300)}`);
|
|
9298
|
+
return out;
|
|
9299
|
+
}
|
|
9300
|
+
const htmlPath = join3(outDir, "summary.html");
|
|
9301
|
+
try {
|
|
9302
|
+
await callOperation("contract.summary.render", { data: summaryData, out: htmlPath }, context);
|
|
9303
|
+
if (isFile4(htmlPath)) {
|
|
9304
|
+
out.html = htmlPath;
|
|
9305
|
+
out.steps.push(["summary.render", true, `${statSync4(htmlPath).size} bytes`]);
|
|
9306
|
+
} else {
|
|
9307
|
+
out.steps.push(["summary.render", false, "\u672A\u751F\u6210 summary.html"]);
|
|
9308
|
+
}
|
|
9309
|
+
} catch (error) {
|
|
9310
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
9311
|
+
out.steps.push(["summary.render", false, message.slice(0, 200)]);
|
|
9312
|
+
}
|
|
9313
|
+
return out;
|
|
9314
|
+
};
|
|
9315
|
+
const [rRec, rSum] = await Promise.all([recordTask(), summaryTask()]);
|
|
9316
|
+
result.parallel.batchB = ["save-recognize-record", "summary.validate+render"];
|
|
9317
|
+
for (const [name, ok, note] of rRec.steps) step(name, ok, note);
|
|
9318
|
+
if (rRec.ok) {
|
|
9319
|
+
result.aiExtraId = rRec.aiExtraId;
|
|
9320
|
+
result.attachmentFieldId = rRec.fieldId || result.attachmentFieldId;
|
|
9321
|
+
result.prefill = true;
|
|
9322
|
+
}
|
|
9323
|
+
warnings.push(...rRec.warn);
|
|
9324
|
+
for (const [name, ok, note] of rSum.steps) step(name, ok, note);
|
|
9325
|
+
if (rSum.html) result.summaryHtml = rSum.html;
|
|
9326
|
+
warnings.push(...rSum.warn);
|
|
9327
|
+
const cardCtx = {
|
|
9328
|
+
scene: "doc",
|
|
9329
|
+
flowKey: flow,
|
|
9330
|
+
hasFileId: Boolean(result.workflowFileId),
|
|
9331
|
+
summaryReady: Boolean(result.summaryHtml),
|
|
9332
|
+
hasCounterparty,
|
|
9333
|
+
fileId: result.workflowFileId || "",
|
|
9334
|
+
fileName: basename6(filePath),
|
|
9335
|
+
companyName: company,
|
|
9336
|
+
baseUrl,
|
|
9337
|
+
summaryHtml: result.summaryHtml || "",
|
|
9338
|
+
aiExtraId: result.aiExtraId || "",
|
|
9339
|
+
attachmentFieldId: result.attachmentFieldId || "",
|
|
9340
|
+
submitted: false
|
|
9341
|
+
};
|
|
9342
|
+
result.launchCardSuppressed = false;
|
|
9343
|
+
if (!result.prefill) {
|
|
9344
|
+
result.launchCardDegraded = true;
|
|
9345
|
+
warnings.push("\u53D1\u8D77\u6D41\u7A0B\u5361\u5DF2\u964D\u7EA7\uFF1A\u8868\u5355\u8981\u7D20\u9700\u4EBA\u5DE5\u586B\u5199\uFF0C\u6D41\u7A0B\u9875\u4E0E\u5408\u540C\u9644\u4EF6\u53EF\u6B63\u5E38\u4F7F\u7528");
|
|
9346
|
+
} else {
|
|
9347
|
+
result.launchCardDegraded = false;
|
|
6360
9348
|
}
|
|
9349
|
+
const cardOut = join3(outDir, "card.html");
|
|
9350
|
+
try {
|
|
9351
|
+
const cardData = await callOperation(
|
|
9352
|
+
"contract.card.action",
|
|
9353
|
+
{
|
|
9354
|
+
context: cardCtx,
|
|
9355
|
+
fileId: result.workflowFileId || void 0,
|
|
9356
|
+
fileName: basename6(filePath),
|
|
9357
|
+
flowKey: flow,
|
|
9358
|
+
companyName: company || void 0,
|
|
9359
|
+
summaryHtml: result.summaryHtml || void 0,
|
|
9360
|
+
aiExtraId: result.prefill && result.aiExtraId ? String(result.aiExtraId) : void 0,
|
|
9361
|
+
attachmentFieldId: result.prefill && result.attachmentFieldId ? String(result.attachmentFieldId) : void 0,
|
|
9362
|
+
baseUrl,
|
|
9363
|
+
...aiid ? { aiid } : {},
|
|
9364
|
+
out: cardOut
|
|
9365
|
+
},
|
|
9366
|
+
context
|
|
9367
|
+
);
|
|
9368
|
+
if (cardData.noCard === true) {
|
|
9369
|
+
result.cardOk = null;
|
|
9370
|
+
step("render_action_card", true, "NO_CARD \u65E0\u53EF\u7528\u52A8\u4F5C");
|
|
9371
|
+
warnings.push("\u52A8\u4F5C\u5F15\u64CE\u8FC7\u6EE4\u540E\u65E0\u53EF\u7528\u5361\u7247\u52A8\u4F5C");
|
|
9372
|
+
} else if (cardData.selfCheckPassed === false && Array.isArray(cardData.selfCheck) && cardData.selfCheck.length) {
|
|
9373
|
+
result.cardOk = false;
|
|
9374
|
+
step("render_action_card", false, cardData.selfCheck.join(" / ").slice(0, 300));
|
|
9375
|
+
warnings.push(`\u5361\u7247\u81EA\u68C0\u672A\u901A\u8FC7\uFF1A${cardData.selfCheck.join(" / ").slice(0, 600)}`);
|
|
9376
|
+
} else if (isFile4(cardOut)) {
|
|
9377
|
+
result.cardHtml = cardOut;
|
|
9378
|
+
result.cardOk = true;
|
|
9379
|
+
step("render_action_card", true, `${statSync4(cardOut).size} bytes`);
|
|
9380
|
+
} else {
|
|
9381
|
+
result.cardOk = false;
|
|
9382
|
+
step("render_action_card", false, "\u672A\u751F\u6210 card.html");
|
|
9383
|
+
warnings.push("\u5361\u7247\u6E32\u67D3\u672A\u4EA7\u51FA\u6587\u4EF6");
|
|
9384
|
+
}
|
|
9385
|
+
} catch (error) {
|
|
9386
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
9387
|
+
result.cardOk = false;
|
|
9388
|
+
step("render_action_card", false, message.slice(0, 300));
|
|
9389
|
+
warnings.push(`\u5361\u7247\u6E32\u67D3\u5931\u8D25\uFF1A${message.slice(0, 600)}`);
|
|
9390
|
+
}
|
|
9391
|
+
result.ok = result.cardOk === false ? false : Boolean(result.cardHtml || result.summaryHtml);
|
|
9392
|
+
const resultPath = join3(outDir, "first_screen_result.json");
|
|
9393
|
+
writeFileSync8(resultPath, JSON.stringify(result, null, 2), "utf8");
|
|
9394
|
+
const cardHtmlContent = input.printCard === true && result.cardHtml && isFile4(result.cardHtml) ? readFileSync9(result.cardHtml, "utf8") : void 0;
|
|
9395
|
+
return {
|
|
9396
|
+
status: "COMPLETE",
|
|
9397
|
+
data: {
|
|
9398
|
+
ok: result.ok,
|
|
9399
|
+
cardOk: result.cardOk ?? null,
|
|
9400
|
+
prefill: result.prefill,
|
|
9401
|
+
aiExtraId: result.aiExtraId,
|
|
9402
|
+
cardHtml: result.cardHtml,
|
|
9403
|
+
summaryHtml: result.summaryHtml,
|
|
9404
|
+
workflowUrl: result.workflowUrl,
|
|
9405
|
+
reviewFileId: result.reviewFileId,
|
|
9406
|
+
workflowFileId: result.workflowFileId,
|
|
9407
|
+
attachmentFieldId: result.attachmentFieldId,
|
|
9408
|
+
parallel: result.parallel,
|
|
9409
|
+
warnings: result.warnings,
|
|
9410
|
+
steps: result.steps,
|
|
9411
|
+
result: resultPath,
|
|
9412
|
+
...cardHtmlContent ? { cardHtmlContent } : {},
|
|
9413
|
+
note: "\u4FE1\u5C01 ok \u8868\u793A\u547D\u4EE4\u6267\u884C\u6210\u529F\uFF1Bdata.ok \u8868\u793A\u94FE\u8DEF\u81F3\u5C11\u4EA7\u51FA\u5361\u7247\u6216\u6458\u8981\u3002\u964D\u7EA7\u4FE1\u606F\u89C1 warnings"
|
|
9414
|
+
}
|
|
9415
|
+
};
|
|
6361
9416
|
}
|
|
6362
|
-
|
|
9417
|
+
};
|
|
9418
|
+
var contractFirstScreenOperations = [contractFirstScreenOperation];
|
|
6363
9419
|
|
|
6364
9420
|
// src/shortcuts/contract/operations/flow.ts
|
|
6365
9421
|
var FLOW_PRESETS = [
|
|
@@ -6386,6 +9442,11 @@ function requestIdOf(value) {
|
|
|
6386
9442
|
const text4 = String(candidate).trim();
|
|
6387
9443
|
return text4 ? text4 : void 0;
|
|
6388
9444
|
}
|
|
9445
|
+
function optionalText(value) {
|
|
9446
|
+
if (value === void 0 || value === null) return void 0;
|
|
9447
|
+
const text4 = String(value).trim();
|
|
9448
|
+
return text4 ? text4 : void 0;
|
|
9449
|
+
}
|
|
6389
9450
|
var contractFlowOperations = [
|
|
6390
9451
|
{
|
|
6391
9452
|
name: "contract.flow.page",
|
|
@@ -6438,37 +9499,79 @@ var contractFlowOperations = [
|
|
|
6438
9499
|
name: "contract.flow.launch",
|
|
6439
9500
|
async execute(input, { host }) {
|
|
6440
9501
|
const flow = resolveFlow(input.flow);
|
|
6441
|
-
const
|
|
6442
|
-
|
|
9502
|
+
const rawPath = optionalText(input.path);
|
|
9503
|
+
const presetFileId = optionalText(input.fileId);
|
|
9504
|
+
if (!rawPath && !presetFileId) {
|
|
9505
|
+
throw contractValidationError(
|
|
9506
|
+
"file_required",
|
|
9507
|
+
"\u5FC5\u987B\u63D0\u4F9B path\uFF08\u672C\u5730\u4E0A\u4F20\uFF09\u6216 fileId\uFF08\u590D\u7528\u4F1A\u8BDD\u5DF2\u6709\u6587\u4EF6\uFF09\u4E4B\u4E00"
|
|
9508
|
+
);
|
|
9509
|
+
}
|
|
9510
|
+
if (rawPath) assertContractDocument(rawPath);
|
|
6443
9511
|
const formContext = await loadFormContext(host, flow.workflowId);
|
|
6444
9512
|
const uploadField = resolveUploadFieldId(formContext.layout, flow.fieldId, flow.label);
|
|
6445
|
-
const
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
9513
|
+
const session = await host.getSession();
|
|
9514
|
+
let presetModule = null;
|
|
9515
|
+
if (presetFileId) {
|
|
9516
|
+
presetModule = await lookupFileModule({
|
|
9517
|
+
fileId: presetFileId,
|
|
9518
|
+
baseUrl: session.baseUrl,
|
|
9519
|
+
userId: session.userId ?? ""
|
|
9520
|
+
});
|
|
9521
|
+
}
|
|
9522
|
+
const canReuse = presetFileId !== void 0 && presetModule === "workflow";
|
|
9523
|
+
let uploaded;
|
|
9524
|
+
let fileSource;
|
|
9525
|
+
let reuploadReason;
|
|
9526
|
+
if (canReuse) {
|
|
9527
|
+
uploaded = {
|
|
9528
|
+
fileId: presetFileId,
|
|
9529
|
+
name: "",
|
|
9530
|
+
size: 0,
|
|
9531
|
+
md5: "",
|
|
9532
|
+
module: "workflow",
|
|
9533
|
+
reused: true,
|
|
9534
|
+
prewarmed: true
|
|
9535
|
+
};
|
|
9536
|
+
fileSource = "reused";
|
|
9537
|
+
} else if (rawPath) {
|
|
9538
|
+
const baseParam = await host.contractRequest({
|
|
9539
|
+
method: "POST",
|
|
9540
|
+
path: "/api/workflow/core/flowPage/loadBaseParam",
|
|
9541
|
+
query: { isCreate: 1, workflowId: flow.workflowId },
|
|
9542
|
+
body: { workflowId: flow.workflowId, isCreate: 1, isMobile: 0 }
|
|
9543
|
+
});
|
|
9544
|
+
const requestId = requestIdOf(baseParam);
|
|
9545
|
+
if (!requestId) {
|
|
9546
|
+
throw contractValidationError(
|
|
9547
|
+
"request_id_missing",
|
|
9548
|
+
"loadBaseParam \u672A\u8FD4\u56DE requestInfo.requestId\uFF0C\u5DF2\u505C\u6B62\u4E0A\u4F20\uFF0C\u907F\u514D\u6587\u4EF6\u6302\u5230\u9519\u8BEF\u6D41\u7A0B",
|
|
9549
|
+
{ workflowId: flow.workflowId }
|
|
9550
|
+
);
|
|
9551
|
+
}
|
|
9552
|
+
uploaded = await uploadFile(host, {
|
|
9553
|
+
path: rawPath,
|
|
9554
|
+
module: "workflow",
|
|
9555
|
+
extraFields: {
|
|
9556
|
+
authModule: "workflow",
|
|
9557
|
+
source: "form",
|
|
9558
|
+
fieldId: uploadField.fieldId,
|
|
9559
|
+
sourceRefId: requestId,
|
|
9560
|
+
refId: requestId,
|
|
9561
|
+
folderId: "300"
|
|
9562
|
+
}
|
|
9563
|
+
});
|
|
9564
|
+
fileSource = presetFileId ? "reuploaded" : "uploaded";
|
|
9565
|
+
if (presetFileId) {
|
|
9566
|
+
reuploadReason = presetModule ? `\u5DF2\u6709\u6587\u4EF6\u7684 module \u662F ${presetModule}\uFF0C\u8868\u5355\u9644\u4EF6\u5FC5\u987B\u7528 workflow \u4E0A\u4F20\u7684\u6587\u4EF6\uFF0C\u5DF2\u91CD\u65B0\u4E0A\u4F20` : "\u5DF2\u6709\u6587\u4EF6\u7684 module \u672A\u77E5\uFF0C\u65E0\u6CD5\u786E\u8BA4\u80FD\u6302\u5230\u8868\u5355\u9644\u4EF6\u5B57\u6BB5\uFF0C\u5DF2\u91CD\u65B0\u4E0A\u4F20";
|
|
9567
|
+
}
|
|
9568
|
+
} else {
|
|
6453
9569
|
throw contractValidationError(
|
|
6454
|
-
"
|
|
6455
|
-
|
|
6456
|
-
{
|
|
9570
|
+
"reupload_required",
|
|
9571
|
+
`fileId ${presetFileId} \u4E0D\u662F workflow \u4E0A\u4F20\u7684\u6587\u4EF6\uFF08\u6216\u65E0\u6CD5\u786E\u8BA4\uFF09\uFF0C\u8868\u5355\u9644\u4EF6\u6302\u4E0D\u4F4F\uFF1B\u8BF7\u540C\u65F6\u63D0\u4F9B path \u4EE5\u4FBF\u91CD\u65B0\u4E0A\u4F20`,
|
|
9572
|
+
{ fileId: presetFileId, module: presetModule }
|
|
6457
9573
|
);
|
|
6458
9574
|
}
|
|
6459
|
-
const uploaded = await uploadFile(host, {
|
|
6460
|
-
path,
|
|
6461
|
-
module: "workflow",
|
|
6462
|
-
extraFields: {
|
|
6463
|
-
authModule: "workflow",
|
|
6464
|
-
source: "form",
|
|
6465
|
-
fieldId: uploadField.fieldId,
|
|
6466
|
-
sourceRefId: requestId,
|
|
6467
|
-
refId: requestId,
|
|
6468
|
-
folderId: "300"
|
|
6469
|
-
}
|
|
6470
|
-
});
|
|
6471
|
-
const session = await host.getSession();
|
|
6472
9575
|
return {
|
|
6473
9576
|
status: "COMPLETE",
|
|
6474
9577
|
data: {
|
|
@@ -6478,8 +9581,11 @@ var contractFlowOperations = [
|
|
|
6478
9581
|
fieldId: uploadField.fieldId,
|
|
6479
9582
|
fieldIdPreset: flow.fieldId,
|
|
6480
9583
|
fieldIdSource: uploadField.state,
|
|
6481
|
-
requestId,
|
|
6482
9584
|
file: uploaded,
|
|
9585
|
+
fileSource,
|
|
9586
|
+
presetFileId,
|
|
9587
|
+
presetFileModule: presetModule,
|
|
9588
|
+
reuploadReason,
|
|
6483
9589
|
url: flowPageUrl(session.baseUrl, flow.workflowId, uploaded.fileId),
|
|
6484
9590
|
page: { width: 1e3 }
|
|
6485
9591
|
}
|
|
@@ -6488,6 +9594,118 @@ var contractFlowOperations = [
|
|
|
6488
9594
|
}
|
|
6489
9595
|
];
|
|
6490
9596
|
|
|
9597
|
+
// src/shortcuts/contract/operations/modeltext.ts
|
|
9598
|
+
var MODEL_TEXT_OBJ_ID = "1290191829260230657";
|
|
9599
|
+
var MODEL_TEXT_LIST_ID = "1290191833571975256";
|
|
9600
|
+
var LIST_DATAS_PATH = "/api/ebuilder/form/list/getListDatas";
|
|
9601
|
+
function dataOf2(value) {
|
|
9602
|
+
return value?.data ?? {};
|
|
9603
|
+
}
|
|
9604
|
+
function rowsOf2(value) {
|
|
9605
|
+
const data = dataOf2(value);
|
|
9606
|
+
for (const candidate of [data.data, data.rows, data.records, data.list]) {
|
|
9607
|
+
if (Array.isArray(candidate)) return candidate;
|
|
9608
|
+
}
|
|
9609
|
+
return Array.isArray(data) ? data : [];
|
|
9610
|
+
}
|
|
9611
|
+
function totalOf(value, rows) {
|
|
9612
|
+
const data = dataOf2(value);
|
|
9613
|
+
const candidates = [
|
|
9614
|
+
data.total,
|
|
9615
|
+
data.count,
|
|
9616
|
+
data.pagination?.mainRecordTotal,
|
|
9617
|
+
data.pagination?.total
|
|
9618
|
+
];
|
|
9619
|
+
for (const candidate of candidates) {
|
|
9620
|
+
const parsed = Number(candidate);
|
|
9621
|
+
if (Number.isFinite(parsed) && parsed > 0) return parsed;
|
|
9622
|
+
}
|
|
9623
|
+
return rows.length;
|
|
9624
|
+
}
|
|
9625
|
+
var PERSON_NAME_KEYS = ["name", "label", "text", "showName", "userName", "username"];
|
|
9626
|
+
function personName(value) {
|
|
9627
|
+
if (typeof value !== "string" || !value) return void 0;
|
|
9628
|
+
try {
|
|
9629
|
+
const parsed = JSON.parse(value);
|
|
9630
|
+
if (Array.isArray(parsed) && parsed.length) {
|
|
9631
|
+
const first = parsed[0];
|
|
9632
|
+
if (typeof first === "string" && first && !/^\d+$/.test(first)) return first;
|
|
9633
|
+
if (first && typeof first === "object") {
|
|
9634
|
+
for (const key of PERSON_NAME_KEYS) {
|
|
9635
|
+
const candidate = first[key];
|
|
9636
|
+
if (typeof candidate === "string" && candidate && !/^\d+$/.test(candidate)) return candidate;
|
|
9637
|
+
}
|
|
9638
|
+
}
|
|
9639
|
+
}
|
|
9640
|
+
} catch {
|
|
9641
|
+
}
|
|
9642
|
+
return /^\d+$/.test(value) ? void 0 : value;
|
|
9643
|
+
}
|
|
9644
|
+
async function listModelText(host, pageNo, pageSize, tableuid) {
|
|
9645
|
+
const value = await host.contractRequest({
|
|
9646
|
+
method: "POST",
|
|
9647
|
+
path: LIST_DATAS_PATH,
|
|
9648
|
+
// ebbusinessid 与 listId 同值,缺它接口取不到该视图的业务上下文。
|
|
9649
|
+
headers: { ebbusinessid: MODEL_TEXT_LIST_ID },
|
|
9650
|
+
query: { passid: MODEL_TEXT_OBJ_ID, cid: MODEL_TEXT_OBJ_ID },
|
|
9651
|
+
body: {
|
|
9652
|
+
current: pageNo,
|
|
9653
|
+
requiredMatch: 1,
|
|
9654
|
+
tableuid: tableuid ?? "",
|
|
9655
|
+
mapResult: "1",
|
|
9656
|
+
recheckQuery: "1",
|
|
9657
|
+
terminal: "PC",
|
|
9658
|
+
searchParamData: {
|
|
9659
|
+
type: "and",
|
|
9660
|
+
searchType: "2",
|
|
9661
|
+
commonSearchFields: {},
|
|
9662
|
+
groupFields: {}
|
|
9663
|
+
},
|
|
9664
|
+
listId: MODEL_TEXT_LIST_ID,
|
|
9665
|
+
isFollow: 0,
|
|
9666
|
+
isShareToMe: 0,
|
|
9667
|
+
filterCondition: {},
|
|
9668
|
+
browser: "Chrome"
|
|
9669
|
+
}
|
|
9670
|
+
});
|
|
9671
|
+
const rows = rowsOf2(value);
|
|
9672
|
+
return { rows, total: totalOf(value, rows) };
|
|
9673
|
+
}
|
|
9674
|
+
var contractModelTextListOperation = {
|
|
9675
|
+
name: "contract.modeltext.list",
|
|
9676
|
+
async execute(input, { host }) {
|
|
9677
|
+
const pageNo = typeof input.pageNo === "number" && input.pageNo >= 1 ? input.pageNo : 1;
|
|
9678
|
+
const pageSize = typeof input.pageSize === "number" && input.pageSize >= 1 ? Math.min(input.pageSize, 200) : 50;
|
|
9679
|
+
const tableuid = typeof input.tableuid === "string" && input.tableuid.trim() ? input.tableuid.trim() : void 0;
|
|
9680
|
+
const { rows, total } = await listModelText(host, pageNo, pageSize, tableuid);
|
|
9681
|
+
const session = await host.getSession();
|
|
9682
|
+
return {
|
|
9683
|
+
status: "COMPLETE",
|
|
9684
|
+
data: {
|
|
9685
|
+
path: LIST_DATAS_PATH,
|
|
9686
|
+
listUrl: `${session.baseUrl}/sp/ebdfpage/list/${MODEL_TEXT_LIST_ID}`,
|
|
9687
|
+
total,
|
|
9688
|
+
pageNo,
|
|
9689
|
+
pageSize,
|
|
9690
|
+
returned: rows.length,
|
|
9691
|
+
modelTexts: rows.map((row) => ({
|
|
9692
|
+
id: row.id ?? row.rowKey ?? row.form_data_id,
|
|
9693
|
+
fileName: row.file_name,
|
|
9694
|
+
classification: row.classification_id,
|
|
9695
|
+
createTime: row.create_time,
|
|
9696
|
+
updateTime: row.update_time,
|
|
9697
|
+
creator: personName(row.creator),
|
|
9698
|
+
updater: personName(row.updater)
|
|
9699
|
+
})),
|
|
9700
|
+
hint: "\u672C\u547D\u4EE4\u8BFB\u7684\u662F\u8303\u6587\u5E93\uFF08\u300C\u5408\u540C\u8303\u6587\u7BA1\u7406\u300D\uFF09\uFF1B\u672C\u6280\u80FD\u5185\u300C\u6A21\u677F\u300D== \u300C\u8303\u6587\u300D\uFF0C\u4E0D\u8981\u4E0E\u5408\u540C\u6A21\u677F\u5E93 contract.template.list \u6DF7\u7528"
|
|
9701
|
+
}
|
|
9702
|
+
};
|
|
9703
|
+
}
|
|
9704
|
+
};
|
|
9705
|
+
var contractModelTextOperations = [
|
|
9706
|
+
contractModelTextListOperation
|
|
9707
|
+
];
|
|
9708
|
+
|
|
6491
9709
|
// src/shortcuts/contract/data/performance-catalog.ts
|
|
6492
9710
|
var PERFORMANCE_CATALOG = {
|
|
6493
9711
|
"origin": "https://{baseUrl}",
|
|
@@ -7810,18 +11028,18 @@ function catalog() {
|
|
|
7810
11028
|
}
|
|
7811
11029
|
function findMenu(name) {
|
|
7812
11030
|
const c = catalog();
|
|
7813
|
-
const
|
|
7814
|
-
if (
|
|
11031
|
+
const matches2 = c.menus.filter((m) => m.name === name || m.aliases.includes(name));
|
|
11032
|
+
if (matches2.length !== 1) {
|
|
7815
11033
|
throw contractValidationError("menu_ambiguous", "\u8BF7\u9009\u62E9\u83DC\u5355\uFF1A" + c.menus.map((m) => m.name).join("\u3001"));
|
|
7816
11034
|
}
|
|
7817
|
-
return
|
|
11035
|
+
return matches2[0];
|
|
7818
11036
|
}
|
|
7819
11037
|
function findField(menu, name) {
|
|
7820
|
-
const
|
|
7821
|
-
if (
|
|
11038
|
+
const matches2 = menu.fields.filter((f) => name === f[0] || name === f[1] || name === "field_" + f[1]);
|
|
11039
|
+
if (matches2.length !== 1) {
|
|
7822
11040
|
throw contractValidationError("field_not_found", `${menu.name}\u6CA1\u6709\u552F\u4E00\u5B57\u6BB5 ${name}`);
|
|
7823
11041
|
}
|
|
7824
|
-
return
|
|
11042
|
+
return matches2[0];
|
|
7825
11043
|
}
|
|
7826
11044
|
function normalizePeriod(value) {
|
|
7827
11045
|
const v = String(value).replace(/\s+/gu, "").replace("\u5E74", "-").replace(/月/gu, "").replace(/-$/u, "");
|
|
@@ -8480,11 +11698,11 @@ function requireApiPrefix(value) {
|
|
|
8480
11698
|
}
|
|
8481
11699
|
|
|
8482
11700
|
// src/shortcuts/contract/operations/quote.ts
|
|
8483
|
-
import { basename as
|
|
8484
|
-
import { existsSync as
|
|
11701
|
+
import { basename as basename7, resolve as resolve14 } from "node:path";
|
|
11702
|
+
import { existsSync as existsSync6, readFileSync as readFileSync11, writeFileSync as writeFileSync9 } from "node:fs";
|
|
8485
11703
|
|
|
8486
11704
|
// src/shortcuts/contract/ooxml/docx.ts
|
|
8487
|
-
import { readFileSync as
|
|
11705
|
+
import { readFileSync as readFileSync10 } from "node:fs";
|
|
8488
11706
|
var PLACEHOLDER_SOURCE = "\\{\\{[^}]{1,60}\\}\\}|\\$\\{[^}]{1,60}\\}|\u3010[^\u3011]{1,60}\u3011";
|
|
8489
11707
|
var BLANK_SOURCE = "_{2,}|\uFF3F{2,}|\u3010\\s*\u3011|\\{\\s*\\}";
|
|
8490
11708
|
function hasPlaceholder(text4) {
|
|
@@ -8495,8 +11713,8 @@ function hasBlank(text4) {
|
|
|
8495
11713
|
}
|
|
8496
11714
|
function labelBefore(text4, pos) {
|
|
8497
11715
|
const seg = text4.slice(0, pos);
|
|
8498
|
-
const
|
|
8499
|
-
if (
|
|
11716
|
+
const matches2 = [...seg.matchAll(/([^\s,,;;。]{1,20})[::]\s*$/gu)];
|
|
11717
|
+
if (matches2.length) return matches2[matches2.length - 1][1];
|
|
8500
11718
|
const m2 = /([^\s,,;;。]{2,20})[::]/u.exec(seg);
|
|
8501
11719
|
return m2 ? m2[1] : "";
|
|
8502
11720
|
}
|
|
@@ -8623,8 +11841,8 @@ function fillTable(tableXml, filler, log) {
|
|
|
8623
11841
|
}));
|
|
8624
11842
|
for (let ci = cells.length - 1; ci >= 0; ci--) {
|
|
8625
11843
|
const cell = cells[ci];
|
|
8626
|
-
const
|
|
8627
|
-
if (
|
|
11844
|
+
const cellText3 = paragraphFullText(cell.xml);
|
|
11845
|
+
if (cellText3 && !hasBlank(cellText3) && !hasPlaceholder(cellText3)) continue;
|
|
8628
11846
|
let label = "";
|
|
8629
11847
|
for (let j = ci - 1; j >= 0; j--) {
|
|
8630
11848
|
const cand = cells[j];
|
|
@@ -8720,7 +11938,7 @@ function formatAmount(v) {
|
|
|
8720
11938
|
function readDocumentXml(templatePath) {
|
|
8721
11939
|
let buffer;
|
|
8722
11940
|
try {
|
|
8723
|
-
buffer =
|
|
11941
|
+
buffer = readFileSync10(templatePath);
|
|
8724
11942
|
} catch {
|
|
8725
11943
|
throw new Error(
|
|
8726
11944
|
"\u5408\u540C\u6A21\u677F\u7F3A\u5931\uFF1A\u5FC5\u987B\u5148\u53D6\u5230\u771F\u5B9E\u7684 .docx \u6A21\u677F\u624D\u80FD\u751F\u6210\u5408\u540C\u3002\u53D6\u4E0D\u5230\u5C31\u505C\u6B62\u5E76\u8BF7\u7528\u6237\u63D0\u4F9B\u6A21\u677F\u6587\u4EF6\uFF1B\u7981\u6B62\u628A\u62A5\u4EF7\u5355\u5185\u5BB9\u76F4\u63A5\u751F\u6210\u6210\u4E00\u4EFD\u5408\u540C\u3002"
|
|
@@ -8828,6 +12046,78 @@ function fmtNum(v) {
|
|
|
8828
12046
|
if (!Number.isFinite(f)) return String(v);
|
|
8829
12047
|
return f === Math.trunc(f) ? f.toLocaleString("en-US") : f.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
8830
12048
|
}
|
|
12049
|
+
var META_FIELDS = [
|
|
12050
|
+
{
|
|
12051
|
+
key: "customer",
|
|
12052
|
+
labels: ["\u5BA2\u6237\u540D\u79F0", "\u5BA2\u6237\u5168\u79F0", "\u5BA2\u6237\u5355\u4F4D", "\u7528\u6237\u540D\u79F0", "\u7532\u65B9\u540D\u79F0", "\u91C7\u8D2D\u65B9", "\u8D2D\u4E70\u65B9", "\u8BA2\u8D2D\u65B9", "\u6700\u7EC8\u7528\u6237", "\u5BA2\u6237", "\u7532\u65B9", "\u9700\u65B9"],
|
|
12053
|
+
valid: (v) => v.length >= 2 && v.length <= 80 && /[\u4e00-\u9fa5A-Za-z]/u.test(v)
|
|
12054
|
+
},
|
|
12055
|
+
{
|
|
12056
|
+
key: "quote_date",
|
|
12057
|
+
labels: ["\u62A5\u4EF7\u65E5\u671F", "\u62A5\u4EF7\u65F6\u95F4", "\u62A5\u4EF7\u65E5"],
|
|
12058
|
+
valid: (v) => /\d{4}/u.test(v)
|
|
12059
|
+
},
|
|
12060
|
+
{
|
|
12061
|
+
key: "sales",
|
|
12062
|
+
labels: ["\u5BA2\u6237\u7ECF\u7406", "\u9500\u552E\u7ECF\u7406", "\u9500\u552E\u4EE3\u8868", "\u62A5\u4EF7\u4EBA", "\u5546\u52A1\u7ECF\u7406"],
|
|
12063
|
+
valid: (v) => v.length >= 1 && v.length <= 30 && !/^\d+$/u.test(v)
|
|
12064
|
+
},
|
|
12065
|
+
{
|
|
12066
|
+
key: "phone",
|
|
12067
|
+
labels: ["\u8054\u7CFB\u7535\u8BDD", "\u8054\u7CFB\u65B9\u5F0F", "\u5BA2\u6237\u7535\u8BDD", "\u624B\u673A\u53F7\u7801", "\u624B\u673A"],
|
|
12068
|
+
valid: (v) => /^[\d\-+() ]{6,}$/u.test(v.replace(/\s+/gu, ""))
|
|
12069
|
+
}
|
|
12070
|
+
];
|
|
12071
|
+
function escapeRe(s) {
|
|
12072
|
+
return s.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
12073
|
+
}
|
|
12074
|
+
function isLabelLike(v) {
|
|
12075
|
+
const bare = v.trim().replace(/[::]$/u, "").trim();
|
|
12076
|
+
if (!bare) return true;
|
|
12077
|
+
return META_FIELDS.some((f) => f.labels.includes(bare));
|
|
12078
|
+
}
|
|
12079
|
+
function cleanMetaValue(v) {
|
|
12080
|
+
return v.replace(/^[\s::\-—_]+/u, "").replace(/[\s::]+$/u, "").trim();
|
|
12081
|
+
}
|
|
12082
|
+
function extractQuoteMeta(rows) {
|
|
12083
|
+
const meta = { customer: "", quote_date: "", sales: "", phone: "" };
|
|
12084
|
+
const bestScore = {};
|
|
12085
|
+
const consider = (field, raw, score) => {
|
|
12086
|
+
const v = cleanMetaValue(raw);
|
|
12087
|
+
if (!v || isLabelLike(v) || !field.valid(v)) return;
|
|
12088
|
+
if (score > (bestScore[field.key] ?? 0)) {
|
|
12089
|
+
meta[field.key] = v;
|
|
12090
|
+
bestScore[field.key] = score;
|
|
12091
|
+
}
|
|
12092
|
+
};
|
|
12093
|
+
for (let r = 0; r < rows.length; r++) {
|
|
12094
|
+
const row = rows[r] ?? [];
|
|
12095
|
+
for (let c = 0; c < row.length; c++) {
|
|
12096
|
+
const cell = cleanMetaValue(row[c] ?? "");
|
|
12097
|
+
if (!cell) continue;
|
|
12098
|
+
for (const field of META_FIELDS) {
|
|
12099
|
+
for (const label of field.labels) {
|
|
12100
|
+
const inline = new RegExp(`^${escapeRe(label)}\\s*[:\uFF1A]\\s*(.+)$`, "u").exec(cell);
|
|
12101
|
+
if (inline && inline[1]) {
|
|
12102
|
+
consider(field, inline[1], 100);
|
|
12103
|
+
continue;
|
|
12104
|
+
}
|
|
12105
|
+
if (cell.replace(/[::]$/u, "").trim() !== label) continue;
|
|
12106
|
+
for (let j = c + 1; j < row.length; j++) {
|
|
12107
|
+
const v = cleanMetaValue(row[j] ?? "");
|
|
12108
|
+
if (!v) continue;
|
|
12109
|
+
if (isLabelLike(v)) break;
|
|
12110
|
+
consider(field, v, 95);
|
|
12111
|
+
break;
|
|
12112
|
+
}
|
|
12113
|
+
const below = cleanMetaValue(rows[r + 1]?.[c] ?? "");
|
|
12114
|
+
if (below && !isLabelLike(below)) consider(field, below, 80);
|
|
12115
|
+
}
|
|
12116
|
+
}
|
|
12117
|
+
}
|
|
12118
|
+
}
|
|
12119
|
+
return meta;
|
|
12120
|
+
}
|
|
8831
12121
|
function parseQuote(buffer, sheetName2, keepRemark = false, includeZero = false) {
|
|
8832
12122
|
const names = listSheetNames(buffer);
|
|
8833
12123
|
if (names.length === 0) throw contractValidationError("xlsx_invalid", "xlsx \u4E2D\u6CA1\u6709\u5DE5\u4F5C\u8868\u3002");
|
|
@@ -8870,22 +12160,7 @@ function parseQuote(buffer, sheetName2, keepRemark = false, includeZero = false)
|
|
|
8870
12160
|
for (let i = 0; i < row.length; i++) if (keys.includes(row[i])) return i;
|
|
8871
12161
|
return null;
|
|
8872
12162
|
};
|
|
8873
|
-
const meta =
|
|
8874
|
-
for (const row of rows) {
|
|
8875
|
-
const joined = row.join("");
|
|
8876
|
-
for (const [label, key] of [["\u5BA2\u6237\u540D\u79F0", "customer"], ["\u62A5\u4EF7\u65E5\u671F", "quote_date"], ["\u5BA2\u6237\u7ECF\u7406", "sales"], ["\u8054\u7CFB\u7535\u8BDD", "phone"]]) {
|
|
8877
|
-
if (!joined.includes(label) || meta[key]) continue;
|
|
8878
|
-
const i = firstIdx(row, [label + "\uFF1A", label + ":", label]);
|
|
8879
|
-
if (i === null) continue;
|
|
8880
|
-
for (let j = i + 1; j < row.length; j++) {
|
|
8881
|
-
const v = row[j];
|
|
8882
|
-
if (v && v.replace(/[::]$/u, "") !== label && !["\u62A5\u4EF7\u65E5\u671F", "\u5BA2\u6237\u7ECF\u7406", "\u8054\u7CFB\u7535\u8BDD"].some((x) => v.startsWith(x))) {
|
|
8883
|
-
meta[key] = v.replace(/[::]$/u, "");
|
|
8884
|
-
break;
|
|
8885
|
-
}
|
|
8886
|
-
}
|
|
8887
|
-
}
|
|
8888
|
-
}
|
|
12163
|
+
const meta = extractQuoteMeta(rows);
|
|
8889
12164
|
const totals = {};
|
|
8890
12165
|
for (const row of rows) {
|
|
8891
12166
|
for (const [label, key] of [["\u6807\u51C6\u4EF7\u5408\u8BA1", "standard_total"], ["\u6700\u7EC8\u4F18\u60E0\u62A5\u4EF7", "final_total"]]) {
|
|
@@ -8987,13 +12262,17 @@ function parseQuote(buffer, sheetName2, keepRemark = false, includeZero = false)
|
|
|
8987
12262
|
if (final !== void 0 && standard !== void 0 && final !== standard) {
|
|
8988
12263
|
warnings.push(`\u5B58\u5728\u6298\u6263\uFF1A\u6807\u51C6\u4EF7 ${standard} \u2192 \u6700\u7EC8\u4F18\u60E0\u62A5\u4EF7 ${final}\uFF0C\u5408\u540C\u91D1\u989D\u5E94\u4EE5\u6700\u7EC8\u4F18\u60E0\u62A5\u4EF7\u4E3A\u51C6`);
|
|
8989
12264
|
}
|
|
8990
|
-
if (!meta.customer)
|
|
12265
|
+
if (!meta.customer) {
|
|
12266
|
+
warnings.push(
|
|
12267
|
+
"\u672A\u80FD\u81EA\u52A8\u5B9A\u4F4D\u300E\u5BA2\u6237\u540D\u79F0\u300F\uFF08\u5DF2\u5C1D\u8BD5\u6807\u7B7E\u540C\u683C\u5185\u8054\u3001\u53F3\u90BB\u683C\u3001\u4E0B\u90BB\u683C\u4E09\u79CD\u5F62\u6001\uFF09\u3002\u8FD9\u4E0D\u4EE3\u8868\u6587\u4EF6\u672A\u586B\u5199\uFF1A\u8BF7\u7528 contract.quote.extract \u53D6\u539F\u59CB\u7F51\u683C\u884C\uFF0C\u7531\u6A21\u578B\u5728\u7F51\u683C\u4E2D\u786E\u8BA4\u5BA2\u6237\u5168\u79F0\u540E\u518D\u4EA4\u7528\u6237\u6838\u5BF9\u3002"
|
|
12268
|
+
);
|
|
12269
|
+
}
|
|
8991
12270
|
return { source_sheet: sheet, available_sheets: names, meta, totals, sections, checks, warnings };
|
|
8992
12271
|
}
|
|
8993
12272
|
function decodeXmlEntities(s) {
|
|
8994
12273
|
return s.replace(/</gu, "<").replace(/>/gu, ">").replace(/"/gu, '"').replace(/'/gu, "'").replace(/&/gu, "&");
|
|
8995
12274
|
}
|
|
8996
|
-
function
|
|
12275
|
+
function cellText2(fragment) {
|
|
8997
12276
|
const re = /<w:t(?:\s[^>]*)?>([\s\S]*?)<\/w:t>/gu;
|
|
8998
12277
|
const out = [];
|
|
8999
12278
|
let m;
|
|
@@ -9012,7 +12291,7 @@ function readDocxTablesFromXml(xml) {
|
|
|
9012
12291
|
const cells = [];
|
|
9013
12292
|
const tcRe = /<w:tc>[\s\S]*?<\/w:tc>/gu;
|
|
9014
12293
|
let cm;
|
|
9015
|
-
while ((cm = tcRe.exec(rm[0])) !== null) cells.push(
|
|
12294
|
+
while ((cm = tcRe.exec(rm[0])) !== null) cells.push(cellText2(cm[0]));
|
|
9016
12295
|
rows.push(cells);
|
|
9017
12296
|
}
|
|
9018
12297
|
if (rows.length) tables.push(rows);
|
|
@@ -9025,7 +12304,7 @@ function docxParagraphs(xml) {
|
|
|
9025
12304
|
const out = [];
|
|
9026
12305
|
let m;
|
|
9027
12306
|
while ((m = re.exec(noTbl)) !== null) {
|
|
9028
|
-
const t =
|
|
12307
|
+
const t = cellText2(m[0]);
|
|
9029
12308
|
if (t) out.push(t);
|
|
9030
12309
|
}
|
|
9031
12310
|
return out;
|
|
@@ -9138,7 +12417,11 @@ function normalizeParsedQuote(input) {
|
|
|
9138
12417
|
const t = asText(v);
|
|
9139
12418
|
if (t) meta[k] = t;
|
|
9140
12419
|
}
|
|
9141
|
-
if (!meta.customer)
|
|
12420
|
+
if (!meta.customer) {
|
|
12421
|
+
warnings.push(
|
|
12422
|
+
"\u672A\u4ECE\u62A5\u4EF7\u4E66\u4E2D\u8BC6\u522B\u5230\u5BA2\u6237\u540D\u79F0\uFF08\u53EF\u80FD\u5199\u6CD5\u975E\u5E38\u89C4\uFF09\u3002\u8FD9\u4E0D\u4EE3\u8868\u6587\u4EF6\u672A\u586B\u5199\uFF1A\u8BF7\u7531\u6A21\u578B\u4ECE\u539F\u6587\u786E\u8BA4\u5BA2\u6237\u5168\u79F0\u540E\u518D\u4EA4\u7528\u6237\u6838\u5BF9\u3002"
|
|
12423
|
+
);
|
|
12424
|
+
}
|
|
9142
12425
|
return {
|
|
9143
12426
|
source_sheet: "docx",
|
|
9144
12427
|
available_sheets: ["\u6B63\u6587"],
|
|
@@ -9229,7 +12512,7 @@ function makeFiller(data) {
|
|
|
9229
12512
|
};
|
|
9230
12513
|
}
|
|
9231
12514
|
function assertContractDocument2(path) {
|
|
9232
|
-
const absolute =
|
|
12515
|
+
const absolute = resolve14(path);
|
|
9233
12516
|
if (!/\.(docx)$/iu.test(absolute)) {
|
|
9234
12517
|
throw contractValidationError("bad_document", "\u53EA\u652F\u6301 .docx \u6A21\u677F\uFF1B.doc \u8001\u683C\u5F0F\u8BF7\u5148\u53E6\u5B58\u4E3A .docx\u3002");
|
|
9235
12518
|
}
|
|
@@ -9260,8 +12543,8 @@ var contractQuoteOperations = [
|
|
|
9260
12543
|
required: ["path"]
|
|
9261
12544
|
},
|
|
9262
12545
|
async execute(input) {
|
|
9263
|
-
const path =
|
|
9264
|
-
const sheets = listSheetNames(
|
|
12546
|
+
const path = resolve14(String(input.path));
|
|
12547
|
+
const sheets = listSheetNames(readFileSync11(path));
|
|
9265
12548
|
if (!sheets.length) throw contractValidationError("xlsx_invalid", "xlsx \u4E2D\u6CA1\u6709\u5DE5\u4F5C\u8868\u3002");
|
|
9266
12549
|
return {
|
|
9267
12550
|
status: "DONE",
|
|
@@ -9284,9 +12567,9 @@ var contractQuoteOperations = [
|
|
|
9284
12567
|
required: ["path"]
|
|
9285
12568
|
},
|
|
9286
12569
|
async execute(input) {
|
|
9287
|
-
const path =
|
|
12570
|
+
const path = resolve14(String(input.path));
|
|
9288
12571
|
if (/\.docx$/iu.test(path)) {
|
|
9289
|
-
const extracted = extractQuoteDocx(
|
|
12572
|
+
const extracted = extractQuoteDocx(readFileSync11(path));
|
|
9290
12573
|
return {
|
|
9291
12574
|
status: "DONE",
|
|
9292
12575
|
data: {
|
|
@@ -9302,7 +12585,7 @@ var contractQuoteOperations = [
|
|
|
9302
12585
|
);
|
|
9303
12586
|
}
|
|
9304
12587
|
const parsed = parseQuote(
|
|
9305
|
-
|
|
12588
|
+
readFileSync11(path),
|
|
9306
12589
|
input.sheet ? String(input.sheet) : null,
|
|
9307
12590
|
Boolean(input.keepRemark),
|
|
9308
12591
|
Boolean(input.includeZero)
|
|
@@ -9317,19 +12600,50 @@ var contractQuoteOperations = [
|
|
|
9317
12600
|
type: "object",
|
|
9318
12601
|
additionalProperties: false,
|
|
9319
12602
|
properties: {
|
|
9320
|
-
path: { type: "string", description: ".docx \u62A5\u4EF7\u4E66\u8DEF\u5F84" }
|
|
12603
|
+
path: { type: "string", description: ".docx / .xlsx \u62A5\u4EF7\u4E66\u8DEF\u5F84" },
|
|
12604
|
+
sheet: { type: "string", description: ".xlsx \u5DE5\u4F5C\u8868\u540D\uFF08\u53EF\u9009\uFF0C\u9ED8\u8BA4\u7B2C\u4E00\u4E2A\uFF09" }
|
|
9321
12605
|
},
|
|
9322
12606
|
required: ["path"]
|
|
9323
12607
|
},
|
|
9324
12608
|
async execute(input) {
|
|
9325
|
-
const path =
|
|
12609
|
+
const path = resolve14(String(input.path));
|
|
12610
|
+
if (/\.xlsx$/iu.test(path)) {
|
|
12611
|
+
const buf = readFileSync11(path);
|
|
12612
|
+
const sheets = listSheetNames(buf);
|
|
12613
|
+
const wanted = input.sheet ? String(input.sheet) : "";
|
|
12614
|
+
const idx = wanted ? Math.max(0, sheets.indexOf(wanted)) : 0;
|
|
12615
|
+
const grid = readGrid(buf, idx);
|
|
12616
|
+
const rows = [];
|
|
12617
|
+
for (let r = 1; r <= grid.maxRow; r++) {
|
|
12618
|
+
const line = [];
|
|
12619
|
+
const rowMap = grid.values.get(r);
|
|
12620
|
+
for (let c = 1; c <= grid.maxCol; c++) {
|
|
12621
|
+
line.push(rowMap?.get(c)?.text ?? "");
|
|
12622
|
+
}
|
|
12623
|
+
rows.push(line);
|
|
12624
|
+
}
|
|
12625
|
+
return {
|
|
12626
|
+
status: "DONE",
|
|
12627
|
+
data: {
|
|
12628
|
+
kind: "xlsx",
|
|
12629
|
+
sheet: sheets[idx] ?? null,
|
|
12630
|
+
sheets,
|
|
12631
|
+
rows,
|
|
12632
|
+
counts: {
|
|
12633
|
+
rows: rows.length,
|
|
12634
|
+
cols: rows.reduce((m, r) => Math.max(m, r.length), 0)
|
|
12635
|
+
},
|
|
12636
|
+
note: "\u96F6\u8BED\u4E49\u5224\u65AD\uFF1A\u53EA\u8FD8\u539F\u5355\u5143\u683C\u6587\u672C\u3002\u8BF7\u6A21\u578B\u8BFB rows \u5224\u5B9A meta\uFF08\u5BA2\u6237\u5168\u79F0/\u65E5\u671F/\u7A0E\u7387\u7B49\uFF09\u3001\u54EA\u5F20\u8868\u662F\u6C47\u603B\u8868\uFF08is_summary=true\uFF09\uFF0C\u4EA7\u51FA JSON \u540E\u4EA4 contract.quote.normalize \u6821\u9A8C\u91D1\u989D\u3002"
|
|
12637
|
+
}
|
|
12638
|
+
};
|
|
12639
|
+
}
|
|
9326
12640
|
if (!/\.docx$/iu.test(path)) {
|
|
9327
12641
|
throw contractValidationError(
|
|
9328
12642
|
"file_type_unsupported",
|
|
9329
|
-
"\u65E0\u635F\u63D0\u53D6\
|
|
12643
|
+
"\u65E0\u635F\u63D0\u53D6\u652F\u6301 .xlsx / .docx\uFF1B.xls / .doc \u8001\u683C\u5F0F\u8BF7\u5148\u53E6\u5B58\u4E3A\u65B0\u683C\u5F0F\u3002"
|
|
9330
12644
|
);
|
|
9331
12645
|
}
|
|
9332
|
-
const extracted = extractQuoteDocx(
|
|
12646
|
+
const extracted = extractQuoteDocx(readFileSync11(path));
|
|
9333
12647
|
return { status: "DONE", data: extracted };
|
|
9334
12648
|
}
|
|
9335
12649
|
},
|
|
@@ -9345,10 +12659,10 @@ var contractQuoteOperations = [
|
|
|
9345
12659
|
required: ["data"]
|
|
9346
12660
|
},
|
|
9347
12661
|
async execute(input) {
|
|
9348
|
-
const p =
|
|
12662
|
+
const p = resolve14(String(input.data));
|
|
9349
12663
|
let raw;
|
|
9350
12664
|
try {
|
|
9351
|
-
raw = JSON.parse(
|
|
12665
|
+
raw = JSON.parse(readFileSync11(p, "utf8"));
|
|
9352
12666
|
} catch (e) {
|
|
9353
12667
|
throw contractValidationError(
|
|
9354
12668
|
"quote_normalize_invalid",
|
|
@@ -9376,7 +12690,7 @@ var contractQuoteOperations = [
|
|
|
9376
12690
|
},
|
|
9377
12691
|
async execute(input) {
|
|
9378
12692
|
const template = assertContractDocument2(String(input.template));
|
|
9379
|
-
if (!
|
|
12693
|
+
if (!existsSync6(template)) {
|
|
9380
12694
|
throw contractValidationError(
|
|
9381
12695
|
"template_missing",
|
|
9382
12696
|
"\u5408\u540C\u6A21\u677F\u7F3A\u5931\uFF1A\u5FC5\u987B\u5148\u53D6\u5230\u771F\u5B9E\u7684 .docx \u6A21\u677F\u624D\u80FD\u751F\u6210\u5408\u540C\u3002\u53D6\u4E0D\u5230\u5C31\u505C\u6B62\u5E76\u8BF7\u7528\u6237\u63D0\u4F9B\u6A21\u677F\u6587\u4EF6\uFF1B\u7981\u6B62\u628A\u62A5\u4EF7\u5355\u5185\u5BB9\u76F4\u63A5\u751F\u6210\u6210\u4E00\u4EFD\u5408\u540C\u3002"
|
|
@@ -9384,7 +12698,7 @@ var contractQuoteOperations = [
|
|
|
9384
12698
|
}
|
|
9385
12699
|
let data;
|
|
9386
12700
|
try {
|
|
9387
|
-
data = JSON.parse(
|
|
12701
|
+
data = JSON.parse(readFileSync11(resolve14(String(input.data)), "utf8"));
|
|
9388
12702
|
} catch (error) {
|
|
9389
12703
|
throw contractValidationError("bad_data", `\u6570\u636E JSON \u65E0\u6CD5\u8BFB\u53D6\u6216\u89E3\u6790\uFF1A${error instanceof Error ? error.message : String(error)}`);
|
|
9390
12704
|
}
|
|
@@ -9395,19 +12709,19 @@ var contractQuoteOperations = [
|
|
|
9395
12709
|
sections: data["__sections"] ?? void 0,
|
|
9396
12710
|
amount: data["amount"] ?? null
|
|
9397
12711
|
});
|
|
9398
|
-
const out =
|
|
9399
|
-
|
|
12712
|
+
const out = resolve14(String(input.out));
|
|
12713
|
+
writeFileSync9(out, buffer);
|
|
9400
12714
|
const response = {
|
|
9401
12715
|
out,
|
|
9402
|
-
template:
|
|
12716
|
+
template: basename7(template),
|
|
9403
12717
|
filled_count: result.filled.length,
|
|
9404
12718
|
filled: result.filled,
|
|
9405
12719
|
unfilled: result.unfilled,
|
|
9406
12720
|
warning: result.unfilled.length > 0 ? "\u5B58\u5728\u672A\u586B\u5145\u5360\u4F4D/\u7A7A\u767D\uFF1A\u8BF7\u628A unfilled \u5217\u8868\u7ED9\u7528\u6237\u786E\u8BA4\uFF0C\u7F3A\u7684\u4FE1\u606F\u8BA9\u7528\u6237\u8865\u5145\u540E\u518D\u586B\uFF0C\u4E0D\u8981\u7F16\u9020\u3002" : null
|
|
9407
12721
|
};
|
|
9408
12722
|
if (input.mapOut) {
|
|
9409
|
-
|
|
9410
|
-
response.map_out =
|
|
12723
|
+
writeFileSync9(resolve14(String(input.mapOut)), JSON.stringify({ filled: result.filled, unfilled: result.unfilled }, null, 2), "utf8");
|
|
12724
|
+
response.map_out = resolve14(String(input.mapOut));
|
|
9411
12725
|
}
|
|
9412
12726
|
return { status: "DONE", data: response };
|
|
9413
12727
|
}
|
|
@@ -9797,34 +13111,8 @@ var contractRequestOperations = [
|
|
|
9797
13111
|
|
|
9798
13112
|
// src/shortcuts/contract/operations/review.ts
|
|
9799
13113
|
var AI_REVIEW_ASSISTANT_ID = "1326842382967570463";
|
|
9800
|
-
var AI_REVIEW_PREWARM_FLOW_ID = "1269716062340284522";
|
|
9801
|
-
var PREWARM_PATH = "/api/ebd/contract/ai/saveInternalRecord";
|
|
9802
|
-
var PREWARM_TIMEOUT_MS = 3e4;
|
|
9803
13114
|
var MAX_FILES = 10;
|
|
9804
13115
|
var CONTRACT_REVIEW_SCLX = "8";
|
|
9805
|
-
async function prewarmOne(host, fileId) {
|
|
9806
|
-
try {
|
|
9807
|
-
await host.contractRequest({
|
|
9808
|
-
method: "POST",
|
|
9809
|
-
path: PREWARM_PATH,
|
|
9810
|
-
body: { flowId: AI_REVIEW_PREWARM_FLOW_ID, fileId },
|
|
9811
|
-
timeoutMs: PREWARM_TIMEOUT_MS,
|
|
9812
|
-
// 触发型接口:成功时响应体为空,代表"预审已在执行"。
|
|
9813
|
-
// 不能走业务码判定,否则空体会被判成业务失败。
|
|
9814
|
-
okOnHttpSuccess: true
|
|
9815
|
-
});
|
|
9816
|
-
return { fileId, ok: true };
|
|
9817
|
-
} catch (error) {
|
|
9818
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
9819
|
-
const structured = error;
|
|
9820
|
-
const code = structured?.code === void 0 ? "" : ` code=${String(structured.code)}`;
|
|
9821
|
-
const raw = typeof structured?.details?.raw === "string" ? ` raw=${String(structured.details.raw).slice(0, 300)}` : "";
|
|
9822
|
-
return { fileId, ok: false, error: `${message}${code}${raw}` };
|
|
9823
|
-
}
|
|
9824
|
-
}
|
|
9825
|
-
async function prewarmAll(host, fileIds) {
|
|
9826
|
-
return Promise.all(fileIds.map((fileId) => prewarmOne(host, fileId)));
|
|
9827
|
-
}
|
|
9828
13116
|
function normalizeSclx(value) {
|
|
9829
13117
|
if (value === void 0 || value === null || value === "") return CONTRACT_REVIEW_SCLX;
|
|
9830
13118
|
if (typeof value !== "string" || value !== CONTRACT_REVIEW_SCLX) {
|
|
@@ -9849,9 +13137,53 @@ var contractReviewOperations = [
|
|
|
9849
13137
|
{
|
|
9850
13138
|
name: "contract.review.upload",
|
|
9851
13139
|
async execute(input, { host }) {
|
|
13140
|
+
const prewarmEnabled = input.prewarm !== false;
|
|
13141
|
+
const existingIds = input.fileIds;
|
|
13142
|
+
if (existingIds !== void 0) {
|
|
13143
|
+
if (input.paths !== void 0) {
|
|
13144
|
+
throw contractValidationError("input_conflict", "paths \u4E0E fileIds \u53EA\u80FD\u4E8C\u9009\u4E00\uFF1A\u8981\u4E48\u672C\u5730\u4E0A\u4F20\uFF0C\u8981\u4E48\u590D\u7528\u5DF2\u6709 fileId");
|
|
13145
|
+
}
|
|
13146
|
+
if (!Array.isArray(existingIds) || existingIds.length === 0) {
|
|
13147
|
+
throw contractValidationError("file_ids_required", "fileIds \u5FC5\u987B\u662F\u975E\u7A7A\u7684 fileId \u6570\u7EC4");
|
|
13148
|
+
}
|
|
13149
|
+
if (existingIds.length > MAX_FILES) {
|
|
13150
|
+
throw contractValidationError("file_ids_too_many", `\u4E00\u6B21\u6700\u591A\u5904\u7406 ${MAX_FILES} \u4EFD\u5408\u540C`);
|
|
13151
|
+
}
|
|
13152
|
+
const names = Array.isArray(input.fileNames) ? input.fileNames : [];
|
|
13153
|
+
const files2 = existingIds.map((rawItem, index) => {
|
|
13154
|
+
const fileId = requireNonEmptyString(rawItem, `fileIds[${index}]`, 64).trim();
|
|
13155
|
+
const name = typeof names[index] === "string" ? String(names[index]) : "";
|
|
13156
|
+
return { fileId, name, size: 0, md5: "", reused: true };
|
|
13157
|
+
});
|
|
13158
|
+
const prewarm2 = prewarmEnabled ? await ensurePrewarmed(host, files2.map((file) => file.fileId)) : null;
|
|
13159
|
+
const warnings2 = (prewarm2?.results ?? []).filter((item) => !item.ok).map((item) => `\u9884\u5BA1\u9884\u70ED\u5931\u8D25\uFF08fileId ${item.fileId}\uFF09\uFF1A${item.error}`);
|
|
13160
|
+
if (!prewarmEnabled) {
|
|
13161
|
+
warnings2.push("\u5DF2\u6309 prewarm=false \u8DF3\u8FC7\u9884\u5BA1\u9884\u70ED\uFF0C\u6253\u5F00\u5BA1\u67E5\u9875\u65F6\u624D\u4F1A\u5F00\u59CB\u8DD1\u9884\u5BA1");
|
|
13162
|
+
}
|
|
13163
|
+
const session2 = await host.getSession();
|
|
13164
|
+
return {
|
|
13165
|
+
status: "COMPLETE",
|
|
13166
|
+
data: {
|
|
13167
|
+
files: files2,
|
|
13168
|
+
reusedFileIds: true,
|
|
13169
|
+
prewarm: prewarm2 ? {
|
|
13170
|
+
flowId: AI_REVIEW_PREWARM_FLOW_ID,
|
|
13171
|
+
enabled: true,
|
|
13172
|
+
okCount: prewarm2.okCount,
|
|
13173
|
+
failCount: prewarm2.failCount,
|
|
13174
|
+
skippedCount: prewarm2.skippedCount,
|
|
13175
|
+
results: prewarm2.results
|
|
13176
|
+
} : { flowId: AI_REVIEW_PREWARM_FLOW_ID, enabled: false },
|
|
13177
|
+
warnings: warnings2,
|
|
13178
|
+
url: reviewPageUrl(session2.baseUrl, files2),
|
|
13179
|
+
page: { width: 1e3 },
|
|
13180
|
+
note: "\u5DF2\u590D\u7528\u4F1A\u8BDD\u4E2D\u5DF2\u6709\u7684 fileId\uFF0C\u672A\u91CD\u65B0\u4E0A\u4F20\uFF1B\u9884\u5BA1\u4E0E module \u65E0\u5173\uFF0C\u53EF\u76F4\u63A5\u6253\u5F00\u5BA1\u67E5\u9875"
|
|
13181
|
+
}
|
|
13182
|
+
};
|
|
13183
|
+
}
|
|
9852
13184
|
const paths = input.paths;
|
|
9853
13185
|
if (!Array.isArray(paths) || paths.length === 0) {
|
|
9854
|
-
throw contractValidationError("paths_required", "paths \u5FC5\u987B\u662F\u975E\u7A7A\u7684\u672C\u5730\u5408\u540C\u6587\u4EF6\u8DEF\u5F84\u6570\u7EC4");
|
|
13186
|
+
throw contractValidationError("paths_required", "paths \u5FC5\u987B\u662F\u975E\u7A7A\u7684\u672C\u5730\u5408\u540C\u6587\u4EF6\u8DEF\u5F84\u6570\u7EC4\uFF0C\u6216\u6539\u7528 fileIds \u590D\u7528\u5DF2\u6709\u6587\u4EF6");
|
|
9855
13187
|
}
|
|
9856
13188
|
if (paths.length > MAX_FILES) {
|
|
9857
13189
|
throw contractValidationError("paths_too_many", `\u4E00\u6B21\u6700\u591A\u4E0A\u4F20 ${MAX_FILES} \u4EFD\u5408\u540C`);
|
|
@@ -9860,11 +13192,10 @@ var contractReviewOperations = [
|
|
|
9860
13192
|
for (const rawPath of paths) {
|
|
9861
13193
|
const path = requireNonEmptyString(rawPath, "paths[]", 1e3);
|
|
9862
13194
|
assertContractDocument(path);
|
|
9863
|
-
files.push(await uploadFile(host, { path, module: "ebContract" }));
|
|
13195
|
+
files.push(await uploadFile(host, { path, module: "ebContract", prewarm: prewarmEnabled }));
|
|
9864
13196
|
}
|
|
9865
|
-
const
|
|
9866
|
-
const
|
|
9867
|
-
const warnings = (prewarm ?? []).filter((item) => !item.ok).map((item) => `\u9884\u5BA1\u9884\u70ED\u5931\u8D25\uFF08fileId ${item.fileId}\uFF09\uFF1A${item.error}`);
|
|
13197
|
+
const prewarm = prewarmEnabled ? await ensurePrewarmed(host, files.map((file) => file.fileId)) : null;
|
|
13198
|
+
const warnings = (prewarm?.results ?? []).filter((item) => !item.ok).map((item) => `\u9884\u5BA1\u9884\u70ED\u5931\u8D25\uFF08fileId ${item.fileId}\uFF09\uFF1A${item.error}`);
|
|
9868
13199
|
if (!prewarmEnabled) {
|
|
9869
13200
|
warnings.push("\u5DF2\u6309 prewarm=false \u8DF3\u8FC7\u9884\u5BA1\u9884\u70ED\uFF0C\u6253\u5F00\u5BA1\u67E5\u9875\u65F6\u624D\u4F1A\u5F00\u59CB\u8DD1\u9884\u5BA1");
|
|
9870
13201
|
}
|
|
@@ -9873,17 +13204,19 @@ var contractReviewOperations = [
|
|
|
9873
13204
|
status: "COMPLETE",
|
|
9874
13205
|
data: {
|
|
9875
13206
|
files,
|
|
13207
|
+
reusedFileIds: false,
|
|
9876
13208
|
prewarm: prewarm ? {
|
|
9877
13209
|
flowId: AI_REVIEW_PREWARM_FLOW_ID,
|
|
9878
13210
|
enabled: true,
|
|
9879
|
-
okCount: prewarm.
|
|
9880
|
-
failCount: prewarm.
|
|
9881
|
-
|
|
13211
|
+
okCount: prewarm.okCount,
|
|
13212
|
+
failCount: prewarm.failCount,
|
|
13213
|
+
skippedCount: prewarm.skippedCount,
|
|
13214
|
+
results: prewarm.results
|
|
9882
13215
|
} : { flowId: AI_REVIEW_PREWARM_FLOW_ID, enabled: false },
|
|
9883
13216
|
warnings,
|
|
9884
13217
|
url: reviewPageUrl(session.baseUrl, files),
|
|
9885
13218
|
page: { width: 1e3 },
|
|
9886
|
-
note: "\u4E0A\u4F20\u5B8C\u6210\u5E76\u5DF2\u89E6\u53D1\u9884\u5BA1\u9884\u70ED\uFF1B\u628A url \u539F\u6837\u653E\u8FDB browsertool \u7684 arguments.url\uFF0C\u5E76\u5E26 width: 1000\uFF1B\u4E0D\u8981\u505A\u6574\u4F53\u7F16\u7801"
|
|
13219
|
+
note: "\u4E0A\u4F20\u5B8C\u6210\u5E76\u5DF2\u89E6\u53D1\u9884\u5BA1\u9884\u70ED\uFF08\u540C\u4E00 fileId \u53EA\u89E6\u53D1\u4E00\u6B21\uFF09\uFF1B\u628A url \u539F\u6837\u653E\u8FDB browsertool \u7684 arguments.url\uFF0C\u5E76\u5E26 width: 1000\uFF1B\u4E0D\u8981\u505A\u6574\u4F53\u7F16\u7801"
|
|
9887
13220
|
}
|
|
9888
13221
|
};
|
|
9889
13222
|
}
|
|
@@ -9895,9 +13228,11 @@ var contractReviewOperations = [
|
|
|
9895
13228
|
if (input.fileIds !== void 0) {
|
|
9896
13229
|
throw contractValidationError("input_conflict", "fileId \u4E0E fileIds \u53EA\u80FD\u4E8C\u9009\u4E00");
|
|
9897
13230
|
}
|
|
9898
|
-
const
|
|
9899
|
-
|
|
9900
|
-
|
|
13231
|
+
const force = input.force !== false;
|
|
13232
|
+
const summary = await ensurePrewarmed(host, [fileId], { force });
|
|
13233
|
+
const result = summary.results[0];
|
|
13234
|
+
if (!result || !result.ok) {
|
|
13235
|
+
throw new Error(`\u9884\u5BA1\u9884\u70ED\u5931\u8D25\uFF1A${result?.error ?? "\u672A\u77E5\u539F\u56E0"}`);
|
|
9901
13236
|
}
|
|
9902
13237
|
return {
|
|
9903
13238
|
status: "COMPLETE",
|
|
@@ -10237,6 +13572,237 @@ var contractSubjectOperations = [
|
|
|
10237
13572
|
contractSubjectCreateApplyOperation
|
|
10238
13573
|
];
|
|
10239
13574
|
|
|
13575
|
+
// src/shortcuts/contract/operations/summary-validate.ts
|
|
13576
|
+
import { existsSync as existsSync7, readFileSync as readFileSync12, statSync as statSync5, writeFileSync as writeFileSync10 } from "node:fs";
|
|
13577
|
+
import { resolve as resolve15 } from "node:path";
|
|
13578
|
+
var SUPPORTED_TYPES = ["alert", "reasons", "grid", "table", "checks", "list", "next"];
|
|
13579
|
+
var REQUIRED_ROWS = ["\u5408\u540C\u7C7B\u578B", "\u5408\u540C\u603B\u989D", "\u7532\u65B9", "\u4E59\u65B9"];
|
|
13580
|
+
var TAX_WORDS = ["\u589E\u503C\u7A0E", "\u7A0E\u7387", "\u53D1\u7968", "\u542B\u7A0E"];
|
|
13581
|
+
var RICHNESS_BASELINE = 14;
|
|
13582
|
+
function pyStr2(value) {
|
|
13583
|
+
if (value === null || value === void 0) return "None";
|
|
13584
|
+
if (value === true) return "True";
|
|
13585
|
+
if (value === false) return "False";
|
|
13586
|
+
if (typeof value === "string") return value;
|
|
13587
|
+
if (typeof value === "number") return String(value);
|
|
13588
|
+
if (Array.isArray(value)) return `[${value.map((item) => pyRepr2(item)).join(", ")}]`;
|
|
13589
|
+
if (typeof value === "object") {
|
|
13590
|
+
return `{${Object.entries(value).map(([key, val]) => `${pyRepr2(key)}: ${pyRepr2(val)}`).join(", ")}}`;
|
|
13591
|
+
}
|
|
13592
|
+
return String(value);
|
|
13593
|
+
}
|
|
13594
|
+
function pyRepr2(value) {
|
|
13595
|
+
if (typeof value === "string") return `'${value}'`;
|
|
13596
|
+
return pyStr2(value);
|
|
13597
|
+
}
|
|
13598
|
+
function textOr(value) {
|
|
13599
|
+
return value === null || value === void 0 || value === false || value === "" || value === 0 ? "" : pyStr2(value);
|
|
13600
|
+
}
|
|
13601
|
+
function loadJson(path) {
|
|
13602
|
+
const raw = readFileSync12(path, "utf8").replace(/^\uFEFF/u, "");
|
|
13603
|
+
const parsed = JSON.parse(raw);
|
|
13604
|
+
if (!parsed || typeof parsed !== "object") {
|
|
13605
|
+
throw new Error("JSON \u6839\u8282\u70B9\u4E0D\u662F\u5BF9\u8C61");
|
|
13606
|
+
}
|
|
13607
|
+
return parsed;
|
|
13608
|
+
}
|
|
13609
|
+
function isFile5(path) {
|
|
13610
|
+
try {
|
|
13611
|
+
return existsSync7(path) && statSync5(path).isFile();
|
|
13612
|
+
} catch {
|
|
13613
|
+
return false;
|
|
13614
|
+
}
|
|
13615
|
+
}
|
|
13616
|
+
function collectRows(summary) {
|
|
13617
|
+
const rows = [];
|
|
13618
|
+
const sections = Array.isArray(summary.sections) ? summary.sections : [];
|
|
13619
|
+
for (const section of sections) {
|
|
13620
|
+
if (!section || typeof section !== "object" || Array.isArray(section)) continue;
|
|
13621
|
+
const sec = section;
|
|
13622
|
+
const type = String(sec.type ?? "").toLowerCase();
|
|
13623
|
+
const sectionTitle = textOr(sec.title);
|
|
13624
|
+
if (type === "table") {
|
|
13625
|
+
const items = Array.isArray(sec.rows) ? sec.rows : [];
|
|
13626
|
+
for (const row of items) {
|
|
13627
|
+
if (Array.isArray(row) && row.length >= 2) {
|
|
13628
|
+
rows.push({ label: pyStr2(row[0]), value: pyStr2(row[1]), section: sectionTitle });
|
|
13629
|
+
}
|
|
13630
|
+
}
|
|
13631
|
+
} else if (type === "grid" || type === "checks") {
|
|
13632
|
+
const items = Array.isArray(sec.items) ? sec.items : [];
|
|
13633
|
+
for (const item of items) {
|
|
13634
|
+
if (item && typeof item === "object" && !Array.isArray(item)) {
|
|
13635
|
+
const record = item;
|
|
13636
|
+
rows.push({
|
|
13637
|
+
label: textOr(record.label),
|
|
13638
|
+
value: textOr(record.value),
|
|
13639
|
+
section: sectionTitle
|
|
13640
|
+
});
|
|
13641
|
+
}
|
|
13642
|
+
}
|
|
13643
|
+
} else if (type === "list") {
|
|
13644
|
+
const items = Array.isArray(sec.items) ? sec.items : [];
|
|
13645
|
+
for (const item of items) {
|
|
13646
|
+
rows.push({ label: "", value: pyStr2(item), section: sectionTitle });
|
|
13647
|
+
}
|
|
13648
|
+
}
|
|
13649
|
+
}
|
|
13650
|
+
return rows;
|
|
13651
|
+
}
|
|
13652
|
+
function flatten(text4) {
|
|
13653
|
+
return text4.replace(/[,\s,]/gu, "");
|
|
13654
|
+
}
|
|
13655
|
+
function validateSummaryData(summary, text4, triagePath, elementsPath, outSummaryPath) {
|
|
13656
|
+
const fails = [];
|
|
13657
|
+
const warns = [];
|
|
13658
|
+
const rows = collectRows(summary);
|
|
13659
|
+
const sections = Array.isArray(summary.sections) ? summary.sections : [];
|
|
13660
|
+
if (!summary.title) fails.push("S1 \u7F3A\u5C11 title");
|
|
13661
|
+
if (!Array.isArray(summary.sections) || summary.sections.length === 0) {
|
|
13662
|
+
fails.push("S1 sections \u4E3A\u7A7A\u6216\u4E0D\u662F\u6570\u7EC4");
|
|
13663
|
+
}
|
|
13664
|
+
sections.forEach((section, index) => {
|
|
13665
|
+
const sec = section && typeof section === "object" ? section : {};
|
|
13666
|
+
const type = String(sec.type ?? "").toLowerCase();
|
|
13667
|
+
const name = textOr(sec.title) || `\u7B2C${index + 1}\u8282`;
|
|
13668
|
+
if (!SUPPORTED_TYPES.includes(type)) {
|
|
13669
|
+
fails.push(`S2 [${name}] \u672A\u77E5 type=${type}\uFF08\u652F\u6301 ${[...SUPPORTED_TYPES].sort().join(" / ")}\uFF09`);
|
|
13670
|
+
}
|
|
13671
|
+
if (type === "grid") {
|
|
13672
|
+
fails.push(`S3 [${name}] \u4F7F\u7528 grid\uFF1ACLI \u6E32\u67D3\u5668\u53EA\u8F93\u51FA\u7A7A\u5BB9\u5668\uFF0C\u5185\u5BB9\u4F1A\u6574\u6BB5\u4E22\u5931\uFF1B\u8BF7\u6539 table`);
|
|
13673
|
+
}
|
|
13674
|
+
if (type === "alert" || type === "checks") {
|
|
13675
|
+
warns.push(`S4 [${name}] \u4F7F\u7528 ${type}\uFF1A\u6458\u8981\u53EA\u505A\u5BA2\u89C2\u5448\u73B0\uFF0C\u98CE\u9669\u63D0\u793A\u5E94\u5F52\u300C\u5408\u540C\u9884\u5BA1\u300D`);
|
|
13676
|
+
}
|
|
13677
|
+
});
|
|
13678
|
+
if (rows.length < RICHNESS_BASELINE) {
|
|
13679
|
+
warns.push(`S5 \u8981\u7D20\u4EC5 ${rows.length} \u884C\uFF0C\u4F4E\u4E8E\u6587\u6863 \xA75.2 \u7684 ${RICHNESS_BASELINE} \u884C\u57FA\u7EBF`);
|
|
13680
|
+
}
|
|
13681
|
+
if (text4) {
|
|
13682
|
+
const flatSource = flatten(text4);
|
|
13683
|
+
for (const row of rows) {
|
|
13684
|
+
const numbers = flatten(row.value).match(/[0-9]{4,}(?:\.[0-9]{1,2})?/gu) ?? [];
|
|
13685
|
+
for (const number of numbers) {
|
|
13686
|
+
if (!flatSource.includes(number)) {
|
|
13687
|
+
warns.push(`S6 [${row.label || row.section}] \u91D1\u989D ${number} \u672A\u5728\u539F\u6587\u4E2D\u627E\u5230\uFF0C\u7591\u4F3C\u6362\u7B97\u6216\u7F16\u9020`);
|
|
13688
|
+
}
|
|
13689
|
+
}
|
|
13690
|
+
}
|
|
13691
|
+
}
|
|
13692
|
+
for (const row of rows) {
|
|
13693
|
+
const joined = `${row.label} ${row.value}`;
|
|
13694
|
+
const isPayRow = row.label.includes("\u4ED8\u6B3E") || row.label.includes("\u9636\u6BB5") || row.label.includes("\u6BD4\u4F8B") && !row.label.includes("\u7A0E");
|
|
13695
|
+
const percents = joined.match(/(\d{1,3})\s*%/gu) ?? [];
|
|
13696
|
+
for (const raw of percents) {
|
|
13697
|
+
const digit = /(\d{1,3})/u.exec(raw);
|
|
13698
|
+
const value = digit ? Number.parseInt(digit[1], 10) : 0;
|
|
13699
|
+
if (value > 100) {
|
|
13700
|
+
fails.push(`S7 [${row.label || row.section}] \u6BD4\u4F8B ${value}% \u8D85\u8FC7 100%`);
|
|
13701
|
+
}
|
|
13702
|
+
const hasTaxWord = TAX_WORDS.some((word) => joined.includes(word));
|
|
13703
|
+
const labelSaysTax = row.label.includes("\u7A0E") || row.label.includes("\u53D1\u7968");
|
|
13704
|
+
if (isPayRow && hasTaxWord && !labelSaysTax) {
|
|
13705
|
+
warns.push(`S8 [${row.label || row.section}] \u4ED8\u6B3E\u4E0E\u7A0E\u7387\u6DF7\u5199\uFF08${value}%\uFF09\uFF0C\u786E\u8BA4\u4E0D\u662F\u628A\u7A0E\u7387\u5F53\u4ED8\u6B3E\u6BD4\u4F8B`);
|
|
13706
|
+
}
|
|
13707
|
+
}
|
|
13708
|
+
}
|
|
13709
|
+
const labelsBlob = rows.map((row) => row.label).join(" ");
|
|
13710
|
+
const valuesBlob = rows.map((row) => row.value).join(" ");
|
|
13711
|
+
const labelAlternatives = {
|
|
13712
|
+
\u5408\u540C\u7C7B\u578B: ["\u5408\u540C\u7C7B\u578B", "\u5408\u540C\u7C7B\u522B", "\u7C7B\u578B"],
|
|
13713
|
+
\u5408\u540C\u603B\u989D: ["\u5408\u540C\u603B\u989D", "\u5408\u540C\u6807\u7684\u603B\u989D", "\u6807\u7684\u603B\u989D", "\u603B\u989D", "\u5408\u540C\u603B\u4EF7", "\u5408\u540C\u4EF7\u6B3E"],
|
|
13714
|
+
\u7532\u65B9: ["\u7532\u65B9", "\u9700\u65B9", "\u4E70\u65B9"],
|
|
13715
|
+
\u4E59\u65B9: ["\u4E59\u65B9", "\u4F9B\u65B9", "\u5356\u65B9"]
|
|
13716
|
+
};
|
|
13717
|
+
const valueAlternatives = {
|
|
13718
|
+
\u5408\u540C\u603B\u989D: ["\u5408\u540C\u603B\u989D", "\u5408\u540C\u6807\u7684\u603B\u989D", "\u6807\u7684\u603B\u989D", "\u5408\u540C\u603B\u4EF7", "\u5408\u540C\u4EF7\u6B3E"]
|
|
13719
|
+
};
|
|
13720
|
+
for (const key of REQUIRED_ROWS) {
|
|
13721
|
+
if ((labelAlternatives[key] ?? [key]).some((word) => labelsBlob.includes(word))) continue;
|
|
13722
|
+
if ((valueAlternatives[key] ?? []).some((word) => valuesBlob.includes(word))) continue;
|
|
13723
|
+
warns.push(`S9 \u7F3A\u5C11\u5FC5\u586B\u884C\u300C${key}\u300D`);
|
|
13724
|
+
}
|
|
13725
|
+
let place = "";
|
|
13726
|
+
let signPlace = "";
|
|
13727
|
+
for (const row of rows) {
|
|
13728
|
+
if (row.label.includes("\u4EA4\u4ED8") && row.label.includes("\u5730\u70B9")) place = row.value;
|
|
13729
|
+
if (row.label.includes("\u7B7E\u8BA2") && row.label.includes("\u5730\u70B9")) signPlace = row.value;
|
|
13730
|
+
}
|
|
13731
|
+
if (place && signPlace && place.trim() === signPlace.trim()) {
|
|
13732
|
+
warns.push(`S10 \u300C\u4EA4\u4ED8\u5730\u70B9\u300D\u4E0E\u300C\u7B7E\u8BA2\u5730\u70B9\u300D\u53D6\u503C\u76F8\u540C\uFF08${place}\uFF09\uFF0C\u786E\u8BA4\u662F\u5426\u7528\u7B7E\u8BA2\u5730\u70B9\u9876\u66FF`);
|
|
13733
|
+
}
|
|
13734
|
+
let merged = false;
|
|
13735
|
+
if (triagePath && elementsPath) {
|
|
13736
|
+
if (!isFile5(triagePath)) {
|
|
13737
|
+
warns.push(`\u5408\u6D41\u8DF3\u8FC7\uFF1Atriage.json \u4E0D\u5B58\u5728 ${triagePath}`);
|
|
13738
|
+
} else if (!isFile5(elementsPath)) {
|
|
13739
|
+
warns.push(`\u5408\u6D41\u8DF3\u8FC7\uFF1Aelements.json \u4E0D\u5B58\u5728 ${elementsPath}`);
|
|
13740
|
+
} else {
|
|
13741
|
+
try {
|
|
13742
|
+
const triage = loadJson(triagePath);
|
|
13743
|
+
const elements = loadJson(elementsPath);
|
|
13744
|
+
triage.elements = elements;
|
|
13745
|
+
triage.elementsSource = "ai_semantic";
|
|
13746
|
+
writeFileSync10(triagePath, JSON.stringify(triage, null, 2), "utf8");
|
|
13747
|
+
merged = true;
|
|
13748
|
+
} catch (error) {
|
|
13749
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
13750
|
+
warns.push(`\u5408\u6D41\u5931\u8D25\uFF1A${message}`);
|
|
13751
|
+
}
|
|
13752
|
+
}
|
|
13753
|
+
}
|
|
13754
|
+
let outSummary;
|
|
13755
|
+
if (outSummaryPath && fails.length === 0) {
|
|
13756
|
+
writeFileSync10(outSummaryPath, JSON.stringify(summary, null, 2), "utf8");
|
|
13757
|
+
outSummary = outSummaryPath;
|
|
13758
|
+
}
|
|
13759
|
+
return {
|
|
13760
|
+
ok: fails.length === 0,
|
|
13761
|
+
merged,
|
|
13762
|
+
sectionCount: sections.length,
|
|
13763
|
+
rowCount: rows.length,
|
|
13764
|
+
fails,
|
|
13765
|
+
warns,
|
|
13766
|
+
...outSummary ? { outSummary } : {}
|
|
13767
|
+
};
|
|
13768
|
+
}
|
|
13769
|
+
var contractSummaryValidateOperation = {
|
|
13770
|
+
name: "contract.summary.validate",
|
|
13771
|
+
async execute(input) {
|
|
13772
|
+
const summaryPath = resolve15(requireNonEmptyString(input.summary, "summary", 4096).trim());
|
|
13773
|
+
if (!isFile5(summaryPath)) {
|
|
13774
|
+
throw contractValidationError("summary_not_found", `\u6458\u8981\u6570\u636E\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${summaryPath}`);
|
|
13775
|
+
}
|
|
13776
|
+
let summary;
|
|
13777
|
+
try {
|
|
13778
|
+
summary = loadJson(summaryPath);
|
|
13779
|
+
} catch (error) {
|
|
13780
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
13781
|
+
throw contractValidationError("summary_parse_fail", `\u6458\u8981\u6570\u636E\u4E0D\u662F\u5408\u6CD5 JSON \u5BF9\u8C61\uFF1A${message}`);
|
|
13782
|
+
}
|
|
13783
|
+
const textPath = typeof input.text === "string" && input.text.trim() ? resolve15(input.text.trim()) : "";
|
|
13784
|
+
const triagePath = typeof input.triage === "string" && input.triage.trim() ? resolve15(input.triage.trim()) : "";
|
|
13785
|
+
const elementsPath = typeof input.elements === "string" && input.elements.trim() ? resolve15(input.elements.trim()) : "";
|
|
13786
|
+
const outSummaryPath = typeof input.outSummary === "string" && input.outSummary.trim() ? resolve15(input.outSummary.trim()) : "";
|
|
13787
|
+
let text4 = "";
|
|
13788
|
+
if (textPath && isFile5(textPath)) {
|
|
13789
|
+
text4 = readFileSync12(textPath, "utf8");
|
|
13790
|
+
}
|
|
13791
|
+
const result = validateSummaryData(summary, text4, triagePath, elementsPath, outSummaryPath);
|
|
13792
|
+
const strict = input.strict === true;
|
|
13793
|
+
return {
|
|
13794
|
+
status: "COMPLETE",
|
|
13795
|
+
data: {
|
|
13796
|
+
...result,
|
|
13797
|
+
strict,
|
|
13798
|
+
pass: result.ok && !(strict && result.warns.length > 0),
|
|
13799
|
+
note: "\u4FE1\u5C01 ok \u8868\u793A\u547D\u4EE4\u6267\u884C\u6210\u529F\uFF1Bdata.ok \u8868\u793A\u6458\u8981\u6821\u9A8C\u901A\u8FC7\u3002FAIL \u65F6\u4E0D\u5F97\u6E32\u67D3\u6458\u8981"
|
|
13800
|
+
}
|
|
13801
|
+
};
|
|
13802
|
+
}
|
|
13803
|
+
};
|
|
13804
|
+
var contractSummaryValidateOperations = [contractSummaryValidateOperation];
|
|
13805
|
+
|
|
10240
13806
|
// src/shortcuts/contract/operations/template.ts
|
|
10241
13807
|
var contractTypeTreeOperation = new ContractReadOperation("contract.type.tree", {
|
|
10242
13808
|
method: "GET",
|
|
@@ -10410,11 +13976,14 @@ function buildRegistry() {
|
|
|
10410
13976
|
const registry = /* @__PURE__ */ new Map();
|
|
10411
13977
|
const handlers = [
|
|
10412
13978
|
...contractTemplateOperations,
|
|
13979
|
+
...contractModelTextOperations,
|
|
10413
13980
|
...contractClauseLibraryOperations,
|
|
10414
13981
|
...contractClauseInsertOperations,
|
|
10415
13982
|
...contractClauseReferenceOperations,
|
|
10416
13983
|
...contractSubjectOperations,
|
|
10417
13984
|
...contractCustomerOperations,
|
|
13985
|
+
...contractElementsBuildOperations,
|
|
13986
|
+
...contractFirstScreenOperations,
|
|
10418
13987
|
...contractWorkflowOperations,
|
|
10419
13988
|
...contractRequestOperations,
|
|
10420
13989
|
...contractReviewOperations,
|
|
@@ -10427,7 +13996,12 @@ function buildRegistry() {
|
|
|
10427
13996
|
...contractAssistantOperations,
|
|
10428
13997
|
...contractPerformanceOperations,
|
|
10429
13998
|
...contractSummaryOperations,
|
|
13999
|
+
...contractSummaryValidateOperations,
|
|
10430
14000
|
...contractCardOperations,
|
|
14001
|
+
...contractCardPlanOperations,
|
|
14002
|
+
...contractCardEbdfListOperations,
|
|
14003
|
+
...contractCardRiskReportOperations,
|
|
14004
|
+
...contractCardActionOperations,
|
|
10431
14005
|
...contractQuoteOperations
|
|
10432
14006
|
];
|
|
10433
14007
|
for (const handler of handlers) {
|
|
@@ -10445,6 +14019,7 @@ function buildRegistry() {
|
|
|
10445
14019
|
return registry;
|
|
10446
14020
|
}
|
|
10447
14021
|
var contractOperationRegistry = buildRegistry();
|
|
14022
|
+
setOperationResolver(getContractOperation);
|
|
10448
14023
|
function getContractOperation(operation) {
|
|
10449
14024
|
const handler = contractOperationRegistry.get(operation);
|
|
10450
14025
|
if (!handler) {
|
|
@@ -10488,7 +14063,7 @@ async function inputFrom(options, extra = {}) {
|
|
|
10488
14063
|
if (opts.input) {
|
|
10489
14064
|
let raw;
|
|
10490
14065
|
try {
|
|
10491
|
-
raw = opts.input === "-" ? await readStdin() : await
|
|
14066
|
+
raw = opts.input === "-" ? await readStdin() : await readFile6(String(opts.input), "utf8");
|
|
10492
14067
|
} catch {
|
|
10493
14068
|
throw contractValidationError("input_unreadable", `\u65E0\u6CD5\u8BFB\u53D6 --input\uFF1A${String(opts.input)}`);
|
|
10494
14069
|
}
|