weaver-work-cli 0.1.28 → 0.1.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/dist/chunks/archive-U766FTFH.js +2537 -0
  2. package/dist/chunks/archive-oa-DMWEKX3L.js +1317 -0
  3. package/dist/chunks/asset-TCR7VDEV.js +2109 -0
  4. package/dist/chunks/attachment-content-AQNX5N3S.js +23 -0
  5. package/dist/chunks/blog-EVZWGDVM.js +2157 -0
  6. package/dist/chunks/caizhilian-JOWS6SL5.js +10087 -0
  7. package/dist/chunks/calendar-5WNCV66Q.js +1195 -0
  8. package/dist/chunks/chunk-2DUV44UX.js +15606 -0
  9. package/dist/chunks/chunk-324YPTC2.js +1607 -0
  10. package/dist/chunks/chunk-65QMVWHS.js +231 -0
  11. package/dist/chunks/chunk-6V7ZLF34.js +387 -0
  12. package/dist/chunks/chunk-AC7KJWC5.js +358 -0
  13. package/dist/chunks/chunk-AJ62BGAW.js +29 -0
  14. package/dist/chunks/chunk-BUSC6UAE.js +43 -0
  15. package/dist/chunks/chunk-CVZ2JOSW.js +62 -0
  16. package/dist/chunks/chunk-D4LTJSJD.js +477 -0
  17. package/dist/chunks/chunk-EG6ZU444.js +654 -0
  18. package/dist/chunks/chunk-EZALDOQH.js +383 -0
  19. package/dist/chunks/chunk-FMPJJYYI.js +106 -0
  20. package/dist/chunks/chunk-G2JSIUWF.js +769 -0
  21. package/dist/chunks/chunk-GCG2NMWR.js +703 -0
  22. package/dist/chunks/chunk-GPMFD4RD.js +75 -0
  23. package/dist/chunks/chunk-H3WDBYJW.js +508 -0
  24. package/dist/chunks/chunk-H6XSTSLM.js +2357 -0
  25. package/dist/chunks/chunk-J7RJTZSV.js +5556 -0
  26. package/dist/chunks/chunk-LUSPKZKY.js +53 -0
  27. package/dist/chunks/chunk-NIAJ5ZCG.js +73 -0
  28. package/dist/chunks/chunk-NOODWMCL.js +584 -0
  29. package/dist/chunks/chunk-OOUTBLZ4.js +51 -0
  30. package/dist/chunks/chunk-P26ZWSKU.js +73 -0
  31. package/dist/chunks/chunk-QWY6PGL6.js +3472 -0
  32. package/dist/chunks/chunk-R2IJAK7T.js +464 -0
  33. package/dist/chunks/chunk-R7O5PUWO.js +205 -0
  34. package/dist/chunks/chunk-RCGYCOMG.js +6962 -0
  35. package/dist/chunks/chunk-VZTXRG6X.js +403 -0
  36. package/dist/chunks/chunk-WHD4XMRP.js +161 -0
  37. package/dist/chunks/chunk-YLCYX7LE.js +371 -0
  38. package/dist/chunks/chunk-ZEDWSH32.js +68 -0
  39. package/dist/chunks/continuation-2CKSBLA6.js +11 -0
  40. package/dist/chunks/continuation-HZIZRZBX.js +13 -0
  41. package/dist/chunks/continuation-NLECEJPX.js +11 -0
  42. package/dist/chunks/ebuilder-form-NJ4YK6CC.js +2276 -0
  43. package/dist/chunks/ehr-MMYN36VA.js +5241 -0
  44. package/dist/chunks/employee-SAK2QYXX.js +11 -0
  45. package/dist/chunks/esb-HIWHOU7Q.js +141 -0
  46. package/dist/chunks/fna-KBACQTA5.js +1444 -0
  47. package/dist/chunks/host-3OHS5QUX.js +21 -0
  48. package/dist/chunks/host-IG6KEH5Q.js +19 -0
  49. package/dist/chunks/host-KQL5N4HO.js +23 -0
  50. package/dist/chunks/host-LLSZQCWR.js +17 -0
  51. package/dist/chunks/hrm-LYEC67ZQ.js +244 -0
  52. package/dist/chunks/im-RN2UKAEU.js +252 -0
  53. package/dist/chunks/invoice-EEPHLAF6.js +5179 -0
  54. package/dist/chunks/jiuchuanhui-WVVZYSJE.js +1940 -0
  55. package/dist/chunks/lazy-dispatch-MDOFFL2S.js +28 -0
  56. package/dist/chunks/mail-LNQLTF6L.js +2695 -0
  57. package/dist/chunks/meeting-XSD3BDVQ.js +504 -0
  58. package/dist/chunks/msg-parse-4GSQ2WTO.js +41 -0
  59. package/dist/chunks/okr-TMWTIU2K.js +2482 -0
  60. package/dist/chunks/plan-A2FSFA7T.js +2025 -0
  61. package/dist/chunks/project-T26QLBQF.js +1361 -0
  62. package/dist/chunks/registry-2VLUAESA.js +14 -0
  63. package/dist/chunks/registry-JCFEYXOE.js +18 -0
  64. package/dist/chunks/registry-NYPYMZXG.js +16 -0
  65. package/dist/chunks/registry-Q7OQJ3SU.js +19 -0
  66. package/dist/chunks/registry-ZJMJVWFA.js +19 -0
  67. package/dist/chunks/room-recommend-UR4ZDZS6.js +20 -0
  68. package/dist/chunks/schedule-5L2PM4M6.js +24 -0
  69. package/dist/chunks/state-Y2XBP6YE.js +15 -0
  70. package/dist/chunks/workflow-TR6PG2SL.js +245 -0
  71. package/dist/cmd/argv.js +45 -0
  72. package/dist/cmd/docs/index.js +3 -3
  73. package/dist/cmd/lazy-dispatch.js +20 -0
  74. package/dist/cmd/root.js +2 -4
  75. package/dist/cmd/setup/index.js +2 -2
  76. package/dist/cmd/skills/index.js +2 -2
  77. package/dist/core/package-paths.js +47 -0
  78. package/dist/index.js +163 -7
  79. package/dist/internal/e10/auth/xiaoe.js +3 -3
  80. package/dist/internal/e10/request-runtime.js +18 -62
  81. package/dist/internal/skills/detector.js +2 -2
  82. package/dist/shortcuts/contract/data/performance-catalog.js +1306 -0
  83. package/dist/shortcuts/contract/host.js +91 -35
  84. package/dist/shortcuts/contract/index.js +213 -0
  85. package/dist/shortcuts/contract/manifest.js +928 -0
  86. package/dist/shortcuts/contract/ooxml/docx.js +295 -0
  87. package/dist/shortcuts/contract/ooxml/xlsx.js +221 -0
  88. package/dist/shortcuts/contract/ooxml/zip.js +158 -0
  89. package/dist/shortcuts/contract/operations/assistant.js +1156 -0
  90. package/dist/shortcuts/contract/operations/clause-library.js +522 -0
  91. package/dist/shortcuts/contract/operations/compare.js +193 -0
  92. package/dist/shortcuts/contract/operations/credit-page.js +34 -0
  93. package/dist/shortcuts/contract/operations/flow.js +98 -0
  94. package/dist/shortcuts/contract/operations/page.js +66 -0
  95. package/dist/shortcuts/contract/operations/performance.js +733 -0
  96. package/dist/shortcuts/contract/operations/quote.js +557 -0
  97. package/dist/shortcuts/contract/operations/recommend.js +78 -0
  98. package/dist/shortcuts/contract/operations/registry.js +18 -0
  99. package/dist/shortcuts/contract/operations/review.js +83 -0
  100. package/dist/shortcuts/contract/operations/shared.js +37 -0
  101. package/dist/shortcuts/contract/operations/upload.js +108 -0
  102. package/dist/shortcuts/contract/operations/write.js +3 -2
  103. package/dist/shortcuts/index.js +140 -40
  104. package/dist/shortcuts/invoice/host.js +2 -1
  105. package/dist/shortcuts/invoice/manifest.js +36 -12
  106. package/dist/shortcuts/invoice/operations/issuing-qys.js +132 -36
  107. package/dist/shortcuts/invoice/operations/reim-auto.js +9 -0
  108. package/dist/shortcuts/invoice/operations/reim.js +81 -5
  109. package/dist/shortcuts/invoice/operations/shared.js +12 -5
  110. package/dist/shortcuts/meeting/host.js +45 -3
  111. package/dist/shortcuts/meeting/invitation/docx.js +442 -0
  112. package/dist/shortcuts/meeting/operations/attachment-content.js +418 -0
  113. package/dist/shortcuts/meeting/operations/attachment.js +442 -0
  114. package/dist/shortcuts/meeting/operations/eb/cache.js +57 -0
  115. package/dist/shortcuts/meeting/operations/eb/catalog.js +343 -28
  116. package/dist/shortcuts/meeting/operations/eb/conflict.js +372 -11
  117. package/dist/shortcuts/meeting/operations/eb/create-flow.js +710 -0
  118. package/dist/shortcuts/meeting/operations/eb/decision.js +47 -1
  119. package/dist/shortcuts/meeting/operations/eb/factory.js +129 -11
  120. package/dist/shortcuts/meeting/operations/eb/index.js +122 -2
  121. package/dist/shortcuts/meeting/operations/eb/room-recommend.js +378 -0
  122. package/dist/shortcuts/meeting/operations/eb/room-summary.js +84 -0
  123. package/dist/shortcuts/meeting/operations/eb/schedule.js +450 -0
  124. package/dist/shortcuts/meeting/operations/from-group-chat.js +576 -0
  125. package/dist/shortcuts/meeting/operations/invitation.js +458 -0
  126. package/dist/shortcuts/meeting/operations/minute-content.js +266 -0
  127. package/dist/shortcuts/meeting/operations/pipeline.js +489 -0
  128. package/dist/shortcuts/meeting/operations/qrcode.js +131 -0
  129. package/dist/shortcuts/meeting/operations/receipts.js +1 -1
  130. package/dist/shortcuts/meeting/operations/registry.js +18 -0
  131. package/dist/shortcuts/meeting/operations/summary.js +276 -0
  132. package/dist/shortcuts/meeting/operations/task-notify.js +325 -0
  133. package/dist/shortcuts/meeting/operations.js +42 -1
  134. package/dist/shortcuts/meeting/qr/encoder.js +427 -0
  135. package/dist/shortcuts/meeting/qr/render.js +103 -0
  136. package/dist/shortcuts/workflow/index.js +3 -0
  137. package/dist/shortcuts/workflow/operations/form.js +17 -5
  138. package/dist/shortcuts/workflow/operations/read.js +13 -6
  139. package/dist/shortcuts/workflow/operations/registry.js +2 -0
  140. package/dist/shortcuts/workflow/operations/todoSmartConvert/businessRules.js +331 -0
  141. package/dist/shortcuts/workflow/operations/todoSmartConvert/detailFieldRules.js +133 -0
  142. package/dist/shortcuts/workflow/operations/todoSmartConvert/summaryCache.js +326 -0
  143. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoDetailCache.js +113 -0
  144. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoDetailFetcher.js +259 -0
  145. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoListRows.js +64 -0
  146. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoOutputPlanner.js +28 -0
  147. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.aggregate.js +70 -0
  148. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +267 -0
  149. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +392 -0
  150. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.detail.js +165 -0
  151. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.group.js +448 -0
  152. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.groupSummary.js +348 -0
  153. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +222 -0
  154. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.pipeline.js +66 -0
  155. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.smartGroup.js +502 -0
  156. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.summary.js +540 -0
  157. package/docs/_catalog.md +1 -0
  158. package/docs/contract.md +39 -4
  159. package/docs/invoice.md +7 -7
  160. package/docs/todo-smart-convert/README.md +171 -0
  161. package/docs/todo-smart-convert/data-contract.md +236 -0
  162. package/docs/todo-smart-convert/mock/ai-todo-query-target.json +209 -0
  163. package/docs/todo-smart-convert/subgroup-rules.md +245 -0
  164. package/package.json +3 -2
  165. package/scripts/bundle.mjs +63 -0
  166. package/scripts/package-skill.mjs +1 -1
  167. package/skill-template/business-info.json +25 -4
  168. package/skill-template/domains/jinchengda.md +16 -3
  169. package/skill-template/domains/yepiaotong.md +3 -3
  170. package/skills/weaver-e10-jinchengda/SKILL.md +111 -31
  171. package/skills/weaver-e10-jinchengda/references/contract-agent-entry.md +7 -13
  172. package/skills/weaver-e10-jinchengda/references/contract-ai-assistant.md +150 -0
  173. package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +87 -0
  174. package/skills/weaver-e10-jinchengda/references/contract-clause-library-crud.md +111 -0
  175. package/skills/weaver-e10-jinchengda/references/contract-clause-recommender.md +0 -15
  176. package/skills/weaver-e10-jinchengda/references/contract-clause-reference-save.md +0 -13
  177. package/skills/weaver-e10-jinchengda/references/contract-credit-page.md +50 -0
  178. package/skills/weaver-e10-jinchengda/references/contract-disabled-capabilities.md +4 -2
  179. package/skills/weaver-e10-jinchengda/references/contract-doc-compare.md +74 -0
  180. package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +84 -0
  181. package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +29 -0
  182. package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +28 -0
  183. package/skills/weaver-e10-jinchengda/references/contract-request-status.md +2 -21
  184. package/skills/weaver-e10-jinchengda/references/contract-request-write.md +0 -24
  185. package/skills/weaver-e10-jinchengda/references/contract-signing-subjects.md +0 -15
  186. package/skills/weaver-e10-jinchengda/references/contract-subject-create.md +0 -17
  187. package/skills/weaver-e10-jinchengda/references/contract-template-recommend.md +70 -0
  188. package/skills/weaver-e10-jinchengda/references/contract-template-selector.md +0 -15
  189. package/skills/weaver-e10-jinchengda/references/contract-workflow-discovery.md +0 -15
  190. package/skills/weaver-e10-jinchengda/references/source-manifest.json +1168 -152
  191. package/skills/weaver-e10-meeting/SKILL.md +493 -17
  192. package/skills/weaver-e10-meeting/references/meeting-change.md +4 -4
  193. package/skills/weaver-e10-meeting/references/meeting-create.md +6 -6
  194. package/skills/weaver-e10-meeting/references/meeting-eb.md +503 -27
  195. package/skills/weaver-e10-meeting/references/meeting-invitation.md +113 -0
  196. package/skills/weaver-e10-meeting/references/meeting-lifecycle.md +6 -6
  197. package/skills/weaver-e10-meeting/references/meeting-minute-file.md +425 -0
  198. package/skills/weaver-e10-meeting/references/meeting-queries.md +4 -4
  199. package/skills/weaver-e10-meeting/references/meeting-receipts-signs.md +15 -15
  200. package/skills/weaver-e10-meeting/references/meeting-verification.md +19 -11
  201. package/skills/weaver-e10-meeting.zip +0 -0
  202. package/skills/weaver-e10-workflow/SKILL.md +23 -1
  203. package/skills/weaver-e10-workflow/references/todo-smart-convert.md +282 -0
  204. package/skills/weaver-e10-workflow/scripts/todo-summary.cjs +695 -0
  205. package/skills/weaver-e10-yepiaotong/SKILL.md +15 -11
  206. package/skills/weaver-e10-yepiaotong/references/invoice-enterprise-list.md +1 -1
  207. package/skills/weaver-e10-yepiaotong/references/invoice-issuing-examples.md +10 -7
  208. package/skills/weaver-e10-yepiaotong/references/invoice-issuing-form-fill-rules.md +41 -14
  209. package/skills/weaver-e10-yepiaotong/references/invoice-issuing-workflow.md +54 -26
  210. package/skills/weaver-e10-yepiaotong/references/invoice-personal-list.md +6 -5
  211. package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +14 -11
  212. package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +97 -56
  213. package/skills/weaver-e10-yepiaotong/references/reim-examples.md +84 -60
  214. package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +142 -105
  215. package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +53 -194
  216. package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +7 -7
  217. package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +164 -72
  218. package/skills/weaver-e10-yepiaotong/references/source-manifest.json +8 -2
  219. package/templates/meeting/invitation.docx +0 -0
@@ -0,0 +1,584 @@
1
+ import { createRequire as __esbuildCreateRequire } from 'node:module';
2
+ const require = __esbuildCreateRequire(import.meta.url);
3
+ import {
4
+ hrmValidationError
5
+ } from "./chunk-OOUTBLZ4.js";
6
+
7
+ // src/shortcuts/hrm/operations/types.ts
8
+ var READ = "read";
9
+ function hrmSuccess(action, data, meta) {
10
+ const payload = { ok: true, action, data };
11
+ if (meta && Object.keys(meta).length > 0) payload.meta = meta;
12
+ return payload;
13
+ }
14
+ function schemaOf(properties, options = {}) {
15
+ return {
16
+ type: "object",
17
+ additionalProperties: false,
18
+ properties,
19
+ ...options.required?.length ? { required: options.required } : {},
20
+ ...options.description ? { description: options.description } : {}
21
+ };
22
+ }
23
+ var SCHEMA_ID = { oneOf: [{ type: "integer" }, { type: "string", pattern: "^\\d+$" }] };
24
+ var SCHEMA_ID_LIST = { type: "array", items: SCHEMA_ID };
25
+ var SCHEMA_PAGE = {
26
+ current: SCHEMA_ID,
27
+ pageSize: SCHEMA_ID
28
+ };
29
+
30
+ // src/shortcuts/hrm/operations/shared.ts
31
+ var FORBIDDEN_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
32
+ function asObject(value) {
33
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
34
+ throw hrmValidationError("input_not_object", "\u8F93\u5165\u5FC5\u987B\u662F JSON \u5BF9\u8C61");
35
+ }
36
+ return value;
37
+ }
38
+ function assertNoForbiddenKeys(input) {
39
+ for (const key of Object.keys(input)) {
40
+ if (FORBIDDEN_KEYS.has(key)) {
41
+ throw hrmValidationError("forbidden_key", `\u8F93\u5165\u5305\u542B\u975E\u6CD5\u5B57\u6BB5\uFF1A${key}`);
42
+ }
43
+ }
44
+ }
45
+ function toNumber(value, field) {
46
+ if (value === void 0 || value === null || value === "") return void 0;
47
+ const numeric = Number(value);
48
+ if (!Number.isFinite(numeric)) {
49
+ throw hrmValidationError("number_invalid", `${field} \u5FC5\u987B\u662F\u6570\u5B57`);
50
+ }
51
+ return numeric;
52
+ }
53
+ function toPositiveInt(value, field) {
54
+ if (value === void 0 || value === null || value === "") return void 0;
55
+ const numeric = Number(value);
56
+ if (!Number.isFinite(numeric)) {
57
+ throw hrmValidationError("number_invalid", `${field} \u5FC5\u987B\u662F\u6570\u5B57`);
58
+ }
59
+ const truncated = Math.trunc(numeric);
60
+ if (truncated !== numeric || truncated <= 0) {
61
+ throw hrmValidationError("number_invalid", `${field} \u5FC5\u987B\u662F\u6B63\u6574\u6570`);
62
+ }
63
+ return truncated;
64
+ }
65
+ function toStringIdList(value, field) {
66
+ if (value === void 0 || value === null) return void 0;
67
+ const list = Array.isArray(value) ? value : [value];
68
+ if (list.length === 0) return void 0;
69
+ return list.map((item, index) => {
70
+ if (item === void 0 || item === null || item === "") {
71
+ throw hrmValidationError("id_list_invalid", `${field}[${index}] \u4E0D\u80FD\u4E3A\u7A7A`);
72
+ }
73
+ const text = String(item);
74
+ if (!/^\d+$/.test(text)) {
75
+ throw hrmValidationError("id_list_invalid", `${field}[${index}] \u5FC5\u987B\u662F\u6570\u5B57 ID`);
76
+ }
77
+ return text;
78
+ });
79
+ }
80
+ function pickDefined(value, keys) {
81
+ const result = {};
82
+ for (const key of keys) {
83
+ if (value[key] !== void 0) result[key] = value[key];
84
+ }
85
+ return result;
86
+ }
87
+ function browserBaseBody() {
88
+ return {
89
+ browserMultiple: true,
90
+ authWecahtBook: false,
91
+ wxDepNeedConvertCount: 0,
92
+ wxEmpNeedConvertCount: 0,
93
+ wxTotalNeedConvertCount: 0
94
+ };
95
+ }
96
+ function personLink(baseUrl, id) {
97
+ return `${baseUrl}/sp/hrm/profileInfo/${String(id)}`;
98
+ }
99
+ function orgLink(baseUrl, id) {
100
+ return `${baseUrl}/sp/hrm/orgCard/${String(id)}`;
101
+ }
102
+ function positionLink(baseUrl, id) {
103
+ return `${baseUrl}/sp/hrm/positionCard/${String(id)}`;
104
+ }
105
+ function inferEmployeeField(target) {
106
+ if (/@/.test(target)) return { key: "email", value: target };
107
+ if (/^\d{11}$/.test(target)) return { key: "mobile", value: target };
108
+ if (/^\d+$/.test(target) || /^[A-Za-z][A-Za-z0-9]*\d[A-Za-z0-9]*$/.test(target)) {
109
+ return { key: "job_num", value: target };
110
+ }
111
+ return { key: "username", value: target };
112
+ }
113
+ async function resolveDepartmentIdByName(host, name) {
114
+ const resp = await host.request({
115
+ method: "POST",
116
+ path: "/api/hrm/common/browser/data/department",
117
+ body: {
118
+ ...browserBaseBody(),
119
+ virtualType: "ALL",
120
+ cmd: "list",
121
+ current: 1,
122
+ pageSize: 200,
123
+ formDatas: { name: [{ nameCondition: { id: "eq", content: "\u7B49\u4E8E", disabled: false }, name }] },
124
+ quickSearchDatas: {},
125
+ type: "and",
126
+ stopDepartment: false
127
+ }
128
+ });
129
+ const rows = resp?.data?.data ?? [];
130
+ if (rows.length === 0) {
131
+ throw hrmValidationError("dept_not_found", `\u672A\u627E\u5230\u90E8\u95E8\uFF1A${name}\uFF08\u8BF7\u786E\u8BA4\u90E8\u95E8\u540D\u79F0\uFF09`);
132
+ }
133
+ if (rows.length > 1) {
134
+ throw hrmValidationError("dept_ambiguous", `\u90E8\u95E8\u91CD\u540D\uFF08${rows.length} \u4E2A\u5019\u9009\uFF09\uFF1A${rows.map((x) => x.name).join("\u3001")}\uFF0C\u8BF7\u6539\u7528\u90E8\u95E8 id`);
135
+ }
136
+ return rows[0];
137
+ }
138
+
139
+ // src/shortcuts/hrm/operations/employee.ts
140
+ var EMPLOYEE_STATUS = ["normal", "6"];
141
+ var SUBORDINATE_SCOPE = ["direct", "indirect", "all"];
142
+ var SUBORDINATE_BYID_SCOPE = ["direct", "indirect"];
143
+ function maskPhone(p) {
144
+ const s = p ? String(p) : "";
145
+ return s && s.length >= 7 ? s.slice(0, 3) + "****" + s.slice(-4) : s;
146
+ }
147
+ function formatMember(r, baseUrl) {
148
+ const deptId = r.departmentId != null && r.departmentId !== "" ? String(r.departmentId) : "";
149
+ return {
150
+ name: r.name,
151
+ id: r.id,
152
+ userid: r.userid,
153
+ cid: r.cid,
154
+ department: r.department,
155
+ departmentId: deptId,
156
+ position: r.position,
157
+ mobile: maskPhone(r.mobile),
158
+ statusCode: r.statusCode,
159
+ link: personLink(baseUrl, r.id),
160
+ deptLink: deptId ? orgLink(baseUrl, deptId) : ""
161
+ };
162
+ }
163
+ var DETAIL_CORE_FIELDS = [
164
+ "id",
165
+ "name",
166
+ "username",
167
+ "job_num",
168
+ "sex",
169
+ "avatar",
170
+ "personnel_status",
171
+ "status",
172
+ "type",
173
+ "department",
174
+ "subcompany",
175
+ "organization",
176
+ "position",
177
+ "jobsetid",
178
+ "jobset_level",
179
+ "superior",
180
+ "other_superior",
181
+ "only_superior",
182
+ "subordinate",
183
+ "assistant",
184
+ "mobile",
185
+ "email",
186
+ "telephone",
187
+ "office",
188
+ "location",
189
+ "active_date"
190
+ ];
191
+ var DETAIL_ENTITY_FIELDS = ["personnel_status", "department", "subcompany", "position", "jobsetid", "jobset_level", "location"];
192
+ var DETAIL_PERSON_FIELDS = ["superior", "other_superior", "assistant"];
193
+ function slimAvatar(avatar) {
194
+ if (!avatar || typeof avatar !== "object") return avatar;
195
+ const a = avatar;
196
+ const out = {};
197
+ for (const key of ["url", "name", "userId"]) {
198
+ if (a[key] !== void 0 && a[key] !== "") out[key] = a[key];
199
+ }
200
+ return out;
201
+ }
202
+ function slimEntities(value) {
203
+ if (!Array.isArray(value)) return value;
204
+ return value.map((item) => {
205
+ if (!item || typeof item !== "object") return item;
206
+ const e = item;
207
+ return e.name === void 0 ? { id: e.id } : { id: e.id, name: e.name };
208
+ });
209
+ }
210
+ function slimPersons(value) {
211
+ if (!Array.isArray(value)) return value;
212
+ return value.map((item) => {
213
+ if (!item || typeof item !== "object") return item;
214
+ const p = item;
215
+ const out = { id: p.id, name: p.name };
216
+ if (p.statusCode !== void 0) out.statusCode = p.statusCode;
217
+ if (p.avatar !== void 0) out.avatar = slimAvatar(p.avatar);
218
+ return out;
219
+ });
220
+ }
221
+ function pickDetailCore(raw) {
222
+ const out = {};
223
+ for (const key of DETAIL_CORE_FIELDS) {
224
+ const value = raw[key];
225
+ if (value === void 0 || value === null) continue;
226
+ if (DETAIL_PERSON_FIELDS.includes(key)) out[key] = slimPersons(value);
227
+ else if (DETAIL_ENTITY_FIELDS.includes(key)) out[key] = slimEntities(value);
228
+ else if (key === "avatar") out[key] = slimAvatar(value);
229
+ else out[key] = value;
230
+ }
231
+ return out;
232
+ }
233
+ function formatPersonBrief(r, baseUrl) {
234
+ const id = r.id ?? r.employeeId;
235
+ return { id, name: r.name ?? r.username, link: personLink(baseUrl, id) };
236
+ }
237
+ function formatSubordinateFull(r, baseUrl) {
238
+ const id = r.id ?? r.employeeId;
239
+ return {
240
+ id,
241
+ name: r.name ?? r.username,
242
+ pinyin: r.pinyin,
243
+ telephone: r.telephone,
244
+ sex: r.sex,
245
+ personnelStatus: r.personnelStatus,
246
+ department: r.department,
247
+ position: r.position,
248
+ superior: r.superior,
249
+ link: personLink(baseUrl, id)
250
+ };
251
+ }
252
+ function formatQueryRowBrief(r, baseUrl) {
253
+ const id = r.id;
254
+ return {
255
+ id,
256
+ name: r.name,
257
+ department: r.department,
258
+ position: r.position,
259
+ statusCode: r.statusCode,
260
+ link: personLink(baseUrl, id)
261
+ };
262
+ }
263
+ function formatBatch(u, baseUrl) {
264
+ const deptId = u.departmentId != null && u.departmentId !== "" ? String(u.departmentId) : "";
265
+ return {
266
+ name: u.name,
267
+ id: u.id,
268
+ jobNum: u.jobNum,
269
+ department: u.department,
270
+ departmentId: deptId,
271
+ subCompany: u.subCompany,
272
+ position: u.position,
273
+ mobile: maskPhone(u.mobile),
274
+ imCid: u.imCid,
275
+ link: personLink(baseUrl, u.id),
276
+ deptLink: deptId ? orgLink(baseUrl, deptId) : ""
277
+ };
278
+ }
279
+ function resolveEmployeeCondition(args) {
280
+ const explicit = ["email", "mobile", "job_num", "username"].find((k) => {
281
+ const v = args[k];
282
+ return v !== void 0 && v !== null && String(v).trim() !== "";
283
+ });
284
+ if (explicit) return { field: explicit, value: String(args[explicit]).trim() };
285
+ const keyword = args.keyword === void 0 ? "" : String(args.keyword).trim();
286
+ if (!keyword) {
287
+ throw hrmValidationError("empty_condition", "\u5458\u5DE5\u67E5\u8BE2\u5FC5\u987B\u643A\u5E26\u81F3\u5C11\u4E00\u4E2A\u6536\u655B\u6761\u4EF6\uFF1Akeyword\uFF08\u81EA\u52A8\u63A8\u65AD\uFF09\u6216 username/job_num/mobile/email \u4E4B\u4E00");
288
+ }
289
+ const inferred = inferEmployeeField(keyword);
290
+ return { field: inferred.key, value: inferred.value };
291
+ }
292
+ function memberFormDatasBase() {
293
+ return {
294
+ subcompany: [{ subcompanyOpt: "in" }],
295
+ department: [{ departmentOpt: "in" }],
296
+ role: [{ roleOpt: "in" }],
297
+ position: [{ positionOpt: "in" }],
298
+ superior: [{ superiorOpt: "in" }]
299
+ };
300
+ }
301
+ var employeeQuery = {
302
+ name: "hrm.employee.query",
303
+ resource: "employee",
304
+ method: "employee.query",
305
+ action: "hrm.employee.query",
306
+ summary: '\u6309\u5DE5\u53F7/\u59D3\u540D/\u624B\u673A/\u90AE\u7BB1\uFF08keyword \u81EA\u52A8\u63A8\u65AD\u6216\u663E\u5F0F\u5B57\u6BB5\uFF09\u67E5\u8BE2\u5458\u5DE5\uFF1B\u9ED8\u8BA4\u5728\u804C\uFF0Cstatus \u4F20 ["6"] \u67E5\u79BB\u804C\uFF1B\u9ED8\u8BA4\u6BCF\u884C\u53EA\u56DE\u4EBA\u5458\u4FE1\u606F',
307
+ risk: READ,
308
+ inputSchema: schemaOf({
309
+ keyword: { type: "string", description: "\u67E5\u8BE2\u5173\u952E\u8BCD\uFF0C\u81EA\u52A8\u63A8\u65AD\uFF1A\u542B @\u2192\u90AE\u7BB1\uFF1B11 \u4F4D\u7EAF\u6570\u5B57\u2192\u624B\u673A\uFF1B\u7EAF\u6570\u5B57\u6216\u5B57\u6BCD\u5F00\u5934\u542B\u6570\u5B57\u2192\u5DE5\u53F7\uFF1B\u5176\u4F59\u2192\u59D3\u540D\uFF08\u6A21\u7CCA\uFF09" },
310
+ username: { type: "string", description: "\u59D3\u540D\uFF08\u6A21\u7CCA\u5339\u914D\uFF09" },
311
+ job_num: { type: "string", description: "\u5DE5\u53F7\uFF08\u6A21\u7CCA\u5339\u914D\uFF09" },
312
+ mobile: { type: "string", description: "\u624B\u673A\u53F7\uFF08\u6A21\u7CCA\u5339\u914D\uFF09" },
313
+ email: { type: "string", description: "\u90AE\u7BB1\uFF08\u6A21\u7CCA\u5339\u914D\uFF09" },
314
+ status: { type: "array", items: { type: "string", enum: [...EMPLOYEE_STATUS] }, description: '\u9ED8\u8BA4 ["normal"] \u5728\u804C\uFF1B["6"] \u79BB\u804C\u3002\u4E0D\u80FD\u5355\u72EC\u4F5C\u4E3A\u6536\u655B\u6761\u4EF6' },
315
+ full: { type: "boolean", description: "\u9ED8\u8BA4 false\uFF1A\u6BCF\u884C\u53EA\u56DE\u4EBA\u5458\u4FE1\u606F\uFF08id/name/department/position/statusCode/link\uFF09\uFF1Btrue\uFF1A\u56DE\u5B8C\u6574\u884C\uFF08\u53E6\u542B userid/cid/mobile/departmentId/deptLink\uFF09" },
316
+ ...SCHEMA_PAGE
317
+ }),
318
+ handler: async (args, { host }) => {
319
+ const { field, value } = resolveEmployeeCondition(args);
320
+ const status = Array.isArray(args.status) && args.status.length > 0 ? args.status : ["normal"];
321
+ const statusText = status.map((s) => {
322
+ const text = String(s);
323
+ if (!EMPLOYEE_STATUS.includes(text)) {
324
+ throw hrmValidationError("enum_invalid", `status \u53D6\u503C\u5FC5\u987B\u662F ${EMPLOYEE_STATUS.join(" / ")} \u4E4B\u4E00`);
325
+ }
326
+ return text;
327
+ });
328
+ const formDatas = {
329
+ ...memberFormDatasBase(),
330
+ status: [{ statusSelect: statusText }],
331
+ [field]: [{ [`${field}Opt`]: "in", [`${field}Input`]: value }]
332
+ };
333
+ const body = {
334
+ ...browserBaseBody(),
335
+ cmd: "all",
336
+ formDatas,
337
+ quickSearchDatas: {},
338
+ type: "and",
339
+ containsNoneAccount: false,
340
+ containsPartTimeEmployee: false,
341
+ containsDls: false
342
+ };
343
+ const current = toPositiveInt(args.current, "current");
344
+ const pageSize = toNumber(args.pageSize, "pageSize");
345
+ if (current !== void 0) body.current = current;
346
+ if (pageSize !== void 0) body.pageSize = pageSize;
347
+ const session = await host.getSession();
348
+ const baseUrl = session.baseUrl.replace(/\/+$/, "");
349
+ const dataResp = await host.request({ method: "POST", path: "/api/hrm/common/browser/data/resource", body });
350
+ const rawRows = dataResp?.data?.data ?? [];
351
+ const total = rawRows.length;
352
+ const rows = rawRows.map((r) => args.full === true ? formatMember(r, baseUrl) : formatQueryRowBrief(r, baseUrl));
353
+ const lookingNormal = statusText.includes("normal");
354
+ const hint = lookingNormal && rows.length === 0 ? `\u5728\u804C\u5458\u5DE5\u672A\u67E5\u5230\u300C${value}\u300D\uFF1B\u82E5\u4E3A\u79BB\u804C\u4EBA\u5458\uFF0C\u8BF7\u7528 status=["6"] \u518D\u67E5` : void 0;
355
+ return hrmSuccess("hrm.employee.query", {
356
+ rows,
357
+ total,
358
+ ...hint ? { hint } : {}
359
+ }, { current: current ?? 1, pageSize: pageSize ?? 200 });
360
+ }
361
+ };
362
+ var employeeBatch = {
363
+ name: "hrm.employee.batch",
364
+ resource: "employee",
365
+ method: "employee.batch",
366
+ action: "hrm.employee.batch",
367
+ summary: "\u6309\u4EBA\u5458 id \u5217\u8868\u6279\u91CF\u67E5\u8BE2\u7CBE\u7B80\u8BE6\u60C5\uFF08\u6BCF\u6279 \u2264100 \u81EA\u52A8\u5206\u6279\uFF0C\u4E0D\u542B\u90E8\u95E8/\u5C97\u4F4D/\u4E0A\u7EA7\u540D\u79F0\uFF09",
368
+ risk: READ,
369
+ inputSchema: schemaOf(
370
+ {
371
+ ids: { ...SCHEMA_ID_LIST, description: "\u4EBA\u5458 id \u5217\u8868\uFF08\u957F\u6574\u578B\u6309\u5B57\u7B26\u4E32\uFF09" }
372
+ },
373
+ { required: ["ids"] }
374
+ ),
375
+ handler: async (args, { host }) => {
376
+ const ids = toStringIdList(args.ids, "ids");
377
+ if (!ids || ids.length === 0) {
378
+ throw hrmValidationError("ids_required", "ids \u5FC5\u586B\u4E14\u4E0D\u80FD\u4E3A\u7A7A");
379
+ }
380
+ const session = await host.getSession();
381
+ const baseUrl = session.baseUrl.replace(/\/+$/, "");
382
+ const collected = [];
383
+ for (let i = 0; i < ids.length; i += 100) {
384
+ const resp = await host.request({
385
+ method: "POST",
386
+ path: "/api/hrm/common/getEmployeeByIds",
387
+ body: { userIdList: ids.slice(i, i + 100), externalIdList: [] },
388
+ headers: { devtype: "5" }
389
+ });
390
+ const userList = resp?.data?.userList ?? [];
391
+ collected.push(...userList);
392
+ }
393
+ const rows = collected.map((r) => formatBatch(r, baseUrl));
394
+ return hrmSuccess("hrm.employee.batch", { rows, total: rows.length });
395
+ }
396
+ };
397
+ var employeeDetail = {
398
+ name: "hrm.employee.detail",
399
+ resource: "employee",
400
+ method: "employee.detail",
401
+ action: "hrm.employee.detail",
402
+ summary: "\u6309\u4EBA\u5458 id \u53D6\u4EBA\u5458\u5361\u7247\uFF08\u9ED8\u8BA4\u53EA\u56DE\u6838\u5FC3\u4E1A\u52A1\u5B57\u6BB5\uFF1Bfull=true \u56DE\u5B8C\u6574\u5361\u7247 85 \u4E2A\u9876\u5C42\u952E\uFF09",
403
+ risk: READ,
404
+ inputSchema: schemaOf(
405
+ {
406
+ id: SCHEMA_ID,
407
+ full: { type: "boolean", description: "\u9ED8\u8BA4 false\uFF1A\u53EA\u56DE\u6838\u5FC3\u4E1A\u52A1\u5B57\u6BB5\uFF08\u59D3\u540D/\u5DE5\u53F7/\u7EC4\u7EC7/\u5C97\u4F4D/\u4E0A\u7EA7/\u52A9\u7406/\u8054\u7CFB\u65B9\u5F0F/\u529E\u516C\u5730\u70B9\u7B49\uFF0C\u4F53\u79EF\u7EA6\u4E3A\u5B8C\u6574\u5361\u7247\u7684 1/5\uFF09\uFF1Btrue\uFF1A\u56DE\u5B8C\u6574\u4EBA\u5458\u5361\u7247\uFF08\u542B password\u3001last_android\u3001hideFieldList\u3001setting\u3001*_admin \u7B49\u767B\u5F55/\u7BA1\u7406\u5143\u6570\u636E\uFF09" }
408
+ },
409
+ { required: ["id"] }
410
+ ),
411
+ handler: async (args, { host }) => {
412
+ const id = String(args.id).trim();
413
+ if (!id) throw hrmValidationError("id_required", "id \u5FC5\u586B");
414
+ const session = await host.getSession();
415
+ const baseUrl = session.baseUrl.replace(/\/+$/, "");
416
+ const resp = await host.request({
417
+ method: "GET",
418
+ path: `/api/hrm/card/get/${id}`,
419
+ query: { id, readOnly: true },
420
+ headers: { Referer: `${baseUrl}/sp/hrm/profileInfo/${id}` }
421
+ });
422
+ const raw = resp?.data?.data ?? {};
423
+ const payload = args.full === true ? raw : pickDetailCore(raw);
424
+ return hrmSuccess("hrm.employee.detail", { ...payload, id, link: personLink(baseUrl, id) });
425
+ }
426
+ };
427
+ var subordinateMine = {
428
+ name: "hrm.subordinate.mine",
429
+ resource: "employee",
430
+ method: "subordinate.mine",
431
+ action: "hrm.subordinate.mine",
432
+ summary: "\u67E5\u5F53\u524D\u767B\u5F55\u4EBA\u7684\u4E0B\u5C5E\uFF08all \u6240\u6709/direct \u76F4\u63A5/indirect \u95F4\u63A5\uFF09\uFF0C\u57FA\u4E8E\u5F53\u524D\u4F1A\u8BDD\u8EAB\u4EFD\uFF1B\u9ED8\u8BA4\u6BCF\u884C\u53EA\u56DE id+name",
433
+ risk: READ,
434
+ inputSchema: schemaOf({
435
+ scope: { type: "string", enum: [...SUBORDINATE_SCOPE], description: "\u9ED8\u8BA4 all\uFF1Bdirect \u76F4\u63A5 / indirect \u95F4\u63A5 / all \u6240\u6709" },
436
+ full: { type: "boolean", description: "\u9ED8\u8BA4 false\uFF1A\u6BCF\u884C\u53EA\u56DE id/name/link\uFF1Btrue\uFF1A\u56DE\u5B8C\u6574\u884C\uFF08\u90E8\u95E8/\u5C97\u4F4D/\u624B\u673A/\u72B6\u6001\u7B49\uFF09" },
437
+ ...SCHEMA_PAGE
438
+ }),
439
+ handler: async (args, { host }) => {
440
+ const scope = args.scope === void 0 ? "all" : String(args.scope);
441
+ const subSelected = { direct: "directSubordinate", indirect: "indirectSubordinate", all: "allSubordinate" }[scope] ?? "allSubordinate";
442
+ const body = {
443
+ ...browserBaseBody(),
444
+ cmd: "mySubordinate",
445
+ subSelected,
446
+ companyId: "1",
447
+ formDatas: {},
448
+ quickSearchDatas: {},
449
+ type: "and",
450
+ containsNoneAccount: true,
451
+ containsPartTimeEmployee: false
452
+ };
453
+ const current = toPositiveInt(args.current, "current");
454
+ const pageSize = toNumber(args.pageSize, "pageSize");
455
+ if (current !== void 0) body.current = current;
456
+ if (pageSize !== void 0) body.pageSize = pageSize;
457
+ const session = await host.getSession();
458
+ const baseUrl = session.baseUrl.replace(/\/+$/, "");
459
+ const dataResp = await host.request({ method: "POST", path: "/api/hrm/common/browser/data/resource", body });
460
+ const rawRows = dataResp?.data?.data ?? [];
461
+ const total = rawRows.length;
462
+ const rows = rawRows.map((r) => args.full === true ? formatMember(r, baseUrl) : formatPersonBrief(r, baseUrl));
463
+ return hrmSuccess("hrm.subordinate.mine", { rows, total, scope }, { current: current ?? 1, pageSize: pageSize ?? 200 });
464
+ }
465
+ };
466
+ var subordinateById = {
467
+ name: "hrm.subordinate.by-id",
468
+ resource: "employee",
469
+ method: "subordinate.by-id",
470
+ action: "hrm.subordinate.by-id",
471
+ summary: "\u6309\u76EE\u6807\u4EBA\u5458 id \u67E5\u5176\u76F4\u63A5/\u95F4\u63A5\u4E0B\u5C5E\uFF08\u65E0\u9700\u5207\u6362\u4F1A\u8BDD\uFF09\uFF1B\u9ED8\u8BA4\u6BCF\u884C\u53EA\u56DE id+name\uFF1B\u6240\u6709\u4E0B\u5C5E = direct + indirect \u4E24\u6B21\u5E76\u96C6",
472
+ risk: READ,
473
+ inputSchema: schemaOf(
474
+ {
475
+ id: SCHEMA_ID,
476
+ scope: { type: "string", enum: [...SUBORDINATE_BYID_SCOPE], description: "\u9ED8\u8BA4 direct\uFF1Bdirect \u76F4\u63A5 / indirect \u95F4\u63A5" },
477
+ full: { type: "boolean", description: "\u9ED8\u8BA4 false\uFF1A\u6BCF\u884C\u53EA\u56DE id/name/link\uFF1Btrue\uFF1A\u56DE\u5B8C\u6574\u884C\uFF08\u90E8\u95E8/\u5C97\u4F4D/\u4E0A\u7EA7/\u7535\u8BDD\u7B49\uFF09" },
478
+ pageNo: { ...SCHEMA_ID, description: "\u9875\u7801\uFF0C\u4ECE 1 \u5F00\u59CB\u3002\u26A0\uFE0F \u672C\u64CD\u4F5C\u7528 pageNo\uFF08\u4E0D\u662F current\uFF09" },
479
+ pageSize: { ...SCHEMA_ID, description: "\u6BCF\u9875\u6761\u6570\uFF0C\u9ED8\u8BA4 10" }
480
+ },
481
+ { required: ["id"] }
482
+ ),
483
+ handler: async (args, { host }) => {
484
+ const id = String(args.id).trim();
485
+ if (!id) throw hrmValidationError("id_required", "id \u5FC5\u586B");
486
+ const scope = args.scope === void 0 ? "direct" : String(args.scope);
487
+ const path = scope === "indirect" ? `/api/bs/hrm/user/myIndirectSubordinates/${id}` : `/api/bs/hrm/user/myDirectSubordinates/${id}`;
488
+ const pageNo = toPositiveInt(args.pageNo, "pageNo") ?? 1;
489
+ const pageSize = toNumber(args.pageSize, "pageSize") ?? 10;
490
+ const session = await host.getSession();
491
+ const baseUrl = session.baseUrl.replace(/\/+$/, "");
492
+ const resp = await host.request({
493
+ method: "GET",
494
+ path,
495
+ query: { id, pageNo, pageSize, virtualId: "", isMobile: "false" },
496
+ headers: { Referer: `${baseUrl}/hrm/addressbook/department` }
497
+ });
498
+ const page = resp?.data?.page ?? {};
499
+ const rawRows = Array.isArray(page.result) ? page.result : [];
500
+ const rows = rawRows.map((r) => args.full === true ? formatSubordinateFull(r, baseUrl) : formatPersonBrief(r, baseUrl));
501
+ return hrmSuccess("hrm.subordinate.by-id", {
502
+ rows,
503
+ total: Number(page.totalCount ?? rows.length),
504
+ scope,
505
+ page: {
506
+ pageNo,
507
+ pageSize,
508
+ hasNext: page.hasNext ?? false,
509
+ totalPages: page.totalPages ?? 1
510
+ }
511
+ });
512
+ }
513
+ };
514
+ var deptMembers = {
515
+ name: "hrm.dept.members",
516
+ resource: "employee",
517
+ method: "dept.members",
518
+ action: "hrm.dept.members",
519
+ summary: "\u67E5\u67D0\u90E8\u95E8/\u5206\u90E8\u4E0B\u7684\u76F4\u63A5\u6210\u5458\uFF08\u90E8\u95E8\u540D\u6216 id\uFF1B\u90E8\u95E8\u540D\u9700\u552F\u4E00\uFF0C\u91CD\u540D\u6539\u7528 id\uFF09\uFF1B\u9ED8\u8BA4\u6BCF\u884C\u53EA\u56DE id+name",
520
+ risk: READ,
521
+ inputSchema: schemaOf(
522
+ {
523
+ dept: { type: "string", description: "\u90E8\u95E8/\u5206\u90E8\u540D\u79F0\uFF08\u9700\u552F\u4E00\uFF09\u6216\u7EC4\u7EC7\u8282\u70B9 id" },
524
+ full: { type: "boolean", description: "\u9ED8\u8BA4 false\uFF1A\u6BCF\u884C\u53EA\u56DE id/name/link\uFF1Btrue\uFF1A\u56DE\u5B8C\u6574\u884C\uFF08\u90E8\u95E8/\u5C97\u4F4D/\u624B\u673A/\u72B6\u6001/\u90E8\u95E8\u5361\u7247\u94FE\u63A5\u7B49\uFF09" },
525
+ ...SCHEMA_PAGE
526
+ },
527
+ { required: ["dept"] }
528
+ ),
529
+ handler: async (args, { host }) => {
530
+ const raw = args.dept === void 0 ? "" : String(args.dept).trim();
531
+ if (!raw) throw hrmValidationError("dept_required", "dept \u5FC5\u586B");
532
+ const deptId = /^\d+$/.test(raw) ? raw : String((await resolveDepartmentIdByName(host, raw)).id);
533
+ const body = {
534
+ ...browserBaseBody(),
535
+ secretLevel: "",
536
+ cmd: "teams",
537
+ leftTreeSelectedId: deptId,
538
+ formDatas: {
539
+ username: [{ usernameOpt: "in" }],
540
+ status: [{ statusSelect: ["normal"] }],
541
+ subcompany: [{ subcompanyOpt: "in" }],
542
+ department: [{ departmentOpt: "in" }],
543
+ role: [{ roleOpt: "in" }],
544
+ position: [{ positionOpt: "in" }]
545
+ }
546
+ };
547
+ const current = toPositiveInt(args.current, "current");
548
+ const pageSize = toNumber(args.pageSize, "pageSize") ?? 200;
549
+ if (current !== void 0) body.current = current;
550
+ if (pageSize !== void 0) body.pageSize = pageSize;
551
+ const resp = await host.request({ method: "POST", path: "/api/mail/base/common/browser/data/resource", body });
552
+ const rawRows = resp?.data?.data ?? [];
553
+ const session = await host.getSession();
554
+ const baseUrl = session.baseUrl.replace(/\/+$/, "");
555
+ const rows = rawRows.map((r) => args.full === true ? formatMember(r, baseUrl) : formatPersonBrief(r, baseUrl));
556
+ return hrmSuccess("hrm.dept.members", { dept: { id: deptId }, rows, total: rows.length }, { current: current ?? 1, pageSize: pageSize ?? 200 });
557
+ }
558
+ };
559
+ var hrmEmployeeOperations = [
560
+ employeeQuery,
561
+ employeeBatch,
562
+ employeeDetail,
563
+ subordinateMine,
564
+ subordinateById,
565
+ deptMembers
566
+ ];
567
+
568
+ export {
569
+ READ,
570
+ hrmSuccess,
571
+ schemaOf,
572
+ SCHEMA_ID,
573
+ SCHEMA_PAGE,
574
+ asObject,
575
+ assertNoForbiddenKeys,
576
+ toNumber,
577
+ toPositiveInt,
578
+ toStringIdList,
579
+ pickDefined,
580
+ browserBaseBody,
581
+ orgLink,
582
+ positionLink,
583
+ hrmEmployeeOperations
584
+ };
@@ -0,0 +1,51 @@
1
+ import { createRequire as __esbuildCreateRequire } from 'node:module';
2
+ const require = __esbuildCreateRequire(import.meta.url);
3
+ import {
4
+ CliError
5
+ } from "./chunk-LUSPKZKY.js";
6
+
7
+ // src/shortcuts/hrm/errors.ts
8
+ var HrmCliError = class extends CliError {
9
+ type;
10
+ subtype;
11
+ code;
12
+ retryable;
13
+ stage;
14
+ details;
15
+ constructor(type, subtype, message, options = {}) {
16
+ super(message, options.exitCode ?? 5 /* InternalError */);
17
+ this.name = "HrmCliError";
18
+ this.type = type;
19
+ this.subtype = subtype;
20
+ this.code = options.code;
21
+ this.retryable = options.retryable ?? false;
22
+ this.stage = options.stage;
23
+ this.details = options.details;
24
+ }
25
+ };
26
+ function hrmValidationError(subtype, message, details) {
27
+ return new HrmCliError("validation", subtype, message, {
28
+ details,
29
+ exitCode: 2 /* UsageError */
30
+ });
31
+ }
32
+ function hrmAuthError(subtype, message, details) {
33
+ return new HrmCliError("authentication", subtype, message, {
34
+ details,
35
+ exitCode: 3 /* AuthError */
36
+ });
37
+ }
38
+ function hrmNetworkError(subtype, message, options = {}) {
39
+ return new HrmCliError("network", subtype, message, {
40
+ ...options,
41
+ retryable: options.retryable ?? true,
42
+ exitCode: 4 /* NetworkError */
43
+ });
44
+ }
45
+
46
+ export {
47
+ HrmCliError,
48
+ hrmValidationError,
49
+ hrmAuthError,
50
+ hrmNetworkError
51
+ };