weaver-work-cli 0.1.68 → 0.1.70

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 (165) hide show
  1. package/dist/chunks/{archive-SJTC5265.js → archive-VUTREF3P.js} +4 -4
  2. package/dist/chunks/{archive-oa-PN46RTI2.js → archive-oa-VXXO4RTB.js} +4 -4
  3. package/dist/chunks/{asset-XM3Y4FVU.js → asset-45U6TY7I.js} +32 -5
  4. package/dist/chunks/{asset-idle-DHGP3NYY.js → asset-idle-YCRBMTIT.js} +4 -4
  5. package/dist/chunks/{attachment-content-IXIBOET6.js → attachment-content-DMU7KNZ7.js} +3 -3
  6. package/dist/chunks/{blog-JC47AIXK.js → blog-5AML4WMG.js} +4 -4
  7. package/dist/chunks/{caizhilian-IKIHM77A.js → caizhilian-3P7BUNHT.js} +6 -6
  8. package/dist/chunks/{calendar-GZTSJ57Y.js → calendar-2HUXM3CZ.js} +4 -4
  9. package/dist/chunks/{chunk-6OK4LW76.js → chunk-4W6BSNIL.js} +6 -6
  10. package/dist/chunks/{chunk-3W5NMGDS.js → chunk-727VKJQK.js} +2 -2
  11. package/dist/chunks/{chunk-QHKY4WZA.js → chunk-7CINV2BU.js} +2 -2
  12. package/dist/chunks/{chunk-26FCCU5O.js → chunk-DSBV4GRK.js} +3 -3
  13. package/dist/chunks/{chunk-HWA2A25Y.js → chunk-E7VWE2XI.js} +3 -3
  14. package/dist/chunks/{chunk-C5IIIT4D.js → chunk-EHH363SP.js} +4 -4
  15. package/dist/chunks/{chunk-LXXR2RRE.js → chunk-GFOFUH6O.js} +50 -50
  16. package/dist/chunks/{chunk-TJN4PIYO.js → chunk-GTAFCAVP.js} +2 -0
  17. package/dist/chunks/{chunk-O7KPHPXQ.js → chunk-GWM5TLIK.js} +34 -34
  18. package/dist/chunks/{chunk-WSHIOSGM.js → chunk-H2NRTGZR.js} +3 -3
  19. package/dist/chunks/{chunk-YSEHTSHS.js → chunk-HAORST2G.js} +11 -11
  20. package/dist/chunks/{chunk-4WCVRDC5.js → chunk-HG6INLH6.js} +13 -0
  21. package/dist/chunks/{chunk-FDBAFANU.js → chunk-I5XB4MZT.js} +227 -23
  22. package/dist/chunks/{chunk-BJNSTCJK.js → chunk-IVCOZCAW.js} +1 -1
  23. package/dist/chunks/{chunk-Y7RGBRLG.js → chunk-KDOJW5LH.js} +1 -1
  24. package/dist/chunks/{chunk-QO6JYDIW.js → chunk-L2A3COWV.js} +4 -4
  25. package/dist/chunks/{chunk-X7ZTM4XG.js → chunk-LJE7RZNC.js} +1 -1
  26. package/dist/chunks/{chunk-FJUOUSV3.js → chunk-LRKKKO5A.js} +36 -9
  27. package/dist/chunks/{chunk-HLT6B26P.js → chunk-LSVA7QA6.js} +1 -1
  28. package/dist/chunks/{chunk-6N4JPNFL.js → chunk-MD5CW4B6.js} +1 -1
  29. package/dist/chunks/{chunk-Q6D6PSMH.js → chunk-QYDSTYGG.js} +3 -3
  30. package/dist/chunks/{chunk-AFZTMYGC.js → chunk-T24EBWAZ.js} +1 -1
  31. package/dist/chunks/{chunk-6T5X6YWX.js → chunk-U3OO3IZF.js} +3 -3
  32. package/dist/chunks/{chunk-VLY5RTVO.js → chunk-UVWW5ABZ.js} +3 -3
  33. package/dist/chunks/{chunk-NP3ZZFGI.js → chunk-VZUH3LKI.js} +16 -5
  34. package/dist/chunks/{chunk-OKUJY5YB.js → chunk-X6PMJQGO.js} +64 -21
  35. package/dist/chunks/{chunk-3NJQTG6X.js → chunk-XIBMZEDB.js} +2 -2
  36. package/dist/chunks/{conflict-CEXRX2KP.js → conflict-YW5BULJ3.js} +2 -2
  37. package/dist/chunks/{contract-PM3EUPZC.js → contract-3PMHUASH.js} +164 -5
  38. package/dist/chunks/{cowork-34CBYVQP.js → cowork-FZBTTBYX.js} +4 -4
  39. package/dist/chunks/{create-flow-DG6D7U2L.js → create-flow-5OBS3B3V.js} +6 -6
  40. package/dist/chunks/{data-3G4GQS5P.js → data-2YZ6A6TL.js} +19 -4
  41. package/dist/chunks/{ebuilder-form-5ENYH7IF.js → ebuilder-form-AWPTMZBZ.js} +5 -5
  42. package/dist/chunks/{ehr-2CONM7R6.js → ehr-MNPR4TE5.js} +4 -4
  43. package/dist/chunks/{entry-mode-KMP66KHE.js → entry-mode-L65OWPFM.js} +3 -3
  44. package/dist/chunks/{env-SW6CTETI.js → env-XW7LYIME.js} +2 -2
  45. package/dist/chunks/{esb-FQASCY2H.js → esb-GSB5QCEX.js} +6 -6
  46. package/dist/chunks/{factory-ETQAICPA.js → factory-MHFZZAGH.js} +1 -1
  47. package/dist/chunks/{fna-FCLVIWAS.js → fna-XBSNUS2V.js} +4 -4
  48. package/dist/chunks/{group-chat-GTYMCBYS.js → group-chat-EEOLO5NM.js} +3 -3
  49. package/dist/chunks/{host-P7G22WNM.js → host-2UMNXX5H.js} +4 -4
  50. package/dist/chunks/{host-XLCBLNJD.js → host-BD44ASOD.js} +4 -4
  51. package/dist/chunks/{host-2ED2KC4X.js → host-NVDG3NC6.js} +4 -4
  52. package/dist/chunks/{host-46NYKDQP.js → host-R7BP3CTI.js} +4 -4
  53. package/dist/chunks/{host-7IPZKIM4.js → host-SYPCA63D.js} +4 -4
  54. package/dist/chunks/{host-2UYZEY2V.js → host-XVWBOSEN.js} +4 -4
  55. package/dist/chunks/{hrm-5WSMSKPX.js → hrm-FZUDJAND.js} +17 -11
  56. package/dist/chunks/{im-P7GNBRG6.js → im-F5NENPD7.js} +4 -4
  57. package/dist/chunks/{invoice-2QCVNXBG.js → invoice-DS6FLU55.js} +42 -6
  58. package/dist/chunks/{jiuchuanhui-FHGFYAHU.js → jiuchuanhui-JCBUR563.js} +1332 -1037
  59. package/dist/chunks/{lazy-dispatch-K25LTKQY.js → lazy-dispatch-F6O2EPGR.js} +7 -7
  60. package/dist/chunks/{mail-P7VMUKQW.js → mail-ZEOSANEJ.js} +4 -4
  61. package/dist/chunks/{meeting-3PTTPUSG.js → meeting-PCD5EPBF.js} +15 -15
  62. package/dist/chunks/{minute-doc-3IMRJDJV.js → minute-doc-WTZJVCHG.js} +4 -4
  63. package/dist/chunks/{okr-OIWJRYWY.js → okr-OZUMTMCL.js} +4 -4
  64. package/dist/chunks/{operations-MI2BSKZX.js → operations-UTUWFJTX.js} +5 -5
  65. package/dist/chunks/{performance-OPEQNW7Y.js → performance-SMVTPK6T.js} +8 -7
  66. package/dist/chunks/{plan-TJAS4N5X.js → plan-C2NENH42.js} +4 -4
  67. package/dist/chunks/{project-CYBGU6K6.js → project-FAJ2P3UR.js} +4 -4
  68. package/dist/chunks/{reception-2VSWJQ5N.js → reception-NH6MJFPR.js} +16 -8
  69. package/dist/chunks/{recruit-stage-KHJYQE3I.js → recruit-stage-DPEFHLSE.js} +3 -3
  70. package/dist/chunks/{registry-FXBOGH2X.js → registry-3B3OAJYX.js} +4 -4
  71. package/dist/chunks/{registry-QRMXRSCT.js → registry-FTPUUHWC.js} +5 -5
  72. package/dist/chunks/{registry-PHPYTXS4.js → registry-ZQ7OONCB.js} +12 -12
  73. package/dist/chunks/{room-recommend-BKCPAXQG.js → room-recommend-73NBN3RU.js} +4 -4
  74. package/dist/chunks/{schedule-Q3MPSZV6.js → schedule-SDBOBBUQ.js} +4 -4
  75. package/dist/chunks/{smart-extract-TYYKC244.js → smart-extract-GTYKF5TJ.js} +4 -4
  76. package/dist/chunks/{workflow-GEDHALMY.js → workflow-OWHWLAOX.js} +81 -12
  77. package/dist/core/error-codes.js +1 -1
  78. package/dist/core/host-policy.js +56 -0
  79. package/dist/core/timing.js +227 -0
  80. package/dist/index.js +39 -36
  81. package/dist/internal/e10/auth/commands.js +11 -0
  82. package/dist/internal/e10/auth/error-log.js +13 -0
  83. package/dist/internal/e10/auth/messages.js +10 -0
  84. package/dist/internal/e10/auth/xiaoe.js +12 -2
  85. package/dist/internal/e10/context.js +39 -12
  86. package/dist/internal/e10/network-error.js +28 -0
  87. package/dist/internal/e10/tls-policy.js +260 -0
  88. package/dist/shortcuts/asset/manifest.js +34 -1
  89. package/dist/shortcuts/contract/manifest.js +166 -1
  90. package/dist/shortcuts/data/manifest.js +32 -1
  91. package/dist/shortcuts/hrm/index.js +20 -7
  92. package/dist/shortcuts/invoice/manifest.js +43 -1
  93. package/dist/shortcuts/jiuchuanhui/cache.js +49 -35
  94. package/dist/shortcuts/jiuchuanhui/host.js +109 -5
  95. package/dist/shortcuts/jiuchuanhui/index.js +43 -7
  96. package/dist/shortcuts/jiuchuanhui/manifest.js +138 -2
  97. package/dist/shortcuts/jiuchuanhui/operations/customer-quick.js +110 -0
  98. package/dist/shortcuts/jiuchuanhui/operations/datajson.js +11 -56
  99. package/dist/shortcuts/jiuchuanhui/operations/esb.js +9 -16
  100. package/dist/shortcuts/jiuchuanhui/operations/generic.js +8 -30
  101. package/dist/shortcuts/jiuchuanhui/operations/registry.js +8 -2
  102. package/dist/shortcuts/jiuchuanhui/operations/shared.js +0 -10
  103. package/dist/shortcuts/performance/operations/flow-detail.js +5 -4
  104. package/dist/shortcuts/reception/host.js +19 -5
  105. package/dist/shortcuts/workflow/index.js +55 -5
  106. package/dist/shortcuts/workflow/operations/aiDeepRead/collect.js +5 -2
  107. package/dist/shortcuts/workflow/operations/read.js +12 -2
  108. package/dist/shortcuts/workflow/operations/types.js +7 -1
  109. package/dist/shortcuts/workflow/operations/write.js +20 -2
  110. package/dist/shortcuts/workflow/operations.js +19 -1
  111. package/docs/e10-auth.md +48 -1
  112. package/docs/jiuchuanhui.md +17 -5
  113. package/package.json +1 -1
  114. package/scripts/xiaoe_env.py +18 -3
  115. package/skills/weaver-e10-asset-idle/SKILL.md +1 -1
  116. package/skills/weaver-e10-blog/SKILL.md +2 -2
  117. package/skills/weaver-e10-calendar/SKILL.md +1 -1
  118. package/skills/weaver-e10-data/SKILL.md +1 -1
  119. package/skills/weaver-e10-esb/SKILL.md +1 -1
  120. package/skills/weaver-e10-esb/references/source-manifest.json +3 -3
  121. package/skills/weaver-e10-hrm/SKILL.md +1 -1
  122. package/skills/weaver-e10-jiuchuanhui/SKILL.md +49 -90
  123. package/skills/weaver-e10-jiuchuanhui/references/cache.md +17 -13
  124. package/skills/weaver-e10-jiuchuanhui/references/customer.md +33 -4
  125. package/skills/weaver-e10-jiuchuanhui/references/discovery-config.md +3 -3
  126. package/skills/weaver-e10-jiuchuanhui/references/jiuchuanhui-entry.md +9 -7
  127. package/skills/weaver-e10-jucailin/SKILL.md +84 -17
  128. package/skills/weaver-e10-jucailin/agents/openai.yaml +2 -1
  129. package/skills/weaver-e10-jucailin/references/recruit-create.md +7 -8
  130. package/skills/weaver-e10-jucailin/references/recruit-implement-INDEX.md +41 -0
  131. package/skills/weaver-e10-jucailin/references/recruit-implement-consult-sop.md +77 -0
  132. package/skills/weaver-e10-jucailin/references/recruit-implement-guardrails.md +41 -0
  133. package/skills/weaver-e10-jucailin/references/recruit-implement-kb-data-update-channels.md +31 -0
  134. package/skills/weaver-e10-jucailin/references/recruit-implement-kb-form-external.md +43 -0
  135. package/skills/weaver-e10-jucailin/references/recruit-implement-kb-talent-base-form.md +32 -0
  136. package/skills/weaver-e10-jucailin/references/recruit-implement-pattern-external-collect-update-talent.md +93 -0
  137. package/skills/weaver-e10-jucailin/references/recruit-implement-pattern-external-share-edit.md +64 -0
  138. package/skills/weaver-e10-jucailin/references/recruit-read.md +1 -1
  139. package/skills/weaver-e10-jucailin/references/recruit-stage-ops.md +1 -1
  140. package/skills/weaver-e10-jucailin/references/recruit-write.md +4 -11
  141. package/skills/weaver-e10-jucailin/references/safety-boundaries.md +3 -3
  142. package/skills/weaver-e10-mail/SKILL.md +52 -10
  143. package/skills/weaver-e10-mail/references/mail-agent-entry.md +1 -2
  144. package/skills/weaver-e10-meeting/SKILL.md +1 -1
  145. package/skills/weaver-e10-meeting/references/meeting-verification.md +1 -1
  146. package/skills/weaver-e10-okr/SKILL.md +1 -1
  147. package/skills/weaver-e10-okr/references/source-manifest.json +3 -3
  148. package/skills/weaver-e10-performance/SKILL.md +2 -2
  149. package/skills/weaver-e10-performance/agents/openai.yaml +4 -2
  150. package/skills/weaver-e10-performance/references/flow-assess.md +19 -6
  151. package/skills/weaver-e10-plan/SKILL.md +2 -2
  152. package/skills/weaver-e10-plan/references/source-manifest.json +3 -3
  153. package/skills/weaver-e10-qiyecheng/SKILL.md +2 -2
  154. package/skills/weaver-e10-qiyecheng/references/source-manifest.json +3 -3
  155. package/skills/weaver-e10-reception-flow/SKILL.md +53 -16
  156. package/skills/weaver-e10-shared/SKILL.md +4 -9
  157. package/skills/weaver-e10-shared/references/e10-auth-and-session.md +2 -2
  158. package/skills/weaver-e10-shijingran/SKILL.md +14 -6
  159. package/skills/weaver-e10-shijingran/references/source-manifest.json +5 -4
  160. package/skills/weaver-e10-workflow/SKILL.md +2 -2
  161. package/skills/weaver-e10-workflow/references/source-manifest.json +3 -3
  162. package/skills/weaver-e10-workflow/references/workflow-agent-entry.md +1 -2
  163. package/skills/weaver-e10-workflow/references/workflow-deep-read.md +8 -3
  164. package/skills/weaver-e10-ziguanjia/SKILL.md +1 -1
  165. package/skills/weaver-e10-ziguanjia/references/ziguanjia-agent-entry.md +1 -2
@@ -1,8 +1,15 @@
1
1
  import { createRequire as __esbuildCreateRequire } from 'node:module';
2
2
  const require = __esbuildCreateRequire(import.meta.url);
3
3
  import {
4
- reportPlatformError
5
- } from "./chunk-6N4JPNFL.js";
4
+ charsOf,
5
+ compactForStdout
6
+ } from "./chunk-HG6INLH6.js";
7
+ import "./chunk-AJ62BGAW.js";
8
+ import {
9
+ reportPlatformError,
10
+ shouldReportPlatformError,
11
+ toPlatformError
12
+ } from "./chunk-MD5CW4B6.js";
6
13
  import {
7
14
  CONTINUATION_TTL_MS,
8
15
  CONTINUATION_TTL_SECONDS
@@ -12,13 +19,13 @@ import {
12
19
  createE10RequestRuntime,
13
20
  isE10SessionExpiredResponse,
14
21
  requireE10Session
15
- } from "./chunk-FJUOUSV3.js";
22
+ } from "./chunk-LRKKKO5A.js";
16
23
  import {
17
24
  E10_SESSION_EXPIRED_MESSAGE
18
- } from "./chunk-TJN4PIYO.js";
25
+ } from "./chunk-GTAFCAVP.js";
19
26
  import {
20
27
  getActiveProfile
21
- } from "./chunk-FDBAFANU.js";
28
+ } from "./chunk-I5XB4MZT.js";
22
29
  import {
23
30
  CliError,
24
31
  isCliError,
@@ -27,7 +34,7 @@ import {
27
34
  import "./chunk-BUSC6UAE.js";
28
35
 
29
36
  // src/shortcuts/jiuchuanhui/index.ts
30
- import { readFile as readFile2 } from "node:fs/promises";
37
+ import { readFile as readFile3 } from "node:fs/promises";
31
38
 
32
39
  // src/shortcuts/jiuchuanhui/continuation.ts
33
40
  import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
@@ -193,6 +200,59 @@ function businessCode(value) {
193
200
  if (typeof code === "string" || typeof code === "number") return code;
194
201
  return void 0;
195
202
  }
203
+ var RAW_RESPONSE_BUDGET_CHARS = 4096;
204
+ var BUSINESS_MESSAGE_KEYS = ["msg", "message", "resultMsg", "reminderMsg", "failMsg", "errorMsg"];
205
+ var BUSINESS_MESSAGE_CONTAINERS = ["actionData", "responseData", "customData", "mainTable", "data", "result"];
206
+ function deepMessage(value, depth) {
207
+ if (!value || typeof value !== "object" || Array.isArray(value) || depth > 4) return "";
208
+ const record = value;
209
+ for (const key of BUSINESS_MESSAGE_KEYS) {
210
+ const item = record[key];
211
+ if (typeof item === "string" && item.trim()) return item.trim();
212
+ }
213
+ for (const key of BUSINESS_MESSAGE_CONTAINERS) {
214
+ const found = deepMessage(record[key], depth + 1);
215
+ if (found) return found;
216
+ }
217
+ return "";
218
+ }
219
+ function jiuchuanhuiBusinessDetailMessage(value) {
220
+ if (!value || typeof value !== "object" || Array.isArray(value)) return "";
221
+ const root = value;
222
+ const top = jiuchuanhuiBusinessMessage(value);
223
+ for (const key of BUSINESS_MESSAGE_CONTAINERS) {
224
+ const found = deepMessage(root[key], 0);
225
+ if (found && found !== top) return found;
226
+ }
227
+ return "";
228
+ }
229
+ function boundedResponse(value) {
230
+ if (value === void 0) return void 0;
231
+ const chars = charsOf(value);
232
+ if (chars <= RAW_RESPONSE_BUDGET_CHARS) return value;
233
+ const compacted = compactForStdout(value, RAW_RESPONSE_BUDGET_CHARS);
234
+ if (charsOf(compacted) <= RAW_RESPONSE_BUDGET_CHARS) {
235
+ return { note: `\u539F\u59CB\u54CD\u5E94 ${chars} \u5B57\u7B26\uFF0C\u5DF2\u6309\u9884\u7B97\u538B\u7F29\u4E3A\u9884\u89C8`, preview: compacted };
236
+ }
237
+ const keys = value && typeof value === "object" && !Array.isArray(value) ? Object.keys(value).slice(0, 20) : [];
238
+ return { note: `\u539F\u59CB\u54CD\u5E94 ${chars} \u5B57\u7B26\uFF0C\u8D85\u8FC7 ${RAW_RESPONSE_BUDGET_CHARS} \u5B57\u7B26\u9884\u7B97\uFF0C\u672A\u5185\u8054`, keys };
239
+ }
240
+ function failureDetails(value, code, message) {
241
+ const businessMessage = jiuchuanhuiBusinessDetailMessage(value);
242
+ return {
243
+ code,
244
+ message,
245
+ ...businessMessage ? { businessMessage } : {},
246
+ response: boundedResponse(value)
247
+ };
248
+ }
249
+ function claimPermissionMessage(value) {
250
+ const messages = [
251
+ value?.actionData?.responseData?.customData?.mainTable?.msg,
252
+ value?.responseData?.customData?.mainTable?.msg
253
+ ];
254
+ return messages.find((message) => typeof message === "string" && /^您对当前客户无领取权限[,,]\s*无法领取[。.]?$/u.test(message.trim()))?.trim();
255
+ }
196
256
  function assertJiuchuanhuiPath(requestPath) {
197
257
  if (typeof requestPath !== "string" || !requestPath.startsWith("/") || requestPath.startsWith("//")) {
198
258
  throw jiuchuanhuiValidationError("path_invalid", "\u8BF7\u6C42\u8DEF\u5F84\u5FC5\u987B\u662F\u76F8\u5BF9\u7EDD\u5BF9\u8DEF\u5F84");
@@ -245,11 +305,11 @@ function createJiuchuanhuiHost(ctx, dependencies = {}) {
245
305
  fetch: dependencies.fetch
246
306
  });
247
307
  }
248
- async function request(request2) {
308
+ async function send(request2) {
249
309
  const {
250
310
  method,
251
311
  path,
252
- query,
312
+ query: query2,
253
313
  body,
254
314
  operation,
255
315
  timeoutMs = 3e4
@@ -263,7 +323,7 @@ function createJiuchuanhuiHost(ctx, dependencies = {}) {
263
323
  operation,
264
324
  method: resolvedMethod,
265
325
  path,
266
- query: omitEmptyQueryValues(query),
326
+ query: omitEmptyQueryValues(query2),
267
327
  body,
268
328
  timeoutMs
269
329
  });
@@ -273,6 +333,29 @@ function createJiuchuanhuiHost(ctx, dependencies = {}) {
273
333
  if (isE10SessionExpiredResponse(response)) {
274
334
  throw jiuchuanhuiAuthError("session_expired", E10_SESSION_EXPIRED_MESSAGE, { httpStatus: response.status });
275
335
  }
336
+ return response;
337
+ }
338
+ async function query(request2) {
339
+ const response = await send(request2);
340
+ const value = response.parseError ? response.text : response.text ? response.value : null;
341
+ return {
342
+ httpStatus: response.status,
343
+ // Keep the JSON text for stdout so exact types and long numeric IDs survive serialization.
344
+ json: response.parseError ? JSON.stringify(response.text) : response.text || "null",
345
+ value
346
+ };
347
+ }
348
+ async function request(request2) {
349
+ const response = await send(request2);
350
+ if (request2.operation === "jiuchuanhui.customer.open-sea.claim.apply") {
351
+ const message = claimPermissionMessage(response.value);
352
+ if (message) {
353
+ throw new JiuchuanhuiCliError("permission", "claim_forbidden", message, {
354
+ exitCode: 6 /* PolicyError */,
355
+ stage: "esb-response"
356
+ });
357
+ }
358
+ }
276
359
  if (response.parseError) {
277
360
  if (response.status < 200 || response.status >= 300) {
278
361
  throw new JiuchuanhuiCliError("api", "http_error", `\u6CDB\u5FAE\u63A5\u53E3 HTTP ${response.status}`, {
@@ -284,1010 +367,1248 @@ function createJiuchuanhuiHost(ctx, dependencies = {}) {
284
367
  throw jiuchuanhuiNetworkError("protocol", `\u63A5\u53E3\u8FD4\u56DE\u4E0D\u662F\u5408\u6CD5 JSON\uFF08HTTP ${response.status}\uFF09`, { retryable: false });
285
368
  }
286
369
  if (response.status < 200 || response.status >= 300) {
370
+ const message = jiuchuanhuiBusinessMessage(response.value);
287
371
  throw new JiuchuanhuiCliError("api", "http_error", `\u6CDB\u5FAE\u63A5\u53E3 HTTP ${response.status}`, {
288
372
  code: response.status,
289
- details: { status: response.status, message: jiuchuanhuiBusinessMessage(response.value) },
373
+ details: { status: response.status, ...failureDetails(response.value, response.status, message) },
290
374
  exitCode: 1
291
375
  });
292
376
  }
293
377
  if (!isJiuchuanhuiSuccess(response.value)) {
294
- throw new JiuchuanhuiCliError("api", "business_error", jiuchuanhuiBusinessMessage(response.value), {
378
+ const message = jiuchuanhuiBusinessMessage(response.value);
379
+ throw new JiuchuanhuiCliError("api", "business_error", message, {
295
380
  code: businessCode(response.value),
296
- details: { code: businessCode(response.value), message: jiuchuanhuiBusinessMessage(response.value) },
381
+ details: failureDetails(response.value, businessCode(response.value), message),
297
382
  exitCode: 1
298
383
  });
299
384
  }
300
385
  return response.value;
301
386
  }
302
- return { request, getSession };
387
+ return { request, query, getSession };
303
388
  }
304
389
 
305
- // src/shortcuts/jiuchuanhui/manifest.ts
306
- var pageProps = {
307
- pageNo: { type: "integer", minimum: 1, default: 1 },
308
- pageSize: { type: "integer", minimum: 1, maximum: 200, default: 10 },
309
- count: { type: "boolean", description: "\u662F\u5426\u5E76\u884C\u8BF7\u6C42\u603B\u6570\u63A5\u53E3" }
310
- };
311
- var idProp = { type: "string", pattern: "^[1-9]\\d*$" };
312
- var formProp = {
313
- type: "object",
314
- additionalProperties: true,
315
- 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"
316
- };
317
- var esbWriteProps = (keys) => {
318
- const props = {};
319
- for (const key of keys) props[key] = { type: "string", description: `\u52A8\u4F5C\u6D41\u4E1A\u52A1\u53C2\u6570 ${key}` };
320
- return props;
390
+ // src/shortcuts/jiuchuanhui/operations/customer-quick.ts
391
+ import { readFile as readFile2 } from "node:fs/promises";
392
+
393
+ // src/shortcuts/jiuchuanhui/cache.ts
394
+ import { existsSync as existsSync2, mkdirSync, readFileSync, writeFileSync } from "node:fs";
395
+ import { homedir as homedir2 } from "node:os";
396
+ import { dirname, join } from "node:path";
397
+ var APP_TAG = "jch-crm-project";
398
+ var MIN_VERSION = "1.5.11";
399
+ var REGION_CONCURRENCY = 4;
400
+ function jiuchuanhuiCacheFile(tenantKey, userId) {
401
+ const root = process.env.WEAVER_E10_JIUCHUANHUI_HOME || join(homedir2(), ".weaver-e10-jiuchuanhui");
402
+ return join(root, tenantKey, userId, "weaver-e10-jiuchuanhui.json");
403
+ }
404
+ var MODULE_TAGS = [
405
+ "uf_jch_customer",
406
+ "uf_jch_sale",
407
+ "uf_jch_clue",
408
+ "uf_jch_contact",
409
+ "uf_jch_customer_open_sea",
410
+ "uf_jch_remind",
411
+ "uf_jch_rival",
412
+ "uf_jch_sale_process",
413
+ "uf_jch_sale_stage",
414
+ "uf_jch_clue_pool",
415
+ "uf_jch_lose_reason",
416
+ "uf_jch_customer_cmt",
417
+ "uf_jch_sale_cmt"
418
+ ];
419
+ var CREATE_PKS = ["customer_create_api", "sale_create_api", "ebclue_ai_create_api", "contact_create_api", "ebcontact_plan_create_api"];
420
+ var SEARCH_PKS = ["ebcustomer_search_api", "ebsale_search_api", "ebclue_ai_search_api"];
421
+ var UPDATE_PKS = ["customer_update_api", "sale_update_api", "ebclue_ai_update_api", "contact_update_api"];
422
+ var ALL_PKS = [...CREATE_PKS, ...SEARCH_PKS, ...UPDATE_PKS];
423
+ var PK_TO_TAG = {
424
+ customer_create_api: "uf_jch_customer",
425
+ sale_create_api: "uf_jch_sale",
426
+ ebclue_ai_create_api: "uf_jch_clue",
427
+ contact_create_api: "uf_jch_contact",
428
+ ebcontact_plan_create_api: "uf_jch_remind",
429
+ ebcustomer_search_api: "uf_jch_customer",
430
+ ebsale_search_api: "uf_jch_sale",
431
+ ebclue_ai_search_api: "uf_jch_clue",
432
+ customer_update_api: "uf_jch_customer",
433
+ sale_update_api: "uf_jch_sale",
434
+ ebclue_ai_update_api: "uf_jch_clue",
435
+ contact_update_api: "uf_jch_contact"
321
436
  };
322
- var esbWriteSchema = (keys, required = keys) => ({
323
- type: "object",
324
- additionalProperties: false,
325
- properties: esbWriteProps(keys),
326
- required
327
- });
328
- function writePair(baseName, title, props, required = [], fixed = {}, withPrepare = true) {
329
- const list = [];
330
- if (withPrepare) {
331
- list.push({
332
- name: `${baseName}.prepare`,
333
- risk: "read-before-write",
334
- fixed: { ...fixed, stage: "prepare" },
335
- inputSchema: {
336
- type: "object",
337
- additionalProperties: false,
338
- properties: {
339
- mainTable: {
340
- type: "object",
341
- additionalProperties: false,
342
- properties: props,
343
- ...required.length ? { required } : {}
344
- }
345
- },
346
- required: ["mainTable"]
347
- }
348
- });
437
+ var DETAIL_KEEP_KEYS = ["id", "interfacePk", "interfaceName", "datasNumber", "datasSize", "mainFields", "detailFields", "interfaceType", "relevanceForm"];
438
+ var FIELD_KEEP_KEYS = ["fieldid", "isRequired", "isInput", "data_key", "title", "component_type"];
439
+ var OPT_COMP = ["Select", "RadioBox", "CheckBox"];
440
+ var EBUILDER_QUERIES = [
441
+ { key: "customer_open_sea", path: "/api/ebuilder/form/formdata/v2/getFormDataList/customer_open_sea_search_api", nameFields: ["open_sea_name", "name"] },
442
+ { key: "sale_stage", path: "/api/ebuilder/form/formdata/v2/getFormDataList/sale_stage_search_api", nameFields: ["stage_name", "name"] },
443
+ { key: "sale_process", path: "/api/ebuilder/form/formdata/v2/getFormDataList/sale_process_sear_api", nameFields: ["process_name", "name"] },
444
+ { key: "clue_pool", path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcluepool_ai_search_api", nameFields: ["clue_pool_name", "name"] },
445
+ { key: "sale_lose_reason", path: "/api/ebuilder/form/formdata/v2/getFormDataList/sale_lose_reason", nameFields: ["reason_name", "name"] },
446
+ { key: "customer_industry", path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_industry_search_api", nameFields: ["industry_name", "name"] },
447
+ { key: "customer_type", path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_type_search_api", nameFields: ["type_name", "name"] },
448
+ { key: "customer_status", path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_status_search_api", nameFields: ["state_name", "name"] }
449
+ ];
450
+ var REGION_CITIES = [
451
+ "\u5317\u4EAC\u5E02",
452
+ "\u4E0A\u6D77\u5E02",
453
+ "\u5929\u6D25\u5E02",
454
+ "\u91CD\u5E86\u5E02",
455
+ "\u6210\u90FD\u5E02",
456
+ "\u5E7F\u5DDE\u5E02",
457
+ "\u6DF1\u5733\u5E02",
458
+ "\u4E1C\u839E\u5E02",
459
+ "\u676D\u5DDE\u5E02",
460
+ "\u5357\u4EAC\u5E02",
461
+ "\u82CF\u5DDE\u5E02",
462
+ "\u6B66\u6C49\u5E02",
463
+ "\u957F\u6C99\u5E02",
464
+ "\u897F\u5B89\u5E02",
465
+ "\u90D1\u5DDE\u5E02",
466
+ "\u6D4E\u5357\u5E02",
467
+ "\u9752\u5C9B\u5E02",
468
+ "\u53A6\u95E8\u5E02",
469
+ "\u798F\u5DDE\u5E02",
470
+ "\u5408\u80A5\u5E02",
471
+ "\u6C88\u9633\u5E02",
472
+ "\u5927\u8FDE\u5E02"
473
+ ];
474
+ function pickKeys(obj, keys) {
475
+ const out = {};
476
+ for (const k of keys) if (obj?.[k] !== void 0) out[k] = obj[k];
477
+ return out;
478
+ }
479
+ var isInputOne = (f) => String(f?.isInput) === "1";
480
+ function semverGte(a, b) {
481
+ const pa = String(a || "").split(".").map((x) => parseInt(x, 10) || 0);
482
+ const pb = b.split(".").map((x) => parseInt(x, 10) || 0);
483
+ for (let i = 0; i < 3; i++) {
484
+ if ((pa[i] || 0) !== (pb[i] || 0)) return (pa[i] || 0) > (pb[i] || 0);
349
485
  }
350
- list.push({
351
- name: `${baseName}.apply`,
352
- risk: "high-risk-write",
353
- fixed: { ...fixed, stage: "apply" },
354
- inputSchema: {
355
- type: "object",
356
- additionalProperties: false,
357
- properties: {
358
- continuation: { type: "string", minLength: 1 },
359
- confirm: { const: true }
360
- },
361
- required: ["continuation", "confirm"]
486
+ return true;
487
+ }
488
+ function searchConditionRows(value) {
489
+ if (typeof value === "string") {
490
+ try {
491
+ value = JSON.parse(value);
492
+ } catch {
493
+ return void 0;
362
494
  }
363
- });
364
- return list;
495
+ }
496
+ return Array.isArray(value?.datas) ? value.datas : void 0;
365
497
  }
366
- var jiuchuanhuiOperations = [
367
- // ==================== 发现与配置 ====================
368
- {
369
- name: "jiuchuanhui.cache.init",
370
- risk: "local-file-write",
371
- fixed: { path: "local:cache", purpose: "\u4E5D\u6C1A\u6C47\u914D\u7F6E\u7F13\u5B58\u521D\u59CB\u5316/\u5237\u65B0" },
372
- inputSchema: {
373
- type: "object",
374
- additionalProperties: false,
375
- properties: {
376
- dryRun: { type: "boolean", description: "\u53EA\u62C9\u53D6\u4E0D\u5199\u5165\uFF08\u9884\u89C8\uFF09" },
377
- verbose: { type: "boolean", description: "\u8FD4\u56DE\u66F4\u591A\u6B65\u9AA4\u660E\u7EC6" }
498
+ function successCheck(value) {
499
+ if (!value || typeof value !== "object") return false;
500
+ if (value.resultCode !== void 0 && value.resultCode !== null) return Number(value.resultCode) === 200;
501
+ if (value.datajson && typeof value.datajson === "object") {
502
+ const status = value.datajson.status;
503
+ if (status === "true" || status === true) return true;
504
+ if (status === "false" || status === false) return false;
505
+ }
506
+ const code = value.code ?? value.res_base?.ret;
507
+ if (code !== void 0 && code !== null) return Number(code) === 0 || Number(code) === 200;
508
+ return typeof value.success === "boolean" ? value.success : false;
509
+ }
510
+ var CacheInitOperation = class {
511
+ name = "jiuchuanhui.cache.init";
512
+ async execute(input, { host }) {
513
+ const dryRun = input.dryRun === true;
514
+ const verbose = input.verbose === true;
515
+ const session = await host.getSession();
516
+ const tenantKey = session.tenantKey || "";
517
+ const userId = session.userId || "";
518
+ if (!tenantKey || !userId) {
519
+ 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");
520
+ }
521
+ const mainFile = jiuchuanhuiCacheFile(tenantKey, String(userId));
522
+ const baseDir = dirname(mainFile);
523
+ const cfgDir = join(baseDir, "config");
524
+ let old = {};
525
+ if (existsSync2(mainFile)) {
526
+ try {
527
+ old = JSON.parse(readFileSync(mainFile, "utf-8"));
528
+ } catch {
378
529
  }
379
530
  }
380
- },
381
- {
382
- name: "jiuchuanhui.app.discovery",
383
- risk: "read",
384
- fixed: { path: "/api/bs/ebuilder/app/tags/getAppIds", method: "GET" },
385
- inputSchema: {
386
- type: "object",
387
- additionalProperties: false,
388
- properties: {
389
- tag: { type: "string", description: "\u5E94\u7528\u6807\u7B7E\uFF1B\u5FC5\u586B\uFF0C\u5E38\u7528 jch-crm-project\uFF08\u4E0D\u4F1A\u81EA\u52A8\u6CE8\u5165\u9ED8\u8BA4\u503C\uFF09" }
390
- },
391
- required: ["tag"]
531
+ const discovery = {};
532
+ const appResp = await host.request({
533
+ method: "GET",
534
+ path: "/api/bs/ebuilder/app/tags/getAppIds",
535
+ query: { tag: APP_TAG },
536
+ operation: this.name
537
+ });
538
+ if (!successCheck(appResp)) throw jiuchuanhuiValidationError("init_failed", "app.discovery \u672A\u6210\u529F\uFF0C\u65E0\u6CD5\u521D\u59CB\u5316\u7F13\u5B58");
539
+ const rawApp = appResp?.data ?? appResp?.datajson?.datas;
540
+ const appId = Array.isArray(rawApp) && rawApp[0] ? String(rawApp[0]) : null;
541
+ if (!appId) throw jiuchuanhuiValidationError("init_failed", "\u6B65\u9AA4 1 \u672A\u53D6\u5F97 appId\uFF0C\u8BF7\u68C0\u67E5 E10 \u767B\u5F55\u6001");
542
+ discovery[`appId:${APP_TAG}`] = appId;
543
+ for (const tag of MODULE_TAGS) {
544
+ const resp = await host.request({
545
+ method: "GET",
546
+ path: "/api/ebuilder/form/obj/getObjsByTag",
547
+ query: { tag, appId },
548
+ operation: this.name
549
+ });
550
+ const list = Array.isArray(resp?.data) ? resp.data : resp?.datajson?.datas ?? [];
551
+ const hit = list.find((o) => o?.formId && String(o.formId) !== "0") ?? list?.[0];
552
+ if (hit?.id) discovery[`objId:${tag}`] = String(hit.id);
392
553
  }
393
- },
394
- {
395
- name: "jiuchuanhui.form.discovery",
396
- risk: "read",
397
- fixed: { path: "/api/ebuilder/form/obj/getObjsByTag", method: "GET" },
398
- inputSchema: {
399
- type: "object",
400
- additionalProperties: false,
401
- properties: {
402
- tag: { type: "string", description: "\u8868\u5355 tag\uFF0C\u5982 uf_jch_customer" },
403
- appId: { type: "string" }
404
- },
405
- required: ["tag", "appId"]
406
- }
407
- },
408
- {
409
- name: "jiuchuanhui.field.options",
410
- risk: "read",
411
- fixed: { path: "/api/ebuilder/common/ds/options", method: "GET", sourceType: "FORM", optionLevel: 1 },
412
- inputSchema: {
413
- type: "object",
414
- additionalProperties: false,
415
- properties: {
416
- fieldName: { type: "string", description: "\u5B57\u6BB5\u5143\u6570\u636EID\uFF08fieldid\uFF09\uFF0C\u4E0D\u662F data_key \u540D\u79F0" },
417
- sourceType: { type: "string", default: "FORM" },
418
- objId: { type: "string", description: "\u8868\u5355\u5BF9\u8C61ID\uFF0C\u53EF\u7701\u7565\u81EA\u52A8\u53D1\u73B0" },
419
- 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" }
420
- },
421
- required: ["fieldName", "sourceType"]
554
+ try {
555
+ const spResp = await host.request({
556
+ method: "GET",
557
+ path: "/api/installer/public/querySpAppVersionInfo",
558
+ query: { appId },
559
+ operation: this.name
560
+ });
561
+ const sp = spResp?.data;
562
+ const commitVersion = typeof sp === "object" && sp !== null ? String(sp.commitVersion ?? sp.version ?? "") : "";
563
+ if (commitVersion) {
564
+ discovery[`spVersion:${APP_TAG}`] = { commitVersion, passed: semverGte(commitVersion, MIN_VERSION) };
565
+ }
566
+ } catch {
422
567
  }
423
- },
424
- {
425
- name: "jiuchuanhui.rest.cfg.detail",
426
- risk: "read",
427
- fixed: { path: "/api/bs/ebuilder/form/formdata/getRestCfgById", method: "GET" },
428
- inputSchema: {
429
- type: "object",
430
- additionalProperties: false,
431
- properties: {
432
- apid: { type: "string", description: "\u5E94\u7528 ID" },
433
- id: { type: "string", description: "\u63A5\u53E3\u914D\u7F6E ID (cfgId)" }
434
- },
435
- required: ["apid", "id"]
568
+ const cfgMap = {};
569
+ for (const pk of ALL_PKS) {
570
+ const resp = await host.request({
571
+ path: "/api/esb/server/event/triggerActionFlow",
572
+ body: { customParams: { mainTable: { interface_pk: pk } }, uniqueIndent: "4F6E1A9702864666803CCA6B77B86227", employeeId: userId },
573
+ operation: this.name
574
+ });
575
+ const cfgId = resp?.actionData?.responseData?.customData?.mainTable?.cfgId ?? resp?.customData?.mainTable?.cfgId ?? resp?.datajson?.mainTable?.cfgId ?? resp?.data?.mainTable?.cfgId ?? resp?.mainTable?.cfgId;
576
+ if (cfgId) cfgMap[pk] = String(cfgId);
436
577
  }
437
- },
438
- {
439
- name: "jiuchuanhui.config.id.by.pk",
440
- risk: "read",
441
- fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "4F6E1A9702864666803CCA6B77B86227" },
442
- inputSchema: {
443
- type: "object",
444
- additionalProperties: false,
445
- properties: {
446
- mainTable: {
447
- type: "object",
448
- additionalProperties: false,
449
- properties: { interface_pk: { type: "string" } },
450
- required: ["interface_pk"]
578
+ const perPk = {};
579
+ const searchConditions = /* @__PURE__ */ new Map();
580
+ for (const pk of Object.keys(cfgMap)) {
581
+ const cfgId = cfgMap[pk];
582
+ const resp = await host.request({
583
+ method: "GET",
584
+ path: "/api/bs/ebuilder/form/formdata/getRestCfgById",
585
+ query: { apid: appId, id: cfgId },
586
+ operation: this.name
587
+ });
588
+ const detail = resp?.data ?? {};
589
+ if (SEARCH_PKS.includes(pk)) {
590
+ const rows = searchConditionRows(detail.conditions);
591
+ if (rows) searchConditions.set(pk, rows);
592
+ }
593
+ if (!detail?.id && !detail?.mainFields) continue;
594
+ const allFields = [
595
+ ...detail.mainFields || [],
596
+ ...(detail.detailFields || []).flatMap((df) => df.fields || [])
597
+ ];
598
+ const fieldIds = [...new Set(allFields.filter(isInputOne).map((f) => String(f.fieldid)).filter(Boolean))];
599
+ const infoMap = /* @__PURE__ */ new Map();
600
+ if (fieldIds.length > 0) {
601
+ try {
602
+ const infoResp = await host.request({
603
+ path: "/api/esb/server/event/triggerActionFlow",
604
+ body: { customParams: { mainTable: { fieldids: fieldIds.join(",") } }, uniqueIndent: "10351A4DC8D4454A9F1957FBE647CD9F", employeeId: userId },
605
+ operation: this.name
606
+ });
607
+ const list = infoResp?.actionData?.responseData?.customData?.mainTable?.fieldInfoList ?? infoResp?.customData?.mainTable?.fieldInfoList ?? infoResp?.datajson?.mainTable?.fieldInfoList ?? infoResp?.fieldInfoList ?? [];
608
+ for (const it of list) infoMap.set(String(it.id), it);
609
+ } catch {
451
610
  }
452
- },
453
- required: ["mainTable"]
454
- }
455
- },
456
- {
457
- name: "jiuchuanhui.file.preview",
458
- risk: "read",
459
- fixed: { path: "/api/file/preview", method: "GET", module: "ebuilderform", authModule: "ebuilderform", source: "form" },
460
- inputSchema: {
461
- type: "object",
462
- additionalProperties: false,
463
- properties: {
464
- fileId: { type: "string" },
465
- fieldId: { type: "string" },
466
- appId: { type: "string" },
467
- customParam: { type: ["string", "object"] }
468
- },
469
- required: ["fileId"]
470
- }
471
- },
472
- // ==================== 客户 ====================
473
- ...writePair("jiuchuanhui.customer.create", "\u5BA2\u6237\u521B\u5EFA", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/saveFormData/customer_create_api" }),
474
- {
475
- name: "jiuchuanhui.customer.get",
476
- risk: "read",
477
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataByPk/customer_get_api" },
478
- inputSchema: { type: "object", additionalProperties: false, properties: { id: idProp }, required: ["id"] }
479
- },
480
- {
481
- name: "jiuchuanhui.customer.search",
482
- risk: "read",
483
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_search_api", countPath: "/api/ebuilder/form/formdata/v2/getFormDataCount/ebcustomer_search_count_api" },
484
- inputSchema: {
485
- type: "object",
486
- additionalProperties: true,
487
- 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",
488
- properties: pageProps
611
+ }
612
+ const merge = (f) => {
613
+ const info = infoMap.get(String(f?.fieldid));
614
+ if (info) {
615
+ f.data_key = info.data_key ?? f.data_key;
616
+ f.title = info.title ?? f.title;
617
+ f.component_type = info.component_type ?? f.component_type;
618
+ }
619
+ };
620
+ detail.mainFields = (detail.mainFields || []).filter(isInputOne);
621
+ detail.detailFields = (detail.detailFields || []).map((df) => ({ ...df, fields: (df.fields || []).filter(isInputOne) })).filter((df) => Array.isArray(df.fields) && df.fields.length > 0);
622
+ for (const f of detail.mainFields) merge(f);
623
+ for (const df of detail.detailFields) for (const f of df.fields) merge(f);
624
+ const kept = pickKeys(detail, DETAIL_KEEP_KEYS);
625
+ if (Array.isArray(kept.mainFields)) kept.mainFields = kept.mainFields.map((f) => pickKeys(f, FIELD_KEEP_KEYS));
626
+ if (Array.isArray(kept.detailFields)) {
627
+ kept.detailFields = kept.detailFields.map((df) => ({
628
+ ...pickKeys(df, ["id", "fieldName", "title", "fields"]),
629
+ fields: Array.isArray(df.fields) ? df.fields.map((f) => pickKeys(f, FIELD_KEEP_KEYS)) : []
630
+ }));
631
+ }
632
+ perPk[pk] = { cfgId, detail: kept };
489
633
  }
490
- },
491
- {
492
- name: "jiuchuanhui.customer.type.search",
493
- risk: "read",
494
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_type_search_api" },
495
- inputSchema: { type: "object", additionalProperties: false, properties: pageProps }
496
- },
497
- {
498
- name: "jiuchuanhui.customer.status.search",
499
- risk: "read",
500
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_status_search_api" },
501
- inputSchema: { type: "object", additionalProperties: false, properties: pageProps }
502
- },
503
- {
504
- name: "jiuchuanhui.customer.industry.search",
505
- risk: "read",
506
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_industry_search_api" },
507
- inputSchema: { type: "object", additionalProperties: false, properties: pageProps }
508
- },
509
- {
510
- name: "jiuchuanhui.customer.open-sea.search",
511
- risk: "read",
512
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/customer_open_sea_search_api" },
513
- inputSchema: { type: "object", additionalProperties: true, properties: pageProps }
514
- },
515
- ...writePair("jiuchuanhui.customer.update", "\u5BA2\u6237\u4FEE\u6539", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/updateFormData/customer_update_api" }),
516
- ...writePair("jiuchuanhui.customer.transfer", "\u5BA2\u6237\u8F6C\u79FB", esbWriteProps(["customerId", "employee_MappingId", "employeeName"]), ["customerId"], { uniqueIndent: "1E44ED7DA9EB46329818E682C2914928" }),
517
- ...writePair("jiuchuanhui.customer.open-sea.release", "\u5BA2\u6237\u91CA\u653E\u516C\u6D77", esbWriteProps(["customerId", "openSeaId"]), ["customerId", "openSeaId"], { uniqueIndent: "0E29AD0E708D4964B071D293288B92D7" }),
518
- ...writePair("jiuchuanhui.customer.open-sea.claim", "\u9886\u53D6\u516C\u6D77\u5BA2\u6237", esbWriteProps(["customer_id"]), ["customer_id"], { uniqueIndent: "D587CDC892FE41118DD073475C01A2CE" }),
519
- {
520
- name: "jiuchuanhui.customer.duplicate.check",
521
- risk: "read",
522
- fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "D5D0A1C30E7B404B842987C0AD3B749D" },
523
- inputSchema: {
524
- type: "object",
525
- additionalProperties: false,
526
- properties: { mainTable: esbWriteSchema(["name", "simpleName"], ["name", "simpleName"]) },
527
- required: ["mainTable"]
634
+ const ebuilder = {};
635
+ for (const { key, path, nameFields } of EBUILDER_QUERIES) {
636
+ const list = [];
637
+ let pageNo = 1;
638
+ for (; ; ) {
639
+ const resp = await host.request({
640
+ path,
641
+ body: { datajson: { mainTable: {}, pageInfo: { pageNo, pageSize: 100 }, header: { operator: userId } } },
642
+ operation: this.name
643
+ });
644
+ const items = resp?.datajson?.datas ?? resp?.data ?? [];
645
+ list.push(...Array.isArray(items) ? items : []);
646
+ const hasMore = resp?.hasMore ?? (Array.isArray(items) && items.length === 100);
647
+ if (!hasMore || list.length >= 500 || pageNo >= 5) break;
648
+ pageNo += 1;
649
+ }
650
+ ebuilder[key] = list.map((it) => {
651
+ const mt = it?.mainTable ?? it ?? {};
652
+ let name = "";
653
+ for (const nf of nameFields) {
654
+ if (mt[nf] !== void 0 && mt[nf] !== null && String(mt[nf]) !== "") {
655
+ name = String(mt[nf]);
656
+ break;
657
+ }
658
+ }
659
+ const item = { id: String(mt.id ?? ""), name };
660
+ if (key === "sale_stage" && mt.sale_process !== void 0) {
661
+ const sp = Array.isArray(mt.sale_process) ? mt.sale_process[0] : mt.sale_process;
662
+ if (sp && typeof sp === "object") item.sale_process = { id: String(sp.id ?? ""), name: String(sp.name ?? "") };
663
+ }
664
+ return item;
665
+ }).filter((x) => x.id);
528
666
  }
529
- },
530
- ...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" }),
531
- ...writePair("jiuchuanhui.customer.contact-record.batch", "\u6279\u91CF\u6DFB\u52A0\u5BA2\u6237\u8054\u7CFB\u8BB0\u5F55", esbWriteProps(["entityList", "content"]), ["entityList", "content"], { uniqueIndent: "D0F315619FE34C669AE738ED68329FAB" }),
532
- // ==================== 联系人 ====================
533
- ...writePair("jiuchuanhui.contact.create", "\u8054\u7CFB\u4EBA\u521B\u5EFA", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/saveFormData/contact_create_api" }),
534
- {
535
- name: "jiuchuanhui.contact.get",
536
- risk: "read",
537
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataByPk/contact_get_api" },
538
- inputSchema: { type: "object", additionalProperties: false, properties: { id: idProp }, required: ["id"] }
539
- },
540
- ...writePair("jiuchuanhui.contact.update", "\u8054\u7CFB\u4EBA\u4FEE\u6539", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/updateFormData/contact_update_api" }),
541
- {
542
- name: "jiuchuanhui.contact.by-entity.search",
543
- risk: "read",
544
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcontact_search_by_entity_api" },
545
- inputSchema: {
546
- type: "object",
547
- additionalProperties: true,
548
- properties: { ...pageProps, customerId: { type: "string" }, saleChanceId: { type: "string" } }
667
+ const options = {};
668
+ for (const pk of Object.keys(perPk)) {
669
+ const tag = PK_TO_TAG[pk];
670
+ const objId = discovery[`objId:${tag}`];
671
+ if (!objId) continue;
672
+ const detail = perPk[pk].detail ?? {};
673
+ const fields = [
674
+ ...detail.mainFields || [],
675
+ ...(detail.detailFields || []).flatMap((d) => d.fields || [])
676
+ ];
677
+ for (const f of fields) {
678
+ if (!f?.fieldid) continue;
679
+ if (!OPT_COMP.includes(f.component_type)) continue;
680
+ const key = `options:${f.fieldid}:*:1`;
681
+ if (options[key]) continue;
682
+ try {
683
+ const resp = await host.request({
684
+ method: "GET",
685
+ path: "/api/ebuilder/common/ds/options",
686
+ query: { fieldName: String(f.fieldid), objId, groupId: appId, optionLevel: 1 },
687
+ operation: this.name
688
+ });
689
+ const values = resp?.data ?? resp?.datajson?.datas ?? [];
690
+ options[key] = {
691
+ lable: `${pk}.${f.data_key ?? f.fieldid}`,
692
+ lableTitle: `${pk}.${f.title ?? f.data_key ?? f.fieldid}`,
693
+ value: (Array.isArray(values) ? values : []).map((v) => ({
694
+ label: String(v?.lable ?? v?.label ?? v?.text ?? v?.name ?? ""),
695
+ value: String(v?.value ?? v?.val ?? v?.id ?? "")
696
+ }))
697
+ };
698
+ } catch {
699
+ }
700
+ }
549
701
  }
550
- },
551
- // ==================== 商机 ====================
552
- ...writePair("jiuchuanhui.sale.create", "\u5546\u673A\u521B\u5EFA", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/saveFormData/sale_create_api" }),
553
- {
554
- name: "jiuchuanhui.sale.get",
555
- risk: "read",
556
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataByPk/sale_get_api" },
557
- inputSchema: { type: "object", additionalProperties: false, properties: { id: idProp }, required: ["id"] }
558
- },
559
- {
560
- name: "jiuchuanhui.sale.search",
561
- risk: "read",
562
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebsale_search_api", countPath: "/api/ebuilder/form/formdata/v2/getFormDataCount/ebsale_search_count_api" },
563
- inputSchema: { type: "object", additionalProperties: true, properties: pageProps }
564
- },
565
- ...writePair("jiuchuanhui.sale.update", "\u5546\u673A\u4FEE\u6539", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/updateFormData/sale_update_api" }),
566
- {
567
- name: "jiuchuanhui.sale.stage.search",
568
- risk: "read",
569
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/sale_stage_search_api" },
570
- inputSchema: { type: "object", additionalProperties: false, properties: pageProps }
571
- },
572
- {
573
- name: "jiuchuanhui.sale.process.search",
574
- risk: "read",
575
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/sale_process_sear_api" },
576
- inputSchema: { type: "object", additionalProperties: false, properties: pageProps }
577
- },
578
- {
579
- name: "jiuchuanhui.sale.lose-reason.search",
580
- risk: "read",
581
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/sale_lose_reason" },
582
- inputSchema: { type: "object", additionalProperties: false, properties: pageProps }
583
- },
584
- {
585
- name: "jiuchuanhui.rival.search",
586
- risk: "read",
587
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebrival_search_api" },
588
- inputSchema: { type: "object", additionalProperties: false, properties: pageProps }
589
- },
590
- ...writePair("jiuchuanhui.sale.win", "\u5546\u673A\u8D62\u5355", esbWriteProps(["saleId"]), ["saleId"], { uniqueIndent: "3B23E782E5084F18A904E895BBD61A96" }),
591
- ...writePair("jiuchuanhui.sale.lose", "\u5546\u673A\u8F93\u5355", esbWriteProps(["saleid", "money", "reasonids", "rivals", "desc"]), ["saleid"], { uniqueIndent: "DE35D926F82F49FDBA26B48B0CA1CB53" }),
592
- ...writePair("jiuchuanhui.sale.invalid", "\u5546\u673A\u65E0\u6548", esbWriteProps(["saleId"]), ["saleId"], { uniqueIndent: "4D88AB8677D84BAC90B63137E7FA1FF9" }),
593
- ...writePair("jiuchuanhui.sale.pause", "\u5546\u673A\u6682\u505C", esbWriteProps(["saleId", "pauseReason", "restartDate"]), ["saleId", "pauseReason"], { uniqueIndent: "859C73403DCC4F01B02329571BDBD9F3" }),
594
- ...writePair("jiuchuanhui.sale.restart", "\u5546\u673A\u91CD\u542F", esbWriteProps(["saleChanceId"]), ["saleChanceId"], { uniqueIndent: "F3004CDCA8A548B5A0DACD3CDE62387A" }),
595
- ...writePair("jiuchuanhui.sale.manager-change", "\u5546\u673A\u8F6C\u79FB/\u8D1F\u8D23\u4EBA\u53D8\u66F4", esbWriteProps(["saleChanceId", "managerId"]), ["saleChanceId", "managerId"], { uniqueIndent: "595F9C6F1C4248929B83086F71363BA7" }),
596
- ...writePair("jiuchuanhui.sale.link-contacts", "\u5546\u673A\u5173\u8054\u8054\u7CFB\u4EBA", esbWriteProps(["salechanceId", "contactIds"]), ["salechanceId", "contactIds"], { uniqueIndent: "1114A713A62F4CA9899CC24ED5902D93" }),
597
- ...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" }),
598
- // ==================== 线索 ====================
599
- ...writePair("jiuchuanhui.clue.create", "\u7EBF\u7D22\u521B\u5EFA", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/saveFormData/ebclue_ai_create_api" }),
600
- {
601
- name: "jiuchuanhui.clue.get",
602
- risk: "read",
603
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataByPk/ebcluepool_ai_get_api" },
604
- inputSchema: { type: "object", additionalProperties: false, properties: { id: idProp }, required: ["id"] }
605
- },
606
- {
607
- name: "jiuchuanhui.clue.search",
608
- risk: "read",
609
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebclue_ai_search_api", countPath: "/api/ebuilder/form/formdata/v2/getFormDataCount/ebclue_ai_search_count_api" },
610
- inputSchema: { type: "object", additionalProperties: true, properties: pageProps }
611
- },
612
- {
613
- name: "jiuchuanhui.clue.pool.search",
614
- risk: "read",
615
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcluepool_ai_search_api" },
616
- inputSchema: { type: "object", additionalProperties: true, properties: pageProps }
617
- },
618
- ...writePair("jiuchuanhui.clue.update", "\u7EBF\u7D22\u4FEE\u6539", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/updateFormData/ebclue_ai_update_api" }),
619
- ...writePair("jiuchuanhui.clue.status-change", "\u7EBF\u7D22\u72B6\u6001\u53D8\u66F4", esbWriteProps(["clueid", "type", "newmanager", "desc"]), ["clueid", "type"], { uniqueIndent: "257CC8DE42234F9191439B229839B8A7" }),
620
- ...writePair("jiuchuanhui.clue.to-customer", "\u7EBF\u7D22\u8F6C\u5DF2\u6709\u5BA2\u6237", esbWriteProps(["clueId", "customerId"]), ["clueId", "customerId"], { uniqueIndent: "00914C6415EB455DB7FCCC32DBE6E0C3" }),
621
- ...writePair("jiuchuanhui.clue.contact-record.create", "\u65B0\u5EFA\u7EBF\u7D22\u8DDF\u8FDB\u8BB0\u5F55", esbWriteProps(["clueId", "content", "clueStatus_MappingId"]), ["clueId", "content"], { uniqueIndent: "B3DD120601344320A2B50A042B450681" }),
622
- // ==================== 联系计划 ====================
623
- ...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" }),
624
- ...writePair("jiuchuanhui.contact-plan.complete", "\u5B8C\u6210\u8054\u7CFB\u8BA1\u5212", esbWriteProps(["planId"]), ["planId"], { uniqueIndent: "2595D3556CFC414F85B1A4A8D806EFE5" }),
625
- // ==================== 联系记录 ====================
626
- {
627
- name: "jiuchuanhui.entity.contact-records.list",
628
- risk: "read",
629
- fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "364A9713D10C4997AF6EDCAA5296968E" },
630
- inputSchema: {
631
- type: "object",
632
- additionalProperties: false,
633
- properties: {
634
- mainTable: {
635
- type: "object",
636
- additionalProperties: false,
637
- properties: {
638
- moduleType: { type: "string", description: "\u4E8B\u9879\u6A21\u5757\u6807\u8BC6\uFF1Acustomer=\u5BA2\u6237\u3001clue=\u7EBF\u7D22\u3001saleChance=\u5546\u673A" },
639
- entityId: { type: "string" }
640
- },
641
- required: ["moduleType", "entityId"]
702
+ const searchPerPk = {};
703
+ for (const pk of SEARCH_PKS) {
704
+ const cfgId = cfgMap[pk];
705
+ if (!cfgId) continue;
706
+ try {
707
+ let rows = searchConditions.get(pk);
708
+ if (!rows) {
709
+ const resp = await host.request({
710
+ method: "GET",
711
+ path: "/api/bs/ebuilder/form/formdata/getRestCfgById",
712
+ query: { apid: appId, id: cfgId },
713
+ operation: this.name
714
+ });
715
+ rows = searchConditionRows(resp?.data?.conditions);
716
+ }
717
+ const params = [];
718
+ for (const d of rows ?? []) {
719
+ const value = d?.conditions?.value;
720
+ if (typeof value === "string") {
721
+ const m = value.match(/\{([^}]+)\}/);
722
+ if (m) {
723
+ params.push({
724
+ key: m[1],
725
+ text: d?.text ?? "",
726
+ fieldType: d?.fieldType ?? "",
727
+ compType: d?.compType ?? "",
728
+ func: d?.conditions?.func ?? "",
729
+ fieldid: d?.fieldName ?? ""
730
+ });
731
+ }
732
+ }
642
733
  }
643
- },
644
- required: ["mainTable"]
645
- }
646
- },
647
- {
648
- name: "jiuchuanhui.contact-records.by-person-time.list",
649
- risk: "read",
650
- fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "D01DD00978524525AD8728BE1BF9FE79" },
651
- inputSchema: {
652
- type: "object",
653
- additionalProperties: false,
654
- properties: { mainTable: esbWriteSchema(["employeeId", "startData", "endData"]) },
655
- required: ["mainTable"]
734
+ searchPerPk[pk] = { cfgId, searchParams: params };
735
+ } catch {
736
+ }
656
737
  }
657
- },
658
- // ==================== 通用辅助 ====================
659
- {
660
- name: "jiuchuanhui.entity.id.by-name",
661
- risk: "read",
662
- fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "7EC1639D5AC24B4DBCEE8D2CB85D4025" },
663
- inputSchema: {
664
- type: "object",
665
- additionalProperties: false,
666
- properties: { mainTable: esbWriteSchema(["moduleType", "name"]) },
667
- required: ["mainTable"]
738
+ for (const [pk, entry] of Object.entries(searchPerPk)) {
739
+ if (perPk[pk]) perPk[pk] = { ...perPk[pk], ...entry };
740
+ else perPk[pk] = entry;
668
741
  }
669
- },
670
- {
671
- name: "jiuchuanhui.user.id.by-name",
672
- risk: "read",
673
- fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "911C17207E2C4BD29379B5A4001B246E" },
674
- inputSchema: {
675
- type: "object",
676
- additionalProperties: false,
677
- properties: { mainTable: esbWriteSchema(["employeeName"]) },
678
- required: ["mainTable"]
742
+ const region = {};
743
+ for (let offset = 0; offset < REGION_CITIES.length; offset += REGION_CONCURRENCY) {
744
+ const cities = REGION_CITIES.slice(offset, offset + REGION_CONCURRENCY);
745
+ const results = await Promise.allSettled(cities.map(async (city) => host.request({
746
+ path: "/api/esb/server/event/triggerActionFlow",
747
+ body: {
748
+ customParams: { mainTable: { moduleType: "administrativeDivision", name: city, fromType: "agentSkill" } },
749
+ uniqueIndent: "7EC1639D5AC24B4DBCEE8D2CB85D4025",
750
+ employeeId: userId
751
+ },
752
+ operation: this.name
753
+ })));
754
+ for (const [index, result] of results.entries()) {
755
+ if (result.status === "fulfilled" && Number(result.value?.resultCode) === 200) {
756
+ region[`administrativeDivision:${cities[index]}`] = result.value;
757
+ }
758
+ }
679
759
  }
680
- },
681
- {
682
- name: "jiuchuanhui.user.current-profile",
683
- risk: "read",
684
- fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "B8F7597190FF419FB9127D6C8272C4FE" },
685
- inputSchema: { type: "object", additionalProperties: false, properties: {} }
686
- },
687
- {
688
- name: "jiuchuanhui.entity.permission.judge",
689
- risk: "read",
690
- fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "6D369F0A84764051A5D7B5AA1245F49A" },
691
- inputSchema: {
692
- type: "object",
693
- additionalProperties: false,
694
- properties: { mainTable: esbWriteSchema(["moduleType", "entityId", "opType"]) },
695
- required: ["mainTable"]
760
+ const cache = { discovery, ebuilder, options, region };
761
+ cache.region = { ...old.region || {}, ...cache.region || {} };
762
+ cache.options = { ...old.options || {}, ...cache.options || {} };
763
+ if (!cache.discovery[`spVersion:${APP_TAG}`] && old.discovery?.[`spVersion:${APP_TAG}`]) {
764
+ cache.discovery[`spVersion:${APP_TAG}`] = old.discovery[`spVersion:${APP_TAG}`];
696
765
  }
697
- },
698
- {
699
- name: "jiuchuanhui.company.business-profile.query",
700
- risk: "read",
701
- fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "BAB4DBE204214BB395BA161620A4A1CD" },
702
- inputSchema: {
703
- type: "object",
704
- additionalProperties: false,
705
- properties: { mainTable: esbWriteSchema(["companyName"]) },
706
- required: ["mainTable"]
766
+ const summary = {
767
+ dryRun,
768
+ cacheDir: baseDir,
769
+ mainFile,
770
+ namespaces: {
771
+ discovery: Object.keys(cache.discovery).length,
772
+ ebuilder: Object.keys(cache.ebuilder).length,
773
+ options: Object.keys(cache.options).length,
774
+ region: Object.keys(cache.region).length
775
+ },
776
+ configFiles: Object.keys(perPk).length,
777
+ objIdCount: Object.keys(discovery).filter((k) => k.startsWith("objId:")).length,
778
+ cfgIdCount: Object.keys(cfgMap).length,
779
+ version: cache.discovery[`spVersion:${APP_TAG}`] ?? null,
780
+ warnings: []
781
+ };
782
+ if (cache.discovery[`spVersion:${APP_TAG}`] && cache.discovery[`spVersion:${APP_TAG}`].passed === false) {
783
+ 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`);
707
784
  }
708
- },
709
- {
710
- name: "jiuchuanhui.field.info.by-ids",
711
- risk: "read",
712
- fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "10351A4DC8D4454A9F1957FBE647CD9F" },
713
- inputSchema: {
714
- type: "object",
715
- additionalProperties: false,
716
- properties: { mainTable: esbWriteSchema(["fieldids"]) },
717
- required: ["mainTable"]
785
+ if (dryRun) return { status: "COMPLETE", data: { ...summary, written: false, note: "dry-run\uFF1A\u53EA\u62C9\u53D6\u672A\u5199\u5165" } };
786
+ mkdirSync(cfgDir, { recursive: true });
787
+ writeFileSync(mainFile, JSON.stringify(cache, null, 2), "utf-8");
788
+ for (const [pk, entry] of Object.entries(perPk)) {
789
+ const tag = PK_TO_TAG[pk];
790
+ const objId = cache.discovery[`objId:${tag}`];
791
+ writeFileSync(join(cfgDir, `${pk}.json`), JSON.stringify({ ...entry, objId: objId ?? "" }, null, 2), "utf-8");
718
792
  }
719
- },
720
- {
721
- name: "jiuchuanhui.browser-option.search",
722
- risk: "read",
723
- fixed: { path: "/api/bcw/common/browser/complete/{customBrowserType}", method: "POST" },
724
- inputSchema: {
725
- type: "object",
726
- additionalProperties: false,
727
- properties: {
728
- pathParams: {
729
- type: "object",
730
- additionalProperties: false,
731
- properties: { customBrowserType: { type: "string" } },
732
- required: ["customBrowserType"]
733
- },
734
- params: {
735
- type: "object",
736
- additionalProperties: true,
737
- properties: { searchValue: { type: "string" } }
738
- }
739
- },
740
- required: ["pathParams"]
793
+ if (verbose) {
794
+ summary.warnings.push(`${JSON.stringify({ step1: "discovery", step2: "cfgId", step3: "cfg.detail", step4: "ebuilder", step5: "options", step6: "searchParams", step7: "region" })}`);
741
795
  }
742
- },
743
- {
744
- name: "jiuchuanhui.get-rest-cfg-detail",
745
- risk: "read",
746
- fixed: { path: "/api/bs/ebuilder/form/formdata/getRestCfgById", method: "GET" },
747
- inputSchema: {
748
- type: "object",
749
- additionalProperties: false,
750
- properties: {
751
- apid: { type: "string" },
752
- id: { type: "string" }
753
- },
754
- required: ["apid", "id"]
796
+ return {
797
+ status: "COMPLETE",
798
+ data: { ...summary, written: true }
799
+ };
800
+ }
801
+ };
802
+
803
+ // src/shortcuts/jiuchuanhui/operations/shared.ts
804
+ var FORBIDDEN_INPUT_KEYS = /* @__PURE__ */ new Set([
805
+ "access_token",
806
+ "app_key",
807
+ "app_secret",
808
+ "cookie",
809
+ "eteamsid",
810
+ "token",
811
+ "sessionid"
812
+ ]);
813
+ var FORBIDDEN_NORMALIZED_KEYS = new Set([...FORBIDDEN_INPUT_KEYS].map((key) => key.toLowerCase()));
814
+ function asObject(value, name = "\u4E1A\u52A1\u8F93\u5165") {
815
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
816
+ throw jiuchuanhuiValidationError("input_invalid", `${name}\u5FC5\u987B\u662F JSON \u5BF9\u8C61`);
817
+ }
818
+ return value;
819
+ }
820
+ function asNonEmptyString(value, name) {
821
+ if (typeof value !== "string" || !value.trim()) {
822
+ throw jiuchuanhuiValidationError("input_invalid", `${name} \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32`);
823
+ }
824
+ return value.trim();
825
+ }
826
+ function asPositiveString(value, name) {
827
+ if (typeof value !== "string" || !/^\d+$/u.test(value) || value === "0") {
828
+ throw jiuchuanhuiValidationError("input_invalid", `${name} \u5FC5\u987B\u662F\u6B63\u6574\u6570\u6587\u672C`);
829
+ }
830
+ return value;
831
+ }
832
+ function assertNoForbiddenKeys(value, location = "input") {
833
+ if (!value || typeof value !== "object") return;
834
+ if (Array.isArray(value)) {
835
+ value.forEach((item, index) => assertNoForbiddenKeys(item, `${location}[${index}]`));
836
+ return;
837
+ }
838
+ for (const [key, child] of Object.entries(value)) {
839
+ if (FORBIDDEN_INPUT_KEYS.has(key) || FORBIDDEN_NORMALIZED_KEYS.has(key.toLowerCase())) {
840
+ throw jiuchuanhuiValidationError("field_forbidden", `\u7981\u6B62\u4E1A\u52A1\u8F93\u5165\u5B57\u6BB5\uFF1A${location}.${key}`);
755
841
  }
842
+ assertNoForbiddenKeys(child, `${location}.${key}`);
756
843
  }
757
- ];
758
- var jiuchuanhuiManifest = {
759
- schemaVersion: 1,
760
- name: "jiuchuanhui",
761
- 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",
762
- version: "0.1.0",
763
- host: "e10-jiuchuanhui",
764
- status: "builtin",
765
- sourceSkill: "weaver-e10-jiuchuanhui",
766
- operations: jiuchuanhuiOperations,
767
- withheldOperations: [
768
- {
769
- name: "jiuchuanhui.sale.stage-advance",
770
- 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"
844
+ }
845
+ function sessionMatches(lease, session) {
846
+ return lease.baseUrl === session.baseUrl && lease.profile === session.profile && lease.userId === session.userId;
847
+ }
848
+ function workflow(name, state) {
849
+ return { workflow: name, version: 1, state };
850
+ }
851
+ function esbBody(mainTable, uniqueIndent, userId) {
852
+ return {
853
+ customParams: { mainTable },
854
+ uniqueIndent,
855
+ employeeId: userId
856
+ };
857
+ }
858
+ function datasBody(form, userId) {
859
+ const datas = Array.isArray(form.datas) ? form.datas : [form];
860
+ const cleansed = datas.map((item) => stripForbidden(item));
861
+ return {
862
+ datajson: {
863
+ datas: cleansed,
864
+ header: { operator: userId }
865
+ }
866
+ };
867
+ }
868
+ function byIdBody(id, userId) {
869
+ return {
870
+ datajson: {
871
+ mainTable: { id },
872
+ header: { operator: userId }
873
+ }
874
+ };
875
+ }
876
+ function listBody(userId, pageNo, pageSize, mainTable) {
877
+ const mt = mainTable && Object.keys(mainTable).length ? { ...mainTable } : {};
878
+ return {
879
+ datajson: {
880
+ mainTable: mt,
881
+ pageInfo: { pageNo, pageSize },
882
+ header: { operator: userId }
771
883
  }
772
- ]
773
- };
884
+ };
885
+ }
886
+ function stripForbidden(value) {
887
+ if (Array.isArray(value)) return value.map(stripForbidden);
888
+ if (!value || typeof value !== "object") return value;
889
+ const result = {};
890
+ for (const [key, child] of Object.entries(value)) {
891
+ if (FORBIDDEN_INPUT_KEYS.has(key) || FORBIDDEN_NORMALIZED_KEYS.has(key.toLowerCase())) continue;
892
+ result[key] = stripForbidden(child);
893
+ }
894
+ return result;
895
+ }
896
+ function stripForbiddenKeys(value) {
897
+ return stripForbidden(value);
898
+ }
899
+ function resultDataIds(value) {
900
+ if (!value || typeof value !== "object") return [];
901
+ const ids = value.datajson?.dataIds;
902
+ if (Array.isArray(ids)) return ids.map((item) => String(item));
903
+ return [];
904
+ }
905
+ function esbOutcome(value) {
906
+ if (!value || typeof value !== "object") return { resultCode: 0, resultMsg: "" };
907
+ const root = value;
908
+ return {
909
+ resultCode: Number(root.resultCode ?? 0),
910
+ resultMsg: typeof root.resultMsg === "string" ? root.resultMsg : ""
911
+ };
912
+ }
913
+ function pagingFrom(input) {
914
+ const pageNo = Number.isInteger(input.pageNo) && input.pageNo >= 1 ? input.pageNo : 1;
915
+ const pageSize = Number.isInteger(input.pageSize) && input.pageSize >= 1 ? input.pageSize : 10;
916
+ return { pageNo, pageSize };
917
+ }
774
918
 
775
- // src/shortcuts/jiuchuanhui/cache.ts
776
- import { existsSync as existsSync2, mkdirSync, readFileSync, writeFileSync } from "node:fs";
777
- import { homedir as homedir2 } from "node:os";
778
- import { join } from "node:path";
779
- var APP_TAG = "jch-crm-project";
780
- var MIN_VERSION = "1.5.11";
781
- var MODULE_TAGS = [
782
- "uf_jch_customer",
783
- "uf_jch_sale",
784
- "uf_jch_clue",
785
- "uf_jch_contact",
786
- "uf_jch_customer_open_sea",
787
- "uf_jch_remind",
788
- "uf_jch_rival",
789
- "uf_jch_sale_process",
790
- "uf_jch_sale_stage",
791
- "uf_jch_clue_pool",
792
- "uf_jch_lose_reason",
793
- "uf_jch_customer_cmt",
794
- "uf_jch_sale_cmt"
795
- ];
796
- var CREATE_PKS = ["customer_create_api", "sale_create_api", "ebclue_ai_create_api", "contact_create_api", "ebcontact_plan_create_api"];
797
- var SEARCH_PKS = ["ebcustomer_search_api", "ebsale_search_api", "ebclue_ai_search_api"];
798
- var UPDATE_PKS = ["customer_update_api", "sale_update_api", "ebclue_ai_update_api", "contact_update_api"];
799
- var ALL_PKS = [...CREATE_PKS, ...SEARCH_PKS, ...UPDATE_PKS];
800
- var PK_TO_TAG = {
801
- customer_create_api: "uf_jch_customer",
802
- sale_create_api: "uf_jch_sale",
803
- ebclue_ai_create_api: "uf_jch_clue",
804
- contact_create_api: "uf_jch_contact",
805
- ebcontact_plan_create_api: "uf_jch_remind",
806
- ebcustomer_search_api: "uf_jch_customer",
807
- ebsale_search_api: "uf_jch_sale",
808
- ebclue_ai_search_api: "uf_jch_clue",
809
- customer_update_api: "uf_jch_customer",
810
- sale_update_api: "uf_jch_sale",
811
- ebclue_ai_update_api: "uf_jch_clue",
812
- contact_update_api: "uf_jch_contact"
919
+ // src/shortcuts/jiuchuanhui/operations/customer-quick.ts
920
+ var CUSTOMER_SEARCH_SCOPES = {
921
+ mine: { mine: "", all: "-1", customerSea: "-1" },
922
+ all: { mine: "-1", all: "", customerSea: "-1" },
923
+ "open-sea": { mine: "-1", all: "-1", customerSea: "" }
813
924
  };
814
- var DETAIL_KEEP_KEYS = ["id", "interfacePk", "interfaceName", "datasNumber", "datasSize", "mainFields", "detailFields", "interfaceType", "relevanceForm"];
815
- var FIELD_KEEP_KEYS = ["fieldid", "isRequired", "isInput", "data_key", "title", "component_type"];
816
- var OPT_COMP = ["Select", "RadioBox", "CheckBox"];
817
- var EBUILDER_QUERIES = [
818
- { key: "customer_open_sea", path: "/api/ebuilder/form/formdata/v2/getFormDataList/customer_open_sea_search_api", nameFields: ["open_sea_name", "name"] },
819
- { key: "sale_stage", path: "/api/ebuilder/form/formdata/v2/getFormDataList/sale_stage_search_api", nameFields: ["stage_name", "name"] },
820
- { key: "sale_process", path: "/api/ebuilder/form/formdata/v2/getFormDataList/sale_process_sear_api", nameFields: ["process_name", "name"] },
821
- { key: "clue_pool", path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcluepool_ai_search_api", nameFields: ["clue_pool_name", "name"] },
822
- { key: "sale_lose_reason", path: "/api/ebuilder/form/formdata/v2/getFormDataList/sale_lose_reason", nameFields: ["reason_name", "name"] },
823
- { key: "customer_industry", path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_industry_search_api", nameFields: ["industry_name", "name"] },
824
- { key: "customer_type", path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_type_search_api", nameFields: ["type_name", "name"] },
825
- { key: "customer_status", path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_status_search_api", nameFields: ["state_name", "name"] }
826
- ];
827
- var REGION_CITIES = [
828
- "\u5317\u4EAC\u5E02",
829
- "\u4E0A\u6D77\u5E02",
830
- "\u5929\u6D25\u5E02",
831
- "\u91CD\u5E86\u5E02",
832
- "\u6210\u90FD\u5E02",
833
- "\u5E7F\u5DDE\u5E02",
834
- "\u6DF1\u5733\u5E02",
835
- "\u4E1C\u839E\u5E02",
836
- "\u676D\u5DDE\u5E02",
837
- "\u5357\u4EAC\u5E02",
838
- "\u82CF\u5DDE\u5E02",
839
- "\u6B66\u6C49\u5E02",
840
- "\u957F\u6C99\u5E02",
841
- "\u897F\u5B89\u5E02",
842
- "\u90D1\u5DDE\u5E02",
843
- "\u6D4E\u5357\u5E02",
844
- "\u9752\u5C9B\u5E02",
845
- "\u53A6\u95E8\u5E02",
846
- "\u798F\u5DDE\u5E02",
847
- "\u5408\u80A5\u5E02",
848
- "\u6C88\u9633\u5E02",
849
- "\u5927\u8FDE\u5E02"
850
- ];
851
- function pickKeys(obj, keys) {
852
- const out = {};
853
- for (const k of keys) if (obj?.[k] !== void 0) out[k] = obj[k];
854
- return out;
925
+ var STATUS_PAGE_SIZE = 100;
926
+ var STATUS_MAX_PAGES = 5;
927
+ function addSuccessStatusIds(ids, rows) {
928
+ for (const row of rows) {
929
+ const status = row?.mainTable ?? row;
930
+ const fields = status;
931
+ const label = String(fields?.state_name ?? "").trim() || String(fields?.name ?? "").trim();
932
+ if (label !== "\u6210\u529F\u5BA2\u6237" && label !== "\u6210\u529F") continue;
933
+ const id = String(fields?.id ?? "").trim();
934
+ if (/^[1-9]\d*$/u.test(id)) ids.add(id);
935
+ }
855
936
  }
856
- var isInputOne = (f) => String(f?.isInput) === "1";
857
- function semverGte(a, b) {
858
- const pa = String(a || "").split(".").map((x) => parseInt(x, 10) || 0);
859
- const pb = b.split(".").map((x) => parseInt(x, 10) || 0);
860
- for (let i = 0; i < 3; i++) {
861
- if ((pa[i] || 0) !== (pb[i] || 0)) return (pa[i] || 0) > (pb[i] || 0);
937
+ async function cachedCustomerStatuses(context) {
938
+ const { tenantKey, userId } = await context.host.getSession();
939
+ if (!tenantKey || !userId) return [];
940
+ try {
941
+ const raw = await readFile2(jiuchuanhuiCacheFile(tenantKey, userId), "utf8");
942
+ const rows = JSON.parse(raw.replace(/^\uFEFF/u, ""))?.ebuilder?.customer_status;
943
+ return Array.isArray(rows) && rows.length < STATUS_PAGE_SIZE * STATUS_MAX_PAGES ? rows : [];
944
+ } catch {
945
+ return [];
862
946
  }
863
- return true;
864
947
  }
865
- function successCheck(value) {
866
- if (!value || typeof value !== "object") return false;
867
- if (value.resultCode !== void 0 && value.resultCode !== null) return Number(value.resultCode) === 200;
868
- if (value.datajson && typeof value.datajson === "object") {
869
- const status = value.datajson.status;
870
- if (status === "true" || status === true) return true;
871
- if (status === "false" || status === false) return false;
948
+ function uniqueSuccessStatusId(ids) {
949
+ if (ids.size > 1) {
950
+ throw jiuchuanhuiValidationError("customer_success_status_ambiguous", "\u627E\u5230\u591A\u4E2A\u6210\u529F\u5BA2\u6237\u72B6\u6001\uFF0C\u8BF7\u786E\u8BA4\u8981\u4F7F\u7528\u7684\u5BA2\u6237\u72B6\u6001", {
951
+ statusIds: [...ids]
952
+ });
872
953
  }
873
- const code = value.code ?? value.res_base?.ret;
874
- if (code !== void 0 && code !== null) return Number(code) === 0 || Number(code) === 200;
875
- return typeof value.success === "boolean" ? value.success : false;
954
+ return ids.values().next().value;
876
955
  }
877
- var CacheInitOperation = class {
878
- name = "jiuchuanhui.cache.init";
879
- async execute(input, { host }) {
880
- const dryRun = input.dryRun === true;
881
- const verbose = input.verbose === true;
882
- const session = await host.getSession();
883
- const tenantKey = session.tenantKey || "";
884
- const userId = session.userId || "";
885
- if (!tenantKey || !userId) {
886
- 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");
956
+ async function resolveSuccessStatus(search, context) {
957
+ const ids = /* @__PURE__ */ new Set();
958
+ addSuccessStatusIds(ids, await cachedCustomerStatuses(context));
959
+ const cachedId = uniqueSuccessStatusId(ids);
960
+ if (cachedId) return cachedId;
961
+ for (let pageNo = 1; pageNo <= STATUS_MAX_PAGES; pageNo += 1) {
962
+ const { response } = await search.execute({ pageNo, pageSize: STATUS_PAGE_SIZE }, context);
963
+ const rows = response.value?.datajson?.datas;
964
+ if (response.httpStatus < 200 || response.httpStatus >= 300 || !Array.isArray(rows)) {
965
+ throw jiuchuanhuiValidationError("customer_success_status_lookup_failed", "\u65E0\u6CD5\u8BFB\u53D6\u5BA2\u6237\u72B6\u6001\u5B57\u5178\uFF0C\u8BF7\u786E\u8BA4\u9700\u8981\u4F7F\u7528\u7684\u5BA2\u6237\u72B6\u6001", { httpStatus: response.httpStatus });
966
+ }
967
+ addSuccessStatusIds(ids, rows);
968
+ const statusId = uniqueSuccessStatusId(ids);
969
+ if (rows.length < STATUS_PAGE_SIZE) {
970
+ if (statusId) return statusId;
971
+ throw jiuchuanhuiValidationError("customer_success_status_not_found", "\u5F53\u524D\u79DF\u6237\u672A\u627E\u5230\u201C\u6210\u529F\u201D\u6216\u201C\u6210\u529F\u5BA2\u6237\u201D\u72B6\u6001\uFF0C\u8BF7\u786E\u8BA4\u5BA2\u6237\u72B6\u6001\u540D\u79F0");
887
972
  }
888
- const baseDir = join(process.env.WEAVER_E10_JIUCHUANHUI_HOME || join(homedir2(), ".weaver-e10-jiuchuanhui"), tenantKey, String(userId));
889
- const mainFile = join(baseDir, "weaver-e10-jiuchuanhui.json");
890
- const cfgDir = join(baseDir, "config");
891
- let old = {};
892
- if (existsSync2(mainFile)) {
893
- try {
894
- old = JSON.parse(readFileSync(mainFile, "utf-8"));
895
- } catch {
973
+ }
974
+ throw jiuchuanhuiValidationError("customer_success_status_lookup_incomplete", "\u5BA2\u6237\u72B6\u6001\u5B57\u5178\u672A\u67E5\u5B8C\uFF0C\u8BF7\u786E\u8BA4\u9700\u8981\u4F7F\u7528\u7684\u5BA2\u6237\u72B6\u6001");
975
+ }
976
+ var CustomerQuickSearchOperation = class {
977
+ constructor(name, customerSearch, defaultScope, customerStatusSearch) {
978
+ this.name = name;
979
+ this.customerSearch = customerSearch;
980
+ this.defaultScope = defaultScope;
981
+ this.customerStatusSearch = customerStatusSearch;
982
+ }
983
+ name;
984
+ customerSearch;
985
+ defaultScope;
986
+ customerStatusSearch;
987
+ async execute(input, context) {
988
+ const { customer_name, pageNo, pageSize, count, scope = this.defaultScope, ...unsupported } = input;
989
+ const unexpected = Object.keys(unsupported);
990
+ if (!this.customerStatusSearch && Object.hasOwn(input, "scope")) unexpected.push("scope");
991
+ if (unexpected.length) {
992
+ throw jiuchuanhuiValidationError("field_unsupported", `\u5FEB\u6377\u67E5\u8BE2\u4E0D\u652F\u6301\u4EE5\u4E0B\u53C2\u6570\uFF1A${unexpected.join("\u3001")}`, { fields: unexpected });
993
+ }
994
+ if (typeof scope !== "string" || !Object.hasOwn(CUSTOMER_SEARCH_SCOPES, scope)) {
995
+ throw jiuchuanhuiValidationError("input_invalid", "scope \u5FC5\u987B\u662F mine\u3001all \u6216 open-sea");
996
+ }
997
+ if (pageNo !== void 0 && (!Number.isSafeInteger(pageNo) || pageNo < 1)) {
998
+ throw jiuchuanhuiValidationError("input_invalid", "pageNo \u5FC5\u987B\u662F\u6B63\u6574\u6570");
999
+ }
1000
+ if (pageSize !== void 0 && (!Number.isSafeInteger(pageSize) || pageSize < 1 || pageSize > 200)) {
1001
+ throw jiuchuanhuiValidationError("input_invalid", "pageSize \u5FC5\u987B\u662F 1 \u5230 200 \u4E4B\u95F4\u7684\u6574\u6570");
1002
+ }
1003
+ if (count !== void 0 && typeof count !== "boolean") {
1004
+ throw jiuchuanhuiValidationError("input_invalid", "count \u5FC5\u987B\u662F\u5E03\u5C14\u503C");
1005
+ }
1006
+ const customerName = customer_name === void 0 ? void 0 : asNonEmptyString(customer_name, "customer_name");
1007
+ const status = this.customerStatusSearch ? await resolveSuccessStatus(this.customerStatusSearch, context) : void 0;
1008
+ return this.customerSearch.execute({
1009
+ ...CUSTOMER_SEARCH_SCOPES[scope],
1010
+ customer_name: customerName,
1011
+ pageNo,
1012
+ pageSize,
1013
+ count,
1014
+ status
1015
+ }, context);
1016
+ }
1017
+ };
1018
+
1019
+ // src/shortcuts/jiuchuanhui/manifest.ts
1020
+ var pageProps = {
1021
+ pageNo: { type: "integer", minimum: 1, default: 1 },
1022
+ pageSize: { type: "integer", minimum: 1, maximum: 200, default: 10 },
1023
+ count: { type: "boolean", description: "\u662F\u5426\u5E76\u884C\u8BF7\u6C42\u603B\u6570\u63A5\u53E3" }
1024
+ };
1025
+ var customerQuickSearchProps = {
1026
+ ...pageProps,
1027
+ customer_name: { type: "string", minLength: 1, description: "\u5BA2\u6237\u540D\u79F0\u641C\u7D22\u6761\u4EF6" }
1028
+ };
1029
+ var idProp = { type: "string", pattern: "^[1-9]\\d*$" };
1030
+ var formProp = {
1031
+ type: "object",
1032
+ additionalProperties: true,
1033
+ 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"
1034
+ };
1035
+ var esbWriteProps = (keys) => {
1036
+ const props = {};
1037
+ for (const key of keys) props[key] = { type: "string", description: `\u52A8\u4F5C\u6D41\u4E1A\u52A1\u53C2\u6570 ${key}` };
1038
+ return props;
1039
+ };
1040
+ var esbWriteSchema = (keys, required = keys) => ({
1041
+ type: "object",
1042
+ additionalProperties: false,
1043
+ properties: esbWriteProps(keys),
1044
+ required
1045
+ });
1046
+ function writePair(baseName, title, props, required = [], fixed = {}, withPrepare = true) {
1047
+ const list = [];
1048
+ if (withPrepare) {
1049
+ list.push({
1050
+ name: `${baseName}.prepare`,
1051
+ risk: "read-before-write",
1052
+ fixed: { ...fixed, stage: "prepare" },
1053
+ inputSchema: {
1054
+ type: "object",
1055
+ additionalProperties: false,
1056
+ properties: {
1057
+ mainTable: {
1058
+ type: "object",
1059
+ additionalProperties: false,
1060
+ properties: props,
1061
+ ...required.length ? { required } : {}
1062
+ }
1063
+ },
1064
+ required: ["mainTable"]
896
1065
  }
897
- }
898
- const discovery = {};
899
- const appResp = await host.request({
900
- method: "GET",
901
- path: "/api/bs/ebuilder/app/tags/getAppIds",
902
- query: { tag: APP_TAG },
903
- operation: this.name
904
1066
  });
905
- if (!successCheck(appResp)) throw jiuchuanhuiValidationError("init_failed", "app.discovery \u672A\u6210\u529F\uFF0C\u65E0\u6CD5\u521D\u59CB\u5316\u7F13\u5B58");
906
- const rawApp = appResp?.data ?? appResp?.datajson?.datas;
907
- const appId = Array.isArray(rawApp) && rawApp[0] ? String(rawApp[0]) : null;
908
- if (!appId) throw jiuchuanhuiValidationError("init_failed", "\u6B65\u9AA4 1 \u672A\u53D6\u5F97 appId\uFF0C\u8BF7\u68C0\u67E5 E10 \u767B\u5F55\u6001");
909
- discovery[`appId:${APP_TAG}`] = appId;
910
- for (const tag of MODULE_TAGS) {
911
- const resp = await host.request({
912
- method: "GET",
913
- path: "/api/ebuilder/form/obj/getObjsByTag",
914
- query: { tag, appId },
915
- operation: this.name
916
- });
917
- const list = Array.isArray(resp?.data) ? resp.data : resp?.datajson?.datas ?? [];
918
- const hit = list.find((o) => o?.formId && String(o.formId) !== "0") ?? list?.[0];
919
- if (hit?.id) discovery[`objId:${tag}`] = String(hit.id);
1067
+ }
1068
+ list.push({
1069
+ name: `${baseName}.apply`,
1070
+ risk: "high-risk-write",
1071
+ fixed: { ...fixed, stage: "apply" },
1072
+ inputSchema: {
1073
+ type: "object",
1074
+ additionalProperties: false,
1075
+ properties: {
1076
+ continuation: { type: "string", minLength: 1 },
1077
+ confirm: { const: true }
1078
+ },
1079
+ required: ["continuation", "confirm"]
920
1080
  }
921
- try {
922
- const spResp = await host.request({
923
- method: "GET",
924
- path: "/api/installer/public/querySpAppVersionInfo",
925
- query: { appId },
926
- operation: this.name
927
- });
928
- const sp = spResp?.data;
929
- const commitVersion = typeof sp === "object" && sp !== null ? String(sp.commitVersion ?? sp.version ?? "") : "";
930
- if (commitVersion) {
931
- discovery[`spVersion:${APP_TAG}`] = { commitVersion, passed: semverGte(commitVersion, MIN_VERSION) };
1081
+ });
1082
+ return list;
1083
+ }
1084
+ var OPERATION_SUMMARIES = {
1085
+ "jiuchuanhui.cache.init": "\u521D\u59CB\u5316\u4E5D\u6C1A\u6C47\u672C\u5730\u7F13\u5B58\uFF08\u5199\u672C\u5730\u7F13\u5B58\u6587\u4EF6\uFF0C\u4E0D\u8C03\u4E1A\u52A1\u63A5\u53E3\uFF09\uFF1B\u5165\u53C2 dryRun/verbose",
1086
+ "jiuchuanhui.app.discovery": "\u6309\u6807\u7B7E\u53D6\u4E5D\u6C1A\u6C47\u76F8\u5173 eBuilder \u5E94\u7528 ID \u5217\u8868",
1087
+ "jiuchuanhui.form.discovery": "\u6309\u6807\u7B7E\u4E0E\u5E94\u7528\u53D6\u8868\u5355\uFF08\u5BF9\u8C61\uFF09\u5B9A\u4E49\uFF0C\u7528\u4E8E\u5B9A\u4F4D\u5BA2\u6237/\u5546\u673A\u7B49\u4E3B\u8868",
1088
+ "jiuchuanhui.field.options": "\u53D6\u8868\u5355\u67D0\u5B57\u6BB5\u7684\u9009\u9879\u5B57\u5178\uFF08id\u2194name\uFF09\uFF1B\u5165\u53C2 fieldName/objId/groupId",
1089
+ "jiuchuanhui.rest.cfg.detail": "\u6309 apid + id \u53D6 REST \u914D\u7F6E\u8BE6\u60C5\uFF08\u52A8\u4F5C\u6D41\u914D\u7F6E\u89E3\u6790\u7ED3\u679C\uFF09",
1090
+ "jiuchuanhui.config.id.by.pk": "\u6309\u4E3B\u8868\u4E0E\u6570\u636E\u4E3B\u952E\u53CD\u67E5\u914D\u7F6E ID\uFF08\u7ECF\u52A8\u4F5C\u6D41\uFF09",
1091
+ "jiuchuanhui.file.preview": "\u53D6\u9644\u4EF6\u9884\u89C8\u5730\u5740\uFF1B\u5165\u53C2 fileId/fieldId/appId",
1092
+ "jiuchuanhui.customer.create.prepare": "\u51C6\u5907\u65B0\u5EFA\u5BA2\u6237\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09\uFF1B\u5165\u53C2 mainTable \u4E0E\u5BA2\u6237\u5B57\u6BB5",
1093
+ "jiuchuanhui.customer.create.apply": "\u63D0\u4EA4\u65B0\u5EFA\u5BA2\u6237\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
1094
+ "jiuchuanhui.customer.get": "\u6309 id \u53D6\u5BA2\u6237\u8BE6\u60C5",
1095
+ "jiuchuanhui.customer.search": "\u5206\u9875\u67E5\u8BE2\u5BA2\u6237\u5217\u8868\uFF08\u652F\u6301\u6761\u4EF6\u8FC7\u6EE4\uFF09",
1096
+ "jiuchuanhui.customer.type.search": "\u5206\u9875\u67E5\u8BE2\u5BA2\u6237\u7C7B\u578B\u5B57\u5178",
1097
+ "jiuchuanhui.customer.status.search": "\u5206\u9875\u67E5\u8BE2\u5BA2\u6237\u72B6\u6001\u5B57\u5178",
1098
+ "jiuchuanhui.customer.industry.search": "\u5206\u9875\u67E5\u8BE2\u5BA2\u6237\u884C\u4E1A\u5B57\u5178",
1099
+ "jiuchuanhui.customer.open-sea.search": "\u5206\u9875\u67E5\u8BE2\u516C\u6D77\u5BA2\u6237\u5217\u8868",
1100
+ "jiuchuanhui.customer.update.prepare": "\u51C6\u5907\u4FEE\u6539\u5BA2\u6237\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09\uFF1B\u5165\u53C2 mainTable \u4E0E\u5F85\u6539\u5B57\u6BB5",
1101
+ "jiuchuanhui.customer.update.apply": "\u63D0\u4EA4\u4FEE\u6539\u5BA2\u6237\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
1102
+ "jiuchuanhui.customer.transfer.prepare": "\u51C6\u5907\u8F6C\u79FB\u5BA2\u6237\u8D1F\u8D23\u4EBA\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09\uFF1B\u5165\u53C2 mainTable \u4E0E\u76EE\u6807\u8D1F\u8D23\u4EBA",
1103
+ "jiuchuanhui.customer.transfer.apply": "\u63D0\u4EA4\u8F6C\u79FB\u5BA2\u6237\u8D1F\u8D23\u4EBA\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
1104
+ "jiuchuanhui.customer.open-sea.release.prepare": "\u51C6\u5907\u628A\u5BA2\u6237\u91CA\u653E\u5230\u516C\u6D77\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
1105
+ "jiuchuanhui.customer.open-sea.release.apply": "\u63D0\u4EA4\u628A\u5BA2\u6237\u91CA\u653E\u5230\u516C\u6D77\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
1106
+ "jiuchuanhui.customer.open-sea.claim.prepare": "\u51C6\u5907\u4ECE\u516C\u6D77\u9886\u53D6\u5BA2\u6237\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
1107
+ "jiuchuanhui.customer.open-sea.claim.apply": "\u63D0\u4EA4\u4ECE\u516C\u6D77\u9886\u53D6\u5BA2\u6237\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
1108
+ "jiuchuanhui.customer.duplicate.check": "\u5BA2\u6237\u67E5\u91CD\uFF1A\u6309\u540D\u79F0/\u5173\u952E\u4FE1\u606F\u627E\u51FA\u7591\u4F3C\u91CD\u590D\u5BA2\u6237\uFF08\u7ECF\u52A8\u4F5C\u6D41\uFF09",
1109
+ "jiuchuanhui.customer.contact-record.create.prepare": "\u51C6\u5907\u65B0\u589E\u5BA2\u6237\u8054\u7CFB\u8BB0\u5F55\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
1110
+ "jiuchuanhui.customer.contact-record.create.apply": "\u63D0\u4EA4\u65B0\u589E\u5BA2\u6237\u8054\u7CFB\u8BB0\u5F55\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
1111
+ "jiuchuanhui.customer.contact-record.batch.prepare": "\u51C6\u5907\u6279\u91CF\u65B0\u589E\u5BA2\u6237\u8054\u7CFB\u8BB0\u5F55\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
1112
+ "jiuchuanhui.customer.contact-record.batch.apply": "\u63D0\u4EA4\u6279\u91CF\u65B0\u589E\u5BA2\u6237\u8054\u7CFB\u8BB0\u5F55\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
1113
+ "jiuchuanhui.contact.create.prepare": "\u51C6\u5907\u65B0\u5EFA\u8054\u7CFB\u4EBA\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09\uFF1B\u5165\u53C2 mainTable \u4E0E\u8054\u7CFB\u4EBA\u5B57\u6BB5",
1114
+ "jiuchuanhui.contact.create.apply": "\u63D0\u4EA4\u65B0\u5EFA\u8054\u7CFB\u4EBA\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
1115
+ "jiuchuanhui.contact.get": "\u6309 id \u53D6\u8054\u7CFB\u4EBA\u8BE6\u60C5",
1116
+ "jiuchuanhui.contact.update.prepare": "\u51C6\u5907\u4FEE\u6539\u8054\u7CFB\u4EBA\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
1117
+ "jiuchuanhui.contact.update.apply": "\u63D0\u4EA4\u4FEE\u6539\u8054\u7CFB\u4EBA\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
1118
+ "jiuchuanhui.contact.by-entity.search": "\u6309\u5BA2\u6237\u6216\u5546\u673A\u67E5\u8BE2\u5173\u8054\u7684\u8054\u7CFB\u4EBA\u5217\u8868\uFF1B\u5165\u53C2 customerId/saleChanceId",
1119
+ "jiuchuanhui.sale.create.prepare": "\u51C6\u5907\u65B0\u5EFA\u5546\u673A\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09\uFF1B\u5165\u53C2 mainTable \u4E0E\u5546\u673A\u5B57\u6BB5",
1120
+ "jiuchuanhui.sale.create.apply": "\u63D0\u4EA4\u65B0\u5EFA\u5546\u673A\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
1121
+ "jiuchuanhui.sale.get": "\u6309 id \u53D6\u5546\u673A\u8BE6\u60C5",
1122
+ "jiuchuanhui.sale.search": "\u5206\u9875\u67E5\u8BE2\u5546\u673A\u5217\u8868\uFF08\u652F\u6301\u6761\u4EF6\u8FC7\u6EE4\uFF09",
1123
+ "jiuchuanhui.sale.update.prepare": "\u51C6\u5907\u4FEE\u6539\u5546\u673A\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
1124
+ "jiuchuanhui.sale.update.apply": "\u63D0\u4EA4\u4FEE\u6539\u5546\u673A\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
1125
+ "jiuchuanhui.sale.stage.search": "\u5206\u9875\u67E5\u8BE2\u9500\u552E\u9636\u6BB5\u5B57\u5178",
1126
+ "jiuchuanhui.sale.process.search": "\u5206\u9875\u67E5\u8BE2\u5546\u673A\u7684\u6D41\u7A0B/\u9636\u6BB5\u63A8\u8FDB\u8BB0\u5F55",
1127
+ "jiuchuanhui.sale.lose-reason.search": "\u5206\u9875\u67E5\u8BE2\u4E22\u5355\u539F\u56E0\u5B57\u5178",
1128
+ "jiuchuanhui.rival.search": "\u5206\u9875\u67E5\u8BE2\u7ADE\u4E89\u5BF9\u624B\u5217\u8868",
1129
+ "jiuchuanhui.sale.win.prepare": "\u51C6\u5907\u6807\u8BB0\u5546\u673A\u8D62\u5355\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
1130
+ "jiuchuanhui.sale.win.apply": "\u63D0\u4EA4\u6807\u8BB0\u5546\u673A\u8D62\u5355\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
1131
+ "jiuchuanhui.sale.lose.prepare": "\u51C6\u5907\u6807\u8BB0\u5546\u673A\u8F93\u5355\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
1132
+ "jiuchuanhui.sale.lose.apply": "\u63D0\u4EA4\u6807\u8BB0\u5546\u673A\u8F93\u5355\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
1133
+ "jiuchuanhui.sale.invalid.prepare": "\u51C6\u5907\u4F5C\u5E9F\u5546\u673A\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
1134
+ "jiuchuanhui.sale.invalid.apply": "\u63D0\u4EA4\u4F5C\u5E9F\u5546\u673A\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
1135
+ "jiuchuanhui.sale.pause.prepare": "\u51C6\u5907\u6682\u505C\u5546\u673A\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
1136
+ "jiuchuanhui.sale.pause.apply": "\u63D0\u4EA4\u6682\u505C\u5546\u673A\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
1137
+ "jiuchuanhui.sale.restart.prepare": "\u51C6\u5907\u91CD\u542F\u5546\u673A\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
1138
+ "jiuchuanhui.sale.restart.apply": "\u63D0\u4EA4\u91CD\u542F\u5546\u673A\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
1139
+ "jiuchuanhui.sale.manager-change.prepare": "\u51C6\u5907\u53D8\u66F4\u5546\u673A\u8D1F\u8D23\u4EBA\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
1140
+ "jiuchuanhui.sale.manager-change.apply": "\u63D0\u4EA4\u53D8\u66F4\u5546\u673A\u8D1F\u8D23\u4EBA\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
1141
+ "jiuchuanhui.sale.link-contacts.prepare": "\u51C6\u5907\u7ED9\u5546\u673A\u5173\u8054\u8054\u7CFB\u4EBA\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
1142
+ "jiuchuanhui.sale.link-contacts.apply": "\u63D0\u4EA4\u7ED9\u5546\u673A\u5173\u8054\u8054\u7CFB\u4EBA\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
1143
+ "jiuchuanhui.sale.contact-record.create.prepare": "\u51C6\u5907\u65B0\u589E\u5546\u673A\u8054\u7CFB\u8BB0\u5F55\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
1144
+ "jiuchuanhui.sale.contact-record.create.apply": "\u63D0\u4EA4\u65B0\u589E\u5546\u673A\u8054\u7CFB\u8BB0\u5F55\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
1145
+ "jiuchuanhui.clue.create.prepare": "\u51C6\u5907\u65B0\u5EFA\u7EBF\u7D22\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09\uFF1B\u5165\u53C2 mainTable \u4E0E\u7EBF\u7D22\u5B57\u6BB5",
1146
+ "jiuchuanhui.clue.create.apply": "\u63D0\u4EA4\u65B0\u5EFA\u7EBF\u7D22\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
1147
+ "jiuchuanhui.clue.get": "\u6309 id \u53D6\u7EBF\u7D22\u8BE6\u60C5",
1148
+ "jiuchuanhui.clue.search": "\u5206\u9875\u67E5\u8BE2\u7EBF\u7D22\u5217\u8868\uFF08\u652F\u6301\u6761\u4EF6\u8FC7\u6EE4\uFF09",
1149
+ "jiuchuanhui.clue.pool.search": "\u5206\u9875\u67E5\u8BE2\u7EBF\u7D22\u6C60\u5217\u8868",
1150
+ "jiuchuanhui.clue.update.prepare": "\u51C6\u5907\u4FEE\u6539\u7EBF\u7D22\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
1151
+ "jiuchuanhui.clue.update.apply": "\u63D0\u4EA4\u4FEE\u6539\u7EBF\u7D22\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
1152
+ "jiuchuanhui.clue.status-change.prepare": "\u51C6\u5907\u53D8\u66F4\u7EBF\u7D22\u72B6\u6001\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
1153
+ "jiuchuanhui.clue.status-change.apply": "\u63D0\u4EA4\u53D8\u66F4\u7EBF\u7D22\u72B6\u6001\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
1154
+ "jiuchuanhui.clue.to-customer.prepare": "\u51C6\u5907\u628A\u7EBF\u7D22\u8F6C\u4E3A\u5BA2\u6237\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
1155
+ "jiuchuanhui.clue.to-customer.apply": "\u63D0\u4EA4\u628A\u7EBF\u7D22\u8F6C\u4E3A\u5BA2\u6237\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
1156
+ "jiuchuanhui.clue.contact-record.create.prepare": "\u51C6\u5907\u65B0\u589E\u7EBF\u7D22\u8054\u7CFB\u8BB0\u5F55\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
1157
+ "jiuchuanhui.clue.contact-record.create.apply": "\u63D0\u4EA4\u65B0\u589E\u7EBF\u7D22\u8054\u7CFB\u8BB0\u5F55\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
1158
+ "jiuchuanhui.contact-plan.create.prepare": "\u51C6\u5907\u65B0\u5EFA\u8054\u7CFB\u8BA1\u5212\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
1159
+ "jiuchuanhui.contact-plan.create.apply": "\u63D0\u4EA4\u65B0\u5EFA\u8054\u7CFB\u8BA1\u5212\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
1160
+ "jiuchuanhui.contact-plan.complete.prepare": "\u51C6\u5907\u628A\u8054\u7CFB\u8BA1\u5212\u6807\u8BB0\u5B8C\u6210\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
1161
+ "jiuchuanhui.contact-plan.complete.apply": "\u63D0\u4EA4\u628A\u8054\u7CFB\u8BA1\u5212\u6807\u8BB0\u5B8C\u6210\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
1162
+ "jiuchuanhui.entity.contact-records.list": "\u67E5\u67D0\u4E2A\u5B9E\u4F53\uFF08\u5BA2\u6237/\u5546\u673A/\u7EBF\u7D22\uFF09\u540D\u4E0B\u7684\u8054\u7CFB\u8BB0\u5F55\uFF1B\u5165\u53C2 mainTable \u4E0E\u5B9E\u4F53\u4E3B\u952E",
1163
+ "jiuchuanhui.contact-records.by-person-time.list": "\u6309\u4EBA\u5458\u4E0E\u65F6\u95F4\u8303\u56F4\u67E5\u8054\u7CFB\u8BB0\u5F55",
1164
+ "jiuchuanhui.entity.id.by-name": "\u6309\u540D\u79F0\u89E3\u6790\u5B9E\u4F53 ID\uFF08\u91CD\u540D\u65F6\u4F1A\u7ED9\u51FA\u5019\u9009\uFF09",
1165
+ "jiuchuanhui.user.id.by-name": "\u6309\u59D3\u540D\u89E3\u6790\u7528\u6237 ID\uFF08\u91CD\u540D\u65F6\u4F1A\u7ED9\u51FA\u5019\u9009\uFF09",
1166
+ "jiuchuanhui.user.current-profile": "\u53D6\u5F53\u524D\u767B\u5F55\u4EBA\u7684\u753B\u50CF\u4FE1\u606F\uFF08\u90E8\u95E8/\u5C97\u4F4D/\u4E0A\u7EA7\uFF09",
1167
+ "jiuchuanhui.entity.permission.judge": "\u5224\u5B9A\u5F53\u524D\u7528\u6237\u5BF9\u67D0\u5B9E\u4F53\uFF08\u5BA2\u6237/\u5546\u673A/\u7EBF\u7D22\uFF09\u7684\u64CD\u4F5C\u6743\u9650",
1168
+ "jiuchuanhui.company.business-profile.query": "\u67E5\u5BA2\u6237\u7684\u5DE5\u5546\u753B\u50CF\u4FE1\u606F",
1169
+ "jiuchuanhui.field.info.by-ids": "\u6309 ID \u6279\u91CF\u53D6\u5B57\u6BB5\u4FE1\u606F\uFF08\u540D\u79F0/\u7C7B\u578B\uFF09",
1170
+ "jiuchuanhui.browser-option.search": "\u901A\u7528\u6D4F\u89C8\u6309\u94AE\u68C0\u7D22\uFF1A\u6309\u81EA\u5B9A\u4E49\u6D4F\u89C8\u6309\u94AE\u7C7B\u578B\u53D6\u5019\u9009\uFF08\u8DEF\u5F84\u53C2\u6570 pathParams\uFF09",
1171
+ "jiuchuanhui.get-rest-cfg-detail": "\u6309 apid + id \u53D6 REST \u914D\u7F6E\u8BE6\u60C5\uFF08\u4E0E rest.cfg.detail \u540C\u7C7B\uFF0C\u8DEF\u5F84\u4E0D\u540C\uFF09"
1172
+ };
1173
+ function withSummaries(operations) {
1174
+ return operations.map((item) => ({
1175
+ ...item,
1176
+ summary: item.summary || OPERATION_SUMMARIES[item.name] || ""
1177
+ }));
1178
+ }
1179
+ var jiuchuanhuiOperations = [
1180
+ // ==================== 发现与配置 ====================
1181
+ {
1182
+ name: "jiuchuanhui.cache.init",
1183
+ risk: "local-file-write",
1184
+ fixed: { path: "local:cache", purpose: "\u4E5D\u6C1A\u6C47\u914D\u7F6E\u7F13\u5B58\u521D\u59CB\u5316/\u5237\u65B0" },
1185
+ inputSchema: {
1186
+ type: "object",
1187
+ additionalProperties: false,
1188
+ properties: {
1189
+ dryRun: { type: "boolean", description: "\u53EA\u62C9\u53D6\u4E0D\u5199\u5165\uFF08\u9884\u89C8\uFF09" },
1190
+ verbose: { type: "boolean", description: "\u8FD4\u56DE\u66F4\u591A\u6B65\u9AA4\u660E\u7EC6" }
932
1191
  }
933
- } catch {
934
1192
  }
935
- const cfgMap = {};
936
- for (const pk of ALL_PKS) {
937
- const resp = await host.request({
938
- path: "/api/esb/server/event/triggerActionFlow",
939
- body: { customParams: { mainTable: { interface_pk: pk } }, uniqueIndent: "4F6E1A9702864666803CCA6B77B86227", employeeId: userId },
940
- operation: this.name
941
- });
942
- const cfgId = resp?.actionData?.responseData?.customData?.mainTable?.cfgId ?? resp?.customData?.mainTable?.cfgId ?? resp?.datajson?.mainTable?.cfgId ?? resp?.data?.mainTable?.cfgId ?? resp?.mainTable?.cfgId;
943
- if (cfgId) cfgMap[pk] = String(cfgId);
1193
+ },
1194
+ {
1195
+ name: "jiuchuanhui.app.discovery",
1196
+ risk: "read",
1197
+ fixed: { path: "/api/bs/ebuilder/app/tags/getAppIds", method: "GET" },
1198
+ inputSchema: {
1199
+ type: "object",
1200
+ additionalProperties: false,
1201
+ properties: {
1202
+ tag: { type: "string", description: "\u5E94\u7528\u6807\u7B7E\uFF1B\u5FC5\u586B\uFF0C\u5E38\u7528 jch-crm-project\uFF08\u4E0D\u4F1A\u81EA\u52A8\u6CE8\u5165\u9ED8\u8BA4\u503C\uFF09" }
1203
+ },
1204
+ required: ["tag"]
944
1205
  }
945
- const perPk = {};
946
- for (const pk of Object.keys(cfgMap)) {
947
- const cfgId = cfgMap[pk];
948
- const resp = await host.request({
949
- method: "GET",
950
- path: "/api/bs/ebuilder/form/formdata/getRestCfgById",
951
- query: { apid: appId, id: cfgId },
952
- operation: this.name
953
- });
954
- const detail = resp?.data ?? {};
955
- if (!detail?.id && !detail?.mainFields) continue;
956
- const allFields = [
957
- ...detail.mainFields || [],
958
- ...(detail.detailFields || []).flatMap((df) => df.fields || [])
959
- ];
960
- const fieldIds = [...new Set(allFields.filter(isInputOne).map((f) => String(f.fieldid)).filter(Boolean))];
961
- const infoMap = /* @__PURE__ */ new Map();
962
- if (fieldIds.length > 0) {
963
- try {
964
- const infoResp = await host.request({
965
- path: "/api/esb/server/event/triggerActionFlow",
966
- body: { customParams: { mainTable: { fieldids: fieldIds.join(",") } }, uniqueIndent: "10351A4DC8D4454A9F1957FBE647CD9F", employeeId: userId },
967
- operation: this.name
968
- });
969
- const list = infoResp?.actionData?.responseData?.customData?.mainTable?.fieldInfoList ?? infoResp?.customData?.mainTable?.fieldInfoList ?? infoResp?.datajson?.mainTable?.fieldInfoList ?? infoResp?.fieldInfoList ?? [];
970
- for (const it of list) infoMap.set(String(it.id), it);
971
- } catch {
972
- }
973
- }
974
- const merge = (f) => {
975
- const info = infoMap.get(String(f?.fieldid));
976
- if (info) {
977
- f.data_key = info.data_key ?? f.data_key;
978
- f.title = info.title ?? f.title;
979
- f.component_type = info.component_type ?? f.component_type;
980
- }
981
- };
982
- detail.mainFields = (detail.mainFields || []).filter(isInputOne);
983
- detail.detailFields = (detail.detailFields || []).map((df) => ({ ...df, fields: (df.fields || []).filter(isInputOne) })).filter((df) => Array.isArray(df.fields) && df.fields.length > 0);
984
- for (const f of detail.mainFields) merge(f);
985
- for (const df of detail.detailFields) for (const f of df.fields) merge(f);
986
- const kept = pickKeys(detail, DETAIL_KEEP_KEYS);
987
- if (Array.isArray(kept.mainFields)) kept.mainFields = kept.mainFields.map((f) => pickKeys(f, FIELD_KEEP_KEYS));
988
- if (Array.isArray(kept.detailFields)) {
989
- kept.detailFields = kept.detailFields.map((df) => ({
990
- ...pickKeys(df, ["id", "fieldName", "title", "fields"]),
991
- fields: Array.isArray(df.fields) ? df.fields.map((f) => pickKeys(f, FIELD_KEEP_KEYS)) : []
992
- }));
993
- }
994
- perPk[pk] = { cfgId, detail: kept };
1206
+ },
1207
+ {
1208
+ name: "jiuchuanhui.form.discovery",
1209
+ risk: "read",
1210
+ fixed: { path: "/api/ebuilder/form/obj/getObjsByTag", method: "GET" },
1211
+ inputSchema: {
1212
+ type: "object",
1213
+ additionalProperties: false,
1214
+ properties: {
1215
+ tag: { type: "string", description: "\u8868\u5355 tag\uFF0C\u5982 uf_jch_customer" },
1216
+ appId: { type: "string" }
1217
+ },
1218
+ required: ["tag", "appId"]
995
1219
  }
996
- const ebuilder = {};
997
- for (const { key, path, nameFields } of EBUILDER_QUERIES) {
998
- const list = [];
999
- let pageNo = 1;
1000
- for (; ; ) {
1001
- const resp = await host.request({
1002
- path,
1003
- body: { datajson: { mainTable: {}, pageInfo: { pageNo, pageSize: 100 }, header: { operator: userId } } },
1004
- operation: this.name
1005
- });
1006
- const items = resp?.datajson?.datas ?? resp?.data ?? [];
1007
- list.push(...Array.isArray(items) ? items : []);
1008
- const hasMore = resp?.hasMore ?? (Array.isArray(items) && items.length === 100);
1009
- if (!hasMore || list.length >= 500 || pageNo >= 5) break;
1010
- pageNo += 1;
1011
- }
1012
- ebuilder[key] = list.map((it) => {
1013
- const mt = it?.mainTable ?? it ?? {};
1014
- let name = "";
1015
- for (const nf of nameFields) {
1016
- if (mt[nf] !== void 0 && mt[nf] !== null && String(mt[nf]) !== "") {
1017
- name = String(mt[nf]);
1018
- break;
1019
- }
1020
- }
1021
- const item = { id: String(mt.id ?? ""), name };
1022
- if (key === "sale_stage" && mt.sale_process !== void 0) {
1023
- const sp = Array.isArray(mt.sale_process) ? mt.sale_process[0] : mt.sale_process;
1024
- if (sp && typeof sp === "object") item.sale_process = { id: String(sp.id ?? ""), name: String(sp.name ?? "") };
1025
- }
1026
- return item;
1027
- }).filter((x) => x.id);
1220
+ },
1221
+ {
1222
+ name: "jiuchuanhui.field.options",
1223
+ risk: "read",
1224
+ fixed: { path: "/api/ebuilder/common/ds/options", method: "GET", sourceType: "FORM", optionLevel: 1 },
1225
+ inputSchema: {
1226
+ type: "object",
1227
+ additionalProperties: false,
1228
+ properties: {
1229
+ fieldName: { type: "string", description: "\u5B57\u6BB5\u5143\u6570\u636EID\uFF08fieldid\uFF09\uFF0C\u4E0D\u662F data_key \u540D\u79F0" },
1230
+ sourceType: { type: "string", default: "FORM" },
1231
+ objId: { type: "string", description: "\u8868\u5355\u5BF9\u8C61ID\uFF0C\u53EF\u7701\u7565\u81EA\u52A8\u53D1\u73B0" },
1232
+ 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" }
1233
+ },
1234
+ required: ["fieldName", "sourceType"]
1028
1235
  }
1029
- const options = {};
1030
- for (const pk of Object.keys(perPk)) {
1031
- const tag = PK_TO_TAG[pk];
1032
- const objId = discovery[`objId:${tag}`];
1033
- if (!objId) continue;
1034
- const detail = perPk[pk].detail ?? {};
1035
- const fields = [
1036
- ...detail.mainFields || [],
1037
- ...(detail.detailFields || []).flatMap((d) => d.fields || [])
1038
- ];
1039
- for (const f of fields) {
1040
- if (!f?.fieldid) continue;
1041
- if (!OPT_COMP.includes(f.component_type)) continue;
1042
- const key = `options:${f.fieldid}:*:1`;
1043
- if (options[key]) continue;
1044
- try {
1045
- const resp = await host.request({
1046
- method: "GET",
1047
- path: "/api/ebuilder/common/ds/options",
1048
- query: { fieldName: String(f.fieldid), objId, groupId: appId, optionLevel: 1 },
1049
- operation: this.name
1050
- });
1051
- const values = resp?.data ?? resp?.datajson?.datas ?? [];
1052
- options[key] = {
1053
- lable: `${pk}.${f.data_key ?? f.fieldid}`,
1054
- lableTitle: `${pk}.${f.title ?? f.data_key ?? f.fieldid}`,
1055
- value: (Array.isArray(values) ? values : []).map((v) => ({
1056
- label: String(v?.lable ?? v?.label ?? v?.text ?? v?.name ?? ""),
1057
- value: String(v?.value ?? v?.val ?? v?.id ?? "")
1058
- }))
1059
- };
1060
- } catch {
1061
- }
1062
- }
1236
+ },
1237
+ {
1238
+ name: "jiuchuanhui.rest.cfg.detail",
1239
+ risk: "read",
1240
+ fixed: { path: "/api/bs/ebuilder/form/formdata/getRestCfgById", method: "GET" },
1241
+ inputSchema: {
1242
+ type: "object",
1243
+ additionalProperties: false,
1244
+ properties: {
1245
+ apid: { type: "string", description: "\u5E94\u7528 ID" },
1246
+ id: { type: "string", description: "\u63A5\u53E3\u914D\u7F6E ID (cfgId)" }
1247
+ },
1248
+ required: ["apid", "id"]
1063
1249
  }
1064
- const searchPerPk = {};
1065
- for (const pk of SEARCH_PKS) {
1066
- const cfgId = cfgMap[pk];
1067
- if (!cfgId) continue;
1068
- try {
1069
- const resp = await host.request({
1070
- method: "GET",
1071
- path: "/api/bs/ebuilder/form/formdata/getRestCfgById",
1072
- query: { apid: appId, id: cfgId },
1073
- operation: this.name
1074
- });
1075
- const cfgObj = resp?.data ?? {};
1076
- let conditions = cfgObj.conditions;
1077
- if (typeof conditions === "string") {
1078
- try {
1079
- conditions = JSON.parse(conditions);
1080
- } catch {
1081
- conditions = null;
1082
- }
1083
- }
1084
- const params = [];
1085
- for (const d of conditions?.datas ?? []) {
1086
- const value = d?.conditions?.value;
1087
- if (typeof value === "string") {
1088
- const m = value.match(/\{([^}]+)\}/);
1089
- if (m) {
1090
- params.push({
1091
- key: m[1],
1092
- text: d?.text ?? "",
1093
- fieldType: d?.fieldType ?? "",
1094
- compType: d?.compType ?? "",
1095
- func: d?.conditions?.func ?? "",
1096
- fieldid: d?.fieldName ?? ""
1097
- });
1098
- }
1099
- }
1250
+ },
1251
+ {
1252
+ name: "jiuchuanhui.config.id.by.pk",
1253
+ risk: "read",
1254
+ fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "4F6E1A9702864666803CCA6B77B86227" },
1255
+ inputSchema: {
1256
+ type: "object",
1257
+ additionalProperties: false,
1258
+ properties: {
1259
+ mainTable: {
1260
+ type: "object",
1261
+ additionalProperties: false,
1262
+ properties: { interface_pk: { type: "string" } },
1263
+ required: ["interface_pk"]
1100
1264
  }
1101
- searchPerPk[pk] = { cfgId, searchParams: params };
1102
- } catch {
1265
+ },
1266
+ required: ["mainTable"]
1267
+ }
1268
+ },
1269
+ {
1270
+ name: "jiuchuanhui.file.preview",
1271
+ risk: "read",
1272
+ fixed: { path: "/api/file/preview", method: "GET", module: "ebuilderform", authModule: "ebuilderform", source: "form" },
1273
+ inputSchema: {
1274
+ type: "object",
1275
+ additionalProperties: false,
1276
+ properties: {
1277
+ fileId: { type: "string" },
1278
+ fieldId: { type: "string" },
1279
+ appId: { type: "string" },
1280
+ customParam: { type: ["string", "object"] }
1281
+ },
1282
+ required: ["fileId"]
1283
+ }
1284
+ },
1285
+ // ==================== 客户 ====================
1286
+ ...writePair("jiuchuanhui.customer.create", "\u5BA2\u6237\u521B\u5EFA", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/saveFormData/customer_create_api" }),
1287
+ {
1288
+ name: "jiuchuanhui.customer.get",
1289
+ risk: "read",
1290
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataByPk/customer_get_api" },
1291
+ inputSchema: { type: "object", additionalProperties: false, properties: { id: idProp }, required: ["id"] }
1292
+ },
1293
+ {
1294
+ name: "jiuchuanhui.customer.search",
1295
+ risk: "read",
1296
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_search_api", countPath: "/api/ebuilder/form/formdata/v2/getFormDataCount/ebcustomer_search_count_api" },
1297
+ inputSchema: {
1298
+ type: "object",
1299
+ additionalProperties: true,
1300
+ 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",
1301
+ properties: pageProps
1302
+ }
1303
+ },
1304
+ {
1305
+ name: "jiuchuanhui.customer.mine.search",
1306
+ risk: "read",
1307
+ inputSchema: { type: "object", additionalProperties: false, description: "\u67E5\u8BE2\u6211\u7684\u5BA2\u6237\u3002\u9ED8\u8BA4\u53D6\u7B2C\u4E00\u9875 10 \u6761\u3002", properties: customerQuickSearchProps }
1308
+ },
1309
+ {
1310
+ name: "jiuchuanhui.customer.success.search",
1311
+ risk: "read",
1312
+ inputSchema: {
1313
+ type: "object",
1314
+ additionalProperties: false,
1315
+ description: "\u67E5\u8BE2\u5BA2\u6237\u72B6\u6001\u4E3A\u201C\u6210\u529F\u201D\u6216\u201C\u6210\u529F\u5BA2\u6237\u201D\u7684\u5BA2\u6237\u3002\u6309\u5F53\u524D\u79DF\u6237\u7684\u72B6\u6001\u5B57\u5178\u89E3\u6790\u72B6\u6001 ID\uFF0C\u9ED8\u8BA4\u5728\u6211\u7684\u5BA2\u6237\u8303\u56F4\u5185\u67E5\u8BE2\u3002",
1316
+ properties: {
1317
+ ...customerQuickSearchProps,
1318
+ scope: { type: "string", enum: Object.keys(CUSTOMER_SEARCH_SCOPES), default: "mine", description: "\u6211\u7684\u5BA2\u6237\u3001\u5168\u90E8\u53EF\u89C1\u5BA2\u6237\u6216\u516C\u6D77\u5BA2\u6237" }
1103
1319
  }
1104
1320
  }
1105
- for (const [pk, entry] of Object.entries(searchPerPk)) {
1106
- if (perPk[pk]) perPk[pk] = { ...perPk[pk], ...entry };
1107
- else perPk[pk] = entry;
1321
+ },
1322
+ {
1323
+ name: "jiuchuanhui.customer.open-sea.customers.search",
1324
+ risk: "read",
1325
+ inputSchema: { type: "object", additionalProperties: false, description: "\u67E5\u8BE2\u516C\u6D77\u8303\u56F4\u4E2D\u7684\u5BA2\u6237\u8BB0\u5F55\u3002\u9ED8\u8BA4\u53D6\u7B2C\u4E00\u9875 10 \u6761\u3002", properties: customerQuickSearchProps }
1326
+ },
1327
+ {
1328
+ name: "jiuchuanhui.customer.type.search",
1329
+ risk: "read",
1330
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_type_search_api" },
1331
+ inputSchema: { type: "object", additionalProperties: false, properties: pageProps }
1332
+ },
1333
+ {
1334
+ name: "jiuchuanhui.customer.status.search",
1335
+ risk: "read",
1336
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_status_search_api" },
1337
+ inputSchema: { type: "object", additionalProperties: false, properties: pageProps }
1338
+ },
1339
+ {
1340
+ name: "jiuchuanhui.customer.industry.search",
1341
+ risk: "read",
1342
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_industry_search_api" },
1343
+ inputSchema: { type: "object", additionalProperties: false, properties: pageProps }
1344
+ },
1345
+ {
1346
+ name: "jiuchuanhui.customer.open-sea.search",
1347
+ risk: "read",
1348
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/customer_open_sea_search_api" },
1349
+ inputSchema: { type: "object", additionalProperties: true, properties: pageProps }
1350
+ },
1351
+ ...writePair("jiuchuanhui.customer.update", "\u5BA2\u6237\u4FEE\u6539", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/updateFormData/customer_update_api" }),
1352
+ ...writePair("jiuchuanhui.customer.transfer", "\u5BA2\u6237\u8F6C\u79FB", esbWriteProps(["customerId", "employee_MappingId", "employeeName"]), ["customerId"], { uniqueIndent: "1E44ED7DA9EB46329818E682C2914928" }),
1353
+ ...writePair("jiuchuanhui.customer.open-sea.release", "\u5BA2\u6237\u91CA\u653E\u516C\u6D77", esbWriteProps(["customerId", "openSeaId"]), ["customerId", "openSeaId"], { uniqueIndent: "0E29AD0E708D4964B071D293288B92D7" }),
1354
+ ...writePair("jiuchuanhui.customer.open-sea.claim", "\u9886\u53D6\u516C\u6D77\u5BA2\u6237", esbWriteProps(["customer_id"]), ["customer_id"], { uniqueIndent: "D587CDC892FE41118DD073475C01A2CE" }),
1355
+ {
1356
+ name: "jiuchuanhui.customer.duplicate.check",
1357
+ risk: "read",
1358
+ fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "D5D0A1C30E7B404B842987C0AD3B749D" },
1359
+ inputSchema: {
1360
+ type: "object",
1361
+ additionalProperties: false,
1362
+ properties: { mainTable: esbWriteSchema(["name", "simpleName"], ["name", "simpleName"]) },
1363
+ required: ["mainTable"]
1108
1364
  }
1109
- const region = {};
1110
- for (const city of REGION_CITIES) {
1111
- try {
1112
- const resp = await host.request({
1113
- path: "/api/esb/server/event/triggerActionFlow",
1114
- body: {
1115
- customParams: { mainTable: { moduleType: "administrativeDivision", name: city, fromType: "agentSkill" } },
1116
- uniqueIndent: "7EC1639D5AC24B4DBCEE8D2CB85D4025",
1117
- employeeId: userId
1365
+ },
1366
+ ...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" }),
1367
+ ...writePair("jiuchuanhui.customer.contact-record.batch", "\u6279\u91CF\u6DFB\u52A0\u5BA2\u6237\u8054\u7CFB\u8BB0\u5F55", esbWriteProps(["entityList", "content"]), ["entityList", "content"], { uniqueIndent: "D0F315619FE34C669AE738ED68329FAB" }),
1368
+ // ==================== 联系人 ====================
1369
+ ...writePair("jiuchuanhui.contact.create", "\u8054\u7CFB\u4EBA\u521B\u5EFA", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/saveFormData/contact_create_api" }),
1370
+ {
1371
+ name: "jiuchuanhui.contact.get",
1372
+ risk: "read",
1373
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataByPk/contact_get_api" },
1374
+ inputSchema: { type: "object", additionalProperties: false, properties: { id: idProp }, required: ["id"] }
1375
+ },
1376
+ ...writePair("jiuchuanhui.contact.update", "\u8054\u7CFB\u4EBA\u4FEE\u6539", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/updateFormData/contact_update_api" }),
1377
+ {
1378
+ name: "jiuchuanhui.contact.by-entity.search",
1379
+ risk: "read",
1380
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcontact_search_by_entity_api" },
1381
+ inputSchema: {
1382
+ type: "object",
1383
+ additionalProperties: true,
1384
+ properties: { ...pageProps, customerId: { type: "string" }, saleChanceId: { type: "string" } }
1385
+ }
1386
+ },
1387
+ // ==================== 商机 ====================
1388
+ ...writePair("jiuchuanhui.sale.create", "\u5546\u673A\u521B\u5EFA", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/saveFormData/sale_create_api" }),
1389
+ {
1390
+ name: "jiuchuanhui.sale.get",
1391
+ risk: "read",
1392
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataByPk/sale_get_api" },
1393
+ inputSchema: { type: "object", additionalProperties: false, properties: { id: idProp }, required: ["id"] }
1394
+ },
1395
+ {
1396
+ name: "jiuchuanhui.sale.search",
1397
+ risk: "read",
1398
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebsale_search_api", countPath: "/api/ebuilder/form/formdata/v2/getFormDataCount/ebsale_search_count_api" },
1399
+ inputSchema: { type: "object", additionalProperties: true, properties: pageProps }
1400
+ },
1401
+ ...writePair("jiuchuanhui.sale.update", "\u5546\u673A\u4FEE\u6539", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/updateFormData/sale_update_api" }),
1402
+ {
1403
+ name: "jiuchuanhui.sale.stage.search",
1404
+ risk: "read",
1405
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/sale_stage_search_api" },
1406
+ inputSchema: { type: "object", additionalProperties: false, properties: pageProps }
1407
+ },
1408
+ {
1409
+ name: "jiuchuanhui.sale.process.search",
1410
+ risk: "read",
1411
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/sale_process_sear_api" },
1412
+ inputSchema: { type: "object", additionalProperties: false, properties: pageProps }
1413
+ },
1414
+ {
1415
+ name: "jiuchuanhui.sale.lose-reason.search",
1416
+ risk: "read",
1417
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/sale_lose_reason" },
1418
+ inputSchema: { type: "object", additionalProperties: false, properties: pageProps }
1419
+ },
1420
+ {
1421
+ name: "jiuchuanhui.rival.search",
1422
+ risk: "read",
1423
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebrival_search_api" },
1424
+ inputSchema: { type: "object", additionalProperties: false, properties: pageProps }
1425
+ },
1426
+ ...writePair("jiuchuanhui.sale.win", "\u5546\u673A\u8D62\u5355", esbWriteProps(["saleId"]), ["saleId"], { uniqueIndent: "3B23E782E5084F18A904E895BBD61A96" }),
1427
+ ...writePair("jiuchuanhui.sale.lose", "\u5546\u673A\u8F93\u5355", esbWriteProps(["saleid", "money", "reasonids", "rivals", "desc"]), ["saleid"], { uniqueIndent: "DE35D926F82F49FDBA26B48B0CA1CB53" }),
1428
+ ...writePair("jiuchuanhui.sale.invalid", "\u5546\u673A\u65E0\u6548", esbWriteProps(["saleId"]), ["saleId"], { uniqueIndent: "4D88AB8677D84BAC90B63137E7FA1FF9" }),
1429
+ ...writePair("jiuchuanhui.sale.pause", "\u5546\u673A\u6682\u505C", esbWriteProps(["saleId", "pauseReason", "restartDate"]), ["saleId", "pauseReason"], { uniqueIndent: "859C73403DCC4F01B02329571BDBD9F3" }),
1430
+ ...writePair("jiuchuanhui.sale.restart", "\u5546\u673A\u91CD\u542F", esbWriteProps(["saleChanceId"]), ["saleChanceId"], { uniqueIndent: "F3004CDCA8A548B5A0DACD3CDE62387A" }),
1431
+ ...writePair("jiuchuanhui.sale.manager-change", "\u5546\u673A\u8F6C\u79FB/\u8D1F\u8D23\u4EBA\u53D8\u66F4", esbWriteProps(["saleChanceId", "managerId"]), ["saleChanceId", "managerId"], { uniqueIndent: "595F9C6F1C4248929B83086F71363BA7" }),
1432
+ ...writePair("jiuchuanhui.sale.link-contacts", "\u5546\u673A\u5173\u8054\u8054\u7CFB\u4EBA", esbWriteProps(["salechanceId", "contactIds"]), ["salechanceId", "contactIds"], { uniqueIndent: "1114A713A62F4CA9899CC24ED5902D93" }),
1433
+ ...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" }),
1434
+ // ==================== 线索 ====================
1435
+ ...writePair("jiuchuanhui.clue.create", "\u7EBF\u7D22\u521B\u5EFA", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/saveFormData/ebclue_ai_create_api" }),
1436
+ {
1437
+ name: "jiuchuanhui.clue.get",
1438
+ risk: "read",
1439
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataByPk/ebcluepool_ai_get_api" },
1440
+ inputSchema: { type: "object", additionalProperties: false, properties: { id: idProp }, required: ["id"] }
1441
+ },
1442
+ {
1443
+ name: "jiuchuanhui.clue.search",
1444
+ risk: "read",
1445
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebclue_ai_search_api", countPath: "/api/ebuilder/form/formdata/v2/getFormDataCount/ebclue_ai_search_count_api" },
1446
+ inputSchema: { type: "object", additionalProperties: true, properties: pageProps }
1447
+ },
1448
+ {
1449
+ name: "jiuchuanhui.clue.pool.search",
1450
+ risk: "read",
1451
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcluepool_ai_search_api" },
1452
+ inputSchema: { type: "object", additionalProperties: true, properties: pageProps }
1453
+ },
1454
+ ...writePair("jiuchuanhui.clue.update", "\u7EBF\u7D22\u4FEE\u6539", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/updateFormData/ebclue_ai_update_api" }),
1455
+ ...writePair("jiuchuanhui.clue.status-change", "\u7EBF\u7D22\u72B6\u6001\u53D8\u66F4", esbWriteProps(["clueid", "type", "newmanager", "desc"]), ["clueid", "type"], { uniqueIndent: "257CC8DE42234F9191439B229839B8A7" }),
1456
+ ...writePair("jiuchuanhui.clue.to-customer", "\u7EBF\u7D22\u8F6C\u5DF2\u6709\u5BA2\u6237", esbWriteProps(["clueId", "customerId"]), ["clueId", "customerId"], { uniqueIndent: "00914C6415EB455DB7FCCC32DBE6E0C3" }),
1457
+ ...writePair("jiuchuanhui.clue.contact-record.create", "\u65B0\u5EFA\u7EBF\u7D22\u8DDF\u8FDB\u8BB0\u5F55", esbWriteProps(["clueId", "content", "clueStatus_MappingId"]), ["clueId", "content"], { uniqueIndent: "B3DD120601344320A2B50A042B450681" }),
1458
+ // ==================== 联系计划 ====================
1459
+ ...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" }),
1460
+ ...writePair("jiuchuanhui.contact-plan.complete", "\u5B8C\u6210\u8054\u7CFB\u8BA1\u5212", esbWriteProps(["planId"]), ["planId"], { uniqueIndent: "2595D3556CFC414F85B1A4A8D806EFE5" }),
1461
+ // ==================== 联系记录 ====================
1462
+ {
1463
+ name: "jiuchuanhui.entity.contact-records.list",
1464
+ risk: "read",
1465
+ fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "364A9713D10C4997AF6EDCAA5296968E" },
1466
+ inputSchema: {
1467
+ type: "object",
1468
+ additionalProperties: false,
1469
+ properties: {
1470
+ mainTable: {
1471
+ type: "object",
1472
+ additionalProperties: false,
1473
+ properties: {
1474
+ moduleType: { type: "string", description: "\u4E8B\u9879\u6A21\u5757\u6807\u8BC6\uFF1Acustomer=\u5BA2\u6237\u3001clue=\u7EBF\u7D22\u3001saleChance=\u5546\u673A" },
1475
+ entityId: { type: "string" }
1118
1476
  },
1119
- operation: this.name
1120
- });
1121
- if (Number(resp?.resultCode ?? 0) === 200) {
1122
- region[`administrativeDivision:${city}`] = resp;
1477
+ required: ["moduleType", "entityId"]
1123
1478
  }
1124
- } catch {
1125
- }
1479
+ },
1480
+ required: ["mainTable"]
1126
1481
  }
1127
- const cache = { discovery, ebuilder, options, region };
1128
- cache.region = { ...old.region || {}, ...cache.region || {} };
1129
- cache.options = { ...old.options || {}, ...cache.options || {} };
1130
- if (!cache.discovery[`spVersion:${APP_TAG}`] && old.discovery?.[`spVersion:${APP_TAG}`]) {
1131
- cache.discovery[`spVersion:${APP_TAG}`] = old.discovery[`spVersion:${APP_TAG}`];
1482
+ },
1483
+ {
1484
+ name: "jiuchuanhui.contact-records.by-person-time.list",
1485
+ risk: "read",
1486
+ fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "D01DD00978524525AD8728BE1BF9FE79" },
1487
+ inputSchema: {
1488
+ type: "object",
1489
+ additionalProperties: false,
1490
+ properties: { mainTable: esbWriteSchema(["employeeId", "startData", "endData"]) },
1491
+ required: ["mainTable"]
1132
1492
  }
1133
- const summary = {
1134
- dryRun,
1135
- cacheDir: baseDir,
1136
- mainFile,
1137
- namespaces: {
1138
- discovery: Object.keys(cache.discovery).length,
1139
- ebuilder: Object.keys(cache.ebuilder).length,
1140
- options: Object.keys(cache.options).length,
1141
- region: Object.keys(cache.region).length
1142
- },
1143
- configFiles: Object.keys(perPk).length,
1144
- objIdCount: Object.keys(discovery).filter((k) => k.startsWith("objId:")).length,
1145
- cfgIdCount: Object.keys(cfgMap).length,
1146
- version: cache.discovery[`spVersion:${APP_TAG}`] ?? null,
1147
- warnings: []
1148
- };
1149
- if (cache.discovery[`spVersion:${APP_TAG}`] && cache.discovery[`spVersion:${APP_TAG}`].passed === false) {
1150
- 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`);
1493
+ },
1494
+ // ==================== 通用辅助 ====================
1495
+ {
1496
+ name: "jiuchuanhui.entity.id.by-name",
1497
+ risk: "read",
1498
+ fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "7EC1639D5AC24B4DBCEE8D2CB85D4025" },
1499
+ inputSchema: {
1500
+ type: "object",
1501
+ additionalProperties: false,
1502
+ properties: { mainTable: esbWriteSchema(["moduleType", "name"]) },
1503
+ required: ["mainTable"]
1151
1504
  }
1152
- if (dryRun) return { status: "COMPLETE", data: { ...summary, written: false, note: "dry-run\uFF1A\u53EA\u62C9\u53D6\u672A\u5199\u5165" } };
1153
- mkdirSync(cfgDir, { recursive: true });
1154
- writeFileSync(mainFile, JSON.stringify(cache, null, 2), "utf-8");
1155
- for (const [pk, entry] of Object.entries(perPk)) {
1156
- const tag = PK_TO_TAG[pk];
1157
- const objId = cache.discovery[`objId:${tag}`];
1158
- writeFileSync(join(cfgDir, `${pk}.json`), JSON.stringify({ ...entry, objId: objId ?? "" }, null, 2), "utf-8");
1505
+ },
1506
+ {
1507
+ name: "jiuchuanhui.user.id.by-name",
1508
+ risk: "read",
1509
+ fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "911C17207E2C4BD29379B5A4001B246E" },
1510
+ inputSchema: {
1511
+ type: "object",
1512
+ additionalProperties: false,
1513
+ properties: { mainTable: esbWriteSchema(["employeeName"]) },
1514
+ required: ["mainTable"]
1159
1515
  }
1160
- if (verbose) {
1161
- summary.warnings.push(`${JSON.stringify({ step1: "discovery", step2: "cfgId", step3: "cfg.detail", step4: "ebuilder", step5: "options", step6: "searchParams", step7: "region" })}`);
1516
+ },
1517
+ {
1518
+ name: "jiuchuanhui.user.current-profile",
1519
+ risk: "read",
1520
+ fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "B8F7597190FF419FB9127D6C8272C4FE" },
1521
+ inputSchema: { type: "object", additionalProperties: false, properties: {} }
1522
+ },
1523
+ {
1524
+ name: "jiuchuanhui.entity.permission.judge",
1525
+ risk: "read",
1526
+ fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "6D369F0A84764051A5D7B5AA1245F49A" },
1527
+ inputSchema: {
1528
+ type: "object",
1529
+ additionalProperties: false,
1530
+ properties: { mainTable: esbWriteSchema(["moduleType", "entityId", "opType"]) },
1531
+ required: ["mainTable"]
1162
1532
  }
1163
- return {
1164
- status: "COMPLETE",
1165
- data: { ...summary, written: true }
1166
- };
1167
- }
1168
- };
1169
-
1170
- // src/shortcuts/jiuchuanhui/operations/shared.ts
1171
- var FORBIDDEN_INPUT_KEYS = /* @__PURE__ */ new Set([
1172
- "access_token",
1173
- "app_key",
1174
- "app_secret",
1175
- "cookie",
1176
- "eteamsid",
1177
- "token",
1178
- "sessionid"
1179
- ]);
1180
- var FORBIDDEN_NORMALIZED_KEYS = new Set([...FORBIDDEN_INPUT_KEYS].map((key) => key.toLowerCase()));
1181
- function asObject(value, name = "\u4E1A\u52A1\u8F93\u5165") {
1182
- if (!value || typeof value !== "object" || Array.isArray(value)) {
1183
- throw jiuchuanhuiValidationError("input_invalid", `${name}\u5FC5\u987B\u662F JSON \u5BF9\u8C61`);
1184
- }
1185
- return value;
1186
- }
1187
- function asNonEmptyString(value, name) {
1188
- if (typeof value !== "string" || !value.trim()) {
1189
- throw jiuchuanhuiValidationError("input_invalid", `${name} \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32`);
1190
- }
1191
- return value.trim();
1192
- }
1193
- function asPositiveString(value, name) {
1194
- if (typeof value !== "string" || !/^\d+$/u.test(value) || value === "0") {
1195
- throw jiuchuanhuiValidationError("input_invalid", `${name} \u5FC5\u987B\u662F\u6B63\u6574\u6570\u6587\u672C`);
1196
- }
1197
- return value;
1198
- }
1199
- function assertNoForbiddenKeys(value, location = "input") {
1200
- if (!value || typeof value !== "object") return;
1201
- if (Array.isArray(value)) {
1202
- value.forEach((item, index) => assertNoForbiddenKeys(item, `${location}[${index}]`));
1203
- return;
1204
- }
1205
- for (const [key, child] of Object.entries(value)) {
1206
- if (FORBIDDEN_INPUT_KEYS.has(key) || FORBIDDEN_NORMALIZED_KEYS.has(key.toLowerCase())) {
1207
- throw jiuchuanhuiValidationError("field_forbidden", `\u7981\u6B62\u4E1A\u52A1\u8F93\u5165\u5B57\u6BB5\uFF1A${location}.${key}`);
1533
+ },
1534
+ {
1535
+ name: "jiuchuanhui.company.business-profile.query",
1536
+ risk: "read",
1537
+ fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "BAB4DBE204214BB395BA161620A4A1CD" },
1538
+ inputSchema: {
1539
+ type: "object",
1540
+ additionalProperties: false,
1541
+ properties: { mainTable: esbWriteSchema(["companyName"]) },
1542
+ required: ["mainTable"]
1208
1543
  }
1209
- assertNoForbiddenKeys(child, `${location}.${key}`);
1210
- }
1211
- }
1212
- function sessionMatches(lease, session) {
1213
- return lease.baseUrl === session.baseUrl && lease.profile === session.profile && lease.userId === session.userId;
1214
- }
1215
- function workflow(name, state) {
1216
- return { workflow: name, version: 1, state };
1217
- }
1218
- function esbBody(mainTable, uniqueIndent, userId) {
1219
- return {
1220
- customParams: { mainTable },
1221
- uniqueIndent,
1222
- employeeId: userId
1223
- };
1224
- }
1225
- function datasBody(form, userId) {
1226
- const datas = Array.isArray(form.datas) ? form.datas : [form];
1227
- const cleansed = datas.map((item) => stripForbidden(item));
1228
- return {
1229
- datajson: {
1230
- datas: cleansed,
1231
- header: { operator: userId }
1544
+ },
1545
+ {
1546
+ name: "jiuchuanhui.field.info.by-ids",
1547
+ risk: "read",
1548
+ fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "10351A4DC8D4454A9F1957FBE647CD9F" },
1549
+ inputSchema: {
1550
+ type: "object",
1551
+ additionalProperties: false,
1552
+ properties: { mainTable: esbWriteSchema(["fieldids"]) },
1553
+ required: ["mainTable"]
1232
1554
  }
1233
- };
1234
- }
1235
- function byIdBody(id, userId) {
1236
- return {
1237
- datajson: {
1238
- mainTable: { id },
1239
- header: { operator: userId }
1555
+ },
1556
+ {
1557
+ name: "jiuchuanhui.browser-option.search",
1558
+ risk: "read",
1559
+ fixed: { path: "/api/bcw/common/browser/complete/{customBrowserType}", method: "POST" },
1560
+ inputSchema: {
1561
+ type: "object",
1562
+ additionalProperties: false,
1563
+ properties: {
1564
+ pathParams: {
1565
+ type: "object",
1566
+ additionalProperties: false,
1567
+ properties: { customBrowserType: { type: "string" } },
1568
+ required: ["customBrowserType"]
1569
+ },
1570
+ params: {
1571
+ type: "object",
1572
+ additionalProperties: true,
1573
+ properties: { searchValue: { type: "string" } }
1574
+ }
1575
+ },
1576
+ required: ["pathParams"]
1240
1577
  }
1241
- };
1242
- }
1243
- function listBody(userId, pageNo, pageSize, mainTable) {
1244
- const mt = mainTable && Object.keys(mainTable).length ? { ...mainTable } : {};
1245
- return {
1246
- datajson: {
1247
- mainTable: mt,
1248
- pageInfo: { pageNo, pageSize },
1249
- header: { operator: userId }
1578
+ },
1579
+ {
1580
+ name: "jiuchuanhui.get-rest-cfg-detail",
1581
+ risk: "read",
1582
+ fixed: { path: "/api/bs/ebuilder/form/formdata/getRestCfgById", method: "GET" },
1583
+ inputSchema: {
1584
+ type: "object",
1585
+ additionalProperties: false,
1586
+ properties: {
1587
+ apid: { type: "string" },
1588
+ id: { type: "string" }
1589
+ },
1590
+ required: ["apid", "id"]
1250
1591
  }
1251
- };
1252
- }
1253
- function stripForbidden(value) {
1254
- if (Array.isArray(value)) return value.map(stripForbidden);
1255
- if (!value || typeof value !== "object") return value;
1256
- const result = {};
1257
- for (const [key, child] of Object.entries(value)) {
1258
- if (FORBIDDEN_INPUT_KEYS.has(key) || FORBIDDEN_NORMALIZED_KEYS.has(key.toLowerCase())) continue;
1259
- result[key] = stripForbidden(child);
1260
1592
  }
1261
- return result;
1262
- }
1263
- function stripForbiddenKeys(value) {
1264
- return stripForbidden(value);
1265
- }
1266
- function listRecords(value) {
1267
- if (!value || typeof value !== "object") return [];
1268
- const root = value;
1269
- const datas = root.datajson?.datas;
1270
- if (Array.isArray(datas)) return datas;
1271
- return [];
1272
- }
1273
- function resultDataIds(value) {
1274
- if (!value || typeof value !== "object") return [];
1275
- const ids = value.datajson?.dataIds;
1276
- if (Array.isArray(ids)) return ids.map((item) => String(item));
1277
- return [];
1278
- }
1279
- function esbOutcome(value) {
1280
- if (!value || typeof value !== "object") return { resultCode: 0, resultMsg: "" };
1281
- const root = value;
1282
- return {
1283
- resultCode: Number(root.resultCode ?? 0),
1284
- resultMsg: typeof root.resultMsg === "string" ? root.resultMsg : ""
1285
- };
1286
- }
1287
- function pagingFrom(input) {
1288
- const pageNo = Number.isInteger(input.pageNo) && input.pageNo >= 1 ? input.pageNo : 1;
1289
- const pageSize = Number.isInteger(input.pageSize) && input.pageSize >= 1 ? input.pageSize : 10;
1290
- return { pageNo, pageSize };
1593
+ ];
1594
+ var jiuchuanhuiManifest = {
1595
+ schemaVersion: 1,
1596
+ name: "jiuchuanhui",
1597
+ 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",
1598
+ version: "0.1.0",
1599
+ host: "e10-jiuchuanhui",
1600
+ status: "builtin",
1601
+ sourceSkill: "weaver-e10-jiuchuanhui",
1602
+ operations: withSummaries(jiuchuanhuiOperations),
1603
+ withheldOperations: [
1604
+ {
1605
+ name: "jiuchuanhui.sale.stage-advance",
1606
+ 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"
1607
+ }
1608
+ ]
1609
+ };
1610
+ function getJiuchuanhuiOperationContract(operation) {
1611
+ return jiuchuanhuiManifest.operations.find((item) => item.name === operation);
1291
1612
  }
1292
1613
 
1293
1614
  // src/shortcuts/jiuchuanhui/operations/datajson.ts
@@ -1388,20 +1709,12 @@ var DatajsonDetailOperation = class {
1388
1709
  async execute(input, { host }) {
1389
1710
  const id = asPositiveString(String(input.id ?? input.dataId), "id");
1390
1711
  const session = await host.getSession();
1391
- const result = await host.request({
1712
+ const response = await host.query({
1392
1713
  path: this.path,
1393
1714
  body: byIdBody(id, session.userId),
1394
1715
  operation: this.name
1395
1716
  });
1396
- return {
1397
- status: "COMPLETE",
1398
- data: {
1399
- id,
1400
- ...result && typeof result === "object" ? { raw: result } : {},
1401
- mainTable: extractMainTable(result),
1402
- detail: result
1403
- }
1404
- };
1717
+ return { response };
1405
1718
  }
1406
1719
  };
1407
1720
  var DatajsonSearchOperation = class {
@@ -1418,22 +1731,13 @@ var DatajsonSearchOperation = class {
1418
1731
  const session = await host.getSession();
1419
1732
  const query = buildSearchQuery(input, pageNo, pageSize);
1420
1733
  const main = listBody(session.userId, pageNo, pageSize, {});
1421
- const listPromise = host.request({ path: this.path, query, body: main, operation: this.name });
1422
- 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;
1423
- const [listResult, countResult] = countPromise ? await Promise.all([listPromise, countPromise]) : [await listPromise, void 0];
1424
- const records = listRecords(listResult);
1425
- const total = extractCount(countResult);
1426
- return {
1427
- status: "COMPLETE",
1428
- data: {
1429
- items: records,
1430
- total,
1431
- pageNo,
1432
- pageSize,
1433
- hasMore: total === void 0 ? records.length >= pageSize : pageNo * pageSize < total,
1434
- query
1435
- }
1436
- };
1734
+ const listPromise = host.query({ path: this.path, query, body: main, operation: this.name });
1735
+ if (input.count !== true || !this.countPath) return { response: await listPromise };
1736
+ const [response, countResponse] = await Promise.all([
1737
+ listPromise,
1738
+ host.query({ path: this.countPath, query: withoutPaging(query), body: listBody(session.userId, 1, 1, {}), operation: `${this.name}.count` })
1739
+ ]);
1740
+ return { response, countResponse };
1437
1741
  }
1438
1742
  };
1439
1743
  function buildSearchQuery(input, pageNo, pageSize) {
@@ -1458,27 +1762,6 @@ function withoutPaging(query) {
1458
1762
  delete next.pageSize;
1459
1763
  return next;
1460
1764
  }
1461
- function extractCount(value) {
1462
- if (!value || typeof value !== "object") return void 0;
1463
- const root = value;
1464
- const datas = root.datajson?.datas;
1465
- const raw = Array.isArray(datas) ? datas[0] : datas;
1466
- const num = Number(raw ?? root.total ?? root.count);
1467
- return Number.isFinite(num) ? num : void 0;
1468
- }
1469
- function extractMainTable(value) {
1470
- if (!value || typeof value !== "object") return void 0;
1471
- const root = value;
1472
- const mt = root.datajson?.mainTable;
1473
- if (mt && typeof mt === "object" && !Array.isArray(mt)) return mt;
1474
- const datas = root.datajson?.datas;
1475
- if (Array.isArray(datas) && datas[0] && typeof datas[0] === "object") {
1476
- const first = datas[0];
1477
- if (first.mainTable && typeof first.mainTable === "object") return first.mainTable;
1478
- return first;
1479
- }
1480
- return void 0;
1481
- }
1482
1765
 
1483
1766
  // src/shortcuts/jiuchuanhui/operations/esb.ts
1484
1767
  var EsbWritePrepareOperation = class {
@@ -1494,6 +1777,11 @@ var EsbWritePrepareOperation = class {
1494
1777
  mainTableKeys;
1495
1778
  async execute(input, { host, continuation }) {
1496
1779
  const mainTable = normalizeMainTable(input.mainTable, this.mainTableKeys);
1780
+ const properties = getJiuchuanhuiOperationContract(this.name)?.inputSchema.properties;
1781
+ const missing = properties?.mainTable?.required?.filter((key) => !Object.hasOwn(mainTable, key) || mainTable[key] === void 0 || mainTable[key] === null || mainTable[key] === "");
1782
+ if (missing?.length) {
1783
+ throw jiuchuanhuiValidationError("field_required", `\u7F3A\u5C11\u5FC5\u586B\u53C2\u6570\uFF1A${missing.join("\u3001")}`, { fields: missing });
1784
+ }
1497
1785
  const preview = summaryOf(mainTable);
1498
1786
  const session = await host.getSession();
1499
1787
  const continuationToken = await continuation.issue({
@@ -1584,26 +1872,12 @@ var EsbReadOperation = class {
1584
1872
  async execute(input, { host }) {
1585
1873
  const mainTable = normalizeMainTable(input.mainTable ?? input, this.mainTableKeys);
1586
1874
  const session = await host.getSession();
1587
- const result = await host.request({
1875
+ const response = await host.query({
1588
1876
  path: "/api/esb/server/event/triggerActionFlow",
1589
1877
  body: esbBody(mainTable, this.uniqueIndent, session.userId),
1590
1878
  operation: this.name
1591
1879
  });
1592
- const { resultCode, resultMsg } = esbOutcome(result);
1593
- if (resultCode !== 200) {
1594
- throw jiuchuanhuiValidationError("esb_read_failed", `\u52A8\u4F5C\u6D41\u67E5\u8BE2\u5931\u8D25\uFF08resultCode=${resultCode}\uFF09\uFF1A${resultMsg}`);
1595
- }
1596
- const customData = result?.actionData?.responseData?.customData;
1597
- return {
1598
- status: "COMPLETE",
1599
- data: {
1600
- resultCode,
1601
- resultMsg,
1602
- ...customData && typeof customData === "object" ? { customData } : {},
1603
- mainTable: customData?.mainTable,
1604
- raw: result
1605
- }
1606
- };
1880
+ return { response };
1607
1881
  }
1608
1882
  };
1609
1883
  function normalizeMainTable(raw, allowedKeys) {
@@ -1646,19 +1920,13 @@ var GetQueryOperation = class {
1646
1920
  if (value === void 0 || value === null || key === "save") continue;
1647
1921
  query[key] = Array.isArray(value) ? value.join(",") : value;
1648
1922
  }
1649
- const result = await host.request({
1923
+ const response = await host.query({
1650
1924
  method: "GET",
1651
1925
  path: this.path,
1652
1926
  query,
1653
1927
  operation: this.name
1654
1928
  });
1655
- return {
1656
- status: "COMPLETE",
1657
- data: {
1658
- ...result && typeof result === "object" ? { raw: result } : { raw: result },
1659
- query
1660
- }
1661
- };
1929
+ return { response };
1662
1930
  }
1663
1931
  };
1664
1932
  var PathParamsPostOperation = class {
@@ -1680,17 +1948,12 @@ var PathParamsPostOperation = class {
1680
1948
  path = path.replace(`{${name}}`, encodeURIComponent(String(value)));
1681
1949
  }
1682
1950
  const body = input.params && typeof input.params === "object" ? input.params : {};
1683
- const result = await host.request({
1951
+ const response = await host.query({
1684
1952
  path,
1685
1953
  body,
1686
1954
  operation: this.name
1687
1955
  });
1688
- return {
1689
- status: "COMPLETE",
1690
- data: {
1691
- ...result && typeof result === "object" ? { raw: result } : { raw: result }
1692
- }
1693
- };
1956
+ return { response };
1694
1957
  }
1695
1958
  };
1696
1959
  var FilePreviewOperation = class {
@@ -1709,25 +1972,21 @@ var FilePreviewOperation = class {
1709
1972
  if (input.fieldId !== void 0) query.fieldId = input.fieldId;
1710
1973
  if (input.appId !== void 0) query.appId = input.appId;
1711
1974
  if (input.customParam !== void 0) query.customParam = typeof input.customParam === "string" ? input.customParam : JSON.stringify(input.customParam);
1712
- const result = await host.request({
1975
+ const response = await host.query({
1713
1976
  method: "GET",
1714
1977
  path: "/api/file/preview",
1715
1978
  query,
1716
1979
  operation: this.name
1717
1980
  });
1718
- return {
1719
- status: "COMPLETE",
1720
- data: {
1721
- ...result && typeof result === "object" ? { raw: result } : { raw: result },
1722
- fileId
1723
- }
1724
- };
1981
+ return { response };
1725
1982
  }
1726
1983
  };
1727
1984
 
1728
1985
  // src/shortcuts/jiuchuanhui/operations/registry.ts
1729
1986
  function buildRegistry() {
1730
1987
  const registry = /* @__PURE__ */ new Map();
1988
+ const customerSearch = new DatajsonSearchOperation("jiuchuanhui.customer.search", "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_search_api", "/api/ebuilder/form/formdata/v2/getFormDataCount/ebcustomer_search_count_api");
1989
+ const customerStatusSearch = new DatajsonSearchOperation("jiuchuanhui.customer.status.search", "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_status_search_api");
1731
1990
  const handlers = [
1732
1991
  // ===== 发现与缓存 =====
1733
1992
  new CacheInitOperation(),
@@ -1741,9 +2000,12 @@ function buildRegistry() {
1741
2000
  new DatajsonWritePrepareOperation("jiuchuanhui.customer.create.prepare", "jiuchuanhui.customer.create.apply"),
1742
2001
  new DatajsonWriteApplyOperation("jiuchuanhui.customer.create.apply", "/api/ebuilder/form/formdata/v2/saveFormData/customer_create_api"),
1743
2002
  new DatajsonDetailOperation("jiuchuanhui.customer.get", "/api/ebuilder/form/formdata/v2/getFormDataByPk/customer_get_api"),
1744
- new DatajsonSearchOperation("jiuchuanhui.customer.search", "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_search_api", "/api/ebuilder/form/formdata/v2/getFormDataCount/ebcustomer_search_count_api"),
2003
+ customerSearch,
2004
+ new CustomerQuickSearchOperation("jiuchuanhui.customer.mine.search", customerSearch, "mine"),
2005
+ new CustomerQuickSearchOperation("jiuchuanhui.customer.success.search", customerSearch, "mine", customerStatusSearch),
2006
+ new CustomerQuickSearchOperation("jiuchuanhui.customer.open-sea.customers.search", customerSearch, "open-sea"),
1745
2007
  new DatajsonSearchOperation("jiuchuanhui.customer.type.search", "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_type_search_api"),
1746
- new DatajsonSearchOperation("jiuchuanhui.customer.status.search", "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_status_search_api"),
2008
+ customerStatusSearch,
1747
2009
  new DatajsonSearchOperation("jiuchuanhui.customer.industry.search", "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_industry_search_api"),
1748
2010
  new DatajsonSearchOperation("jiuchuanhui.customer.open-sea.search", "/api/ebuilder/form/formdata/v2/getFormDataList/customer_open_sea_search_api"),
1749
2011
  new DatajsonWritePrepareOperation("jiuchuanhui.customer.update.prepare", "jiuchuanhui.customer.update.apply"),
@@ -1880,7 +2142,7 @@ async function inputFrom(options, extra = {}) {
1880
2142
  if (opts.input) {
1881
2143
  let raw;
1882
2144
  try {
1883
- raw = stripBom(opts.input === "-" ? await readStdin() : await readFile2(String(opts.input), "utf8"));
2145
+ raw = stripBom(opts.input === "-" ? await readStdin() : await readFile3(String(opts.input), "utf8"));
1884
2146
  } catch {
1885
2147
  throw jiuchuanhuiValidationError("input_unreadable", `\u65E0\u6CD5\u8BFB\u53D6 --input\uFF1A${String(opts.input)}`);
1886
2148
  }
@@ -1921,16 +2183,41 @@ function failureEnvelope(error) {
1921
2183
  error: toErrorEnvelope(error)
1922
2184
  };
1923
2185
  }
2186
+ function queryEnvelope(operation, { response, countResponse }) {
2187
+ const envelope = JSON.stringify({
2188
+ schemaVersion: 1,
2189
+ ok: true,
2190
+ operation,
2191
+ meta: {
2192
+ status: "COMPLETE",
2193
+ httpStatus: response.httpStatus,
2194
+ ...countResponse ? { countHttpStatus: countResponse.httpStatus } : {}
2195
+ },
2196
+ warnings: []
2197
+ });
2198
+ const count = countResponse ? `,"countResponse":${countResponse.json}` : "";
2199
+ return `${envelope.slice(0, -1)},"data":${response.json}${count}}`;
2200
+ }
1924
2201
  async function executeAndPrint(ctx, operation, input) {
1925
2202
  try {
1926
2203
  const result = await executeJiuchuanhuiOperation(operation, input, {
1927
2204
  host: createJiuchuanhuiHost(ctx),
1928
2205
  continuation: createJiuchuanhuiContinuationSigner(ctx)
1929
2206
  });
1930
- ctx.output.write(successEnvelope(operation, result), { json: true });
2207
+ if ("response" in result) {
2208
+ ctx.output.raw(queryEnvelope(operation, result));
2209
+ } else {
2210
+ ctx.output.write(successEnvelope(operation, result), { json: true });
2211
+ }
1931
2212
  } catch (error) {
1932
- reportPlatformError(error);
1933
- console.error(JSON.stringify(failureEnvelope(error), null, 2));
2213
+ const envelope = failureEnvelope(error);
2214
+ if (ctx.getGlobalOptions().json) {
2215
+ const platformError = shouldReportPlatformError(error) ? toPlatformError(error) : {};
2216
+ console.error(JSON.stringify({ ...envelope, ...platformError }));
2217
+ } else {
2218
+ reportPlatformError(error);
2219
+ console.error(JSON.stringify(envelope, null, 2));
2220
+ }
1934
2221
  process.exitCode = isCliError(error) ? error.exitCode : 1 /* GeneralError */;
1935
2222
  }
1936
2223
  }
@@ -1940,8 +2227,15 @@ var jiuchuanhuiShortcut = {
1940
2227
  category: "shortcut",
1941
2228
  register({ program, action }) {
1942
2229
  const jiuchuanhui = program.command("jiuchuanhui").description("\u6CDB\u5FAEE10\u4E5D\u6C1A\u6C47\u8425\u9500\u7BA1\u7406");
1943
- jiuchuanhui.command("schema").description("Print jiuchuanhui operation manifest for agents").action(action((ctx) => {
1944
- ctx.output.write(jiuchuanhuiManifest, { json: true });
2230
+ jiuchuanhui.command("schema").description("Print jiuchuanhui operation manifest for agents").option("--operation <name>", "print the contract for one operation").action(action((ctx, options) => {
2231
+ const { operation } = asOptions(options);
2232
+ if (operation === void 0) {
2233
+ ctx.output.write(jiuchuanhuiManifest, { json: true });
2234
+ return;
2235
+ }
2236
+ const contract = getJiuchuanhuiOperationContract(operation);
2237
+ if (!contract) throw jiuchuanhuiValidationError("operation_unknown", `\u4E5D\u6C1A\u6C47\u4E0D\u652F\u6301\u64CD\u4F5C\uFF1A${operation}`);
2238
+ ctx.output.write(contract, { json: true });
1945
2239
  }));
1946
2240
  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) => {
1947
2241
  await executeAndPrint(ctx, String(operation), await inputFrom(options));
@@ -1950,5 +2244,6 @@ var jiuchuanhuiShortcut = {
1950
2244
  };
1951
2245
  export {
1952
2246
  inputFrom,
1953
- jiuchuanhuiShortcut
2247
+ jiuchuanhuiShortcut,
2248
+ queryEnvelope
1954
2249
  };