weaver-work-cli 0.1.29 → 0.1.32

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 (185) hide show
  1. package/dist/chunks/archive-UMGX72K6.js +2537 -0
  2. package/dist/chunks/archive-oa-N2IYBLF3.js +1317 -0
  3. package/dist/chunks/asset-GLEGKFG5.js +2109 -0
  4. package/dist/chunks/attachment-content-AQNX5N3S.js +23 -0
  5. package/dist/chunks/blog-E44OTVDA.js +2157 -0
  6. package/dist/chunks/caizhilian-DQUFZXZL.js +10087 -0
  7. package/dist/chunks/calendar-JKPIRKFD.js +1195 -0
  8. package/dist/chunks/chunk-2GA5ZIQL.js +1615 -0
  9. package/dist/chunks/chunk-4YC43QQ4.js +403 -0
  10. package/dist/chunks/chunk-6EFWDL7Y.js +161 -0
  11. package/dist/chunks/chunk-6RKD4DRZ.js +5556 -0
  12. package/dist/chunks/chunk-AJ62BGAW.js +29 -0
  13. package/dist/chunks/chunk-BUSC6UAE.js +43 -0
  14. package/dist/chunks/chunk-C6R3B2ML.js +358 -0
  15. package/dist/chunks/chunk-CVZ2JOSW.js +62 -0
  16. package/dist/chunks/chunk-DW6AUUKS.js +508 -0
  17. package/dist/chunks/chunk-E4Z23GHM.js +6962 -0
  18. package/dist/chunks/chunk-EG6ZU444.js +654 -0
  19. package/dist/chunks/chunk-EZALDOQH.js +383 -0
  20. package/dist/chunks/chunk-FMPJJYYI.js +106 -0
  21. package/dist/chunks/chunk-G2JSIUWF.js +769 -0
  22. package/dist/chunks/chunk-G3QJULO2.js +387 -0
  23. package/dist/chunks/chunk-GCG2NMWR.js +703 -0
  24. package/dist/chunks/chunk-GPMFD4RD.js +75 -0
  25. package/dist/chunks/chunk-H6XSTSLM.js +2357 -0
  26. package/dist/chunks/chunk-H7J4DC5R.js +464 -0
  27. package/dist/chunks/chunk-IURUFGZK.js +477 -0
  28. package/dist/chunks/chunk-LUSPKZKY.js +53 -0
  29. package/dist/chunks/chunk-NIAJ5ZCG.js +73 -0
  30. package/dist/chunks/chunk-NOODWMCL.js +584 -0
  31. package/dist/chunks/chunk-OOUTBLZ4.js +51 -0
  32. package/dist/chunks/chunk-P26ZWSKU.js +73 -0
  33. package/dist/chunks/chunk-QWY6PGL6.js +3472 -0
  34. package/dist/chunks/chunk-WKI2FBIQ.js +15606 -0
  35. package/dist/chunks/chunk-WSKBSQ2U.js +231 -0
  36. package/dist/chunks/chunk-YLCYX7LE.js +371 -0
  37. package/dist/chunks/chunk-YRVDW4WN.js +205 -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-V5FG2EHC.js +2276 -0
  43. package/dist/chunks/ehr-HMFY6VIL.js +5241 -0
  44. package/dist/chunks/employee-SAK2QYXX.js +11 -0
  45. package/dist/chunks/esb-ZYSVB7SG.js +141 -0
  46. package/dist/chunks/fna-B7RKPAZD.js +1444 -0
  47. package/dist/chunks/host-45WED2KK.js +21 -0
  48. package/dist/chunks/host-I4Z6BFYX.js +23 -0
  49. package/dist/chunks/host-KNZ52LJZ.js +17 -0
  50. package/dist/chunks/host-OCH2BCCV.js +19 -0
  51. package/dist/chunks/hrm-2KAZGUHI.js +244 -0
  52. package/dist/chunks/im-ACJJWH4U.js +252 -0
  53. package/dist/chunks/invoice-ZK3WCX2U.js +5179 -0
  54. package/dist/chunks/jiuchuanhui-5PQD3IL2.js +1940 -0
  55. package/dist/chunks/lazy-dispatch-JQXBW3GM.js +28 -0
  56. package/dist/chunks/mail-S2HDDXO2.js +2695 -0
  57. package/dist/chunks/meeting-QVN3I37L.js +504 -0
  58. package/dist/chunks/msg-parse-4GSQ2WTO.js +41 -0
  59. package/dist/chunks/okr-QNG4VC2Q.js +2482 -0
  60. package/dist/chunks/plan-A25EMW6U.js +2025 -0
  61. package/dist/chunks/project-G6XV66DZ.js +1361 -0
  62. package/dist/chunks/registry-2VLUAESA.js +14 -0
  63. package/dist/chunks/registry-7C5UMIPL.js +19 -0
  64. package/dist/chunks/registry-DC6KR3NH.js +18 -0
  65. package/dist/chunks/registry-NYPYMZXG.js +16 -0
  66. package/dist/chunks/registry-TI3CIUXF.js +19 -0
  67. package/dist/chunks/room-recommend-WRTHO6Y2.js +20 -0
  68. package/dist/chunks/schedule-KFIITGSK.js +24 -0
  69. package/dist/chunks/state-Y2XBP6YE.js +15 -0
  70. package/dist/chunks/workflow-DJ7SYWAF.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 +61 -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/manifest.js +34 -11
  105. package/dist/shortcuts/invoice/operations/reim-auto.js +9 -0
  106. package/dist/shortcuts/invoice/operations/reim.js +81 -5
  107. package/dist/shortcuts/invoice/operations/shared.js +12 -5
  108. package/dist/shortcuts/meeting/host.js +45 -3
  109. package/dist/shortcuts/meeting/invitation/docx.js +442 -0
  110. package/dist/shortcuts/meeting/operations/attachment-content.js +418 -0
  111. package/dist/shortcuts/meeting/operations/attachment.js +442 -0
  112. package/dist/shortcuts/meeting/operations/eb/cache.js +57 -0
  113. package/dist/shortcuts/meeting/operations/eb/catalog.js +343 -28
  114. package/dist/shortcuts/meeting/operations/eb/conflict.js +372 -11
  115. package/dist/shortcuts/meeting/operations/eb/create-flow.js +710 -0
  116. package/dist/shortcuts/meeting/operations/eb/decision.js +47 -1
  117. package/dist/shortcuts/meeting/operations/eb/factory.js +129 -11
  118. package/dist/shortcuts/meeting/operations/eb/index.js +122 -2
  119. package/dist/shortcuts/meeting/operations/eb/room-recommend.js +378 -0
  120. package/dist/shortcuts/meeting/operations/eb/room-summary.js +84 -0
  121. package/dist/shortcuts/meeting/operations/eb/schedule.js +450 -0
  122. package/dist/shortcuts/meeting/operations/from-group-chat.js +576 -0
  123. package/dist/shortcuts/meeting/operations/invitation.js +458 -0
  124. package/dist/shortcuts/meeting/operations/minute-content.js +266 -0
  125. package/dist/shortcuts/meeting/operations/pipeline.js +489 -0
  126. package/dist/shortcuts/meeting/operations/qrcode.js +131 -0
  127. package/dist/shortcuts/meeting/operations/receipts.js +1 -1
  128. package/dist/shortcuts/meeting/operations/registry.js +18 -0
  129. package/dist/shortcuts/meeting/operations/summary.js +276 -0
  130. package/dist/shortcuts/meeting/operations/task-notify.js +325 -0
  131. package/dist/shortcuts/meeting/operations.js +42 -1
  132. package/dist/shortcuts/meeting/qr/encoder.js +427 -0
  133. package/dist/shortcuts/meeting/qr/render.js +103 -0
  134. package/dist/shortcuts/workflow/operations/form.js +17 -5
  135. package/docs/contract.md +39 -4
  136. package/docs/invoice.md +5 -5
  137. package/package.json +3 -2
  138. package/scripts/bundle.mjs +63 -0
  139. package/skill-template/business-info.json +25 -4
  140. package/skill-template/domains/jinchengda.md +16 -3
  141. package/skill-template/domains/yepiaotong.md +1 -1
  142. package/skills/weaver-e10-jinchengda/SKILL.md +111 -31
  143. package/skills/weaver-e10-jinchengda/references/contract-agent-entry.md +7 -13
  144. package/skills/weaver-e10-jinchengda/references/contract-ai-assistant.md +150 -0
  145. package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +87 -0
  146. package/skills/weaver-e10-jinchengda/references/contract-clause-library-crud.md +111 -0
  147. package/skills/weaver-e10-jinchengda/references/contract-clause-recommender.md +0 -15
  148. package/skills/weaver-e10-jinchengda/references/contract-clause-reference-save.md +0 -13
  149. package/skills/weaver-e10-jinchengda/references/contract-credit-page.md +50 -0
  150. package/skills/weaver-e10-jinchengda/references/contract-disabled-capabilities.md +4 -2
  151. package/skills/weaver-e10-jinchengda/references/contract-doc-compare.md +74 -0
  152. package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +84 -0
  153. package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +29 -0
  154. package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +28 -0
  155. package/skills/weaver-e10-jinchengda/references/contract-request-status.md +2 -21
  156. package/skills/weaver-e10-jinchengda/references/contract-request-write.md +0 -24
  157. package/skills/weaver-e10-jinchengda/references/contract-signing-subjects.md +0 -15
  158. package/skills/weaver-e10-jinchengda/references/contract-subject-create.md +0 -17
  159. package/skills/weaver-e10-jinchengda/references/contract-template-recommend.md +70 -0
  160. package/skills/weaver-e10-jinchengda/references/contract-template-selector.md +0 -15
  161. package/skills/weaver-e10-jinchengda/references/contract-workflow-discovery.md +0 -15
  162. package/skills/weaver-e10-jinchengda/references/source-manifest.json +1168 -152
  163. package/skills/weaver-e10-meeting/SKILL.md +493 -17
  164. package/skills/weaver-e10-meeting/references/meeting-change.md +4 -4
  165. package/skills/weaver-e10-meeting/references/meeting-create.md +6 -6
  166. package/skills/weaver-e10-meeting/references/meeting-eb.md +503 -27
  167. package/skills/weaver-e10-meeting/references/meeting-invitation.md +113 -0
  168. package/skills/weaver-e10-meeting/references/meeting-lifecycle.md +6 -6
  169. package/skills/weaver-e10-meeting/references/meeting-minute-file.md +425 -0
  170. package/skills/weaver-e10-meeting/references/meeting-queries.md +4 -4
  171. package/skills/weaver-e10-meeting/references/meeting-receipts-signs.md +15 -15
  172. package/skills/weaver-e10-meeting/references/meeting-verification.md +19 -11
  173. package/skills/weaver-e10-meeting.zip +0 -0
  174. package/skills/weaver-e10-yepiaotong/SKILL.md +9 -5
  175. package/skills/weaver-e10-yepiaotong/references/invoice-enterprise-list.md +1 -1
  176. package/skills/weaver-e10-yepiaotong/references/invoice-personal-list.md +6 -5
  177. package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +14 -11
  178. package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +97 -56
  179. package/skills/weaver-e10-yepiaotong/references/reim-examples.md +84 -60
  180. package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +142 -105
  181. package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +53 -194
  182. package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +7 -7
  183. package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +164 -72
  184. package/skills/weaver-e10-yepiaotong/references/source-manifest.json +6 -0
  185. package/templates/meeting/invitation.docx +0 -0
@@ -0,0 +1,403 @@
1
+ import { createRequire as __esbuildCreateRequire } from 'node:module';
2
+ const require = __esbuildCreateRequire(import.meta.url);
3
+ import {
4
+ readCache,
5
+ writeCache
6
+ } from "./chunk-CVZ2JOSW.js";
7
+ import {
8
+ SCHEMA_DATETIME_MINUTE,
9
+ meetingSuccess,
10
+ meetingValidationError,
11
+ schemaOf
12
+ } from "./chunk-H6XSTSLM.js";
13
+
14
+ // src/shortcuts/meeting/operations/eb/schedule.ts
15
+ var SCHEDULE_TYPE_PATH = "/api/ebuilder/form/formdata/v2/getFormDataList/queryAgendaType";
16
+ var DEFAULT_SCHEDULE_FLOW_ID = "1328057613897310208";
17
+ var DEFAULT_SCHEDULE_UNIQUE_INDENT = "E37BF827FF2D47F6BD1DF928ABD25F69";
18
+ var DEFAULT_MEETING_TYPE_NAME = "\u4F1A\u8BAE\u65E5\u7A0B";
19
+ var MEETING_TYPE_CODE = "HYRC";
20
+ var TYPE_CACHE_TTL_MS = 7 * 24 * 60 * 60 * 1e3;
21
+ function splitIds(value) {
22
+ if (value === void 0 || value === null) return [];
23
+ if (Array.isArray(value)) {
24
+ return value.map((item) => String(item).trim()).filter((item) => item !== "");
25
+ }
26
+ return String(value).split(/[,;,;\s]+/).map((item) => item.trim()).filter((item) => item !== "");
27
+ }
28
+ async function fetchScheduleTypeOptions(env) {
29
+ const session = await env.host.getSession();
30
+ const response = await env.host.request({
31
+ method: "POST",
32
+ path: SCHEDULE_TYPE_PATH,
33
+ operation: "meeting.eb.schedule.free",
34
+ body: {
35
+ datajson: {
36
+ mainTable: {},
37
+ pageInfo: { pageNo: "1", pageSize: "100" },
38
+ header: { operator: session.userId }
39
+ }
40
+ },
41
+ acceptBusiness: (value2) => {
42
+ if (!value2 || typeof value2 !== "object") return false;
43
+ if (typeof value2.status === "boolean") return value2.status;
44
+ return Number(value2.code ?? 200) === 200;
45
+ }
46
+ });
47
+ const value = response;
48
+ const dj = value?.datajson ?? value?.data ?? {};
49
+ const raw = dj?.datas ?? dj?.data ?? (Array.isArray(dj) ? dj : []);
50
+ const rows = Array.isArray(raw) ? raw : [];
51
+ return rows.map((row) => {
52
+ const main = row?.mainTable ?? row ?? {};
53
+ return {
54
+ id: String(main.id ?? "").trim(),
55
+ name: String(main.type_name ?? main.name ?? "").trim(),
56
+ code: String(main.type_code ?? "").trim().toUpperCase()
57
+ };
58
+ }).filter((item) => item.id !== "");
59
+ }
60
+ async function resolveMeetingScheduleTypeIds(env, options = {}) {
61
+ const fromArgs = splitIds(options.excludeTypeIds);
62
+ if (fromArgs.length > 0) {
63
+ return { ids: fromArgs, names: [], source: "args", warnings: [] };
64
+ }
65
+ const fromEnv = splitIds(process.env.WEAVER_MEETING_SCHEDULE_TYPE_IDS);
66
+ if (fromEnv.length > 0) {
67
+ return { ids: fromEnv, names: [], source: "env", warnings: [] };
68
+ }
69
+ const cacheKey = `schedule-types-${await scopeSuffix(env)}`;
70
+ if (!options.refresh) {
71
+ const cached = await readCache(env, cacheKey, { ttlMs: TYPE_CACHE_TTL_MS });
72
+ if (cached?.data?.meetingTypeIds?.length) {
73
+ return { ids: cached.data.meetingTypeIds, names: cached.data.names ?? [], source: "cache", warnings: [] };
74
+ }
75
+ }
76
+ const warnings = [];
77
+ try {
78
+ const typeName = (process.env.WEAVER_MEETING_SCHEDULE_TYPE_NAME || DEFAULT_MEETING_TYPE_NAME).trim();
79
+ const options2 = await fetchScheduleTypeOptions(env);
80
+ const matched = options2.filter((item) => item.name === typeName || item.code === MEETING_TYPE_CODE);
81
+ if (matched.length === 0) {
82
+ warnings.push(
83
+ `\u65E5\u7A0B\u7C7B\u578B\u5B57\u5178\u91CC\u6CA1\u627E\u5230\u300C${typeName}\u300D\uFF08\u4E5F\u6CA1\u6709 type_code=${MEETING_TYPE_CODE} \u7684\u9879\uFF09\u2014\u2014\u672C\u6B21\u4E0D\u505A\u4F1A\u8BAE\u65E5\u7A0B\u8FC7\u6EE4\uFF0C\u51B2\u7A81\u91CC\u53EF\u80FD\u5305\u542B\u4F1A\u8BAE\u751F\u6210\u7684\u65E5\u7A0B\uFF08\u4F1A\u4E0E\u4F1A\u8BAE\u51B2\u7A81\u91CD\u590D\u8BA1\uFF09\u3002\u53EF\u7528\u5165\u53C2 excludeTypeIds \u6216\u73AF\u5883\u53D8\u91CF WEAVER_MEETING_SCHEDULE_TYPE_IDS \u663E\u5F0F\u6307\u5B9A\u3002`
84
+ );
85
+ return { ids: [], names: [], source: "none", warnings };
86
+ }
87
+ const ids = matched.map((item) => item.id);
88
+ const names = matched.map((item) => item.name);
89
+ await writeCache(env, cacheKey, { meetingTypeIds: ids, names });
90
+ return { ids, names, source: "remote", warnings };
91
+ } catch (error) {
92
+ warnings.push(
93
+ `\u65E5\u7A0B\u7C7B\u578B\u5B57\u5178\u8BFB\u53D6\u5931\u8D25\uFF08${String(error?.message ?? error).slice(0, 80)}\uFF09\uFF1A\u672C\u6B21\u4E0D\u505A\u4F1A\u8BAE\u65E5\u7A0B\u8FC7\u6EE4\uFF0C\u8BF7\u4EBA\u5DE5\u5224\u65AD\u662F\u5426\u5C5E\u4E8E\u91CD\u590D\u8BA1\u5165\u3002`
94
+ );
95
+ return { ids: [], names: [], source: "none", warnings };
96
+ }
97
+ }
98
+ async function scopeSuffix(env) {
99
+ try {
100
+ const session = await env.host.getSession();
101
+ const host = String(session?.baseUrl ?? "").replace(/^https?:\/\//, "").replace(/[^0-9a-zA-Z]+/g, "-");
102
+ return `${host || "local"}-${String(session?.tenantKey ?? "unknown")}`;
103
+ } catch {
104
+ return "local-unknown";
105
+ }
106
+ }
107
+ async function runScheduleConflictFlow(env, input) {
108
+ const session = await env.host.getSession();
109
+ const employeeId = String(session?.userId ?? "").trim();
110
+ if (!employeeId) {
111
+ throw meetingValidationError("schedule_employee_required", "\u53D6\u4E0D\u5230\u5F53\u524D\u767B\u5F55\u7528\u6237 id\uFF0C\u65E0\u6CD5\u89E6\u53D1 ESB \u65E5\u7A0B\u67E5\u8BE2");
112
+ }
113
+ const { createEsbHost } = await import("./host-45WED2KK.js");
114
+ const { createEsbContinuationSigner } = await import("./continuation-NLECEJPX.js");
115
+ const { getEsbOperation } = await import("./registry-DC6KR3NH.js");
116
+ const esbEnv = {
117
+ ctx: env.ctx,
118
+ host: createEsbHost(env.ctx),
119
+ continuation: createEsbContinuationSigner(env.ctx)
120
+ };
121
+ const mainTable = {
122
+ startDate: input.startDate,
123
+ endDate: input.endDate,
124
+ memberIds: input.memberIds.join(",")
125
+ };
126
+ if (input.mtId) mainTable.mtId = input.mtId;
127
+ const explicitFlowId = String(input.flowId ?? "").trim() || process.env.WEAVER_MEETING_SCHEDULE_FLOW_ID || "";
128
+ const uniqueIndent = String(input.uniqueIndent ?? "").trim() || process.env.WEAVER_MEETING_SCHEDULE_FLOW_KEY || DEFAULT_SCHEDULE_UNIQUE_INDENT;
129
+ const resolvedTarget = explicitFlowId ? { esbFlowId: explicitFlowId } : uniqueIndent ? { uniqueIndent } : { esbFlowId: DEFAULT_SCHEDULE_FLOW_ID };
130
+ const prepareOp = getEsbOperation("esb.trigger.prepare");
131
+ const applyOp = getEsbOperation("esb.trigger.apply");
132
+ const pre = await prepareOp.handler(
133
+ { employeeId, ...resolvedTarget, customParams: { mainTable } },
134
+ esbEnv
135
+ );
136
+ const applied = await applyOp.handler({ continuation: pre?.data?.continuation, confirm: true }, esbEnv);
137
+ const actionData = applied?.data?.actionData ?? {};
138
+ const main = actionData?.responseData?.customData?.mainTable ?? {};
139
+ const rowsFrom = (value) => {
140
+ if (Array.isArray(value)) return value;
141
+ return [];
142
+ };
143
+ const rows = rowsFrom(main.memberWpConflictData).concat(rowsFrom(main.wpConflictData)).concat(rowsFrom(main.conflictList)).concat(rowsFrom(main.scheduleConflicts));
144
+ const count = Number(main.memberWpConflictNum ?? main.conflictNum ?? rows.length) || 0;
145
+ const message = String(main.memberWpConflictMsg ?? main.conflictMsg ?? "");
146
+ return {
147
+ rows,
148
+ count,
149
+ message,
150
+ raw: applied?.data ?? applied,
151
+ target: {
152
+ mode: explicitFlowId ? "esbFlowId" : "uniqueIndent",
153
+ value: explicitFlowId || uniqueIndent
154
+ }
155
+ };
156
+ }
157
+ function normalizeTypeId(value) {
158
+ if (value === void 0 || value === null) return { id: "", name: "" };
159
+ if (Array.isArray(value)) {
160
+ const first = value[0];
161
+ if (first && typeof first === "object") {
162
+ return { id: String(first.id ?? "").trim(), name: String(first.name ?? "").trim() };
163
+ }
164
+ return { id: String(first ?? "").trim(), name: "" };
165
+ }
166
+ if (typeof value === "object") {
167
+ const item = value;
168
+ return { id: String(item.id ?? "").trim(), name: String(item.name ?? "").trim() };
169
+ }
170
+ return { id: String(value).trim(), name: "" };
171
+ }
172
+ function normalizeMembers(value) {
173
+ if (Array.isArray(value)) {
174
+ return value.map((item) => item && typeof item === "object" ? String(item.id ?? "") : String(item ?? "")).map((item) => item.trim()).filter((item) => item !== "");
175
+ }
176
+ return splitIds(value);
177
+ }
178
+ function normalizeRows(rows) {
179
+ return rows.map((row) => {
180
+ const main = row?.mainTable ?? row ?? {};
181
+ const type = normalizeTypeId(main.agn_type);
182
+ return {
183
+ scheduleId: String(main.id ?? "").trim(),
184
+ title: String(main.agn_name ?? main.name ?? "").trim(),
185
+ startTime: String(main.start_time ?? "").trim(),
186
+ endTime: String(main.end_time ?? "").trim(),
187
+ typeId: type.id,
188
+ typeName: type.name,
189
+ members: normalizeMembers(main.participants),
190
+ meetingSchedule: false
191
+ };
192
+ });
193
+ }
194
+ function buildScheduleFreeResult(flow, typeIds, options) {
195
+ const normalized = normalizeRows(flow.rows);
196
+ const wanted = new Set(options.memberIds);
197
+ const excluded = new Set(typeIds);
198
+ let meetingSchedule = 0;
199
+ const kept = [];
200
+ for (const item of normalized) {
201
+ const isMeetingType = item.typeId !== "" && excluded.has(item.typeId);
202
+ if (isMeetingType) meetingSchedule += 1;
203
+ if (isMeetingType) {
204
+ kept.push({ ...item, meetingSchedule: true });
205
+ continue;
206
+ }
207
+ kept.push(item);
208
+ }
209
+ const busyMap = /* @__PURE__ */ new Map();
210
+ for (const item of kept) {
211
+ if (item.meetingSchedule) continue;
212
+ for (const memberId of item.members) {
213
+ if (wanted.size > 0 && !wanted.has(memberId)) continue;
214
+ const list = busyMap.get(memberId) ?? [];
215
+ list.push({
216
+ scheduleId: item.scheduleId,
217
+ title: item.title,
218
+ startTime: item.startTime,
219
+ endTime: item.endTime,
220
+ typeId: item.typeId,
221
+ typeName: item.typeName
222
+ });
223
+ busyMap.set(memberId, list);
224
+ }
225
+ }
226
+ const busyMembers = [...busyMap.entries()].map(([memberId, items]) => ({ memberId, items }));
227
+ const busySet = new Set(busyMembers.map((item) => item.memberId));
228
+ const freeMembers = options.memberIds.filter((memberId) => !busySet.has(memberId));
229
+ const detailAvailable = normalized.length > 0 || flow.count === 0;
230
+ const verdict = normalized.length === 0 && flow.count === 0 ? "free" : busyMembers.length > 0 ? "busy" : "unknown";
231
+ return {
232
+ verdict,
233
+ counts: {
234
+ requested: options.memberIds.length,
235
+ free: freeMembers.length,
236
+ busy: busyMembers.length
237
+ },
238
+ freeMembers,
239
+ busyMembers,
240
+ filtered: { total: normalized.length, meetingSchedule },
241
+ meetingScheduleTypes: { ids: typeIds, names: [], source: "" },
242
+ message: flow.message,
243
+ detailAvailable,
244
+ target: flow.target,
245
+ ...options.includeRaw ? { raw: flow.raw } : {}
246
+ };
247
+ }
248
+ var ebScheduleFree = {
249
+ name: "meeting.eb.schedule.free",
250
+ resource: "eb",
251
+ method: "meeting.eb.schedule.free",
252
+ action: "meeting.eb.schedule.free",
253
+ summary: "\u53C2\u4F1A\u4EBA\u65E5\u7A0B\u7A7A\u95F2\u68C0\u6D4B\uFF08ESB \u52A8\u4F5C\u6D41\u67E5\u65E5\u7A0B\u5E94\u7528\uFF0C\u975E\u4F1A\u8BAE\u8868\uFF09\uFF1A\u5224\u65AD\u4EBA\u5728\u76EE\u6807\u65F6\u6BB5\u6709\u6CA1\u6709\u5176\u5B83\u65E5\u7A0B\u5360\u7528\uFF1B\u81EA\u52A8\u8FC7\u6EE4\u300C\u4F1A\u8BAE\u65E5\u7A0B\u300D\u7C7B\u578B\uFF08\u7C7B\u578B id \u52A8\u6001\u89E3\u6790\uFF0C\u4E0D\u5199\u6B7B\uFF09",
254
+ capability: "eb.schedule",
255
+ risk: "read",
256
+ inputSchema: schemaOf(
257
+ {
258
+ startDate: { ...SCHEMA_DATETIME_MINUTE, description: "\u5F00\u59CB\u65F6\u95F4\uFF08\u5FC5\u586B\uFF0Cyyyy-MM-dd HH:mm\uFF09" },
259
+ endDate: { ...SCHEMA_DATETIME_MINUTE, description: "\u7ED3\u675F\u65F6\u95F4\uFF08\u5FC5\u586B\uFF0Cyyyy-MM-dd HH:mm\uFF09" },
260
+ memberIds: {
261
+ type: "array",
262
+ items: { type: "string" },
263
+ description: "\u53C2\u4F1A\u4EBA id \u6570\u7EC4\uFF08\u5FC5\u586B\uFF1BHRM \u5458\u5DE5 id\uFF0C\u4E0E\u56DE\u6267 member_id \u540C\u53E3\u5F84\uFF09"
264
+ },
265
+ mtId: { type: "string", description: "\u53D8\u66F4\u4F1A\u8BAE\u65F6\u6392\u9664\u8BE5\u4F1A\u8BAE\u81EA\u8EAB\u751F\u6210\u7684\u65E5\u7A0B" },
266
+ excludeTypeIds: {
267
+ type: "string",
268
+ description: "\u663E\u5F0F\u6307\u5B9A\u8981\u8FC7\u6EE4\u7684\u65E5\u7A0B\u7C7B\u578B id\uFF08\u9017\u53F7\u5206\u9694\uFF09\u3002\u4E0D\u4F20\u65F6\u6309\u65E5\u7A0B\u7C7B\u578B\u5B57\u5178\u52A8\u6001\u89E3\u6790\u300C\u4F1A\u8BAE\u65E5\u7A0B\u300D"
269
+ },
270
+ refreshTypes: { type: "boolean", description: "true=\u5F3A\u5236\u91CD\u65B0\u62C9\u53D6\u65E5\u7A0B\u7C7B\u578B\u5B57\u5178\uFF08\u9ED8\u8BA4\u547D\u4E2D 7 \u5929\u7F13\u5B58\uFF09" },
271
+ flowId: { type: "string", description: "\u8986\u76D6 ESB \u52A8\u4F5C\u6D41 id\uFF08\u79DF\u6237\u4E0D\u540C\u65F6\u7528\uFF09" },
272
+ uniqueIndent: { type: "string", description: "\u8986\u76D6 ESB \u52A8\u4F5C\u6D41 primary_key\uFF08\u9ED8\u8BA4\u7528\u5185\u7F6E\u503C\uFF0C\u6362\u73AF\u5883\u65F6\u4F20\uFF09" },
273
+ includeRaw: { type: "boolean", description: "true=\u9644\u5E26 ESB \u539F\u59CB\u8FD4\u56DE\uFF0C\u4FBF\u4E8E\u6392\u67E5\u53E3\u5F84\u95EE\u9898" }
274
+ },
275
+ { required: ["startDate", "endDate", "memberIds"] }
276
+ ),
277
+ handler: async (args, env) => {
278
+ const startDate = String(args.startDate ?? "").trim();
279
+ const endDate = String(args.endDate ?? "").trim();
280
+ const memberIds = splitIds(args.memberIds);
281
+ if (memberIds.length === 0) {
282
+ throw meetingValidationError("schedule_member_required", "memberIds \u4E0D\u80FD\u4E3A\u7A7A\uFF08\u53C2\u4F1A\u4EBA id \u6570\u7EC4\uFF09");
283
+ }
284
+ const typeResolution = await resolveMeetingScheduleTypeIds(env, {
285
+ excludeTypeIds: args.excludeTypeIds,
286
+ refresh: args.refreshTypes === true
287
+ });
288
+ const flow = await runScheduleConflictFlow(env, {
289
+ startDate,
290
+ endDate,
291
+ memberIds,
292
+ ...args.mtId ? { mtId: String(args.mtId) } : {},
293
+ ...args.flowId ? { flowId: String(args.flowId) } : {},
294
+ ...args.uniqueIndent ? { uniqueIndent: String(args.uniqueIndent) } : {}
295
+ });
296
+ const result = buildScheduleFreeResult(flow, typeResolution.ids, {
297
+ memberIds,
298
+ includeRaw: args.includeRaw === true
299
+ });
300
+ result.meetingScheduleTypes.names = typeResolution.names;
301
+ result.meetingScheduleTypes.source = typeResolution.source;
302
+ await applyMessageDetails(env, result, flow, memberIds);
303
+ const warnings = [...typeResolution.warnings];
304
+ if (!result.detailAvailable) {
305
+ warnings.push(
306
+ `ESB \u53EA\u8FD4\u56DE\u4E86\u51B2\u7A81\u6570\u91CF\uFF08${flow.count}\uFF09\u4E0E\u63D0\u793A\u8BED\u300C${flow.message || "\u7A7A"}\u300D\uFF0C\u6CA1\u6709\u9010\u6761\u65E5\u7A0B\u660E\u7EC6\u2014\u2014\u65E0\u6CD5\u5224\u65AD\u662F\u54EA\u51E0\u6761\u65E5\u7A0B\u5360\u7528\uFF1B\u5982\u9700\u660E\u7EC6\u8BF7\u8BA9 ESB \u52A8\u4F5C\u6D41\u8F93\u51FA scheduleConflicts \u5217\u8868\u3002`
307
+ );
308
+ }
309
+ return meetingSuccess("meeting.eb.schedule.free", result, warnings.length > 0 ? { warnings } : {});
310
+ }
311
+ };
312
+ var meetingEbScheduleOperations = [ebScheduleFree];
313
+ function parseScheduleConflictMessage(message) {
314
+ const text = String(message ?? "");
315
+ if (!text.trim()) return [];
316
+ const pattern = /(\d{1,2}:\d{2})\s*[~~-]\s*(\d{1,2}:\d{2})[^《]*《([^》]*)》[^【]*【([^】]*)】/g;
317
+ const items = [];
318
+ for (const match of text.matchAll(pattern)) {
319
+ const memberNames = match[4].split(/[、,,;;\s]+/).map((name) => name.trim()).filter((name) => name !== "");
320
+ items.push({
321
+ startTime: match[1],
322
+ endTime: match[2],
323
+ title: match[3].trim(),
324
+ memberNames
325
+ });
326
+ }
327
+ return items;
328
+ }
329
+ async function resolveMemberIdsByName(env, names) {
330
+ const map = /* @__PURE__ */ new Map();
331
+ const unique = [...new Set(names)].filter((name) => name !== "");
332
+ if (unique.length === 0) return map;
333
+ try {
334
+ const { hrmEmployeeOperations } = await import("./employee-SAK2QYXX.js");
335
+ const query = hrmEmployeeOperations.find((operation) => operation.name === "hrm.employee.query");
336
+ if (!query) return map;
337
+ for (const name of unique) {
338
+ try {
339
+ const result = await query.handler({ keyword: name, pageSize: 5 }, env);
340
+ const rows = result?.data?.rows ?? [];
341
+ const hit = rows.find((row) => String(row.name ?? "").trim() === name) ?? rows[0];
342
+ const id = String(hit?.id ?? "").trim();
343
+ if (id) map.set(name, id);
344
+ } catch {
345
+ }
346
+ }
347
+ } catch {
348
+ }
349
+ return map;
350
+ }
351
+ async function applyMessageDetails(env, result, flow, requestedMemberIds) {
352
+ if (result.detailAvailable) return false;
353
+ const parsed = parseScheduleConflictMessage(flow.message);
354
+ if (parsed.length === 0) return false;
355
+ const idsByName = await resolveMemberIdsByName(env, parsed.flatMap((item) => item.memberNames));
356
+ const wanted = new Set(requestedMemberIds);
357
+ const busy = /* @__PURE__ */ new Map();
358
+ const unresolved = [];
359
+ for (const item of parsed) {
360
+ for (const name of item.memberNames) {
361
+ const id = idsByName.get(name) ?? "";
362
+ const key = id || `name:${name}`;
363
+ if (id && wanted.size > 0 && !wanted.has(id)) continue;
364
+ const entry = busy.get(key) ?? { memberId: id || name, items: [] };
365
+ entry.items.push({
366
+ scheduleId: "",
367
+ title: item.title,
368
+ startTime: item.startTime,
369
+ endTime: item.endTime,
370
+ typeId: "",
371
+ typeName: ""
372
+ });
373
+ busy.set(key, entry);
374
+ if (!id) unresolved.push(name);
375
+ }
376
+ }
377
+ if (busy.size === 0) return false;
378
+ result.busyMembers = [...busy.values()];
379
+ const busyIds = new Set(result.busyMembers.map((item) => item.memberId));
380
+ result.freeMembers = requestedMemberIds.filter((id) => !busyIds.has(id));
381
+ result.counts = {
382
+ requested: requestedMemberIds.length,
383
+ free: result.freeMembers.length,
384
+ busy: result.busyMembers.length
385
+ };
386
+ result.verdict = "busy";
387
+ result.detailAvailable = true;
388
+ result.parsedFrom = "message";
389
+ if (unresolved.length > 0) {
390
+ result.unresolvedNames = [...new Set(unresolved)];
391
+ }
392
+ return true;
393
+ }
394
+
395
+ export {
396
+ resolveMeetingScheduleTypeIds,
397
+ runScheduleConflictFlow,
398
+ buildScheduleFreeResult,
399
+ meetingEbScheduleOperations,
400
+ parseScheduleConflictMessage,
401
+ resolveMemberIdsByName,
402
+ applyMessageDetails
403
+ };
@@ -0,0 +1,161 @@
1
+ import { createRequire as __esbuildCreateRequire } from 'node:module';
2
+ const require = __esbuildCreateRequire(import.meta.url);
3
+ import {
4
+ HrmCliError,
5
+ hrmAuthError,
6
+ hrmNetworkError,
7
+ hrmValidationError
8
+ } from "./chunk-OOUTBLZ4.js";
9
+ import {
10
+ E10ApiError,
11
+ createE10RequestRuntime,
12
+ requireE10Session
13
+ } from "./chunk-DW6AUUKS.js";
14
+ import {
15
+ E10_SESSION_EXPIRED_MESSAGE,
16
+ getActiveProfile
17
+ } from "./chunk-2GA5ZIQL.js";
18
+
19
+ // src/shortcuts/hrm/host.ts
20
+ function inferProfile(ctx) {
21
+ const options = ctx.getGlobalOptions();
22
+ return options.profile || getActiveProfile();
23
+ }
24
+ function isBusinessSuccess(value) {
25
+ if (!value || typeof value !== "object") return false;
26
+ if (value.code !== void 0 && value.code !== null) return Number(value.code) === 200;
27
+ if (typeof value.status === "boolean") return value.status;
28
+ return false;
29
+ }
30
+ function businessMessage(value) {
31
+ if (!value || typeof value !== "object") return "\u6CDB\u5FAE\u63A5\u53E3\u8FD4\u56DE\u4E1A\u52A1\u5931\u8D25";
32
+ const candidates = [value.msg, value.message, value.data?.message];
33
+ for (const item of candidates) {
34
+ if (typeof item === "string" && item.trim()) return item;
35
+ }
36
+ return "\u6CDB\u5FAE\u63A5\u53E3\u8FD4\u56DE\u4E1A\u52A1\u5931\u8D25";
37
+ }
38
+ function businessCode(value) {
39
+ if (!value || typeof value !== "object") return void 0;
40
+ const code = value.code ?? value.status;
41
+ if (typeof code === "string" || typeof code === "number") return code;
42
+ return void 0;
43
+ }
44
+ function assertPath(requestPath) {
45
+ if (typeof requestPath !== "string" || !requestPath.startsWith("/") || requestPath.startsWith("//")) {
46
+ throw hrmValidationError("path_invalid", "\u8BF7\u6C42\u8DEF\u5F84\u5FC5\u987B\u662F\u76F8\u5BF9\u7EDD\u5BF9\u8DEF\u5F84");
47
+ }
48
+ if (/^https?:/i.test(requestPath) || /[\r\n]/.test(requestPath) || requestPath.includes("/../")) {
49
+ throw hrmValidationError("path_invalid", "\u8BF7\u6C42\u8DEF\u5F84\u4E0D\u5141\u8BB8\u8DE8\u57DF\u6216\u8DEF\u5F84\u9003\u9038");
50
+ }
51
+ if (!requestPath.startsWith("/api/")) {
52
+ throw hrmValidationError("path_not_allowed", "\u7EC4\u7EC7\u7BA1\u7406\u53EA\u80FD\u8C03\u7528 /api/ \u8DEF\u5F84");
53
+ }
54
+ }
55
+ function omitEmptyQueryValues(query) {
56
+ if (!query) return void 0;
57
+ return Object.fromEntries(Object.entries(query).filter(([, value]) => value !== "" && value !== void 0));
58
+ }
59
+ function mapRuntimeNetworkError(error) {
60
+ if (error instanceof E10ApiError && error.type === "network") {
61
+ throw hrmNetworkError(error.subtype, error.message, {
62
+ retryable: error.retryable,
63
+ details: error.details
64
+ });
65
+ }
66
+ throw error;
67
+ }
68
+ function createHrmHost(ctx, dependencies = {}) {
69
+ let e10Session = null;
70
+ let sessionContext = null;
71
+ const requireSession = dependencies.requireSession || requireE10Session;
72
+ async function ensureSession() {
73
+ if (!e10Session) {
74
+ e10Session = await requireSession(ctx);
75
+ sessionContext = {
76
+ baseUrl: e10Session.getBaseUrl(),
77
+ profile: inferProfile(ctx),
78
+ userId: e10Session.userId,
79
+ tenantKey: e10Session.tenantKey,
80
+ eteamsId: e10Session.eteamsId
81
+ };
82
+ }
83
+ return e10Session;
84
+ }
85
+ async function getSession() {
86
+ await ensureSession();
87
+ return sessionContext;
88
+ }
89
+ async function runtime() {
90
+ return createE10RequestRuntime(ctx, await ensureSession(), {
91
+ interceptors: dependencies.interceptors,
92
+ fetch: dependencies.fetch
93
+ });
94
+ }
95
+ async function request(request2) {
96
+ const { method, path, query, body, operation, headers: extraHeaders = {}, timeoutMs = 3e4 } = request2;
97
+ assertPath(path);
98
+ const session = await getSession();
99
+ const referer = extraHeaders.Referer || `${session.baseUrl}/hrm/main`;
100
+ const resolvedMethod = method || (body === void 0 ? "GET" : "POST");
101
+ let response;
102
+ try {
103
+ response = await (await runtime()).requestJson({
104
+ module: "hrm",
105
+ operation,
106
+ method: resolvedMethod,
107
+ path,
108
+ query: omitEmptyQueryValues(query),
109
+ body,
110
+ headers: { "X-Requested-With": "XMLHttpRequest", Referer: referer, ...extraHeaders },
111
+ timeoutMs
112
+ });
113
+ } catch (error) {
114
+ mapRuntimeNetworkError(error);
115
+ }
116
+ if (response.status === 401 || response.status === 302) {
117
+ throw hrmAuthError("session_expired", E10_SESSION_EXPIRED_MESSAGE, { httpStatus: response.status });
118
+ }
119
+ if (response.parseError) {
120
+ if (response.status < 200 || response.status >= 300) {
121
+ throw new HrmCliError("api", "http_error", `\u6CDB\u5FAE\u63A5\u53E3 HTTP ${response.status}`, {
122
+ code: response.status,
123
+ details: { status: response.status },
124
+ exitCode: 1
125
+ });
126
+ }
127
+ throw hrmNetworkError("protocol", `\u63A5\u53E3\u8FD4\u56DE\u4E0D\u662F\u5408\u6CD5 JSON\uFF08HTTP ${response.status}\uFF09`, { retryable: false });
128
+ }
129
+ if (response.status < 200 || response.status >= 300) {
130
+ throw new HrmCliError("api", "http_error", `\u6CDB\u5FAE\u63A5\u53E3 HTTP ${response.status}`, {
131
+ code: response.status,
132
+ details: { status: response.status, message: businessMessage(response.value) },
133
+ exitCode: 1
134
+ });
135
+ }
136
+ if (!isBusinessSuccess(response.value)) {
137
+ const code = businessCode(response.value);
138
+ const message = businessMessage(response.value);
139
+ if (code === 403) {
140
+ throw new HrmCliError("api", "permission_denied", message || "\u5F53\u524D\u79DF\u6237\u672A\u5F00\u542F\u7EC4\u7EC7\u7BA1\u7406\u8BFB\u63A5\u53E3\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u5F00\u542F\u540E\u518D\u8BD5", {
141
+ code,
142
+ details: { code, message },
143
+ exitCode: 1
144
+ });
145
+ }
146
+ throw new HrmCliError("api", "business_error", message, {
147
+ code,
148
+ details: { code, message },
149
+ exitCode: 1
150
+ });
151
+ }
152
+ return response.value;
153
+ }
154
+ return { request, getSession };
155
+ }
156
+
157
+ export {
158
+ isBusinessSuccess,
159
+ businessMessage,
160
+ createHrmHost
161
+ };