weaver-work-cli 0.1.48 → 0.1.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/dist/chunks/{archive-oa-EDJDU3V4.js → archive-oa-57R2FYHV.js} +111 -12
  2. package/dist/chunks/{attachment-content-4KSNBPRO.js → attachment-content-EJYIOJPH.js} +3 -3
  3. package/dist/chunks/{chunk-FEP6ELMR.js → chunk-3NCFFHB2.js} +1 -1
  4. package/dist/chunks/chunk-5QYE52LG.js +223 -0
  5. package/dist/chunks/{chunk-3YV7PKRL.js → chunk-6QYNE6HE.js} +12 -212
  6. package/dist/chunks/{chunk-NBEWUR7L.js → chunk-6T53BSWZ.js} +158 -44
  7. package/dist/chunks/{chunk-OCYRVZGN.js → chunk-7AYQJSFY.js} +2 -2
  8. package/dist/chunks/{chunk-5B5JXTY2.js → chunk-7ECB22G3.js} +221 -30
  9. package/dist/chunks/{chunk-72MI3MBX.js → chunk-ATEXBEPD.js} +55 -15
  10. package/dist/chunks/{chunk-WMSAWAWZ.js → chunk-BFKLQLBK.js} +8 -8
  11. package/dist/chunks/{chunk-EFOUMXIX.js → chunk-HARQF5IP.js} +28 -28
  12. package/dist/chunks/{chunk-O6CMPO65.js → chunk-IW7A2IQY.js} +16 -146
  13. package/dist/chunks/chunk-JEQHNNSS.js +158 -0
  14. package/dist/chunks/{chunk-NK74RE5F.js → chunk-K67FODVC.js} +3 -3
  15. package/dist/chunks/{chunk-YLCYX7LE.js → chunk-KMRT7NAT.js} +18 -5
  16. package/dist/chunks/{chunk-BCACE6VV.js → chunk-MCZG6HPM.js} +3 -3
  17. package/dist/chunks/{chunk-SVFG6EMV.js → chunk-RYFRGTUV.js} +5 -5
  18. package/dist/chunks/{chunk-PSPOFLSU.js → chunk-WNJUGI2F.js} +1 -1
  19. package/dist/chunks/{chunk-R2HHLJNN.js → chunk-YB3AJYPY.js} +4 -4
  20. package/dist/chunks/{conflict-APGSD5E7.js → conflict-C4UDHCWV.js} +2 -2
  21. package/dist/chunks/{contract-N6P2HIIE.js → contract-VUC6JOPG.js} +464 -9
  22. package/dist/chunks/{create-flow-5TXFOC7X.js → create-flow-6OG2LYBD.js} +6 -6
  23. package/dist/chunks/data-QO7QWOIV.js +2525 -0
  24. package/dist/chunks/{employee-NOHNXC46.js → employee-DR5Y64TI.js} +2 -1
  25. package/dist/chunks/{env-B6GKA2J3.js → env-WP57TF2S.js} +2 -2
  26. package/dist/chunks/{factory-MFCKLUT6.js → factory-VUXI7N5C.js} +1 -1
  27. package/dist/chunks/{fna-ZVB2IILI.js → fna-ECOYBQYL.js} +328 -5
  28. package/dist/chunks/{group-chat-YE7WIBFO.js → group-chat-UQRGXILK.js} +3 -3
  29. package/dist/chunks/{hrm-UNKCCCGP.js → hrm-YGIR3HGF.js} +4 -2
  30. package/dist/chunks/{im-3RCNL5GT.js → im-TN2JYVGJ.js} +2 -2
  31. package/dist/chunks/{invoice-FXWH5GPO.js → invoice-E7GOITEU.js} +1 -1
  32. package/dist/chunks/{meeting-RYZV2JTQ.js → meeting-4BBLVAWM.js} +10 -10
  33. package/dist/chunks/{msg-parse-4GSQ2WTO.js → msg-parse-FPFVPMYI.js} +5 -1
  34. package/dist/chunks/org-NFE7X7FK.js +12 -0
  35. package/dist/chunks/{reception-VL6TKVAW.js → reception-QGPNTGHG.js} +526 -175
  36. package/dist/chunks/{recruit-stage-ERZD3ZNB.js → recruit-stage-FKWS5UQF.js} +66 -13
  37. package/dist/chunks/{registry-VWXWPVAG.js → registry-3UGIWH53.js} +4 -2
  38. package/dist/chunks/{registry-22O6UG4I.js → registry-5CRCN2TV.js} +10 -10
  39. package/dist/chunks/{registry-BUTEDK3C.js → registry-E5RQJVWN.js} +2 -2
  40. package/dist/chunks/{registry-7VZ6YJUF.js → registry-V4CHRQDI.js} +1 -1
  41. package/dist/chunks/{room-recommend-IMZPJMYB.js → room-recommend-AYR3UG7R.js} +4 -4
  42. package/dist/chunks/{schedule-SPPAHER2.js → schedule-JZEFIXUS.js} +4 -4
  43. package/dist/chunks/{workflow-WVEFJ6KC.js → workflow-3ZAF2J5E.js} +4 -4
  44. package/dist/index.js +16 -11
  45. package/dist/shortcuts/archive-oa/operations/contract-modules.js +57 -0
  46. package/dist/shortcuts/archive-oa/operations/contract.js +23 -8
  47. package/dist/shortcuts/archive-oa/operations/registry.js +4 -1
  48. package/dist/shortcuts/archive-oa/operations/shared.js +41 -5
  49. package/dist/shortcuts/contract/host.js +11 -0
  50. package/dist/shortcuts/contract/index.js +13 -0
  51. package/dist/shortcuts/contract/manifest.js +53 -0
  52. package/dist/shortcuts/contract/operations/performance.js +58 -7
  53. package/dist/shortcuts/contract/operations/quote.js +283 -1
  54. package/dist/shortcuts/contract/operations/registry.js +2 -0
  55. package/dist/shortcuts/contract/operations/save-recognize.js +151 -0
  56. package/dist/shortcuts/data/errors.js +64 -0
  57. package/dist/shortcuts/data/host.js +140 -0
  58. package/dist/shortcuts/data/index.js +429 -0
  59. package/dist/shortcuts/data/manifest.js +133 -0
  60. package/dist/shortcuts/data/operations/attend.js +62 -0
  61. package/dist/shortcuts/data/operations/conf.js +384 -0
  62. package/dist/shortcuts/data/operations/ds.js +686 -0
  63. package/dist/shortcuts/data/operations/field.js +68 -0
  64. package/dist/shortcuts/data/operations/index.js +65 -0
  65. package/dist/shortcuts/data/operations/module.js +383 -0
  66. package/dist/shortcuts/data/operations/noun.js +102 -0
  67. package/dist/shortcuts/data/operations/query.js +85 -0
  68. package/dist/shortcuts/data/operations/scene.js +235 -0
  69. package/dist/shortcuts/data/operations/shared.js +279 -0
  70. package/dist/shortcuts/ehr/recruit-stage/operations/interview-arrange.js +12 -5
  71. package/dist/shortcuts/ehr/recruit-stage/operations/resume-import.js +21 -13
  72. package/dist/shortcuts/ehr/recruit-stage/shared.js +57 -0
  73. package/dist/shortcuts/fna/host.js +4 -2
  74. package/dist/shortcuts/fna/manifest.js +14 -5
  75. package/dist/shortcuts/fna/operations/audit.js +334 -0
  76. package/dist/shortcuts/fna/operations/registry.js +2 -0
  77. package/dist/shortcuts/im/operations/at-mention.js +6 -3
  78. package/dist/shortcuts/im/operations/msg-parse.js +35 -5
  79. package/dist/shortcuts/im/operations/msg-sync.js +3 -1
  80. package/dist/shortcuts/im/operations/msg-write.js +57 -9
  81. package/dist/shortcuts/index.js +5 -0
  82. package/dist/shortcuts/invoice/manifest.js +1 -1
  83. package/dist/shortcuts/meeting/operations/eb/member-expand.js +200 -0
  84. package/dist/shortcuts/meeting/operations/from-group-chat.js +16 -2
  85. package/dist/shortcuts/meeting/operations/registry.js +2 -0
  86. package/dist/shortcuts/reception/constants.js +13 -6
  87. package/dist/shortcuts/reception/index.js +3 -1
  88. package/dist/shortcuts/reception/manifest.js +3 -2
  89. package/dist/shortcuts/reception/operations/ask.js +20 -2
  90. package/dist/shortcuts/reception/operations/compose.js +11 -0
  91. package/dist/shortcuts/reception/operations/doc.js +59 -0
  92. package/dist/shortcuts/reception/operations/docrender.js +25 -1
  93. package/dist/shortcuts/reception/operations/leads.js +31 -7
  94. package/dist/shortcuts/reception/operations/panels.js +86 -22
  95. package/dist/shortcuts/reception/operations/render.js +40 -0
  96. package/dist/shortcuts/reception/operations/restaurant.js +17 -4
  97. package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +12 -5
  98. package/dist/shortcuts/recruit-stage/operations/resume-import.js +21 -13
  99. package/dist/shortcuts/recruit-stage/shared.js +57 -0
  100. package/dist/shortcuts/workflow/operations/read.js +58 -14
  101. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +140 -24
  102. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +42 -14
  103. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +4 -6
  104. package/docs/SKILL.md +2 -1
  105. package/docs/_catalog.md +4 -1
  106. package/docs/data.md +149 -0
  107. package/docs/fna.md +11 -4
  108. package/docs/reception.md +59 -5
  109. package/package.json +1 -1
  110. package/scripts/check-skill-sync.mjs +188 -0
  111. package/scripts/package-skill.mjs +17 -3
  112. package/skill-template/business-info.json +29 -1
  113. package/skill-template/domains/data.md +15 -0
  114. package/skill-template/domains/qiyecheng.md +4 -2
  115. package/skills/weaver-e10-archive-oa/SKILL.md +7 -6
  116. package/skills/weaver-e10-archive-oa/references/contract-search.md +83 -14
  117. package/skills/weaver-e10-archive-oa/references/disabled-capabilities.md +1 -1
  118. package/skills/weaver-e10-archive-oa/references/qys-contract-search.md +35 -11
  119. package/skills/weaver-e10-data/SKILL.md +118 -0
  120. package/skills/weaver-e10-data/references/config-center.md +90 -0
  121. package/skills/weaver-e10-data/references/datasource.md +136 -0
  122. package/skills/weaver-e10-data/references/scene-and-misc.md +82 -0
  123. package/skills/weaver-e10-jinchengda/SKILL.md +1 -1
  124. package/skills/weaver-e10-jinchengda/references/contract-action-card.md +5 -5
  125. package/skills/weaver-e10-jinchengda/references/contract-action-engine.md +1 -1
  126. package/skills/weaver-e10-jinchengda/references/contract-clause-library-crud.md +44 -2
  127. package/skills/weaver-e10-jinchengda/references/contract-command-index.md +2 -2
  128. package/skills/weaver-e10-jinchengda/references/contract-element-save-record.md +219 -0
  129. package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +50 -30
  130. package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +24 -15
  131. package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +1 -1
  132. package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +96 -2
  133. package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +43 -0
  134. package/skills/weaver-e10-jinchengda/scripts/fill_plan.py +997 -0
  135. package/skills/weaver-e10-jinchengda/scripts/render_ebdf_list_card.py +265 -0
  136. package/skills/weaver-e10-jinchengda/scripts/validate_action_card.py +83 -0
  137. package/skills/weaver-e10-jinchengda/scripts/verify_docx_placeholders.py +118 -0
  138. package/skills/weaver-e10-meeting/SKILL.md +39 -7
  139. package/skills/weaver-e10-qiyecheng/SKILL.md +21 -7
  140. package/skills/weaver-e10-qiyecheng/references/ai-check-audit.md +104 -0
  141. package/skills/weaver-e10-qiyecheng/references/catalog.md +17 -3
  142. package/skills/weaver-e10-qiyecheng/references/source-manifest.json +136 -30
  143. package/skills/weaver-e10-reception-flow/SKILL.md +70 -19
  144. package/skills/weaver-e10-reception-flow/references/guide.md +5 -4
  145. package/skills/weaver-e10-reception-flow/scripts/render.py +5 -3
  146. package/skills/weaver-e10-recruit-stage/SKILL.md +1 -1
  147. package/skills/weaver-e10-recruit-stage/agents/openai.yaml +26 -6
  148. package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +3 -3
  149. package/skills/weaver-e10-recruit-stage/references/recruit-output-links.md +6 -4
  150. package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +3 -3
  151. package/skills/weaver-e10-recruit-stage/references/recruit-utterance-glossary.md +53 -11
  152. package/skills/weaver-e10-workflow/SKILL.md +2 -1
  153. package/skills/weaver-e10-workflow/references/todo-smart-convert.md +29 -6
  154. package/skills/weaver-e10-workflow/tools/todo-summary.cjs +162 -10
  155. package/skills/weaver-e10-yepiaotong/SKILL.md +10 -5
  156. package/skills/weaver-e10-yepiaotong/references/invoice-issuing-workflow.md +19 -32
  157. package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +6 -45
  158. package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +5 -5
  159. package/skills/weaver-e10-yepiaotong/references/reim-examples.md +4 -37
  160. package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +2 -2
  161. package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +4 -4
  162. package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +22 -35
  163. package/skills/weaver-e10-yimiaoban/SKILL.md +8 -6
  164. package/skills/weaver-e10-yimiaoban/references/msg-read.md +20 -0
  165. package/skills/weaver-e10-yimiaoban/references/msg-write.md +7 -0
  166. package/skills/weaver-e10-yimiaoban/references/source-manifest.json +18 -15
  167. package/dist/chunks/{ebuilder-form-I5ZIX4WO.js → ebuilder-form-CBYI6CQ6.js} +4 -4
@@ -0,0 +1,2525 @@
1
+ import { createRequire as __esbuildCreateRequire } from 'node:module';
2
+ const require = __esbuildCreateRequire(import.meta.url);
3
+ import {
4
+ E10ApiError,
5
+ createE10RequestRuntime,
6
+ isE10SessionExpiredResponse,
7
+ requireE10Session
8
+ } from "./chunk-6NXT4ICB.js";
9
+ import {
10
+ E10_SESSION_EXPIRED_MESSAGE
11
+ } from "./chunk-U6R6FZHD.js";
12
+ import {
13
+ CliError
14
+ } from "./chunk-UG5G54VL.js";
15
+ import "./chunk-BUSC6UAE.js";
16
+
17
+ // src/shortcuts/data/index.ts
18
+ import { readFile } from "node:fs/promises";
19
+
20
+ // src/shortcuts/data/errors.ts
21
+ var DataExit = {
22
+ OK: 0,
23
+ AUTH: 2,
24
+ JSON: 3,
25
+ PERM: 4,
26
+ HRM: 6,
27
+ HTTP: 7,
28
+ USAGE: 8
29
+ };
30
+ var DataCliError = class extends CliError {
31
+ type;
32
+ subtype;
33
+ code;
34
+ retryable;
35
+ stage;
36
+ details;
37
+ constructor(type, subtype, message, options = {}) {
38
+ super(message, options.exitCode ?? 1 /* GeneralError */);
39
+ this.name = "DataCliError";
40
+ this.type = type;
41
+ this.subtype = subtype;
42
+ this.code = options.code;
43
+ this.retryable = options.retryable ?? false;
44
+ this.stage = options.stage;
45
+ this.details = options.details;
46
+ }
47
+ };
48
+ function dataValidationError(subtype, message, exitCode = DataExit.USAGE) {
49
+ return new DataCliError("validation", subtype, message, { exitCode });
50
+ }
51
+ function dataAuthError(subtype, message, details) {
52
+ return new DataCliError("authentication", subtype, message, { exitCode: DataExit.AUTH, details });
53
+ }
54
+ function dataNetworkError(subtype, message, details) {
55
+ return new DataCliError("network", subtype, message, { exitCode: DataExit.HTTP, retryable: true, details });
56
+ }
57
+ function dataApiError(subtype, message, options = {}) {
58
+ return new DataCliError("api", subtype, message, {
59
+ code: options.code,
60
+ details: options.details,
61
+ exitCode: options.exitCode ?? DataExit.JSON
62
+ });
63
+ }
64
+ function dataPermissionBlocked(message) {
65
+ return new DataCliError("policy", "permission_restricted", message, { exitCode: DataExit.PERM });
66
+ }
67
+ function dataHrmBlocked(apiPath) {
68
+ return new DataCliError(
69
+ "policy",
70
+ "hrm_path_blocked",
71
+ `\u8BE5\u63A5\u53E3\u547D\u4E2D HRM \u8DEF\u5F84\u9ED1\u540D\u5355\uFF08${apiPath}\uFF09\u2192 \u4EBA\u5458/\u90E8\u95E8/\u5C97\u4F4D\u4E00\u5F8B\u8D70 weaver-work-cli \u7684 hrm \u5B50\u547D\u4EE4\uFF0C\u7981\u6B62\u76F4\u8C03`,
72
+ { exitCode: DataExit.HRM, details: { apiPath } }
73
+ );
74
+ }
75
+
76
+ // src/shortcuts/data/host.ts
77
+ var DATA_TIMEOUT_MS = 6e4;
78
+ var DATA_EB_BUSINESS_ID = "10000000000000000";
79
+ function queryStringOf(query) {
80
+ if (!query) return void 0;
81
+ const out = {};
82
+ for (const [key, value] of Object.entries(query)) {
83
+ if (value === void 0 || value === null) continue;
84
+ out[key] = value;
85
+ }
86
+ return out;
87
+ }
88
+ function formStringOf(form) {
89
+ if (typeof form === "string") return form;
90
+ const params = new URLSearchParams();
91
+ for (const [key, value] of Object.entries(form)) {
92
+ if (value === void 0 || value === null) continue;
93
+ if (Array.isArray(value)) {
94
+ for (const item of value) {
95
+ params.append(key, item !== null && typeof item === "object" ? JSON.stringify(item) : String(item));
96
+ }
97
+ } else {
98
+ params.append(key, typeof value === "object" ? JSON.stringify(value) : String(value));
99
+ }
100
+ }
101
+ return params.toString();
102
+ }
103
+ function multipartOf(fields) {
104
+ const form = new FormData();
105
+ for (const [key, value] of Object.entries(fields)) {
106
+ if (value === void 0 || value === null) continue;
107
+ form.append(key, typeof value === "object" ? JSON.stringify(value) : String(value));
108
+ }
109
+ return form;
110
+ }
111
+ function createDataHost(ctx, dependencies = {}) {
112
+ let authSession = null;
113
+ let snapshot = null;
114
+ const requireSession = dependencies.requireSession ?? requireE10Session;
115
+ async function ensureSession() {
116
+ if (!authSession) {
117
+ authSession = await requireSession(ctx);
118
+ snapshot = {
119
+ baseUrl: authSession.getBaseUrl(),
120
+ userId: authSession.userId,
121
+ tenantKey: authSession.tenantKey,
122
+ eteamsId: authSession.eteamsId,
123
+ userAgent: authSession.uaHeader()
124
+ };
125
+ }
126
+ return authSession;
127
+ }
128
+ async function requestText(request2) {
129
+ const session2 = await ensureSession();
130
+ const runtime = createE10RequestRuntime(ctx, session2);
131
+ const method = request2.method ?? (request2.body === void 0 && request2.form === void 0 && request2.multipart === void 0 ? "GET" : "POST");
132
+ let response;
133
+ try {
134
+ response = await runtime.requestJson({
135
+ module: "data",
136
+ operation: request2.operation ?? request2.path,
137
+ method,
138
+ path: request2.path,
139
+ query: queryStringOf(request2.query),
140
+ // multipart 与 body/form 互斥:FormData 自带 boundary,不能与 Content-Type 混用
141
+ body: request2.multipart === void 0 ? request2.body : void 0,
142
+ form: request2.multipart === void 0 && request2.form !== void 0 ? formStringOf(request2.form) : void 0,
143
+ formData: request2.multipart === void 0 ? void 0 : multipartOf(request2.multipart),
144
+ headers: {
145
+ // e10-data 对 conf / module 通道恒定下发 ebbusinessid,运行时不会自动注入
146
+ ebbusinessid: DATA_EB_BUSINESS_ID,
147
+ ...request2.headers ?? {}
148
+ },
149
+ trustedHeaders: request2.trustedHeaders,
150
+ timeoutMs: request2.timeoutMs ?? DATA_TIMEOUT_MS
151
+ });
152
+ } catch (error) {
153
+ if (error instanceof E10ApiError) {
154
+ if (error.type === "authentication") throw dataAuthError("session_expired", error.message);
155
+ if (error.type === "network") throw dataNetworkError(error.subtype, error.message, error.details);
156
+ }
157
+ throw error;
158
+ }
159
+ if (isE10SessionExpiredResponse(response)) {
160
+ throw dataAuthError("session_expired", E10_SESSION_EXPIRED_MESSAGE, { httpStatus: response.status });
161
+ }
162
+ if (response.parseError) {
163
+ if (response.status >= 200 && response.status < 300) {
164
+ return { status: response.status, text: response.text, value: null };
165
+ }
166
+ throw dataNetworkError("non_json", `HTTP ${response.status} \u975E JSON \u54CD\u5E94: ${response.text.slice(0, 300)}`, {
167
+ status: response.status
168
+ });
169
+ }
170
+ return { status: response.status, text: response.text, value: response.value };
171
+ }
172
+ async function request(request2) {
173
+ const { status, value, text } = await requestText(request2);
174
+ if (status < 200 || status >= 300) {
175
+ throw dataApiError("http_error", `\u63A5\u53E3 HTTP ${status}`, {
176
+ code: status,
177
+ details: { status, body: String(text ?? "").slice(0, 500) },
178
+ exitCode: 7
179
+ });
180
+ }
181
+ return value;
182
+ }
183
+ async function session() {
184
+ await ensureSession();
185
+ return snapshot;
186
+ }
187
+ return { session, request, requestText };
188
+ }
189
+ function needArg(input, key, flag) {
190
+ const raw = input[key];
191
+ if (raw === void 0 || raw === null || raw === "" || raw === true) {
192
+ throw dataValidationError("missing_argument", `\u7F3A\u5C11\u5FC5\u586B\u53C2\u6570 --${flag ?? key.replace(/_/g, "-")}`);
193
+ }
194
+ return String(raw);
195
+ }
196
+
197
+ // src/shortcuts/data/operations/shared.ts
198
+ import { readFileSync } from "node:fs";
199
+ function quoteLongInts(raw) {
200
+ return raw.replace(/([:[,]\s*)(-?\d{16,})(?=\s*[,}\]])/g, '$1"$2"');
201
+ }
202
+ function parseJsonSafe(raw) {
203
+ return JSON.parse(quoteLongInts(String(raw).replace(/^\uFEFF+/, "")));
204
+ }
205
+ function readJsonArg(value, label) {
206
+ if (value === void 0 || value === null || value === true) return void 0;
207
+ const raw = String(value);
208
+ const text = raw.startsWith("@") ? readFileSync(raw.slice(1), "utf-8") : raw;
209
+ try {
210
+ return parseJsonSafe(text);
211
+ } catch (error) {
212
+ throw dataValidationError("json_invalid", `${label} \u4E0D\u662F\u5408\u6CD5 JSON\uFF1A${error.message}`);
213
+ }
214
+ }
215
+ function readListArg(value) {
216
+ if (value === void 0 || value === null || value === true) return "";
217
+ const raw = String(value);
218
+ return raw.startsWith("@") ? readFileSync(raw.slice(1), "utf-8").trim() : raw;
219
+ }
220
+ function dynamicParams(session) {
221
+ return {
222
+ eteamsId: session.eteamsId,
223
+ userId: session.userId || "",
224
+ tenantKey: session.tenantKey || "",
225
+ langId: 7,
226
+ formatDate: "yyyy-MM-dd HH:mm:ss",
227
+ isPublic: false
228
+ };
229
+ }
230
+ function baseDto(session, tableId, groupId, pageNo, pageSize, queryType) {
231
+ return {
232
+ tableId: String(tableId),
233
+ groupId,
234
+ pageNo,
235
+ pageSize,
236
+ queryType,
237
+ containDetailTable: false,
238
+ needFormat: true,
239
+ dynamicParams: dynamicParams(session)
240
+ };
241
+ }
242
+ function applyAppId(dto, appId) {
243
+ if (typeof appId === "string" && appId !== "" && appId !== "auto") dto.appId = appId;
244
+ return dto;
245
+ }
246
+ function normRelationship(value) {
247
+ return value === "0" || value === 0 || value === false ? "0" : "1";
248
+ }
249
+ function isConditionGroup(node) {
250
+ return !!node && Array.isArray(node.conditionList) && node.conditionList.length > 0;
251
+ }
252
+ function buildConditionNode(node, key, parentKey) {
253
+ if (isConditionGroup(node)) {
254
+ return {
255
+ key,
256
+ relationship: normRelationship(node.relationship),
257
+ isParent: true,
258
+ parentNode: parentKey,
259
+ mainField: node.mainField !== false,
260
+ conditionList: node.conditionList.map((child, index) => buildConditionNode(child, `${key}_${index}`, key))
261
+ };
262
+ }
263
+ const fieldId = node && (node.fieldId || node.conditionId) || "";
264
+ if (!fieldId) {
265
+ throw dataValidationError(
266
+ "where_invalid",
267
+ "--where \u6761\u4EF6\u7F3A\u5C11\u5B57\u6BB5\uFF1A\u53F6\u5B50\u987B\u63D0\u4F9B fieldId\uFF08\u6216 conditionId\uFF09\uFF0C\u6761\u4EF6\u7EC4\u987B\u63D0\u4F9B\u975E\u7A7A conditionList"
268
+ );
269
+ }
270
+ return {
271
+ key,
272
+ relationship: "1",
273
+ isParent: false,
274
+ parentNode: parentKey,
275
+ objId: node.objId || "",
276
+ conditionId: fieldId,
277
+ fieldName: node.fieldName || fieldId,
278
+ conditionType: node.conditionType || "",
279
+ compareType: node.compareType,
280
+ conditionValue: node.conditionValue ?? "",
281
+ fieldValue: node.fieldValue || "",
282
+ mainField: node.mainField !== false,
283
+ ignoreCaseMark: node.ignoreCaseMark || false
284
+ };
285
+ }
286
+ function parseWhere(value) {
287
+ if (value === void 0 || value === null || value === "" || value === true) return null;
288
+ const raw = readJsonArg(value, "--where");
289
+ if (!raw) return null;
290
+ const rootKey = `root_${Date.now()}`;
291
+ if (Array.isArray(raw)) {
292
+ const children = [];
293
+ raw.forEach((node, index) => {
294
+ if (node && typeof node === "object") children.push(buildConditionNode(node, `${rootKey}_${index}`, rootKey));
295
+ });
296
+ if (!children.length) return null;
297
+ return { key: rootKey, relationship: "1", isParent: true, parentNode: "", mainField: true, conditionList: children };
298
+ }
299
+ if (typeof raw !== "object") throw dataValidationError("where_invalid", "--where \u987B\u4E3A\u6761\u4EF6\u6570\u7EC4\u6216\u6761\u4EF6\u6811\u5BF9\u8C61");
300
+ if (!Array.isArray(raw.conditionList) || !raw.conditionList.length) return null;
301
+ return buildConditionNode(raw, rootKey, "");
302
+ }
303
+ function parseStat(value) {
304
+ const raw = readJsonArg(value, "--stat");
305
+ const list = Array.isArray(raw) ? raw : [raw];
306
+ return list.map((item) => ({
307
+ fieldId: item.fieldId,
308
+ fieldName: item.fieldId,
309
+ objId: "",
310
+ mainField: true,
311
+ aggregator: item.aggregator || "SUM",
312
+ ...item.fieldAlias ? { fieldAlias: item.fieldAlias } : {}
313
+ }));
314
+ }
315
+ function parseOrder(value) {
316
+ const raw = readListArg(value);
317
+ if (!raw) return [];
318
+ return raw.split(",").filter((item) => item.trim()).map((item) => {
319
+ const [field, direction] = item.trim().split(/\s+/);
320
+ return {
321
+ fieldId: field,
322
+ fieldName: field,
323
+ objId: "",
324
+ isAsc: (direction || "asc").toLowerCase() !== "desc",
325
+ mainField: true
326
+ };
327
+ });
328
+ }
329
+ var TIP_FLAG_KEYS = {
330
+ tipTimeout: ["tipTimeout"],
331
+ tipTimelimit: ["tipTimelimit", "tipTimeLimit"]
332
+ };
333
+ var TIP_MSG_KEYS = {
334
+ tipTimeoutMsg: ["tipTimeoutMsg", "tipTimeoutMessage"],
335
+ tipTimelimitMsg: ["tipTimelimitMsg", "tipTimeLimitMsg", "tipTimelimitMessage", "tipTimeLimitMessage"]
336
+ };
337
+ var TIP_SCAN_MAX_DEPTH = 4;
338
+ var TIP_SCAN_MAX_ITEMS = 20;
339
+ function tipTruthy(value) {
340
+ if (value === true) return true;
341
+ if (typeof value === "number") return value === 1;
342
+ if (typeof value === "string") return ["true", "1", "yes", "y"].includes(value.trim().toLowerCase());
343
+ return false;
344
+ }
345
+ function scanTips(node, depth = 0, acc = {}) {
346
+ if (!node || typeof node !== "object" || depth > TIP_SCAN_MAX_DEPTH) return acc;
347
+ if (Array.isArray(node)) {
348
+ for (const item of node.slice(0, TIP_SCAN_MAX_ITEMS)) scanTips(item, depth + 1, acc);
349
+ return acc;
350
+ }
351
+ for (const [key, aliases] of Object.entries(TIP_FLAG_KEYS)) {
352
+ if (acc[key] !== void 0) continue;
353
+ for (const alias of aliases) {
354
+ if (tipTruthy(node[alias])) {
355
+ acc[key] = true;
356
+ break;
357
+ }
358
+ }
359
+ }
360
+ for (const [key, aliases] of Object.entries(TIP_MSG_KEYS)) {
361
+ if (acc[key] !== void 0) continue;
362
+ for (const alias of aliases) {
363
+ const value = node[alias];
364
+ if (value !== void 0 && value !== null && String(value).trim() !== "") {
365
+ acc[key] = String(value).trim();
366
+ break;
367
+ }
368
+ }
369
+ }
370
+ let seen = 0;
371
+ for (const value of Object.values(node)) {
372
+ if (seen++ >= TIP_SCAN_MAX_ITEMS) break;
373
+ if (value && typeof value === "object") scanTips(value, depth + 1, acc);
374
+ }
375
+ return acc;
376
+ }
377
+ function tipFields(tips) {
378
+ const out = {};
379
+ if (tips.tipTimeout) out.tipTimeout = true;
380
+ if (tips.tipTimeoutMsg) out.tipTimeoutMsg = tips.tipTimeoutMsg;
381
+ if (tips.tipTimelimit) out.tipTimelimit = true;
382
+ if (tips.tipTimelimitMsg) out.tipTimelimitMsg = tips.tipTimelimitMsg;
383
+ return out;
384
+ }
385
+ function tipsLines(tips) {
386
+ const lines = [];
387
+ if (tips.tipTimeout) {
388
+ lines.push(`[!] tipTimeout=true\uFF5C\u5E73\u53F0\u63D0\u793A\uFF08\u6570\u636E\u8303\u56F4\u8FC7\u5927\uFF0C\u4E0D\u662F 0 \u884C\uFF0Ccount \u8BB0 null\uFF09\uFF1A${tips.tipTimeoutMsg || "\uFF08\u5E73\u53F0\u672A\u7ED9\u51FA\u6587\u6848\uFF09"}`);
389
+ }
390
+ if (tips.tipTimelimit) {
391
+ lines.push(`[!] tipTimelimit=true\uFF5C\u5E73\u53F0\u63D0\u793A\uFF08\u6570\u636E\u5DF2\u8FD4\u56DE\uFF0C\u4F46\u5B9E\u9645\u67E5\u8BE2\u8303\u56F4\u88AB\u6536\u7A84\uFF09\uFF1A${tips.tipTimelimitMsg || "\uFF08\u5E73\u53F0\u672A\u7ED9\u51FA\u6587\u6848\uFF09"}`);
392
+ }
393
+ return lines;
394
+ }
395
+ function cell(value) {
396
+ if (value === null || value === void 0) return "";
397
+ if (typeof value === "object") {
398
+ const text = JSON.stringify(value);
399
+ return text.length > 80 ? `${text.slice(0, 80)}\u2026` : text;
400
+ }
401
+ return String(value);
402
+ }
403
+ function renderTable(title, rows, columns) {
404
+ const lines = [];
405
+ if (title) lines.push(`== ${title} ==`);
406
+ if (!rows || !rows.length) {
407
+ lines.push("(\u7A7A)");
408
+ return lines.join("\n");
409
+ }
410
+ if (columns) {
411
+ lines.push(columns.join(" "));
412
+ for (const row of rows) lines.push(columns.map((column) => cell(row?.[column])).join(" "));
413
+ return lines.join("\n");
414
+ }
415
+ for (const row of rows.slice(0, 100)) lines.push(JSON.stringify(row));
416
+ if (rows.length > 100) lines.push(`... \u5171 ${rows.length} \u884C\uFF08--json \u53D6\u5168\u91CF\uFF09`);
417
+ return lines.join("\n");
418
+ }
419
+
420
+ // src/shortcuts/data/operations/query.ts
421
+ var QUERY_PARAM_ALIASES = [
422
+ ["dimension", "dimension"],
423
+ ["confGroup", "conf-group"],
424
+ ["username", "username"],
425
+ ["startDate", "start-date"]
426
+ ];
427
+ function argStr(input, key) {
428
+ const value = input[key];
429
+ if (value === void 0 || value === null || value === true) return "";
430
+ return String(value).trim();
431
+ }
432
+ function buildQueryString(input) {
433
+ return "?" + QUERY_PARAM_ALIASES.map(([name, flag]) => {
434
+ const snake = flag.replace(/-/g, "_");
435
+ const raw = argStr(input, name) || argStr(input, snake) || argStr(input, flag);
436
+ return `${encodeURIComponent(name)}=${encodeURIComponent(raw)}`;
437
+ }).join("&");
438
+ }
439
+ async function executeQuery(input, host) {
440
+ const conn = needArg(input, "conn");
441
+ const model = needArg(input, "model");
442
+ const schema = needArg(input, "schema");
443
+ const dslRaw = needArg(input, "dsl");
444
+ const dslQuery = readJsonArg(dslRaw, "--dsl");
445
+ const body = {
446
+ connId: conn,
447
+ model,
448
+ schema,
449
+ tableId: input.table_id || input.tableId || "",
450
+ dslQuery
451
+ };
452
+ if (input.debug !== void 0 && input.debug !== null && input.debug !== "") {
453
+ const flag = String(input.debug).toLowerCase();
454
+ if (flag === "true" || flag === "1") body.debug = true;
455
+ else if (flag === "false" || flag === "0") body.debug = false;
456
+ else throw dataValidationError("debug_invalid", `--debug \u503C\u5FC5\u987B\u4E3A true \u6216 false\uFF08\u5F53\u524D: ${input.debug}\uFF09`);
457
+ }
458
+ const response = await host.request({
459
+ method: "POST",
460
+ path: `/api/dw/dsl/executeQueryDsl${buildQueryString(input)}`,
461
+ body,
462
+ headers: { "Content-Type": "application/json;charset=utf-8" }
463
+ });
464
+ const code = response?.code;
465
+ if (code !== void 0 && String(code) !== "200" && String(code) !== "0") {
466
+ const message = String(response?.msg || "");
467
+ if (/没有权限|无权限|权限不足|未授权|无权访问|无查询权限/i.test(message)) {
468
+ throw dataValidationError(
469
+ "permission_denied",
470
+ "\u5F53\u524D\u7528\u6237\u5BF9\u8BE5\u6570\u636E\u65E0\u67E5\u8BE2\u6743\u9650\uFF0C\u8BF7\u68C0\u67E5\u767B\u5F55\u6001\u662F\u5426\u6709\u6548\u6216\u8054\u7CFB\u7BA1\u7406\u5458\u5F00\u901A",
471
+ 4
472
+ );
473
+ }
474
+ }
475
+ const payload = response?.data;
476
+ const rows = Array.isArray(payload) ? payload : payload && Array.isArray(payload.records) ? payload.records : [];
477
+ const lines = [];
478
+ if (payload && !Array.isArray(payload) && payload.sql) lines.push(`SQL: ${payload.sql}`);
479
+ if (String(code) !== "200" && code !== void 0) lines.push(`code=${code} msg=${response?.msg || ""}`);
480
+ lines.push(rows.length ? renderTable(`\u7ED3\u679C ${rows.length} \u884C`, rows) : "(\u7A7A\uFF1A0 \u884C)");
481
+ return { data: response, text: lines.join("\n") };
482
+ }
483
+
484
+ // src/shortcuts/data/operations/ds.ts
485
+ var DS_GROUPS = [
486
+ [1, "\u4E1A\u52A1\u8868\u5355", "weaver-formreport-service", "form"],
487
+ [2, "\u6D41\u7A0B", "weaver-workflow-report-serviceworkflowreport", "workflow"],
488
+ [3, "\u4EFB\u52A1", "weaver-project-servicetask", "task"],
489
+ [4, "\u65E5\u5FD7", "weaver-elog-service", "elog"],
490
+ [5, "\u4F1A\u8BAE", "weaver-meeting-service", "meeting"],
491
+ [6, "\u65E5\u62A5", "weaver-blog-service", "blog"],
492
+ [7, "OKR", "weaver-wr-goal-service", "goal"],
493
+ [8, "\u6D41\u7A0B\u5217\u8868", "weaver-workflow-list-service", "workflow"],
494
+ [9, "\u8003\u52E4", "weaver-attend-service", "attend"],
495
+ [10, "CRM", "weaver-crm-service", "customer"],
496
+ [11, "\u7EC4\u7EC7\u753B\u50CF", "weaver-portrait-service", "portrait"],
497
+ [12, "\u5DE5\u4F5C\u6D41\u62A5\u544A", "weaver-workflow-report-serviceworkflow_report", "workflow"],
498
+ [13, "\u7EE9\u6548", "weaver-wr-performance-service", "kpi"],
499
+ [14, "\u9879\u76EE", "weaver-project-service", "mainline"],
500
+ [15, "\u57FA\u7840\u5B9A\u65F6\u6A21\u5757", "weaver-basic-schedule-service", "escheduler"],
501
+ [16, "\u77E5\u8BC6\u753B\u50CF", "weaver-doc-service", "document"],
502
+ [17, "HRM", "weaver-hrm-service", "hrm"],
503
+ [18, "e-builder\u62A5\u8868", "weaver-edcreportd-service", null],
504
+ [19, "e-builder\u5E94\u7528", "weaver-ebuilder-app-service", "ebuilder"],
505
+ [20, "e-builder\u8868\u5355", "weaver-ebuilder-form-service", "ebuilder"],
506
+ [21, "\u65E5\u7A0B", "weaver-calendar-service", "calendar"],
507
+ [22, "\u6587\u6863", "weaver-doc-servicedocument", "document"],
508
+ [23, "\u6587\u4EF6", "weaver-file-service", "file"],
509
+ [24, "\u516C\u6587\u7BA1\u7406", "weaver-odoc-service", "odoc"],
510
+ [25, "SCRM", "weaver-crm-market-service", "scrm"],
511
+ [26, "\u534F\u4F5C\u533A", "weaver-cowork-service", "cowork"],
512
+ [27, "\u6570\u636E\u6E90", "weaver-datasource-service", "datasource"],
513
+ [28, "\u8BA1\u5212\u62A5\u544A", "weaver-wr-plan-service", "workreport"],
514
+ [29, "\u7535\u5B50\u7B7E", "weaver-signcenter-service", "signcontract"],
515
+ [30, "\u8868\u5355\u52A0\u5BC6", "weaver-datasecurity", "datasecurity"],
516
+ [31, "\u4EBA\u4E8B", "weaver-hr-service", null],
517
+ [32, "\u52A8\u4F5C\u6D41", "weaver-esb-setting-serviceesbCustom", "esb"],
518
+ [33, "\u53D1\u7968\u4E91", "weaver-inc-biz-service", "inc"],
519
+ [34, "\u7EE9\u6548\u6838\u7B97", "weaver-ebuilder-contract-servicecmdatauFJXHS", "ebuilder"],
520
+ [35, "EB\u5408\u540C\u7BA1\u7406", "weaver-ebuilder-contract-service", null],
521
+ [36, "\u5F85\u529E\u4E8B\u9879", "weaver-my-service", null],
522
+ [37, "\u7B7E\u540D", "weaver-signature-service", null],
523
+ [38, "\u90AE\u4EF6", "weaver-mail-base-service", "email"],
524
+ [39, "\u85AA\u916C", "weaver-hrm-salary", "hrmsalary"],
525
+ [40, "\u7CFB\u7EDF\u5B89\u5168", "weaver-security-framework-service", "security"],
526
+ [41, "\u516C\u6587\u4EA4\u6362\u4E2D\u5FC3", "weaver-odocexchange-service", "odocexchange"],
527
+ [42, "\u62DB\u8058\u7BA1\u7406", "weaver-recruit-service", "recruit"],
528
+ [43, "\u5FAE\u641C", "weaver-esearch-search-service", null],
529
+ [44, "\u7EDF\u4E00\u5BA1\u6279\u4E2D\u5FC3", "weaver-intunifytodo-server-config-service", "intunifytodos"],
530
+ [45, "\u516C\u5171\u6570\u636E\u6E90", "weaver-component-web-service", "common"],
531
+ [46, "\u6570\u636E\u5206\u6790", "weaver-analyze-service", "analyze"],
532
+ [47, "\u8D22\u52A1\u6A21\u5757", "weaver-fna-expense-servicefexs", "fna"],
533
+ [48, "ESB\u8FDE\u63A5\u5668", "weaver-esb-setting-serviceesbConnect", "esb"],
534
+ [49, "AI\u8FDE\u63A5\u5668", "weaver-ai-application-service", "ai"],
535
+ [50, "\u5916\u90E8\u6D41\u7A0B", "weaver-workflow-core-serviceworkflowCoreOuterwf", "workflow"],
536
+ [51, "\u7EE9\u6548\u8003\u6838", "weaver-wr-performance-eb-service", "ebuilder"],
537
+ [52, "\u95EE\u9898\u5B9A\u4F4D\u5E73\u53F0", "weaver-tissot-service", "tissot"],
538
+ [53, "\u5DE5\u4F5C\u6D41\u57FA\u7840\u6548\u7387", "weaver-workflow-report-serviceworkflowEffReport", "workflow"],
539
+ [54, "\u5DE5\u4F5C\u6D41\u64CD\u4F5C\u8005\u6548\u7387", "weaver-workflow-report-serviceworkflowEffOperateReport", "workflow"],
540
+ [55, "\u5DE5\u4F5C\u6D41\u8282\u70B9\u6548\u7387", "weaver-workflow-report-serviceworkflowEffNodeReport", "workflow"],
541
+ [56, "\u89C4\u5219\u5F15\u64CE", "weaver-logicflow-service", "logicflow"],
542
+ [57, "\u5DE5\u4F5C\u6D41\u8868\u5355", "weaver-workflow-report-serviceworkflowFormReport", "workflow"],
543
+ [58, "\u7EDF\u4E00\u8BA4\u8BC1\u4E2D\u5FC3", "weaver-intunifyauth-server-base-service", null]
544
+ ];
545
+ var DS_CORE_GROUPS = [
546
+ "weaver-formreport-service",
547
+ "weaver-ebuilder-form-service",
548
+ "weaver-workflow-report-serviceworkflowreport"
549
+ ];
550
+ var DS_FIND_SEMANTIC_RULES = [
551
+ { tag: "\u8003\u52E4/\u5047\u671F", re: /考勤|打卡|出勤|请假|假期|年假|事假|病假|加班|外勤|工时|调休|补卡|申诉/, groups: ["weaver-attend-service", "weaver-hr-service"] },
552
+ { tag: "\u6D41\u7A0B/\u5BA1\u6279", re: /流程|审批|待办|已办|发起|抄送|传阅|征询|签字|节点|报销|申请单/, groups: ["weaver-workflow-report-serviceworkflowreport", "weaver-workflow-list-service"] },
553
+ { tag: "\u65E5\u62A5/\u5468\u62A5", re: /日报|周报|月报|年报|工作总结/, groups: ["weaver-blog-service", "weaver-wr-plan-service"] },
554
+ { tag: "\u6587\u6863/\u9644\u4EF6", re: /文档|附件|文件夹|共享|资料/, groups: ["weaver-doc-servicedocument", "weaver-doc-service", "weaver-file-service"] },
555
+ { tag: "\u9879\u76EE/\u4EFB\u52A1", re: /项目|任务|工时|里程碑|延期|验收/, groups: ["weaver-project-service", "weaver-project-servicetask"] },
556
+ { tag: "\u5BA2\u6237/\u5546\u673A", re: /客户|商机|线索|联系人|公海|销售|CRM|营销/i, groups: ["weaver-crm-service", "weaver-crm-market-service"] },
557
+ { tag: "\u4F1A\u8BAE/\u65E5\u7A0B", re: /会议|日程|日历|预约|会议室|预定/, groups: ["weaver-meeting-service", "weaver-calendar-service"] },
558
+ { tag: "\u4EBA\u4E8B/\u62DB\u8058", re: /招聘|入职|离职|offer|人才|员工|人员|通讯录|调岗|组织/i, groups: ["weaver-recruit-service", "weaver-hr-service", "weaver-hrm-service"] },
559
+ { tag: "\u85AA\u916C/\u7EE9\u6548", re: /薪酬|薪资|工资|社保|公积金|绩效|考核|KPI|OKR/i, groups: ["weaver-hrm-salary", "weaver-wr-performance-service", "weaver-wr-goal-service"] },
560
+ { tag: "\u5408\u540C/\u6536\u6B3E", re: /合同|签约|收款|回款|开票|发票|应收/, groups: ["weaver-ebuilder-contract-service", "weaver-ebuilder-contract-servicecmdatauFJXHS", "weaver-inc-biz-service"] },
561
+ { tag: "\u90AE\u4EF6/\u516C\u6587", re: /邮件|收件箱|公文|发文|档案|借阅/, groups: ["weaver-mail-base-service", "weaver-odoc-service"] },
562
+ { tag: "\u8D44\u4EA7/\u65E5\u5FD7", re: /资产|台账|日志|动作流|自动化/, groups: ["weaver-elog-service", "weaver-esb-setting-serviceesbCustom"] }
563
+ ];
564
+ function groupLabel(groupId) {
565
+ const hit = DS_GROUPS.find((item) => item[2] === groupId);
566
+ return hit ? hit[1] : null;
567
+ }
568
+ function groupMark(groupId) {
569
+ const hit = DS_GROUPS.find((item) => item[2] === groupId);
570
+ return hit ? hit[3] : null;
571
+ }
572
+ function explicitAppId(input) {
573
+ const appId = input.app_id;
574
+ return typeof appId === "string" && appId !== "" && appId !== "auto" ? appId : null;
575
+ }
576
+ var DS_LB_PATH = "/api/dw/newetl/chatBi/ds/listByPage";
577
+ async function listByPage(host, form) {
578
+ return host.request({ method: "POST", path: DS_LB_PATH, multipart: form, operation: "ds.listByPage" });
579
+ }
580
+ function fieldsForm(groupId, tableId, sourceType) {
581
+ return {
582
+ groupId,
583
+ sourceId: tableId,
584
+ sourceType,
585
+ detailFieldsGroup: "true",
586
+ enableMerge: "true",
587
+ needTableName: "true",
588
+ params: "[]"
589
+ };
590
+ }
591
+ async function fetchFields(host, input, path) {
592
+ const groupId = needArg(input, "group");
593
+ const tableId = needArg(input, "table");
594
+ const form = fieldsForm(groupId, tableId, String(input.source_type || "LOGIC"));
595
+ const appId = explicitAppId(input);
596
+ if (appId) form.appId = appId;
597
+ return host.request({ method: "POST", path, multipart: form, operation: "ds.fields" });
598
+ }
599
+ function renderFields(response) {
600
+ const lines = [];
601
+ for (const node of response?.data || []) {
602
+ lines.push(`== \u8868: ${node.name} (id=${node.id}) \u5B57\u6BB5 ${(node.fields || []).length} \u4E2A ==`);
603
+ for (const field of node.fields || []) {
604
+ lines.push([field.name, field.text, field.type, field.mainPrimaryKey ? "PK" : ""].filter(Boolean).join(" "));
605
+ }
606
+ }
607
+ return lines.length ? lines.join("\n") : "(\u7A7A\uFF1A\u672A\u8FD4\u56DE\u5B57\u6BB5)";
608
+ }
609
+ async function dsGroups(input) {
610
+ const pattern = input.pattern ? String(input.pattern) : null;
611
+ const groups = DS_GROUPS.filter((item) => !pattern || item[2].includes(pattern) || item[1].includes(pattern)).map((item) => ({ groupId: item[2], label: item[1], serviceMark: item[3] }));
612
+ const data = {
613
+ count: groups.length,
614
+ groups,
615
+ coreGroups: DS_CORE_GROUPS,
616
+ semanticRules: DS_FIND_SEMANTIC_RULES.map((rule) => ({ tag: rule.tag, groups: rule.groups })),
617
+ note: "\u5185\u7F6E\u5206\u7EC4\u6E05\u5355\uFF0C\u4EC5\u7528\u4E8E ds find \u7684\u9ED8\u8BA4\u626B\u63CF\u5019\u9009\u96C6\uFF1B\u5206\u7EC4\u968F\u73AF\u5883\u53D8\u52A8\u65F6\u7528 --groups \u663E\u5F0F\u8986\u76D6"
618
+ };
619
+ return { data, text: renderTable(`\u5185\u7F6E\u5206\u7EC4\u6E05\u5355 ${groups.length} \u4E2A`, groups, ["groupId", "label", "serviceMark"]) };
620
+ }
621
+ async function dsTables(input, host) {
622
+ const groupId = needArg(input, "group");
623
+ const form = {
624
+ name: input.name || "",
625
+ pageNo: String(input.page || "1"),
626
+ pageSize: String(input.size || "100"),
627
+ groupId,
628
+ sourceType: String(input.source_type || "LOGIC"),
629
+ dataUsage: ""
630
+ };
631
+ const appId = explicitAppId(input);
632
+ if (appId) form.appId = appId;
633
+ const response = await listByPage(host, form);
634
+ const records = response?.data?.records || [];
635
+ return {
636
+ data: response,
637
+ text: renderTable(`\u5206\u7EC4\u8868\u6E05\u5355 (total=${response?.data?.total})`, records, ["id", "name", "appId", "tableText", "detailTable", "usage"])
638
+ };
639
+ }
640
+ async function dsFields(input, host) {
641
+ const response = await fetchFields(host, input, "/api/ebuilder/common/ds/fields");
642
+ return { data: response, text: renderFields(response) };
643
+ }
644
+ async function dsFieldsDsl(input, host) {
645
+ const response = await fetchFields(host, input, "/api/dw/newetl/chatBi/ds/fieldsForDSL");
646
+ return { data: response, text: renderFields(response) };
647
+ }
648
+ async function dsList(input, host) {
649
+ const groupId = needArg(input, "group");
650
+ const tableId = needArg(input, "table");
651
+ const fieldIds = readListArg(needArg(input, "fields")).split(",").map((item) => item.trim()).filter(Boolean);
652
+ const session = await host.session();
653
+ const dto = applyAppId(
654
+ baseDto(session, tableId, groupId, Number(input.page || "1") || 1, Number(input.size || "20") || 20, "getListData"),
655
+ input.app_id
656
+ );
657
+ dto.queryFields = fieldIds.map((field) => ({ fieldId: field, fieldName: field, objId: String(tableId), mainField: true }));
658
+ dto.orderFields = parseOrder(input.order);
659
+ const conditionTree = parseWhere(input.where);
660
+ if (conditionTree) dto.conditionTrees = conditionTree;
661
+ dto.queryCount = true;
662
+ const response = await host.request({
663
+ method: "POST",
664
+ path: "/api/dw/newetl/chatBi/ds/getListDatas",
665
+ multipart: { sourceType: String(input.source_type || "LOGIC"), queryDto: dto },
666
+ operation: "ds.list"
667
+ });
668
+ const data = response?.data || {};
669
+ const lines = [...tipsLines(scanTips(response)), `== \u6570\u636E\u5217\u8868 count=${data.count} \u884C=${(data.list || []).length} ==`];
670
+ lines.push(renderTable("", data.list || [], fieldIds));
671
+ return { data: response, text: lines.join("\n") };
672
+ }
673
+ async function dsChart(input, host) {
674
+ const groupId = needArg(input, "group");
675
+ const tableId = needArg(input, "table");
676
+ const groupBy = readListArg(needArg(input, "group_by")).split(",").map((item) => item.trim()).filter(Boolean);
677
+ const statFields = parseStat(needArg(input, "stat"));
678
+ const session = await host.session();
679
+ const dto = applyAppId(
680
+ baseDto(session, tableId, groupId, Number(input.page || "1") || 1, Number(input.size || "100") || 100, "getChartData"),
681
+ input.app_id
682
+ );
683
+ dto.groupFields = groupBy.map((field) => ({ fieldId: field, fieldName: field, objId: String(tableId), mainField: true }));
684
+ dto.groupStatFields = statFields.map((stat) => ({ ...stat, objId: String(tableId) }));
685
+ const conditionTree = parseWhere(input.where);
686
+ if (conditionTree) dto.conditionTrees = conditionTree;
687
+ const response = await host.request({
688
+ method: "POST",
689
+ path: "/api/dw/newetl/chatBi/ds/getChartDatas",
690
+ multipart: { sourceType: String(input.source_type || "LOGIC"), queryDto: dto },
691
+ operation: "ds.chart"
692
+ });
693
+ const rows = response?.data || [];
694
+ return {
695
+ data: response,
696
+ text: [...tipsLines(scanTips(response)), renderTable(`\u5206\u7EC4\u805A\u5408 rows=${rows.length}`, rows)].join("\n")
697
+ };
698
+ }
699
+ async function dsStat(input, host) {
700
+ const groupId = needArg(input, "group");
701
+ const tableId = needArg(input, "table");
702
+ const statFields = parseStat(needArg(input, "stat"));
703
+ const session = await host.session();
704
+ const dto = applyAppId(baseDto(session, tableId, groupId, 1, 10, "getStatData"), input.app_id);
705
+ dto.statFields = statFields.map((stat) => ({ ...stat, objId: String(tableId) }));
706
+ const conditionTree = parseWhere(input.where);
707
+ if (conditionTree) dto.conditionTrees = conditionTree;
708
+ const response = await host.request({
709
+ method: "POST",
710
+ path: "/api/dw/newetl/chatBi/ds/getStatDatas",
711
+ multipart: { sourceType: String(input.source_type || "LOGIC"), queryDto: dto },
712
+ operation: "ds.stat"
713
+ });
714
+ const fields = response?.data?.fields || [];
715
+ const lines = tipsLines(scanTips(response));
716
+ if (fields.length) for (const field of fields) lines.push(JSON.stringify(field));
717
+ else lines.push("(\u65E0\u7EDF\u8BA1\u7ED3\u679C)");
718
+ return { data: response, text: lines.join("\n") };
719
+ }
720
+ async function dsCount(input, host) {
721
+ const groupId = needArg(input, "group");
722
+ const tableId = needArg(input, "table");
723
+ const session = await host.session();
724
+ const dto = applyAppId(baseDto(session, tableId, groupId, 1, 10, "getCountData"), input.app_id);
725
+ const conditionTree = parseWhere(input.where);
726
+ if (conditionTree) dto.conditionTrees = conditionTree;
727
+ const response = await host.request({
728
+ method: "POST",
729
+ path: "/api/dw/newetl/chatBi/ds/getCountData",
730
+ multipart: { sourceType: String(input.source_type || "LOGIC"), queryDto: dto },
731
+ operation: "ds.count"
732
+ });
733
+ const tips = scanTips(response);
734
+ return {
735
+ data: response,
736
+ text: [...tipsLines(tips), `totalCount = ${response?.data?.totalCount ?? "-"}`].join("\n")
737
+ };
738
+ }
739
+ function pickFindGroups(input, keyword) {
740
+ if (input.groups) {
741
+ return { mode: "explicit", groups: String(input.groups).split(",").map((item) => item.trim()).filter(Boolean) };
742
+ }
743
+ if (input.all_groups) return { mode: "all", groups: DS_GROUPS.map((item) => item[2]) };
744
+ const max = Math.max(Number(input.max_groups || "6") || 6, DS_CORE_GROUPS.length);
745
+ const picked = [];
746
+ const push = (groupId) => {
747
+ if (groupId && !picked.includes(groupId)) picked.push(groupId);
748
+ };
749
+ for (const groupId of DS_CORE_GROUPS) push(groupId);
750
+ for (const rule of DS_FIND_SEMANTIC_RULES) {
751
+ if (rule.re.test(keyword)) for (const groupId of rule.groups) push(groupId);
752
+ }
753
+ return { mode: "core", groups: picked.slice(0, max) };
754
+ }
755
+ async function mapLimit(items, limit, fn) {
756
+ const out = new Array(items.length);
757
+ let next = 0;
758
+ const workers = Array.from({ length: Math.max(1, Math.min(limit, items.length)) }, async () => {
759
+ for (; ; ) {
760
+ const index = next++;
761
+ if (index >= items.length) return;
762
+ out[index] = await fn(items[index], index);
763
+ }
764
+ });
765
+ await Promise.all(workers);
766
+ return out;
767
+ }
768
+ async function scanGroups(host, groupIds, keyword, sourceType, pageSize, concurrency, appId, pages) {
769
+ return mapLimit(groupIds, concurrency, async (groupId) => {
770
+ const result = {
771
+ groupId,
772
+ label: groupLabel(groupId),
773
+ serviceMark: groupMark(groupId),
774
+ records: [],
775
+ error: null,
776
+ total: null,
777
+ pagesFetched: 0
778
+ };
779
+ try {
780
+ for (let page = 1; page <= pages; page += 1) {
781
+ const form = {
782
+ name: keyword,
783
+ pageNo: String(page),
784
+ pageSize: String(pageSize),
785
+ groupId,
786
+ sourceType,
787
+ dataUsage: ""
788
+ };
789
+ if (appId) form.appId = String(appId);
790
+ const response = await listByPage(host, form);
791
+ const records = response?.data?.records || [];
792
+ if (result.total === null) result.total = response?.data?.total ?? null;
793
+ result.records = result.records.concat(records);
794
+ result.pagesFetched += 1;
795
+ if (records.length < pageSize) break;
796
+ }
797
+ } catch (error) {
798
+ result.error = String(error?.message || error);
799
+ }
800
+ return result;
801
+ });
802
+ }
803
+ function groupPriority(groupId) {
804
+ if (groupId === "weaver-ebuilder-form-service") return 100;
805
+ if (groupId === "weaver-formreport-service") return 95;
806
+ if (groupId === "weaver-workflow-report-serviceworkflowreport") return 90;
807
+ if (/workflowEff|workflowFormReport|workflow_report$/i.test(groupId)) return 20;
808
+ return 50;
809
+ }
810
+ function mergeCandidates(scan, limit) {
811
+ const map = /* @__PURE__ */ new Map();
812
+ for (const result of scan) {
813
+ for (const record of result.records) {
814
+ const groupId = record.groupId || result.groupId;
815
+ const name = String(record.originalName || record.tableText || record.name || "").trim();
816
+ const key = name.replace(/\s+/g, "").toLowerCase() || `${groupId}|${record.id}`;
817
+ const item = {
818
+ groupId,
819
+ groupLabel: result.label,
820
+ serviceMark: record.serviceMark ?? result.serviceMark ?? null,
821
+ tableId: String(record.id ?? ""),
822
+ name: String(record.tableText || record.name || name),
823
+ originalName: name,
824
+ objType: record.objType ?? null,
825
+ physicalTable: record.physicalTable ?? null,
826
+ appId: record.appId ?? null,
827
+ isPhysical: record.isPhysical ?? null,
828
+ detailTable: !!record.detailTable,
829
+ usage: record.usage ?? null,
830
+ sourceType: record.sourceType ?? null,
831
+ alsoInGroups: [],
832
+ _pri: groupPriority(groupId)
833
+ };
834
+ const previous = map.get(key);
835
+ if (!previous) {
836
+ map.set(key, item);
837
+ continue;
838
+ }
839
+ const winner = previous._pri >= item._pri ? previous : item;
840
+ const loser = previous._pri >= item._pri ? item : previous;
841
+ winner.alsoInGroups = winner.alsoInGroups.concat(
842
+ [{ groupId: loser.groupId, groupLabel: loser.groupLabel, tableId: loser.tableId, serviceMark: loser.serviceMark }],
843
+ loser.alsoInGroups || []
844
+ );
845
+ map.set(key, winner);
846
+ }
847
+ }
848
+ const list = [...map.values()].sort((a, b) => b._pri - a._pri || String(a.originalName).localeCompare(String(b.originalName)));
849
+ const max = Number(limit || "0") || 0;
850
+ return (max > 0 ? list.slice(0, max) : list).map(({ _pri, ...rest }) => rest);
851
+ }
852
+ function routeHint(candidates) {
853
+ const has = (fn) => candidates.some(fn);
854
+ if (has((c) => /workflow/i.test(c.groupId) || c.serviceMark === "workflow")) {
855
+ return { channel: "WORKFLOW", desc: "WORKFLOW \u6A21\u5757\u914D\u7F6E\u901A\u9053 \u2014\u2014 \u6D41\u7A0B\u7C7B\u95EE\u9898\u4E00\u5F8B\u8D70\u6A21\u5757\u63A5\u53E3\uFF0C\u4E0D\u7528 DSL\uFF0C\u4E5F\u4E0D\u8D70\u6570\u636E\u6E90", reason: "\u547D\u4E2D\u6D41\u7A0B\u7C7B\u5206\u7EC4" };
856
+ }
857
+ if (has((c) => c.groupId === "weaver-ebuilder-form-service" || c.serviceMark === "ebuilder")) {
858
+ return { channel: "DS_EB", desc: "\u6570\u636E\u6E90\u901A\u9053\uFF08EB \u5EFA\u6A21\u8868\u5355\uFF09\u2014\u2014 \u4E0D\u505A\u6743\u9650\u524D\u7F6E\u6821\u9A8C\uFF0CappId \u53D6\u81EA ebdf_obj.app_id", reason: "\u547D\u4E2D EB \u5206\u7EC4" };
859
+ }
860
+ if (has((c) => c.serviceMark === "form")) {
861
+ return { channel: "DS_FORM", desc: "\u6570\u636E\u6E90\u901A\u9053\uFF08\u4E1A\u52A1\u8868\u5355 / \u6D41\u7A0B\u4E1A\u52A1\u8868\u5355\uFF09", reason: "\u547D\u4E2D\u4E1A\u52A1\u8868\u5355\u5206\u7EC4" };
862
+ }
863
+ if (has((c) => c.serviceMark === "task" || c.serviceMark === "mainline")) {
864
+ return { channel: "PROJECT/PMO", desc: "\u9879\u76EE\u7C7B\uFF1APMO \u6307\u6807\u8D70 business/project-mgmt + DSL\uFF1B\u660E\u7EC6/\u4E0B\u62C9\u9009\u9879\u8D70 PROJECT \u6A21\u5757", reason: "\u547D\u4E2D\u9879\u76EE\u5206\u7EC4" };
865
+ }
866
+ if (has((c) => c.serviceMark === "attend")) return { channel: "EHR", desc: "EHR \u6A21\u5757\u914D\u7F6E\u901A\u9053\uFF08\u8003\u52E4/\u4EBA\u4E8B\uFF09", reason: "\u547D\u4E2D\u8003\u52E4\u5206\u7EC4" };
867
+ if (has((c) => c.serviceMark === "blog")) return { channel: "BLOG_DAILY", desc: "BLOG_DAILY \u6A21\u5757\u914D\u7F6E\u901A\u9053\uFF08\u65E5\u62A5\uFF09", reason: "\u547D\u4E2D\u65E5\u62A5\u5206\u7EC4" };
868
+ if (has((c) => c.serviceMark === "document")) return { channel: "DOCUMENT", desc: "DOCUMENT \u6A21\u5757\u914D\u7F6E\u901A\u9053\uFF08\u6587\u6863\uFF09", reason: "\u547D\u4E2D\u6587\u6863\u5206\u7EC4" };
869
+ if (has((c) => c.serviceMark === "customer" || c.serviceMark === "scrm")) {
870
+ return { channel: "CRM", desc: "CRM \u6A21\u5757\u914D\u7F6E\u901A\u9053\uFF08\u5BA2\u6237/\u5546\u673A/\u7EBF\u7D22\uFF09", reason: "\u547D\u4E2D CRM \u5206\u7EC4" };
871
+ }
872
+ if (has((c) => c.serviceMark === "esb")) return { channel: "ESB", desc: "\u52A8\u4F5C\u6D41\uFF08ESB\uFF09\u2014\u2014 \u65E0\u6807\u51C6\u95EE\u6570\u901A\u9053\uFF0C\u9700\u4EBA\u5DE5\u786E\u8BA4", reason: "\u4EC5\u547D\u4E2D\u52A8\u4F5C\u6D41\u5206\u7EC4" };
873
+ return { channel: "DS", desc: "\u6570\u636E\u6E90\u901A\u9053\uFF08ds list / chart / stat / count\uFF09", reason: "\u901A\u7528" };
874
+ }
875
+ async function dsFind(input, host) {
876
+ const keyword = String(input.name || input.keyword || "").trim();
877
+ if (!keyword) throw dataValidationError("missing_argument", "\u7F3A\u5C11\u5FC5\u586B\u53C2\u6570 --name <\u5173\u952E\u8BCD>");
878
+ const sourceType = String(input.source_type || "LOGIC");
879
+ const pageSize = Math.min(Math.max(Number(input.size || "100") || 100, 1), 2e3);
880
+ const pages = Math.min(Math.max(Number(input.pages || "1") || 1, 1), 50);
881
+ const concurrency = Math.max(1, Number(input.concurrency || "10") || 10);
882
+ const appId = explicitAppId(input);
883
+ const picked = pickFindGroups(input, keyword);
884
+ const startedAt = Date.now();
885
+ let scan = await scanGroups(host, picked.groups, keyword, sourceType, pageSize, concurrency, appId, pages);
886
+ const keywordNorm = keyword.replace(/\s+/g, "").toLowerCase();
887
+ const looseSample = [];
888
+ let looseDropped = 0;
889
+ let rowsScanned = 0;
890
+ const applyStrict = (results) => results.map((result) => {
891
+ rowsScanned += result.records.length;
892
+ if (input.loose) return result;
893
+ const keep = [];
894
+ const drop = [];
895
+ for (const record of result.records) {
896
+ const name = String(record.originalName || record.tableText || record.name || "").replace(/\s+/g, "").toLowerCase();
897
+ (name.includes(keywordNorm) ? keep : drop).push(record);
898
+ }
899
+ looseDropped += drop.length;
900
+ for (const item of drop.slice(0, 3)) {
901
+ if (looseSample.length < 6) {
902
+ looseSample.push({ groupId: result.groupId, name: String(item.originalName || item.tableText || item.name || "") });
903
+ }
904
+ }
905
+ return { ...result, records: keep };
906
+ });
907
+ scan = applyStrict(scan);
908
+ let escalated = false;
909
+ const escalateOk = pages * pageSize <= 2e3;
910
+ if (!scan.some((result) => result.records.length) && picked.mode === "core" && !input.no_escalate && escalateOk) {
911
+ escalated = true;
912
+ const seen = new Set(picked.groups);
913
+ const extra = DS_GROUPS.map((item) => item[2]).filter((groupId) => !seen.has(groupId));
914
+ scan = scan.concat(applyStrict(await scanGroups(host, extra, keyword, sourceType, pageSize, concurrency, appId, pages)));
915
+ }
916
+ const elapsedMs = Date.now() - startedAt;
917
+ const okScan = scan.filter((result) => !result.error);
918
+ const errs = scan.filter((result) => result.error);
919
+ if (!okScan.length && errs.length && errs.some((result) => /登录态失效|401/.test(String(result.error)))) {
920
+ throw dataValidationError(
921
+ "session_expired",
922
+ "\u767B\u5F55\u6001\u5931\u6548\uFF1A\u8BF7\u91CD\u65B0\u767B\u5F55 weaver-work-cli\uFF08`weaver-work-cli auth login --base-url <\u57DF\u540D>`\uFF09\u540E\u91CD\u8BD5\uFF08\u672C\u6B21\u672A\u53D6\u5230\u4EFB\u4F55\u5206\u7EC4\uFF09",
923
+ 2
924
+ );
925
+ }
926
+ const candidates = mergeCandidates(scan, input.limit);
927
+ const data = {
928
+ keyword,
929
+ sourceType,
930
+ scanMode: picked.mode + (escalated ? "+escalated" : ""),
931
+ scannedGroups: scan.length,
932
+ hitGroups: scan.filter((result) => result.records.length).length,
933
+ escalated,
934
+ elapsedMs,
935
+ concurrency,
936
+ candidates,
937
+ routeHint: routeHint(candidates),
938
+ nameFilter: input.loose ? { serverSide: false, filtered: false, pages, pageSize, rowsScanned, note: "--loose\uFF1A\u672A\u505A\u672C\u5730\u8FC7\u6EE4\uFF0C\u76F4\u63A5\u91C7\u7528\u540E\u7AEF\u8FD4\u56DE" } : {
939
+ serverSide: false,
940
+ filtered: true,
941
+ pages,
942
+ pageSize,
943
+ rowsScanned,
944
+ dropped: looseDropped,
945
+ sample: looseSample,
946
+ note: `\u7AEF\u70B9 /api/dw/newetl/chatBi/ds/listByPage **\u5F53\u524D\u5FFD\u7565 name**\uFF08\u540E\u7AEF\u5F85\u5347\u7EA7\uFF09\u21D2 \u672C\u6B21\u4E3A\u300C\u6293 ${pages} \u9875 \xD7 ${pageSize} \u884C + \u672C\u5730\u6309\u8868\u540D\u8FC7\u6EE4\u300D\uFF0C\u5171\u6BD4\u5BF9 ${rowsScanned} \u884C\uFF1B**\u672A\u547D\u4E2D\u53EA\u4EE3\u8868\u672A\u843D\u5728\u8BE5\u7A97\u53E3\u5185\uFF0C\u4E0D\u7B49\u4E8E\u8BE5\u8868\u4E0D\u5B58\u5728**\uFF08\u82E5\u8BE5\u5206\u7EC4\u884C\u6570 > ${pages * pageSize} \u8BF7\u8C03\u5927 --size/--pages\uFF09\u3002\u540E\u7AEF\u652F\u6301 name \u540E\u81EA\u52A8\u6062\u590D\u7CBE\u786E\u8FC7\u6EE4\uFF0C\u65E0\u9700\u6539\u8C03\u7528\u65B9\u5F0F\u3002`
947
+ },
948
+ scopeNote: scan.some((result) => result.groupId === "weaver-ebuilder-form-service") ? appId ? `\u672C\u6B21\u5DF2\u5E26 --app-id=${appId}\uFF08EB \u5206\u7EC4\u6309\u5E94\u7528\u5206\u57DF\uFF0C\u7528\u4E8E\u9650\u5B9A/\u5BF9\u9F50\u5E94\u7528\u8303\u56F4\uFF09` : "\u26A0\uFE0F \u672C\u6B21\u672A\u5E26 --app-id\uFF1AEB \u5206\u7EC4\uFF08weaver-ebuilder-form-service\uFF09\u6309\u5E94\u7528\u5206\u57DF\uFF0C\u5982\u9700\u9650\u5B9A\u67D0\u4E2A\u5E94\u7528\u8BF7\u5E26 --app-id <\u8BE5\u5E94\u7528ID>" : null,
949
+ errors: errs.map((result) => ({ groupId: result.groupId, error: result.error }))
950
+ };
951
+ const lines = [
952
+ `== \u627E\u8868\u300C${keyword}\u300D\u626B\u63CF ${data.scannedGroups} \u7EC4 / \u6293\u53D6 ${rowsScanned} \u884C / \u547D\u4E2D ${data.hitGroups} \u7EC4 (${elapsedMs}ms${escalated ? "\uFF0C\u5DF2\u5347\u7EA7\u5168\u626B" : ""}) ==`
953
+ ];
954
+ if (!candidates.length) {
955
+ lines.push(`(\u672A\u547D\u4E2D) \u26A0\uFE0F \u7AEF\u70B9\u5F53\u524D\u5FFD\u7565 name\uFF0C\u672C\u6B21\u662F\u300C\u6293 ${pages} \u9875 \xD7 ${pageSize} \u884C + \u672C\u5730\u8FC7\u6EE4\u300D\u6BD4\u5BF9 ${rowsScanned} \u884C\uFF1B`);
956
+ lines.push(` **\u672A\u547D\u4E2D \u2260 \u8BE5\u8868\u4E0D\u5B58\u5728** \u2014\u2014 \u8BE5\u5206\u7EC4\u884C\u6570\u82E5\u8D85\u8FC7 ${pages * pageSize}\uFF0C\u8BF7\u8C03\u5927 --size\uFF08\u22642000\uFF09/--pages\uFF08\u226450\uFF09\u518D\u8BD5\uFF1B`);
957
+ lines.push(" \u4E5F\u53EF\u663E\u5F0F\u6307\u5B9A --groups a,b / --all-groups\uFF1B\u5206\u7EC4\u6E05\u5355\u89C1 ds groups\u3002");
958
+ } else {
959
+ for (const candidate of candidates) {
960
+ const extra = candidate.alsoInGroups?.length ? ` [\u540C\u5B9E\u4F53\u4EA6\u89C1\u4E8E: ${candidate.alsoInGroups.map((item) => item.groupId).join(", ")}]` : "";
961
+ lines.push([
962
+ candidate.groupId,
963
+ candidate.tableId,
964
+ candidate.originalName || candidate.name,
965
+ candidate.physicalTable ? `\u7269\u7406\u8868=${candidate.physicalTable}` : "",
966
+ candidate.appId ? `appId=${candidate.appId}` : ""
967
+ ].filter(Boolean).join(" ") + extra);
968
+ }
969
+ }
970
+ lines.push(`\u8DEF\u7531\u5EFA\u8BAE: ${data.routeHint.channel} \u2014\u2014 ${data.routeHint.desc}`);
971
+ if (data.scopeNote) lines.push(`\u8303\u56F4\u63D0\u793A: ${data.scopeNote}`);
972
+ if (errs.length) lines.push(`\u26A0 \u6709 ${errs.length} \u4E2A\u5206\u7EC4\u8BF7\u6C42\u5931\u8D25\uFF08--json \u770B\u8BE6\u60C5\uFF09`);
973
+ return { data, text: lines.join("\n") };
974
+ }
975
+ function collectFieldNodes(list, out, subName) {
976
+ for (const field of list || []) {
977
+ if (!field) continue;
978
+ if (field.isDetailtable) {
979
+ const node = { subTableName: field.name, fields: [] };
980
+ collectFieldNodes(field.fields, node.fields, field.name);
981
+ out.push({ __detail: true, ...node });
982
+ } else {
983
+ out.push({
984
+ name: field.name,
985
+ text: field.text ?? null,
986
+ type: field.type ?? null,
987
+ dbFieldType: field.dbFieldType ?? null,
988
+ isPK: !!field.mainPrimaryKey,
989
+ subTable: subName || null,
990
+ dataKey: field.config && field.config.dataKey || null,
991
+ formTableId: field.config && field.config.formTableId || null
992
+ });
993
+ }
994
+ }
995
+ }
996
+ function normalizeFieldsResponse(response) {
997
+ const node = (response?.data || [])[0] || {};
998
+ const flat = [];
999
+ collectFieldNodes(node.fields, flat, null);
1000
+ const main = flat.filter((item) => !item.__detail);
1001
+ const detail = flat.filter((item) => item.__detail).map((item) => ({ subTableName: item.subTableName, fieldCount: item.fields.length, fields: item.fields }));
1002
+ return {
1003
+ tableName: node.name ?? null,
1004
+ tableId: node.id ?? null,
1005
+ mainCount: main.length,
1006
+ detailCount: detail.reduce((sum, item) => sum + item.fieldCount, 0),
1007
+ main,
1008
+ detail
1009
+ };
1010
+ }
1011
+ function relatedHint(groupId, detailCount) {
1012
+ if (groupId === "weaver-ebuilder-form-service") {
1013
+ return {
1014
+ likelyApplicable: true,
1015
+ tableOrigin: "eb",
1016
+ note: `EB \u8868\uFF1A\u6309 ebdf_obj \u22C8 form_table \u22C8 form \u4E09\u8868 JOIN \u5B9A\u4F4D\uFF0C\u518D\u7528 form_field / form_table_field \u63D0\u5173\u8054\u5B57\u6BB5\uFF1B\u660E\u7EC6\u5B50\u8868\u8D70 sub_form\uFF08\u672C\u8868\u660E\u7EC6\u5B57\u6BB5 ${detailCount} \u4E2A\uFF09`
1017
+ };
1018
+ }
1019
+ if (/^weaver-workflow/.test(groupId)) {
1020
+ return { likelyApplicable: true, tableOrigin: "flow", note: "\u6D41\u7A0B\u76F8\u5173\u8868\uFF1A\u6309 ec_weaver_wfp_fusion \u7684 form_field / form_table_field \u63D0\u5173\u8054\u5B57\u6BB5" };
1021
+ }
1022
+ if (groupId === "weaver-formreport-service") {
1023
+ return {
1024
+ likelyApplicable: false,
1025
+ tableOrigin: "form-report",
1026
+ note: "\u4E1A\u52A1\u8868\u5355\uFF08formreport\uFF09\uFF1A\u8868\u540D\u662F\u4E2D\u6587\u663E\u793A\u540D\u3001\u975E\u7269\u7406\u8868\u540D \u21D2 relate-fields-extract \u7684 \u2460ETL \u2461SQL\u89C6\u56FE \u2462\u2463EB \u2464\u2465\u6D41\u7A0B \u516D\u7C7B\u5224\u5B9A\u5168\u90E8\u4E0D\u9002\u7528\uFF0C\u8BE5\u8DF3\u5FC5\u7136\u7A7A\u8F6C\uFF0C**\u4E0D\u8981\u53D1\u8D77**"
1027
+ };
1028
+ }
1029
+ return { likelyApplicable: false, tableOrigin: "unknown", note: "\u975E EB / \u975E\u6D41\u7A0B\u8868\uFF0C\u5173\u8054\u5B57\u6BB5\u63D0\u53D6\u901A\u5E38\u4E0D\u9002\u7528\uFF1B\u5982\u786E\u9700\u5148\u6309\u8868\u540D\u5F62\u6001\uFF08sv_ / uf_ / \u7CFB\u7EDF\u8868\u540D\uFF09\u4EBA\u5DE5\u786E\u8BA4" };
1030
+ }
1031
+ async function dsDescribe(input, host) {
1032
+ const groupId = needArg(input, "group");
1033
+ const tableId = String(needArg(input, "table"));
1034
+ const sourceType = String(input.source_type || "LOGIC");
1035
+ const startedAt = Date.now();
1036
+ const branches = await Promise.all([
1037
+ (async () => {
1038
+ try {
1039
+ const form = fieldsForm(groupId, tableId, sourceType);
1040
+ const appId = explicitAppId(input);
1041
+ if (appId) form.appId = appId;
1042
+ const response = await host.request({
1043
+ method: "POST",
1044
+ path: "/api/ebuilder/common/ds/fields",
1045
+ multipart: form,
1046
+ operation: "ds.describe.fields"
1047
+ });
1048
+ return { key: "fields", value: normalizeFieldsResponse(response) };
1049
+ } catch (error) {
1050
+ return { key: "fields", error: String(error?.message || error) };
1051
+ }
1052
+ })(),
1053
+ (async () => {
1054
+ const skillKey = input.skill || "data-source-query";
1055
+ try {
1056
+ const response = await host.request({
1057
+ method: "GET",
1058
+ path: "/api/dw/newetl/chatBi/skill/getChatDocsBySkillKey",
1059
+ query: { skillKey, sourceType, sourceGroupId: groupId, sourceTableId: tableId },
1060
+ operation: "ds.describe.lexicon"
1061
+ });
1062
+ const data2 = response?.data;
1063
+ const missing = !data2 || !Array.isArray(data2.nouns);
1064
+ return {
1065
+ key: "lexicon",
1066
+ value: {
1067
+ skillKey,
1068
+ sourceType,
1069
+ sourceGroupId: groupId,
1070
+ sourceTableId: tableId,
1071
+ noLexicon: missing,
1072
+ count: missing ? 0 : data2.nouns.length,
1073
+ nouns: missing ? [] : data2.nouns.map((n) => ({
1074
+ keyword: n.keyword ?? null,
1075
+ synonyms: n.synonyms ?? null,
1076
+ wordExplain: n.wordExplain ?? null
1077
+ })),
1078
+ note: missing ? `\u8BE5\u6570\u636E\u96C6\u65E0\u8BCD\u5E93\uFF08\u540E\u7AEF\uFF1A${response?.msg || "\u672A\u8FD4\u56DE nouns"}\uFF09\u2014\u2014 \u56DB\u53C2\u6570\u5747\u53D6\u81EA\u672C\u6B21\u8C03\u7528\uFF0C\u6545\u4E3A**\u786E\u5B9A\u7ED3\u8BBA**\uFF1B\u6309\u94C1\u5F8B\u5982\u5B9E\u8BF4\u660E\u300E\u8BE5\u6570\u636E\u96C6\u6682\u65E0\u540D\u8BCD\u89E3\u91CA\u300F\uFF0C\u4E0D\u81EA\u52A8\u5EFA\u5E93\u3001\u4E0D\u65B0\u589E\u540D\u8BCD` : "\u8BCD\u5E93\u547D\u4E2D\uFF1A\u987B\u5148\u628A\u6BCF\u6761\u89C4\u5219\u9010\u6761\u6620\u5C04\u5230 --where / --fields / --group-by / --stat \u5E76\u81EA\u68C0\u65E0\u9057\u6F0F\uFF0C\u518D\u751F\u6210\u67E5\u8BE2"
1079
+ }
1080
+ };
1081
+ } catch (error) {
1082
+ return { key: "lexicon", error: String(error?.message || error) };
1083
+ }
1084
+ })()
1085
+ ]);
1086
+ const data = { groupId, groupLabel: groupLabel(groupId), tableId, sourceType, branches: branches.length };
1087
+ const errors = [];
1088
+ for (const branch of branches) {
1089
+ if (branch.error) {
1090
+ data[branch.key] = { error: branch.error };
1091
+ errors.push({ branch: branch.key, error: branch.error });
1092
+ } else {
1093
+ data[branch.key] = branch.value;
1094
+ }
1095
+ }
1096
+ data.relatedFields = relatedHint(groupId, data.fields?.detailCount || 0);
1097
+ data.channelHint = routeHint([{ groupId, serviceMark: groupMark(groupId) }]);
1098
+ data.permissionNote = groupId === "weaver-ebuilder-form-service" ? "\u8BE5\u5206\u7EC4\u662F EB \u5EFA\u6A21\u8868\u5355\uFF1A\u53D6\u6570\u4E0D\u518D\u505A\u6743\u9650\u524D\u7F6E\u6821\u9A8C\uFF0C--app-id \u76F4\u63A5\u53D6 ebdf_obj.app_id\uFF08obj_id = ebdf_obj.id = \u6570\u636E\u6E90 tableId\uFF09" : "\u975E EB \u5206\u7EC4\uFF0C\u6570\u636E\u6E90\u901A\u9053\u65E0\u9700 appId";
1099
+ data.elapsedMs = Date.now() - startedAt;
1100
+ if (errors.length && input.require) {
1101
+ throw dataValidationError("describe_failed", `describe \u5B58\u5728\u5931\u8D25\u5206\u652F\uFF0C--require \u4E0B\u4E0D\u7EE7\u7EED\uFF1A${JSON.stringify(errors)}`, 7);
1102
+ }
1103
+ const fields = data.fields || {};
1104
+ const lexicon = data.lexicon || {};
1105
+ const lines = [`== describe ${groupId} / ${tableId} (${data.elapsedMs}ms\uFF0C\u5E76\u53D1 ${branches.length} \u8DEF) ==`];
1106
+ lines.push(fields.error ? `\u5B57\u6BB5: \u5931\u8D25 ${fields.error}` : `\u5B57\u6BB5: \u4E3B\u8868 ${fields.mainCount} \u4E2A\uFF0C\u660E\u7EC6 ${fields.detailCount} \u4E2A\uFF08\u8868\u540D ${fields.tableName ?? "-"}\uFF09`);
1107
+ lines.push(lexicon.error ? `\u8BCD\u5E93: \u5931\u8D25 ${lexicon.error}` : `\u8BCD\u5E93: ${lexicon.noLexicon ? "\u8BE5\u6570\u636E\u96C6\u65E0\u8BCD\u5E93" : `\u547D\u4E2D ${lexicon.count} \u6761\uFF08skill=${lexicon.skillKey}\uFF09`}`);
1108
+ lines.push(`\u5173\u8054\u5B57\u6BB5: ${data.relatedFields.likelyApplicable ? `\u9002\u7528\uFF08${data.relatedFields.tableOrigin}\uFF09` : `\u4E0D\u9002\u7528\uFF08${data.relatedFields.tableOrigin}\uFF09`} \u2014\u2014 ${data.relatedFields.note}`);
1109
+ lines.push(`\u901A\u9053\u63D0\u793A: ${data.channelHint.channel} \u2014\u2014 ${data.channelHint.desc}`);
1110
+ lines.push(`\u6743\u9650: ${data.permissionNote}`);
1111
+ return { data, text: lines.join("\n") };
1112
+ }
1113
+
1114
+ // src/shortcuts/data/operations/attend.ts
1115
+ function defaultMonthRange() {
1116
+ const now = /* @__PURE__ */ new Date();
1117
+ const year = now.getFullYear();
1118
+ const month = now.getMonth() + 1;
1119
+ const lastDay = new Date(year, month, 0).getDate();
1120
+ const pad = (value) => String(value).padStart(2, "0");
1121
+ return { begin: `${year}-${pad(month)}-01`, end: `${year}-${pad(month)}-${pad(lastDay)}` };
1122
+ }
1123
+ async function attendStatis(input, host) {
1124
+ const session = await host.session();
1125
+ const userId = String(input.user || session.userId || "");
1126
+ if (!userId) {
1127
+ throw dataValidationError("missing_argument", "\u7F3A\u5C11\u67E5\u8BE2\u4EBA\u5458\uFF1A--user <\u4EBA\u5458ID>\uFF08\u67E5\u672C\u4EBA\u53EF\u4E0D\u4F20\uFF0C\u9ED8\u8BA4\u5F53\u524D\u767B\u5F55\u7528\u6237\uFF09");
1128
+ }
1129
+ const range = defaultMonthRange();
1130
+ const body = {
1131
+ beginDate: String(input.begin || range.begin),
1132
+ endDate: String(input.end || range.end),
1133
+ userId
1134
+ };
1135
+ const response = await host.request({
1136
+ method: "POST",
1137
+ path: "/api/attend/web/attendInfoV2/getAttendInfoStatis",
1138
+ body,
1139
+ operation: "attend.statis"
1140
+ });
1141
+ if (String(response?.code) !== "200") {
1142
+ const message = String(response?.msg || "");
1143
+ if (/没有权限|无权限|权限不足|未授权|无权访问|无查询权限/i.test(message)) {
1144
+ throw dataValidationError(
1145
+ "permission_denied",
1146
+ "\u5F53\u524D\u7528\u6237\u5BF9\u8BE5\u4EBA\u5458\u8003\u52E4\u6570\u636E\u65E0\u67E5\u8BE2\u6743\u9650\uFF0C\u8BF7\u68C0\u67E5\u767B\u5F55\u6001\u6216\u8054\u7CFB\u7BA1\u7406\u5458\u5F00\u901A",
1147
+ 4
1148
+ );
1149
+ }
1150
+ return { data: response, text: `code=${response?.code} msg=${message}` };
1151
+ }
1152
+ const data = response?.data || {};
1153
+ const list = Array.isArray(data.vacationBalanceList) ? data.vacationBalanceList : [];
1154
+ const lines = tipsLines(scanTips(response));
1155
+ if (!list.length) {
1156
+ lines.push(`(\u7A7A\uFF1A\u8BE5\u4EBA\u5458\u65E0\u5047\u671F\u4F59\u989D\u6570\u636E) userId=${userId} ${body.beginDate}~${body.endDate}`);
1157
+ return { data: response, text: lines.join("\n") };
1158
+ }
1159
+ lines.push(`== \u8003\u52E4\u5047\u671F\u4F59\u989D userId=${userId}\uFF08${body.beginDate} ~ ${body.endDate}\uFF09==`);
1160
+ for (const item of list) {
1161
+ lines.push(`${item.title || item.id || "?"}${item.id ? ` [${item.id}]` : ""}`);
1162
+ if (Array.isArray(item.data) && item.data.length) {
1163
+ lines.push(` ${item.data.map((cell2) => `${cell2.name || cell2.key}=${cell2.value ?? ""}`).join(" ")}`);
1164
+ }
1165
+ }
1166
+ return { data: response, text: lines.join("\n") };
1167
+ }
1168
+
1169
+ // src/shortcuts/data/operations/field.ts
1170
+ function customParamOf(input) {
1171
+ if (input.form_param) return { formParam: input.form_param };
1172
+ if (input.eb_browser_param) return { ebBrowserForEditParam: readJsonArg(input.eb_browser_param, "--eb-browser-param") };
1173
+ if (input.property_type) return { propertyType: input.property_type };
1174
+ return {};
1175
+ }
1176
+ async function fieldName2id(input, host) {
1177
+ const module = needArg(input, "module");
1178
+ const type = needArg(input, "type");
1179
+ const name = needArg(input, "name");
1180
+ const body = { newly: 1, searchValue: name, ...customParamOf(input) };
1181
+ const response = await host.request({
1182
+ method: "POST",
1183
+ path: `/api/${module}/common/browser/complete/${type}`,
1184
+ body,
1185
+ operation: "field.name2id"
1186
+ });
1187
+ const rows = response?.data?.data || [];
1188
+ if (!rows.length) return { data: response, text: "(\u672A\u5339\u914D\u5230\u540D\u79F0\u5BF9\u5E94 ID)" };
1189
+ const rendered = rows.map((row) => ({ id: row.id, name: row.name ?? row.title ?? "" }));
1190
+ return {
1191
+ data: response,
1192
+ text: renderTable(`name\u2192id \u5019\u9009 ${rows.length} \u6761`, rendered, ["id", "name"])
1193
+ };
1194
+ }
1195
+ async function fieldOptions(input, host) {
1196
+ const fieldName = needArg(input, "field_name", "field-name");
1197
+ const objId = needArg(input, "obj_id", "obj-id");
1198
+ const groupId = needArg(input, "group");
1199
+ const sourceType = String(input.source_type || "LOGIC");
1200
+ const response = await host.request({
1201
+ method: "GET",
1202
+ path: "/api/ebuilder/common/ds/options",
1203
+ query: { fieldName, objId, sourceType, groupId },
1204
+ operation: "field.options"
1205
+ });
1206
+ const rows = Array.isArray(response?.data) ? response.data : [];
1207
+ if (!rows.length) {
1208
+ return {
1209
+ data: response,
1210
+ text: `(\u7A7A\uFF1A\u8BE5\u5B57\u6BB5\u65E0\u9009\u9879\u6216\u53C2\u6570\u4E0D\u5339\u914D) code=${response?.code ?? ""} msg=${response?.msg || ""}`
1211
+ };
1212
+ }
1213
+ return { data: response, text: renderTable(`\u9009\u9879\u6E05\u5355 ${rows.length} \u9879`, rows, ["id", "name", "archive"]) };
1214
+ }
1215
+
1216
+ // src/shortcuts/data/operations/noun.ts
1217
+ var DOC_SCOPE_PATH = "/api/dw/newetl/chatBi/doc/getChatBiDocByScopeId";
1218
+ function normalizeDoc(doc) {
1219
+ return {
1220
+ keyword: doc.keyword ?? null,
1221
+ synonyms: doc.synonyms ?? null,
1222
+ wordExplain: doc.wordExplain ?? null,
1223
+ allScope: doc.allScope ?? null,
1224
+ scopeEffectId: doc.scopeEffectId ?? null,
1225
+ docType: doc.docType ?? null
1226
+ };
1227
+ }
1228
+ function parseScopeIds(value) {
1229
+ const raw = String(readListArg(value) ?? "").trim();
1230
+ const ids = raw.split(/[,\s]+/).map((item) => item.trim().replace(/^["']|["']$/g, "")).filter(Boolean);
1231
+ if (!ids.length) {
1232
+ throw dataValidationError("missing_argument", "--ids \u4E3A\u7A7A\uFF1A\u8BF7\u4F20\u6570\u636E\u96C6 id \u5217\u8868\uFF08\u5982 --ids 1060565684758507544,1060565684758507545 \u6216 --ids @ids.json\uFF09");
1233
+ }
1234
+ for (const id of ids) {
1235
+ if (!/^\d+$/.test(id)) {
1236
+ throw dataValidationError("ids_invalid", `--ids \u542B\u975E\u6CD5\u9879\u300C${id}\u300D\uFF08\u987B\u4E3A\u6570\u5B57\u578B\u6570\u636E\u96C6 id\uFF0C\u53D6\u81EA scene items \u7684\u6761\u76EE id\uFF09`);
1237
+ }
1238
+ if (BigInt(id) > 9223372036854775807n) throw dataValidationError("ids_invalid", `--ids \u542B\u8D85\u51FA Long \u4E0A\u9650\u7684 id\uFF1A${id}`);
1239
+ }
1240
+ return [...new Set(ids)];
1241
+ }
1242
+ async function nounList(input, host) {
1243
+ const skill = needArg(input, "skill");
1244
+ const query = { skillKey: skill };
1245
+ if (input.source_type) query.sourceType = String(input.source_type);
1246
+ if (input.source_group) query.sourceGroupId = String(input.source_group);
1247
+ if (input.source_table) query.sourceTableId = String(input.source_table);
1248
+ const response = await host.request({
1249
+ method: "GET",
1250
+ path: "/api/dw/newetl/chatBi/skill/getChatDocsBySkillKey",
1251
+ query,
1252
+ operation: "noun.list"
1253
+ });
1254
+ const data = response?.data;
1255
+ if (!data || !data.nouns) {
1256
+ return { data: response, text: `(\u8BE5 skill \u8BCD\u5E93\u4E0D\u5B58\u5728\u6216\u4E3A\u7A7A) msg=${response?.msg || ""}` };
1257
+ }
1258
+ const lines = [`== \u540D\u8BCD\u89E3\u91CA ${data.nouns.length} \u6761 (skill=${skill}) ==`];
1259
+ for (const noun of data.nouns) {
1260
+ lines.push(`\u3010${noun.keyword || ""}\u3011${noun.synonyms ? ` \u540C\u4E49:${noun.synonyms}` : ""}`);
1261
+ if (noun.wordExplain) lines.push(` ${String(noun.wordExplain).replace(/\n/g, " ")}`);
1262
+ }
1263
+ return { data: response, text: lines.join("\n") };
1264
+ }
1265
+ async function nounScope(input, host) {
1266
+ const ids = parseScopeIds(needArg(input, "ids"));
1267
+ const response = await host.request({
1268
+ method: "POST",
1269
+ path: DOC_SCOPE_PATH,
1270
+ body: ids.map(String),
1271
+ operation: "noun.scope"
1272
+ });
1273
+ const bad = response && typeof response === "object" && !Array.isArray(response) && (response.code !== void 0 && Number(response.code) !== 0 || response.fail === true);
1274
+ if (bad) {
1275
+ throw dataApiError("noun_scope_failed", `getChatBiDocByScopeId \u4E1A\u52A1\u5931\u8D25\uFF1Acode=${response.code} msg=${response.msg || "(\u65E0 msg)"}`, {
1276
+ code: response.code
1277
+ });
1278
+ }
1279
+ const docs = (response && response.data || []).map(normalizeDoc);
1280
+ const globalCount = docs.filter((doc) => doc.allScope === 1).length;
1281
+ const scopedCount = docs.filter((doc) => doc.allScope !== 1).length;
1282
+ const lines = [`== \u8BCD\u5E93 ${docs.length} \u6761\uFF08\u751F\u6548\u8303\u56F4 id ${ids.length} \u4E2A\uFF1B\u5168\u5C40 ${globalCount} \uFF0B \u6570\u636E\u96C6\u7EA7 ${scopedCount}\uFF09==`];
1283
+ if (!docs.length) {
1284
+ lines.push("(\u7A7A\u8BCD\u5E93\uFF1A\u8BE5\u73AF\u5883\u672A\u8FD4\u56DE\u4EFB\u4F55\u8BCD\u5E93\u6761\u76EE)");
1285
+ } else {
1286
+ for (const doc of docs) {
1287
+ const tag = doc.allScope === 1 ? "\u5168\u5C40" : doc.allScope === 2 ? "Skill" : "\u6570\u636E\u96C6";
1288
+ const scope = doc.allScope === 1 ? "\u5168\u90E8\u6570\u636E" : doc.scopeEffectId || "";
1289
+ lines.push(`\u3010${doc.keyword || ""}\u3011${doc.synonyms ? ` \u540C\u4E49:${doc.synonyms}` : ""} [${tag} ${scope}]`);
1290
+ if (doc.wordExplain) lines.push(` ${String(doc.wordExplain).replace(/\n/g, " ")}`);
1291
+ }
1292
+ if (!scopedCount) lines.push("(\u63D0\u793A\uFF1A\u672C\u6B21\u53EA\u547D\u4E2D\u5168\u5C40\u8BCD\u5E93\uFF0C\u6240\u9009\u6570\u636E\u96C6\u5747\u65E0\u4E13\u5C5E\u8BCD\u5E93 \u2014\u2014 \u4E3A\u786E\u5B9A\u7ED3\u8BBA)");
1293
+ }
1294
+ return { data: { scopeIds: ids, count: docs.length, globalCount, scopedCount, docs }, text: lines.join("\n") };
1295
+ }
1296
+
1297
+ // src/shortcuts/data/operations/conf.ts
1298
+ import { readFileSync as readFileSync2 } from "node:fs";
1299
+ var CONF_PREFIX_TYPE = [["CONN_", "conn"], ["DS_", "ds"], ["WF_", "wf"], ["API_", "api"]];
1300
+ var CONF_GET_PATH = "/api/dw/newetl/chatBi/getChatBiConfigMap";
1301
+ var CONF_BATCH_PATH = "/api/dw/newetl/chatBi/batchGetChatBiConfigMap";
1302
+ var CONF_BATCH_GROUP_PATH = "/api/dw/newetl/chatBi/batchGetChatBiConfigMapByTypeAndGroup";
1303
+ var CONF_ADD_PATH = "/api/dw/newetl/chatBi/batchAddChatBiConfigMap";
1304
+ var CONF_UPDATE_PATH = "/api/dw/newetl/chatBi/updateChatBiConfigMap";
1305
+ var CONF_DELETE_PATH = "/api/dw/newetl/chatBi/deleteChatBiConfigMap";
1306
+ var CONF_TOKEN_RE = /#\{([A-Z][A-Z0-9_]{2,})\}/g;
1307
+ function confKeyType(key, explicitType) {
1308
+ if (typeof explicitType === "string" && explicitType) return explicitType;
1309
+ for (const [prefix, type] of CONF_PREFIX_TYPE) {
1310
+ if (key.startsWith(prefix)) return type;
1311
+ }
1312
+ throw dataValidationError(
1313
+ "conf_type_unknown",
1314
+ `\u65E0\u6CD5\u7531 confKey \u63A8\u5BFC confType\uFF08\u9700 CONN_/DS_/WF_/API_ \u524D\u7F00\u6216\u663E\u5F0F --type\uFF09: ${key}`
1315
+ );
1316
+ }
1317
+ function useGroup(confType, group) {
1318
+ return confType === "api" || group !== void 0 && group !== null && group !== "";
1319
+ }
1320
+ function putGroup(body, confType, group) {
1321
+ if (useGroup(confType, group)) body.confGroup = group === void 0 || group === null ? "" : String(group);
1322
+ return body;
1323
+ }
1324
+ function groupSuffix(confType, group) {
1325
+ return useGroup(confType, group) ? `&confGroup=${encodeURIComponent(group === void 0 || group === null ? "" : String(group))}` : "";
1326
+ }
1327
+ function itemId(item) {
1328
+ const group = item?.confGroup;
1329
+ return group ? `${group}|${item?.confKey || ""}` : item?.confKey || "";
1330
+ }
1331
+ function lookup(map, item) {
1332
+ return map[itemId(item)] || map[item.confKey];
1333
+ }
1334
+ function normalizeBatch(payload) {
1335
+ const data = payload?.data ?? null;
1336
+ const out = {};
1337
+ const put = (row, fallbackKey) => {
1338
+ if (!row || typeof row !== "object") return;
1339
+ const key = row.confKey || row.conf_key || fallbackKey;
1340
+ if (!key) return;
1341
+ if (row.confGroup === void 0 && row.conf_group !== void 0 && row.conf_group !== null && row.conf_group !== "") {
1342
+ row.confGroup = row.conf_group;
1343
+ }
1344
+ out[itemId({ confGroup: row.confGroup, confKey: key })] = row;
1345
+ };
1346
+ if (Array.isArray(data)) for (const row of data) put(row);
1347
+ else if (data && typeof data === "object") for (const [key, value] of Object.entries(data)) put(value, key);
1348
+ return out;
1349
+ }
1350
+ async function confGetData(host, confType, key, silent, group) {
1351
+ let response;
1352
+ try {
1353
+ response = await host.request({
1354
+ method: "GET",
1355
+ path: `${CONF_GET_PATH}?confType=${encodeURIComponent(confType)}&confKey=${encodeURIComponent(key)}${groupSuffix(confType, group)}`,
1356
+ operation: "conf.get"
1357
+ });
1358
+ } catch (error) {
1359
+ if (silent) return null;
1360
+ throw error;
1361
+ }
1362
+ const data = response?.data ?? null;
1363
+ if (!silent && (!data || data.confValue === void 0 || data.confValue === null || data.confValue === "")) {
1364
+ throw dataApiError("conf_missing", `\u914D\u7F6E\u4E0D\u5B58\u5728\u6216\u4E3A\u7A7A: confType=${confType}${group ? ` confGroup=${group}` : ""} confKey=${key}`, {
1365
+ details: { confType, confGroup: group, confKey: key }
1366
+ });
1367
+ }
1368
+ return data;
1369
+ }
1370
+ async function batchByTypeAndGroup(host, pairs) {
1371
+ const payload = pairs.map((pair) => ({
1372
+ confType: pair.confType,
1373
+ confGroup: pair.confGroup === void 0 || pair.confGroup === null ? "" : String(pair.confGroup)
1374
+ }));
1375
+ const response = await host.request({ method: "POST", path: CONF_BATCH_GROUP_PATH, body: payload, operation: "conf.group" });
1376
+ return normalizeBatch(response);
1377
+ }
1378
+ function positionals(input, key) {
1379
+ const value = input[key];
1380
+ return Array.isArray(value) ? value.map((item) => String(item)) : [];
1381
+ }
1382
+ async function confGet(input, host) {
1383
+ const keys = positionals(input, "keys");
1384
+ const key = keys[0] || (typeof input.key === "string" ? input.key : "");
1385
+ if (!key) throw dataValidationError("missing_argument", "conf get \u7F3A\u5C11 confKey\uFF08\u7528\u6CD5: conf get <key> [--type t] [--group g]\uFF09");
1386
+ const confType = confKeyType(key, input.type);
1387
+ let data;
1388
+ try {
1389
+ data = await confGetData(host, confType, key, false, input.group);
1390
+ } catch (error) {
1391
+ if (confType === "api" && !input.group) {
1392
+ throw dataApiError(
1393
+ "conf_missing",
1394
+ `${error.message}\uFF08confType=api \u5EFA\u8BAE\u7528 --group \u6307\u5B9A\u5206\u7EC4\uFF0C\u5982 --group workflow\uFF1B\u6216\u7528 conf group api <\u5206\u7EC4> \u67E5\u770B\u8BE5\u5206\u7EC4\u4E0B\u5168\u90E8\u914D\u7F6E\uFF09`
1395
+ );
1396
+ }
1397
+ throw error;
1398
+ }
1399
+ return { data, text: JSON.stringify(data, null, 1) };
1400
+ }
1401
+ async function confBatch(input, host) {
1402
+ const keys = positionals(input, "keys");
1403
+ if (!keys.length) {
1404
+ throw dataValidationError("missing_argument", "conf batch \u7F3A\u5C11 confKey \u5217\u8868\uFF08\u7528\u6CD5: conf batch <key1> [key2 ...] [--type t] [--group g]\uFF09");
1405
+ }
1406
+ const items = keys.map((key) => {
1407
+ const confType = confKeyType(key, input.type);
1408
+ return putGroup({ confType, confKey: key }, confType, input.group);
1409
+ });
1410
+ let map = {};
1411
+ try {
1412
+ const response = await host.request({ method: "POST", path: CONF_BATCH_PATH, body: items, operation: "conf.batch" });
1413
+ map = normalizeBatch(response);
1414
+ for (const item of items) {
1415
+ const current = lookup(map, item);
1416
+ if (!current || current.confValue === void 0 || current.confValue === null || current.confValue === "") {
1417
+ throw dataApiError("conf_batch_missing", `\u6279\u91CF\u54CD\u5E94\u7F3A\u5931 confKey=${item.confKey}`);
1418
+ }
1419
+ }
1420
+ } catch (error) {
1421
+ if (String(error.message).startsWith("\u6279\u91CF\u54CD\u5E94\u7F3A\u5931")) throw error;
1422
+ process.stderr.write(`[config-resolve] \u6279\u91CF\u63A5\u53E3\u4E0D\u53EF\u7528\uFF0C\u964D\u7EA7\u9010\u6761\u5355\u67E5: ${error.message}
1423
+ `);
1424
+ map = {};
1425
+ for (const item of items) {
1426
+ map[itemId(item)] = await confGetData(host, item.confType, item.confKey, false, item.confGroup);
1427
+ }
1428
+ }
1429
+ const rows = keys.map((key) => {
1430
+ const item = items.find((candidate) => candidate.confKey === key);
1431
+ const current = lookup(map, item) || {};
1432
+ return { key, confType: item.confType, confGroup: item.confGroup ?? "", confValue: current.confValue ?? "", confName: current.confName ?? "" };
1433
+ });
1434
+ return { data: map, text: renderTable(`\u914D\u7F6E ${items.length} \u6761`, rows, ["key", "confType", "confGroup", "confValue", "confName"]) };
1435
+ }
1436
+ async function confBatchFile(input, host) {
1437
+ const raw = input.batch_file ?? input.file ?? positionals(input, "keys")[0];
1438
+ if (raw === void 0) {
1439
+ throw dataValidationError("missing_argument", "conf batch-file \u7F3A\u5C11\u53C2\u6570\uFF08\u7528\u6CD5: conf batch-file @items.json\uFF09");
1440
+ }
1441
+ const parsed = readJsonArg(String(raw), "--batch-file");
1442
+ const list = Array.isArray(parsed) ? parsed : [parsed];
1443
+ const map = {};
1444
+ const meta = {};
1445
+ for (const item of list) {
1446
+ if (!item.confKey || !item.confType) continue;
1447
+ const id = itemId(item);
1448
+ map[id] = await confGetData(host, item.confType, item.confKey, false, item.confGroup);
1449
+ meta[id] = item;
1450
+ }
1451
+ const rows = Object.keys(map).map((id) => ({
1452
+ key: meta[id].confKey,
1453
+ confGroup: meta[id].confGroup ?? "",
1454
+ confValue: (map[id] || {}).confValue ?? "",
1455
+ confName: (map[id] || {}).confName ?? ""
1456
+ }));
1457
+ return { data: map, text: renderTable(`\u914D\u7F6E ${Object.keys(map).length} \u6761`, rows, ["key", "confGroup", "confValue", "confName"]) };
1458
+ }
1459
+ async function confGroup(input, host) {
1460
+ const keys = positionals(input, "keys");
1461
+ const confType = keys[0] || input.type;
1462
+ const group = keys[1] !== void 0 ? keys[1] : input.group;
1463
+ if (!confType) throw dataValidationError("missing_argument", "conf group \u7F3A\u5C11 confType\uFF08\u7528\u6CD5: conf group <confType> <confGroup>\uFF09");
1464
+ if (group === void 0) throw dataValidationError("missing_argument", "conf group \u7F3A\u5C11 confGroup\uFF08\u7528\u6CD5: conf group <confType> <confGroup>\uFF09");
1465
+ const map = await batchByTypeAndGroup(host, [{ confType, confGroup: group }]);
1466
+ const rows = Object.values(map);
1467
+ const onlyKey = input.key;
1468
+ const filtered = onlyKey ? rows.filter((row) => (row.confKey || row.conf_key) === onlyKey) : rows;
1469
+ if (onlyKey && !filtered.length) {
1470
+ throw dataApiError("conf_missing", `\u914D\u7F6E\u4E0D\u5B58\u5728: confType=${confType} confGroup=${group} confKey=${onlyKey}`);
1471
+ }
1472
+ const rendered = filtered.map((row) => ({
1473
+ confKey: row.confKey || row.conf_key || "",
1474
+ confValue: row.confValue ?? "",
1475
+ confName: row.confName ?? "",
1476
+ confAttrs: row.confAttrs ?? ""
1477
+ }));
1478
+ return {
1479
+ data: onlyKey ? filtered[0] ?? null : filtered,
1480
+ text: renderTable(`confType=${confType} confGroup=${group} \u914D\u7F6E ${filtered.length} \u6761`, rendered, ["confKey", "confValue", "confName", "confAttrs"])
1481
+ };
1482
+ }
1483
+ async function confGroupFile(input, host) {
1484
+ const raw = input.group_file ?? positionals(input, "keys")[0];
1485
+ if (raw === void 0) {
1486
+ throw dataValidationError("missing_argument", "conf group-file \u7F3A\u5C11\u53C2\u6570\uFF08\u7528\u6CD5: conf group-file @items.json\uFF09");
1487
+ }
1488
+ const parsed = readJsonArg(String(raw), "--group-file");
1489
+ const list = (Array.isArray(parsed) ? parsed : [parsed]).filter((item) => item && item.confType);
1490
+ if (!list.length) throw dataValidationError("conf_group_file_empty", "conf group-file \u5185\u5BB9\u4E3A\u7A7A\u6216\u7F3A\u5C11 confType");
1491
+ const map = await batchByTypeAndGroup(host, list);
1492
+ const rows = Object.values(map).map((row) => ({
1493
+ confType: row.confType ?? "",
1494
+ confGroup: row.confGroup ?? "",
1495
+ confKey: row.confKey || row.conf_key || "",
1496
+ confValue: row.confValue ?? "",
1497
+ confName: row.confName ?? ""
1498
+ }));
1499
+ return { data: map, text: renderTable(`\u6279\u91CF\u5206\u7EC4\u914D\u7F6E ${rows.length} \u6761`, rows, ["confType", "confGroup", "confKey", "confValue", "confName"]) };
1500
+ }
1501
+ async function resolveAll(host, keys, group) {
1502
+ const items = keys.map((key) => {
1503
+ const confType = confKeyType(key, "");
1504
+ return putGroup({ confType, confKey: key }, confType, group);
1505
+ });
1506
+ const map = {};
1507
+ try {
1508
+ const response = await host.request({ method: "POST", path: CONF_BATCH_PATH, body: items, operation: "conf.resolve" });
1509
+ const got = normalizeBatch(response);
1510
+ for (const item of items) {
1511
+ const current = lookup(got, item);
1512
+ if (!current || current.confValue === void 0 || current.confValue === null || current.confValue === "") {
1513
+ throw dataApiError("conf_batch_missing", `\u7F3A\u5931 ${item.confKey}`);
1514
+ }
1515
+ map[item.confKey] = current;
1516
+ }
1517
+ } catch {
1518
+ for (const item of items) map[item.confKey] = await confGetData(host, item.confType, item.confKey, false, item.confGroup);
1519
+ }
1520
+ return map;
1521
+ }
1522
+ async function resolveText(host, text, group) {
1523
+ const found = [...new Set([...text.matchAll(CONF_TOKEN_RE)].map((match) => match[1]))];
1524
+ const map = found.length ? await resolveAll(host, found, group) : {};
1525
+ const output = text.replace(CONF_TOKEN_RE, (whole, key) => {
1526
+ const config = map[key];
1527
+ if (!config) throw dataApiError("conf_missing", `\u914D\u7F6E\u4E0D\u5B58\u5728\u6216\u4E3A\u7A7A: ${key}`, { code: key });
1528
+ return config.confValue ?? "";
1529
+ });
1530
+ return {
1531
+ input: text,
1532
+ output,
1533
+ resolved: Object.fromEntries(Object.entries(map).map(([key, value]) => [key, value.confValue ?? ""]))
1534
+ };
1535
+ }
1536
+ async function confResolve(input, host) {
1537
+ let text = input.text ?? positionals(input, "keys")[0];
1538
+ if (!text) throw dataValidationError("missing_argument", "conf resolve \u7F3A\u5C11\u6587\u672C\uFF08\u7528\u6CD5: conf resolve '<\u542B#{KEY}\u6587\u672C>' | @file.txt [--group g]\uFF09");
1539
+ text = String(text);
1540
+ if (text.startsWith("@")) text = readFileSync2(text.slice(1), "utf-8");
1541
+ const result = await resolveText(host, text, input.group);
1542
+ return { data: result, text: result.output };
1543
+ }
1544
+ async function confResolveFile(input, host) {
1545
+ const path = input.resolve_file ?? positionals(input, "keys")[0];
1546
+ if (!path) throw dataValidationError("missing_argument", "conf resolve-file \u7F3A\u5C11\u6587\u4EF6\u8DEF\u5F84");
1547
+ const text = readFileSync2(String(path), "utf-8");
1548
+ const result = await resolveText(host, text, input.group);
1549
+ return { data: result, text: result.output };
1550
+ }
1551
+ async function confAdd(input, host) {
1552
+ const key = positionals(input, "keys")[0] || (typeof input.key === "string" ? input.key : "");
1553
+ if (!key || input.value === void 0) {
1554
+ throw dataValidationError("missing_argument", "conf add \u7F3A\u5C11 confKey/confValue\uFF08\u7528\u6CD5: conf add <key> --value <\u771F\u5B9E\u503C>\uFF09");
1555
+ }
1556
+ const confType = confKeyType(key, input.type);
1557
+ if (!input.force && await confGetData(host, confType, key, true, input.group)) {
1558
+ process.stderr.write(`[config-resolve] \u914D\u7F6E\u5DF2\u5B58\u5728\uFF0C\u8DF3\u8FC7\u65B0\u589E\uFF08\u5982\u9700\u4FEE\u6539\u8BF7\u7528 conf update\uFF09: ${key}
1559
+ `);
1560
+ return { data: null, text: `\u5DF2\u5B58\u5728\uFF0C\u8DF3\u8FC7: ${key}` };
1561
+ }
1562
+ const item = putGroup({
1563
+ confType,
1564
+ confKey: key,
1565
+ confValue: String(input.value),
1566
+ confAttrs: input.attrs || "",
1567
+ confName: input.name || ""
1568
+ }, confType, input.group);
1569
+ const response = await host.request({ method: "POST", path: CONF_ADD_PATH, body: [item], operation: "conf.add" });
1570
+ return {
1571
+ data: response,
1572
+ text: `\u65B0\u589E\u6210\u529F: ${item.confGroup ? `${item.confGroup}/` : ""}${key} = ${item.confValue}`
1573
+ };
1574
+ }
1575
+ async function confAddFile(input, host) {
1576
+ const raw = input.add_file ?? positionals(input, "keys")[0];
1577
+ if (raw === void 0) throw dataValidationError("missing_argument", "conf add-file \u7F3A\u5C11\u53C2\u6570\uFF08\u7528\u6CD5: conf add-file @items.json\uFF09");
1578
+ const parsed = readJsonArg(String(raw), "--add-file");
1579
+ const list = Array.isArray(parsed) ? parsed : [parsed];
1580
+ const toAdd = [];
1581
+ for (const item of list) {
1582
+ if (!item.confKey || item.confValue === void 0) continue;
1583
+ const confType = item.confType || confKeyType(item.confKey, input.type);
1584
+ const group = item.confGroup !== void 0 ? item.confGroup : input.group;
1585
+ if (await confGetData(host, confType, item.confKey, true, group)) {
1586
+ process.stderr.write(`[config-resolve] \u5DF2\u5B58\u5728\u8DF3\u8FC7: ${item.confKey}
1587
+ `);
1588
+ continue;
1589
+ }
1590
+ toAdd.push(putGroup({
1591
+ confType,
1592
+ confKey: item.confKey,
1593
+ confValue: String(item.confValue),
1594
+ confAttrs: item.confAttrs || "",
1595
+ confName: item.confName || ""
1596
+ }, confType, group));
1597
+ }
1598
+ if (!toAdd.length) return { data: null, text: "\u5168\u90E8\u5DF2\u5B58\u5728\uFF0C\u65E0\u65B0\u589E" };
1599
+ const response = await host.request({ method: "POST", path: CONF_ADD_PATH, body: toAdd, operation: "conf.add-file" });
1600
+ return { data: response, text: `\u6279\u91CF\u65B0\u589E ${toAdd.length} \u6761\u6210\u529F` };
1601
+ }
1602
+ async function confUpdate(input, host) {
1603
+ const key = positionals(input, "keys")[0] || (typeof input.key === "string" ? input.key : "");
1604
+ if (!key) throw dataValidationError("missing_argument", "conf update \u7F3A\u5C11 confKey");
1605
+ if (input.value === void 0 && input.name === void 0 && input.attrs === void 0) {
1606
+ throw dataValidationError("nothing_to_update", "conf update \u81F3\u5C11\u9700\u63D0\u4F9B --value / --name / --attrs \u4E4B\u4E00");
1607
+ }
1608
+ const confType = confKeyType(key, input.type);
1609
+ const body = putGroup({ confType, confKey: key }, confType, input.group);
1610
+ if (input.value !== void 0) body.confValue = String(input.value);
1611
+ if (input.name !== void 0) body.confName = input.name;
1612
+ if (input.attrs !== void 0) body.confAttrs = input.attrs;
1613
+ const response = await host.request({ method: "POST", path: CONF_UPDATE_PATH, body, operation: "conf.update" });
1614
+ return { data: response, text: `\u66F4\u65B0\u6210\u529F: ${body.confGroup ? `${body.confGroup}/` : ""}${key}` };
1615
+ }
1616
+ async function confDelete(input, host) {
1617
+ const key = positionals(input, "keys")[0] || (typeof input.key === "string" ? input.key : "");
1618
+ if (!key) throw dataValidationError("missing_argument", "conf delete \u7F3A\u5C11 confKey");
1619
+ const confType = confKeyType(key, input.type);
1620
+ const response = await host.request({
1621
+ method: "DELETE",
1622
+ path: `${CONF_DELETE_PATH}?confType=${encodeURIComponent(confType)}&confKey=${encodeURIComponent(key)}${groupSuffix(confType, input.group)}`,
1623
+ operation: "conf.delete"
1624
+ });
1625
+ return {
1626
+ data: response,
1627
+ text: `\u5220\u9664\u6210\u529F: ${useGroup(confType, input.group) && input.group ? `${input.group}/` : ""}${key}`
1628
+ };
1629
+ }
1630
+ function attributesOf(record) {
1631
+ const attrs = record?.confAttrs;
1632
+ if (!attrs) return {};
1633
+ if (typeof attrs === "object") return attrs;
1634
+ try {
1635
+ return parseJsonSafe(String(attrs));
1636
+ } catch {
1637
+ throw dataApiError("conf_attrs_invalid", "confAttrs \u4E8C\u6B21\u89E3\u6790\u5931\u8D25\uFF08\u975E JSON \u5B57\u7B26\u4E32\uFF09", { code: "confAttrs" });
1638
+ }
1639
+ }
1640
+
1641
+ // src/shortcuts/data/operations/module.ts
1642
+ import { readFileSync as readFileSync3 } from "node:fs";
1643
+ var HRM_PATTERNS = ["/api/hrm/", "/api/bs/hrm/", "/api/app/hrm/"];
1644
+ var PERM_WORDS = ["\u6CA1\u6709\u6743\u9650", "\u65E0\u6743\u9650", "\u6743\u9650\u4E0D\u8DB3", "\u672A\u6388\u6743", "\u65E0\u6743\u8BBF\u95EE", "\u65E0\u67E5\u8BE2\u6743\u9650"];
1645
+ var INVOICE_TOKEN_PATH = "/api/inc/proxy/getToken?appType=1";
1646
+ function queryStringOf2(obj) {
1647
+ const params = new URLSearchParams();
1648
+ for (const [key, value] of Object.entries(obj || {})) {
1649
+ if (value === void 0 || value === null) continue;
1650
+ if (Array.isArray(value)) {
1651
+ for (const item of value) {
1652
+ params.append(key, item !== null && typeof item === "object" ? JSON.stringify(item) : String(item));
1653
+ }
1654
+ } else {
1655
+ params.append(key, typeof value === "object" ? JSON.stringify(value) : String(value));
1656
+ }
1657
+ }
1658
+ return params.toString();
1659
+ }
1660
+ function rowsOf(obj) {
1661
+ const numish = (value) => typeof value === "number" || typeof value === "string" ? value : null;
1662
+ if (Array.isArray(obj)) return { rows: obj, total: null };
1663
+ if (!obj || typeof obj !== "object") return { rows: null, total: null };
1664
+ for (const key of ["datajson", "data", "result"]) {
1665
+ const value = obj[key];
1666
+ if (Array.isArray(value)) return { rows: value, total: null };
1667
+ if (value && typeof value === "object") {
1668
+ for (const inner of ["data", "datas", "records", "list", "items", "rows"]) {
1669
+ if (Array.isArray(value[inner])) return { rows: value[inner], total: numish(value.total) };
1670
+ }
1671
+ return { rows: null, total: null };
1672
+ }
1673
+ }
1674
+ for (const inner of ["datas", "list", "records", "items", "rows"]) {
1675
+ if (Array.isArray(obj[inner])) return { rows: obj[inner], total: numish(obj.total) };
1676
+ }
1677
+ return { rows: null, total: null };
1678
+ }
1679
+ function payloadOf(obj) {
1680
+ if (obj && typeof obj === "object" && !Array.isArray(obj)) {
1681
+ for (const key of ["datajson", "data"]) {
1682
+ if (obj[key] !== void 0 && obj[key] !== null) return { value: obj[key], via: key };
1683
+ }
1684
+ }
1685
+ return { value: obj, via: "(root)" };
1686
+ }
1687
+ function flagsOf(obj, payload) {
1688
+ const flags = [];
1689
+ if (payload && typeof payload === "object" && !Array.isArray(payload) && payload.hasSearchRight === false) {
1690
+ flags.push("hasSearchRight=false\uFF08\u6743\u9650\u53D7\u9650\uFF0C\u5176\u4F59\u5B57\u6BB5\u5FC5\u4E3A\u7A7A \u2192 \u7ACB\u5373\u7EC8\u6B62\uFF0C\u4E0D\u5F97\u4EA4\u4ED8\u4E3A\u300C\u65E0\u6570\u636E\u300D\uFF09");
1691
+ }
1692
+ if (payload && typeof payload === "object" && !Array.isArray(payload) && payload.pageUid === "checkSecondFail") {
1693
+ flags.push("pageUid=checkSecondFail\uFF08\u4E8C\u6B21\u8EAB\u4EFD\u9A8C\u8BC1\uFF1Atotal \u53EF\u4FE1\u3001\u660E\u7EC6\u6052 0 \u884C \u2192 \u5982\u5B9E\u8BF4\u660E\uFF0C\u4E0D\u5F97\u5F53\u65E0\u6570\u636E\uFF09");
1694
+ }
1695
+ let text = "";
1696
+ try {
1697
+ text = JSON.stringify(obj).slice(0, 4e3);
1698
+ } catch {
1699
+ text = "";
1700
+ }
1701
+ if (PERM_WORDS.some((word) => text.includes(word))) flags.push("\u54CD\u5E94\u542B\u6743\u9650\u5173\u952E\u8BCD \u2192 \u6309\u300C\u65E0\u6743\u9650\u5373\u7EC8\u6B62\u300D\u5904\u7406");
1702
+ return flags;
1703
+ }
1704
+ function loadConfFile(path) {
1705
+ let raw;
1706
+ try {
1707
+ raw = readFileSync3(path, "utf-8");
1708
+ } catch (error) {
1709
+ throw dataApiError("conf_file_unreadable", `\u8BFB --conf-file \u5931\u8D25\uFF1A${error.message}\uFF08${path}\uFF09`);
1710
+ }
1711
+ let parsed;
1712
+ try {
1713
+ parsed = JSON.parse(raw.replace(/^\uFEFF/, "").trim());
1714
+ } catch {
1715
+ throw dataApiError("conf_file_invalid", `--conf-file \u4E0D\u662F\u5408\u6CD5 JSON\uFF1A${path}`);
1716
+ }
1717
+ if (Array.isArray(parsed)) parsed = parsed[0] || {};
1718
+ if (!parsed || typeof parsed !== "object") {
1719
+ throw dataApiError("conf_file_invalid", `--conf-file \u5F62\u6001\u5F02\u5E38\uFF08\u671F\u671B\u5BF9\u8C61\uFF09\uFF1A${path}`);
1720
+ }
1721
+ if (parsed.confAttrs !== void 0 || parsed.confValue !== void 0 && parsed.api_path === void 0) {
1722
+ const attrs = attributesOf(parsed);
1723
+ return {
1724
+ record: parsed,
1725
+ attrs,
1726
+ confKey: String(parsed.confKey || attrs.confKey || ""),
1727
+ group: String(attrs.module || parsed.module || "")
1728
+ };
1729
+ }
1730
+ return {
1731
+ record: parsed,
1732
+ attrs: parsed,
1733
+ confKey: String(parsed.confKey || ""),
1734
+ group: String(parsed.module || "")
1735
+ };
1736
+ }
1737
+ async function moduleCall(input, host) {
1738
+ const confFile = typeof input.conf_file === "string" && input.conf_file ? String(input.conf_file).replace(/^@/, "") : typeof input.attrs === "string" && input.attrs ? String(input.attrs).replace(/^@/, "") : "";
1739
+ if (!input.conf_key && !confFile) {
1740
+ throw dataValidationError(
1741
+ "missing_argument",
1742
+ "\u7F3A\u5FC5\u586B\u53C2\u6570 --conf-key\uFF08\u7528\u6CD5: module call --conf-key <confKey> --group <\u6A21\u5757> [--type <confType>] [--conf-file <\u672C\u5730confAttrs>]\uFF09"
1743
+ );
1744
+ }
1745
+ if (!input.group && !confFile) {
1746
+ throw dataValidationError("missing_argument", "\u7F3A\u5FC5\u586B\u53C2\u6570 --group\uFF08\u6A21\u5757\u552F\u4E00\u6807\u8BC6\uFF0C\u5982 WORKFLOW / EHR / DOCUMENT\uFF1B\u5E26 --conf-file \u65F6\u53EF\u7701\uFF09");
1747
+ }
1748
+ let confKey = typeof input.conf_key === "string" ? input.conf_key : "";
1749
+ let group = typeof input.group === "string" ? input.group : "";
1750
+ const confType = typeof input.type === "string" && input.type ? input.type : "api";
1751
+ const timeoutMs = Math.max(1, Number(input.timeout || "60") || 60) * 1e3;
1752
+ const limit = input.limit === void 0 || input.limit === true ? 50 : Number(input.limit) || 0;
1753
+ const fields = typeof input.fields === "string" && input.fields ? readListArg(input.fields).split(",").map((item) => item.trim()).filter(Boolean) : null;
1754
+ let record;
1755
+ let attrs;
1756
+ if (confFile) {
1757
+ const loaded = loadConfFile(confFile);
1758
+ record = loaded.record;
1759
+ attrs = loaded.attrs;
1760
+ confKey = confKey || loaded.confKey;
1761
+ group = group || loaded.group;
1762
+ process.stderr.write(`# confAttrs \u6765\u81EA\u672C\u5730\u7F13\u5B58\uFF08${confFile}\uFF09\uFF5C\u672A\u8BF7\u6C42\u914D\u7F6E\u4E2D\u5FC3
1763
+ `);
1764
+ } else {
1765
+ try {
1766
+ record = await confGetData(host, confType, confKey, false, group);
1767
+ } catch (error) {
1768
+ const message = String(error?.message || error);
1769
+ throw dataApiError(
1770
+ "conf_get_failed",
1771
+ `conf get \u5931\u8D25\uFF1A${message}\uFF08\u5148\u6838\u5BF9 confType / confGroup / confKey\uFF1B\u81EA\u5B9A\u4E49 confType \u987B\u663E\u5F0F --type\uFF1B\u767B\u5F55\u6001\u95EE\u9898\u8BF7\u91CD\u65B0\u767B\u5F55\uFF09`,
1772
+ { code: /登录态失效/.test(message) ? 2 : 3 }
1773
+ );
1774
+ }
1775
+ attrs = attributesOf(record);
1776
+ }
1777
+ if (!attrs || typeof attrs !== "object" || Array.isArray(attrs)) {
1778
+ throw dataApiError("conf_attrs_invalid", `confAttrs \u7F3A\u5931\u6216\u5F62\u6001\u5F02\u5E38: ${confKey}\uFF08--group ${group}\uFF09`);
1779
+ }
1780
+ const apiPath = String(attrs.api_path || record?.confValue || "");
1781
+ if (!apiPath) throw dataApiError("conf_attrs_invalid", `confAttrs \u672A\u63D0\u4F9B api_path / confValue: ${confKey}`);
1782
+ if (HRM_PATTERNS.some((pattern) => apiPath.includes(pattern))) throw dataHrmBlocked(apiPath);
1783
+ const apiName = attrs.api_name || record?.confName || confKey;
1784
+ if (input.show_params) {
1785
+ const fullExample = (input.full === true || input.with_example === true) && input.no_example !== true;
1786
+ const out2 = {
1787
+ confKey,
1788
+ conf_type: confType,
1789
+ module: group,
1790
+ api_name: apiName,
1791
+ http_method: attrs.http_method ?? null,
1792
+ api_path: apiPath,
1793
+ business_desc: attrs.business_desc ?? null,
1794
+ api_params: attrs.api_params ?? null,
1795
+ input_params: attrs.input_params ?? null,
1796
+ output_params: attrs.output_params ?? null
1797
+ };
1798
+ if (fullExample) out2.request_example = attrs.request_example ?? null;
1799
+ else {
1800
+ out2.request_example_omitted = true;
1801
+ out2.request_example_hint = "\u5DF2\u7701\u7565 request_example\uFF08\u9700\u5B8C\u6574\u6A21\u677F\u52A0 --full\uFF09\uFF1B\u7EC4\u53C2\u5EFA\u8BAE\u7528 build_query.py --set/--set-file \u751F\u6210";
1802
+ }
1803
+ return { data: out2, text: JSON.stringify(out2, null, 1) };
1804
+ }
1805
+ let businessArgs = {};
1806
+ if (input.args !== void 0 && input.args !== true) {
1807
+ try {
1808
+ businessArgs = readJsonArg(String(input.args), "--args") || {};
1809
+ } catch (error) {
1810
+ throw dataValidationError("args_invalid", `--args \u8BFB\u53D6/\u89E3\u6790\u5931\u8D25\uFF1A${error.message}`);
1811
+ }
1812
+ }
1813
+ if (!businessArgs || typeof businessArgs !== "object" || Array.isArray(businessArgs)) {
1814
+ throw dataValidationError("args_invalid", "--args \u5FC5\u987B\u662F JSON \u5BF9\u8C61");
1815
+ }
1816
+ if (typeof input.query === "string" && input.query) {
1817
+ for (const pair of input.query.split("&")) {
1818
+ if (!pair) continue;
1819
+ const index = pair.indexOf("=");
1820
+ if (index > 0) businessArgs[pair.slice(0, index)] = pair.slice(index + 1);
1821
+ }
1822
+ }
1823
+ const extraHeaders = {};
1824
+ if (input.headers !== void 0 && input.headers !== true) {
1825
+ let parsed;
1826
+ try {
1827
+ parsed = readJsonArg(String(input.headers), "--headers");
1828
+ } catch (error) {
1829
+ throw dataValidationError("headers_invalid", `--headers \u8BFB\u53D6/\u89E3\u6790\u5931\u8D25\uFF1A${error.message}`);
1830
+ }
1831
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) Object.assign(extraHeaders, parsed);
1832
+ }
1833
+ if (typeof input.header === "string" && input.header.includes(":")) {
1834
+ const index = input.header.indexOf(":");
1835
+ extraHeaders[input.header.slice(0, index).trim()] = input.header.slice(index + 1).trim();
1836
+ }
1837
+ const declared = String(input.method || attrs.http_method || "POST").toUpperCase();
1838
+ if (declared !== "GET" && declared !== "POST" && declared !== "FORM") {
1839
+ throw dataValidationError("method_invalid", `--method \u53EA\u652F\u6301 GET / POST / FORM\uFF08\u5F53\u524D: ${input.method}\uFF09`);
1840
+ }
1841
+ const effMethod = declared === "FORM" ? "POST" : declared;
1842
+ const isForm = declared === "FORM" || /x-www-form-urlencoded/i.test(String(attrs.api_definition || ""));
1843
+ let queryString = "";
1844
+ let jsonBody;
1845
+ let formBody;
1846
+ if (effMethod === "GET") {
1847
+ const serialized = queryStringOf2(businessArgs);
1848
+ queryString = serialized ? `?${serialized}` : "";
1849
+ } else if (isForm) {
1850
+ formBody = queryStringOf2(businessArgs);
1851
+ } else {
1852
+ jsonBody = businessArgs;
1853
+ }
1854
+ if (input.dry_run) {
1855
+ const masked = {};
1856
+ for (const [key, value] of Object.entries(extraHeaders)) masked[key] = /^token$/i.test(key) ? "<\u8131\u654F>" : value;
1857
+ const out2 = {
1858
+ ok: true,
1859
+ confKey,
1860
+ api_name: apiName,
1861
+ method: effMethod,
1862
+ url: `<baseUrl>${apiPath}${queryString}`,
1863
+ body: businessArgs,
1864
+ headers: {
1865
+ Cookie: "<\u8131\u654F>",
1866
+ eteamsid: "<\u8131\u654F>",
1867
+ "User-Agent": "<AgentType=\u2026,IsAgent=true>",
1868
+ "Content-Type": effMethod === "POST" ? isForm ? "application/x-www-form-urlencoded" : "application/json;charset=UTF-8" : null,
1869
+ ...masked
1870
+ },
1871
+ note: "--dry-run\uFF1A\u672A\u53D1\u9001\u8BF7\u6C42"
1872
+ };
1873
+ return { data: out2, text: JSON.stringify(out2, null, 1) };
1874
+ }
1875
+ const headers = { ...extraHeaders };
1876
+ const trustedHeaders = {};
1877
+ if (effMethod === "POST") headers["Content-Type"] = isForm ? "application/x-www-form-urlencoded;charset=UTF-8" : "application/json;charset=UTF-8";
1878
+ if (group.toUpperCase() === "INVOICE" || String(attrs.module_key || "").toUpperCase() === "INVOICE") {
1879
+ const tokenResponse = await host.requestText({ method: "GET", path: INVOICE_TOKEN_PATH, operation: "module.invoiceToken" });
1880
+ let token = null;
1881
+ try {
1882
+ token = parseJsonSafe(tokenResponse.text)?.data?.token ?? null;
1883
+ } catch {
1884
+ token = null;
1885
+ }
1886
+ if (!token) {
1887
+ throw dataApiError("invoice_token_missing", `\u672A\u53D6\u5230\u53D1\u7968\u4E91 Token\uFF08INVOICE \u4E1A\u52A1\u63A5\u53E3\u5FC5\u9700\uFF1BHTTP ${tokenResponse.status}\uFF09`, { code: 7 });
1888
+ }
1889
+ trustedHeaders.token = token;
1890
+ }
1891
+ for (const [key, value] of Object.entries(extraHeaders)) {
1892
+ if (/^token$/i.test(key) || ["cookie", "eteamsid", "user-agent"].includes(key.toLowerCase())) trustedHeaders[key] = value;
1893
+ }
1894
+ const { status, text } = await host.requestText({
1895
+ method: effMethod,
1896
+ path: apiPath + queryString,
1897
+ body: effMethod === "POST" ? jsonBody : void 0,
1898
+ form: effMethod === "POST" ? formBody : void 0,
1899
+ headers,
1900
+ trustedHeaders,
1901
+ timeoutMs,
1902
+ operation: `module.call:${confKey}`
1903
+ });
1904
+ if (status === 401) {
1905
+ throw dataApiError("login_required", "\u767B\u5F55\u6001\u5931\u6548(HTTP 401)\uFF1A\u8BF7\u6267\u884C `weaver-work-cli auth login --base-url <\u57DF\u540D>` \u91CD\u65B0\u767B\u5F55", { code: 2 });
1906
+ }
1907
+ let obj = null;
1908
+ try {
1909
+ obj = parseJsonSafe(text);
1910
+ } catch {
1911
+ obj = null;
1912
+ }
1913
+ if (obj === null) {
1914
+ const out2 = { ok: status >= 200 && status < 300, api_name: apiName, http: status, nonJson: text.slice(0, 2e3) };
1915
+ if (status < 200 || status >= 300) {
1916
+ throw dataApiError("non_json", `HTTP ${status} \u4E14\u54CD\u5E94\u975E JSON\uFF08\u5DF2\u539F\u6837\u8F93\u51FA\u524D 2000 \u5B57\u7B26\uFF09`, { code: 7, details: out2 });
1917
+ }
1918
+ return { data: out2, text: text.slice(0, 2e3) };
1919
+ }
1920
+ if (input.raw) return { data: obj, text: JSON.stringify(obj, null, 1) };
1921
+ const payload = payloadOf(obj);
1922
+ const flags = flagsOf(obj, payload.value);
1923
+ const tips = scanTips(obj);
1924
+ const { rows, total } = rowsOf(obj);
1925
+ const out = { ok: true, api_name: apiName, http: status, via: payload.via, ...tipFields(tips) };
1926
+ let projected = null;
1927
+ if (rows !== null) {
1928
+ const shown = limit > 0 ? rows.slice(0, limit) : rows;
1929
+ projected = fields ? shown.map((row) => {
1930
+ const picked = {};
1931
+ if (row && typeof row === "object") {
1932
+ for (const key of fields) if (key in row) picked[key] = row[key];
1933
+ }
1934
+ return picked;
1935
+ }) : shown;
1936
+ out.total = total;
1937
+ out.rows = rows.length;
1938
+ out.shown = projected.length;
1939
+ out.data = projected;
1940
+ } else {
1941
+ out.data = payload.value;
1942
+ }
1943
+ if (flags.length) out.flags = flags;
1944
+ const lines = [`== ${apiName} ==`, `${effMethod} ${apiPath} \u2192 HTTP ${status}\uFF08via=${payload.via}\uFF09`];
1945
+ if (rows !== null) {
1946
+ lines.push(`rows=${rows.length}${total !== null && total !== void 0 ? ` / total=${total}` : ""}${limit > 0 && rows.length > limit ? `\uFF08\u5DF2\u622A\u65AD\u5230 ${limit} \u884C\uFF09` : ""}`);
1947
+ lines.push(renderTable("", projected));
1948
+ } else {
1949
+ lines.push(JSON.stringify(payload.value, null, 1));
1950
+ }
1951
+ for (const flag of flags) lines.push(`[!] ${flag}`);
1952
+ lines.push(...tipsLines(tips));
1953
+ if (flags.some((flag) => flag.startsWith("hasSearchRight=false"))) {
1954
+ const error = dataPermissionBlocked("\u6743\u9650\u53D7\u9650\uFF1AhasSearchRight=false\uFF08\u7ACB\u5373\u7EC8\u6B62\uFF0C\u4E0D\u91CD\u8BD5\u3001\u4E0D\u6362\u53C2\u3001\u4E0D\u4EA4\u4ED8\u4E3A\u300C\u65E0\u6570\u636E\u300D\uFF09");
1955
+ error.details = { result: out };
1956
+ throw error;
1957
+ }
1958
+ return { data: out, text: lines.join("\n") };
1959
+ }
1960
+
1961
+ // src/shortcuts/data/operations/scene.ts
1962
+ var SCENE_PATH = "/api/dw/newetl/chatBi/getSceneGroups";
1963
+ var SCENE_CLIENTS = ["agent", "all", "connector"];
1964
+ function sceneClient(input) {
1965
+ const client = input.client === void 0 ? "agent" : String(input.client).trim();
1966
+ if (!SCENE_CLIENTS.includes(client)) {
1967
+ throw dataValidationError("client_invalid", `--client \u503C\u5FC5\u987B\u4E3A ${SCENE_CLIENTS.join("|")}\uFF08\u5F53\u524D: ${input.client}\uFF09`);
1968
+ }
1969
+ return client;
1970
+ }
1971
+ async function sceneRequest(host, params) {
1972
+ const response = await host.request({ method: "GET", path: SCENE_PATH, query: params, operation: "scene" });
1973
+ if (response && typeof response === "object" && !Array.isArray(response)) {
1974
+ const bad = response.code !== void 0 && Number(response.code) !== 0 || response.fail === true;
1975
+ if (bad) {
1976
+ throw dataApiError(
1977
+ "scene_business_error",
1978
+ `getSceneGroups \u8FD4\u56DE\u4E1A\u52A1\u9519\u8BEF\uFF1Acode=${response.code} msg=${response.msg || response.message || "(\u65E0 msg)"}\uFF08\u5E38\u89C1\uFF1A401\u300C\u6682\u65E0\u6743\u9650\uFF01\u300D= \u8BE5\u63A5\u53E3\u5728\u5F53\u524D\u73AF\u5883\u672A\u5F00\u653E\u6216\u8D26\u53F7\u65E0\u6743\u9650\uFF1B-1\u300Ctoken\u4E3A\u7A7A\u6216\u5931\u6548\u300D= \u767B\u5F55\u6001\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55\uFF09`,
1979
+ { code: response.code }
1980
+ );
1981
+ }
1982
+ }
1983
+ return response && typeof response === "object" && !Array.isArray(response) && "data" in response ? response.data : response;
1984
+ }
1985
+ function asArray(data) {
1986
+ return Array.isArray(data) ? data : data == null ? [] : [data];
1987
+ }
1988
+ function slimItem(dataset) {
1989
+ const item = {
1990
+ id: String(dataset.id ?? ""),
1991
+ datasetName: dataset.datasetName ?? "",
1992
+ datasetType: dataset.datasetType ?? "",
1993
+ sourceId: dataset.sourceId ?? ""
1994
+ };
1995
+ if (dataset.moduleName) item.moduleName = dataset.moduleName;
1996
+ if (dataset.sourceType) item.sourceType = dataset.sourceType;
1997
+ if (dataset.sourceGroupId) item.sourceGroupId = dataset.sourceGroupId;
1998
+ if (dataset.appId) item.appId = dataset.appId;
1999
+ item.datasetDesc = dataset.datasetDesc ?? "";
2000
+ if (dataset.datasetLogic !== void 0) item.datasetLogic = dataset.datasetLogic;
2001
+ return item;
2002
+ }
2003
+ async function sceneGroups(input, host) {
2004
+ const data = await sceneRequest(host, { datasetClient: sceneClient(input) });
2005
+ const arr = asArray(data);
2006
+ if (data != null && !Array.isArray(data)) {
2007
+ process.stderr.write(`# \u6CE8\u610F\uFF1A\u63A5\u53E3\u8FD4\u56DE\u975E\u6570\u7EC4\u5F62\u6001\uFF08${typeof data}\uFF09\uFF0C\u5DF2\u6309\u5355\u5143\u7D20\u6570\u7EC4\u5904\u7406
2008
+ `);
2009
+ }
2010
+ process.stderr.write(`# \u5206\u7EC4 ${arr.length} \u4E2A
2011
+ `);
2012
+ const out = arr.map((group) => ({
2013
+ groupId: String(group.groupId ?? ""),
2014
+ groupName: group.groupName ?? "",
2015
+ itemCount: Number(group.itemCount ?? 0),
2016
+ groupDesc: group.groupDesc ?? ""
2017
+ }));
2018
+ return { data: out, text: JSON.stringify(out, null, 1) };
2019
+ }
2020
+ async function sceneItems(input, host) {
2021
+ const group = input.group || input.group_id;
2022
+ if (!group) throw dataValidationError("missing_argument", "\u7F3A\u5C11\u5FC5\u586B\u53C2\u6570 --group <groupId>");
2023
+ const data = await sceneRequest(host, { datasetClient: sceneClient(input), groupId: String(group) });
2024
+ const arr = asArray(data);
2025
+ const out = arr.map((entry) => {
2026
+ const datasets = (entry.datasets || []).map(slimItem);
2027
+ return {
2028
+ groupId: String(entry.groupId ?? group),
2029
+ groupName: entry.groupName ?? "",
2030
+ itemCount: Number(entry.itemCount ?? datasets.length),
2031
+ datasets
2032
+ };
2033
+ });
2034
+ const total = out.reduce((sum, entry) => sum + entry.datasets.length, 0);
2035
+ if (!out.length) {
2036
+ process.stderr.write("# \u672A\u627E\u5230\u8BE5\u5206\u7EC4\n");
2037
+ return { data: [], text: "[]" };
2038
+ }
2039
+ process.stderr.write(`# \u6761\u76EE ${total} \u6761
2040
+ `);
2041
+ return { data: out, text: JSON.stringify(out, null, 1) };
2042
+ }
2043
+ function keywordsOf(raw) {
2044
+ return String(raw ?? "").split(/[,,、;;\s]+/).map((item) => item.trim()).filter(Boolean);
2045
+ }
2046
+ function hitScore(text, keywords) {
2047
+ const hay = String(text ?? "").toLowerCase();
2048
+ if (!hay) return 0;
2049
+ let score = 0;
2050
+ for (const keyword of keywords) if (hay.includes(keyword.toLowerCase())) score += 1;
2051
+ return score;
2052
+ }
2053
+ async function sceneSearch(input, host) {
2054
+ const client = sceneClient(input);
2055
+ const keywords = keywordsOf(input.keywords ?? input.keyword);
2056
+ if (!keywords.length) throw dataValidationError("missing_argument", "\u7F3A\u5C11\u5FC5\u586B\u53C2\u6570 --keywords <\u8BCD1,\u8BCD2>\uFF08\u4E5F\u53EF\u7528\u7A7A\u683C / \u3001 \u5206\u9694\uFF09");
2057
+ const maxGroups = Math.max(1, Number(input.max_groups ?? 3) || 3);
2058
+ const maxItems = Math.max(1, Number(input.max_items ?? 12) || 12);
2059
+ const scope = input.scope_group_id == null ? "" : String(input.scope_group_id).trim();
2060
+ const serverFilter = String(input.server_filter ?? "auto").trim().toLowerCase();
2061
+ if (!["auto", "on", "off"].includes(serverFilter)) {
2062
+ throw dataValidationError("server_filter_invalid", `--server-filter \u503C\u5FC5\u987B\u4E3A auto|on|off\uFF08\u5F53\u524D: ${input.server_filter}\uFF09`);
2063
+ }
2064
+ const inScope = (group) => !scope || String(group.groupId) === scope;
2065
+ const keywordJoined = keywords.join(",");
2066
+ let pool = [];
2067
+ let requests = 0;
2068
+ let usedServer = false;
2069
+ if (serverFilter !== "off") {
2070
+ try {
2071
+ const raw = await sceneRequest(host, { datasetClient: client, keyword: keywordJoined });
2072
+ requests += 1;
2073
+ const hit = asArray(raw).filter((group) => group && group.groupId !== void 0 && inScope(group));
2074
+ if (hit.length) {
2075
+ pool = hit;
2076
+ usedServer = true;
2077
+ } else if (serverFilter === "auto") {
2078
+ process.stderr.write(`# \u540E\u7AEF keyword \u672A\u547D\u4E2D\uFF0C\u56DE\u9000\u672C\u5730\u6253\u5206\uFF08keyword=${keywordJoined}\uFF09
2079
+ `);
2080
+ }
2081
+ } catch (error) {
2082
+ if (serverFilter === "on") throw error;
2083
+ process.stderr.write(`# [warn] \u5E26 keyword \u7684\u53EC\u56DE\u5931\u8D25\uFF0C\u56DE\u9000\u672C\u5730\u6253\u5206\uFF1A${error?.message || error}
2084
+ `);
2085
+ }
2086
+ }
2087
+ let scored;
2088
+ if (usedServer) {
2089
+ scored = pool.map((group) => ({
2090
+ group,
2091
+ score: hitScore(group.groupName, keywords) * 3 + hitScore(group.groupDesc, keywords),
2092
+ items: Array.isArray(group.datasets) ? group.datasets : null
2093
+ })).sort((a, b) => b.score - a.score || (b.items || []).length - (a.items || []).length).slice(0, maxGroups);
2094
+ } else if (serverFilter === "on") {
2095
+ scored = [];
2096
+ } else {
2097
+ if (!pool.length) {
2098
+ const raw = await sceneRequest(host, { datasetClient: client });
2099
+ requests += 1;
2100
+ pool = asArray(raw).filter((group) => group && group.groupId !== void 0 && inScope(group));
2101
+ }
2102
+ scored = pool.map((group) => ({
2103
+ group,
2104
+ score: hitScore(group.groupName, keywords) * 3 + hitScore(group.groupDesc, keywords),
2105
+ items: null
2106
+ })).filter((candidate) => candidate.score > 0).sort((a, b) => b.score - a.score).slice(0, maxGroups);
2107
+ }
2108
+ const out = [];
2109
+ for (const candidate of scored) {
2110
+ const group = candidate.group;
2111
+ let items = candidate.items ?? [];
2112
+ if (!candidate.items) {
2113
+ const one = await sceneRequest(host, { datasetClient: client, groupId: String(group.groupId) });
2114
+ requests += 1;
2115
+ const arr = asArray(one);
2116
+ const hit = arr.find((entry2) => entry2 && String(entry2.groupId) === String(group.groupId)) || arr[0] || {};
2117
+ items = Array.isArray(hit.datasets) ? hit.datasets : [];
2118
+ }
2119
+ const ranked = items.map((dataset) => ({ dataset, score: hitScore(dataset.datasetName, keywords) * 3 + hitScore(dataset.datasetDesc, keywords) })).sort((a, b) => b.score - a.score);
2120
+ const ordered = usedServer ? ranked : (() => {
2121
+ const matched = ranked.filter((entry2) => entry2.score > 0);
2122
+ return matched.length ? matched : ranked;
2123
+ })();
2124
+ const serverPartial = usedServer && Number(group.itemCount ?? items.length) > items.length;
2125
+ const keep = usedServer && serverPartial ? ordered : ordered.slice(0, maxItems);
2126
+ const entry = {
2127
+ groupId: String(group.groupId),
2128
+ groupName: group.groupName ?? "",
2129
+ groupDesc: group.groupDesc ?? "",
2130
+ itemCount: Number(group.itemCount ?? items.length),
2131
+ datasets: keep.map((item) => slimItem(item.dataset))
2132
+ };
2133
+ if (group.groupLogic !== void 0) entry.groupLogic = group.groupLogic;
2134
+ out.push(entry);
2135
+ }
2136
+ const itemTotal = out.reduce((sum, group) => sum + group.datasets.length, 0);
2137
+ const filterMode = usedServer ? "\u540E\u7AEF keyword" : serverFilter === "on" ? "\u540E\u7AEF keyword\uFF08\u65E0\u547D\u4E2D\uFF09" : "\u672C\u5730\u6253\u5206";
2138
+ if (!out.length) {
2139
+ process.stderr.write(
2140
+ `# \u672A\u547D\u4E2D\u4EFB\u4F55\u5206\u7EC4\uFF08\u5173\u952E\u8BCD\uFF1A${keywords.join(",")}\uFF1B${serverFilter === "on" ? "\u540E\u7AEF keyword \u65E0\u547D\u4E2D\uFF0C\u5DF2\u6309 --server-filter on \u4E0D\u56DE\u9000" : `\u5019\u9009\u6C60 ${pool.length} \u7EC4`}\uFF09
2141
+ `
2142
+ );
2143
+ }
2144
+ process.stderr.write(
2145
+ `# \u5173\u952E\u8BCD ${keywords.join(",")} \uFF5C \u5019\u9009\u5206\u7EC4 ${out.length} \u4E2A \uFF5C \u6761\u76EE ${itemTotal} \u6761 \uFF5C \u8BF7\u6C42 ${requests} \u6B21 \uFF5C \u8FC7\u6EE4\u65B9\u5F0F ${filterMode}
2146
+ `
2147
+ );
2148
+ return { data: out, text: JSON.stringify(out, null, 1) };
2149
+ }
2150
+
2151
+ // src/shortcuts/data/operations/index.ts
2152
+ var DEFINITIONS = [
2153
+ { name: "data.dsl.query", summary: "\u76F4\u63A5\u6267\u884C DSL \u67E5\u8BE2\uFF08executeQueryDsl\uFF09\uFF0Cds list/chart/stat/count \u7684\u5E95\u5C42\u5165\u53E3", capability: "dsl", handler: executeQuery, command: "query" },
2154
+ { name: "data.ds.groups", summary: "\u5185\u7F6E\u6570\u636E\u6E90\u5206\u7EC4\u6E05\u5355\uFF08\u4EC5\u7528\u4E8E ds find \u7684\u9ED8\u8BA4\u626B\u63CF\u5019\u9009\u96C6\uFF09", capability: "discovery", handler: dsGroups, command: "ds groups" },
2155
+ { name: "data.ds.find", summary: "\u6309\u5173\u952E\u8BCD\u8DE8\u5206\u7EC4\u627E\u8868\uFF08\u8FDB\u7A0B\u5185\u5E76\u53D1\u6247\u51FA + \u672C\u5730\u8FC7\u6EE4 + \u8DEF\u7531\u5EFA\u8BAE\uFF09", capability: "discovery", handler: dsFind, command: "ds find" },
2156
+ { name: "data.ds.describe", summary: "\u4E00\u6B21\u5E76\u53D1\u53D6\u56DE\u5B57\u6BB5\u5143\u6570\u636E + \u8BCD\u5E93\uFF0C\u5E76\u7ED9\u51FA\u5173\u8054\u5B57\u6BB5/\u901A\u9053\u63D0\u793A", capability: "discovery", handler: dsDescribe, command: "ds describe" },
2157
+ { name: "data.ds.tables", summary: "\u5217\u67D0\u4E2A\u5206\u7EC4\u4E0B\u7684\u6570\u636E\u96C6\uFF08\u8868\uFF09\u6E05\u5355", capability: "metadata", handler: dsTables, command: "ds tables" },
2158
+ { name: "data.ds.fields", summary: "\u53D6\u6570\u636E\u96C6\u5B57\u6BB5\u5143\u6570\u636E\uFF08/api/ebuilder/common/ds/fields\uFF09", capability: "metadata", handler: dsFields, command: "ds fields" },
2159
+ { name: "data.ds.fields-dsl", summary: "\u53D6 DSL \u53E3\u5F84\u5B57\u6BB5\u5143\u6570\u636E\uFF08/ds/fieldsForDSL\uFF0C\u542B dataKey / formTableId\uFF09", capability: "metadata", handler: dsFieldsDsl, command: "ds fields-dsl" },
2160
+ { name: "data.ds.list", summary: "\u660E\u7EC6\u5217\u8868\u53D6\u6570\uFF08getListDatas\uFF09", capability: "fetch", handler: dsList, command: "ds list" },
2161
+ { name: "data.ds.chart", summary: "\u5206\u7EC4\u805A\u5408\u53D6\u6570\uFF08getChartDatas\uFF09", capability: "fetch", handler: dsChart, command: "ds chart" },
2162
+ { name: "data.ds.stat", summary: "\u7EDF\u8BA1\u5B57\u6BB5\u53D6\u6570\uFF08getStatDatas\uFF09", capability: "fetch", handler: dsStat, command: "ds stat" },
2163
+ { name: "data.ds.count", summary: "\u8BA1\u6570\uFF08getCountData\uFF09", capability: "fetch", handler: dsCount, command: "ds count" },
2164
+ { name: "data.noun.list", summary: "\u6309 skill \u53D6\u8BCD\u5E93\uFF08ChatBI \u540D\u8BCD\u89E3\u91CA\uFF09", capability: "lexicon", handler: nounList, command: "noun list" },
2165
+ { name: "data.noun.scope", summary: "\u6309\u6570\u636E\u96C6\u751F\u6548\u8303\u56F4\u6279\u91CF\u53D6\u8BCD\u5E93\uFF08getChatBiDocByScopeId\uFF09", capability: "lexicon", handler: nounScope, command: "noun scope" },
2166
+ { name: "data.field.name2id", summary: "\u540D\u79F0 \u2192 \u5B57\u6BB5\u503C id \u5019\u9009\uFF08\u6D4F\u89C8\u6309\u94AE\u7C7B\u5B57\u6BB5\uFF09", capability: "field", handler: fieldName2id, command: "field name2id" },
2167
+ { name: "data.field.options", summary: "Select/Radio/Checkbox \u9009\u9879\u503C\u5B57\u5178\uFF08id\u2194name\uFF09", capability: "field", handler: fieldOptions, command: "field options" },
2168
+ { name: "data.conf.get", summary: "\u6309 confKey \u53D6\u5355\u6761\u914D\u7F6E\uFF08confType \u7531\u524D\u7F00\u63A8\u5BFC\u6216 --type \u6307\u5B9A\uFF09", capability: "config", handler: confGet, command: "conf get" },
2169
+ { name: "data.conf.batch", summary: "\u6279\u91CF\u53D6\u914D\u7F6E\uFF08\u6279\u91CF\u63A5\u53E3\u4E0D\u53EF\u7528\u65F6\u81EA\u52A8\u964D\u7EA7\u9010\u6761\u5355\u67E5\uFF09", capability: "config", handler: confBatch, command: "conf batch" },
2170
+ { name: "data.conf.batch-file", summary: "\u6309\u6587\u4EF6\u6279\u91CF\u53D6\u914D\u7F6E\uFF08\u9010\u6761\u5355\u67E5\uFF0C\u8DF3\u8FC7\u6279\u91CF\u63A5\u53E3\uFF09", capability: "config", handler: confBatchFile, command: "conf batch-file" },
2171
+ { name: "data.conf.group", summary: "\u6309 confType + confGroup \u6279\u91CF\u53D6\u56DE\u6574\u7EC4\u914D\u7F6E", capability: "config", handler: confGroup, command: "conf group" },
2172
+ { name: "data.conf.group-file", summary: "\u6309\u6587\u4EF6\u6279\u91CF\u53D6\u591A\u4E2A\u5206\u7EC4\u7684\u914D\u7F6E", capability: "config", handler: confGroupFile, command: "conf group-file" },
2173
+ { name: "data.conf.resolve", summary: "\u628A\u6587\u672C\u91CC\u7684 #{KEY} \u5360\u4F4D\u7B26\u66FF\u6362\u4E3A\u914D\u7F6E\u503C", capability: "config", handler: confResolve, command: "conf resolve" },
2174
+ { name: "data.conf.resolve-file", summary: "\u6309\u6587\u4EF6\u66FF\u6362 #{KEY} \u5360\u4F4D\u7B26", capability: "config", handler: confResolveFile, command: "conf resolve-file" },
2175
+ { name: "data.conf.add", summary: "\u65B0\u589E\u914D\u7F6E\uFF08\u5DF2\u5B58\u5728\u9ED8\u8BA4\u8DF3\u8FC7\uFF0C--force \u91CD\u5EFA\uFF09", capability: "config", handler: confAdd, command: "conf add" },
2176
+ { name: "data.conf.add-file", summary: "\u6309\u6587\u4EF6\u6279\u91CF\u65B0\u589E\u914D\u7F6E\uFF08\u5DF2\u5B58\u5728\u7684\u8DF3\u8FC7\uFF09", capability: "config", handler: confAddFile, command: "conf add-file" },
2177
+ { name: "data.conf.update", summary: "\u66F4\u65B0\u914D\u7F6E\u7684 value / name / attrs", capability: "config", handler: confUpdate, command: "conf update" },
2178
+ { name: "data.conf.delete", summary: "\u5220\u9664\u914D\u7F6E", capability: "config", handler: confDelete, command: "conf delete" },
2179
+ { name: "data.scene.groups", summary: "\u573A\u666F\u5206\u7EC4\u9AA8\u67B6\uFF08getSceneGroups\uFF09", capability: "scene", handler: sceneGroups, command: "scene groups" },
2180
+ { name: "data.scene.items", summary: "\u7EC4\u5185\u6761\u76EE\uFF08\u63A5\u53E3 / \u6570\u636E\u6E90\uFF0C\u542B\u53D6\u6570\u901A\u9053\u53C2\u6570\uFF09", capability: "scene", handler: sceneItems, command: "scene items" },
2181
+ { name: "data.scene.search", summary: "\u5173\u952E\u8BCD\u5019\u9009\u53EC\u56DE\uFF08\u540E\u7AEF keyword \u4F18\u5148\uFF0C\u672C\u5730\u6253\u5206\u515C\u5E95\uFF09", capability: "scene", handler: sceneSearch, command: "scene search" },
2182
+ { name: "data.module.call", summary: "\u6309\u914D\u7F6E\u4E2D\u5FC3\u7684\u63A5\u53E3\u5B9A\u4E49\u7EC4\u53C2\u5E76\u8C03\u7528\uFF08confAttrs \u9A71\u52A8\uFF09", capability: "module", handler: moduleCall, command: "module call" },
2183
+ { name: "data.attend.statis", summary: "\u8003\u52E4\u5047\u671F\u4F59\u989D\uFF08getAttendInfoStatis\uFF1B\u5E74\u5047/\u5E26\u85AA\u75C5\u5047/\u5E26\u85AA\u4E8B\u5047\uFF09", capability: "attend", handler: attendStatis, command: "attend statis" }
2184
+ ];
2185
+ var REGISTRY = new Map(DEFINITIONS.map((definition) => [definition.name, definition]));
2186
+ function operationNames() {
2187
+ return DEFINITIONS.map((definition) => definition.name);
2188
+ }
2189
+ function operationDefinitions() {
2190
+ return DEFINITIONS;
2191
+ }
2192
+ async function executeDataOperation(name, input, host) {
2193
+ const definition = REGISTRY.get(name);
2194
+ if (!definition) {
2195
+ throw dataValidationError(
2196
+ "unknown_operation",
2197
+ `\u672A\u77E5 operation\uFF1A${name}\u3002\u53EF\u7528\u503C\u89C1 \`weaver-work-cli data schema\`\uFF08\u5171 ${DEFINITIONS.length} \u4E2A\uFF09`
2198
+ );
2199
+ }
2200
+ return definition.handler(input, host);
2201
+ }
2202
+
2203
+ // src/shortcuts/data/manifest.ts
2204
+ var INPUT_SCHEMAS = {
2205
+ "data.dsl.query": {
2206
+ required: ["conn", "model", "schema", "dsl"],
2207
+ optional: ["table_id", "debug", "dimension", "conf_group", "username", "start_date"]
2208
+ },
2209
+ "data.ds.groups": { required: [], optional: ["pattern"] },
2210
+ "data.ds.find": {
2211
+ required: ["name"],
2212
+ optional: ["source_type", "size", "pages", "concurrency", "groups", "all_groups", "max_groups", "app_id", "limit", "loose", "no_escalate"]
2213
+ },
2214
+ "data.ds.describe": { required: ["group", "table"], optional: ["source_type", "app_id", "skill", "require"] },
2215
+ "data.ds.tables": { required: ["group"], optional: ["name", "page", "size", "source_type", "app_id"] },
2216
+ "data.ds.fields": { required: ["group", "table"], optional: ["source_type", "app_id"] },
2217
+ "data.ds.fields-dsl": { required: ["group", "table"], optional: ["source_type", "app_id"] },
2218
+ "data.ds.list": {
2219
+ required: ["group", "table", "fields"],
2220
+ optional: ["where", "order", "page", "size", "source_type", "app_id"]
2221
+ },
2222
+ "data.ds.chart": {
2223
+ required: ["group", "table", "group_by", "stat"],
2224
+ optional: ["where", "page", "size", "source_type", "app_id"]
2225
+ },
2226
+ "data.ds.stat": { required: ["group", "table", "stat"], optional: ["where", "source_type", "app_id"] },
2227
+ "data.ds.count": { required: ["group", "table"], optional: ["where", "source_type", "app_id"] },
2228
+ "data.noun.list": { required: ["skill"], optional: ["source_type", "source_group", "source_table"] },
2229
+ "data.noun.scope": { required: ["ids"], optional: [] },
2230
+ "data.field.name2id": { required: ["module", "type", "name"], optional: ["form_param", "eb_browser_param", "property_type"] },
2231
+ "data.field.options": { required: ["field_name", "obj_id", "group"], optional: ["source_type"] },
2232
+ "data.conf.get": { required: ["key"], optional: ["type", "group"] },
2233
+ "data.conf.batch": { required: ["keys"], optional: ["type", "group"] },
2234
+ "data.conf.batch-file": { required: ["batch_file"], optional: [] },
2235
+ "data.conf.group": { required: ["conf_type", "conf_group"], optional: ["key"] },
2236
+ "data.conf.group-file": { required: ["group_file"], optional: [] },
2237
+ "data.conf.resolve": { required: ["text"], optional: ["group"] },
2238
+ "data.conf.resolve-file": { required: ["path"], optional: ["group"] },
2239
+ "data.conf.add": { required: ["key", "value"], optional: ["name", "attrs", "type", "group", "force"] },
2240
+ "data.conf.add-file": { required: ["add_file"], optional: ["type", "group"] },
2241
+ "data.conf.update": { required: ["key"], optional: ["value", "name", "attrs", "type", "group"] },
2242
+ "data.conf.delete": { required: ["key"], optional: ["type", "group"] },
2243
+ "data.scene.groups": { required: [], optional: ["client"] },
2244
+ "data.scene.items": { required: ["group"], optional: ["client"] },
2245
+ "data.scene.search": {
2246
+ required: ["keywords"],
2247
+ optional: ["client", "max_groups", "max_items", "scope_group_id", "server_filter"]
2248
+ },
2249
+ "data.module.call": {
2250
+ required: [],
2251
+ optional: [
2252
+ "conf_key",
2253
+ "group",
2254
+ "type",
2255
+ "conf_file",
2256
+ "args",
2257
+ "query",
2258
+ "header",
2259
+ "headers",
2260
+ "method",
2261
+ "limit",
2262
+ "fields",
2263
+ "raw",
2264
+ "show_params",
2265
+ "full",
2266
+ "with_example",
2267
+ "no_example",
2268
+ "dry_run",
2269
+ "timeout"
2270
+ ]
2271
+ },
2272
+ "data.attend.statis": { required: [], optional: ["user", "begin", "end"] }
2273
+ };
2274
+ function inputSchemaOf(name) {
2275
+ const spec = INPUT_SCHEMAS[name] || { required: [], optional: [] };
2276
+ const properties = {};
2277
+ for (const key of [...spec.required, ...spec.optional]) {
2278
+ properties[key] = { type: key === "keys" || key === "ids" ? "array" : "string" };
2279
+ }
2280
+ return {
2281
+ type: "object",
2282
+ properties,
2283
+ required: spec.required,
2284
+ additionalProperties: false
2285
+ };
2286
+ }
2287
+ var dataOperations = operationDefinitions().map((definition) => ({
2288
+ name: definition.name,
2289
+ resource: definition.capability,
2290
+ summary: definition.summary,
2291
+ command: definition.command,
2292
+ inputSchema: inputSchemaOf(definition.name)
2293
+ }));
2294
+ var dataManifest = {
2295
+ schemaVersion: 1,
2296
+ name: "data",
2297
+ title: "\u6CDB\u5FAEE10\u6570\u636E\u52A9\u624B\uFF08\u6570\u636E\u6E90\u67E5\u8BE2 / \u914D\u7F6E\u4E2D\u5FC3 / \u573A\u666F\u5B9A\u4F4D\uFF09",
2298
+ version: "0.1.0",
2299
+ host: "e10-data",
2300
+ status: "builtin",
2301
+ sourceSkill: "weaver-e10-data",
2302
+ capabilities: ["dsl", "discovery", "metadata", "fetch", "lexicon", "field", "config", "scene", "module", "attend"],
2303
+ auth: {
2304
+ required: "e10-session",
2305
+ note: "\u6240\u6709\u64CD\u4F5C\u90FD\u8981\u6C42\u5DF2\u767B\u5F55 E10\uFF1B\u767B\u5F55\u7EDF\u4E00\u8D70 `weaver-work-cli auth login --base-url <\u57DF\u540D>`\uFF0Cdata \u6A21\u5757\u4E0D\u63D0\u4F9B\u4EFB\u4F55\u767B\u5F55\u5165\u53E3\u3002"
2306
+ },
2307
+ rules: [
2308
+ "\u4FBF\u6377\u547D\u4EE4\uFF08`data ds count` \u2026\uFF09\u4E0E\u7EDF\u4E00\u5165\u53E3\uFF08`data run data.ds.count`\uFF09\u5171\u7528\u540C\u4E00\u4EFD\u5B9E\u73B0\uFF1B\u53C2\u6570\u540D\u9010\u5B57\u4FDD\u7559\uFF0C\u8001\u8C03\u7528\u65E0\u9700\u6539\u52A8\u3002",
2309
+ "`data --json` \u8F93\u51FA**\u4E0E\u65E7 CLI \u9010\u5B57\u4E00\u81F4\u7684\u539F\u59CB\u54CD\u5E94\u4F53**\uFF08\u6280\u80FD\u91CC\u7684 jq \u8DEF\u5F84\u4E0D\u53D8\uFF09\uFF1B`data run` \u8F93\u51FA `{schemaVersion, ok, operation, data, warnings}` \u4FE1\u5C01\u3002",
2310
+ "\u6D41\u7A0B\u7C7B\u95EE\u9898\u4E00\u5F8B\u8D70 WORKFLOW \u6A21\u5757\u63A5\u53E3\uFF0C\u4E0D\u7528 DSL\u3001\u4E5F\u4E0D\u8D70\u6570\u636E\u6E90\uFF1B`ds find` \u7684 routeHint \u5DF2\u7ED9\u51FA\u901A\u9053\u5EFA\u8BAE\u3002",
2311
+ "`ds.find` \u7684 `/ds/listByPage` \u7AEF\u70B9\u5F53\u524D\u5FFD\u7565 name \u21D2 \u672A\u547D\u4E2D\u53EA\u4EE3\u8868\u672A\u843D\u5728\u6293\u53D6\u7A97\u53E3\u5185\uFF0C\u4E0D\u7B49\u4E8E\u8868\u4E0D\u5B58\u5728\u3002",
2312
+ "`module call` \u7684 `token` \u5934\u5728\u8FD0\u884C\u65F6\u5C5E\u4FDD\u7559\u5934\uFF0C\u5FC5\u987B\u8D70 trustedHeaders\uFF08INVOICE \u5DF2\u5185\u7F6E\u6362\u53D6\u903B\u8F91\uFF09\u3002",
2313
+ "\u4EBA\u5458 / \u90E8\u95E8 / \u5C97\u4F4D\u4E00\u5F8B\u8D70 `weaver-work-cli hrm`\uFF1Bdata \u901A\u9053\u5BF9 /api/hrm/ \u8DEF\u5F84\u6709\u9ED1\u540D\u5355\uFF08\u9000\u51FA\u7801 6\uFF09\u3002",
2314
+ "`hasSearchRight=false` \u662F\u6743\u9650\u53D7\u9650\uFF08\u7EC8\u7AEF\u6001\uFF09\uFF1A\u7ED3\u679C\u7167\u5E38\u7ED9\u51FA\u4F46\u9000\u51FA\u7801 4\uFF0C\u4E0D\u5F97\u4EA4\u4ED8\u4E3A\u300C\u65E0\u6570\u636E\u300D\u3002",
2315
+ "`field name2id`\uFF08\u540D\u79F0\u2192\u5B57\u6BB5\u503C id\uFF09\u4E0E `ds fields`\uFF08\u5B57\u6BB5\u5143\u6570\u636E\uFF09\u662F\u4E24\u4EF6\u4E8B\uFF1B`id2name` \u5DF2\u505C\u7528\u5E76\u5728\u672C\u6B21\u8FC1\u79FB\u4E2D\u5220\u9664\u3002"
2316
+ ],
2317
+ operations: dataOperations,
2318
+ withheldOperations: [
2319
+ {
2320
+ name: "data.doc.count",
2321
+ reason: "\u6587\u6863\u6570\u91CF\u7531\u914D\u7F6E\u4E2D\u5FC3 DOCUMENT.POST_DOCUMENT_DOCUMENT_LIST_COUNT \u8986\u76D6\uFF08conf group api DOCUMENT \u2192 module call\uFF09\uFF0C\u4E0D\u5728 data \u6A21\u5757\u91CD\u590D\u5C01\u88C5\u3002"
2322
+ },
2323
+ {
2324
+ name: "data.doc.list",
2325
+ reason: "\u540C\u4E0A\uFF1ADOCUMENT.POST_DOCUMENT_DOCUMENT_LIST\u3002\u6CE8\u610F documentList \u7684 data.total \u5B9E\u6D4B\u6052\u4E3A 0\uFF0C\u603B\u91CF\u5FC5\u987B\u53D6 count \u63A5\u53E3\u3002"
2326
+ },
2327
+ {
2328
+ name: "data.field.id2name",
2329
+ reason: "\u5DF2\u505C\u7528\uFF1A\u6280\u80FD\u91CC 19 \u5904\u5747\u4E3A\u7981\u4EE4\uFF1B\u8BE5\u5B9E\u73B0\u6253\u7684\u662F /api/bcw/test/testRemoteBrowser \u63A2\u9488\u63A5\u53E3\u3002\u9009\u9879\u503C\u663E\u793A\u6620\u5C04\u6539\u8D70 field options\u3002"
2330
+ },
2331
+ {
2332
+ name: "data.refusal.get",
2333
+ reason: "\u62D2\u7B54\u8BDD\u672F\u5C5E\u667A\u80FD\u95EE\u6570\u5BBF\u4E3B\u5E73\u53F0\u804C\u8D23\uFF1B\u573A\u666F\u6280\u80FD\u660E\u786E\u300C\u4E0D\u505A\u62D2\u7B54 / \u8BDD\u672F\u5224\u5B9A\u300D\uFF0C\u8FC1\u5165\u53EA\u4F1A\u6269\u51FA\u4E00\u4E2A\u88AB\u7981\u6B62\u8C03\u7528\u7684\u5165\u53E3\u3002"
2334
+ },
2335
+ {
2336
+ name: "data.refusal.rules",
2337
+ reason: "\u540C\u4E0A\uFF1AgetRefusalSpeechRules \u7531\u5E73\u53F0\u5728\u52A0\u8F7D\u5B8C\u6210 / \u53D6\u6570\u524D / \u4EA4\u4ED8\u524D\u81EA\u884C\u62C9\u53D6\u5E76\u66FF\u6362\u8BDD\u672F\u3002"
2338
+ },
2339
+ {
2340
+ name: "data.exp.*",
2341
+ reason: "\u4E13\u5BB6\u5305\u8FDC\u7AEF\u7248\u672C\u7BA1\u7406\u5C5E `weaver-work-cli skills repo \u2026` \u8D44\u6E90\u57DF\uFF0C\u4E0D\u8FDB data\u3002"
2342
+ }
2343
+ ]
2344
+ };
2345
+
2346
+ // src/shortcuts/data/index.ts
2347
+ function toInput(options) {
2348
+ const input = {};
2349
+ for (const [key, value] of Object.entries(options)) {
2350
+ if (value === void 0) continue;
2351
+ input[key.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`)] = value;
2352
+ }
2353
+ if (input.escalate === false) {
2354
+ input.no_escalate = true;
2355
+ delete input.escalate;
2356
+ }
2357
+ return input;
2358
+ }
2359
+ async function readStdin() {
2360
+ const chunks = [];
2361
+ for await (const chunk of process.stdin) chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
2362
+ return Buffer.concat(chunks).toString("utf8");
2363
+ }
2364
+ async function inputFrom(options) {
2365
+ let input = {};
2366
+ if (options.input && options.inputJson) {
2367
+ throw dataValidationError("input_conflict", "\u4E0D\u80FD\u540C\u65F6\u4F20 --input \u548C --input-json");
2368
+ }
2369
+ if (options.inputJson) input = parseInput(String(options.inputJson), "--input-json");
2370
+ if (options.input) {
2371
+ let raw;
2372
+ try {
2373
+ raw = options.input === "-" ? await readStdin() : await readFile(String(options.input), "utf8");
2374
+ } catch {
2375
+ throw dataValidationError("input_unreadable", `\u65E0\u6CD5\u8BFB\u53D6 --input\uFF1A${String(options.input)}`);
2376
+ }
2377
+ input = parseInput(raw, "--input");
2378
+ }
2379
+ return input;
2380
+ }
2381
+ function parseInput(raw, label) {
2382
+ try {
2383
+ const parsed = JSON.parse(raw.replace(/^\uFEFF+/g, ""));
2384
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error("not an object");
2385
+ return parsed;
2386
+ } catch {
2387
+ throw dataValidationError("input_invalid", `${label} \u4E0D\u662F\u5408\u6CD5 JSON \u5BF9\u8C61`);
2388
+ }
2389
+ }
2390
+ function emit(ctx, result) {
2391
+ ctx.output.write(result.data, { text: result.text, persist: false });
2392
+ }
2393
+ function emitEnvelope(ctx, operation, result) {
2394
+ ctx.output.write({
2395
+ schemaVersion: 1,
2396
+ ok: true,
2397
+ operation,
2398
+ data: result.data === void 0 ? null : result.data,
2399
+ warnings: []
2400
+ }, { text: result.text, persist: false });
2401
+ }
2402
+ async function run(ctx, operation, input, envelope) {
2403
+ const host = createDataHost(ctx);
2404
+ const result = await executeDataOperation(operation, input, host);
2405
+ if (envelope) emitEnvelope(ctx, operation, result);
2406
+ else emit(ctx, result);
2407
+ }
2408
+ var dataShortcut = {
2409
+ name: "data",
2410
+ description: "\u6CDB\u5FAEE10\u6570\u636E\u52A9\u624B CLI\uFF08\u6570\u636E\u6E90\u67E5\u8BE2 / \u914D\u7F6E\u4E2D\u5FC3 / \u573A\u666F\u5B9A\u4F4D\uFF09",
2411
+ category: "shortcut",
2412
+ register({ program, action }) {
2413
+ const data = program.command("data").description("\u6CDB\u5FAEE10\u6570\u636E\u52A9\u624B\uFF08DSL \u67E5\u8BE2 / \u6570\u636E\u6E90\u53D1\u73B0 / \u914D\u7F6E\u4E2D\u5FC3 / \u573A\u666F\u5B9A\u4F4D\uFF09");
2414
+ data.command("schema").description("Print data operation manifest for agents").action(action((ctx) => {
2415
+ ctx.output.write(dataManifest, { json: true, persist: false });
2416
+ }));
2417
+ data.command("run").description("Run a data operation with JSON input").argument("<operation>", `operation name, e.g. data.ds.count\uFF08\u5171 ${operationNames().length} \u4E2A\uFF09`).option("--input <path>", "JSON input file, or - for stdin").option("--input-json <json>", "inline JSON input object").action(action(async (ctx, operation, options) => {
2418
+ await run(ctx, String(operation), await inputFrom(options), true);
2419
+ }));
2420
+ data.command("query").description("\u76F4\u63A5\u6267\u884C DSL \u67E5\u8BE2\uFF08executeQueryDsl\uFF09").option("--conn <connId>", "\u6570\u636E\u8FDE\u63A5 ID\uFF08CONN_*\uFF09").option("--model <model>", "\u6A21\u578B\u6807\u8BC6\uFF0C\u5982 dw / ebuilder / flow").option("--schema <schema>", "\u5E93\u540D").option("--table-id <id>", "\u6570\u636E\u96C6 / \u6D41\u7A0B ID").option("--dsl <json|@file>", "DSL \u67E5\u8BE2\u4F53").option("--debug [bool]", "\u56DE\u663E SQL\uFF08true/false\uFF09").option("--dimension <key>", "\u540E\u7AEF confKey\uFF08URL query\uFF0C\u6052\u5B9A\u53D1\u9001\uFF09").option("--conf-group <group>", "confGroup\uFF08URL query\uFF0C\u6052\u5B9A\u53D1\u9001\uFF09").option("--confGroup <group>", "\u540C --conf-group").option("--username <name>", "\u95EE\u53E5\u4E2D\u51FA\u73B0\u7684\u4EBA\u540D\uFF08\u65E0\u5219\u4F20\u7A7A\uFF09").option("--start-date <ym>", "\u95EE\u53E5\u65E5\u671F\u8D77\u59CB\u5E74\u6708\uFF08\u65E0\u5219\u4F20\u7A7A\uFF09").action(action(async (ctx, options) => {
2421
+ await run(ctx, "data.dsl.query", toInput(options), false);
2422
+ }));
2423
+ const ds = data.command("ds").description("\u6570\u636E\u6E90\uFF1A\u5206\u7EC4 / \u627E\u8868 / \u5143\u6570\u636E / \u53D6\u6570");
2424
+ ds.command("groups").description("\u5185\u7F6E\u5206\u7EC4\u6E05\u5355\uFF08\u4EC5\u7528\u4E8E ds find \u7684\u9ED8\u8BA4\u626B\u63CF\u5019\u9009\u96C6\uFF09").option("--pattern <sub>", "\u6309 groupId / \u4E2D\u6587\u540D\u8FC7\u6EE4").action(action(async (ctx, options) => {
2425
+ await run(ctx, "data.ds.groups", toInput(options), false);
2426
+ }));
2427
+ ds.command("find").description("\u6309\u5173\u952E\u8BCD\u8DE8\u5206\u7EC4\u627E\u8868\uFF08\u5E76\u53D1\u6247\u51FA + \u672C\u5730\u8FC7\u6EE4 + \u8DEF\u7531\u5EFA\u8BAE\uFF09").option("--name <keyword>", "\u8868\u540D\u5173\u952E\u8BCD").option("--keyword <keyword>", "\u540C --name").option("--source-type <type>", "LOGIC / ETEAMS\uFF0C\u9ED8\u8BA4 LOGIC").option("--size <n>", "\u6BCF\u9875\u6761\u6570\uFF08\u22642000\uFF09\uFF0C\u9ED8\u8BA4 100").option("--pages <n>", "\u6293\u53D6\u9875\u6570\uFF08\u226450\uFF09\uFF0C\u9ED8\u8BA4 1").option("--concurrency <n>", "\u8FDB\u7A0B\u5185\u5E76\u53D1\u6570\uFF0C\u9ED8\u8BA4 10").option("--groups <a,b>", "\u663E\u5F0F\u6307\u5B9A\u626B\u63CF\u5206\u7EC4").option("--all-groups", "\u626B\u63CF\u5168\u90E8 58 \u4E2A\u5206\u7EC4").option("--max-groups <n>", "\u9ED8\u8BA4\u626B\u63CF\u96C6\u4E0A\u9650\uFF0C\u9ED8\u8BA4 6").option("--app-id <id>", "EB \u5206\u7EC4\u6309\u5E94\u7528\u5206\u57DF\u65F6\u663E\u5F0F\u4F20\u5165").option("--limit <n>", "\u5019\u9009\u4E0A\u9650").option("--loose", "\u5173\u95ED\u672C\u5730\u5173\u952E\u8BCD\u8FC7\u6EE4").option("--no-escalate", "\u672A\u547D\u4E2D\u65F6\u4E0D\u5347\u7EA7\u5168\u626B").action(action(async (ctx, options) => {
2428
+ await run(ctx, "data.ds.find", toInput(options), false);
2429
+ }));
2430
+ ds.command("describe").description("\u5E76\u53D1\u53D6\u5B57\u6BB5\u5143\u6570\u636E + \u8BCD\u5E93\uFF0C\u5E76\u7ED9\u51FA\u5173\u8054\u5B57\u6BB5/\u901A\u9053\u63D0\u793A").option("--group <groupId>", "\u5206\u7EC4 ID").option("--table <tableId>", "\u6570\u636E\u96C6 ID").option("--source-type <type>", "LOGIC / ETEAMS").option("--app-id <id>", "EB \u5206\u7EC4\u5E94\u7528 ID").option("--skill <skillKey>", "\u8BCD\u5E93 skillKey\uFF0C\u9ED8\u8BA4 data-source-query").option("--require", "\u5B58\u5728\u5931\u8D25\u5206\u652F\u65F6\u76F4\u63A5\u5931\u8D25").action(action(async (ctx, options) => {
2431
+ await run(ctx, "data.ds.describe", toInput(options), false);
2432
+ }));
2433
+ ds.command("tables").description("\u5217\u5206\u7EC4\u4E0B\u7684\u6570\u636E\u96C6\uFF08\u8868\uFF09\u6E05\u5355").option("--group <groupId>", "\u5206\u7EC4 ID").option("--name <keyword>", "\u8868\u540D\u5173\u952E\u8BCD").option("--page <n>", "\u9875\u7801\uFF0C\u9ED8\u8BA4 1").option("--size <n>", "\u6BCF\u9875\u6761\u6570\uFF0C\u9ED8\u8BA4 100").option("--source-type <type>", "LOGIC / ETEAMS").option("--app-id <id>", "EB \u5206\u7EC4\u5E94\u7528 ID").action(action(async (ctx, options) => {
2434
+ await run(ctx, "data.ds.tables", toInput(options), false);
2435
+ }));
2436
+ ds.command("fields").description("\u53D6\u6570\u636E\u96C6\u5B57\u6BB5\u5143\u6570\u636E\uFF08/api/ebuilder/common/ds/fields\uFF09").option("--group <groupId>", "\u5206\u7EC4 ID").option("--table <tableId>", "\u6570\u636E\u96C6 ID").option("--source-type <type>", "LOGIC / ETEAMS").option("--app-id <id>", "EB \u5206\u7EC4\u5E94\u7528 ID").action(action(async (ctx, options) => {
2437
+ await run(ctx, "data.ds.fields", toInput(options), false);
2438
+ }));
2439
+ ds.command("fields-dsl").description("\u53D6 DSL \u53E3\u5F84\u5B57\u6BB5\u5143\u6570\u636E\uFF08\u542B dataKey / formTableId\uFF09").option("--group <groupId>", "\u5206\u7EC4 ID").option("--table <tableId>", "\u6570\u636E\u96C6 ID").option("--source-type <type>", "LOGIC / ETEAMS").option("--app-id <id>", "EB \u5206\u7EC4\u5E94\u7528 ID").action(action(async (ctx, options) => {
2440
+ await run(ctx, "data.ds.fields-dsl", toInput(options), false);
2441
+ }));
2442
+ ds.command("list").description("\u660E\u7EC6\u5217\u8868\u53D6\u6570\uFF08getListDatas\uFF09").option("--group <groupId>", "\u5206\u7EC4 ID").option("--table <tableId>", "\u6570\u636E\u96C6 ID").option("--fields <a,b|@f>", "\u8FD4\u56DE\u5B57\u6BB5\uFF08\u9017\u53F7\u5206\u9694\uFF09").option("--where <json|@file>", "\u6761\u4EF6\u6811 / \u6761\u4EF6\u6570\u7EC4").option("--order <expr>", '\u6392\u5E8F\uFF0C\u5982 "create_time desc"').option("--page <n>", "\u9875\u7801\uFF0C\u9ED8\u8BA4 1").option("--size <n>", "\u6BCF\u9875\u6761\u6570\uFF0C\u9ED8\u8BA4 20").option("--source-type <type>", "LOGIC / ETEAMS").option("--app-id <id>", "EB \u5206\u7EC4\u5E94\u7528 ID").action(action(async (ctx, options) => {
2443
+ await run(ctx, "data.ds.list", toInput(options), false);
2444
+ }));
2445
+ ds.command("chart").description("\u5206\u7EC4\u805A\u5408\u53D6\u6570\uFF08getChartDatas\uFF09").option("--group <groupId>", "\u5206\u7EC4 ID").option("--table <tableId>", "\u6570\u636E\u96C6 ID").option("--group-by <a,b>", "\u5206\u7EC4\u5B57\u6BB5").option("--stat <json|@file>", "\u7EDF\u8BA1\u5B57\u6BB5\uFF08fieldId + aggregator\uFF09").option("--where <json|@file>", "\u6761\u4EF6\u6811 / \u6761\u4EF6\u6570\u7EC4").option("--page <n>", "\u9875\u7801").option("--size <n>", "\u6BCF\u9875\u6761\u6570\uFF0C\u9ED8\u8BA4 100").option("--source-type <type>", "LOGIC / ETEAMS").option("--app-id <id>", "EB \u5206\u7EC4\u5E94\u7528 ID").action(action(async (ctx, options) => {
2446
+ await run(ctx, "data.ds.chart", toInput(options), false);
2447
+ }));
2448
+ ds.command("stat").description("\u7EDF\u8BA1\u5B57\u6BB5\u53D6\u6570\uFF08getStatDatas\uFF09").option("--group <groupId>", "\u5206\u7EC4 ID").option("--table <tableId>", "\u6570\u636E\u96C6 ID").option("--stat <json|@file>", "\u7EDF\u8BA1\u5B57\u6BB5\uFF08fieldId + aggregator\uFF09").option("--where <json|@file>", "\u6761\u4EF6\u6811 / \u6761\u4EF6\u6570\u7EC4").option("--source-type <type>", "LOGIC / ETEAMS").option("--app-id <id>", "EB \u5206\u7EC4\u5E94\u7528 ID").action(action(async (ctx, options) => {
2449
+ await run(ctx, "data.ds.stat", toInput(options), false);
2450
+ }));
2451
+ ds.command("count").description("\u8BA1\u6570\uFF08getCountData\uFF09").option("--group <groupId>", "\u5206\u7EC4 ID").option("--table <tableId>", "\u6570\u636E\u96C6 ID").option("--where <json|@file>", "\u6761\u4EF6\u6811 / \u6761\u4EF6\u6570\u7EC4").option("--source-type <type>", "LOGIC / ETEAMS").option("--app-id <id>", "EB \u5206\u7EC4\u5E94\u7528 ID").action(action(async (ctx, options) => {
2452
+ await run(ctx, "data.ds.count", toInput(options), false);
2453
+ }));
2454
+ const noun = data.command("noun").description("\u8BCD\u5E93\uFF08ChatBI \u540D\u8BCD\u89E3\u91CA\uFF09");
2455
+ noun.command("list").description("\u6309 skill \u53D6\u8BCD\u5E93").option("--skill <skillKey>", "skill \u6807\u8BC6").option("--source-type <type>", "\u6570\u636E\u6E90\u7C7B\u578B").option("--source-group <groupId>", "\u6570\u636E\u6E90\u5206\u7EC4").option("--source-table <tableId>", "\u6570\u636E\u96C6 ID").action(action(async (ctx, options) => {
2456
+ await run(ctx, "data.noun.list", toInput(options), false);
2457
+ }));
2458
+ noun.command("scope").description("\u6309\u6570\u636E\u96C6\u751F\u6548\u8303\u56F4\u6279\u91CF\u53D6\u8BCD\u5E93").option("--ids <a,b|@f>", "\u6570\u636E\u96C6 id \u5217\u8868\uFF08\u53D6\u81EA scene items\uFF09").action(action(async (ctx, options) => {
2459
+ await run(ctx, "data.noun.scope", toInput(options), false);
2460
+ }));
2461
+ const field = data.command("field").description("\u5B57\u6BB5\u503C\u7FFB\u8BD1 / \u9009\u9879\u5B57\u5178");
2462
+ field.command("name2id").description("\u540D\u79F0 \u2192 \u5B57\u6BB5\u503C id \u5019\u9009\uFF08\u6D4F\u89C8\u6309\u94AE\u7C7B\u5B57\u6BB5\uFF09").option("--module <module>", "\u6A21\u5757\u6807\u8BC6\uFF0C\u5982 hrm / workflow").option("--type <browserType>", "\u6D4F\u89C8\u6309\u94AE\u7C7B\u578B").option("--name <text>", "\u8981\u7FFB\u8BD1\u7684\u540D\u79F0").option("--form-param <json>", "\u8868\u5355\u53C2\u6570").option("--eb-browser-param <json|@file>", "EB \u6D4F\u89C8\u53C2\u6570").option("--property-type <type>", "\u5C5E\u6027\u7C7B\u578B").action(action(async (ctx, options) => {
2463
+ await run(ctx, "data.field.name2id", toInput(options), false);
2464
+ }));
2465
+ field.command("options").description("Select/Radio/Checkbox \u9009\u9879\u503C\u5B57\u5178\uFF08id\u2194name\uFF09").option("--field-name <name>", "\u5B57\u6BB5\u540D\uFF08ds fields \u8FD4\u56DE\u7684 name\uFF09").option("--obj-id <id>", "\u6570\u636E\u96C6 / \u8868 ID").option("--group <groupId>", "\u5206\u7EC4 ID").option("--source-type <type>", "LOGIC / ETEAMS").action(action(async (ctx, options) => {
2466
+ await run(ctx, "data.field.options", toInput(options), false);
2467
+ }));
2468
+ const conf = data.command("conf").description("\u73AF\u5883\u53C2\u6570\u914D\u7F6E\u4E2D\u5FC3\uFF08chatBi config map\uFF09");
2469
+ conf.command("get").description("\u6309 confKey \u53D6\u5355\u6761\u914D\u7F6E").argument("<key>", "confKey\uFF08CONN_/DS_/WF_/API_ \u524D\u7F00\u53EF\u63A8\u5BFC confType\uFF09").option("--type <confType>", "confType\uFF08\u9ED8\u8BA4\u7531\u524D\u7F00\u63A8\u5BFC\uFF09").option("--group <confGroup>", "confGroup\uFF08confType=api \u65F6\u5EFA\u8BAE\u663E\u5F0F\u6307\u5B9A\uFF09").action(action(async (ctx, key, options) => {
2470
+ await run(ctx, "data.conf.get", { ...toInput(options), keys: [key] }, false);
2471
+ }));
2472
+ conf.command("batch").description("\u6279\u91CF\u53D6\u914D\u7F6E").argument("<keys...>", "confKey \u5217\u8868").option("--type <confType>", "confType").option("--group <confGroup>", "confGroup").action(action(async (ctx, keys, options) => {
2473
+ await run(ctx, "data.conf.batch", { ...toInput(options), keys }, false);
2474
+ }));
2475
+ conf.command("batch-file").description("\u6309\u6587\u4EF6\u6279\u91CF\u53D6\u914D\u7F6E\uFF08\u9010\u6761\u5355\u67E5\uFF09").argument("<file>", "JSON \u6587\u4EF6\uFF0C\u6216 @items.json").action(action(async (ctx, file, options) => {
2476
+ await run(ctx, "data.conf.batch-file", { ...toInput(options), batch_file: file }, false);
2477
+ }));
2478
+ conf.command("group").description("\u6309 confType + confGroup \u6279\u91CF\u53D6\u56DE\u6574\u7EC4\u914D\u7F6E").argument("<confType>", "confType\uFF0C\u5982 api").argument("<confGroup>", "confGroup\uFF0C\u5982 workflow").option("--key <confKey>", "\u53EA\u53D6\u8BE5\u7EC4\u4E0B\u7684\u4E00\u6761").action(action(async (ctx, confType, confGroup2, options) => {
2479
+ await run(ctx, "data.conf.group", { ...toInput(options), keys: [confType, confGroup2] }, false);
2480
+ }));
2481
+ conf.command("group-file").description("\u6309\u6587\u4EF6\u6279\u91CF\u53D6\u591A\u4E2A\u5206\u7EC4\u7684\u914D\u7F6E").argument("<file>", "JSON \u6587\u4EF6\uFF0C\u5F62\u5982 [{confType, confGroup}]").action(action(async (ctx, file, options) => {
2482
+ await run(ctx, "data.conf.group-file", { ...toInput(options), group_file: file }, false);
2483
+ }));
2484
+ conf.command("resolve").description("\u628A\u6587\u672C\u91CC\u7684 #{KEY} \u5360\u4F4D\u7B26\u66FF\u6362\u4E3A\u914D\u7F6E\u503C").argument("<text>", "\u542B #{KEY} \u7684\u6587\u672C\uFF0C\u6216 @file.txt").option("--group <confGroup>", "confGroup").action(action(async (ctx, text, options) => {
2485
+ await run(ctx, "data.conf.resolve", { ...toInput(options), text }, false);
2486
+ }));
2487
+ conf.command("resolve-file").description("\u6309\u6587\u4EF6\u66FF\u6362 #{KEY} \u5360\u4F4D\u7B26").argument("<path>", "\u6587\u672C\u6587\u4EF6\u8DEF\u5F84").option("--group <confGroup>", "confGroup").action(action(async (ctx, path, options) => {
2488
+ await run(ctx, "data.conf.resolve-file", { ...toInput(options), path }, false);
2489
+ }));
2490
+ conf.command("add").description("\u65B0\u589E\u914D\u7F6E\uFF08\u5DF2\u5B58\u5728\u9ED8\u8BA4\u8DF3\u8FC7\uFF09").argument("<key>", "confKey").option("--value <v>", "\u914D\u7F6E\u503C").option("--name <n>", "\u914D\u7F6E\u540D\u79F0").option("--attrs <json>", "confAttrs").option("--type <confType>", "confType").option("--group <confGroup>", "confGroup").option("--force", "\u5DF2\u5B58\u5728\u65F6\u4E5F\u91CD\u5EFA").action(action(async (ctx, key, options) => {
2491
+ await run(ctx, "data.conf.add", { ...toInput(options), keys: [key] }, false);
2492
+ }));
2493
+ conf.command("add-file").description("\u6309\u6587\u4EF6\u6279\u91CF\u65B0\u589E\u914D\u7F6E").argument("<file>", "JSON \u6587\u4EF6").option("--type <confType>", "confType").option("--group <confGroup>", "confGroup").action(action(async (ctx, file, options) => {
2494
+ await run(ctx, "data.conf.add-file", { ...toInput(options), add_file: file }, false);
2495
+ }));
2496
+ conf.command("update").description("\u66F4\u65B0\u914D\u7F6E\u7684 value / name / attrs").argument("<key>", "confKey").option("--value <v>", "\u914D\u7F6E\u503C").option("--name <n>", "\u914D\u7F6E\u540D\u79F0").option("--attrs <json>", "confAttrs").option("--type <confType>", "confType").option("--group <confGroup>", "confGroup").action(action(async (ctx, key, options) => {
2497
+ await run(ctx, "data.conf.update", { ...toInput(options), keys: [key] }, false);
2498
+ }));
2499
+ conf.command("delete").description("\u5220\u9664\u914D\u7F6E").argument("<key>", "confKey").option("--type <confType>", "confType").option("--group <confGroup>", "confGroup").action(action(async (ctx, key, options) => {
2500
+ await run(ctx, "data.conf.delete", { ...toInput(options), keys: [key] }, false);
2501
+ }));
2502
+ const scene = data.command("scene").description("\u573A\u666F\u5B9A\u4F4D\u5143\u6570\u636E\uFF08getSceneGroups\uFF09");
2503
+ scene.command("groups").description("\u573A\u666F\u5206\u7EC4\u9AA8\u67B6").option("--client <client>", "agent / all / connector\uFF0C\u9ED8\u8BA4 agent").action(action(async (ctx, options) => {
2504
+ await run(ctx, "data.scene.groups", toInput(options), false);
2505
+ }));
2506
+ scene.command("items").description("\u7EC4\u5185\u6761\u76EE\uFF08\u63A5\u53E3 / \u6570\u636E\u6E90\uFF09").option("--group <groupId>", "\u5206\u7EC4 ID\uFF0819 \u4F4D\u96EA\u82B1\u53F7\u6309\u5B57\u7B26\u4E32\u4F20\uFF09").option("--client <client>", "agent / all / connector").action(action(async (ctx, options) => {
2507
+ await run(ctx, "data.scene.items", toInput(options), false);
2508
+ }));
2509
+ scene.command("search").description("\u5173\u952E\u8BCD\u5019\u9009\u53EC\u56DE\uFF08\u540E\u7AEF keyword \u4F18\u5148\uFF0C\u672C\u5730\u6253\u5206\u515C\u5E95\uFF09").option("--keywords <a,b>", "\u5173\u952E\u8BCD\uFF08\u4E5F\u652F\u6301\u7A7A\u683C / \u3001 \u5206\u9694\uFF09").option("--keyword <a,b>", "\u540C --keywords").option("--client <client>", "agent / all / connector").option("--max-groups <n>", "\u5019\u9009\u5206\u7EC4\u4E0A\u9650\uFF0C\u9ED8\u8BA4 3").option("--max-items <n>", "\u6BCF\u7EC4\u6761\u76EE\u4E0A\u9650\uFF0C\u9ED8\u8BA4 12").option("--scope-group-id <id>", "\u9650\u5B9A\u5355\u4E2A\u5206\u7EC4").option("--server-filter <mode>", "auto / on / off\uFF0C\u9ED8\u8BA4 auto").action(action(async (ctx, options) => {
2510
+ await run(ctx, "data.scene.search", toInput(options), false);
2511
+ }));
2512
+ const moduleCommand = data.command("module").description("\u6A21\u5757\u914D\u7F6E\u63A5\u53E3\u8C03\u7528\uFF08\u914D\u7F6E\u4E2D\u5FC3\u9A71\u52A8\uFF09");
2513
+ moduleCommand.command("call").description("\u6309 confAttrs \u7EC4\u53C2\u5E76\u8C03\u7528\u63A5\u53E3\uFF08\u5DF2\u786E\u5B9A\u6A21\u5757 + \u63A5\u53E3\u4E4B\u540E\u7528\uFF09").option("--conf-key <key>", "confKey").option("--group <module>", "\u6A21\u5757\u552F\u4E00\u6807\u8BC6\uFF0C\u5982 WORKFLOW / EHR / DOCUMENT").option("--type <confType>", "confType\uFF0C\u9ED8\u8BA4 api").option("--conf-file <path>", "\u672C\u5730 confAttrs \u6587\u4EF6\uFF08\u8DF3\u8FC7\u914D\u7F6E\u8BFB\u53D6\uFF09").option("--args <json|@file>", "\u4E1A\u52A1\u53C2\u6570\uFF08JSON \u5BF9\u8C61\uFF09").option("--query <k=v&k2=v2>", "\u4E1A\u52A1\u53C2\u6570\uFF08query \u4E32\uFF0C\u4E0E --args \u5408\u5E76\uFF09").option("--header <k: v>", "\u989D\u5916\u8BF7\u6C42\u5934\uFF08\u5355\u4E2A\uFF09").option("--headers <json|@file>", "\u989D\u5916\u8BF7\u6C42\u5934\uFF08JSON \u5BF9\u8C61\uFF09").option("--method <GET|POST|FORM>", "\u63D0\u4EA4\u65B9\u5F0F\uFF0C\u9ED8\u8BA4\u53D6 confAttrs.http_method").option("--limit <n>", "\u884C\u6570\u4E0A\u9650\uFF0C\u9ED8\u8BA4 50\uFF1B0 = \u4E0D\u622A\u65AD").option("--fields <a,b|@f>", "\u53EA\u4FDD\u7559\u8FD9\u4E9B\u884C\u5B57\u6BB5").option("--raw", "\u539F\u6837\u8F93\u51FA\u54CD\u5E94\u4F53").option("--show-params", "\u53EA\u6253\u5370\u5165/\u51FA\u53C2\u8BF4\u660E\uFF0C\u4E0D\u8C03\u63A5\u53E3").option("--full", "--show-params \u65F6\u56DE\u663E\u5B8C\u6574 request_example").option("--with-example", "\u540C --full").option("--no-example", "--show-params \u65F6\u5F3A\u5236\u7701\u7565 request_example").option("--dry-run", "\u53EA\u7EC4\u88C5\u8BF7\u6C42\u4E0D\u53D1\u9001\uFF08\u51ED\u636E\u8131\u654F\uFF09").option("--timeout <sec>", "\u8D85\u65F6\u79D2\u6570\uFF0C\u9ED8\u8BA4 60").action(action(async (ctx, options) => {
2514
+ await run(ctx, "data.module.call", toInput(options), false);
2515
+ }));
2516
+ const attend = data.command("attend").description("\u8003\u52E4 REST \u63A5\u53E3");
2517
+ attend.command("statis").description("\u8003\u52E4\u5047\u671F\u4F59\u989D\uFF08\u5E74\u5047 / \u5E26\u85AA\u75C5\u5047 / \u5E26\u85AA\u4E8B\u5047\uFF09").option("--user <\u4EBA\u5458ID>", "\u67E5\u672C\u4EBA\u53EF\u4E0D\u4F20\uFF0C\u9ED8\u8BA4\u5F53\u524D\u767B\u5F55\u7528\u6237").option("--begin <yyyy-MM-dd>", "\u8D77\u59CB\u65E5\u671F\uFF0C\u9ED8\u8BA4\u5F53\u6708 1 \u53F7").option("--end <yyyy-MM-dd>", "\u7ED3\u675F\u65E5\u671F\uFF0C\u9ED8\u8BA4\u5F53\u6708\u6700\u540E\u4E00\u5929").action(action(async (ctx, options) => {
2518
+ await run(ctx, "data.attend.statis", toInput(options), false);
2519
+ }));
2520
+ }
2521
+ };
2522
+ export {
2523
+ dataShortcut,
2524
+ toInput
2525
+ };