weaver-work-cli 0.1.69 → 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 (53) hide show
  1. package/dist/chunks/{attachment-content-7BEDNQ3O.js → attachment-content-DMU7KNZ7.js} +3 -3
  2. package/dist/chunks/{chunk-ELF5TPSG.js → chunk-4W6BSNIL.js} +6 -6
  3. package/dist/chunks/{chunk-BEYEXCWU.js → chunk-7CINV2BU.js} +2 -2
  4. package/dist/chunks/{chunk-JAIZY37Z.js → chunk-EHH363SP.js} +4 -4
  5. package/dist/chunks/{chunk-6DH73Q5H.js → chunk-GFOFUH6O.js} +38 -38
  6. package/dist/chunks/{chunk-MLJK4KLE.js → chunk-GWM5TLIK.js} +32 -32
  7. package/dist/chunks/{chunk-FMAZ42HS.js → chunk-HAORST2G.js} +7 -7
  8. package/dist/chunks/{chunk-ERAE4GHX.js → chunk-IVCOZCAW.js} +1 -1
  9. package/dist/chunks/{chunk-3TZURS7M.js → chunk-KDOJW5LH.js} +1 -1
  10. package/dist/chunks/{chunk-3CBURKSY.js → chunk-L2A3COWV.js} +2 -2
  11. package/dist/chunks/{chunk-4XYRTXRR.js → chunk-LJE7RZNC.js} +1 -1
  12. package/dist/chunks/{chunk-67AN5YJT.js → chunk-X6PMJQGO.js} +3 -3
  13. package/dist/chunks/{chunk-YR3K53BU.js → chunk-XIBMZEDB.js} +2 -2
  14. package/dist/chunks/{conflict-VKCRXHUV.js → conflict-YW5BULJ3.js} +2 -2
  15. package/dist/chunks/{create-flow-WYPLBLRK.js → create-flow-5OBS3B3V.js} +6 -6
  16. package/dist/chunks/{entry-mode-BCJ7RPFC.js → entry-mode-L65OWPFM.js} +3 -3
  17. package/dist/chunks/{env-SCVCHBN2.js → env-XW7LYIME.js} +2 -2
  18. package/dist/chunks/{factory-CBXYOEBF.js → factory-MHFZZAGH.js} +1 -1
  19. package/dist/chunks/{group-chat-RFL4U7RF.js → group-chat-EEOLO5NM.js} +3 -3
  20. package/dist/chunks/{jiuchuanhui-PY2WEBUH.js → jiuchuanhui-JCBUR563.js} +1278 -1131
  21. package/dist/chunks/{meeting-N2AGGLVI.js → meeting-PCD5EPBF.js} +11 -11
  22. package/dist/chunks/{minute-doc-C62EZOJH.js → minute-doc-WTZJVCHG.js} +2 -2
  23. package/dist/chunks/{performance-GBKM5G2Y.js → performance-SMVTPK6T.js} +5 -4
  24. package/dist/chunks/{registry-Y2HWS6JS.js → registry-3B3OAJYX.js} +1 -1
  25. package/dist/chunks/{registry-7US3QQXV.js → registry-ZQ7OONCB.js} +11 -11
  26. package/dist/chunks/{room-recommend-LMNF76YS.js → room-recommend-73NBN3RU.js} +4 -4
  27. package/dist/chunks/{schedule-4QE2THAP.js → schedule-SDBOBBUQ.js} +4 -4
  28. package/dist/chunks/{workflow-KXYTQZ2H.js → workflow-OWHWLAOX.js} +1 -1
  29. package/dist/index.js +4 -4
  30. package/dist/shortcuts/jiuchuanhui/cache.js +49 -35
  31. package/dist/shortcuts/jiuchuanhui/host.js +37 -5
  32. package/dist/shortcuts/jiuchuanhui/index.js +43 -7
  33. package/dist/shortcuts/jiuchuanhui/manifest.js +36 -1
  34. package/dist/shortcuts/jiuchuanhui/operations/customer-quick.js +110 -0
  35. package/dist/shortcuts/jiuchuanhui/operations/datajson.js +11 -56
  36. package/dist/shortcuts/jiuchuanhui/operations/esb.js +9 -16
  37. package/dist/shortcuts/jiuchuanhui/operations/generic.js +8 -30
  38. package/dist/shortcuts/jiuchuanhui/operations/registry.js +8 -2
  39. package/dist/shortcuts/jiuchuanhui/operations/shared.js +0 -10
  40. package/dist/shortcuts/performance/operations/flow-detail.js +5 -4
  41. package/dist/shortcuts/workflow/operations/aiDeepRead/collect.js +5 -2
  42. package/docs/jiuchuanhui.md +17 -5
  43. package/package.json +1 -1
  44. package/skills/weaver-e10-jiuchuanhui/SKILL.md +49 -90
  45. package/skills/weaver-e10-jiuchuanhui/references/cache.md +17 -13
  46. package/skills/weaver-e10-jiuchuanhui/references/customer.md +33 -5
  47. package/skills/weaver-e10-jiuchuanhui/references/discovery-config.md +3 -3
  48. package/skills/weaver-e10-jiuchuanhui/references/jiuchuanhui-entry.md +9 -7
  49. package/skills/weaver-e10-performance/SKILL.md +2 -2
  50. package/skills/weaver-e10-performance/agents/openai.yaml +4 -2
  51. package/skills/weaver-e10-performance/references/flow-assess.md +19 -6
  52. package/skills/weaver-e10-workflow/SKILL.md +1 -1
  53. package/skills/weaver-e10-workflow/references/workflow-deep-read.md +8 -3
@@ -6,7 +6,9 @@ import {
6
6
  } from "./chunk-HG6INLH6.js";
7
7
  import "./chunk-AJ62BGAW.js";
8
8
  import {
9
- reportPlatformError
9
+ reportPlatformError,
10
+ shouldReportPlatformError,
11
+ toPlatformError
10
12
  } from "./chunk-MD5CW4B6.js";
11
13
  import {
12
14
  CONTINUATION_TTL_MS,
@@ -32,7 +34,7 @@ import {
32
34
  import "./chunk-BUSC6UAE.js";
33
35
 
34
36
  // src/shortcuts/jiuchuanhui/index.ts
35
- import { readFile as readFile2 } from "node:fs/promises";
37
+ import { readFile as readFile3 } from "node:fs/promises";
36
38
 
37
39
  // src/shortcuts/jiuchuanhui/continuation.ts
38
40
  import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
@@ -244,6 +246,13 @@ function failureDetails(value, code, message) {
244
246
  response: boundedResponse(value)
245
247
  };
246
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
+ }
247
256
  function assertJiuchuanhuiPath(requestPath) {
248
257
  if (typeof requestPath !== "string" || !requestPath.startsWith("/") || requestPath.startsWith("//")) {
249
258
  throw jiuchuanhuiValidationError("path_invalid", "\u8BF7\u6C42\u8DEF\u5F84\u5FC5\u987B\u662F\u76F8\u5BF9\u7EDD\u5BF9\u8DEF\u5F84");
@@ -296,11 +305,11 @@ function createJiuchuanhuiHost(ctx, dependencies = {}) {
296
305
  fetch: dependencies.fetch
297
306
  });
298
307
  }
299
- async function request(request2) {
308
+ async function send(request2) {
300
309
  const {
301
310
  method,
302
311
  path,
303
- query,
312
+ query: query2,
304
313
  body,
305
314
  operation,
306
315
  timeoutMs = 3e4
@@ -314,7 +323,7 @@ function createJiuchuanhuiHost(ctx, dependencies = {}) {
314
323
  operation,
315
324
  method: resolvedMethod,
316
325
  path,
317
- query: omitEmptyQueryValues(query),
326
+ query: omitEmptyQueryValues(query2),
318
327
  body,
319
328
  timeoutMs
320
329
  });
@@ -324,20 +333,44 @@ function createJiuchuanhuiHost(ctx, dependencies = {}) {
324
333
  if (isE10SessionExpiredResponse(response)) {
325
334
  throw jiuchuanhuiAuthError("session_expired", E10_SESSION_EXPIRED_MESSAGE, { httpStatus: response.status });
326
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
+ }
327
359
  if (response.parseError) {
328
360
  if (response.status < 200 || response.status >= 300) {
329
361
  throw new JiuchuanhuiCliError("api", "http_error", `\u6CDB\u5FAE\u63A5\u53E3 HTTP ${response.status}`, {
330
362
  code: response.status,
331
- details: { status: response.status, response: boundedResponse(response.value) },
363
+ details: { status: response.status },
332
364
  exitCode: 1
333
365
  });
334
366
  }
335
367
  throw jiuchuanhuiNetworkError("protocol", `\u63A5\u53E3\u8FD4\u56DE\u4E0D\u662F\u5408\u6CD5 JSON\uFF08HTTP ${response.status}\uFF09`, { retryable: false });
336
368
  }
337
369
  if (response.status < 200 || response.status >= 300) {
370
+ const message = jiuchuanhuiBusinessMessage(response.value);
338
371
  throw new JiuchuanhuiCliError("api", "http_error", `\u6CDB\u5FAE\u63A5\u53E3 HTTP ${response.status}`, {
339
372
  code: response.status,
340
- details: { status: response.status, message: jiuchuanhuiBusinessMessage(response.value), response: boundedResponse(response.value) },
373
+ details: { status: response.status, ...failureDetails(response.value, response.status, message) },
341
374
  exitCode: 1
342
375
  });
343
376
  }
@@ -345,1097 +378,1237 @@ function createJiuchuanhuiHost(ctx, dependencies = {}) {
345
378
  const message = jiuchuanhuiBusinessMessage(response.value);
346
379
  throw new JiuchuanhuiCliError("api", "business_error", message, {
347
380
  code: businessCode(response.value),
348
- // message 一律原样(服务端 resultMsg),细节另开字段补充,不改写既有文案。
349
381
  details: failureDetails(response.value, businessCode(response.value), message),
350
382
  exitCode: 1
351
383
  });
352
384
  }
353
385
  return response.value;
354
386
  }
355
- return { request, getSession };
387
+ return { request, query, getSession };
356
388
  }
357
389
 
358
- // src/shortcuts/jiuchuanhui/manifest.ts
359
- var pageProps = {
360
- pageNo: { type: "integer", minimum: 1, default: 1 },
361
- pageSize: { type: "integer", minimum: 1, maximum: 200, default: 10 },
362
- count: { type: "boolean", description: "\u662F\u5426\u5E76\u884C\u8BF7\u6C42\u603B\u6570\u63A5\u53E3" }
363
- };
364
- var idProp = { type: "string", pattern: "^[1-9]\\d*$" };
365
- var formProp = {
366
- type: "object",
367
- additionalProperties: true,
368
- 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"
369
- };
370
- var esbWriteProps = (keys) => {
371
- const props = {};
372
- for (const key of keys) props[key] = { type: "string", description: `\u52A8\u4F5C\u6D41\u4E1A\u52A1\u53C2\u6570 ${key}` };
373
- 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"
374
436
  };
375
- var esbWriteSchema = (keys, required = keys) => ({
376
- type: "object",
377
- additionalProperties: false,
378
- properties: esbWriteProps(keys),
379
- required
380
- });
381
- function writePair(baseName, title, props, required = [], fixed = {}, withPrepare = true) {
382
- const list = [];
383
- if (withPrepare) {
384
- list.push({
385
- name: `${baseName}.prepare`,
386
- risk: "read-before-write",
387
- fixed: { ...fixed, stage: "prepare" },
388
- inputSchema: {
389
- type: "object",
390
- additionalProperties: false,
391
- properties: {
392
- mainTable: {
393
- type: "object",
394
- additionalProperties: false,
395
- properties: props,
396
- ...required.length ? { required } : {}
397
- }
398
- },
399
- required: ["mainTable"]
400
- }
401
- });
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);
402
485
  }
403
- list.push({
404
- name: `${baseName}.apply`,
405
- risk: "high-risk-write",
406
- fixed: { ...fixed, stage: "apply" },
407
- inputSchema: {
408
- type: "object",
409
- additionalProperties: false,
410
- properties: {
411
- continuation: { type: "string", minLength: 1 },
412
- confirm: { const: true }
413
- },
414
- 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;
415
494
  }
416
- });
417
- return list;
495
+ }
496
+ return Array.isArray(value?.datas) ? value.datas : void 0;
418
497
  }
419
- var OPERATION_SUMMARIES = {
420
- "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",
421
- "jiuchuanhui.app.discovery": "\u6309\u6807\u7B7E\u53D6\u4E5D\u6C1A\u6C47\u76F8\u5173 eBuilder \u5E94\u7528 ID \u5217\u8868",
422
- "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",
423
- "jiuchuanhui.field.options": "\u53D6\u8868\u5355\u67D0\u5B57\u6BB5\u7684\u9009\u9879\u5B57\u5178\uFF08id\u2194name\uFF09\uFF1B\u5165\u53C2 fieldName/objId/groupId",
424
- "jiuchuanhui.rest.cfg.detail": "\u6309 apid + id \u53D6 REST \u914D\u7F6E\u8BE6\u60C5\uFF08\u52A8\u4F5C\u6D41\u914D\u7F6E\u89E3\u6790\u7ED3\u679C\uFF09",
425
- "jiuchuanhui.config.id.by.pk": "\u6309\u4E3B\u8868\u4E0E\u6570\u636E\u4E3B\u952E\u53CD\u67E5\u914D\u7F6E ID\uFF08\u7ECF\u52A8\u4F5C\u6D41\uFF09",
426
- "jiuchuanhui.file.preview": "\u53D6\u9644\u4EF6\u9884\u89C8\u5730\u5740\uFF1B\u5165\u53C2 fileId/fieldId/appId",
427
- "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",
428
- "jiuchuanhui.customer.create.apply": "\u63D0\u4EA4\u65B0\u5EFA\u5BA2\u6237\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
429
- "jiuchuanhui.customer.get": "\u6309 id \u53D6\u5BA2\u6237\u8BE6\u60C5",
430
- "jiuchuanhui.customer.search": "\u5206\u9875\u67E5\u8BE2\u5BA2\u6237\u5217\u8868\uFF08\u652F\u6301\u6761\u4EF6\u8FC7\u6EE4\uFF09",
431
- "jiuchuanhui.customer.type.search": "\u5206\u9875\u67E5\u8BE2\u5BA2\u6237\u7C7B\u578B\u5B57\u5178",
432
- "jiuchuanhui.customer.status.search": "\u5206\u9875\u67E5\u8BE2\u5BA2\u6237\u72B6\u6001\u5B57\u5178",
433
- "jiuchuanhui.customer.industry.search": "\u5206\u9875\u67E5\u8BE2\u5BA2\u6237\u884C\u4E1A\u5B57\u5178",
434
- "jiuchuanhui.customer.open-sea.search": "\u5206\u9875\u67E5\u8BE2\u516C\u6D77\u5BA2\u6237\u5217\u8868",
435
- "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",
436
- "jiuchuanhui.customer.update.apply": "\u63D0\u4EA4\u4FEE\u6539\u5BA2\u6237\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
437
- "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",
438
- "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",
439
- "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",
440
- "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",
441
- "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",
442
- "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",
443
- "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",
444
- "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",
445
- "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",
446
- "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",
447
- "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",
448
- "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",
449
- "jiuchuanhui.contact.create.apply": "\u63D0\u4EA4\u65B0\u5EFA\u8054\u7CFB\u4EBA\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
450
- "jiuchuanhui.contact.get": "\u6309 id \u53D6\u8054\u7CFB\u4EBA\u8BE6\u60C5",
451
- "jiuchuanhui.contact.update.prepare": "\u51C6\u5907\u4FEE\u6539\u8054\u7CFB\u4EBA\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
452
- "jiuchuanhui.contact.update.apply": "\u63D0\u4EA4\u4FEE\u6539\u8054\u7CFB\u4EBA\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
453
- "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",
454
- "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",
455
- "jiuchuanhui.sale.create.apply": "\u63D0\u4EA4\u65B0\u5EFA\u5546\u673A\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
456
- "jiuchuanhui.sale.get": "\u6309 id \u53D6\u5546\u673A\u8BE6\u60C5",
457
- "jiuchuanhui.sale.search": "\u5206\u9875\u67E5\u8BE2\u5546\u673A\u5217\u8868\uFF08\u652F\u6301\u6761\u4EF6\u8FC7\u6EE4\uFF09",
458
- "jiuchuanhui.sale.update.prepare": "\u51C6\u5907\u4FEE\u6539\u5546\u673A\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
459
- "jiuchuanhui.sale.update.apply": "\u63D0\u4EA4\u4FEE\u6539\u5546\u673A\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
460
- "jiuchuanhui.sale.stage.search": "\u5206\u9875\u67E5\u8BE2\u9500\u552E\u9636\u6BB5\u5B57\u5178",
461
- "jiuchuanhui.sale.process.search": "\u5206\u9875\u67E5\u8BE2\u5546\u673A\u7684\u6D41\u7A0B/\u9636\u6BB5\u63A8\u8FDB\u8BB0\u5F55",
462
- "jiuchuanhui.sale.lose-reason.search": "\u5206\u9875\u67E5\u8BE2\u4E22\u5355\u539F\u56E0\u5B57\u5178",
463
- "jiuchuanhui.rival.search": "\u5206\u9875\u67E5\u8BE2\u7ADE\u4E89\u5BF9\u624B\u5217\u8868",
464
- "jiuchuanhui.sale.win.prepare": "\u51C6\u5907\u6807\u8BB0\u5546\u673A\u8D62\u5355\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
465
- "jiuchuanhui.sale.win.apply": "\u63D0\u4EA4\u6807\u8BB0\u5546\u673A\u8D62\u5355\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
466
- "jiuchuanhui.sale.lose.prepare": "\u51C6\u5907\u6807\u8BB0\u5546\u673A\u8F93\u5355\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
467
- "jiuchuanhui.sale.lose.apply": "\u63D0\u4EA4\u6807\u8BB0\u5546\u673A\u8F93\u5355\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
468
- "jiuchuanhui.sale.invalid.prepare": "\u51C6\u5907\u4F5C\u5E9F\u5546\u673A\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
469
- "jiuchuanhui.sale.invalid.apply": "\u63D0\u4EA4\u4F5C\u5E9F\u5546\u673A\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
470
- "jiuchuanhui.sale.pause.prepare": "\u51C6\u5907\u6682\u505C\u5546\u673A\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
471
- "jiuchuanhui.sale.pause.apply": "\u63D0\u4EA4\u6682\u505C\u5546\u673A\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
472
- "jiuchuanhui.sale.restart.prepare": "\u51C6\u5907\u91CD\u542F\u5546\u673A\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
473
- "jiuchuanhui.sale.restart.apply": "\u63D0\u4EA4\u91CD\u542F\u5546\u673A\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
474
- "jiuchuanhui.sale.manager-change.prepare": "\u51C6\u5907\u53D8\u66F4\u5546\u673A\u8D1F\u8D23\u4EBA\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
475
- "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",
476
- "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",
477
- "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",
478
- "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",
479
- "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",
480
- "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",
481
- "jiuchuanhui.clue.create.apply": "\u63D0\u4EA4\u65B0\u5EFA\u7EBF\u7D22\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
482
- "jiuchuanhui.clue.get": "\u6309 id \u53D6\u7EBF\u7D22\u8BE6\u60C5",
483
- "jiuchuanhui.clue.search": "\u5206\u9875\u67E5\u8BE2\u7EBF\u7D22\u5217\u8868\uFF08\u652F\u6301\u6761\u4EF6\u8FC7\u6EE4\uFF09",
484
- "jiuchuanhui.clue.pool.search": "\u5206\u9875\u67E5\u8BE2\u7EBF\u7D22\u6C60\u5217\u8868",
485
- "jiuchuanhui.clue.update.prepare": "\u51C6\u5907\u4FEE\u6539\u7EBF\u7D22\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
486
- "jiuchuanhui.clue.update.apply": "\u63D0\u4EA4\u4FEE\u6539\u7EBF\u7D22\uFF08\u843D\u5E93\u524D\u9700\u786E\u8BA4\uFF09\uFF1B\u9700 continuation + confirm",
487
- "jiuchuanhui.clue.status-change.prepare": "\u51C6\u5907\u53D8\u66F4\u7EBF\u7D22\u72B6\u6001\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
488
- "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",
489
- "jiuchuanhui.clue.to-customer.prepare": "\u51C6\u5907\u628A\u7EBF\u7D22\u8F6C\u4E3A\u5BA2\u6237\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
490
- "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",
491
- "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",
492
- "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",
493
- "jiuchuanhui.contact-plan.create.prepare": "\u51C6\u5907\u65B0\u5EFA\u8054\u7CFB\u8BA1\u5212\uFF08\u53EA\u51FA\u9884\u89C8\uFF0C\u4E0D\u5199\u5165\uFF09",
494
- "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",
495
- "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",
496
- "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",
497
- "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",
498
- "jiuchuanhui.contact-records.by-person-time.list": "\u6309\u4EBA\u5458\u4E0E\u65F6\u95F4\u8303\u56F4\u67E5\u8054\u7CFB\u8BB0\u5F55",
499
- "jiuchuanhui.entity.id.by-name": "\u6309\u540D\u79F0\u89E3\u6790\u5B9E\u4F53 ID\uFF08\u91CD\u540D\u65F6\u4F1A\u7ED9\u51FA\u5019\u9009\uFF09",
500
- "jiuchuanhui.user.id.by-name": "\u6309\u59D3\u540D\u89E3\u6790\u7528\u6237 ID\uFF08\u91CD\u540D\u65F6\u4F1A\u7ED9\u51FA\u5019\u9009\uFF09",
501
- "jiuchuanhui.user.current-profile": "\u53D6\u5F53\u524D\u767B\u5F55\u4EBA\u7684\u753B\u50CF\u4FE1\u606F\uFF08\u90E8\u95E8/\u5C97\u4F4D/\u4E0A\u7EA7\uFF09",
502
- "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",
503
- "jiuchuanhui.company.business-profile.query": "\u67E5\u5BA2\u6237\u7684\u5DE5\u5546\u753B\u50CF\u4FE1\u606F",
504
- "jiuchuanhui.field.info.by-ids": "\u6309 ID \u6279\u91CF\u53D6\u5B57\u6BB5\u4FE1\u606F\uFF08\u540D\u79F0/\u7C7B\u578B\uFF09",
505
- "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",
506
- "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"
507
- };
508
- function withSummaries(operations) {
509
- return operations.map((item) => ({
510
- ...item,
511
- summary: item.summary || OPERATION_SUMMARIES[item.name] || ""
512
- }));
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;
513
509
  }
514
- var jiuchuanhuiOperations = [
515
- // ==================== 发现与配置 ====================
516
- {
517
- name: "jiuchuanhui.cache.init",
518
- risk: "local-file-write",
519
- fixed: { path: "local:cache", purpose: "\u4E5D\u6C1A\u6C47\u914D\u7F6E\u7F13\u5B58\u521D\u59CB\u5316/\u5237\u65B0" },
520
- inputSchema: {
521
- type: "object",
522
- additionalProperties: false,
523
- properties: {
524
- dryRun: { type: "boolean", description: "\u53EA\u62C9\u53D6\u4E0D\u5199\u5165\uFF08\u9884\u89C8\uFF09" },
525
- verbose: { type: "boolean", description: "\u8FD4\u56DE\u66F4\u591A\u6B65\u9AA4\u660E\u7EC6" }
526
- }
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");
527
520
  }
528
- },
529
- {
530
- name: "jiuchuanhui.app.discovery",
531
- risk: "read",
532
- fixed: { path: "/api/bs/ebuilder/app/tags/getAppIds", method: "GET" },
533
- inputSchema: {
534
- type: "object",
535
- additionalProperties: false,
536
- properties: {
537
- 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" }
538
- },
539
- required: ["tag"]
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 {
529
+ }
540
530
  }
541
- },
542
- {
543
- name: "jiuchuanhui.form.discovery",
544
- risk: "read",
545
- fixed: { path: "/api/ebuilder/form/obj/getObjsByTag", method: "GET" },
546
- inputSchema: {
547
- type: "object",
548
- additionalProperties: false,
549
- properties: {
550
- tag: { type: "string", description: "\u8868\u5355 tag\uFF0C\u5982 uf_jch_customer" },
551
- appId: { type: "string" }
552
- },
553
- required: ["tag", "appId"]
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);
554
553
  }
555
- },
556
- {
557
- name: "jiuchuanhui.field.options",
558
- risk: "read",
559
- fixed: { path: "/api/ebuilder/common/ds/options", method: "GET", sourceType: "FORM", optionLevel: 1 },
560
- inputSchema: {
561
- type: "object",
562
- additionalProperties: false,
563
- properties: {
564
- fieldName: { type: "string", description: "\u5B57\u6BB5\u5143\u6570\u636EID\uFF08fieldid\uFF09\uFF0C\u4E0D\u662F data_key \u540D\u79F0" },
565
- sourceType: { type: "string", default: "FORM" },
566
- objId: { type: "string", description: "\u8868\u5355\u5BF9\u8C61ID\uFF0C\u53EF\u7701\u7565\u81EA\u52A8\u53D1\u73B0" },
567
- 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" }
568
- },
569
- 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 {
570
567
  }
571
- },
572
- {
573
- name: "jiuchuanhui.rest.cfg.detail",
574
- risk: "read",
575
- fixed: { path: "/api/bs/ebuilder/form/formdata/getRestCfgById", method: "GET" },
576
- inputSchema: {
577
- type: "object",
578
- additionalProperties: false,
579
- properties: {
580
- apid: { type: "string", description: "\u5E94\u7528 ID" },
581
- id: { type: "string", description: "\u63A5\u53E3\u914D\u7F6E ID (cfgId)" }
582
- },
583
- 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);
584
577
  }
585
- },
586
- {
587
- name: "jiuchuanhui.config.id.by.pk",
588
- risk: "read",
589
- fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "4F6E1A9702864666803CCA6B77B86227" },
590
- inputSchema: {
591
- type: "object",
592
- additionalProperties: false,
593
- properties: {
594
- mainTable: {
595
- type: "object",
596
- additionalProperties: false,
597
- properties: { interface_pk: { type: "string" } },
598
- 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 {
599
610
  }
600
- },
601
- required: ["mainTable"]
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 };
602
633
  }
603
- },
604
- {
605
- name: "jiuchuanhui.file.preview",
606
- risk: "read",
607
- fixed: { path: "/api/file/preview", method: "GET", module: "ebuilderform", authModule: "ebuilderform", source: "form" },
608
- inputSchema: {
609
- type: "object",
610
- additionalProperties: false,
611
- properties: {
612
- fileId: { type: "string" },
613
- fieldId: { type: "string" },
614
- appId: { type: "string" },
615
- customParam: { type: ["string", "object"] }
616
- },
617
- required: ["fileId"]
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);
618
666
  }
619
- },
620
- // ==================== 客户 ====================
621
- ...writePair("jiuchuanhui.customer.create", "\u5BA2\u6237\u521B\u5EFA", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/saveFormData/customer_create_api" }),
622
- {
623
- name: "jiuchuanhui.customer.get",
624
- risk: "read",
625
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataByPk/customer_get_api" },
626
- inputSchema: { type: "object", additionalProperties: false, properties: { id: idProp }, required: ["id"] }
627
- },
628
- {
629
- name: "jiuchuanhui.customer.search",
630
- risk: "read",
631
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_search_api", countPath: "/api/ebuilder/form/formdata/v2/getFormDataCount/ebcustomer_search_count_api" },
632
- inputSchema: {
633
- type: "object",
634
- additionalProperties: true,
635
- 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",
636
- properties: pageProps
637
- }
638
- },
639
- {
640
- name: "jiuchuanhui.customer.type.search",
641
- risk: "read",
642
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_type_search_api" },
643
- inputSchema: { type: "object", additionalProperties: false, properties: pageProps }
644
- },
645
- {
646
- name: "jiuchuanhui.customer.status.search",
647
- risk: "read",
648
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_status_search_api" },
649
- inputSchema: { type: "object", additionalProperties: false, properties: pageProps }
650
- },
651
- {
652
- name: "jiuchuanhui.customer.industry.search",
653
- risk: "read",
654
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_industry_search_api" },
655
- inputSchema: { type: "object", additionalProperties: false, properties: pageProps }
656
- },
657
- {
658
- name: "jiuchuanhui.customer.open-sea.search",
659
- risk: "read",
660
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/customer_open_sea_search_api" },
661
- inputSchema: { type: "object", additionalProperties: true, properties: pageProps }
662
- },
663
- ...writePair("jiuchuanhui.customer.update", "\u5BA2\u6237\u4FEE\u6539", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/updateFormData/customer_update_api" }),
664
- ...writePair("jiuchuanhui.customer.transfer", "\u5BA2\u6237\u8F6C\u79FB", esbWriteProps(["customerId", "employee_MappingId", "employeeName"]), ["customerId"], { uniqueIndent: "1E44ED7DA9EB46329818E682C2914928" }),
665
- ...writePair("jiuchuanhui.customer.open-sea.release", "\u5BA2\u6237\u91CA\u653E\u516C\u6D77", esbWriteProps(["customerId", "openSeaId"]), ["customerId", "openSeaId"], { uniqueIndent: "0E29AD0E708D4964B071D293288B92D7" }),
666
- ...writePair("jiuchuanhui.customer.open-sea.claim", "\u9886\u53D6\u516C\u6D77\u5BA2\u6237", esbWriteProps(["customer_id"]), ["customer_id"], { uniqueIndent: "D587CDC892FE41118DD073475C01A2CE" }),
667
- {
668
- name: "jiuchuanhui.customer.duplicate.check",
669
- risk: "read",
670
- fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "D5D0A1C30E7B404B842987C0AD3B749D" },
671
- inputSchema: {
672
- type: "object",
673
- additionalProperties: false,
674
- properties: { mainTable: esbWriteSchema(["name", "simpleName"], ["name", "simpleName"]) },
675
- required: ["mainTable"]
676
- }
677
- },
678
- ...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" }),
679
- ...writePair("jiuchuanhui.customer.contact-record.batch", "\u6279\u91CF\u6DFB\u52A0\u5BA2\u6237\u8054\u7CFB\u8BB0\u5F55", esbWriteProps(["entityList", "content"]), ["entityList", "content"], { uniqueIndent: "D0F315619FE34C669AE738ED68329FAB" }),
680
- // ==================== 联系人 ====================
681
- ...writePair("jiuchuanhui.contact.create", "\u8054\u7CFB\u4EBA\u521B\u5EFA", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/saveFormData/contact_create_api" }),
682
- {
683
- name: "jiuchuanhui.contact.get",
684
- risk: "read",
685
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataByPk/contact_get_api" },
686
- inputSchema: { type: "object", additionalProperties: false, properties: { id: idProp }, required: ["id"] }
687
- },
688
- ...writePair("jiuchuanhui.contact.update", "\u8054\u7CFB\u4EBA\u4FEE\u6539", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/updateFormData/contact_update_api" }),
689
- {
690
- name: "jiuchuanhui.contact.by-entity.search",
691
- risk: "read",
692
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcontact_search_by_entity_api" },
693
- inputSchema: {
694
- type: "object",
695
- additionalProperties: true,
696
- properties: { ...pageProps, customerId: { type: "string" }, saleChanceId: { type: "string" } }
697
- }
698
- },
699
- // ==================== 商机 ====================
700
- ...writePair("jiuchuanhui.sale.create", "\u5546\u673A\u521B\u5EFA", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/saveFormData/sale_create_api" }),
701
- {
702
- name: "jiuchuanhui.sale.get",
703
- risk: "read",
704
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataByPk/sale_get_api" },
705
- inputSchema: { type: "object", additionalProperties: false, properties: { id: idProp }, required: ["id"] }
706
- },
707
- {
708
- name: "jiuchuanhui.sale.search",
709
- risk: "read",
710
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebsale_search_api", countPath: "/api/ebuilder/form/formdata/v2/getFormDataCount/ebsale_search_count_api" },
711
- inputSchema: { type: "object", additionalProperties: true, properties: pageProps }
712
- },
713
- ...writePair("jiuchuanhui.sale.update", "\u5546\u673A\u4FEE\u6539", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/updateFormData/sale_update_api" }),
714
- {
715
- name: "jiuchuanhui.sale.stage.search",
716
- risk: "read",
717
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/sale_stage_search_api" },
718
- inputSchema: { type: "object", additionalProperties: false, properties: pageProps }
719
- },
720
- {
721
- name: "jiuchuanhui.sale.process.search",
722
- risk: "read",
723
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/sale_process_sear_api" },
724
- inputSchema: { type: "object", additionalProperties: false, properties: pageProps }
725
- },
726
- {
727
- name: "jiuchuanhui.sale.lose-reason.search",
728
- risk: "read",
729
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/sale_lose_reason" },
730
- inputSchema: { type: "object", additionalProperties: false, properties: pageProps }
731
- },
732
- {
733
- name: "jiuchuanhui.rival.search",
734
- risk: "read",
735
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebrival_search_api" },
736
- inputSchema: { type: "object", additionalProperties: false, properties: pageProps }
737
- },
738
- ...writePair("jiuchuanhui.sale.win", "\u5546\u673A\u8D62\u5355", esbWriteProps(["saleId"]), ["saleId"], { uniqueIndent: "3B23E782E5084F18A904E895BBD61A96" }),
739
- ...writePair("jiuchuanhui.sale.lose", "\u5546\u673A\u8F93\u5355", esbWriteProps(["saleid", "money", "reasonids", "rivals", "desc"]), ["saleid"], { uniqueIndent: "DE35D926F82F49FDBA26B48B0CA1CB53" }),
740
- ...writePair("jiuchuanhui.sale.invalid", "\u5546\u673A\u65E0\u6548", esbWriteProps(["saleId"]), ["saleId"], { uniqueIndent: "4D88AB8677D84BAC90B63137E7FA1FF9" }),
741
- ...writePair("jiuchuanhui.sale.pause", "\u5546\u673A\u6682\u505C", esbWriteProps(["saleId", "pauseReason", "restartDate"]), ["saleId", "pauseReason"], { uniqueIndent: "859C73403DCC4F01B02329571BDBD9F3" }),
742
- ...writePair("jiuchuanhui.sale.restart", "\u5546\u673A\u91CD\u542F", esbWriteProps(["saleChanceId"]), ["saleChanceId"], { uniqueIndent: "F3004CDCA8A548B5A0DACD3CDE62387A" }),
743
- ...writePair("jiuchuanhui.sale.manager-change", "\u5546\u673A\u8F6C\u79FB/\u8D1F\u8D23\u4EBA\u53D8\u66F4", esbWriteProps(["saleChanceId", "managerId"]), ["saleChanceId", "managerId"], { uniqueIndent: "595F9C6F1C4248929B83086F71363BA7" }),
744
- ...writePair("jiuchuanhui.sale.link-contacts", "\u5546\u673A\u5173\u8054\u8054\u7CFB\u4EBA", esbWriteProps(["salechanceId", "contactIds"]), ["salechanceId", "contactIds"], { uniqueIndent: "1114A713A62F4CA9899CC24ED5902D93" }),
745
- ...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" }),
746
- // ==================== 线索 ====================
747
- ...writePair("jiuchuanhui.clue.create", "\u7EBF\u7D22\u521B\u5EFA", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/saveFormData/ebclue_ai_create_api" }),
748
- {
749
- name: "jiuchuanhui.clue.get",
750
- risk: "read",
751
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataByPk/ebcluepool_ai_get_api" },
752
- inputSchema: { type: "object", additionalProperties: false, properties: { id: idProp }, required: ["id"] }
753
- },
754
- {
755
- name: "jiuchuanhui.clue.search",
756
- risk: "read",
757
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebclue_ai_search_api", countPath: "/api/ebuilder/form/formdata/v2/getFormDataCount/ebclue_ai_search_count_api" },
758
- inputSchema: { type: "object", additionalProperties: true, properties: pageProps }
759
- },
760
- {
761
- name: "jiuchuanhui.clue.pool.search",
762
- risk: "read",
763
- fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcluepool_ai_search_api" },
764
- inputSchema: { type: "object", additionalProperties: true, properties: pageProps }
765
- },
766
- ...writePair("jiuchuanhui.clue.update", "\u7EBF\u7D22\u4FEE\u6539", { form: formProp }, ["form"], { path: "/api/ebuilder/form/formdata/v2/updateFormData/ebclue_ai_update_api" }),
767
- ...writePair("jiuchuanhui.clue.status-change", "\u7EBF\u7D22\u72B6\u6001\u53D8\u66F4", esbWriteProps(["clueid", "type", "newmanager", "desc"]), ["clueid", "type"], { uniqueIndent: "257CC8DE42234F9191439B229839B8A7" }),
768
- ...writePair("jiuchuanhui.clue.to-customer", "\u7EBF\u7D22\u8F6C\u5DF2\u6709\u5BA2\u6237", esbWriteProps(["clueId", "customerId"]), ["clueId", "customerId"], { uniqueIndent: "00914C6415EB455DB7FCCC32DBE6E0C3" }),
769
- ...writePair("jiuchuanhui.clue.contact-record.create", "\u65B0\u5EFA\u7EBF\u7D22\u8DDF\u8FDB\u8BB0\u5F55", esbWriteProps(["clueId", "content", "clueStatus_MappingId"]), ["clueId", "content"], { uniqueIndent: "B3DD120601344320A2B50A042B450681" }),
770
- // ==================== 联系计划 ====================
771
- ...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" }),
772
- ...writePair("jiuchuanhui.contact-plan.complete", "\u5B8C\u6210\u8054\u7CFB\u8BA1\u5212", esbWriteProps(["planId"]), ["planId"], { uniqueIndent: "2595D3556CFC414F85B1A4A8D806EFE5" }),
773
- // ==================== 联系记录 ====================
774
- {
775
- name: "jiuchuanhui.entity.contact-records.list",
776
- risk: "read",
777
- fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "364A9713D10C4997AF6EDCAA5296968E" },
778
- inputSchema: {
779
- type: "object",
780
- additionalProperties: false,
781
- properties: {
782
- mainTable: {
783
- type: "object",
784
- additionalProperties: false,
785
- properties: {
786
- moduleType: { type: "string", description: "\u4E8B\u9879\u6A21\u5757\u6807\u8BC6\uFF1Acustomer=\u5BA2\u6237\u3001clue=\u7EBF\u7D22\u3001saleChance=\u5546\u673A" },
787
- entityId: { type: "string" }
788
- },
789
- required: ["moduleType", "entityId"]
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 {
790
699
  }
791
- },
792
- required: ["mainTable"]
793
- }
794
- },
795
- {
796
- name: "jiuchuanhui.contact-records.by-person-time.list",
797
- risk: "read",
798
- fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "D01DD00978524525AD8728BE1BF9FE79" },
799
- inputSchema: {
800
- type: "object",
801
- additionalProperties: false,
802
- properties: { mainTable: esbWriteSchema(["employeeId", "startData", "endData"]) },
803
- required: ["mainTable"]
804
- }
805
- },
806
- // ==================== 通用辅助 ====================
807
- {
808
- name: "jiuchuanhui.entity.id.by-name",
809
- risk: "read",
810
- fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "7EC1639D5AC24B4DBCEE8D2CB85D4025" },
811
- inputSchema: {
812
- type: "object",
813
- additionalProperties: false,
814
- properties: { mainTable: esbWriteSchema(["moduleType", "name"]) },
815
- required: ["mainTable"]
816
- }
817
- },
818
- {
819
- name: "jiuchuanhui.user.id.by-name",
820
- risk: "read",
821
- fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "911C17207E2C4BD29379B5A4001B246E" },
822
- inputSchema: {
823
- type: "object",
824
- additionalProperties: false,
825
- properties: { mainTable: esbWriteSchema(["employeeName"]) },
826
- required: ["mainTable"]
827
- }
828
- },
829
- {
830
- name: "jiuchuanhui.user.current-profile",
831
- risk: "read",
832
- fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "B8F7597190FF419FB9127D6C8272C4FE" },
833
- inputSchema: { type: "object", additionalProperties: false, properties: {} }
834
- },
835
- {
836
- name: "jiuchuanhui.entity.permission.judge",
837
- risk: "read",
838
- fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "6D369F0A84764051A5D7B5AA1245F49A" },
839
- inputSchema: {
840
- type: "object",
841
- additionalProperties: false,
842
- properties: { mainTable: esbWriteSchema(["moduleType", "entityId", "opType"]) },
843
- required: ["mainTable"]
844
- }
845
- },
846
- {
847
- name: "jiuchuanhui.company.business-profile.query",
848
- risk: "read",
849
- fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "BAB4DBE204214BB395BA161620A4A1CD" },
850
- inputSchema: {
851
- type: "object",
852
- additionalProperties: false,
853
- properties: { mainTable: esbWriteSchema(["companyName"]) },
854
- required: ["mainTable"]
855
- }
856
- },
857
- {
858
- name: "jiuchuanhui.field.info.by-ids",
859
- risk: "read",
860
- fixed: { path: "/api/esb/server/event/triggerActionFlow", uniqueIndent: "10351A4DC8D4454A9F1957FBE647CD9F" },
861
- inputSchema: {
862
- type: "object",
863
- additionalProperties: false,
864
- properties: { mainTable: esbWriteSchema(["fieldids"]) },
865
- required: ["mainTable"]
700
+ }
866
701
  }
867
- },
868
- {
869
- name: "jiuchuanhui.browser-option.search",
870
- risk: "read",
871
- fixed: { path: "/api/bcw/common/browser/complete/{customBrowserType}", method: "POST" },
872
- inputSchema: {
873
- type: "object",
874
- additionalProperties: false,
875
- properties: {
876
- pathParams: {
877
- type: "object",
878
- additionalProperties: false,
879
- properties: { customBrowserType: { type: "string" } },
880
- required: ["customBrowserType"]
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
+ }
733
+ }
734
+ searchPerPk[pk] = { cfgId, searchParams: params };
735
+ } catch {
736
+ }
737
+ }
738
+ for (const [pk, entry] of Object.entries(searchPerPk)) {
739
+ if (perPk[pk]) perPk[pk] = { ...perPk[pk], ...entry };
740
+ else perPk[pk] = entry;
741
+ }
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
881
751
  },
882
- params: {
883
- type: "object",
884
- additionalProperties: true,
885
- properties: { searchValue: { type: "string" } }
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;
886
757
  }
887
- },
888
- required: ["pathParams"]
758
+ }
889
759
  }
890
- },
891
- {
892
- name: "jiuchuanhui.get-rest-cfg-detail",
893
- risk: "read",
894
- fixed: { path: "/api/bs/ebuilder/form/formdata/getRestCfgById", method: "GET" },
895
- inputSchema: {
896
- type: "object",
897
- additionalProperties: false,
898
- properties: {
899
- apid: { type: "string" },
900
- id: { type: "string" }
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}`];
765
+ }
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
901
775
  },
902
- required: ["apid", "id"]
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`);
903
784
  }
904
- }
905
- ];
906
- var jiuchuanhuiManifest = {
907
- schemaVersion: 1,
908
- name: "jiuchuanhui",
909
- 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",
910
- version: "0.1.0",
911
- host: "e10-jiuchuanhui",
912
- status: "builtin",
913
- sourceSkill: "weaver-e10-jiuchuanhui",
914
- operations: withSummaries(jiuchuanhuiOperations),
915
- withheldOperations: [
916
- {
917
- name: "jiuchuanhui.sale.stage-advance",
918
- 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"
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");
919
792
  }
920
- ]
793
+ if (verbose) {
794
+ summary.warnings.push(`${JSON.stringify({ step1: "discovery", step2: "cfgId", step3: "cfg.detail", step4: "ebuilder", step5: "options", step6: "searchParams", step7: "region" })}`);
795
+ }
796
+ return {
797
+ status: "COMPLETE",
798
+ data: { ...summary, written: true }
799
+ };
800
+ }
921
801
  };
922
802
 
923
- // src/shortcuts/jiuchuanhui/cache.ts
924
- import { existsSync as existsSync2, mkdirSync, readFileSync, writeFileSync } from "node:fs";
925
- import { homedir as homedir2 } from "node:os";
926
- import { join } from "node:path";
927
- var APP_TAG = "jch-crm-project";
928
- var MIN_VERSION = "1.5.11";
929
- var MODULE_TAGS = [
930
- "uf_jch_customer",
931
- "uf_jch_sale",
932
- "uf_jch_clue",
933
- "uf_jch_contact",
934
- "uf_jch_customer_open_sea",
935
- "uf_jch_remind",
936
- "uf_jch_rival",
937
- "uf_jch_sale_process",
938
- "uf_jch_sale_stage",
939
- "uf_jch_clue_pool",
940
- "uf_jch_lose_reason",
941
- "uf_jch_customer_cmt",
942
- "uf_jch_sale_cmt"
943
- ];
944
- var CREATE_PKS = ["customer_create_api", "sale_create_api", "ebclue_ai_create_api", "contact_create_api", "ebcontact_plan_create_api"];
945
- var SEARCH_PKS = ["ebcustomer_search_api", "ebsale_search_api", "ebclue_ai_search_api"];
946
- var UPDATE_PKS = ["customer_update_api", "sale_update_api", "ebclue_ai_update_api", "contact_update_api"];
947
- var ALL_PKS = [...CREATE_PKS, ...SEARCH_PKS, ...UPDATE_PKS];
948
- var PK_TO_TAG = {
949
- customer_create_api: "uf_jch_customer",
950
- sale_create_api: "uf_jch_sale",
951
- ebclue_ai_create_api: "uf_jch_clue",
952
- contact_create_api: "uf_jch_contact",
953
- ebcontact_plan_create_api: "uf_jch_remind",
954
- ebcustomer_search_api: "uf_jch_customer",
955
- ebsale_search_api: "uf_jch_sale",
956
- ebclue_ai_search_api: "uf_jch_clue",
957
- customer_update_api: "uf_jch_customer",
958
- sale_update_api: "uf_jch_sale",
959
- ebclue_ai_update_api: "uf_jch_clue",
960
- contact_update_api: "uf_jch_contact"
961
- };
962
- var DETAIL_KEEP_KEYS = ["id", "interfacePk", "interfaceName", "datasNumber", "datasSize", "mainFields", "detailFields", "interfaceType", "relevanceForm"];
963
- var FIELD_KEEP_KEYS = ["fieldid", "isRequired", "isInput", "data_key", "title", "component_type"];
964
- var OPT_COMP = ["Select", "RadioBox", "CheckBox"];
965
- var EBUILDER_QUERIES = [
966
- { key: "customer_open_sea", path: "/api/ebuilder/form/formdata/v2/getFormDataList/customer_open_sea_search_api", nameFields: ["open_sea_name", "name"] },
967
- { key: "sale_stage", path: "/api/ebuilder/form/formdata/v2/getFormDataList/sale_stage_search_api", nameFields: ["stage_name", "name"] },
968
- { key: "sale_process", path: "/api/ebuilder/form/formdata/v2/getFormDataList/sale_process_sear_api", nameFields: ["process_name", "name"] },
969
- { key: "clue_pool", path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcluepool_ai_search_api", nameFields: ["clue_pool_name", "name"] },
970
- { key: "sale_lose_reason", path: "/api/ebuilder/form/formdata/v2/getFormDataList/sale_lose_reason", nameFields: ["reason_name", "name"] },
971
- { key: "customer_industry", path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_industry_search_api", nameFields: ["industry_name", "name"] },
972
- { key: "customer_type", path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_type_search_api", nameFields: ["type_name", "name"] },
973
- { key: "customer_status", path: "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_status_search_api", nameFields: ["state_name", "name"] }
974
- ];
975
- var REGION_CITIES = [
976
- "\u5317\u4EAC\u5E02",
977
- "\u4E0A\u6D77\u5E02",
978
- "\u5929\u6D25\u5E02",
979
- "\u91CD\u5E86\u5E02",
980
- "\u6210\u90FD\u5E02",
981
- "\u5E7F\u5DDE\u5E02",
982
- "\u6DF1\u5733\u5E02",
983
- "\u4E1C\u839E\u5E02",
984
- "\u676D\u5DDE\u5E02",
985
- "\u5357\u4EAC\u5E02",
986
- "\u82CF\u5DDE\u5E02",
987
- "\u6B66\u6C49\u5E02",
988
- "\u957F\u6C99\u5E02",
989
- "\u897F\u5B89\u5E02",
990
- "\u90D1\u5DDE\u5E02",
991
- "\u6D4E\u5357\u5E02",
992
- "\u9752\u5C9B\u5E02",
993
- "\u53A6\u95E8\u5E02",
994
- "\u798F\u5DDE\u5E02",
995
- "\u5408\u80A5\u5E02",
996
- "\u6C88\u9633\u5E02",
997
- "\u5927\u8FDE\u5E02"
998
- ];
999
- function pickKeys(obj, keys) {
1000
- const out = {};
1001
- for (const k of keys) if (obj?.[k] !== void 0) out[k] = obj[k];
1002
- return out;
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}`);
841
+ }
842
+ assertNoForbiddenKeys(child, `${location}.${key}`);
843
+ }
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 }
883
+ }
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 [];
1003
904
  }
1004
- var isInputOne = (f) => String(f?.isInput) === "1";
1005
- function semverGte(a, b) {
1006
- const pa = String(a || "").split(".").map((x) => parseInt(x, 10) || 0);
1007
- const pb = b.split(".").map((x) => parseInt(x, 10) || 0);
1008
- for (let i = 0; i < 3; i++) {
1009
- if ((pa[i] || 0) !== (pb[i] || 0)) return (pa[i] || 0) > (pb[i] || 0);
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
+ }
918
+
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: "" }
924
+ };
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);
1010
935
  }
1011
- return true;
1012
936
  }
1013
- function successCheck(value) {
1014
- if (!value || typeof value !== "object") return false;
1015
- if (value.resultCode !== void 0 && value.resultCode !== null) return Number(value.resultCode) === 200;
1016
- if (value.datajson && typeof value.datajson === "object") {
1017
- const status = value.datajson.status;
1018
- if (status === "true" || status === true) return true;
1019
- if (status === "false" || status === false) return false;
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 [];
1020
946
  }
1021
- const code = value.code ?? value.res_base?.ret;
1022
- if (code !== void 0 && code !== null) return Number(code) === 0 || Number(code) === 200;
1023
- return typeof value.success === "boolean" ? value.success : false;
1024
947
  }
1025
- var CacheInitOperation = class {
1026
- name = "jiuchuanhui.cache.init";
1027
- async execute(input, { host }) {
1028
- const dryRun = input.dryRun === true;
1029
- const verbose = input.verbose === true;
1030
- const session = await host.getSession();
1031
- const tenantKey = session.tenantKey || "";
1032
- const userId = session.userId || "";
1033
- if (!tenantKey || !userId) {
1034
- 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");
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
+ });
953
+ }
954
+ return ids.values().next().value;
955
+ }
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");
1035
972
  }
1036
- const baseDir = join(process.env.WEAVER_E10_JIUCHUANHUI_HOME || join(homedir2(), ".weaver-e10-jiuchuanhui"), tenantKey, String(userId));
1037
- const mainFile = join(baseDir, "weaver-e10-jiuchuanhui.json");
1038
- const cfgDir = join(baseDir, "config");
1039
- let old = {};
1040
- if (existsSync2(mainFile)) {
1041
- try {
1042
- old = JSON.parse(readFileSync(mainFile, "utf-8"));
1043
- } 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"]
1044
1065
  }
1045
- }
1046
- const discovery = {};
1047
- const appResp = await host.request({
1048
- method: "GET",
1049
- path: "/api/bs/ebuilder/app/tags/getAppIds",
1050
- query: { tag: APP_TAG },
1051
- operation: this.name
1052
1066
  });
1053
- if (!successCheck(appResp)) throw jiuchuanhuiValidationError("init_failed", "app.discovery \u672A\u6210\u529F\uFF0C\u65E0\u6CD5\u521D\u59CB\u5316\u7F13\u5B58");
1054
- const rawApp = appResp?.data ?? appResp?.datajson?.datas;
1055
- const appId = Array.isArray(rawApp) && rawApp[0] ? String(rawApp[0]) : null;
1056
- if (!appId) throw jiuchuanhuiValidationError("init_failed", "\u6B65\u9AA4 1 \u672A\u53D6\u5F97 appId\uFF0C\u8BF7\u68C0\u67E5 E10 \u767B\u5F55\u6001");
1057
- discovery[`appId:${APP_TAG}`] = appId;
1058
- for (const tag of MODULE_TAGS) {
1059
- const resp = await host.request({
1060
- method: "GET",
1061
- path: "/api/ebuilder/form/obj/getObjsByTag",
1062
- query: { tag, appId },
1063
- operation: this.name
1064
- });
1065
- const list = Array.isArray(resp?.data) ? resp.data : resp?.datajson?.datas ?? [];
1066
- const hit = list.find((o) => o?.formId && String(o.formId) !== "0") ?? list?.[0];
1067
- 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"]
1068
1080
  }
1069
- try {
1070
- const spResp = await host.request({
1071
- method: "GET",
1072
- path: "/api/installer/public/querySpAppVersionInfo",
1073
- query: { appId },
1074
- operation: this.name
1075
- });
1076
- const sp = spResp?.data;
1077
- const commitVersion = typeof sp === "object" && sp !== null ? String(sp.commitVersion ?? sp.version ?? "") : "";
1078
- if (commitVersion) {
1079
- 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" }
1080
1191
  }
1081
- } catch {
1082
1192
  }
1083
- const cfgMap = {};
1084
- for (const pk of ALL_PKS) {
1085
- const resp = await host.request({
1086
- path: "/api/esb/server/event/triggerActionFlow",
1087
- body: { customParams: { mainTable: { interface_pk: pk } }, uniqueIndent: "4F6E1A9702864666803CCA6B77B86227", employeeId: userId },
1088
- operation: this.name
1089
- });
1090
- const cfgId = resp?.actionData?.responseData?.customData?.mainTable?.cfgId ?? resp?.customData?.mainTable?.cfgId ?? resp?.datajson?.mainTable?.cfgId ?? resp?.data?.mainTable?.cfgId ?? resp?.mainTable?.cfgId;
1091
- 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"]
1092
1205
  }
1093
- const perPk = {};
1094
- for (const pk of Object.keys(cfgMap)) {
1095
- const cfgId = cfgMap[pk];
1096
- const resp = await host.request({
1097
- method: "GET",
1098
- path: "/api/bs/ebuilder/form/formdata/getRestCfgById",
1099
- query: { apid: appId, id: cfgId },
1100
- operation: this.name
1101
- });
1102
- const detail = resp?.data ?? {};
1103
- if (!detail?.id && !detail?.mainFields) continue;
1104
- const allFields = [
1105
- ...detail.mainFields || [],
1106
- ...(detail.detailFields || []).flatMap((df) => df.fields || [])
1107
- ];
1108
- const fieldIds = [...new Set(allFields.filter(isInputOne).map((f) => String(f.fieldid)).filter(Boolean))];
1109
- const infoMap = /* @__PURE__ */ new Map();
1110
- if (fieldIds.length > 0) {
1111
- try {
1112
- const infoResp = await host.request({
1113
- path: "/api/esb/server/event/triggerActionFlow",
1114
- body: { customParams: { mainTable: { fieldids: fieldIds.join(",") } }, uniqueIndent: "10351A4DC8D4454A9F1957FBE647CD9F", employeeId: userId },
1115
- operation: this.name
1116
- });
1117
- const list = infoResp?.actionData?.responseData?.customData?.mainTable?.fieldInfoList ?? infoResp?.customData?.mainTable?.fieldInfoList ?? infoResp?.datajson?.mainTable?.fieldInfoList ?? infoResp?.fieldInfoList ?? [];
1118
- for (const it of list) infoMap.set(String(it.id), it);
1119
- } catch {
1120
- }
1121
- }
1122
- const merge = (f) => {
1123
- const info = infoMap.get(String(f?.fieldid));
1124
- if (info) {
1125
- f.data_key = info.data_key ?? f.data_key;
1126
- f.title = info.title ?? f.title;
1127
- f.component_type = info.component_type ?? f.component_type;
1128
- }
1129
- };
1130
- detail.mainFields = (detail.mainFields || []).filter(isInputOne);
1131
- detail.detailFields = (detail.detailFields || []).map((df) => ({ ...df, fields: (df.fields || []).filter(isInputOne) })).filter((df) => Array.isArray(df.fields) && df.fields.length > 0);
1132
- for (const f of detail.mainFields) merge(f);
1133
- for (const df of detail.detailFields) for (const f of df.fields) merge(f);
1134
- const kept = pickKeys(detail, DETAIL_KEEP_KEYS);
1135
- if (Array.isArray(kept.mainFields)) kept.mainFields = kept.mainFields.map((f) => pickKeys(f, FIELD_KEEP_KEYS));
1136
- if (Array.isArray(kept.detailFields)) {
1137
- kept.detailFields = kept.detailFields.map((df) => ({
1138
- ...pickKeys(df, ["id", "fieldName", "title", "fields"]),
1139
- fields: Array.isArray(df.fields) ? df.fields.map((f) => pickKeys(f, FIELD_KEEP_KEYS)) : []
1140
- }));
1141
- }
1142
- 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"]
1143
1219
  }
1144
- const ebuilder = {};
1145
- for (const { key, path, nameFields } of EBUILDER_QUERIES) {
1146
- const list = [];
1147
- let pageNo = 1;
1148
- for (; ; ) {
1149
- const resp = await host.request({
1150
- path,
1151
- body: { datajson: { mainTable: {}, pageInfo: { pageNo, pageSize: 100 }, header: { operator: userId } } },
1152
- operation: this.name
1153
- });
1154
- const items = resp?.datajson?.datas ?? resp?.data ?? [];
1155
- list.push(...Array.isArray(items) ? items : []);
1156
- const hasMore = resp?.hasMore ?? (Array.isArray(items) && items.length === 100);
1157
- if (!hasMore || list.length >= 500 || pageNo >= 5) break;
1158
- pageNo += 1;
1159
- }
1160
- ebuilder[key] = list.map((it) => {
1161
- const mt = it?.mainTable ?? it ?? {};
1162
- let name = "";
1163
- for (const nf of nameFields) {
1164
- if (mt[nf] !== void 0 && mt[nf] !== null && String(mt[nf]) !== "") {
1165
- name = String(mt[nf]);
1166
- break;
1167
- }
1168
- }
1169
- const item = { id: String(mt.id ?? ""), name };
1170
- if (key === "sale_stage" && mt.sale_process !== void 0) {
1171
- const sp = Array.isArray(mt.sale_process) ? mt.sale_process[0] : mt.sale_process;
1172
- if (sp && typeof sp === "object") item.sale_process = { id: String(sp.id ?? ""), name: String(sp.name ?? "") };
1173
- }
1174
- return item;
1175
- }).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"]
1176
1235
  }
1177
- const options = {};
1178
- for (const pk of Object.keys(perPk)) {
1179
- const tag = PK_TO_TAG[pk];
1180
- const objId = discovery[`objId:${tag}`];
1181
- if (!objId) continue;
1182
- const detail = perPk[pk].detail ?? {};
1183
- const fields = [
1184
- ...detail.mainFields || [],
1185
- ...(detail.detailFields || []).flatMap((d) => d.fields || [])
1186
- ];
1187
- for (const f of fields) {
1188
- if (!f?.fieldid) continue;
1189
- if (!OPT_COMP.includes(f.component_type)) continue;
1190
- const key = `options:${f.fieldid}:*:1`;
1191
- if (options[key]) continue;
1192
- try {
1193
- const resp = await host.request({
1194
- method: "GET",
1195
- path: "/api/ebuilder/common/ds/options",
1196
- query: { fieldName: String(f.fieldid), objId, groupId: appId, optionLevel: 1 },
1197
- operation: this.name
1198
- });
1199
- const values = resp?.data ?? resp?.datajson?.datas ?? [];
1200
- options[key] = {
1201
- lable: `${pk}.${f.data_key ?? f.fieldid}`,
1202
- lableTitle: `${pk}.${f.title ?? f.data_key ?? f.fieldid}`,
1203
- value: (Array.isArray(values) ? values : []).map((v) => ({
1204
- label: String(v?.lable ?? v?.label ?? v?.text ?? v?.name ?? ""),
1205
- value: String(v?.value ?? v?.val ?? v?.id ?? "")
1206
- }))
1207
- };
1208
- } catch {
1209
- }
1210
- }
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"]
1211
1249
  }
1212
- const searchPerPk = {};
1213
- for (const pk of SEARCH_PKS) {
1214
- const cfgId = cfgMap[pk];
1215
- if (!cfgId) continue;
1216
- try {
1217
- const resp = await host.request({
1218
- method: "GET",
1219
- path: "/api/bs/ebuilder/form/formdata/getRestCfgById",
1220
- query: { apid: appId, id: cfgId },
1221
- operation: this.name
1222
- });
1223
- const cfgObj = resp?.data ?? {};
1224
- let conditions = cfgObj.conditions;
1225
- if (typeof conditions === "string") {
1226
- try {
1227
- conditions = JSON.parse(conditions);
1228
- } catch {
1229
- conditions = null;
1230
- }
1231
- }
1232
- const params = [];
1233
- for (const d of conditions?.datas ?? []) {
1234
- const value = d?.conditions?.value;
1235
- if (typeof value === "string") {
1236
- const m = value.match(/\{([^}]+)\}/);
1237
- if (m) {
1238
- params.push({
1239
- key: m[1],
1240
- text: d?.text ?? "",
1241
- fieldType: d?.fieldType ?? "",
1242
- compType: d?.compType ?? "",
1243
- func: d?.conditions?.func ?? "",
1244
- fieldid: d?.fieldName ?? ""
1245
- });
1246
- }
1247
- }
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"]
1248
1264
  }
1249
- searchPerPk[pk] = { cfgId, searchParams: params };
1250
- } 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" }
1251
1319
  }
1252
1320
  }
1253
- for (const [pk, entry] of Object.entries(searchPerPk)) {
1254
- if (perPk[pk]) perPk[pk] = { ...perPk[pk], ...entry };
1255
- 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"]
1256
1364
  }
1257
- const region = {};
1258
- for (const city of REGION_CITIES) {
1259
- try {
1260
- const resp = await host.request({
1261
- path: "/api/esb/server/event/triggerActionFlow",
1262
- body: {
1263
- customParams: { mainTable: { moduleType: "administrativeDivision", name: city, fromType: "agentSkill" } },
1264
- uniqueIndent: "7EC1639D5AC24B4DBCEE8D2CB85D4025",
1265
- 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" }
1266
1476
  },
1267
- operation: this.name
1268
- });
1269
- if (Number(resp?.resultCode ?? 0) === 200) {
1270
- region[`administrativeDivision:${city}`] = resp;
1477
+ required: ["moduleType", "entityId"]
1271
1478
  }
1272
- } catch {
1273
- }
1479
+ },
1480
+ required: ["mainTable"]
1274
1481
  }
1275
- const cache = { discovery, ebuilder, options, region };
1276
- cache.region = { ...old.region || {}, ...cache.region || {} };
1277
- cache.options = { ...old.options || {}, ...cache.options || {} };
1278
- if (!cache.discovery[`spVersion:${APP_TAG}`] && old.discovery?.[`spVersion:${APP_TAG}`]) {
1279
- 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"]
1280
1492
  }
1281
- const summary = {
1282
- dryRun,
1283
- cacheDir: baseDir,
1284
- mainFile,
1285
- namespaces: {
1286
- discovery: Object.keys(cache.discovery).length,
1287
- ebuilder: Object.keys(cache.ebuilder).length,
1288
- options: Object.keys(cache.options).length,
1289
- region: Object.keys(cache.region).length
1290
- },
1291
- configFiles: Object.keys(perPk).length,
1292
- objIdCount: Object.keys(discovery).filter((k) => k.startsWith("objId:")).length,
1293
- cfgIdCount: Object.keys(cfgMap).length,
1294
- version: cache.discovery[`spVersion:${APP_TAG}`] ?? null,
1295
- warnings: []
1296
- };
1297
- if (cache.discovery[`spVersion:${APP_TAG}`] && cache.discovery[`spVersion:${APP_TAG}`].passed === false) {
1298
- 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"]
1299
1504
  }
1300
- if (dryRun) return { status: "COMPLETE", data: { ...summary, written: false, note: "dry-run\uFF1A\u53EA\u62C9\u53D6\u672A\u5199\u5165" } };
1301
- mkdirSync(cfgDir, { recursive: true });
1302
- writeFileSync(mainFile, JSON.stringify(cache, null, 2), "utf-8");
1303
- for (const [pk, entry] of Object.entries(perPk)) {
1304
- const tag = PK_TO_TAG[pk];
1305
- const objId = cache.discovery[`objId:${tag}`];
1306
- 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"]
1307
1515
  }
1308
- if (verbose) {
1309
- 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"]
1310
1532
  }
1311
- return {
1312
- status: "COMPLETE",
1313
- data: { ...summary, written: true }
1314
- };
1315
- }
1316
- };
1317
-
1318
- // src/shortcuts/jiuchuanhui/operations/shared.ts
1319
- var FORBIDDEN_INPUT_KEYS = /* @__PURE__ */ new Set([
1320
- "access_token",
1321
- "app_key",
1322
- "app_secret",
1323
- "cookie",
1324
- "eteamsid",
1325
- "token",
1326
- "sessionid"
1327
- ]);
1328
- var FORBIDDEN_NORMALIZED_KEYS = new Set([...FORBIDDEN_INPUT_KEYS].map((key) => key.toLowerCase()));
1329
- function asObject(value, name = "\u4E1A\u52A1\u8F93\u5165") {
1330
- if (!value || typeof value !== "object" || Array.isArray(value)) {
1331
- throw jiuchuanhuiValidationError("input_invalid", `${name}\u5FC5\u987B\u662F JSON \u5BF9\u8C61`);
1332
- }
1333
- return value;
1334
- }
1335
- function asNonEmptyString(value, name) {
1336
- if (typeof value !== "string" || !value.trim()) {
1337
- throw jiuchuanhuiValidationError("input_invalid", `${name} \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32`);
1338
- }
1339
- return value.trim();
1340
- }
1341
- function asPositiveString(value, name) {
1342
- if (typeof value !== "string" || !/^\d+$/u.test(value) || value === "0") {
1343
- throw jiuchuanhuiValidationError("input_invalid", `${name} \u5FC5\u987B\u662F\u6B63\u6574\u6570\u6587\u672C`);
1344
- }
1345
- return value;
1346
- }
1347
- function assertNoForbiddenKeys(value, location = "input") {
1348
- if (!value || typeof value !== "object") return;
1349
- if (Array.isArray(value)) {
1350
- value.forEach((item, index) => assertNoForbiddenKeys(item, `${location}[${index}]`));
1351
- return;
1352
- }
1353
- for (const [key, child] of Object.entries(value)) {
1354
- if (FORBIDDEN_INPUT_KEYS.has(key) || FORBIDDEN_NORMALIZED_KEYS.has(key.toLowerCase())) {
1355
- 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"]
1356
1543
  }
1357
- assertNoForbiddenKeys(child, `${location}.${key}`);
1358
- }
1359
- }
1360
- function sessionMatches(lease, session) {
1361
- return lease.baseUrl === session.baseUrl && lease.profile === session.profile && lease.userId === session.userId;
1362
- }
1363
- function workflow(name, state) {
1364
- return { workflow: name, version: 1, state };
1365
- }
1366
- function esbBody(mainTable, uniqueIndent, userId) {
1367
- return {
1368
- customParams: { mainTable },
1369
- uniqueIndent,
1370
- employeeId: userId
1371
- };
1372
- }
1373
- function datasBody(form, userId) {
1374
- const datas = Array.isArray(form.datas) ? form.datas : [form];
1375
- const cleansed = datas.map((item) => stripForbidden(item));
1376
- return {
1377
- datajson: {
1378
- datas: cleansed,
1379
- 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"]
1380
1554
  }
1381
- };
1382
- }
1383
- function byIdBody(id, userId) {
1384
- return {
1385
- datajson: {
1386
- mainTable: { id },
1387
- 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"]
1388
1577
  }
1389
- };
1390
- }
1391
- function listBody(userId, pageNo, pageSize, mainTable) {
1392
- const mt = mainTable && Object.keys(mainTable).length ? { ...mainTable } : {};
1393
- return {
1394
- datajson: {
1395
- mainTable: mt,
1396
- pageInfo: { pageNo, pageSize },
1397
- 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"]
1398
1591
  }
1399
- };
1400
- }
1401
- function stripForbidden(value) {
1402
- if (Array.isArray(value)) return value.map(stripForbidden);
1403
- if (!value || typeof value !== "object") return value;
1404
- const result = {};
1405
- for (const [key, child] of Object.entries(value)) {
1406
- if (FORBIDDEN_INPUT_KEYS.has(key) || FORBIDDEN_NORMALIZED_KEYS.has(key.toLowerCase())) continue;
1407
- result[key] = stripForbidden(child);
1408
1592
  }
1409
- return result;
1410
- }
1411
- function stripForbiddenKeys(value) {
1412
- return stripForbidden(value);
1413
- }
1414
- function listRecords(value) {
1415
- if (!value || typeof value !== "object") return [];
1416
- const root = value;
1417
- const datas = root.datajson?.datas;
1418
- if (Array.isArray(datas)) return datas;
1419
- return [];
1420
- }
1421
- function resultDataIds(value) {
1422
- if (!value || typeof value !== "object") return [];
1423
- const ids = value.datajson?.dataIds;
1424
- if (Array.isArray(ids)) return ids.map((item) => String(item));
1425
- return [];
1426
- }
1427
- function esbOutcome(value) {
1428
- if (!value || typeof value !== "object") return { resultCode: 0, resultMsg: "" };
1429
- const root = value;
1430
- return {
1431
- resultCode: Number(root.resultCode ?? 0),
1432
- resultMsg: typeof root.resultMsg === "string" ? root.resultMsg : ""
1433
- };
1434
- }
1435
- function pagingFrom(input) {
1436
- const pageNo = Number.isInteger(input.pageNo) && input.pageNo >= 1 ? input.pageNo : 1;
1437
- const pageSize = Number.isInteger(input.pageSize) && input.pageSize >= 1 ? input.pageSize : 10;
1438
- 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);
1439
1612
  }
1440
1613
 
1441
1614
  // src/shortcuts/jiuchuanhui/operations/datajson.ts
@@ -1536,20 +1709,12 @@ var DatajsonDetailOperation = class {
1536
1709
  async execute(input, { host }) {
1537
1710
  const id = asPositiveString(String(input.id ?? input.dataId), "id");
1538
1711
  const session = await host.getSession();
1539
- const result = await host.request({
1712
+ const response = await host.query({
1540
1713
  path: this.path,
1541
1714
  body: byIdBody(id, session.userId),
1542
1715
  operation: this.name
1543
1716
  });
1544
- return {
1545
- status: "COMPLETE",
1546
- data: {
1547
- id,
1548
- ...result && typeof result === "object" ? { raw: result } : {},
1549
- mainTable: extractMainTable(result),
1550
- detail: result
1551
- }
1552
- };
1717
+ return { response };
1553
1718
  }
1554
1719
  };
1555
1720
  var DatajsonSearchOperation = class {
@@ -1566,22 +1731,13 @@ var DatajsonSearchOperation = class {
1566
1731
  const session = await host.getSession();
1567
1732
  const query = buildSearchQuery(input, pageNo, pageSize);
1568
1733
  const main = listBody(session.userId, pageNo, pageSize, {});
1569
- const listPromise = host.request({ path: this.path, query, body: main, operation: this.name });
1570
- 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;
1571
- const [listResult, countResult] = countPromise ? await Promise.all([listPromise, countPromise]) : [await listPromise, void 0];
1572
- const records = listRecords(listResult);
1573
- const total = extractCount(countResult);
1574
- return {
1575
- status: "COMPLETE",
1576
- data: {
1577
- items: records,
1578
- total,
1579
- pageNo,
1580
- pageSize,
1581
- hasMore: total === void 0 ? records.length >= pageSize : pageNo * pageSize < total,
1582
- query
1583
- }
1584
- };
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 };
1585
1741
  }
1586
1742
  };
1587
1743
  function buildSearchQuery(input, pageNo, pageSize) {
@@ -1606,27 +1762,6 @@ function withoutPaging(query) {
1606
1762
  delete next.pageSize;
1607
1763
  return next;
1608
1764
  }
1609
- function extractCount(value) {
1610
- if (!value || typeof value !== "object") return void 0;
1611
- const root = value;
1612
- const datas = root.datajson?.datas;
1613
- const raw = Array.isArray(datas) ? datas[0] : datas;
1614
- const num = Number(raw ?? root.total ?? root.count);
1615
- return Number.isFinite(num) ? num : void 0;
1616
- }
1617
- function extractMainTable(value) {
1618
- if (!value || typeof value !== "object") return void 0;
1619
- const root = value;
1620
- const mt = root.datajson?.mainTable;
1621
- if (mt && typeof mt === "object" && !Array.isArray(mt)) return mt;
1622
- const datas = root.datajson?.datas;
1623
- if (Array.isArray(datas) && datas[0] && typeof datas[0] === "object") {
1624
- const first = datas[0];
1625
- if (first.mainTable && typeof first.mainTable === "object") return first.mainTable;
1626
- return first;
1627
- }
1628
- return void 0;
1629
- }
1630
1765
 
1631
1766
  // src/shortcuts/jiuchuanhui/operations/esb.ts
1632
1767
  var EsbWritePrepareOperation = class {
@@ -1642,6 +1777,11 @@ var EsbWritePrepareOperation = class {
1642
1777
  mainTableKeys;
1643
1778
  async execute(input, { host, continuation }) {
1644
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
+ }
1645
1785
  const preview = summaryOf(mainTable);
1646
1786
  const session = await host.getSession();
1647
1787
  const continuationToken = await continuation.issue({
@@ -1732,26 +1872,12 @@ var EsbReadOperation = class {
1732
1872
  async execute(input, { host }) {
1733
1873
  const mainTable = normalizeMainTable(input.mainTable ?? input, this.mainTableKeys);
1734
1874
  const session = await host.getSession();
1735
- const result = await host.request({
1875
+ const response = await host.query({
1736
1876
  path: "/api/esb/server/event/triggerActionFlow",
1737
1877
  body: esbBody(mainTable, this.uniqueIndent, session.userId),
1738
1878
  operation: this.name
1739
1879
  });
1740
- const { resultCode, resultMsg } = esbOutcome(result);
1741
- if (resultCode !== 200) {
1742
- throw jiuchuanhuiValidationError("esb_read_failed", `\u52A8\u4F5C\u6D41\u67E5\u8BE2\u5931\u8D25\uFF08resultCode=${resultCode}\uFF09\uFF1A${resultMsg}`);
1743
- }
1744
- const customData = result?.actionData?.responseData?.customData;
1745
- return {
1746
- status: "COMPLETE",
1747
- data: {
1748
- resultCode,
1749
- resultMsg,
1750
- ...customData && typeof customData === "object" ? { customData } : {},
1751
- mainTable: customData?.mainTable,
1752
- raw: result
1753
- }
1754
- };
1880
+ return { response };
1755
1881
  }
1756
1882
  };
1757
1883
  function normalizeMainTable(raw, allowedKeys) {
@@ -1794,19 +1920,13 @@ var GetQueryOperation = class {
1794
1920
  if (value === void 0 || value === null || key === "save") continue;
1795
1921
  query[key] = Array.isArray(value) ? value.join(",") : value;
1796
1922
  }
1797
- const result = await host.request({
1923
+ const response = await host.query({
1798
1924
  method: "GET",
1799
1925
  path: this.path,
1800
1926
  query,
1801
1927
  operation: this.name
1802
1928
  });
1803
- return {
1804
- status: "COMPLETE",
1805
- data: {
1806
- ...result && typeof result === "object" ? { raw: result } : { raw: result },
1807
- query
1808
- }
1809
- };
1929
+ return { response };
1810
1930
  }
1811
1931
  };
1812
1932
  var PathParamsPostOperation = class {
@@ -1828,17 +1948,12 @@ var PathParamsPostOperation = class {
1828
1948
  path = path.replace(`{${name}}`, encodeURIComponent(String(value)));
1829
1949
  }
1830
1950
  const body = input.params && typeof input.params === "object" ? input.params : {};
1831
- const result = await host.request({
1951
+ const response = await host.query({
1832
1952
  path,
1833
1953
  body,
1834
1954
  operation: this.name
1835
1955
  });
1836
- return {
1837
- status: "COMPLETE",
1838
- data: {
1839
- ...result && typeof result === "object" ? { raw: result } : { raw: result }
1840
- }
1841
- };
1956
+ return { response };
1842
1957
  }
1843
1958
  };
1844
1959
  var FilePreviewOperation = class {
@@ -1857,25 +1972,21 @@ var FilePreviewOperation = class {
1857
1972
  if (input.fieldId !== void 0) query.fieldId = input.fieldId;
1858
1973
  if (input.appId !== void 0) query.appId = input.appId;
1859
1974
  if (input.customParam !== void 0) query.customParam = typeof input.customParam === "string" ? input.customParam : JSON.stringify(input.customParam);
1860
- const result = await host.request({
1975
+ const response = await host.query({
1861
1976
  method: "GET",
1862
1977
  path: "/api/file/preview",
1863
1978
  query,
1864
1979
  operation: this.name
1865
1980
  });
1866
- return {
1867
- status: "COMPLETE",
1868
- data: {
1869
- ...result && typeof result === "object" ? { raw: result } : { raw: result },
1870
- fileId
1871
- }
1872
- };
1981
+ return { response };
1873
1982
  }
1874
1983
  };
1875
1984
 
1876
1985
  // src/shortcuts/jiuchuanhui/operations/registry.ts
1877
1986
  function buildRegistry() {
1878
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");
1879
1990
  const handlers = [
1880
1991
  // ===== 发现与缓存 =====
1881
1992
  new CacheInitOperation(),
@@ -1889,9 +2000,12 @@ function buildRegistry() {
1889
2000
  new DatajsonWritePrepareOperation("jiuchuanhui.customer.create.prepare", "jiuchuanhui.customer.create.apply"),
1890
2001
  new DatajsonWriteApplyOperation("jiuchuanhui.customer.create.apply", "/api/ebuilder/form/formdata/v2/saveFormData/customer_create_api"),
1891
2002
  new DatajsonDetailOperation("jiuchuanhui.customer.get", "/api/ebuilder/form/formdata/v2/getFormDataByPk/customer_get_api"),
1892
- 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"),
1893
2007
  new DatajsonSearchOperation("jiuchuanhui.customer.type.search", "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_type_search_api"),
1894
- new DatajsonSearchOperation("jiuchuanhui.customer.status.search", "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_status_search_api"),
2008
+ customerStatusSearch,
1895
2009
  new DatajsonSearchOperation("jiuchuanhui.customer.industry.search", "/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_industry_search_api"),
1896
2010
  new DatajsonSearchOperation("jiuchuanhui.customer.open-sea.search", "/api/ebuilder/form/formdata/v2/getFormDataList/customer_open_sea_search_api"),
1897
2011
  new DatajsonWritePrepareOperation("jiuchuanhui.customer.update.prepare", "jiuchuanhui.customer.update.apply"),
@@ -2028,7 +2142,7 @@ async function inputFrom(options, extra = {}) {
2028
2142
  if (opts.input) {
2029
2143
  let raw;
2030
2144
  try {
2031
- 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"));
2032
2146
  } catch {
2033
2147
  throw jiuchuanhuiValidationError("input_unreadable", `\u65E0\u6CD5\u8BFB\u53D6 --input\uFF1A${String(opts.input)}`);
2034
2148
  }
@@ -2069,16 +2183,41 @@ function failureEnvelope(error) {
2069
2183
  error: toErrorEnvelope(error)
2070
2184
  };
2071
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
+ }
2072
2201
  async function executeAndPrint(ctx, operation, input) {
2073
2202
  try {
2074
2203
  const result = await executeJiuchuanhuiOperation(operation, input, {
2075
2204
  host: createJiuchuanhuiHost(ctx),
2076
2205
  continuation: createJiuchuanhuiContinuationSigner(ctx)
2077
2206
  });
2078
- 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
+ }
2079
2212
  } catch (error) {
2080
- reportPlatformError(error);
2081
- 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
+ }
2082
2221
  process.exitCode = isCliError(error) ? error.exitCode : 1 /* GeneralError */;
2083
2222
  }
2084
2223
  }
@@ -2088,8 +2227,15 @@ var jiuchuanhuiShortcut = {
2088
2227
  category: "shortcut",
2089
2228
  register({ program, action }) {
2090
2229
  const jiuchuanhui = program.command("jiuchuanhui").description("\u6CDB\u5FAEE10\u4E5D\u6C1A\u6C47\u8425\u9500\u7BA1\u7406");
2091
- jiuchuanhui.command("schema").description("Print jiuchuanhui operation manifest for agents").action(action((ctx) => {
2092
- 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 });
2093
2239
  }));
2094
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) => {
2095
2241
  await executeAndPrint(ctx, String(operation), await inputFrom(options));
@@ -2098,5 +2244,6 @@ var jiuchuanhuiShortcut = {
2098
2244
  };
2099
2245
  export {
2100
2246
  inputFrom,
2101
- jiuchuanhuiShortcut
2247
+ jiuchuanhuiShortcut,
2248
+ queryEnvelope
2102
2249
  };