weaver-work-cli 0.1.28 → 0.1.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/dist/chunks/archive-U766FTFH.js +2537 -0
  2. package/dist/chunks/archive-oa-DMWEKX3L.js +1317 -0
  3. package/dist/chunks/asset-TCR7VDEV.js +2109 -0
  4. package/dist/chunks/attachment-content-AQNX5N3S.js +23 -0
  5. package/dist/chunks/blog-EVZWGDVM.js +2157 -0
  6. package/dist/chunks/caizhilian-JOWS6SL5.js +10087 -0
  7. package/dist/chunks/calendar-5WNCV66Q.js +1195 -0
  8. package/dist/chunks/chunk-2DUV44UX.js +15606 -0
  9. package/dist/chunks/chunk-324YPTC2.js +1607 -0
  10. package/dist/chunks/chunk-65QMVWHS.js +231 -0
  11. package/dist/chunks/chunk-6V7ZLF34.js +387 -0
  12. package/dist/chunks/chunk-AC7KJWC5.js +358 -0
  13. package/dist/chunks/chunk-AJ62BGAW.js +29 -0
  14. package/dist/chunks/chunk-BUSC6UAE.js +43 -0
  15. package/dist/chunks/chunk-CVZ2JOSW.js +62 -0
  16. package/dist/chunks/chunk-D4LTJSJD.js +477 -0
  17. package/dist/chunks/chunk-EG6ZU444.js +654 -0
  18. package/dist/chunks/chunk-EZALDOQH.js +383 -0
  19. package/dist/chunks/chunk-FMPJJYYI.js +106 -0
  20. package/dist/chunks/chunk-G2JSIUWF.js +769 -0
  21. package/dist/chunks/chunk-GCG2NMWR.js +703 -0
  22. package/dist/chunks/chunk-GPMFD4RD.js +75 -0
  23. package/dist/chunks/chunk-H3WDBYJW.js +508 -0
  24. package/dist/chunks/chunk-H6XSTSLM.js +2357 -0
  25. package/dist/chunks/chunk-J7RJTZSV.js +5556 -0
  26. package/dist/chunks/chunk-LUSPKZKY.js +53 -0
  27. package/dist/chunks/chunk-NIAJ5ZCG.js +73 -0
  28. package/dist/chunks/chunk-NOODWMCL.js +584 -0
  29. package/dist/chunks/chunk-OOUTBLZ4.js +51 -0
  30. package/dist/chunks/chunk-P26ZWSKU.js +73 -0
  31. package/dist/chunks/chunk-QWY6PGL6.js +3472 -0
  32. package/dist/chunks/chunk-R2IJAK7T.js +464 -0
  33. package/dist/chunks/chunk-R7O5PUWO.js +205 -0
  34. package/dist/chunks/chunk-RCGYCOMG.js +6962 -0
  35. package/dist/chunks/chunk-VZTXRG6X.js +403 -0
  36. package/dist/chunks/chunk-WHD4XMRP.js +161 -0
  37. package/dist/chunks/chunk-YLCYX7LE.js +371 -0
  38. package/dist/chunks/chunk-ZEDWSH32.js +68 -0
  39. package/dist/chunks/continuation-2CKSBLA6.js +11 -0
  40. package/dist/chunks/continuation-HZIZRZBX.js +13 -0
  41. package/dist/chunks/continuation-NLECEJPX.js +11 -0
  42. package/dist/chunks/ebuilder-form-NJ4YK6CC.js +2276 -0
  43. package/dist/chunks/ehr-MMYN36VA.js +5241 -0
  44. package/dist/chunks/employee-SAK2QYXX.js +11 -0
  45. package/dist/chunks/esb-HIWHOU7Q.js +141 -0
  46. package/dist/chunks/fna-KBACQTA5.js +1444 -0
  47. package/dist/chunks/host-3OHS5QUX.js +21 -0
  48. package/dist/chunks/host-IG6KEH5Q.js +19 -0
  49. package/dist/chunks/host-KQL5N4HO.js +23 -0
  50. package/dist/chunks/host-LLSZQCWR.js +17 -0
  51. package/dist/chunks/hrm-LYEC67ZQ.js +244 -0
  52. package/dist/chunks/im-RN2UKAEU.js +252 -0
  53. package/dist/chunks/invoice-EEPHLAF6.js +5179 -0
  54. package/dist/chunks/jiuchuanhui-WVVZYSJE.js +1940 -0
  55. package/dist/chunks/lazy-dispatch-MDOFFL2S.js +28 -0
  56. package/dist/chunks/mail-LNQLTF6L.js +2695 -0
  57. package/dist/chunks/meeting-XSD3BDVQ.js +504 -0
  58. package/dist/chunks/msg-parse-4GSQ2WTO.js +41 -0
  59. package/dist/chunks/okr-TMWTIU2K.js +2482 -0
  60. package/dist/chunks/plan-A2FSFA7T.js +2025 -0
  61. package/dist/chunks/project-T26QLBQF.js +1361 -0
  62. package/dist/chunks/registry-2VLUAESA.js +14 -0
  63. package/dist/chunks/registry-JCFEYXOE.js +18 -0
  64. package/dist/chunks/registry-NYPYMZXG.js +16 -0
  65. package/dist/chunks/registry-Q7OQJ3SU.js +19 -0
  66. package/dist/chunks/registry-ZJMJVWFA.js +19 -0
  67. package/dist/chunks/room-recommend-UR4ZDZS6.js +20 -0
  68. package/dist/chunks/schedule-5L2PM4M6.js +24 -0
  69. package/dist/chunks/state-Y2XBP6YE.js +15 -0
  70. package/dist/chunks/workflow-TR6PG2SL.js +245 -0
  71. package/dist/cmd/argv.js +45 -0
  72. package/dist/cmd/docs/index.js +3 -3
  73. package/dist/cmd/lazy-dispatch.js +20 -0
  74. package/dist/cmd/root.js +2 -4
  75. package/dist/cmd/setup/index.js +2 -2
  76. package/dist/cmd/skills/index.js +2 -2
  77. package/dist/core/package-paths.js +47 -0
  78. package/dist/index.js +163 -7
  79. package/dist/internal/e10/auth/xiaoe.js +3 -3
  80. package/dist/internal/e10/request-runtime.js +18 -62
  81. package/dist/internal/skills/detector.js +2 -2
  82. package/dist/shortcuts/contract/data/performance-catalog.js +1306 -0
  83. package/dist/shortcuts/contract/host.js +91 -35
  84. package/dist/shortcuts/contract/index.js +213 -0
  85. package/dist/shortcuts/contract/manifest.js +928 -0
  86. package/dist/shortcuts/contract/ooxml/docx.js +295 -0
  87. package/dist/shortcuts/contract/ooxml/xlsx.js +221 -0
  88. package/dist/shortcuts/contract/ooxml/zip.js +158 -0
  89. package/dist/shortcuts/contract/operations/assistant.js +1156 -0
  90. package/dist/shortcuts/contract/operations/clause-library.js +522 -0
  91. package/dist/shortcuts/contract/operations/compare.js +193 -0
  92. package/dist/shortcuts/contract/operations/credit-page.js +34 -0
  93. package/dist/shortcuts/contract/operations/flow.js +98 -0
  94. package/dist/shortcuts/contract/operations/page.js +66 -0
  95. package/dist/shortcuts/contract/operations/performance.js +733 -0
  96. package/dist/shortcuts/contract/operations/quote.js +557 -0
  97. package/dist/shortcuts/contract/operations/recommend.js +78 -0
  98. package/dist/shortcuts/contract/operations/registry.js +18 -0
  99. package/dist/shortcuts/contract/operations/review.js +83 -0
  100. package/dist/shortcuts/contract/operations/shared.js +37 -0
  101. package/dist/shortcuts/contract/operations/upload.js +108 -0
  102. package/dist/shortcuts/contract/operations/write.js +3 -2
  103. package/dist/shortcuts/index.js +140 -40
  104. package/dist/shortcuts/invoice/host.js +2 -1
  105. package/dist/shortcuts/invoice/manifest.js +36 -12
  106. package/dist/shortcuts/invoice/operations/issuing-qys.js +132 -36
  107. package/dist/shortcuts/invoice/operations/reim-auto.js +9 -0
  108. package/dist/shortcuts/invoice/operations/reim.js +81 -5
  109. package/dist/shortcuts/invoice/operations/shared.js +12 -5
  110. package/dist/shortcuts/meeting/host.js +45 -3
  111. package/dist/shortcuts/meeting/invitation/docx.js +442 -0
  112. package/dist/shortcuts/meeting/operations/attachment-content.js +418 -0
  113. package/dist/shortcuts/meeting/operations/attachment.js +442 -0
  114. package/dist/shortcuts/meeting/operations/eb/cache.js +57 -0
  115. package/dist/shortcuts/meeting/operations/eb/catalog.js +343 -28
  116. package/dist/shortcuts/meeting/operations/eb/conflict.js +372 -11
  117. package/dist/shortcuts/meeting/operations/eb/create-flow.js +710 -0
  118. package/dist/shortcuts/meeting/operations/eb/decision.js +47 -1
  119. package/dist/shortcuts/meeting/operations/eb/factory.js +129 -11
  120. package/dist/shortcuts/meeting/operations/eb/index.js +122 -2
  121. package/dist/shortcuts/meeting/operations/eb/room-recommend.js +378 -0
  122. package/dist/shortcuts/meeting/operations/eb/room-summary.js +84 -0
  123. package/dist/shortcuts/meeting/operations/eb/schedule.js +450 -0
  124. package/dist/shortcuts/meeting/operations/from-group-chat.js +576 -0
  125. package/dist/shortcuts/meeting/operations/invitation.js +458 -0
  126. package/dist/shortcuts/meeting/operations/minute-content.js +266 -0
  127. package/dist/shortcuts/meeting/operations/pipeline.js +489 -0
  128. package/dist/shortcuts/meeting/operations/qrcode.js +131 -0
  129. package/dist/shortcuts/meeting/operations/receipts.js +1 -1
  130. package/dist/shortcuts/meeting/operations/registry.js +18 -0
  131. package/dist/shortcuts/meeting/operations/summary.js +276 -0
  132. package/dist/shortcuts/meeting/operations/task-notify.js +325 -0
  133. package/dist/shortcuts/meeting/operations.js +42 -1
  134. package/dist/shortcuts/meeting/qr/encoder.js +427 -0
  135. package/dist/shortcuts/meeting/qr/render.js +103 -0
  136. package/dist/shortcuts/workflow/index.js +3 -0
  137. package/dist/shortcuts/workflow/operations/form.js +17 -5
  138. package/dist/shortcuts/workflow/operations/read.js +13 -6
  139. package/dist/shortcuts/workflow/operations/registry.js +2 -0
  140. package/dist/shortcuts/workflow/operations/todoSmartConvert/businessRules.js +331 -0
  141. package/dist/shortcuts/workflow/operations/todoSmartConvert/detailFieldRules.js +133 -0
  142. package/dist/shortcuts/workflow/operations/todoSmartConvert/summaryCache.js +326 -0
  143. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoDetailCache.js +113 -0
  144. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoDetailFetcher.js +259 -0
  145. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoListRows.js +64 -0
  146. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoOutputPlanner.js +28 -0
  147. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.aggregate.js +70 -0
  148. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +267 -0
  149. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +392 -0
  150. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.detail.js +165 -0
  151. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.group.js +448 -0
  152. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.groupSummary.js +348 -0
  153. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +222 -0
  154. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.pipeline.js +66 -0
  155. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.smartGroup.js +502 -0
  156. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.summary.js +540 -0
  157. package/docs/_catalog.md +1 -0
  158. package/docs/contract.md +39 -4
  159. package/docs/invoice.md +7 -7
  160. package/docs/todo-smart-convert/README.md +171 -0
  161. package/docs/todo-smart-convert/data-contract.md +236 -0
  162. package/docs/todo-smart-convert/mock/ai-todo-query-target.json +209 -0
  163. package/docs/todo-smart-convert/subgroup-rules.md +245 -0
  164. package/package.json +3 -2
  165. package/scripts/bundle.mjs +63 -0
  166. package/scripts/package-skill.mjs +1 -1
  167. package/skill-template/business-info.json +25 -4
  168. package/skill-template/domains/jinchengda.md +16 -3
  169. package/skill-template/domains/yepiaotong.md +3 -3
  170. package/skills/weaver-e10-jinchengda/SKILL.md +111 -31
  171. package/skills/weaver-e10-jinchengda/references/contract-agent-entry.md +7 -13
  172. package/skills/weaver-e10-jinchengda/references/contract-ai-assistant.md +150 -0
  173. package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +87 -0
  174. package/skills/weaver-e10-jinchengda/references/contract-clause-library-crud.md +111 -0
  175. package/skills/weaver-e10-jinchengda/references/contract-clause-recommender.md +0 -15
  176. package/skills/weaver-e10-jinchengda/references/contract-clause-reference-save.md +0 -13
  177. package/skills/weaver-e10-jinchengda/references/contract-credit-page.md +50 -0
  178. package/skills/weaver-e10-jinchengda/references/contract-disabled-capabilities.md +4 -2
  179. package/skills/weaver-e10-jinchengda/references/contract-doc-compare.md +74 -0
  180. package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +84 -0
  181. package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +29 -0
  182. package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +28 -0
  183. package/skills/weaver-e10-jinchengda/references/contract-request-status.md +2 -21
  184. package/skills/weaver-e10-jinchengda/references/contract-request-write.md +0 -24
  185. package/skills/weaver-e10-jinchengda/references/contract-signing-subjects.md +0 -15
  186. package/skills/weaver-e10-jinchengda/references/contract-subject-create.md +0 -17
  187. package/skills/weaver-e10-jinchengda/references/contract-template-recommend.md +70 -0
  188. package/skills/weaver-e10-jinchengda/references/contract-template-selector.md +0 -15
  189. package/skills/weaver-e10-jinchengda/references/contract-workflow-discovery.md +0 -15
  190. package/skills/weaver-e10-jinchengda/references/source-manifest.json +1168 -152
  191. package/skills/weaver-e10-meeting/SKILL.md +493 -17
  192. package/skills/weaver-e10-meeting/references/meeting-change.md +4 -4
  193. package/skills/weaver-e10-meeting/references/meeting-create.md +6 -6
  194. package/skills/weaver-e10-meeting/references/meeting-eb.md +503 -27
  195. package/skills/weaver-e10-meeting/references/meeting-invitation.md +113 -0
  196. package/skills/weaver-e10-meeting/references/meeting-lifecycle.md +6 -6
  197. package/skills/weaver-e10-meeting/references/meeting-minute-file.md +425 -0
  198. package/skills/weaver-e10-meeting/references/meeting-queries.md +4 -4
  199. package/skills/weaver-e10-meeting/references/meeting-receipts-signs.md +15 -15
  200. package/skills/weaver-e10-meeting/references/meeting-verification.md +19 -11
  201. package/skills/weaver-e10-meeting.zip +0 -0
  202. package/skills/weaver-e10-workflow/SKILL.md +23 -1
  203. package/skills/weaver-e10-workflow/references/todo-smart-convert.md +282 -0
  204. package/skills/weaver-e10-workflow/scripts/todo-summary.cjs +695 -0
  205. package/skills/weaver-e10-yepiaotong/SKILL.md +15 -11
  206. package/skills/weaver-e10-yepiaotong/references/invoice-enterprise-list.md +1 -1
  207. package/skills/weaver-e10-yepiaotong/references/invoice-issuing-examples.md +10 -7
  208. package/skills/weaver-e10-yepiaotong/references/invoice-issuing-form-fill-rules.md +41 -14
  209. package/skills/weaver-e10-yepiaotong/references/invoice-issuing-workflow.md +54 -26
  210. package/skills/weaver-e10-yepiaotong/references/invoice-personal-list.md +6 -5
  211. package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +14 -11
  212. package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +97 -56
  213. package/skills/weaver-e10-yepiaotong/references/reim-examples.md +84 -60
  214. package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +142 -105
  215. package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +53 -194
  216. package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +7 -7
  217. package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +164 -72
  218. package/skills/weaver-e10-yepiaotong/references/source-manifest.json +8 -2
  219. package/templates/meeting/invitation.docx +0 -0
@@ -0,0 +1,1940 @@
1
+ import { createRequire as __esbuildCreateRequire } from 'node:module';
2
+ const require = __esbuildCreateRequire(import.meta.url);
3
+ import {
4
+ E10ApiError,
5
+ createE10RequestRuntime,
6
+ requireE10Session
7
+ } from "./chunk-H3WDBYJW.js";
8
+ import {
9
+ E10_SESSION_EXPIRED_MESSAGE,
10
+ getActiveProfile
11
+ } from "./chunk-324YPTC2.js";
12
+ import {
13
+ CliError,
14
+ isCliError,
15
+ toErrorEnvelope
16
+ } from "./chunk-LUSPKZKY.js";
17
+ import "./chunk-BUSC6UAE.js";
18
+
19
+ // src/shortcuts/jiuchuanhui/index.ts
20
+ import { readFile as readFile2 } from "node:fs/promises";
21
+
22
+ // src/shortcuts/jiuchuanhui/continuation.ts
23
+ import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
24
+ import { existsSync } from "node:fs";
25
+ import { chmod, mkdir, readFile, writeFile } from "node:fs/promises";
26
+ import { homedir } from "node:os";
27
+ import { resolve } from "node:path";
28
+
29
+ // src/shortcuts/jiuchuanhui/errors.ts
30
+ var JiuchuanhuiCliError = class extends CliError {
31
+ type;
32
+ subtype;
33
+ code;
34
+ retryable;
35
+ stage;
36
+ details;
37
+ partialData;
38
+ constructor(type, subtype, message, options = {}) {
39
+ super(message, options.exitCode ?? 5 /* InternalError */);
40
+ this.name = "JiuchuanhuiCliError";
41
+ this.type = type;
42
+ this.subtype = subtype;
43
+ this.code = options.code;
44
+ this.retryable = options.retryable ?? false;
45
+ this.stage = options.stage;
46
+ this.details = options.details;
47
+ this.partialData = options.partialData;
48
+ }
49
+ };
50
+ function jiuchuanhuiValidationError(subtype, message, details) {
51
+ return new JiuchuanhuiCliError("validation", subtype, message, {
52
+ details,
53
+ exitCode: 2 /* UsageError */
54
+ });
55
+ }
56
+ function jiuchuanhuiAuthError(subtype, message, details) {
57
+ return new JiuchuanhuiCliError("authentication", subtype, message, {
58
+ details,
59
+ exitCode: 3 /* AuthError */
60
+ });
61
+ }
62
+ function jiuchuanhuiNetworkError(subtype, message, options = {}) {
63
+ return new JiuchuanhuiCliError("network", subtype, message, {
64
+ ...options,
65
+ retryable: options.retryable ?? true,
66
+ exitCode: 4 /* NetworkError */
67
+ });
68
+ }
69
+ function jiuchuanhuiConfirmationError(action, details) {
70
+ return new JiuchuanhuiCliError("confirmation", "required", "\u8BE5\u64CD\u4F5C\u9700\u8981\u660E\u786E\u786E\u8BA4", {
71
+ details: { action, ...details },
72
+ exitCode: 10 /* ConfirmationRequired */
73
+ });
74
+ }
75
+ function jiuchuanhuiPartialError(message, partialData, details) {
76
+ return new JiuchuanhuiCliError("partial", "write_uncertain", message, {
77
+ details,
78
+ partialData,
79
+ exitCode: 11 /* Partial */
80
+ });
81
+ }
82
+ function isJiuchuanhuiNetworkError(error) {
83
+ return Boolean(
84
+ error && typeof error === "object" && "type" in error && error.type === "network"
85
+ );
86
+ }
87
+
88
+ // src/shortcuts/jiuchuanhui/continuation.ts
89
+ function stateRoot(ctx) {
90
+ const configured = ctx?.config?.path();
91
+ if (configured) return resolve(configured, "..");
92
+ return process.env.WEAVER_WORK_CLI_HOME || process.env.WORK_CLI_HOME || resolve(homedir(), ".weaver-work-cli");
93
+ }
94
+ async function loadKey(ctx) {
95
+ const keysDir = resolve(stateRoot(ctx), "keys");
96
+ const filename = resolve(keysDir, "jiuchuanhui-continuation.key");
97
+ await mkdir(keysDir, { recursive: true, mode: 448 });
98
+ if (existsSync(filename)) return readFile(filename);
99
+ const key = randomBytes(32);
100
+ try {
101
+ await writeFile(filename, key, { flag: "wx", mode: 384 });
102
+ if (process.platform !== "win32") await chmod(filename, 384).catch(() => void 0);
103
+ return key;
104
+ } catch {
105
+ return readFile(filename);
106
+ }
107
+ }
108
+ function encode(value) {
109
+ return Buffer.from(JSON.stringify(value)).toString("base64url");
110
+ }
111
+ function signature(payload, key) {
112
+ return createHmac("sha256", key).update(payload).digest("base64url");
113
+ }
114
+ function createJiuchuanhuiContinuationSigner(ctx) {
115
+ return {
116
+ async issue(payload, ttlMs = 10 * 6e4) {
117
+ const issuedAt = Date.now();
118
+ const body = encode({ ...payload, issuedAt, expiresAt: issuedAt + ttlMs });
119
+ const sig = signature(body, await loadKey(ctx));
120
+ return `${body}.${sig}`;
121
+ },
122
+ async verify(token, expectedOperation) {
123
+ if (typeof token !== "string" || !token.includes(".")) {
124
+ throw jiuchuanhuiValidationError("continuation_invalid", "continuation \u65E0\u6548");
125
+ }
126
+ const [body, provided] = token.split(".");
127
+ const expected = signature(body, await loadKey(ctx));
128
+ const valid = provided.length === expected.length && timingSafeEqual(Buffer.from(provided), Buffer.from(expected));
129
+ if (!valid) throw jiuchuanhuiValidationError("continuation_invalid", "continuation \u7B7E\u540D\u6821\u9A8C\u5931\u8D25");
130
+ let value;
131
+ try {
132
+ value = JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
133
+ } catch {
134
+ throw jiuchuanhuiValidationError("continuation_invalid", "continuation \u5185\u5BB9\u65E0\u6CD5\u89E3\u6790");
135
+ }
136
+ if (value.operation !== expectedOperation) {
137
+ throw jiuchuanhuiValidationError("continuation_mismatch", "continuation \u4E0D\u5C5E\u4E8E\u5F53\u524D\u64CD\u4F5C");
138
+ }
139
+ if (!Number.isSafeInteger(value.expiresAt) || value.expiresAt < Date.now()) {
140
+ throw jiuchuanhuiValidationError("continuation_expired", "continuation \u5DF2\u8FC7\u671F");
141
+ }
142
+ return value;
143
+ }
144
+ };
145
+ }
146
+
147
+ // src/shortcuts/jiuchuanhui/host.ts
148
+ function inferProfile(ctx) {
149
+ const options = ctx.getGlobalOptions();
150
+ return options.profile || getActiveProfile();
151
+ }
152
+ function isJiuchuanhuiSuccess(value) {
153
+ if (!value || typeof value !== "object") return false;
154
+ if (value.resultCode !== void 0 && value.resultCode !== null) return Number(value.resultCode) === 200;
155
+ if (value.datajson && typeof value.datajson === "object") {
156
+ const status = value.datajson.status;
157
+ if (status === "true" || status === true) return true;
158
+ if (status === "false" || status === false) return false;
159
+ }
160
+ const code = value.code ?? value.res_base?.ret;
161
+ if (code !== void 0 && code !== null) return Number(code) === 0 || Number(code) === 200;
162
+ if (typeof value.success === "boolean") return value.success;
163
+ return false;
164
+ }
165
+ function jiuchuanhuiBusinessMessage(value) {
166
+ if (!value || typeof value !== "object") return "\u6CDB\u5FAE\u63A5\u53E3\u8FD4\u56DE\u4E1A\u52A1\u5931\u8D25";
167
+ const candidates = [
168
+ value.resultMsg,
169
+ value.msg,
170
+ value.message,
171
+ value.res_base?.message,
172
+ value.datajson?.message,
173
+ value.data?.message
174
+ ];
175
+ for (const item of candidates) {
176
+ if (typeof item === "string" && item.trim()) return item;
177
+ }
178
+ return "\u6CDB\u5FAE\u63A5\u53E3\u8FD4\u56DE\u4E1A\u52A1\u5931\u8D25";
179
+ }
180
+ function businessCode(value) {
181
+ if (!value || typeof value !== "object") return void 0;
182
+ const code = value.resultCode ?? value.code ?? value.res_base?.ret;
183
+ if (typeof code === "string" || typeof code === "number") return code;
184
+ return void 0;
185
+ }
186
+ function assertJiuchuanhuiPath(requestPath) {
187
+ if (typeof requestPath !== "string" || !requestPath.startsWith("/") || requestPath.startsWith("//")) {
188
+ throw jiuchuanhuiValidationError("path_invalid", "\u8BF7\u6C42\u8DEF\u5F84\u5FC5\u987B\u662F\u76F8\u5BF9\u7EDD\u5BF9\u8DEF\u5F84");
189
+ }
190
+ if (/^https?:/i.test(requestPath) || /[\r\n]/.test(requestPath) || requestPath.includes("/../")) {
191
+ throw jiuchuanhuiValidationError("path_invalid", "\u8BF7\u6C42\u8DEF\u5F84\u4E0D\u5141\u8BB8\u8DE8\u57DF\u6216\u8DEF\u5F84\u9003\u9038");
192
+ }
193
+ if (!requestPath.startsWith("/api/")) {
194
+ throw jiuchuanhuiValidationError("path_not_allowed", "\u4E5D\u6C1A\u6C47\u53EA\u80FD\u8C03\u7528 /api/ \u8DEF\u5F84");
195
+ }
196
+ }
197
+ function omitEmptyQueryValues(query) {
198
+ if (!query) return void 0;
199
+ return Object.fromEntries(Object.entries(query).filter(([, value]) => value !== void 0 && value !== null));
200
+ }
201
+ function mapRuntimeNetworkError(error) {
202
+ if (error instanceof E10ApiError && error.type === "network") {
203
+ throw jiuchuanhuiNetworkError(error.subtype, error.message, {
204
+ retryable: error.retryable,
205
+ details: error.details
206
+ });
207
+ }
208
+ throw error;
209
+ }
210
+ function createJiuchuanhuiHost(ctx, dependencies = {}) {
211
+ let e10Session = null;
212
+ let sessionContext = null;
213
+ const requireSession = dependencies.requireSession || requireE10Session;
214
+ async function ensureSession() {
215
+ if (!e10Session) {
216
+ e10Session = await requireSession(ctx);
217
+ sessionContext = {
218
+ baseUrl: e10Session.getBaseUrl(),
219
+ profile: inferProfile(ctx),
220
+ userId: e10Session.userId,
221
+ eteamsId: e10Session.eteamsId,
222
+ tenantKey: e10Session.tenantKey,
223
+ tenantName: e10Session.tenantName
224
+ };
225
+ }
226
+ return e10Session;
227
+ }
228
+ async function getSession() {
229
+ await ensureSession();
230
+ return sessionContext;
231
+ }
232
+ async function runtime() {
233
+ return createE10RequestRuntime(ctx, await ensureSession(), {
234
+ interceptors: dependencies.interceptors,
235
+ fetch: dependencies.fetch
236
+ });
237
+ }
238
+ async function request(request2) {
239
+ const {
240
+ method,
241
+ path,
242
+ query,
243
+ body,
244
+ operation,
245
+ timeoutMs = 3e4
246
+ } = request2;
247
+ assertJiuchuanhuiPath(path);
248
+ const resolvedMethod = method || "POST";
249
+ let response;
250
+ try {
251
+ response = await (await runtime()).requestJson({
252
+ module: "jiuchuanhui",
253
+ operation,
254
+ method: resolvedMethod,
255
+ path,
256
+ query: omitEmptyQueryValues(query),
257
+ body,
258
+ timeoutMs
259
+ });
260
+ } catch (error) {
261
+ mapRuntimeNetworkError(error);
262
+ }
263
+ if (response.status === 401 || response.status === 302) {
264
+ throw jiuchuanhuiAuthError("session_expired", E10_SESSION_EXPIRED_MESSAGE, { httpStatus: response.status });
265
+ }
266
+ if (response.parseError) {
267
+ if (response.status < 200 || response.status >= 300) {
268
+ throw new JiuchuanhuiCliError("api", "http_error", `\u6CDB\u5FAE\u63A5\u53E3 HTTP ${response.status}`, {
269
+ code: response.status,
270
+ details: { status: response.status },
271
+ exitCode: 1
272
+ });
273
+ }
274
+ throw jiuchuanhuiNetworkError("protocol", `\u63A5\u53E3\u8FD4\u56DE\u4E0D\u662F\u5408\u6CD5 JSON\uFF08HTTP ${response.status}\uFF09`, { retryable: false });
275
+ }
276
+ if (response.status < 200 || response.status >= 300) {
277
+ throw new JiuchuanhuiCliError("api", "http_error", `\u6CDB\u5FAE\u63A5\u53E3 HTTP ${response.status}`, {
278
+ code: response.status,
279
+ details: { status: response.status, message: jiuchuanhuiBusinessMessage(response.value) },
280
+ exitCode: 1
281
+ });
282
+ }
283
+ if (!isJiuchuanhuiSuccess(response.value)) {
284
+ throw new JiuchuanhuiCliError("api", "business_error", jiuchuanhuiBusinessMessage(response.value), {
285
+ code: businessCode(response.value),
286
+ details: { code: businessCode(response.value), message: jiuchuanhuiBusinessMessage(response.value) },
287
+ exitCode: 1
288
+ });
289
+ }
290
+ return response.value;
291
+ }
292
+ return { request, getSession };
293
+ }
294
+
295
+ // src/shortcuts/jiuchuanhui/manifest.ts
296
+ var pageProps = {
297
+ pageNo: { type: "integer", minimum: 1, default: 1 },
298
+ pageSize: { type: "integer", minimum: 1, maximum: 200, default: 10 },
299
+ count: { type: "boolean", description: "\u662F\u5426\u5E76\u884C\u8BF7\u6C42\u603B\u6570\u63A5\u53E3" }
300
+ };
301
+ var idProp = { type: "string", pattern: "^[1-9]\\d*$" };
302
+ var formProp = {
303
+ type: "object",
304
+ additionalProperties: true,
305
+ description: "\u521B\u5EFA/\u66F4\u65B0\u8868\u5355\u6570\u636E\uFF1A{ mainTable, detail1?, detail2?, ... } \u6216 { datas: [...] }\u3002data_key \u4E0E\u660E\u7EC6\u8868\u540D\u4EE5\u7F13\u5B58 config/{pk}.json \u4E3A\u51C6\u3002"
306
+ };
307
+ var esbWriteProps = (keys) => {
308
+ const props = {};
309
+ for (const key of keys) props[key] = { type: "string", description: `\u52A8\u4F5C\u6D41\u4E1A\u52A1\u53C2\u6570 ${key}` };
310
+ return props;
311
+ };
312
+ var esbWriteSchema = (keys, required = keys) => ({
313
+ type: "object",
314
+ additionalProperties: false,
315
+ properties: esbWriteProps(keys),
316
+ required
317
+ });
318
+ function writePair(baseName, title, props, required = [], fixed = {}, withPrepare = true) {
319
+ const list = [];
320
+ if (withPrepare) {
321
+ list.push({
322
+ name: `${baseName}.prepare`,
323
+ risk: "read-before-write",
324
+ fixed: { ...fixed, stage: "prepare" },
325
+ inputSchema: {
326
+ type: "object",
327
+ additionalProperties: false,
328
+ properties: {
329
+ mainTable: {
330
+ type: "object",
331
+ additionalProperties: false,
332
+ properties: props,
333
+ ...required.length ? { required } : {}
334
+ }
335
+ },
336
+ required: ["mainTable"]
337
+ }
338
+ });
339
+ }
340
+ list.push({
341
+ name: `${baseName}.apply`,
342
+ risk: "high-risk-write",
343
+ fixed: { ...fixed, stage: "apply" },
344
+ inputSchema: {
345
+ type: "object",
346
+ additionalProperties: false,
347
+ properties: {
348
+ continuation: { type: "string", minLength: 1 },
349
+ confirm: { const: true }
350
+ },
351
+ required: ["continuation", "confirm"]
352
+ }
353
+ });
354
+ return list;
355
+ }
356
+ var jiuchuanhuiOperations = [
357
+ // ==================== 发现与配置 ====================
358
+ {
359
+ name: "jiuchuanhui.cache.init",
360
+ risk: "local-file-write",
361
+ fixed: { path: "local:cache", purpose: "\u4E5D\u6C1A\u6C47\u914D\u7F6E\u7F13\u5B58\u521D\u59CB\u5316/\u5237\u65B0" },
362
+ inputSchema: {
363
+ type: "object",
364
+ additionalProperties: false,
365
+ properties: {
366
+ dryRun: { type: "boolean", description: "\u53EA\u62C9\u53D6\u4E0D\u5199\u5165\uFF08\u9884\u89C8\uFF09" },
367
+ verbose: { type: "boolean", description: "\u8FD4\u56DE\u66F4\u591A\u6B65\u9AA4\u660E\u7EC6" }
368
+ }
369
+ }
370
+ },
371
+ {
372
+ name: "jiuchuanhui.app.discovery",
373
+ risk: "read",
374
+ fixed: { path: "/api/bs/ebuilder/app/tags/getAppIds", method: "GET" },
375
+ inputSchema: {
376
+ type: "object",
377
+ additionalProperties: false,
378
+ properties: { tag: { type: "string", default: "jch-crm-project" } }
379
+ }
380
+ },
381
+ {
382
+ name: "jiuchuanhui.form.discovery",
383
+ risk: "read",
384
+ fixed: { path: "/api/ebuilder/form/obj/getObjsByTag", method: "GET" },
385
+ inputSchema: {
386
+ type: "object",
387
+ additionalProperties: false,
388
+ properties: {
389
+ tag: { type: "string", description: "\u8868\u5355 tag\uFF0C\u5982 uf_jch_customer" },
390
+ appId: { type: "string" }
391
+ },
392
+ required: ["tag", "appId"]
393
+ }
394
+ },
395
+ {
396
+ name: "jiuchuanhui.field.options",
397
+ risk: "read",
398
+ fixed: { path: "/api/ebuilder/common/ds/options", method: "GET", sourceType: "FORM", optionLevel: 1 },
399
+ inputSchema: {
400
+ type: "object",
401
+ additionalProperties: false,
402
+ properties: {
403
+ fieldName: { type: "string", description: "\u5B57\u6BB5\u5143\u6570\u636EID\uFF08fieldid\uFF09\uFF0C\u4E0D\u662F data_key \u540D\u79F0" },
404
+ sourceType: { type: "string", default: "FORM" },
405
+ objId: { type: "string", description: "\u8868\u5355\u5BF9\u8C61ID\uFF0C\u53EF\u7701\u7565\u81EA\u52A8\u53D1\u73B0" },
406
+ groupId: { type: "string", description: "\u5E94\u7528\u5206\u7EC4ID\uFF0C\u53EF\u7701\u7565\u81EA\u52A8\u53D1\u73B0\uFF08\u9ED8\u8BA4\u6309 jch-crm-project \u53D1\u73B0\uFF09" }
407
+ },
408
+ required: ["fieldName", "sourceType"]
409
+ }
410
+ },
411
+ {
412
+ name: "jiuchuanhui.rest.cfg.detail",
413
+ risk: "read",
414
+ fixed: { path: "/api/bs/ebuilder/form/formdata/getRestCfgById", method: "GET" },
415
+ inputSchema: {
416
+ type: "object",
417
+ additionalProperties: false,
418
+ properties: {
419
+ apid: { type: "string", description: "\u5E94\u7528 ID" },
420
+ id: { type: "string", description: "\u63A5\u53E3\u914D\u7F6E ID (cfgId)" }
421
+ },
422
+ required: ["apid", "id"]
423
+ }
424
+ },
425
+ {
426
+ name: "jiuchuanhui.config.id.by.pk",
427
+ risk: "read",
428
+ fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "4F6E1A9702864666803CCA6B77B86227" },
429
+ inputSchema: {
430
+ type: "object",
431
+ additionalProperties: false,
432
+ properties: {
433
+ mainTable: {
434
+ type: "object",
435
+ additionalProperties: false,
436
+ properties: { interface_pk: { type: "string" } },
437
+ required: ["interface_pk"]
438
+ }
439
+ },
440
+ required: ["mainTable"]
441
+ }
442
+ },
443
+ {
444
+ name: "jiuchuanhui.file.preview",
445
+ risk: "read",
446
+ fixed: { path: "/api/file/preview", method: "GET", module: "ebuilderform", authModule: "ebuilderform", source: "form" },
447
+ inputSchema: {
448
+ type: "object",
449
+ additionalProperties: false,
450
+ properties: {
451
+ fileId: { type: "string" },
452
+ fieldId: { type: "string" },
453
+ appId: { type: "string" },
454
+ customParam: { type: ["string", "object"] }
455
+ },
456
+ required: ["fileId"]
457
+ }
458
+ },
459
+ // ==================== 客户 ====================
460
+ ...writePair("jiuchuanhui.customer.create", "\u5BA2\u6237\u521B\u5EFA", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/saveFormData/customer_create_api" }),
461
+ {
462
+ name: "jiuchuanhui.customer.get",
463
+ risk: "read",
464
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataByPk/customer_get_api" },
465
+ inputSchema: { type: "object", additionalProperties: false, properties: { id: idProp }, required: ["id"] }
466
+ },
467
+ {
468
+ name: "jiuchuanhui.customer.search",
469
+ risk: "read",
470
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_search_api", countPath: "/api/ebuilder/form/formdata/v2/getFormDataCount/ebcustomer_search_count_api" },
471
+ inputSchema: {
472
+ type: "object",
473
+ additionalProperties: true,
474
+ description: "\u641C\u7D22\u6761\u4EF6\u8D70 query\uFF1A\u652F\u6301 searchParams \u4E2D\u7684\u5B57\u6BB5\uFF08customer_name/status/type/managerid/...\uFF09\uFF0C\u4EE5\u53CA\u4E8B\u9879\u8303\u56F4 mine/all/customerSea\uFF08\u5FC5\u987B\u4E09\u9009\u4E00\u7F6E\u7A7A\u5176\u4F59\u4E3A -1\uFF09\u4E0E\u5206\u9875\u3002",
475
+ properties: pageProps
476
+ }
477
+ },
478
+ {
479
+ name: "jiuchuanhui.customer.type.search",
480
+ risk: "read",
481
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_type_search_api" },
482
+ inputSchema: { type: "object", additionalProperties: false, properties: pageProps }
483
+ },
484
+ {
485
+ name: "jiuchuanhui.customer.status.search",
486
+ risk: "read",
487
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_status_search_api" },
488
+ inputSchema: { type: "object", additionalProperties: false, properties: pageProps }
489
+ },
490
+ {
491
+ name: "jiuchuanhui.customer.industry.search",
492
+ risk: "read",
493
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_industry_search_api" },
494
+ inputSchema: { type: "object", additionalProperties: false, properties: pageProps }
495
+ },
496
+ {
497
+ name: "jiuchuanhui.customer.open-sea.search",
498
+ risk: "read",
499
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/customer_open_sea_search_api" },
500
+ inputSchema: { type: "object", additionalProperties: true, properties: pageProps }
501
+ },
502
+ ...writePair("jiuchuanhui.customer.update", "\u5BA2\u6237\u4FEE\u6539", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/updateFormData/customer_update_api" }),
503
+ ...writePair("jiuchuanhui.customer.transfer", "\u5BA2\u6237\u8F6C\u79FB", esbWriteProps(["customerId", "employee_MappingId", "employeeName"]), ["customerId"], { uniqueIndent: "1E44ED7DA9EB46329818E682C2914928" }),
504
+ ...writePair("jiuchuanhui.customer.open-sea.release", "\u5BA2\u6237\u91CA\u653E\u516C\u6D77", esbWriteProps(["customerId", "openSeaId"]), ["customerId", "openSeaId"], { uniqueIndent: "0E29AD0E708D4964B071D293288B92D7" }),
505
+ ...writePair("jiuchuanhui.customer.open-sea.claim", "\u9886\u53D6\u516C\u6D77\u5BA2\u6237", esbWriteProps(["customer_id"]), ["customer_id"], { uniqueIndent: "D587CDC892FE41118DD073475C01A2CE" }),
506
+ {
507
+ name: "jiuchuanhui.customer.duplicate.check",
508
+ risk: "read",
509
+ fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "D5D0A1C30E7B404B842987C0AD3B749D" },
510
+ inputSchema: {
511
+ type: "object",
512
+ additionalProperties: false,
513
+ properties: { mainTable: esbWriteSchema(["name", "simpleName"], ["name", "simpleName"]) },
514
+ required: ["mainTable"]
515
+ }
516
+ },
517
+ ...writePair("jiuchuanhui.customer.contact-record.create", "\u65B0\u5EFA\u5BA2\u6237\u8054\u7CFB\u8BB0\u5F55", esbWriteProps(["customerId", "comment_content", "type", "rating", "contact_information", "contacts", "next_time", "next_content", "next_contact_information", "next_contacts", "sync_salechance", "rel_remind"]), ["customerId", "comment_content"], { uniqueIndent: "C7A226EEE1324FF3B6E5BD18AF923DE7" }),
518
+ ...writePair("jiuchuanhui.customer.contact-record.batch", "\u6279\u91CF\u6DFB\u52A0\u5BA2\u6237\u8054\u7CFB\u8BB0\u5F55", esbWriteProps(["entityList", "content"]), ["entityList", "content"], { uniqueIndent: "D0F315619FE34C669AE738ED68329FAB" }),
519
+ // ==================== 联系人 ====================
520
+ ...writePair("jiuchuanhui.contact.create", "\u8054\u7CFB\u4EBA\u521B\u5EFA", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/saveFormData/contact_create_api" }),
521
+ {
522
+ name: "jiuchuanhui.contact.get",
523
+ risk: "read",
524
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataByPk/contact_get_api" },
525
+ inputSchema: { type: "object", additionalProperties: false, properties: { id: idProp }, required: ["id"] }
526
+ },
527
+ ...writePair("jiuchuanhui.contact.update", "\u8054\u7CFB\u4EBA\u4FEE\u6539", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/updateFormData/contact_update_api" }),
528
+ {
529
+ name: "jiuchuanhui.contact.by-entity.search",
530
+ risk: "read",
531
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcontact_search_by_entity_api" },
532
+ inputSchema: {
533
+ type: "object",
534
+ additionalProperties: true,
535
+ properties: { ...pageProps, customerId: { type: "string" }, saleChanceId: { type: "string" } }
536
+ }
537
+ },
538
+ // ==================== 商机 ====================
539
+ ...writePair("jiuchuanhui.sale.create", "\u5546\u673A\u521B\u5EFA", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/saveFormData/sale_create_api" }),
540
+ {
541
+ name: "jiuchuanhui.sale.get",
542
+ risk: "read",
543
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataByPk/sale_get_api" },
544
+ inputSchema: { type: "object", additionalProperties: false, properties: { id: idProp }, required: ["id"] }
545
+ },
546
+ {
547
+ name: "jiuchuanhui.sale.search",
548
+ risk: "read",
549
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebsale_search_api", countPath: "/api/ebuilder/form/formdata/v2/getFormDataCount/ebsale_search_count_api" },
550
+ inputSchema: { type: "object", additionalProperties: true, properties: pageProps }
551
+ },
552
+ ...writePair("jiuchuanhui.sale.update", "\u5546\u673A\u4FEE\u6539", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/updateFormData/sale_update_api" }),
553
+ {
554
+ name: "jiuchuanhui.sale.stage.search",
555
+ risk: "read",
556
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/sale_stage_search_api" },
557
+ inputSchema: { type: "object", additionalProperties: false, properties: pageProps }
558
+ },
559
+ {
560
+ name: "jiuchuanhui.sale.process.search",
561
+ risk: "read",
562
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/sale_process_sear_api" },
563
+ inputSchema: { type: "object", additionalProperties: false, properties: pageProps }
564
+ },
565
+ {
566
+ name: "jiuchuanhui.sale.lose-reason.search",
567
+ risk: "read",
568
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/sale_lose_reason" },
569
+ inputSchema: { type: "object", additionalProperties: false, properties: pageProps }
570
+ },
571
+ {
572
+ name: "jiuchuanhui.rival.search",
573
+ risk: "read",
574
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebrival_search_api" },
575
+ inputSchema: { type: "object", additionalProperties: false, properties: pageProps }
576
+ },
577
+ ...writePair("jiuchuanhui.sale.win", "\u5546\u673A\u8D62\u5355", esbWriteProps(["saleId"]), ["saleId"], { uniqueIndent: "3B23E782E5084F18A904E895BBD61A96" }),
578
+ ...writePair("jiuchuanhui.sale.lose", "\u5546\u673A\u8F93\u5355", esbWriteProps(["saleid", "money", "reasonids", "rivals", "desc"]), ["saleid"], { uniqueIndent: "DE35D926F82F49FDBA26B48B0CA1CB53" }),
579
+ ...writePair("jiuchuanhui.sale.invalid", "\u5546\u673A\u65E0\u6548", esbWriteProps(["saleId"]), ["saleId"], { uniqueIndent: "4D88AB8677D84BAC90B63137E7FA1FF9" }),
580
+ ...writePair("jiuchuanhui.sale.pause", "\u5546\u673A\u6682\u505C", esbWriteProps(["saleId", "pauseReason", "restartDate"]), ["saleId", "pauseReason"], { uniqueIndent: "859C73403DCC4F01B02329571BDBD9F3" }),
581
+ ...writePair("jiuchuanhui.sale.restart", "\u5546\u673A\u91CD\u542F", esbWriteProps(["saleChanceId"]), ["saleChanceId"], { uniqueIndent: "F3004CDCA8A548B5A0DACD3CDE62387A" }),
582
+ ...writePair("jiuchuanhui.sale.manager-change", "\u5546\u673A\u8F6C\u79FB/\u8D1F\u8D23\u4EBA\u53D8\u66F4", esbWriteProps(["saleChanceId", "managerId"]), ["saleChanceId", "managerId"], { uniqueIndent: "595F9C6F1C4248929B83086F71363BA7" }),
583
+ ...writePair("jiuchuanhui.sale.link-contacts", "\u5546\u673A\u5173\u8054\u8054\u7CFB\u4EBA", esbWriteProps(["salechanceId", "contactIds"]), ["salechanceId", "contactIds"], { uniqueIndent: "1114A713A62F4CA9899CC24ED5902D93" }),
584
+ ...writePair("jiuchuanhui.sale.contact-record.create", "\u65B0\u5EFA\u5546\u673A\u8054\u7CFB\u8BB0\u5F55", esbWriteProps(["saleId", "comment_content", "type", "rating", "contact_information", "contacts", "next_time", "next_content", "next_contact_information", "next_contacts", "rel_remind"]), ["saleId", "comment_content"], { uniqueIndent: "7BB3A1918186445F9E770862EFA7EDA9" }),
585
+ // ==================== 线索 ====================
586
+ ...writePair("jiuchuanhui.clue.create", "\u7EBF\u7D22\u521B\u5EFA", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/saveFormData/ebclue_ai_create_api" }),
587
+ {
588
+ name: "jiuchuanhui.clue.get",
589
+ risk: "read",
590
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataByPk/ebcluepool_ai_get_api" },
591
+ inputSchema: { type: "object", additionalProperties: false, properties: { id: idProp }, required: ["id"] }
592
+ },
593
+ {
594
+ name: "jiuchuanhui.clue.search",
595
+ risk: "read",
596
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebclue_ai_search_api", countPath: "/api/ebuilder/form/formdata/v2/getFormDataCount/ebclue_ai_search_count_api" },
597
+ inputSchema: { type: "object", additionalProperties: true, properties: pageProps }
598
+ },
599
+ {
600
+ name: "jiuchuanhui.clue.pool.search",
601
+ risk: "read",
602
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcluepool_ai_search_api" },
603
+ inputSchema: { type: "object", additionalProperties: true, properties: pageProps }
604
+ },
605
+ ...writePair("jiuchuanhui.clue.update", "\u7EBF\u7D22\u4FEE\u6539", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/updateFormData/ebclue_ai_update_api" }),
606
+ ...writePair("jiuchuanhui.clue.status-change", "\u7EBF\u7D22\u72B6\u6001\u53D8\u66F4", esbWriteProps(["clueid", "type", "newmanager", "desc"]), ["clueid", "type"], { uniqueIndent: "257CC8DE42234F9191439B229839B8A7" }),
607
+ ...writePair("jiuchuanhui.clue.to-customer", "\u7EBF\u7D22\u8F6C\u5DF2\u6709\u5BA2\u6237", esbWriteProps(["clueId", "customerId"]), ["clueId", "customerId"], { uniqueIndent: "00914C6415EB455DB7FCCC32DBE6E0C3" }),
608
+ ...writePair("jiuchuanhui.clue.contact-record.create", "\u65B0\u5EFA\u7EBF\u7D22\u8DDF\u8FDB\u8BB0\u5F55", esbWriteProps(["clueId", "content", "clueStatus_MappingId"]), ["clueId", "content"], { uniqueIndent: "B3DD120601344320A2B50A042B450681" }),
609
+ // ==================== 联系计划 ====================
610
+ ...writePair("jiuchuanhui.contact-plan.create", "\u521B\u5EFA\u8054\u7CFB\u8BA1\u5212", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/saveFormData/ebcontact_plan_create_api" }),
611
+ ...writePair("jiuchuanhui.contact-plan.complete", "\u5B8C\u6210\u8054\u7CFB\u8BA1\u5212", esbWriteProps(["planId"]), ["planId"], { uniqueIndent: "2595D3556CFC414F85B1A4A8D806EFE5" }),
612
+ // ==================== 联系记录 ====================
613
+ {
614
+ name: "jiuchuanhui.entity.contact-records.list",
615
+ risk: "read",
616
+ fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "364A9713D10C4997AF6EDCAA5296968E" },
617
+ inputSchema: {
618
+ type: "object",
619
+ additionalProperties: false,
620
+ properties: {
621
+ mainTable: {
622
+ type: "object",
623
+ additionalProperties: false,
624
+ properties: {
625
+ moduleType: { type: "string", description: "\u4E8B\u9879\u6A21\u5757\u6807\u8BC6\uFF1Acustomer=\u5BA2\u6237\u3001clue=\u7EBF\u7D22\u3001saleChance=\u5546\u673A" },
626
+ entityId: { type: "string" }
627
+ },
628
+ required: ["moduleType", "entityId"]
629
+ }
630
+ },
631
+ required: ["mainTable"]
632
+ }
633
+ },
634
+ {
635
+ name: "jiuchuanhui.contact-records.by-person-time.list",
636
+ risk: "read",
637
+ fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "D01DD00978524525AD8728BE1BF9FE79" },
638
+ inputSchema: {
639
+ type: "object",
640
+ additionalProperties: false,
641
+ properties: { mainTable: esbWriteSchema(["employeeId", "startData", "endData"]) },
642
+ required: ["mainTable"]
643
+ }
644
+ },
645
+ // ==================== 通用辅助 ====================
646
+ {
647
+ name: "jiuchuanhui.entity.id.by-name",
648
+ risk: "read",
649
+ fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "7EC1639D5AC24B4DBCEE8D2CB85D4025" },
650
+ inputSchema: {
651
+ type: "object",
652
+ additionalProperties: false,
653
+ properties: { mainTable: esbWriteSchema(["moduleType", "name"]) },
654
+ required: ["mainTable"]
655
+ }
656
+ },
657
+ {
658
+ name: "jiuchuanhui.user.id.by-name",
659
+ risk: "read",
660
+ fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "911C17207E2C4BD29379B5A4001B246E" },
661
+ inputSchema: {
662
+ type: "object",
663
+ additionalProperties: false,
664
+ properties: { mainTable: esbWriteSchema(["employeeName"]) },
665
+ required: ["mainTable"]
666
+ }
667
+ },
668
+ {
669
+ name: "jiuchuanhui.user.current-profile",
670
+ risk: "read",
671
+ fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "B8F7597190FF419FB9127D6C8272C4FE" },
672
+ inputSchema: { type: "object", additionalProperties: false, properties: {} }
673
+ },
674
+ {
675
+ name: "jiuchuanhui.entity.permission.judge",
676
+ risk: "read",
677
+ fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "6D369F0A84764051A5D7B5AA1245F49A" },
678
+ inputSchema: {
679
+ type: "object",
680
+ additionalProperties: false,
681
+ properties: { mainTable: esbWriteSchema(["moduleType", "entityId", "opType"]) },
682
+ required: ["mainTable"]
683
+ }
684
+ },
685
+ {
686
+ name: "jiuchuanhui.company.business-profile.query",
687
+ risk: "read",
688
+ fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "BAB4DBE204214BB395BA161620A4A1CD" },
689
+ inputSchema: {
690
+ type: "object",
691
+ additionalProperties: false,
692
+ properties: { mainTable: esbWriteSchema(["companyName"]) },
693
+ required: ["mainTable"]
694
+ }
695
+ },
696
+ {
697
+ name: "jiuchuanhui.field.info.by-ids",
698
+ risk: "read",
699
+ fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "10351A4DC8D4454A9F1957FBE647CD9F" },
700
+ inputSchema: {
701
+ type: "object",
702
+ additionalProperties: false,
703
+ properties: { mainTable: esbWriteSchema(["fieldids"]) },
704
+ required: ["mainTable"]
705
+ }
706
+ },
707
+ {
708
+ name: "jiuchuanhui.browser-option.search",
709
+ risk: "read",
710
+ fixed: { path: "/api/bcw/common/browser/complete/{customBrowserType}", method: "POST" },
711
+ inputSchema: {
712
+ type: "object",
713
+ additionalProperties: false,
714
+ properties: {
715
+ pathParams: {
716
+ type: "object",
717
+ additionalProperties: false,
718
+ properties: { customBrowserType: { type: "string" } },
719
+ required: ["customBrowserType"]
720
+ },
721
+ params: {
722
+ type: "object",
723
+ additionalProperties: true,
724
+ properties: { searchValue: { type: "string" } }
725
+ }
726
+ },
727
+ required: ["pathParams"]
728
+ }
729
+ },
730
+ {
731
+ name: "jiuchuanhui.get-rest-cfg-detail",
732
+ risk: "read",
733
+ fixed: { path: "/api/bs/ebuilder/form/formdata/getRestCfgById", method: "GET" },
734
+ inputSchema: {
735
+ type: "object",
736
+ additionalProperties: false,
737
+ properties: {
738
+ apid: { type: "string" },
739
+ id: { type: "string" }
740
+ },
741
+ required: ["apid", "id"]
742
+ }
743
+ }
744
+ ];
745
+ var jiuchuanhuiManifest = {
746
+ schemaVersion: 1,
747
+ name: "jiuchuanhui",
748
+ title: "\u6CDB\u5FAEE10\u4E5D\u6C1A\u6C47\u8425\u9500\u7BA1\u7406\uFF08\u5BA2\u6237/\u8054\u7CFB\u4EBA/\u5546\u673A/\u7EBF\u7D22/\u8054\u7CFB\u8BA1\u5212/\u516C\u6D77\uFF09",
749
+ version: "0.1.0",
750
+ host: "e10-jiuchuanhui",
751
+ status: "builtin",
752
+ sourceSkill: "weaver-e10-jiuchuanhui",
753
+ operations: jiuchuanhuiOperations,
754
+ withheldOperations: [
755
+ {
756
+ name: "jiuchuanhui.sale.stage-advance",
757
+ reason: "\u5546\u673A\u63A8\u8FDB\u9500\u552E\u9636\u6BB5\u4F9D\u8D56\u7F13\u5B58\u4E2D\u7684 sale_stage \u914D\u7F6E\u505A\u9636\u6BB5 ID \u6620\u5C04\u4E0E\u524D\u7F6E\u6821\u9A8C\uFF0C\u5C5E\u4E8E Skill \u7F16\u6392\u5C42\u804C\u8D23\uFF1BCLI \u66B4\u9732\u7684 sale.update \u4E0E sale.stage.search \u5DF2\u8986\u76D6\u57FA\u7840\u80FD\u529B\uFF0C\u9636\u6BB5\u63A8\u8FDB\u7684\u7EC4\u5408\u903B\u8F91\u4E0D\u5728 CLI \u786C\u7F16\u7801\u3002"
758
+ }
759
+ ]
760
+ };
761
+
762
+ // src/shortcuts/jiuchuanhui/cache.ts
763
+ import { existsSync as existsSync2, mkdirSync, readFileSync, writeFileSync } from "node:fs";
764
+ import { homedir as homedir2 } from "node:os";
765
+ import { join } from "node:path";
766
+ var APP_TAG = "jch-crm-project";
767
+ var MIN_VERSION = "1.5.11";
768
+ var MODULE_TAGS = [
769
+ "uf_jch_customer",
770
+ "uf_jch_sale",
771
+ "uf_jch_clue",
772
+ "uf_jch_contact",
773
+ "uf_jch_customer_open_sea",
774
+ "uf_jch_remind",
775
+ "uf_jch_rival",
776
+ "uf_jch_sale_process",
777
+ "uf_jch_sale_stage",
778
+ "uf_jch_clue_pool",
779
+ "uf_jch_lose_reason",
780
+ "uf_jch_customer_cmt",
781
+ "uf_jch_sale_cmt"
782
+ ];
783
+ var CREATE_PKS = ["customer_create_api", "sale_create_api", "ebclue_ai_create_api", "contact_create_api", "ebcontact_plan_create_api"];
784
+ var SEARCH_PKS = ["ebcustomer_search_api", "ebsale_search_api", "ebclue_ai_search_api"];
785
+ var UPDATE_PKS = ["customer_update_api", "sale_update_api", "ebclue_ai_update_api", "contact_update_api"];
786
+ var ALL_PKS = [...CREATE_PKS, ...SEARCH_PKS, ...UPDATE_PKS];
787
+ var PK_TO_TAG = {
788
+ customer_create_api: "uf_jch_customer",
789
+ sale_create_api: "uf_jch_sale",
790
+ ebclue_ai_create_api: "uf_jch_clue",
791
+ contact_create_api: "uf_jch_contact",
792
+ ebcontact_plan_create_api: "uf_jch_remind",
793
+ ebcustomer_search_api: "uf_jch_customer",
794
+ ebsale_search_api: "uf_jch_sale",
795
+ ebclue_ai_search_api: "uf_jch_clue",
796
+ customer_update_api: "uf_jch_customer",
797
+ sale_update_api: "uf_jch_sale",
798
+ ebclue_ai_update_api: "uf_jch_clue",
799
+ contact_update_api: "uf_jch_contact"
800
+ };
801
+ var DETAIL_KEEP_KEYS = ["id", "interfacePk", "interfaceName", "datasNumber", "datasSize", "mainFields", "detailFields", "interfaceType", "relevanceForm"];
802
+ var FIELD_KEEP_KEYS = ["fieldid", "isRequired", "isInput", "data_key", "title", "component_type"];
803
+ var OPT_COMP = ["Select", "RadioBox", "CheckBox"];
804
+ var EBUILDER_QUERIES = [
805
+ { key: "customer_open_sea", path: "/api/ebuilder/form/formdata/v2/getFormDataList/customer_open_sea_search_api", nameFields: ["open_sea_name", "name"] },
806
+ { key: "sale_stage", path: "/api/ebuilder/form/formdata/v2/getFormDataList/sale_stage_search_api", nameFields: ["stage_name", "name"] },
807
+ { key: "sale_process", path: "/api/ebuilder/form/formdata/v2/getFormDataList/sale_process_sear_api", nameFields: ["process_name", "name"] },
808
+ { key: "clue_pool", path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcluepool_ai_search_api", nameFields: ["clue_pool_name", "name"] },
809
+ { key: "sale_lose_reason", path: "/api/ebuilder/form/formdata/v2/getFormDataList/sale_lose_reason", nameFields: ["reason_name", "name"] },
810
+ { key: "customer_industry", path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_industry_search_api", nameFields: ["industry_name", "name"] },
811
+ { key: "customer_type", path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_type_search_api", nameFields: ["type_name", "name"] },
812
+ { key: "customer_status", path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_status_search_api", nameFields: ["state_name", "name"] }
813
+ ];
814
+ var REGION_CITIES = [
815
+ "\u5317\u4EAC\u5E02",
816
+ "\u4E0A\u6D77\u5E02",
817
+ "\u5929\u6D25\u5E02",
818
+ "\u91CD\u5E86\u5E02",
819
+ "\u6210\u90FD\u5E02",
820
+ "\u5E7F\u5DDE\u5E02",
821
+ "\u6DF1\u5733\u5E02",
822
+ "\u4E1C\u839E\u5E02",
823
+ "\u676D\u5DDE\u5E02",
824
+ "\u5357\u4EAC\u5E02",
825
+ "\u82CF\u5DDE\u5E02",
826
+ "\u6B66\u6C49\u5E02",
827
+ "\u957F\u6C99\u5E02",
828
+ "\u897F\u5B89\u5E02",
829
+ "\u90D1\u5DDE\u5E02",
830
+ "\u6D4E\u5357\u5E02",
831
+ "\u9752\u5C9B\u5E02",
832
+ "\u53A6\u95E8\u5E02",
833
+ "\u798F\u5DDE\u5E02",
834
+ "\u5408\u80A5\u5E02",
835
+ "\u6C88\u9633\u5E02",
836
+ "\u5927\u8FDE\u5E02"
837
+ ];
838
+ function pickKeys(obj, keys) {
839
+ const out = {};
840
+ for (const k of keys) if (obj?.[k] !== void 0) out[k] = obj[k];
841
+ return out;
842
+ }
843
+ var isInputOne = (f) => String(f?.isInput) === "1";
844
+ function semverGte(a, b) {
845
+ const pa = String(a || "").split(".").map((x) => parseInt(x, 10) || 0);
846
+ const pb = b.split(".").map((x) => parseInt(x, 10) || 0);
847
+ for (let i = 0; i < 3; i++) {
848
+ if ((pa[i] || 0) !== (pb[i] || 0)) return (pa[i] || 0) > (pb[i] || 0);
849
+ }
850
+ return true;
851
+ }
852
+ function successCheck(value) {
853
+ if (!value || typeof value !== "object") return false;
854
+ if (value.resultCode !== void 0 && value.resultCode !== null) return Number(value.resultCode) === 200;
855
+ if (value.datajson && typeof value.datajson === "object") {
856
+ const status = value.datajson.status;
857
+ if (status === "true" || status === true) return true;
858
+ if (status === "false" || status === false) return false;
859
+ }
860
+ const code = value.code ?? value.res_base?.ret;
861
+ if (code !== void 0 && code !== null) return Number(code) === 0 || Number(code) === 200;
862
+ return typeof value.success === "boolean" ? value.success : false;
863
+ }
864
+ var CacheInitOperation = class {
865
+ name = "jiuchuanhui.cache.init";
866
+ async execute(input, { host }) {
867
+ const dryRun = input.dryRun === true;
868
+ const verbose = input.verbose === true;
869
+ const session = await host.getSession();
870
+ const tenantKey = session.tenantKey || "";
871
+ const userId = session.userId || "";
872
+ if (!tenantKey || !userId) {
873
+ throw jiuchuanhuiValidationError("session_context_missing", "\u65E0\u6CD5\u83B7\u53D6\u7F13\u5B58\u9694\u79BB\u4E0A\u4E0B\u6587\uFF1Asession \u7F3A\u5C11 tenantKey/userId\uFF0C\u8BF7\u786E\u8BA4 E10 \u767B\u5F55\u6001");
874
+ }
875
+ const baseDir = join(process.env.WEAVER_E10_JIUCHUANHUI_HOME || join(homedir2(), ".weaver-e10-jiuchuanhui"), tenantKey, String(userId));
876
+ const mainFile = join(baseDir, "weaver-e10-jiuchuanhui.json");
877
+ const cfgDir = join(baseDir, "config");
878
+ let old = {};
879
+ if (existsSync2(mainFile)) {
880
+ try {
881
+ old = JSON.parse(readFileSync(mainFile, "utf-8"));
882
+ } catch {
883
+ }
884
+ }
885
+ const discovery = {};
886
+ const appResp = await host.request({
887
+ method: "GET",
888
+ path: "/api/bs/ebuilder/app/tags/getAppIds",
889
+ query: { tag: APP_TAG },
890
+ operation: this.name
891
+ });
892
+ if (!successCheck(appResp)) throw jiuchuanhuiValidationError("init_failed", "app.discovery \u672A\u6210\u529F\uFF0C\u65E0\u6CD5\u521D\u59CB\u5316\u7F13\u5B58");
893
+ const rawApp = appResp?.data ?? appResp?.datajson?.datas;
894
+ const appId = Array.isArray(rawApp) && rawApp[0] ? String(rawApp[0]) : null;
895
+ if (!appId) throw jiuchuanhuiValidationError("init_failed", "\u6B65\u9AA4 1 \u672A\u53D6\u5F97 appId\uFF0C\u8BF7\u68C0\u67E5 E10 \u767B\u5F55\u6001");
896
+ discovery[`appId:${APP_TAG}`] = appId;
897
+ for (const tag of MODULE_TAGS) {
898
+ const resp = await host.request({
899
+ method: "GET",
900
+ path: "/api/ebuilder/form/obj/getObjsByTag",
901
+ query: { tag, appId },
902
+ operation: this.name
903
+ });
904
+ const list = Array.isArray(resp?.data) ? resp.data : resp?.datajson?.datas ?? [];
905
+ const hit = list.find((o) => o?.formId && String(o.formId) !== "0") ?? list?.[0];
906
+ if (hit?.id) discovery[`objId:${tag}`] = String(hit.id);
907
+ }
908
+ try {
909
+ const spResp = await host.request({
910
+ method: "GET",
911
+ path: "/api/installer/public/querySpAppVersionInfo",
912
+ query: { appId },
913
+ operation: this.name
914
+ });
915
+ const sp = spResp?.data;
916
+ const commitVersion = typeof sp === "object" && sp !== null ? String(sp.commitVersion ?? sp.version ?? "") : "";
917
+ if (commitVersion) {
918
+ discovery[`spVersion:${APP_TAG}`] = { commitVersion, passed: semverGte(commitVersion, MIN_VERSION) };
919
+ }
920
+ } catch {
921
+ }
922
+ const cfgMap = {};
923
+ for (const pk of ALL_PKS) {
924
+ const resp = await host.request({
925
+ path: "/api/esb/server/event/triggerActionFlow",
926
+ body: { customParams: { mainTable: { interface_pk: pk } }, uniqueIndent: "4F6E1A9702864666803CCA6B77B86227", employeeId: userId },
927
+ operation: this.name
928
+ });
929
+ const cfgId = resp?.actionData?.responseData?.customData?.mainTable?.cfgId ?? resp?.customData?.mainTable?.cfgId ?? resp?.datajson?.mainTable?.cfgId ?? resp?.data?.mainTable?.cfgId ?? resp?.mainTable?.cfgId;
930
+ if (cfgId) cfgMap[pk] = String(cfgId);
931
+ }
932
+ const perPk = {};
933
+ for (const pk of Object.keys(cfgMap)) {
934
+ const cfgId = cfgMap[pk];
935
+ const resp = await host.request({
936
+ method: "GET",
937
+ path: "/api/bs/ebuilder/form/formdata/getRestCfgById",
938
+ query: { apid: appId, id: cfgId },
939
+ operation: this.name
940
+ });
941
+ const detail = resp?.data ?? {};
942
+ if (!detail?.id && !detail?.mainFields) continue;
943
+ const allFields = [
944
+ ...detail.mainFields || [],
945
+ ...(detail.detailFields || []).flatMap((df) => df.fields || [])
946
+ ];
947
+ const fieldIds = [...new Set(allFields.filter(isInputOne).map((f) => String(f.fieldid)).filter(Boolean))];
948
+ const infoMap = /* @__PURE__ */ new Map();
949
+ if (fieldIds.length > 0) {
950
+ try {
951
+ const infoResp = await host.request({
952
+ path: "/api/esb/server/event/triggerActionFlow",
953
+ body: { customParams: { mainTable: { fieldids: fieldIds.join(",") } }, uniqueIndent: "10351A4DC8D4454A9F1957FBE647CD9F", employeeId: userId },
954
+ operation: this.name
955
+ });
956
+ const list = infoResp?.actionData?.responseData?.customData?.mainTable?.fieldInfoList ?? infoResp?.customData?.mainTable?.fieldInfoList ?? infoResp?.datajson?.mainTable?.fieldInfoList ?? infoResp?.fieldInfoList ?? [];
957
+ for (const it of list) infoMap.set(String(it.id), it);
958
+ } catch {
959
+ }
960
+ }
961
+ const merge = (f) => {
962
+ const info = infoMap.get(String(f?.fieldid));
963
+ if (info) {
964
+ f.data_key = info.data_key ?? f.data_key;
965
+ f.title = info.title ?? f.title;
966
+ f.component_type = info.component_type ?? f.component_type;
967
+ }
968
+ };
969
+ detail.mainFields = (detail.mainFields || []).filter(isInputOne);
970
+ detail.detailFields = (detail.detailFields || []).map((df) => ({ ...df, fields: (df.fields || []).filter(isInputOne) })).filter((df) => Array.isArray(df.fields) && df.fields.length > 0);
971
+ for (const f of detail.mainFields) merge(f);
972
+ for (const df of detail.detailFields) for (const f of df.fields) merge(f);
973
+ const kept = pickKeys(detail, DETAIL_KEEP_KEYS);
974
+ if (Array.isArray(kept.mainFields)) kept.mainFields = kept.mainFields.map((f) => pickKeys(f, FIELD_KEEP_KEYS));
975
+ if (Array.isArray(kept.detailFields)) {
976
+ kept.detailFields = kept.detailFields.map((df) => ({
977
+ ...pickKeys(df, ["id", "fieldName", "title", "fields"]),
978
+ fields: Array.isArray(df.fields) ? df.fields.map((f) => pickKeys(f, FIELD_KEEP_KEYS)) : []
979
+ }));
980
+ }
981
+ perPk[pk] = { cfgId, detail: kept };
982
+ }
983
+ const ebuilder = {};
984
+ for (const { key, path, nameFields } of EBUILDER_QUERIES) {
985
+ const list = [];
986
+ let pageNo = 1;
987
+ for (; ; ) {
988
+ const resp = await host.request({
989
+ path,
990
+ body: { datajson: { mainTable: {}, pageInfo: { pageNo, pageSize: 100 }, header: { operator: userId } } },
991
+ operation: this.name
992
+ });
993
+ const items = resp?.datajson?.datas ?? resp?.data ?? [];
994
+ list.push(...Array.isArray(items) ? items : []);
995
+ const hasMore = resp?.hasMore ?? (Array.isArray(items) && items.length === 100);
996
+ if (!hasMore || list.length >= 500 || pageNo >= 5) break;
997
+ pageNo += 1;
998
+ }
999
+ ebuilder[key] = list.map((it) => {
1000
+ const mt = it?.mainTable ?? it ?? {};
1001
+ let name = "";
1002
+ for (const nf of nameFields) {
1003
+ if (mt[nf] !== void 0 && mt[nf] !== null && String(mt[nf]) !== "") {
1004
+ name = String(mt[nf]);
1005
+ break;
1006
+ }
1007
+ }
1008
+ const item = { id: String(mt.id ?? ""), name };
1009
+ if (key === "sale_stage" && mt.sale_process !== void 0) {
1010
+ const sp = Array.isArray(mt.sale_process) ? mt.sale_process[0] : mt.sale_process;
1011
+ if (sp && typeof sp === "object") item.sale_process = { id: String(sp.id ?? ""), name: String(sp.name ?? "") };
1012
+ }
1013
+ return item;
1014
+ }).filter((x) => x.id);
1015
+ }
1016
+ const options = {};
1017
+ for (const pk of Object.keys(perPk)) {
1018
+ const tag = PK_TO_TAG[pk];
1019
+ const objId = discovery[`objId:${tag}`];
1020
+ if (!objId) continue;
1021
+ const detail = perPk[pk].detail ?? {};
1022
+ const fields = [
1023
+ ...detail.mainFields || [],
1024
+ ...(detail.detailFields || []).flatMap((d) => d.fields || [])
1025
+ ];
1026
+ for (const f of fields) {
1027
+ if (!f?.fieldid) continue;
1028
+ if (!OPT_COMP.includes(f.component_type)) continue;
1029
+ const key = `options:${f.fieldid}:*:1`;
1030
+ if (options[key]) continue;
1031
+ try {
1032
+ const resp = await host.request({
1033
+ method: "GET",
1034
+ path: "/api/ebuilder/common/ds/options",
1035
+ query: { fieldName: String(f.fieldid), objId, groupId: appId, optionLevel: 1 },
1036
+ operation: this.name
1037
+ });
1038
+ const values = resp?.data ?? resp?.datajson?.datas ?? [];
1039
+ options[key] = {
1040
+ lable: `${pk}.${f.data_key ?? f.fieldid}`,
1041
+ lableTitle: `${pk}.${f.title ?? f.data_key ?? f.fieldid}`,
1042
+ value: (Array.isArray(values) ? values : []).map((v) => ({
1043
+ label: String(v?.lable ?? v?.label ?? v?.text ?? v?.name ?? ""),
1044
+ value: String(v?.value ?? v?.val ?? v?.id ?? "")
1045
+ }))
1046
+ };
1047
+ } catch {
1048
+ }
1049
+ }
1050
+ }
1051
+ const searchPerPk = {};
1052
+ for (const pk of SEARCH_PKS) {
1053
+ const cfgId = cfgMap[pk];
1054
+ if (!cfgId) continue;
1055
+ try {
1056
+ const resp = await host.request({
1057
+ method: "GET",
1058
+ path: "/api/bs/ebuilder/form/formdata/getRestCfgById",
1059
+ query: { apid: appId, id: cfgId },
1060
+ operation: this.name
1061
+ });
1062
+ const cfgObj = resp?.data ?? {};
1063
+ let conditions = cfgObj.conditions;
1064
+ if (typeof conditions === "string") {
1065
+ try {
1066
+ conditions = JSON.parse(conditions);
1067
+ } catch {
1068
+ conditions = null;
1069
+ }
1070
+ }
1071
+ const params = [];
1072
+ for (const d of conditions?.datas ?? []) {
1073
+ const value = d?.conditions?.value;
1074
+ if (typeof value === "string") {
1075
+ const m = value.match(/\{([^}]+)\}/);
1076
+ if (m) {
1077
+ params.push({
1078
+ key: m[1],
1079
+ text: d?.text ?? "",
1080
+ fieldType: d?.fieldType ?? "",
1081
+ compType: d?.compType ?? "",
1082
+ func: d?.conditions?.func ?? "",
1083
+ fieldid: d?.fieldName ?? ""
1084
+ });
1085
+ }
1086
+ }
1087
+ }
1088
+ searchPerPk[pk] = { cfgId, searchParams: params };
1089
+ } catch {
1090
+ }
1091
+ }
1092
+ for (const [pk, entry] of Object.entries(searchPerPk)) {
1093
+ if (perPk[pk]) perPk[pk] = { ...perPk[pk], ...entry };
1094
+ else perPk[pk] = entry;
1095
+ }
1096
+ const region = {};
1097
+ for (const city of REGION_CITIES) {
1098
+ try {
1099
+ const resp = await host.request({
1100
+ path: "/api/esb/server/event/triggerActionFlow",
1101
+ body: {
1102
+ customParams: { mainTable: { moduleType: "administrativeDivision", name: city, fromType: "agentSkill" } },
1103
+ uniqueIndent: "7EC1639D5AC24B4DBCEE8D2CB85D4025",
1104
+ employeeId: userId
1105
+ },
1106
+ operation: this.name
1107
+ });
1108
+ if (Number(resp?.resultCode ?? 0) === 200) {
1109
+ region[`administrativeDivision:${city}`] = resp;
1110
+ }
1111
+ } catch {
1112
+ }
1113
+ }
1114
+ const cache = { discovery, ebuilder, options, region };
1115
+ cache.region = { ...old.region || {}, ...cache.region || {} };
1116
+ cache.options = { ...old.options || {}, ...cache.options || {} };
1117
+ if (!cache.discovery[`spVersion:${APP_TAG}`] && old.discovery?.[`spVersion:${APP_TAG}`]) {
1118
+ cache.discovery[`spVersion:${APP_TAG}`] = old.discovery[`spVersion:${APP_TAG}`];
1119
+ }
1120
+ const summary = {
1121
+ dryRun,
1122
+ cacheDir: baseDir,
1123
+ mainFile,
1124
+ namespaces: {
1125
+ discovery: Object.keys(cache.discovery).length,
1126
+ ebuilder: Object.keys(cache.ebuilder).length,
1127
+ options: Object.keys(cache.options).length,
1128
+ region: Object.keys(cache.region).length
1129
+ },
1130
+ configFiles: Object.keys(perPk).length,
1131
+ objIdCount: Object.keys(discovery).filter((k) => k.startsWith("objId:")).length,
1132
+ cfgIdCount: Object.keys(cfgMap).length,
1133
+ version: cache.discovery[`spVersion:${APP_TAG}`] ?? null,
1134
+ warnings: []
1135
+ };
1136
+ if (cache.discovery[`spVersion:${APP_TAG}`] && cache.discovery[`spVersion:${APP_TAG}`].passed === false) {
1137
+ summary.warnings.push(`\u4E5D\u6C1A\u6C47\u8425\u9500\u7BA1\u7406\u5305\u7248\u672C\uFF08${cache.discovery[`spVersion:${APP_TAG}`].commitVersion}\uFF09\u4F4E\u4E8E ${MIN_VERSION}\uFF0C\u4E1A\u52A1\u8C03\u7528\u5E94\u505C\u6B62`);
1138
+ }
1139
+ if (dryRun) return { status: "COMPLETE", data: { ...summary, written: false, note: "dry-run\uFF1A\u53EA\u62C9\u53D6\u672A\u5199\u5165" } };
1140
+ mkdirSync(cfgDir, { recursive: true });
1141
+ writeFileSync(mainFile, JSON.stringify(cache, null, 2), "utf-8");
1142
+ for (const [pk, entry] of Object.entries(perPk)) {
1143
+ const tag = PK_TO_TAG[pk];
1144
+ const objId = cache.discovery[`objId:${tag}`];
1145
+ writeFileSync(join(cfgDir, `${pk}.json`), JSON.stringify({ ...entry, objId: objId ?? "" }, null, 2), "utf-8");
1146
+ }
1147
+ if (verbose) {
1148
+ summary.warnings.push(`${JSON.stringify({ step1: "discovery", step2: "cfgId", step3: "cfg.detail", step4: "ebuilder", step5: "options", step6: "searchParams", step7: "region" })}`);
1149
+ }
1150
+ return {
1151
+ status: "COMPLETE",
1152
+ data: { ...summary, written: true }
1153
+ };
1154
+ }
1155
+ };
1156
+
1157
+ // src/shortcuts/jiuchuanhui/operations/shared.ts
1158
+ var FORBIDDEN_INPUT_KEYS = /* @__PURE__ */ new Set([
1159
+ "access_token",
1160
+ "app_key",
1161
+ "app_secret",
1162
+ "cookie",
1163
+ "eteamsid",
1164
+ "token",
1165
+ "sessionid"
1166
+ ]);
1167
+ var FORBIDDEN_NORMALIZED_KEYS = new Set([...FORBIDDEN_INPUT_KEYS].map((key) => key.toLowerCase()));
1168
+ function asObject(value, name = "\u4E1A\u52A1\u8F93\u5165") {
1169
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
1170
+ throw jiuchuanhuiValidationError("input_invalid", `${name}\u5FC5\u987B\u662F JSON \u5BF9\u8C61`);
1171
+ }
1172
+ return value;
1173
+ }
1174
+ function asNonEmptyString(value, name) {
1175
+ if (typeof value !== "string" || !value.trim()) {
1176
+ throw jiuchuanhuiValidationError("input_invalid", `${name} \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32`);
1177
+ }
1178
+ return value.trim();
1179
+ }
1180
+ function asPositiveString(value, name) {
1181
+ if (typeof value !== "string" || !/^\d+$/u.test(value) || value === "0") {
1182
+ throw jiuchuanhuiValidationError("input_invalid", `${name} \u5FC5\u987B\u662F\u6B63\u6574\u6570\u6587\u672C`);
1183
+ }
1184
+ return value;
1185
+ }
1186
+ function assertNoForbiddenKeys(value, location = "input") {
1187
+ if (!value || typeof value !== "object") return;
1188
+ if (Array.isArray(value)) {
1189
+ value.forEach((item, index) => assertNoForbiddenKeys(item, `${location}[${index}]`));
1190
+ return;
1191
+ }
1192
+ for (const [key, child] of Object.entries(value)) {
1193
+ if (FORBIDDEN_INPUT_KEYS.has(key) || FORBIDDEN_NORMALIZED_KEYS.has(key.toLowerCase())) {
1194
+ throw jiuchuanhuiValidationError("field_forbidden", `\u7981\u6B62\u4E1A\u52A1\u8F93\u5165\u5B57\u6BB5\uFF1A${location}.${key}`);
1195
+ }
1196
+ assertNoForbiddenKeys(child, `${location}.${key}`);
1197
+ }
1198
+ }
1199
+ function sessionMatches(lease, session) {
1200
+ return lease.baseUrl === session.baseUrl && lease.profile === session.profile && lease.userId === session.userId;
1201
+ }
1202
+ function workflow(name, state) {
1203
+ return { workflow: name, version: 1, state };
1204
+ }
1205
+ function esbBody(mainTable, uniqueIndent, userId) {
1206
+ return {
1207
+ customParams: { mainTable },
1208
+ uniqueIndent,
1209
+ employeeId: userId
1210
+ };
1211
+ }
1212
+ function datasBody(form, userId) {
1213
+ const datas = Array.isArray(form.datas) ? form.datas : [form];
1214
+ const cleansed = datas.map((item) => stripForbidden(item));
1215
+ return {
1216
+ datajson: {
1217
+ datas: cleansed,
1218
+ header: { operator: userId }
1219
+ }
1220
+ };
1221
+ }
1222
+ function byIdBody(id, userId) {
1223
+ return {
1224
+ datajson: {
1225
+ mainTable: { id },
1226
+ header: { operator: userId }
1227
+ }
1228
+ };
1229
+ }
1230
+ function listBody(userId, pageNo, pageSize, mainTable) {
1231
+ const mt = mainTable && Object.keys(mainTable).length ? { ...mainTable } : {};
1232
+ return {
1233
+ datajson: {
1234
+ mainTable: mt,
1235
+ pageInfo: { pageNo, pageSize },
1236
+ header: { operator: userId }
1237
+ }
1238
+ };
1239
+ }
1240
+ function stripForbidden(value) {
1241
+ if (Array.isArray(value)) return value.map(stripForbidden);
1242
+ if (!value || typeof value !== "object") return value;
1243
+ const result = {};
1244
+ for (const [key, child] of Object.entries(value)) {
1245
+ if (FORBIDDEN_INPUT_KEYS.has(key) || FORBIDDEN_NORMALIZED_KEYS.has(key.toLowerCase())) continue;
1246
+ result[key] = stripForbidden(child);
1247
+ }
1248
+ return result;
1249
+ }
1250
+ function stripForbiddenKeys(value) {
1251
+ return stripForbidden(value);
1252
+ }
1253
+ function listRecords(value) {
1254
+ if (!value || typeof value !== "object") return [];
1255
+ const root = value;
1256
+ const datas = root.datajson?.datas;
1257
+ if (Array.isArray(datas)) return datas;
1258
+ return [];
1259
+ }
1260
+ function resultDataIds(value) {
1261
+ if (!value || typeof value !== "object") return [];
1262
+ const ids = value.datajson?.dataIds;
1263
+ if (Array.isArray(ids)) return ids.map((item) => String(item));
1264
+ return [];
1265
+ }
1266
+ function esbOutcome(value) {
1267
+ if (!value || typeof value !== "object") return { resultCode: 0, resultMsg: "" };
1268
+ const root = value;
1269
+ return {
1270
+ resultCode: Number(root.resultCode ?? 0),
1271
+ resultMsg: typeof root.resultMsg === "string" ? root.resultMsg : ""
1272
+ };
1273
+ }
1274
+ function pagingFrom(input) {
1275
+ const pageNo = Number.isInteger(input.pageNo) && input.pageNo >= 1 ? input.pageNo : 1;
1276
+ const pageSize = Number.isInteger(input.pageSize) && input.pageSize >= 1 ? input.pageSize : 10;
1277
+ return { pageNo, pageSize };
1278
+ }
1279
+
1280
+ // src/shortcuts/jiuchuanhui/operations/datajson.ts
1281
+ var DatajsonWritePrepareOperation = class {
1282
+ constructor(name, applyOperation) {
1283
+ this.name = name;
1284
+ this.applyOperation = applyOperation;
1285
+ }
1286
+ name;
1287
+ applyOperation;
1288
+ async execute(input, { host, continuation }) {
1289
+ const form = asObject(input.form, "form");
1290
+ const session = await host.getSession();
1291
+ const preview = {
1292
+ datas: form.datas !== void 0 ? form.datas : [stripForbiddenKeys(form)],
1293
+ operator: session.userId
1294
+ };
1295
+ const continuationToken = await continuation.issue({
1296
+ operation: this.applyOperation,
1297
+ workflow: workflow(this.applyOperation, "AWAITING_CONFIRMATION"),
1298
+ baseUrl: session.baseUrl,
1299
+ profile: session.profile,
1300
+ userId: session.userId,
1301
+ form,
1302
+ preview
1303
+ });
1304
+ return {
1305
+ status: "AWAITING_CONFIRMATION",
1306
+ data: {
1307
+ preview,
1308
+ continuation: continuationToken,
1309
+ expiresInSeconds: 600,
1310
+ workflow: workflow(this.applyOperation, "AWAITING_CONFIRMATION")
1311
+ }
1312
+ };
1313
+ }
1314
+ };
1315
+ var DatajsonWriteApplyOperation = class {
1316
+ constructor(name, path) {
1317
+ this.name = name;
1318
+ this.path = path;
1319
+ }
1320
+ name;
1321
+ path;
1322
+ async execute(input, { host, continuation }) {
1323
+ if (input.confirm !== true) throw jiuchuanhuiConfirmationError(this.name, { hint: "\u91CD\u65B0\u8C03\u7528\u65F6\u4F20\u5165 confirm=true" });
1324
+ if (typeof input.continuation !== "string" || !input.continuation) {
1325
+ throw jiuchuanhuiValidationError("continuation_required", "apply \u5FC5\u987B\u643A\u5E26 prepare \u8FD4\u56DE\u7684 continuation");
1326
+ }
1327
+ const lease = await continuation.verify(input.continuation, this.name);
1328
+ if (!lease.form || typeof lease.form !== "object") {
1329
+ throw jiuchuanhuiValidationError("continuation_invalid", `${this.name} continuation \u7F3A\u5C11\u8868\u5355\u6570\u636E`);
1330
+ }
1331
+ const session = await host.getSession();
1332
+ if (!sessionMatches(lease, session)) throw jiuchuanhuiValidationError("context_mismatch", "\u786E\u8BA4\u4E0A\u4E0B\u6587\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u51C6\u5907\u64CD\u4F5C");
1333
+ let result;
1334
+ try {
1335
+ result = await host.request({
1336
+ path: this.path,
1337
+ body: datasBody(lease.form, session.userId),
1338
+ operation: this.name
1339
+ });
1340
+ } catch (error) {
1341
+ if (isJiuchuanhuiNetworkError(error)) {
1342
+ throw jiuchuanhuiPartialError("\u5199\u8BF7\u6C42\u53D1\u9001\u540E\u8FDE\u63A5\u4E2D\u65AD\uFF0C\u7ED3\u679C\u4E0D\u786E\u5B9A\uFF0C\u7981\u6B62\u81EA\u52A8\u91CD\u8BD5", {
1343
+ preview: lease.preview,
1344
+ workflow: workflow(this.name, "EXECUTING")
1345
+ }, { stage: "datajson-apply" });
1346
+ }
1347
+ throw error;
1348
+ }
1349
+ const dataIds = resultDataIds(result);
1350
+ if (!dataIds.length) {
1351
+ throw jiuchuanhuiPartialError("\u4FDD\u5B58\u63A5\u53E3\u8FD4\u56DE\u6210\u529F\u4F46\u6CA1\u6709 dataIds\uFF0C\u7ED3\u679C\u4E0D\u786E\u5B9A", {
1352
+ preview: lease.preview,
1353
+ result,
1354
+ workflow: workflow(this.name, "EXECUTING")
1355
+ }, { stage: "datajson-response" });
1356
+ }
1357
+ return {
1358
+ status: "COMPLETE",
1359
+ data: {
1360
+ dataIds,
1361
+ applied: lease.preview,
1362
+ result,
1363
+ workflow: workflow(this.name, "COMPLETE")
1364
+ }
1365
+ };
1366
+ }
1367
+ };
1368
+ var DatajsonDetailOperation = class {
1369
+ constructor(name, path) {
1370
+ this.name = name;
1371
+ this.path = path;
1372
+ }
1373
+ name;
1374
+ path;
1375
+ async execute(input, { host }) {
1376
+ const id = asPositiveString(String(input.id ?? input.dataId), "id");
1377
+ const session = await host.getSession();
1378
+ const result = await host.request({
1379
+ path: this.path,
1380
+ body: byIdBody(id, session.userId),
1381
+ operation: this.name
1382
+ });
1383
+ return {
1384
+ status: "COMPLETE",
1385
+ data: {
1386
+ id,
1387
+ ...result && typeof result === "object" ? { raw: result } : {},
1388
+ mainTable: extractMainTable(result),
1389
+ detail: result
1390
+ }
1391
+ };
1392
+ }
1393
+ };
1394
+ var DatajsonSearchOperation = class {
1395
+ constructor(name, path, countPath) {
1396
+ this.name = name;
1397
+ this.path = path;
1398
+ this.countPath = countPath;
1399
+ }
1400
+ name;
1401
+ path;
1402
+ countPath;
1403
+ async execute(input, { host }) {
1404
+ const { pageNo, pageSize } = pagingFrom(input);
1405
+ const session = await host.getSession();
1406
+ const query = buildSearchQuery(input, pageNo, pageSize);
1407
+ const main = listBody(session.userId, pageNo, pageSize, {});
1408
+ const listPromise = host.request({ path: this.path, query, body: main, operation: this.name });
1409
+ const countPromise = input.count === true && this.countPath ? host.request({ path: this.countPath, query: withoutPaging(query), body: listBody(session.userId, 1, 1, {}), operation: `${this.name}.count` }) : void 0;
1410
+ const [listResult, countResult] = countPromise ? await Promise.all([listPromise, countPromise]) : [await listPromise, void 0];
1411
+ const records = listRecords(listResult);
1412
+ const total = extractCount(countResult);
1413
+ return {
1414
+ status: "COMPLETE",
1415
+ data: {
1416
+ items: records,
1417
+ total,
1418
+ pageNo,
1419
+ pageSize,
1420
+ hasMore: total === void 0 ? records.length >= pageSize : pageNo * pageSize < total,
1421
+ query
1422
+ }
1423
+ };
1424
+ }
1425
+ };
1426
+ function buildSearchQuery(input, pageNo, pageSize) {
1427
+ const query = {};
1428
+ for (const [key, value] of Object.entries(input)) {
1429
+ if (key === "pageNo" || key === "pageSize" || key === "count" || value === void 0 || value === null) continue;
1430
+ if (Array.isArray(value)) {
1431
+ query[key] = value.join(",");
1432
+ } else if (typeof value === "boolean") {
1433
+ query[key] = value ? "true" : "false";
1434
+ } else {
1435
+ query[key] = String(value);
1436
+ }
1437
+ }
1438
+ query.pageNo = pageNo;
1439
+ query.pageSize = pageSize;
1440
+ return query;
1441
+ }
1442
+ function withoutPaging(query) {
1443
+ const next = { ...query };
1444
+ delete next.pageNo;
1445
+ delete next.pageSize;
1446
+ return next;
1447
+ }
1448
+ function extractCount(value) {
1449
+ if (!value || typeof value !== "object") return void 0;
1450
+ const root = value;
1451
+ const datas = root.datajson?.datas;
1452
+ const raw = Array.isArray(datas) ? datas[0] : datas;
1453
+ const num = Number(raw ?? root.total ?? root.count);
1454
+ return Number.isFinite(num) ? num : void 0;
1455
+ }
1456
+ function extractMainTable(value) {
1457
+ if (!value || typeof value !== "object") return void 0;
1458
+ const root = value;
1459
+ const mt = root.datajson?.mainTable;
1460
+ if (mt && typeof mt === "object" && !Array.isArray(mt)) return mt;
1461
+ const datas = root.datajson?.datas;
1462
+ if (Array.isArray(datas) && datas[0] && typeof datas[0] === "object") {
1463
+ const first = datas[0];
1464
+ if (first.mainTable && typeof first.mainTable === "object") return first.mainTable;
1465
+ return first;
1466
+ }
1467
+ return void 0;
1468
+ }
1469
+
1470
+ // src/shortcuts/jiuchuanhui/operations/esb.ts
1471
+ var EsbWritePrepareOperation = class {
1472
+ constructor(name, applyOperation, uniqueIndent, mainTableKeys) {
1473
+ this.name = name;
1474
+ this.applyOperation = applyOperation;
1475
+ this.uniqueIndent = uniqueIndent;
1476
+ this.mainTableKeys = mainTableKeys;
1477
+ }
1478
+ name;
1479
+ applyOperation;
1480
+ uniqueIndent;
1481
+ mainTableKeys;
1482
+ async execute(input, { host, continuation }) {
1483
+ const mainTable = normalizeMainTable(input.mainTable, this.mainTableKeys);
1484
+ const preview = summaryOf(mainTable);
1485
+ const session = await host.getSession();
1486
+ const continuationToken = await continuation.issue({
1487
+ operation: this.applyOperation,
1488
+ workflow: workflow(this.applyOperation, "AWAITING_CONFIRMATION"),
1489
+ baseUrl: session.baseUrl,
1490
+ profile: session.profile,
1491
+ userId: session.userId,
1492
+ uniqueIndent: this.uniqueIndent,
1493
+ mainTable,
1494
+ preview
1495
+ });
1496
+ return {
1497
+ status: "AWAITING_CONFIRMATION",
1498
+ data: {
1499
+ preview,
1500
+ continuation: continuationToken,
1501
+ expiresInSeconds: 600,
1502
+ workflow: workflow(this.applyOperation, "AWAITING_CONFIRMATION")
1503
+ }
1504
+ };
1505
+ }
1506
+ };
1507
+ var EsbWriteApplyOperation = class {
1508
+ constructor(name, uniqueIndent) {
1509
+ this.name = name;
1510
+ this.uniqueIndent = uniqueIndent;
1511
+ }
1512
+ name;
1513
+ uniqueIndent;
1514
+ async execute(input, { host, continuation }) {
1515
+ if (input.confirm !== true) throw jiuchuanhuiConfirmationError(this.name, { hint: "\u91CD\u65B0\u8C03\u7528\u65F6\u4F20\u5165 confirm=true" });
1516
+ if (typeof input.continuation !== "string" || !input.continuation) {
1517
+ throw jiuchuanhuiValidationError("continuation_required", "apply \u5FC5\u987B\u643A\u5E26 prepare \u8FD4\u56DE\u7684 continuation");
1518
+ }
1519
+ const lease = await continuation.verify(input.continuation, this.name);
1520
+ if (!lease.uniqueIndent || !lease.mainTable || typeof lease.mainTable !== "object") {
1521
+ throw jiuchuanhuiValidationError("continuation_invalid", `${this.name} continuation \u7F3A\u5C11\u52A8\u4F5C\u6D41\u6807\u8BC6\u6216\u4E1A\u52A1\u53C2\u6570`);
1522
+ }
1523
+ const session = await host.getSession();
1524
+ if (!sessionMatches(lease, session)) throw jiuchuanhuiValidationError("context_mismatch", "\u786E\u8BA4\u4E0A\u4E0B\u6587\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u51C6\u5907\u64CD\u4F5C");
1525
+ if (lease.uniqueIndent !== this.uniqueIndent) {
1526
+ throw jiuchuanhuiValidationError("continuation_mismatch", "continuation \u4E0E\u5F53\u524D\u64CD\u4F5C\u7684\u52A8\u4F5C\u6D41\u6807\u8BC6\u4E0D\u4E00\u81F4");
1527
+ }
1528
+ let result;
1529
+ try {
1530
+ result = await host.request({
1531
+ path: "/api/esb/server/event/triggerActionFlow",
1532
+ body: esbBody(lease.mainTable, this.uniqueIndent, session.userId),
1533
+ operation: this.name
1534
+ });
1535
+ } catch (error) {
1536
+ if (isJiuchuanhuiNetworkError(error)) {
1537
+ throw jiuchuanhuiPartialError("\u5199\u8BF7\u6C42\u53D1\u9001\u540E\u8FDE\u63A5\u4E2D\u65AD\uFF0C\u7ED3\u679C\u4E0D\u786E\u5B9A\uFF0C\u7981\u6B62\u81EA\u52A8\u91CD\u8BD5", {
1538
+ preview: lease.preview,
1539
+ workflow: workflow(this.name, "EXECUTING")
1540
+ }, { stage: "esb-apply" });
1541
+ }
1542
+ throw error;
1543
+ }
1544
+ const { resultCode, resultMsg } = esbOutcome(result);
1545
+ if (resultCode !== 200) {
1546
+ throw jiuchuanhuiPartialError(`\u52A8\u4F5C\u6D41\u8FD4\u56DE\u975E\u6210\u529F\u7ED3\u679C\uFF08resultCode=${resultCode}\uFF09\uFF0C\u7ED3\u679C\u4E0D\u786E\u5B9A`, {
1547
+ preview: lease.preview,
1548
+ result,
1549
+ workflow: workflow(this.name, "EXECUTING")
1550
+ }, { stage: "esb-response", resultCode, resultMsg });
1551
+ }
1552
+ return {
1553
+ status: "COMPLETE",
1554
+ data: {
1555
+ applied: lease.preview,
1556
+ result: { resultCode, resultMsg },
1557
+ workflow: workflow(this.name, "COMPLETE")
1558
+ }
1559
+ };
1560
+ }
1561
+ };
1562
+ var EsbReadOperation = class {
1563
+ constructor(name, uniqueIndent, mainTableKeys) {
1564
+ this.name = name;
1565
+ this.uniqueIndent = uniqueIndent;
1566
+ this.mainTableKeys = mainTableKeys;
1567
+ }
1568
+ name;
1569
+ uniqueIndent;
1570
+ mainTableKeys;
1571
+ async execute(input, { host }) {
1572
+ const mainTable = normalizeMainTable(input.mainTable ?? input, this.mainTableKeys);
1573
+ const session = await host.getSession();
1574
+ const result = await host.request({
1575
+ path: "/api/esb/server/event/triggerActionFlow",
1576
+ body: esbBody(mainTable, this.uniqueIndent, session.userId),
1577
+ operation: this.name
1578
+ });
1579
+ const { resultCode, resultMsg } = esbOutcome(result);
1580
+ if (resultCode !== 200) {
1581
+ throw jiuchuanhuiValidationError("esb_read_failed", `\u52A8\u4F5C\u6D41\u67E5\u8BE2\u5931\u8D25\uFF08resultCode=${resultCode}\uFF09\uFF1A${resultMsg}`);
1582
+ }
1583
+ const customData = result?.actionData?.responseData?.customData;
1584
+ return {
1585
+ status: "COMPLETE",
1586
+ data: {
1587
+ resultCode,
1588
+ resultMsg,
1589
+ ...customData && typeof customData === "object" ? { customData } : {},
1590
+ mainTable: customData?.mainTable,
1591
+ raw: result
1592
+ }
1593
+ };
1594
+ }
1595
+ };
1596
+ function normalizeMainTable(raw, allowedKeys) {
1597
+ const mainTable = asObject(raw, "mainTable");
1598
+ if (!allowedKeys.length) return { ...mainTable };
1599
+ for (const key of Object.keys(mainTable)) {
1600
+ if (!allowedKeys.includes(key)) {
1601
+ throw jiuchuanhuiValidationError("field_unsupported", `${key} \u4E0D\u662F\u8BE5\u64CD\u4F5C\u652F\u6301\u7684\u5B57\u6BB5`);
1602
+ }
1603
+ }
1604
+ if (!allowedKeys.some((key) => mainTable[key] !== void 0 && mainTable[key] !== null && mainTable[key] !== "")) {
1605
+ throw jiuchuanhuiValidationError("field_required", `\u81F3\u5C11\u9700\u8981\u63D0\u4F9B\u4EE5\u4E0B\u5B57\u6BB5\u4E4B\u4E00\uFF1A${allowedKeys.join("\u3001")}`);
1606
+ }
1607
+ return { ...mainTable };
1608
+ }
1609
+ function summaryOf(mainTable) {
1610
+ return Object.fromEntries(Object.entries(mainTable).map(([key, value]) => [key, asNonEmptyString(value, key)]));
1611
+ }
1612
+
1613
+ // src/shortcuts/jiuchuanhui/operations/generic.ts
1614
+ var GetQueryOperation = class {
1615
+ constructor(name, path, requiredKeys = []) {
1616
+ this.name = name;
1617
+ this.path = path;
1618
+ this.requiredKeys = requiredKeys;
1619
+ }
1620
+ name;
1621
+ path;
1622
+ requiredKeys;
1623
+ async execute(input, { host }) {
1624
+ const query = {};
1625
+ for (const key of this.requiredKeys) {
1626
+ const value = input[key];
1627
+ if (value === void 0 || value === null || value === "") {
1628
+ throw jiuchuanhuiValidationError("field_required", `\u7F3A\u5C11\u5FC5\u586B\u53C2\u6570\uFF1A${key}`);
1629
+ }
1630
+ query[key] = String(value);
1631
+ }
1632
+ for (const [key, value] of Object.entries(input)) {
1633
+ if (value === void 0 || value === null || key === "save") continue;
1634
+ query[key] = Array.isArray(value) ? value.join(",") : value;
1635
+ }
1636
+ const result = await host.request({
1637
+ method: "GET",
1638
+ path: this.path,
1639
+ query,
1640
+ operation: this.name
1641
+ });
1642
+ return {
1643
+ status: "COMPLETE",
1644
+ data: {
1645
+ ...result && typeof result === "object" ? { raw: result } : { raw: result },
1646
+ query
1647
+ }
1648
+ };
1649
+ }
1650
+ };
1651
+ var PathParamsPostOperation = class {
1652
+ constructor(name, pathTemplate) {
1653
+ this.name = name;
1654
+ this.pathTemplate = pathTemplate;
1655
+ }
1656
+ name;
1657
+ pathTemplate;
1658
+ async execute(input, { host }) {
1659
+ const pathParams = asObject(input.pathParams ?? input.pathParamsRaw, "pathParams");
1660
+ const names = [...this.pathTemplate.matchAll(/\{(\w+)\}/g)].map((m) => m[1]);
1661
+ let path = this.pathTemplate;
1662
+ for (const name of names) {
1663
+ const value = pathParams[name];
1664
+ if (value === void 0 || value === null || value === "") {
1665
+ throw jiuchuanhuiValidationError("path_param_missing", `\u8DEF\u5F84\u5360\u4F4D\u7B26 {${name}} \u7F3A\u5931\uFF0C\u8BF7\u901A\u8FC7 pathParams \u4F20\u5165`);
1666
+ }
1667
+ path = path.replace(`{${name}}`, encodeURIComponent(String(value)));
1668
+ }
1669
+ const body = input.params && typeof input.params === "object" ? input.params : {};
1670
+ const result = await host.request({
1671
+ path,
1672
+ body,
1673
+ operation: this.name
1674
+ });
1675
+ return {
1676
+ status: "COMPLETE",
1677
+ data: {
1678
+ ...result && typeof result === "object" ? { raw: result } : { raw: result }
1679
+ }
1680
+ };
1681
+ }
1682
+ };
1683
+ var FilePreviewOperation = class {
1684
+ constructor(name) {
1685
+ this.name = name;
1686
+ }
1687
+ name;
1688
+ async execute(input, { host }) {
1689
+ const fileId = asNonEmptyString(input.fileId, "fileId");
1690
+ const query = {
1691
+ fileId,
1692
+ module: input.module ?? "ebuilderform",
1693
+ authModule: input.authModule ?? "ebuilderform",
1694
+ source: input.source ?? "form"
1695
+ };
1696
+ if (input.fieldId !== void 0) query.fieldId = input.fieldId;
1697
+ if (input.appId !== void 0) query.appId = input.appId;
1698
+ if (input.customParam !== void 0) query.customParam = typeof input.customParam === "string" ? input.customParam : JSON.stringify(input.customParam);
1699
+ const result = await host.request({
1700
+ method: "GET",
1701
+ path: "/api/file/preview",
1702
+ query,
1703
+ operation: this.name
1704
+ });
1705
+ return {
1706
+ status: "COMPLETE",
1707
+ data: {
1708
+ ...result && typeof result === "object" ? { raw: result } : { raw: result },
1709
+ fileId
1710
+ }
1711
+ };
1712
+ }
1713
+ };
1714
+
1715
+ // src/shortcuts/jiuchuanhui/operations/registry.ts
1716
+ function buildRegistry() {
1717
+ const registry = /* @__PURE__ */ new Map();
1718
+ const handlers = [
1719
+ // ===== 发现与缓存 =====
1720
+ new CacheInitOperation(),
1721
+ new GetQueryOperation("jiuchuanhui.app.discovery", "/api/bs/ebuilder/app/tags/getAppIds", ["tag"]),
1722
+ new GetQueryOperation("jiuchuanhui.form.discovery", "/api/ebuilder/form/obj/getObjsByTag", ["tag", "appId"]),
1723
+ new GetQueryOperation("jiuchuanhui.field.options", "/api/ebuilder/common/ds/options", ["fieldName", "sourceType"]),
1724
+ new GetQueryOperation("jiuchuanhui.rest.cfg.detail", "/api/bs/ebuilder/form/formdata/getRestCfgById", ["apid", "id"]),
1725
+ new EsbReadOperation("jiuchuanhui.config.id.by.pk", "4F6E1A9702864666803CCA6B77B86227", ["interface_pk"]),
1726
+ new FilePreviewOperation("jiuchuanhui.file.preview"),
1727
+ // ===== 客户 =====
1728
+ new DatajsonWritePrepareOperation("jiuchuanhui.customer.create.prepare", "jiuchuanhui.customer.create.apply"),
1729
+ new DatajsonWriteApplyOperation("jiuchuanhui.customer.create.apply", "/api/ebuilder/form/formdata/v2/saveFormData/customer_create_api"),
1730
+ new DatajsonDetailOperation("jiuchuanhui.customer.get", "/api/ebuilder/form/formdata/v2/getFormDataByPk/customer_get_api"),
1731
+ new DatajsonSearchOperation("jiuchuanhui.customer.search", "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_search_api", "/api/ebuilder/form/formdata/v2/getFormDataCount/ebcustomer_search_count_api"),
1732
+ new DatajsonSearchOperation("jiuchuanhui.customer.type.search", "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_type_search_api"),
1733
+ new DatajsonSearchOperation("jiuchuanhui.customer.status.search", "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_status_search_api"),
1734
+ new DatajsonSearchOperation("jiuchuanhui.customer.industry.search", "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_industry_search_api"),
1735
+ new DatajsonSearchOperation("jiuchuanhui.customer.open-sea.search", "/api/ebuilder/form/formdata/v2/getFormDataList/customer_open_sea_search_api"),
1736
+ new DatajsonWritePrepareOperation("jiuchuanhui.customer.update.prepare", "jiuchuanhui.customer.update.apply"),
1737
+ new DatajsonWriteApplyOperation("jiuchuanhui.customer.update.apply", "/api/ebuilder/form/formdata/v2/updateFormData/customer_update_api"),
1738
+ // ===== 客户 ESB 写操作 =====
1739
+ new EsbWritePrepareOperation("jiuchuanhui.customer.transfer.prepare", "jiuchuanhui.customer.transfer.apply", "1E44ED7DA9EB46329818E682C2914928", ["customerId", "employee_MappingId", "employeeName"]),
1740
+ new EsbWriteApplyOperation("jiuchuanhui.customer.transfer.apply", "1E44ED7DA9EB46329818E682C2914928"),
1741
+ new EsbWritePrepareOperation("jiuchuanhui.customer.open-sea.release.prepare", "jiuchuanhui.customer.open-sea.release.apply", "0E29AD0E708D4964B071D293288B92D7", ["customerId", "openSeaId"]),
1742
+ new EsbWriteApplyOperation("jiuchuanhui.customer.open-sea.release.apply", "0E29AD0E708D4964B071D293288B92D7"),
1743
+ new EsbWritePrepareOperation("jiuchuanhui.customer.open-sea.claim.prepare", "jiuchuanhui.customer.open-sea.claim.apply", "D587CDC892FE41118DD073475C01A2CE", ["customer_id"]),
1744
+ new EsbWriteApplyOperation("jiuchuanhui.customer.open-sea.claim.apply", "D587CDC892FE41118DD073475C01A2CE"),
1745
+ new EsbReadOperation("jiuchuanhui.customer.duplicate.check", "D5D0A1C30E7B404B842987C0AD3B749D", ["name", "simpleName"]),
1746
+ new EsbWritePrepareOperation("jiuchuanhui.customer.contact-record.create.prepare", "jiuchuanhui.customer.contact-record.create.apply", "C7A226EEE1324FF3B6E5BD18AF923DE7", ["customerId", "comment_content", "type", "rating", "contact_information", "contacts", "next_time", "next_content", "next_contact_information", "next_contacts", "sync_salechance", "rel_remind"]),
1747
+ new EsbWriteApplyOperation("jiuchuanhui.customer.contact-record.create.apply", "C7A226EEE1324FF3B6E5BD18AF923DE7"),
1748
+ new EsbWritePrepareOperation("jiuchuanhui.customer.contact-record.batch.prepare", "jiuchuanhui.customer.contact-record.batch.apply", "D0F315619FE34C669AE738ED68329FAB", ["entityList", "content"]),
1749
+ new EsbWriteApplyOperation("jiuchuanhui.customer.contact-record.batch.apply", "D0F315619FE34C669AE738ED68329FAB"),
1750
+ // ===== 联系人 =====
1751
+ new DatajsonWritePrepareOperation("jiuchuanhui.contact.create.prepare", "jiuchuanhui.contact.create.apply"),
1752
+ new DatajsonWriteApplyOperation("jiuchuanhui.contact.create.apply", "/api/ebuilder/form/formdata/v2/saveFormData/contact_create_api"),
1753
+ new DatajsonDetailOperation("jiuchuanhui.contact.get", "/api/ebuilder/form/formdata/v2/getFormDataByPk/contact_get_api"),
1754
+ new DatajsonWritePrepareOperation("jiuchuanhui.contact.update.prepare", "jiuchuanhui.contact.update.apply"),
1755
+ new DatajsonWriteApplyOperation("jiuchuanhui.contact.update.apply", "/api/ebuilder/form/formdata/v2/updateFormData/contact_update_api"),
1756
+ new DatajsonSearchOperation("jiuchuanhui.contact.by-entity.search", "/api/ebuilder/form/formdata/v2/getFormDataList/ebcontact_search_by_entity_api"),
1757
+ // ===== 商机 =====
1758
+ new DatajsonWritePrepareOperation("jiuchuanhui.sale.create.prepare", "jiuchuanhui.sale.create.apply"),
1759
+ new DatajsonWriteApplyOperation("jiuchuanhui.sale.create.apply", "/api/ebuilder/form/formdata/v2/saveFormData/sale_create_api"),
1760
+ new DatajsonDetailOperation("jiuchuanhui.sale.get", "/api/ebuilder/form/formdata/v2/getFormDataByPk/sale_get_api"),
1761
+ new DatajsonSearchOperation("jiuchuanhui.sale.search", "/api/ebuilder/form/formdata/v2/getFormDataList/ebsale_search_api", "/api/ebuilder/form/formdata/v2/getFormDataCount/ebsale_search_count_api"),
1762
+ new DatajsonWritePrepareOperation("jiuchuanhui.sale.update.prepare", "jiuchuanhui.sale.update.apply"),
1763
+ new DatajsonWriteApplyOperation("jiuchuanhui.sale.update.apply", "/api/ebuilder/form/formdata/v2/updateFormData/sale_update_api"),
1764
+ new DatajsonSearchOperation("jiuchuanhui.sale.stage.search", "/api/ebuilder/form/formdata/v2/getFormDataList/sale_stage_search_api"),
1765
+ new DatajsonSearchOperation("jiuchuanhui.sale.process.search", "/api/ebuilder/form/formdata/v2/getFormDataList/sale_process_sear_api"),
1766
+ new DatajsonSearchOperation("jiuchuanhui.sale.lose-reason.search", "/api/ebuilder/form/formdata/v2/getFormDataList/sale_lose_reason"),
1767
+ new DatajsonSearchOperation("jiuchuanhui.rival.search", "/api/ebuilder/form/formdata/v2/getFormDataList/ebrival_search_api"),
1768
+ // ===== 商机 ESB 写操作 =====
1769
+ new EsbWritePrepareOperation("jiuchuanhui.sale.win.prepare", "jiuchuanhui.sale.win.apply", "3B23E782E5084F18A904E895BBD61A96", ["saleId"]),
1770
+ new EsbWriteApplyOperation("jiuchuanhui.sale.win.apply", "3B23E782E5084F18A904E895BBD61A96"),
1771
+ new EsbWritePrepareOperation("jiuchuanhui.sale.lose.prepare", "jiuchuanhui.sale.lose.apply", "DE35D926F82F49FDBA26B48B0CA1CB53", ["saleid", "money", "reasonids", "rivals", "desc"]),
1772
+ new EsbWriteApplyOperation("jiuchuanhui.sale.lose.apply", "DE35D926F82F49FDBA26B48B0CA1CB53"),
1773
+ new EsbWritePrepareOperation("jiuchuanhui.sale.invalid.prepare", "jiuchuanhui.sale.invalid.apply", "4D88AB8677D84BAC90B63137E7FA1FF9", ["saleId"]),
1774
+ new EsbWriteApplyOperation("jiuchuanhui.sale.invalid.apply", "4D88AB8677D84BAC90B63137E7FA1FF9"),
1775
+ new EsbWritePrepareOperation("jiuchuanhui.sale.pause.prepare", "jiuchuanhui.sale.pause.apply", "859C73403DCC4F01B02329571BDBD9F3", ["saleId", "pauseReason", "restartDate"]),
1776
+ new EsbWriteApplyOperation("jiuchuanhui.sale.pause.apply", "859C73403DCC4F01B02329571BDBD9F3"),
1777
+ new EsbWritePrepareOperation("jiuchuanhui.sale.restart.prepare", "jiuchuanhui.sale.restart.apply", "F3004CDCA8A548B5A0DACD3CDE62387A", ["saleChanceId"]),
1778
+ new EsbWriteApplyOperation("jiuchuanhui.sale.restart.apply", "F3004CDCA8A548B5A0DACD3CDE62387A"),
1779
+ new EsbWritePrepareOperation("jiuchuanhui.sale.manager-change.prepare", "jiuchuanhui.sale.manager-change.apply", "595F9C6F1C4248929B83086F71363BA7", ["saleChanceId", "managerId"]),
1780
+ new EsbWriteApplyOperation("jiuchuanhui.sale.manager-change.apply", "595F9C6F1C4248929B83086F71363BA7"),
1781
+ new EsbWritePrepareOperation("jiuchuanhui.sale.link-contacts.prepare", "jiuchuanhui.sale.link-contacts.apply", "1114A713A62F4CA9899CC24ED5902D93", ["salechanceId", "contactIds"]),
1782
+ new EsbWriteApplyOperation("jiuchuanhui.sale.link-contacts.apply", "1114A713A62F4CA9899CC24ED5902D93"),
1783
+ new EsbWritePrepareOperation("jiuchuanhui.sale.contact-record.create.prepare", "jiuchuanhui.sale.contact-record.create.apply", "7BB3A1918186445F9E770862EFA7EDA9", ["saleId", "comment_content", "type", "rating", "contact_information", "contacts", "next_time", "next_content", "next_contact_information", "next_contacts", "rel_remind"]),
1784
+ new EsbWriteApplyOperation("jiuchuanhui.sale.contact-record.create.apply", "7BB3A1918186445F9E770862EFA7EDA9"),
1785
+ // ===== 线索 =====
1786
+ new DatajsonWritePrepareOperation("jiuchuanhui.clue.create.prepare", "jiuchuanhui.clue.create.apply"),
1787
+ new DatajsonWriteApplyOperation("jiuchuanhui.clue.create.apply", "/api/ebuilder/form/formdata/v2/saveFormData/ebclue_ai_create_api"),
1788
+ new DatajsonDetailOperation("jiuchuanhui.clue.get", "/api/ebuilder/form/formdata/v2/getFormDataByPk/ebcluepool_ai_get_api"),
1789
+ new DatajsonSearchOperation("jiuchuanhui.clue.search", "/api/ebuilder/form/formdata/v2/getFormDataList/ebclue_ai_search_api", "/api/ebuilder/form/formdata/v2/getFormDataCount/ebclue_ai_search_count_api"),
1790
+ new DatajsonSearchOperation("jiuchuanhui.clue.pool.search", "/api/ebuilder/form/formdata/v2/getFormDataList/ebcluepool_ai_search_api"),
1791
+ new DatajsonWritePrepareOperation("jiuchuanhui.clue.update.prepare", "jiuchuanhui.clue.update.apply"),
1792
+ new DatajsonWriteApplyOperation("jiuchuanhui.clue.update.apply", "/api/ebuilder/form/formdata/v2/updateFormData/ebclue_ai_update_api"),
1793
+ // ===== 线索 ESB 写操作 =====
1794
+ new EsbWritePrepareOperation("jiuchuanhui.clue.status-change.prepare", "jiuchuanhui.clue.status-change.apply", "257CC8DE42234F9191439B229839B8A7", ["clueid", "type", "newmanager", "desc"]),
1795
+ new EsbWriteApplyOperation("jiuchuanhui.clue.status-change.apply", "257CC8DE42234F9191439B229839B8A7"),
1796
+ new EsbWritePrepareOperation("jiuchuanhui.clue.to-customer.prepare", "jiuchuanhui.clue.to-customer.apply", "00914C6415EB455DB7FCCC32DBE6E0C3", ["clueId", "customerId"]),
1797
+ new EsbWriteApplyOperation("jiuchuanhui.clue.to-customer.apply", "00914C6415EB455DB7FCCC32DBE6E0C3"),
1798
+ new EsbWritePrepareOperation("jiuchuanhui.clue.contact-record.create.prepare", "jiuchuanhui.clue.contact-record.create.apply", "B3DD120601344320A2B50A042B450681", ["clueId", "content", "clueStatus_MappingId"]),
1799
+ new EsbWriteApplyOperation("jiuchuanhui.clue.contact-record.create.apply", "B3DD120601344320A2B50A042B450681"),
1800
+ // ===== 联系计划 =====
1801
+ new DatajsonWritePrepareOperation("jiuchuanhui.contact-plan.create.prepare", "jiuchuanhui.contact-plan.create.apply"),
1802
+ new DatajsonWriteApplyOperation("jiuchuanhui.contact-plan.create.apply", "/api/ebuilder/form/formdata/v2/saveFormData/ebcontact_plan_create_api"),
1803
+ new EsbWritePrepareOperation("jiuchuanhui.contact-plan.complete.prepare", "jiuchuanhui.contact-plan.complete.apply", "2595D3556CFC414F85B1A4A8D806EFE5", ["planId"]),
1804
+ new EsbWriteApplyOperation("jiuchuanhui.contact-plan.complete.apply", "2595D3556CFC414F85B1A4A8D806EFE5"),
1805
+ // ===== 联系记录 =====
1806
+ new EsbReadOperation("jiuchuanhui.entity.contact-records.list", "364A9713D10C4997AF6EDCAA5296968E", ["moduleType", "entityId"]),
1807
+ new EsbReadOperation("jiuchuanhui.contact-records.by-person-time.list", "D01DD00978524525AD8728BE1BF9FE79", ["employeeId", "startData", "endData"]),
1808
+ // ===== 通用辅助 =====
1809
+ new EsbReadOperation("jiuchuanhui.entity.id.by-name", "7EC1639D5AC24B4DBCEE8D2CB85D4025", ["moduleType", "name"]),
1810
+ new EsbReadOperation("jiuchuanhui.user.id.by-name", "911C17207E2C4BD29379B5A4001B246E", ["employeeName"]),
1811
+ new EsbReadOperation("jiuchuanhui.user.current-profile", "B8F7597190FF419FB9127D6C8272C4FE", []),
1812
+ new EsbReadOperation("jiuchuanhui.entity.permission.judge", "6D369F0A84764051A5D7B5AA1245F49A", ["moduleType", "entityId", "opType"]),
1813
+ new EsbReadOperation("jiuchuanhui.company.business-profile.query", "BAB4DBE204214BB395BA161620A4A1CD", ["companyName"]),
1814
+ new EsbReadOperation("jiuchuanhui.field.info.by-ids", "10351A4DC8D4454A9F1957FBE647CD9F", ["fieldids"]),
1815
+ new PathParamsPostOperation("jiuchuanhui.browser-option.search", "/api/bcw/common/browser/complete/{customBrowserType}"),
1816
+ new GetQueryOperation("jiuchuanhui.get-rest-cfg-detail", "/api/bs/ebuilder/form/formdata/getRestCfgById", ["apid", "id"])
1817
+ ];
1818
+ for (const handler of handlers) {
1819
+ if (registry.has(handler.name)) throw new Error(`duplicate jiuchuanhui operation handler: ${handler.name}`);
1820
+ registry.set(handler.name, handler);
1821
+ }
1822
+ for (const contract of jiuchuanhuiOperations) {
1823
+ if (!registry.has(contract.name)) throw new Error(`missing jiuchuanhui operation handler: ${contract.name}`);
1824
+ }
1825
+ return registry;
1826
+ }
1827
+ var jiuchuanhuiOperationRegistry = buildRegistry();
1828
+ function getJiuchuanhuiOperation(operation) {
1829
+ const handler = jiuchuanhuiOperationRegistry.get(operation);
1830
+ if (!handler) {
1831
+ throw jiuchuanhuiValidationError("operation_unknown", `\u4E5D\u6C1A\u6C47\u4E0D\u652F\u6301\u64CD\u4F5C\uFF1A${operation}`);
1832
+ }
1833
+ return handler;
1834
+ }
1835
+
1836
+ // src/shortcuts/jiuchuanhui/operations.ts
1837
+ async function executeJiuchuanhuiOperation(operation, rawInput, context) {
1838
+ const handler = getJiuchuanhuiOperation(operation);
1839
+ const input = asObject(rawInput);
1840
+ assertNoForbiddenKeys(input);
1841
+ return handler.execute(input, context);
1842
+ }
1843
+
1844
+ // src/shortcuts/jiuchuanhui/index.ts
1845
+ function asOptions(value) {
1846
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
1847
+ }
1848
+ async function readStdin() {
1849
+ const chunks = [];
1850
+ for await (const chunk of process.stdin) {
1851
+ chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
1852
+ }
1853
+ return Buffer.concat(chunks).toString("utf8");
1854
+ }
1855
+ function stripBom(value) {
1856
+ return value.replace(/^\uFEFF+/, "");
1857
+ }
1858
+ async function inputFrom(options, extra = {}) {
1859
+ const opts = asOptions(options);
1860
+ let input = {};
1861
+ if (opts.input && opts.inputJson) {
1862
+ throw jiuchuanhuiValidationError("input_conflict", "\u4E0D\u80FD\u540C\u65F6\u4F20 --input \u548C --input-json");
1863
+ }
1864
+ if (opts.inputJson) {
1865
+ input = parseJsonInput(String(opts.inputJson), "--input-json");
1866
+ }
1867
+ if (opts.input) {
1868
+ let raw;
1869
+ try {
1870
+ raw = stripBom(opts.input === "-" ? await readStdin() : await readFile2(String(opts.input), "utf8"));
1871
+ } catch {
1872
+ throw jiuchuanhuiValidationError("input_unreadable", `\u65E0\u6CD5\u8BFB\u53D6 --input\uFF1A${String(opts.input)}`);
1873
+ }
1874
+ input = parseJsonInput(raw, "--input");
1875
+ }
1876
+ return {
1877
+ ...input,
1878
+ ...Object.fromEntries(Object.entries(extra).filter(([, value]) => value !== void 0 && value !== ""))
1879
+ };
1880
+ }
1881
+ function parseJsonInput(raw, label) {
1882
+ try {
1883
+ const parsed = JSON.parse(stripBom(raw));
1884
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
1885
+ throw new Error("input must be an object");
1886
+ }
1887
+ return parsed;
1888
+ } catch {
1889
+ throw jiuchuanhuiValidationError("input_invalid", `${label} \u4E0D\u662F\u5408\u6CD5 JSON \u5BF9\u8C61`);
1890
+ }
1891
+ }
1892
+ function successEnvelope(operation, result) {
1893
+ return {
1894
+ schemaVersion: 1,
1895
+ ok: true,
1896
+ operation,
1897
+ data: result.data,
1898
+ meta: { status: result.status },
1899
+ warnings: []
1900
+ };
1901
+ }
1902
+ function failureEnvelope(error) {
1903
+ const structured = error;
1904
+ return {
1905
+ schemaVersion: 1,
1906
+ ok: false,
1907
+ ...structured?.partialData === void 0 ? {} : { data: structured.partialData },
1908
+ error: toErrorEnvelope(error)
1909
+ };
1910
+ }
1911
+ async function executeAndPrint(ctx, operation, input) {
1912
+ try {
1913
+ const result = await executeJiuchuanhuiOperation(operation, input, {
1914
+ host: createJiuchuanhuiHost(ctx),
1915
+ continuation: createJiuchuanhuiContinuationSigner(ctx)
1916
+ });
1917
+ ctx.output.write(successEnvelope(operation, result), { json: true });
1918
+ } catch (error) {
1919
+ console.error(JSON.stringify(failureEnvelope(error), null, 2));
1920
+ process.exitCode = isCliError(error) ? error.exitCode : 1 /* GeneralError */;
1921
+ }
1922
+ }
1923
+ var jiuchuanhuiShortcut = {
1924
+ name: "jiuchuanhui",
1925
+ description: "\u6CDB\u5FAEE10\u4E5D\u6C1A\u6C47\u8425\u9500\u7BA1\u7406 CLI\uFF08\u5BA2\u6237/\u8054\u7CFB\u4EBA/\u5546\u673A/\u7EBF\u7D22/\u8054\u7CFB\u8BA1\u5212/\u516C\u6D77\uFF09",
1926
+ category: "shortcut",
1927
+ register({ program, action }) {
1928
+ const jiuchuanhui = program.command("jiuchuanhui").description("\u6CDB\u5FAEE10\u4E5D\u6C1A\u6C47\u8425\u9500\u7BA1\u7406");
1929
+ jiuchuanhui.command("schema").description("Print jiuchuanhui operation manifest for agents").action(action((ctx) => {
1930
+ ctx.output.write(jiuchuanhuiManifest, { json: true });
1931
+ }));
1932
+ jiuchuanhui.command("run").description("Run a jiuchuanhui operation with JSON input").argument("<operation>", "operation name, e.g. jiuchuanhui.customer.search").option("--input <path>", "JSON input file, or - for stdin").option("--input-json <json>", "inline JSON input object").action(action(async (ctx, operation, options) => {
1933
+ await executeAndPrint(ctx, String(operation), await inputFrom(options));
1934
+ }));
1935
+ }
1936
+ };
1937
+ export {
1938
+ inputFrom,
1939
+ jiuchuanhuiShortcut
1940
+ };