weaver-work-cli 0.1.29 → 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 (185) 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/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,1317 @@
1
+ import { createRequire as __esbuildCreateRequire } from 'node:module';
2
+ const require = __esbuildCreateRequire(import.meta.url);
3
+ import {
4
+ E10ApiError,
5
+ createE10RequestRuntime,
6
+ requireE10Session
7
+ } from "./chunk-H3WDBYJW.js";
8
+ import {
9
+ E10_SESSION_EXPIRED_MESSAGE,
10
+ getActiveProfile
11
+ } from "./chunk-324YPTC2.js";
12
+ import {
13
+ CliError,
14
+ isCliError,
15
+ toErrorEnvelope
16
+ } from "./chunk-LUSPKZKY.js";
17
+ import "./chunk-BUSC6UAE.js";
18
+
19
+ // src/shortcuts/archive-oa/index.ts
20
+ import { readFile as readFile2 } from "node:fs/promises";
21
+
22
+ // src/shortcuts/archive-oa/continuation.ts
23
+ import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
24
+ import { existsSync } from "node:fs";
25
+ import { chmod, mkdir, readFile, writeFile } from "node:fs/promises";
26
+ import { homedir } from "node:os";
27
+ import { resolve } from "node:path";
28
+
29
+ // src/shortcuts/archive-oa/errors.ts
30
+ var ArchiveOaCliError = class extends CliError {
31
+ type;
32
+ subtype;
33
+ code;
34
+ retryable;
35
+ stage;
36
+ details;
37
+ partialData;
38
+ constructor(type, subtype, message, options = {}) {
39
+ super(message, options.exitCode ?? 5 /* InternalError */);
40
+ this.name = "ArchiveOaCliError";
41
+ this.type = type;
42
+ this.subtype = subtype;
43
+ this.code = options.code;
44
+ this.retryable = options.retryable ?? false;
45
+ this.stage = options.stage;
46
+ this.details = options.details;
47
+ this.partialData = options.partialData;
48
+ }
49
+ };
50
+ function archiveOaValidationError(subtype, message, details) {
51
+ return new ArchiveOaCliError("validation", subtype, message, {
52
+ details,
53
+ exitCode: 2 /* UsageError */
54
+ });
55
+ }
56
+ function archiveOaAuthError(subtype, message, details) {
57
+ return new ArchiveOaCliError("authentication", subtype, message, {
58
+ details,
59
+ exitCode: 3 /* AuthError */
60
+ });
61
+ }
62
+ function archiveOaNetworkError(subtype, message, options = {}) {
63
+ return new ArchiveOaCliError("network", subtype, message, {
64
+ ...options,
65
+ retryable: options.retryable ?? true,
66
+ exitCode: 4 /* NetworkError */
67
+ });
68
+ }
69
+ function archiveOaConfirmationError(action, details) {
70
+ return new ArchiveOaCliError("confirmation", "required", "\u8BE5\u64CD\u4F5C\u9700\u8981\u660E\u786E\u786E\u8BA4", {
71
+ details: { action, ...details },
72
+ exitCode: 10 /* ConfirmationRequired */
73
+ });
74
+ }
75
+ function archiveOaPartialError(message, partialData, details) {
76
+ return new ArchiveOaCliError("partial", "write_uncertain", message, {
77
+ details,
78
+ partialData,
79
+ exitCode: 11 /* Partial */
80
+ });
81
+ }
82
+
83
+ // src/shortcuts/archive-oa/continuation.ts
84
+ function stateRoot(ctx) {
85
+ const configured = ctx?.config?.path();
86
+ if (configured) return resolve(configured, "..");
87
+ return process.env.WEAVER_WORK_CLI_HOME || process.env.WORK_CLI_HOME || resolve(homedir(), ".weaver-work-cli");
88
+ }
89
+ async function loadKey(ctx) {
90
+ const keysDir = resolve(stateRoot(ctx), "keys");
91
+ const filename = resolve(keysDir, "archive-oa-continuation.key");
92
+ await mkdir(keysDir, { recursive: true, mode: 448 });
93
+ if (existsSync(filename)) return readFile(filename);
94
+ const key = randomBytes(32);
95
+ try {
96
+ await writeFile(filename, key, { flag: "wx", mode: 384 });
97
+ if (process.platform !== "win32") await chmod(filename, 384).catch(() => void 0);
98
+ return key;
99
+ } catch {
100
+ return readFile(filename);
101
+ }
102
+ }
103
+ function encode(value) {
104
+ return Buffer.from(JSON.stringify(value)).toString("base64url");
105
+ }
106
+ function signature(payload, key) {
107
+ return createHmac("sha256", key).update(payload).digest("base64url");
108
+ }
109
+ function createArchiveOaContinuationSigner(ctx) {
110
+ return {
111
+ async issue(payload, ttlMs = 10 * 6e4) {
112
+ const issuedAt = Date.now();
113
+ const body = encode({ ...payload, issuedAt, expiresAt: issuedAt + ttlMs });
114
+ const sig = signature(body, await loadKey(ctx));
115
+ return `${body}.${sig}`;
116
+ },
117
+ async verify(token, expectedOperation) {
118
+ if (typeof token !== "string" || !token.includes(".")) {
119
+ throw archiveOaValidationError("continuation_invalid", "continuation \u65E0\u6548");
120
+ }
121
+ const [body, provided] = token.split(".");
122
+ const expected = signature(body, await loadKey(ctx));
123
+ const valid = provided.length === expected.length && timingSafeEqual(Buffer.from(provided), Buffer.from(expected));
124
+ if (!valid) throw archiveOaValidationError("continuation_invalid", "continuation \u7B7E\u540D\u6821\u9A8C\u5931\u8D25");
125
+ let value;
126
+ try {
127
+ value = JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
128
+ } catch {
129
+ throw archiveOaValidationError("continuation_invalid", "continuation \u5185\u5BB9\u65E0\u6CD5\u89E3\u6790");
130
+ }
131
+ if (value.operation !== expectedOperation) {
132
+ throw archiveOaValidationError("continuation_mismatch", "continuation \u4E0D\u5C5E\u4E8E\u5F53\u524D\u64CD\u4F5C");
133
+ }
134
+ if (!Number.isSafeInteger(value.expiresAt) || value.expiresAt < Date.now()) {
135
+ throw archiveOaValidationError("continuation_expired", "continuation \u5DF2\u8FC7\u671F");
136
+ }
137
+ return value;
138
+ }
139
+ };
140
+ }
141
+
142
+ // src/shortcuts/archive-oa/host.ts
143
+ var ALLOWED_PATH_PREFIXES = ["/api/", "/openserver/"];
144
+ function inferProfile(ctx) {
145
+ const options = ctx.getGlobalOptions();
146
+ return options.profile || getActiveProfile();
147
+ }
148
+ function isArchiveOaBusinessSuccess(value) {
149
+ if (!value || typeof value !== "object") return false;
150
+ if (value.errcode !== void 0 && value.errcode !== null) return String(value.errcode) === "0";
151
+ if (typeof value.status === "boolean") return value.status;
152
+ if (typeof value.success === "boolean") return value.success;
153
+ if (value.datajson && typeof value.datajson === "object" && typeof value.datajson.status === "boolean") {
154
+ return value.datajson.status;
155
+ }
156
+ if (value.code !== void 0 && value.code !== null) return Number(value.code) === 200;
157
+ return false;
158
+ }
159
+ function archiveOaBusinessMessage(value) {
160
+ if (!value || typeof value !== "object") return "OA \u6863\u6848\u63A5\u53E3\u8FD4\u56DE\u4E1A\u52A1\u5931\u8D25";
161
+ const candidates = [
162
+ value.errmsg,
163
+ value.msg,
164
+ value.message,
165
+ value.errMsg,
166
+ value.data?.msg,
167
+ value.data?.message,
168
+ value.datajson?.msg,
169
+ value.datajson?.message
170
+ ];
171
+ for (const item of candidates) {
172
+ if (typeof item === "string" && item.trim()) return item;
173
+ }
174
+ return "OA \u6863\u6848\u63A5\u53E3\u8FD4\u56DE\u4E1A\u52A1\u5931\u8D25";
175
+ }
176
+ function archiveOaBusinessCode(value) {
177
+ if (!value || typeof value !== "object") return void 0;
178
+ const code = value.errcode ?? value.code ?? value.status;
179
+ if (typeof code === "string" || typeof code === "number") return code;
180
+ return void 0;
181
+ }
182
+ function assertArchiveOaPath(requestPath) {
183
+ if (typeof requestPath !== "string" || !requestPath.startsWith("/") || requestPath.startsWith("//")) {
184
+ throw archiveOaValidationError("path_invalid", "\u8BF7\u6C42\u8DEF\u5F84\u5FC5\u987B\u662F\u76F8\u5BF9\u7EDD\u5BF9\u8DEF\u5F84");
185
+ }
186
+ if (/^https?:/i.test(requestPath) || /[\r\n]/.test(requestPath) || requestPath.includes("/../")) {
187
+ throw archiveOaValidationError("path_invalid", "\u8BF7\u6C42\u8DEF\u5F84\u4E0D\u5141\u8BB8\u8DE8\u57DF\u6216\u8DEF\u5F84\u9003\u9038");
188
+ }
189
+ if (!ALLOWED_PATH_PREFIXES.some((prefix2) => requestPath.startsWith(prefix2))) {
190
+ throw archiveOaValidationError(
191
+ "path_not_allowed",
192
+ `archive-oa \u53EA\u80FD\u8C03\u7528 ${ALLOWED_PATH_PREFIXES.join(" / ")} \u8DEF\u5F84`
193
+ );
194
+ }
195
+ }
196
+ function omitEmptyQueryValues(query) {
197
+ if (!query) return void 0;
198
+ return Object.fromEntries(Object.entries(query).filter(([, value]) => value !== void 0 && value !== null && value !== ""));
199
+ }
200
+ function mapRuntimeNetworkError(error) {
201
+ if (error instanceof E10ApiError && error.type === "network") {
202
+ throw archiveOaNetworkError(error.subtype, error.message, {
203
+ retryable: error.retryable,
204
+ details: error.details
205
+ });
206
+ }
207
+ throw error;
208
+ }
209
+ function createArchiveOaHost(ctx, dependencies = {}) {
210
+ let e10Session = null;
211
+ let sessionContext = null;
212
+ const requireSession = dependencies.requireSession || requireE10Session;
213
+ async function ensureSession() {
214
+ if (!e10Session) {
215
+ e10Session = await requireSession(ctx);
216
+ sessionContext = {
217
+ baseUrl: e10Session.getBaseUrl(),
218
+ profile: inferProfile(ctx),
219
+ userId: e10Session.userId,
220
+ tenantKey: e10Session.tenantKey,
221
+ eteamsId: e10Session.eteamsId
222
+ };
223
+ }
224
+ return e10Session;
225
+ }
226
+ async function getSession() {
227
+ await ensureSession();
228
+ return sessionContext;
229
+ }
230
+ async function request(request2) {
231
+ const {
232
+ method,
233
+ path,
234
+ query,
235
+ body,
236
+ operation,
237
+ headers: extraHeaders = {},
238
+ timeoutMs = 6e4,
239
+ skipBusinessCheck = false
240
+ } = request2;
241
+ assertArchiveOaPath(path);
242
+ const resolvedMethod = method || (body === void 0 ? "GET" : "POST");
243
+ const runtime = createE10RequestRuntime(ctx, await ensureSession(), {
244
+ interceptors: dependencies.interceptors,
245
+ fetch: dependencies.fetch
246
+ });
247
+ const response = await runtime.requestJson({
248
+ module: "archive-oa",
249
+ operation,
250
+ method: resolvedMethod,
251
+ path,
252
+ query: omitEmptyQueryValues(query),
253
+ body,
254
+ headers: { "X-Requested-With": "XMLHttpRequest", ...extraHeaders },
255
+ timeoutMs
256
+ }).catch((error) => mapRuntimeNetworkError(error));
257
+ if (response.status === 401 || response.status === 302) {
258
+ throw archiveOaAuthError(
259
+ "session_expired",
260
+ E10_SESSION_EXPIRED_MESSAGE,
261
+ { httpStatus: response.status }
262
+ );
263
+ }
264
+ if (response.parseError) {
265
+ if (response.status < 200 || response.status >= 300) {
266
+ throw new ArchiveOaCliError("api", "http_error", `OA \u6863\u6848\u63A5\u53E3 HTTP ${response.status}`, {
267
+ code: response.status,
268
+ details: { status: response.status },
269
+ exitCode: 1
270
+ });
271
+ }
272
+ throw archiveOaNetworkError("protocol", `\u63A5\u53E3\u8FD4\u56DE\u4E0D\u662F\u5408\u6CD5 JSON\uFF08HTTP ${response.status}\uFF09`, { retryable: false });
273
+ }
274
+ if (response.status < 200 || response.status >= 300) {
275
+ throw new ArchiveOaCliError("api", "http_error", `OA \u6863\u6848\u63A5\u53E3 HTTP ${response.status}`, {
276
+ code: response.status,
277
+ details: { status: response.status, message: archiveOaBusinessMessage(response.value) },
278
+ exitCode: 1
279
+ });
280
+ }
281
+ if (!skipBusinessCheck && !isArchiveOaBusinessSuccess(response.value)) {
282
+ throw new ArchiveOaCliError("api", "business_error", archiveOaBusinessMessage(response.value), {
283
+ code: archiveOaBusinessCode(response.value),
284
+ details: {
285
+ code: archiveOaBusinessCode(response.value),
286
+ message: archiveOaBusinessMessage(response.value)
287
+ },
288
+ exitCode: 1
289
+ });
290
+ }
291
+ return response.value;
292
+ }
293
+ return { request, getSession };
294
+ }
295
+
296
+ // src/shortcuts/archive-oa/constants.ts
297
+ var MAX_BORROW_ITEMS = 6;
298
+ var BORROW_FLOW_ID = "100003460000002090";
299
+ var ARCHIVE_LOCATE_INTERFACE_PK = "getArcIdByContractNo";
300
+ var ARCHIVE_LOCATE_PATH = `/api/ebuilder/form/formdata/v2/getFormDataList/${ARCHIVE_LOCATE_INTERFACE_PK}`;
301
+ var WEAVER_CONTRACT = {
302
+ source: "weaver",
303
+ passId: "850741972510941185",
304
+ listId: "850741985437786120",
305
+ filterListId: "850741985437786120",
306
+ cusMenuId: "5408862605522555751",
307
+ urlPageTitle: "5rOb5b6u5qGI5L6L"
308
+ };
309
+ var WEAVER_BORROW_CAR = {
310
+ source: "weaver",
311
+ passId: "882393476189437952",
312
+ listId: "882393480417296390",
313
+ cusMenuId: "5408862605522555751",
314
+ urlPageTitle: "5rOb5b6u5qGI5L6L"
315
+ };
316
+ var WEAVER_ESB_ADD = {
317
+ source: "weaver",
318
+ esbActionIds: "882395911377174530",
319
+ objId: "850741972510941185",
320
+ listId: "850741985437786120",
321
+ successText: "\u3010\u52A0\u5165\u501F\u9605\u8F66\u3011\u6267\u884C\u6210\u529F\uFF01"
322
+ };
323
+ var QYS_CONTRACT = {
324
+ source: "qys",
325
+ passId: "850742853046345728",
326
+ listId: "1190611964371984450",
327
+ cusMenuId: "5408862605522555752",
328
+ urlPageTitle: "5aWR57qm6ZSB5qGI5L6L"
329
+ };
330
+ var QYS_BORROW_CAR = {
331
+ source: "qys",
332
+ passId: "882393476189437952",
333
+ listId: "883819516961857839",
334
+ cusMenuId: "5408862605522555752",
335
+ urlPageTitle: "5aWR57qm6ZSB5qGI5L6L"
336
+ };
337
+ var QYS_ESB_ADD = {
338
+ source: "qys",
339
+ esbActionIds: "892706856573648911",
340
+ objId: "850742853046345728",
341
+ listId: "1190611964371984450",
342
+ successText: "\u3010\u5951\u7EA6\u9501\u52A0\u5165\u501F\u9605\u8F66\u3011\u6267\u884C\u6210\u529F\uFF01"
343
+ };
344
+ var QYS_DEFAULT_ARCHIVED_FIELD = "cljd";
345
+ var QYS_DEFAULT_ARCHIVED_VALUE = "\u5DF2\u5F52\u6863";
346
+
347
+ // src/shortcuts/archive-oa/operations/types.ts
348
+ var READ = "read";
349
+ var READ_BEFORE_WRITE = "read-before-write";
350
+ var HIGH_RISK_WRITE = "high-risk-write";
351
+ function archiveOaSuccess(action, data, meta) {
352
+ const payload = { ok: true, action, data };
353
+ if (meta && Object.keys(meta).length > 0) payload.meta = meta;
354
+ return payload;
355
+ }
356
+ function schemaOf(properties, options = {}) {
357
+ return {
358
+ type: "object",
359
+ additionalProperties: false,
360
+ properties,
361
+ ...options.required?.length ? { required: options.required } : {},
362
+ ...options.description ? { description: options.description } : {}
363
+ };
364
+ }
365
+ var SCHEMA_PAGE_NO = { type: "integer", minimum: 1 };
366
+ var SCHEMA_ID_STRING = { type: "string", pattern: "^\\d+$" };
367
+ var SCHEMA_ID_LIST = { type: "array", items: SCHEMA_ID_STRING, minItems: 1 };
368
+ var SCHEMA_SEARCH_FIELDS = {
369
+ type: "array",
370
+ description: "\u641C\u7D22\u6761\u4EF6\u6570\u7EC4\uFF0C\u5143\u7D20\u4E3A { field, conditionType, value }",
371
+ items: {
372
+ type: "object",
373
+ additionalProperties: false,
374
+ required: ["field", "value"],
375
+ properties: {
376
+ field: { type: "string", minLength: 1, description: "\u5B57\u6BB5\u5185\u90E8\u540D\uFF0C\u5982 hth / khmc / htzje / zxfa" },
377
+ conditionType: {
378
+ type: "string",
379
+ enum: ["like", "between", "in", "inC"],
380
+ description: "\u6761\u4EF6\u7C7B\u578B\uFF0C\u7F3A\u7701 like\uFF1Bbetween \u7528 {min,max} \u6216 [\u8D77,\u6B62]\uFF1Bin/inC \u7528\u6570\u7EC4"
381
+ },
382
+ value: { description: "\u6761\u4EF6\u503C\uFF1Alike \u4E3A\u5B57\u7B26\u4E32\uFF0Cbetween \u4E3A\u5BF9\u8C61\u6216\u4E8C\u5143\u6570\u7EC4\uFF0Cin/inC \u4E3A\u6570\u7EC4" }
383
+ }
384
+ }
385
+ };
386
+
387
+ // src/shortcuts/archive-oa/operations/shared.ts
388
+ var FORBIDDEN_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
389
+ var CONDITION_TYPES = /* @__PURE__ */ new Set(["like", "between", "in", "inC"]);
390
+ function asObject(value) {
391
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
392
+ throw archiveOaValidationError("input_not_object", "\u8F93\u5165\u5FC5\u987B\u662F JSON \u5BF9\u8C61");
393
+ }
394
+ return value;
395
+ }
396
+ function assertNoForbiddenKeys(input) {
397
+ for (const key of Object.keys(input)) {
398
+ if (FORBIDDEN_KEYS.has(key)) {
399
+ throw archiveOaValidationError("forbidden_key", `\u8F93\u5165\u5305\u542B\u975E\u6CD5\u5B57\u6BB5\uFF1A${key}`);
400
+ }
401
+ }
402
+ }
403
+ function unwrapData(response) {
404
+ if (!response || typeof response !== "object") return response;
405
+ return response.data;
406
+ }
407
+ function positiveInt(value, field, fallback) {
408
+ if (value === void 0 || value === null || value === "") return fallback;
409
+ const parsed = Number(value);
410
+ if (!Number.isInteger(parsed) || parsed <= 0) {
411
+ throw archiveOaValidationError("number_invalid", `${field} \u5FC5\u987B\u662F\u6B63\u6574\u6570`);
412
+ }
413
+ return parsed;
414
+ }
415
+ function requireText(value, field) {
416
+ if (typeof value !== "string" || !value.trim()) {
417
+ throw archiveOaValidationError("field_required", `${field} \u5FC5\u586B`);
418
+ }
419
+ return value.trim();
420
+ }
421
+ function assertEnum(value, allowed, field) {
422
+ const text = typeof value === "string" ? value : String(value);
423
+ if (!allowed.includes(text)) {
424
+ throw archiveOaValidationError("enum_invalid", `${field} \u53D6\u503C\u5FC5\u987B\u662F ${allowed.join(" / ")} \u4E4B\u4E00`);
425
+ }
426
+ return text;
427
+ }
428
+ function requireIdList(value, field, max = MAX_BORROW_ITEMS) {
429
+ if (!Array.isArray(value) || value.length === 0) {
430
+ throw archiveOaValidationError("id_list_required", `${field} \u5FC5\u586B\u4E14\u81F3\u5C11\u4E00\u9879`);
431
+ }
432
+ if (value.length > max) {
433
+ throw archiveOaValidationError("id_list_too_many", `${field} \u6700\u591A ${max} \u6761\uFF0C\u5F53\u524D ${value.length} \u6761`);
434
+ }
435
+ const seen = /* @__PURE__ */ new Set();
436
+ return value.map((item, index) => {
437
+ const text = typeof item === "string" ? item.trim() : String(item ?? "").trim();
438
+ if (!/^\d+$/.test(text)) {
439
+ throw archiveOaValidationError("id_list_invalid", `${field}[${index}] \u5FC5\u987B\u662F\u6570\u5B57 ID`);
440
+ }
441
+ if (seen.has(text)) {
442
+ throw archiveOaValidationError("id_list_duplicated", `${field}[${index}] \u91CD\u590D\uFF1A${text}`);
443
+ }
444
+ seen.add(text);
445
+ return text;
446
+ });
447
+ }
448
+ function buildCommonSearchFields(fields, extra = []) {
449
+ const result = {};
450
+ const items = [...extra];
451
+ if (fields !== void 0 && fields !== null) {
452
+ if (!Array.isArray(fields)) {
453
+ throw archiveOaValidationError("search_fields_invalid", "fields \u5FC5\u987B\u662F\u6570\u7EC4");
454
+ }
455
+ for (const [index, raw] of fields.entries()) {
456
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
457
+ throw archiveOaValidationError("search_fields_invalid", `fields[${index}] \u5FC5\u987B\u662F\u5BF9\u8C61`);
458
+ }
459
+ const item = raw;
460
+ const field = requireText(item.field, `fields[${index}].field`);
461
+ const conditionType = item.conditionType === void 0 || item.conditionType === null ? "like" : String(item.conditionType);
462
+ if (!CONDITION_TYPES.has(conditionType)) {
463
+ throw archiveOaValidationError(
464
+ "search_condition_invalid",
465
+ `fields[${index}].conditionType \u5FC5\u987B\u662F like / between / in / inC \u4E4B\u4E00`
466
+ );
467
+ }
468
+ if (item.value === void 0 || item.value === null) {
469
+ throw archiveOaValidationError("search_value_required", `fields[${index}].value \u5FC5\u586B`);
470
+ }
471
+ items.push({ field, conditionType, value: item.value });
472
+ }
473
+ }
474
+ for (const item of items) {
475
+ const value = normalizeConditionValue(item.conditionType, item.value, item.field);
476
+ result[item.field] = [{ [`${item.field}_condition_type`]: item.conditionType, [item.field]: value }];
477
+ }
478
+ return result;
479
+ }
480
+ function normalizeConditionValue(conditionType, value, field) {
481
+ if (conditionType === "between") {
482
+ if (Array.isArray(value)) {
483
+ if (value.length !== 2) {
484
+ throw archiveOaValidationError("search_value_invalid", `${field} \u7684 between \u6761\u4EF6\u9700\u8981\u4E24\u4E2A\u503C`);
485
+ }
486
+ return { min: String(value[0]), max: String(value[1]) };
487
+ }
488
+ if (value && typeof value === "object") {
489
+ const range = value;
490
+ if (range.min === void 0 || range.max === void 0) {
491
+ throw archiveOaValidationError("search_value_invalid", `${field} \u7684 between \u6761\u4EF6\u9700\u8981 min / max`);
492
+ }
493
+ return { min: String(range.min), max: String(range.max) };
494
+ }
495
+ throw archiveOaValidationError("search_value_invalid", `${field} \u7684 between \u6761\u4EF6\u5FC5\u987B\u662F {min,max} \u6216 [\u8D77,\u6B62]`);
496
+ }
497
+ if (conditionType === "in" || conditionType === "inC") {
498
+ if (!Array.isArray(value)) {
499
+ throw archiveOaValidationError("search_value_invalid", `${field} \u7684 ${conditionType} \u6761\u4EF6\u5FC5\u987B\u662F\u6570\u7EC4`);
500
+ }
501
+ return value;
502
+ }
503
+ return value;
504
+ }
505
+ function normalizeListResult(action, response, source) {
506
+ const data = unwrapData(response) ?? {};
507
+ const rows = Array.isArray(data.data) ? data.data : [];
508
+ const columns = Array.isArray(data.columns) ? data.columns.map((column) => ({
509
+ title: String(column?.title ?? ""),
510
+ dataIndex: String(column?.dataIndex ?? "")
511
+ })) : [];
512
+ return {
513
+ rows,
514
+ meta: {
515
+ source,
516
+ count: rows.length,
517
+ current: data.current ?? void 0,
518
+ pageSize: data.pageSize ?? void 0,
519
+ /** 接口可能返回 total=0 但 data 非空,属于正常现象,不做无数据判定。 */
520
+ total: data.total ?? void 0,
521
+ columns
522
+ }
523
+ };
524
+ }
525
+
526
+ // src/shortcuts/archive-oa/operations/confirm.ts
527
+ function requireConfirm(args, action) {
528
+ if (args.confirm !== true) {
529
+ throw archiveOaConfirmationError(action, {
530
+ hint: `\u6267\u884C ${action} \u5FC5\u987B\u663E\u5F0F\u786E\u8BA4\uFF1A\u4F20\u5165 confirm=true\uFF08CLI \u7528 --yes\uFF09`
531
+ });
532
+ }
533
+ }
534
+ async function issueLease(env, action, payload, ttlMs = 10 * 6e4) {
535
+ const session = await env.host.getSession();
536
+ const continuation = await env.continuation.issue(
537
+ {
538
+ operation: action,
539
+ baseUrl: session.baseUrl,
540
+ userId: session.userId,
541
+ ...payload
542
+ },
543
+ ttlMs
544
+ );
545
+ return { continuation, expiresInMs: ttlMs };
546
+ }
547
+ async function verifyLease(args, action, env) {
548
+ requireConfirm(args, action);
549
+ if (typeof args.continuation !== "string" || !args.continuation.trim()) {
550
+ throw archiveOaValidationError("continuation_required", `${action} \u5FC5\u987B\u4F20\u5165 prepare \u8FD4\u56DE\u7684 continuation`);
551
+ }
552
+ const lease = await env.continuation.verify(args.continuation.trim(), action);
553
+ const session = await env.host.getSession();
554
+ if (lease.baseUrl !== session.baseUrl || lease.userId !== session.userId) {
555
+ throw archiveOaValidationError(
556
+ "continuation_context_mismatch",
557
+ "\u786E\u8BA4\u4E0A\u4E0B\u6587\u5DF2\u53D8\u5316\uFF08\u73AF\u5883\u6216\u767B\u5F55\u8D26\u53F7\u4E0D\u540C\uFF09\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C prepare"
558
+ );
559
+ }
560
+ return lease;
561
+ }
562
+ function assertLeaseTarget(lease, args, keys, action) {
563
+ for (const key of keys) {
564
+ if (args[key] === void 0 || args[key] === null || args[key] === "") continue;
565
+ const expected = String(lease[key] ?? "");
566
+ const actual = Array.isArray(args[key]) ? args[key].map(String).join(",") : String(args[key]);
567
+ if (expected !== actual) {
568
+ throw archiveOaValidationError(
569
+ "continuation_target_changed",
570
+ `${action} \u7684\u53C2\u6570 ${key} \u4E0E prepare \u65F6\u4E0D\u4E00\u81F4\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C prepare`
571
+ );
572
+ }
573
+ }
574
+ }
575
+
576
+ // src/shortcuts/archive-oa/operations/borrow-car.ts
577
+ var CONTRACT_LIST_PATH = "/api/ebuilder/form/list/getListDatas";
578
+ var RUN_ESB_PATH = "/api/ebuilder/form/esb/runEsb";
579
+ function prefix(source) {
580
+ return source === "qys" ? "archive-oa.qys.borrow-car" : "archive-oa.borrow-car";
581
+ }
582
+ function makeListOperation(profile) {
583
+ const name = `${prefix(profile.source)}.list`;
584
+ return {
585
+ name,
586
+ resource: "borrow-car",
587
+ method: "list",
588
+ action: name,
589
+ summary: `\u67E5\u8BE2${profile.source === "qys" ? "\u5951\u7EA6\u9501" : "\u6CDB\u5FAE"}\u5408\u540C\u501F\u9605\u8F66\u5217\u8868`,
590
+ capability: "borrow-car",
591
+ risk: READ,
592
+ inputSchema: schemaOf(
593
+ { pageNo: { ...SCHEMA_PAGE_NO, description: "\u9875\u7801\uFF0C\u4ECE 1 \u5F00\u59CB\uFF0C\u7F3A\u7701 1" } },
594
+ { description: "\u67E5\u8BE2\u501F\u9605\u8F66\u5217\u8868" }
595
+ ),
596
+ handler: async (args, env) => {
597
+ const pageNo = positiveInt(args.pageNo, "pageNo", 1);
598
+ const response = await env.host.request({
599
+ method: "POST",
600
+ path: CONTRACT_LIST_PATH,
601
+ operation: name,
602
+ query: { passid: profile.passId, cid: profile.passId, sf_request_type: "ajax" },
603
+ body: {
604
+ current: pageNo,
605
+ requiredMatch: 1,
606
+ mapResult: "1",
607
+ recheckQuery: "1",
608
+ cusMenuId: profile.cusMenuId,
609
+ urlPageTitle: profile.urlPageTitle,
610
+ searchParamData: { searchType: "2", type: "and", commonSearchFields: {}, groupFields: {} },
611
+ listId: profile.listId,
612
+ isFollow: 0,
613
+ isShareToMe: 0,
614
+ filterCondition: {},
615
+ browser: "Chrome"
616
+ }
617
+ });
618
+ const { rows, meta } = normalizeListResult(name, response, profile.source);
619
+ return archiveOaSuccess(name, { rows }, { ...meta, pageNo });
620
+ }
621
+ };
622
+ }
623
+ function makeAddOperations(carProfile, esb) {
624
+ const prepareName = `${prefix(carProfile.source)}.add.prepare`;
625
+ const applyName = `${prefix(carProfile.source)}.add.apply`;
626
+ const prepare = {
627
+ name: prepareName,
628
+ resource: "borrow-car",
629
+ method: "add",
630
+ action: prepareName,
631
+ summary: `\u628A${esb.source === "qys" ? "\u5951\u7EA6\u9501" : "\u6CDB\u5FAE"}\u5408\u540C\u52A0\u5165\u501F\u9605\u8F66\uFF1A\u6821\u9A8C\u6761\u6570\u5E76\u56DE\u67E5\u501F\u9605\u8F66\u73B0\u72B6\uFF08\u4E0D\u5199\u6570\u636E\uFF09`,
632
+ capability: "borrow-car",
633
+ risk: READ_BEFORE_WRITE,
634
+ inputSchema: schemaOf(
635
+ {
636
+ dataIds: {
637
+ ...SCHEMA_ID_LIST,
638
+ maxItems: MAX_BORROW_ITEMS,
639
+ description: `\u5408\u540C\u6570\u636E\u884C id \u6570\u7EC4\uFF0C\u6765\u81EA\u5408\u540C\u67E5\u8BE2\u7ED3\u679C\u7684 data[*].id\uFF0C\u6700\u591A ${MAX_BORROW_ITEMS} \u6761`
640
+ }
641
+ },
642
+ { required: ["dataIds"], description: "\u52A0\u5165\u501F\u9605\u8F66\u9884\u68C0" }
643
+ ),
644
+ handler: async (args, env) => {
645
+ const dataIds = requireIdList(args.dataIds, "dataIds", MAX_BORROW_ITEMS);
646
+ const current = await env.host.request({
647
+ method: "POST",
648
+ path: CONTRACT_LIST_PATH,
649
+ operation: prepareName,
650
+ query: { passid: carProfile.passId, cid: carProfile.passId, sf_request_type: "ajax" },
651
+ body: {
652
+ current: 1,
653
+ requiredMatch: 1,
654
+ mapResult: "1",
655
+ recheckQuery: "1",
656
+ cusMenuId: carProfile.cusMenuId,
657
+ urlPageTitle: carProfile.urlPageTitle,
658
+ searchParamData: { searchType: "2", type: "and", commonSearchFields: {}, groupFields: {} },
659
+ listId: carProfile.listId,
660
+ isFollow: 0,
661
+ isShareToMe: 0,
662
+ filterCondition: {},
663
+ browser: "Chrome"
664
+ }
665
+ });
666
+ const { rows } = normalizeListResult(prepareName, current, carProfile.source);
667
+ const { continuation, expiresInMs } = await issueLease(env, applyName, {
668
+ dataIds,
669
+ esbActionIds: esb.esbActionIds,
670
+ objId: esb.objId,
671
+ listId: esb.listId
672
+ });
673
+ return archiveOaSuccess(
674
+ prepareName,
675
+ {
676
+ preview: {
677
+ source: carProfile.source,
678
+ count: dataIds.length,
679
+ dataIds,
680
+ borrowCarBefore: rows.length
681
+ },
682
+ hint: `\u786E\u8BA4\u540E\u8C03\u7528 ${applyName}\uFF08CLI\uFF1Aarchive-oa borrow-car add-apply --continuation <token> --yes\uFF09`,
683
+ continuation
684
+ },
685
+ { requiresConfirmation: true, expiresInMs }
686
+ );
687
+ }
688
+ };
689
+ const apply = {
690
+ name: applyName,
691
+ resource: "borrow-car",
692
+ method: "add",
693
+ action: applyName,
694
+ summary: `\u628A${esb.source === "qys" ? "\u5951\u7EA6\u9501" : "\u6CDB\u5FAE"}\u5408\u540C\u52A0\u5165\u501F\u9605\u8F66\uFF08\u5199\u64CD\u4F5C\uFF09\uFF1A\u6267\u884C ESB \u52A8\u4F5C`,
695
+ capability: "borrow-car",
696
+ risk: HIGH_RISK_WRITE,
697
+ requiresConfirmation: true,
698
+ inputSchema: schemaOf(
699
+ {
700
+ continuation: { type: "string", description: "prepare \u8FD4\u56DE\u7684\u786E\u8BA4\u7968\u636E" },
701
+ confirm: { type: "boolean", description: "\u5FC5\u987B\u4E3A true\uFF08CLI --yes\uFF09" }
702
+ },
703
+ { required: ["continuation", "confirm"], description: "\u52A0\u5165\u501F\u9605\u8F66" }
704
+ ),
705
+ handler: async (args, env) => {
706
+ const lease = await verifyLease(args, applyName, env);
707
+ assertLeaseTarget(lease, args, ["dataIds"], applyName);
708
+ const dataIds = Array.isArray(lease.dataIds) ? lease.dataIds.map(String) : [];
709
+ if (dataIds.length === 0 || dataIds.length > MAX_BORROW_ITEMS) {
710
+ throw new Error("continuation \u7F3A\u5C11\u5408\u6CD5\u7684 dataIds");
711
+ }
712
+ const response = await env.host.request({
713
+ method: "POST",
714
+ path: RUN_ESB_PATH,
715
+ operation: applyName,
716
+ query: { sf_request_type: "ajax" },
717
+ body: {
718
+ dataIds: dataIds.join(","),
719
+ esbActionIds: String(lease.esbActionIds ?? esb.esbActionIds),
720
+ objId: String(lease.objId ?? esb.objId),
721
+ listId: String(lease.listId ?? esb.listId)
722
+ }
723
+ });
724
+ const data = unwrapData(response) ?? {};
725
+ const failNum = Number(data.failNum ?? 0);
726
+ if (failNum > 0) {
727
+ throw archiveOaPartialError(
728
+ `\u52A0\u5165\u501F\u9605\u8F66\u90E8\u5206\u5931\u8D25\uFF1A\u6210\u529F ${data.successNum ?? 0} \u6761\uFF0C\u5931\u8D25 ${failNum} \u6761`,
729
+ { successNum: data.successNum ?? 0, failNum, failIds: data.failIds ?? [] },
730
+ { dataIds, needRefresh: data.needRefresh === true }
731
+ );
732
+ }
733
+ return archiveOaSuccess(
734
+ applyName,
735
+ {
736
+ message: String(data.successMsg ?? esb.successText),
737
+ successNum: data.successNum ?? dataIds.length,
738
+ failNum,
739
+ needRefresh: data.needRefresh === true
740
+ },
741
+ { wrote: true, source: carProfile.source, count: dataIds.length }
742
+ );
743
+ }
744
+ };
745
+ return [prepare, apply];
746
+ }
747
+ function createBorrowCarOperations(carProfile, esb) {
748
+ return [makeListOperation(carProfile), ...makeAddOperations(carProfile, esb)];
749
+ }
750
+
751
+ // src/shortcuts/archive-oa/operations/borrow-url.ts
752
+ var CONTRACT_LIST_PATH2 = "/api/ebuilder/form/list/getListDatas";
753
+ function buildBorrowStartUrl(baseUrl, fb, items) {
754
+ const root = baseUrl.replace(/\/+$/, "");
755
+ const data = encodeURIComponent(JSON.stringify(items));
756
+ return `${root}/sp/workflow/flowpage/fullCreate/${BORROW_FLOW_ID}?fb=${fb}&data=${data}`;
757
+ }
758
+ function toItem(row) {
759
+ return {
760
+ hth: String(row?.hth ?? ""),
761
+ /** 泛微用 htmc,契约锁用 qymc,二者取其一,缺失为空串。 */
762
+ htmc: String(row?.htmc ?? row?.qymc ?? ""),
763
+ yfhd: String(row?.yfhd ?? row?.yhhd ?? ""),
764
+ fph: String(row?.fph ?? "")
765
+ };
766
+ }
767
+ function createBorrowStartUrlOperation(profile) {
768
+ const name = profile.source === "qys" ? "archive-oa.qys.borrow.start.url" : "archive-oa.borrow.start.url";
769
+ const listName = profile.source === "qys" ? "archive-oa.qys.borrow-car.list" : "archive-oa.borrow-car.list";
770
+ return {
771
+ name,
772
+ resource: "borrow",
773
+ method: "start-url",
774
+ action: name,
775
+ summary: "\u6309\u501F\u9605\u8F66\u8BB0\u5F55\u6784\u9020\u300C\u53D1\u8D77\u501F\u9605\u300D\u6D41\u7A0B\u521B\u5EFA\u9875 URL\uFF08\u53EA\u8BFB\uFF1A\u4E0D\u5199\u6570\u636E\u3001\u4E0D\u89E6\u53D1\u6D41\u7A0B\u3001\u4E0D\u9700\u8981\u540E\u53F0\u5E94\u7528\u51ED\u636E\uFF09",
776
+ capability: "borrowCar",
777
+ risk: READ,
778
+ inputSchema: schemaOf(
779
+ {
780
+ contractNos: {
781
+ type: "array",
782
+ items: { type: "string" },
783
+ maxItems: MAX_BORROW_ITEMS,
784
+ description: `\u8981\u501F\u9605\u7684\u5408\u540C\u53F7\uFF08\u53D6\u81EA\u501F\u9605\u8F66\uFF09\uFF0C\u6700\u591A ${MAX_BORROW_ITEMS} \u4E2A\uFF1B\u4E0D\u4F20\u8868\u793A\u4F7F\u7528\u6574\u9875\u501F\u9605\u8F66\u8BB0\u5F55`
785
+ }
786
+ },
787
+ { description: "\u6784\u9020\u53D1\u8D77\u501F\u9605\u6D41\u7A0B\u521B\u5EFA\u9875 URL" }
788
+ ),
789
+ handler: async (args, env) => {
790
+ const session = await env.host.getSession();
791
+ const response = await env.host.request({
792
+ method: "POST",
793
+ path: CONTRACT_LIST_PATH2,
794
+ operation: listName,
795
+ query: { passid: profile.passId, cid: profile.passId, sf_request_type: "ajax" },
796
+ body: {
797
+ current: 1,
798
+ requiredMatch: 1,
799
+ mapResult: "1",
800
+ recheckQuery: "1",
801
+ cusMenuId: profile.cusMenuId,
802
+ urlPageTitle: profile.urlPageTitle,
803
+ searchParamData: {
804
+ searchType: "2",
805
+ type: "and",
806
+ commonSearchFields: {},
807
+ groupFields: {}
808
+ },
809
+ listId: profile.listId,
810
+ isFollow: 0,
811
+ isShareToMe: 0,
812
+ filterCondition: {},
813
+ browser: "Chrome"
814
+ }
815
+ });
816
+ const { rows, meta } = normalizeListResult(listName, response, profile.source);
817
+ const requested = Array.isArray(args.contractNos) ? args.contractNos.map((value) => String(value).trim()).filter(Boolean) : [];
818
+ let picked = rows;
819
+ if (requested.length > 0) {
820
+ if (requested.length > MAX_BORROW_ITEMS) {
821
+ throw archiveOaValidationError(
822
+ "too_many_items",
823
+ `\u4E00\u6B21\u6700\u591A\u501F\u9605 ${MAX_BORROW_ITEMS} \u6761\uFF0C\u5F53\u524D\u4F20\u5165 ${requested.length} \u6761`
824
+ );
825
+ }
826
+ picked = rows.filter((row) => requested.includes(String(row?.hth ?? "")));
827
+ const missing = requested.filter(
828
+ (no) => !picked.some((row) => String(row?.hth ?? "") === no)
829
+ );
830
+ if (missing.length > 0) {
831
+ throw archiveOaValidationError(
832
+ "contract_not_in_borrow_car",
833
+ `\u501F\u9605\u8F66\u4E2D\u4E0D\u5B58\u5728\u8FD9\u4E9B\u5408\u540C\u53F7\uFF1A${missing.join("\u3001")}`,
834
+ { missing }
835
+ );
836
+ }
837
+ }
838
+ if (picked.length === 0) {
839
+ throw archiveOaValidationError("borrow_car_empty", "\u501F\u9605\u8F66\u4E3A\u7A7A\uFF0C\u8BF7\u5148\u628A\u5408\u540C\u52A0\u5165\u501F\u9605\u8F66");
840
+ }
841
+ if (picked.length > MAX_BORROW_ITEMS) {
842
+ throw archiveOaValidationError(
843
+ "too_many_items",
844
+ `\u501F\u9605\u8F66\u53EF\u53D1\u8D77\u6761\u6570\u6700\u591A ${MAX_BORROW_ITEMS} \u6761\uFF0C\u5F53\u524D ${picked.length} \u6761\uFF0C\u8BF7\u6307\u5B9A\u5408\u540C\u53F7`
845
+ );
846
+ }
847
+ const fb = String(picked[0]?.fb ?? "0");
848
+ const items = picked.map(toItem);
849
+ const url = buildBorrowStartUrl(session.baseUrl, fb, items);
850
+ return archiveOaSuccess(
851
+ name,
852
+ {
853
+ url,
854
+ flowId: BORROW_FLOW_ID,
855
+ fb,
856
+ items,
857
+ borrowCarCount: rows.length,
858
+ columns: meta.columns
859
+ },
860
+ { opensBrowser: false, count: items.length }
861
+ );
862
+ }
863
+ };
864
+ }
865
+
866
+ // src/shortcuts/archive-oa/operations/contract.ts
867
+ var CONTRACT_LIST_PATH3 = "/api/ebuilder/form/list/getListDatas";
868
+ function filterPath(profile) {
869
+ return `/api/ebuilder/form/listFilter/showFilters/${profile.listId}`;
870
+ }
871
+ function operationName(profile, action) {
872
+ return profile.source === "qys" ? `archive-oa.qys.contract.${action}` : `archive-oa.contract.${action}`;
873
+ }
874
+ function listBody(profile, pageNo, commonSearchFields, matchType) {
875
+ return {
876
+ current: pageNo,
877
+ requiredMatch: 1,
878
+ mapResult: "1",
879
+ recheckQuery: "1",
880
+ cusMenuId: profile.cusMenuId,
881
+ urlPageTitle: profile.urlPageTitle,
882
+ searchParamData: {
883
+ searchType: "2",
884
+ type: matchType,
885
+ commonSearchFields,
886
+ groupFields: {}
887
+ },
888
+ listId: profile.listId,
889
+ isFollow: 0,
890
+ isShareToMe: 0,
891
+ filterCondition: {},
892
+ browser: "Chrome"
893
+ };
894
+ }
895
+ function makeFieldsOperation(profile) {
896
+ const name = operationName(profile, "fields");
897
+ return {
898
+ name,
899
+ resource: "contract",
900
+ method: "fields",
901
+ action: name,
902
+ summary: `\u67E5\u8BE2${profile.source === "qys" ? "\u5951\u7EA6\u9501" : "\u6CDB\u5FAE"}\u5546\u52A1\u5408\u540C\u53EF\u641C\u7D22\u5B57\u6BB5\u914D\u7F6E\uFF08\u6784\u9020 commonSearchFields \u7528\uFF09`,
903
+ capability: "contract-search",
904
+ risk: READ,
905
+ inputSchema: schemaOf({}, { description: "\u67E5\u8BE2\u5408\u540C\u641C\u7D22\u5B57\u6BB5\u914D\u7F6E\uFF0C\u65E0\u9700\u5165\u53C2" }),
906
+ handler: async (_args, env) => {
907
+ const response = await env.host.request({
908
+ method: "GET",
909
+ path: filterPath(profile),
910
+ operation: name,
911
+ query: { passid: profile.passId, sf_request_type: "ajax" }
912
+ });
913
+ const data = unwrapData(response) ?? {};
914
+ const fields = Array.isArray(data.fields) ? data.fields : Array.isArray(data) ? data : [];
915
+ return archiveOaSuccess(
916
+ name,
917
+ { fields },
918
+ { source: profile.source, listId: profile.listId, count: Array.isArray(fields) ? fields.length : 0 }
919
+ );
920
+ }
921
+ };
922
+ }
923
+ function makeListOperation2(profile) {
924
+ const name = operationName(profile, "list");
925
+ const isQys = profile.source === "qys";
926
+ return {
927
+ name,
928
+ resource: "contract",
929
+ method: "list",
930
+ action: name,
931
+ summary: `\u67E5\u8BE2${isQys ? "\u5951\u7EA6\u9501\u534F\u4F5C\u91C7\u7EB3\uFF08\u6848\u4F8B\uFF09" : "\u6CDB\u5FAE"}\u5546\u52A1\u5408\u540C\u5217\u8868`,
932
+ capability: "contract-search",
933
+ risk: READ,
934
+ inputSchema: schemaOf(
935
+ {
936
+ pageNo: { ...SCHEMA_PAGE_NO, description: "\u9875\u7801\uFF0C\u4ECE 1 \u5F00\u59CB\uFF0C\u7F3A\u7701 1" },
937
+ fields: SCHEMA_SEARCH_FIELDS,
938
+ matchType: {
939
+ type: "string",
940
+ enum: ["and", "or"],
941
+ description: "\u591A\u6761\u4EF6\u7EC4\u5408\u65B9\u5F0F\uFF0C\u7F3A\u7701 and\uFF08\u6E90\u8D44\u6599\u7EA6\u5B9A\u9ED8\u8BA4\u300C\u4E14\u300D\uFF09"
942
+ },
943
+ ...isQys ? {
944
+ archivedOnly: {
945
+ type: "boolean",
946
+ description: `\u9ED8\u8BA4 true\uFF1A\u9644\u52A0 ${QYS_DEFAULT_ARCHIVED_FIELD}=${QYS_DEFAULT_ARCHIVED_VALUE}\uFF08\u5904\u7406\u8FDB\u5EA6=\u5DF2\u5F52\u6863\uFF09\u8FC7\u6EE4`
947
+ }
948
+ } : {}
949
+ },
950
+ { description: `\u67E5\u8BE2${isQys ? "\u5951\u7EA6\u9501" : "\u6CDB\u5FAE"}\u5546\u52A1\u5408\u540C\u5217\u8868` }
951
+ ),
952
+ handler: async (args, env) => {
953
+ const pageNo = positiveInt(args.pageNo, "pageNo", 1);
954
+ const matchType = args.matchType === void 0 ? "and" : assertEnum(args.matchType, ["and", "or"], "matchType");
955
+ const extra = [];
956
+ const archivedOnly = args.archivedOnly === void 0 ? true : args.archivedOnly;
957
+ if (isQys && archivedOnly === true) {
958
+ extra.push({
959
+ field: QYS_DEFAULT_ARCHIVED_FIELD,
960
+ conditionType: "like",
961
+ value: QYS_DEFAULT_ARCHIVED_VALUE
962
+ });
963
+ }
964
+ const commonSearchFields = buildCommonSearchFields(args.fields, extra);
965
+ const response = await env.host.request({
966
+ method: "POST",
967
+ path: CONTRACT_LIST_PATH3,
968
+ operation: name,
969
+ query: { passid: profile.passId, cid: profile.passId, sf_request_type: "ajax" },
970
+ body: listBody(profile, pageNo, commonSearchFields, matchType)
971
+ });
972
+ const { rows, meta } = normalizeListResult(name, response, profile.source);
973
+ return archiveOaSuccess(
974
+ name,
975
+ { rows, searchFields: commonSearchFields },
976
+ { ...meta, pageNo, archivedOnly: isQys ? archivedOnly : void 0 }
977
+ );
978
+ }
979
+ };
980
+ }
981
+ var weaverContractFieldsOperation = makeFieldsOperation(WEAVER_CONTRACT);
982
+ var weaverContractListOperation = makeListOperation2(WEAVER_CONTRACT);
983
+ var qysContractListOperation = makeListOperation2(QYS_CONTRACT);
984
+
985
+ // src/shortcuts/archive-oa/operations/locate.ts
986
+ var ARCHIVE_LOCATE = "archive-oa.archive.locate";
987
+ var archiveLocateOperation = {
988
+ name: ARCHIVE_LOCATE,
989
+ resource: "archive",
990
+ method: "locate",
991
+ action: ARCHIVE_LOCATE,
992
+ summary: "\u6309\u5408\u540C\u53F7\u5B9A\u4F4D\u6863\u6848\uFF1A\u8FD4\u56DE\u6863\u6848\u8BB0\u5F55 ID / \u9898\u540D / \u5408\u540C\u53F7",
993
+ capability: "archive-locate",
994
+ risk: READ,
995
+ inputSchema: schemaOf(
996
+ {
997
+ contractNo: { type: "string", minLength: 1, description: "\u5408\u540C\u53F7\uFF08\u5BF9\u5E94\u63A5\u53E3\u9876\u5C42 htbh\uFF09" },
998
+ pageNo: { ...SCHEMA_PAGE_NO, description: "\u9875\u7801\uFF0C\u4ECE 1 \u5F00\u59CB\uFF0C\u7F3A\u7701 1" }
999
+ },
1000
+ { required: ["contractNo"], description: "\u6309\u5408\u540C\u53F7\u5B9A\u4F4D\u6863\u6848" }
1001
+ ),
1002
+ handler: async (args, env) => {
1003
+ const contractNo = requireText(args.contractNo, "contractNo");
1004
+ const pageNo = positiveInt(args.pageNo, "pageNo", 1);
1005
+ const response = await env.host.request({
1006
+ method: "POST",
1007
+ path: ARCHIVE_LOCATE_PATH,
1008
+ operation: ARCHIVE_LOCATE,
1009
+ body: {
1010
+ htbh: contractNo,
1011
+ datajson: {
1012
+ mainTable: {},
1013
+ pageInfo: { pageNo: String(pageNo) }
1014
+ }
1015
+ }
1016
+ });
1017
+ const datajson = response?.datajson ?? {};
1018
+ const datas = Array.isArray(datajson.datas) ? datajson.datas : [];
1019
+ const rows = datas.map((item) => {
1020
+ const mainTable = item?.mainTable ?? {};
1021
+ return {
1022
+ id: String(mainTable.id ?? "").trim(),
1023
+ title: String(mainTable.folder_title ?? "").trim(),
1024
+ contractNo: String(mainTable.hth ?? contractNo).trim()
1025
+ };
1026
+ });
1027
+ return archiveOaSuccess(
1028
+ ARCHIVE_LOCATE,
1029
+ { rows, matched: rows.length > 0 },
1030
+ { count: rows.length, contractNo, pageNo }
1031
+ );
1032
+ }
1033
+ };
1034
+
1035
+ // src/shortcuts/archive-oa/operations/registry.ts
1036
+ function buildRegistry() {
1037
+ const registry = /* @__PURE__ */ new Map();
1038
+ const definitions = [
1039
+ archiveLocateOperation,
1040
+ weaverContractFieldsOperation,
1041
+ weaverContractListOperation,
1042
+ qysContractListOperation,
1043
+ ...createBorrowCarOperations(WEAVER_BORROW_CAR, WEAVER_ESB_ADD),
1044
+ ...createBorrowCarOperations(QYS_BORROW_CAR, QYS_ESB_ADD),
1045
+ createBorrowStartUrlOperation(WEAVER_BORROW_CAR),
1046
+ createBorrowStartUrlOperation(QYS_BORROW_CAR)
1047
+ ];
1048
+ for (const definition of definitions) {
1049
+ if (registry.has(definition.name)) {
1050
+ throw new Error(`duplicate archive-oa operation: ${definition.name}`);
1051
+ }
1052
+ registry.set(definition.name, definition);
1053
+ }
1054
+ return registry;
1055
+ }
1056
+ var archiveOaOperationRegistry = buildRegistry();
1057
+ function archiveOaOperationDefinitions() {
1058
+ return [...archiveOaOperationRegistry.values()];
1059
+ }
1060
+ function getArchiveOaOperation(operation) {
1061
+ const definition = archiveOaOperationRegistry.get(operation);
1062
+ if (!definition) {
1063
+ throw archiveOaValidationError("operation_unknown", `archive-oa \u4E0D\u652F\u6301\u64CD\u4F5C\uFF1A${operation}`);
1064
+ }
1065
+ return definition;
1066
+ }
1067
+
1068
+ // src/shortcuts/archive-oa/manifest.ts
1069
+ var archiveOaOperations = archiveOaOperationDefinitions().map((definition) => ({
1070
+ name: definition.name,
1071
+ resource: definition.resource,
1072
+ summary: definition.summary,
1073
+ ...definition.capability ? { capability: definition.capability } : {},
1074
+ risk: definition.risk,
1075
+ ...definition.requiresConfirmation ? { requiresConfirmation: true } : {},
1076
+ inputSchema: definition.inputSchema
1077
+ }));
1078
+ var archiveOaManifest = {
1079
+ schemaVersion: 1,
1080
+ name: "archive-oa",
1081
+ title: "\u6CDB\u5FAEE10\u6863\u6848\u5B9A\u4F4D\u4E0EOA\u5546\u52A1\u5408\u540C\u501F\u9605",
1082
+ version: "0.1.0",
1083
+ host: "e10-archive-oa",
1084
+ status: "builtin",
1085
+ sourceSkill: "weaver-e10-archive-oa",
1086
+ capabilities: ["archiveLocate", "contractSearch", "borrowCar"],
1087
+ auth: {
1088
+ required: "e10-session",
1089
+ note: "\u6240\u6709\u64CD\u4F5C\u90FD\u8981\u6C42\u5DF2\u767B\u5F55 E10\uFF0C\u5177\u4F53\u767B\u5F55\u65B9\u5F0F\u7531\u8C03\u7528\u65B9\u6839\u636E\u5F53\u524D\u5BBF\u4E3B\u73AF\u5883\u9009\u62E9\u3002\u53D1\u8D77\u501F\u9605\u4E0D\u5728 CLI \u80FD\u529B\u8303\u56F4\u5185\uFF0C\u7531\u7528\u6237\u5728\u6D4F\u89C8\u5668\u767B\u5F55\u540E\u4E8E\u754C\u9762\u81EA\u5DF1\u5B8C\u6210\u3002"
1090
+ },
1091
+ rules: [
1092
+ "\u5199\u64CD\u4F5C\uFF08*.apply\uFF09\u5FC5\u987B\u5148\u6267\u884C\u540C\u540D\u7684 prepare \u62FF\u5230 continuation\uFF0C\u518D\u5E26 confirm=true \u6267\u884C apply\uFF1BCLI \u7528 --yes \u8868\u793A\u786E\u8BA4\u3002",
1093
+ "\u6CDB\u5FAE\u5546\u52A1\u5408\u540C\u4E0E\u5951\u7EA6\u9501\u534F\u4F5C\u91C7\u7EB3\uFF08\u6848\u4F8B\uFF09\u662F\u4E24\u5957\u72EC\u7ACB\u5E94\u7528\uFF1Apassid / listId / esbActionIds / objId / cusMenuId \u5404\u4E0D\u76F8\u540C\uFF0C\u7981\u6B62\u4EA4\u53C9\u6DF7\u7528\u3002",
1094
+ "\u52A0\u5165\u501F\u9605\u8F66\u6BCF\u6B21\u6700\u591A 6 \u6761\u3002",
1095
+ "\u53D1\u8D77\u501F\u9605\u901A\u8FC7 archive-oa.borrow.start.url\uFF08\u5951\u7EA6\u9501\u4E3A archive-oa.qys.borrow.start.url\uFF09\u751F\u6210\u6D41\u7A0B\u521B\u5EFA\u9875 URL\uFF08/sp/workflow/flowpage/fullCreate/<flowId>?fb=<fb>&data=<JSON>\uFF09\uFF1A\u4E24\u4E2A operation \u5747\u53EA\u8BFB\u3001\u4E0D\u5199\u6570\u636E\u3001\u4E0D\u89E6\u53D1\u6D41\u7A0B\u3001\u4E0D\u9700\u8981\u4EFB\u4F55\u540E\u53F0\u5E94\u7528\u51ED\u636E\uFF1Bfb \u5FC5\u987B\u53D6\u501F\u9605\u8F66\u8BB0\u5F55\u81EA\u8EAB\u7684\u503C\uFF08\u6CDB\u5FAE 0\u3001\u5951\u7EA6\u9501 1\uFF09\uFF0C\u7981\u6B62\u624B\u5DE5\u6307\u5B9A\uFF1BURL \u53EF\u5728\u6D4F\u89C8\u5668\u76F4\u63A5\u6253\u5F00\uFF0C\u7531\u7528\u6237\u5B8C\u6210\u586B\u5199\u4E0E\u63D0\u4EA4\u3002",
1096
+ "\u5408\u540C\u884C\u7684\u5185\u90E8 ID\uFF08data[*].id\uFF09\u53EA\u7528\u4E8E\u52A0\u5165\u501F\u9605\u8F66\uFF0C\u4E0D\u5C55\u793A\u7ED9\u6700\u7EC8\u7528\u6237\u3002"
1097
+ ],
1098
+ operations: archiveOaOperations,
1099
+ withheldOperations: [
1100
+ {
1101
+ name: "archive-oa.archive.usage-log",
1102
+ reason: "\u6863\u6848\u64CD\u4F5C/\u5229\u7528\u8BB0\u5F55\uFF08\u501F\u9605\u3001\u4E0B\u8F7D\u3001\u6D4F\u89C8\uFF09\u63A5\u53E3\u6E90\u8D44\u6599\u5C1A\u672A\u6536\u5F55\uFF0C\u4E1A\u52A1\u65B9\u63D0\u4F9B\u63A5\u53E3\u5951\u7EA6\u540E\u518D\u767B\u8BB0\u3002"
1103
+ },
1104
+ {
1105
+ name: "archive-oa.qys.contract.fields",
1106
+ reason: "\u5951\u7EA6\u9501\u534F\u4F5C\u91C7\u7EB3\u7684\u641C\u7D22\u5B57\u6BB5\u914D\u7F6E\u63A5\u53E3\u6E90\u8D44\u6599\u672A\u6536\u5F55\uFF1B\u6784\u9020\u641C\u7D22\u6761\u4EF6\u65F6\u53EF\u53C2\u8003\u6CDB\u5FAE showFilters \u7684\u5B57\u6BB5\u89C4\u5219\u3002"
1107
+ },
1108
+ {
1109
+ name: "archive-oa.borrow.start.prepare",
1110
+ reason: "\u53D1\u8D77\u501F\u9605\u6539\u7531\u7528\u6237\u5728\u6D4F\u89C8\u5668\u767B\u5F55\u540E\u4E8E\u501F\u9605\u8F66\u754C\u9762\u81EA\u5DF1\u5B8C\u6210\uFF0CCLI \u4E0D\u63D0\u4F9B OpenESB \u89E6\u53D1\u80FD\u529B\u3002"
1111
+ },
1112
+ {
1113
+ name: "archive-oa.borrow.start.apply",
1114
+ reason: "\u540C prepare\uFF1A\u53D1\u8D77\u501F\u9605\u4E0D\u5728 CLI operation \u8303\u56F4\u5185\uFF0C\u4E0D\u5411\u7528\u6237\u7D22\u8981\u540E\u53F0\u5E94\u7528\u51ED\u636E\u3002"
1115
+ },
1116
+ {
1117
+ name: "archive-oa.qys.borrow.start.prepare",
1118
+ reason: "\u5951\u7EA6\u9501\u53D1\u8D77\u501F\u9605\u540C\u6837\u7531\u7528\u6237\u5728\u6D4F\u89C8\u5668\u754C\u9762\u81EA\u5DF1\u5B8C\u6210\uFF0CCLI \u4E0D\u4EE3\u4E3A\u89E6\u53D1\u3002"
1119
+ },
1120
+ {
1121
+ name: "archive-oa.qys.borrow.start.apply",
1122
+ reason: "\u540C prepare\uFF1A\u5951\u7EA6\u9501\u53D1\u8D77\u501F\u9605\u4E0D\u5728 CLI operation \u8303\u56F4\u5185\u3002"
1123
+ }
1124
+ ]
1125
+ };
1126
+
1127
+ // src/shortcuts/archive-oa/operations.ts
1128
+ async function executeArchiveOaOperation(operation, rawInput, env) {
1129
+ const definition = getArchiveOaOperation(operation);
1130
+ const input = asObject(rawInput);
1131
+ assertNoForbiddenKeys(input);
1132
+ return definition.handler(input, { ctx: env.ctx, host: env.host, continuation: env.continuation });
1133
+ }
1134
+
1135
+ // src/shortcuts/archive-oa/index.ts
1136
+ var SOURCES = ["weaver", "qys"];
1137
+ function asOptions(value) {
1138
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
1139
+ }
1140
+ async function readStdin() {
1141
+ const chunks = [];
1142
+ for await (const chunk of process.stdin) {
1143
+ chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
1144
+ }
1145
+ return Buffer.concat(chunks).toString("utf8");
1146
+ }
1147
+ async function archiveOaInputFrom(options, extra = {}) {
1148
+ const opts = asOptions(options);
1149
+ let input = {};
1150
+ if (opts.input && opts.inputJson) {
1151
+ throw archiveOaValidationError("input_conflict", "\u4E0D\u80FD\u540C\u65F6\u4F20 --input \u548C --input-json");
1152
+ }
1153
+ if (opts.inputJson) {
1154
+ input = parseJsonInput(String(opts.inputJson), "--input-json");
1155
+ }
1156
+ if (opts.input) {
1157
+ let raw;
1158
+ try {
1159
+ raw = opts.input === "-" ? await readStdin() : await readFile2(String(opts.input), "utf8");
1160
+ } catch {
1161
+ throw archiveOaValidationError("input_unreadable", `\u65E0\u6CD5\u8BFB\u53D6 --input\uFF1A${String(opts.input)}`);
1162
+ }
1163
+ input = parseJsonInput(raw, "--input");
1164
+ }
1165
+ return {
1166
+ ...input,
1167
+ ...Object.fromEntries(Object.entries(extra).filter(([, value]) => value !== void 0 && value !== ""))
1168
+ };
1169
+ }
1170
+ function parseJsonInput(raw, label) {
1171
+ try {
1172
+ const parsed = JSON.parse(raw.replace(/^\uFEFF/u, ""));
1173
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
1174
+ throw new Error("input must be an object");
1175
+ }
1176
+ return parsed;
1177
+ } catch {
1178
+ throw archiveOaValidationError("input_invalid", `${label} \u4E0D\u662F\u5408\u6CD5 JSON \u5BF9\u8C61`);
1179
+ }
1180
+ }
1181
+ function withJsonInputOptions(command) {
1182
+ command.option("--input <path>", "JSON input file, or - for stdin").option("--input-json <json>", "inline JSON input object");
1183
+ return command;
1184
+ }
1185
+ function intOption(value) {
1186
+ if (value === void 0 || value === null || value === "") return void 0;
1187
+ const parsed = Number(value);
1188
+ return Number.isInteger(parsed) ? parsed : void 0;
1189
+ }
1190
+ function stringOption(value) {
1191
+ if (value === void 0 || value === null || value === "") return void 0;
1192
+ return String(value);
1193
+ }
1194
+ function stringListOption(value) {
1195
+ const text = stringOption(value);
1196
+ if (text === void 0) return void 0;
1197
+ return text.split(",").map((item) => item.trim()).filter((item) => item.length > 0);
1198
+ }
1199
+ function resolveSource(value) {
1200
+ const text = String(stringOption(value) ?? "weaver").toLowerCase();
1201
+ if (!SOURCES.includes(text)) {
1202
+ throw archiveOaValidationError("source_invalid", "source \u5FC5\u987B\u662F weaver \u6216 qys");
1203
+ }
1204
+ return text;
1205
+ }
1206
+ function borrowCarOperation(action, source) {
1207
+ return source === "qys" ? `archive-oa.qys.borrow-car.${action}` : `archive-oa.borrow-car.${action}`;
1208
+ }
1209
+ function successEnvelope(result) {
1210
+ return {
1211
+ schemaVersion: 1,
1212
+ ok: true,
1213
+ operation: result.action,
1214
+ data: result.data,
1215
+ ...result.meta ? { meta: result.meta } : {},
1216
+ warnings: []
1217
+ };
1218
+ }
1219
+ function failureEnvelope(error) {
1220
+ const structured = error;
1221
+ return {
1222
+ schemaVersion: 1,
1223
+ ok: false,
1224
+ ...structured?.partialData === void 0 ? {} : { data: structured.partialData },
1225
+ error: toErrorEnvelope(error)
1226
+ };
1227
+ }
1228
+ async function executeAndPrint(ctx, operation, input) {
1229
+ try {
1230
+ const result = await executeArchiveOaOperation(operation, input, {
1231
+ ctx,
1232
+ host: createArchiveOaHost(ctx),
1233
+ continuation: createArchiveOaContinuationSigner(ctx)
1234
+ });
1235
+ ctx.output.write(successEnvelope(result), { json: true });
1236
+ } catch (error) {
1237
+ console.error(JSON.stringify(failureEnvelope(error), null, 2));
1238
+ process.exitCode = isCliError(error) ? error.exitCode : 1 /* GeneralError */;
1239
+ }
1240
+ }
1241
+ var archiveOaShortcut = {
1242
+ name: "archive-oa",
1243
+ description: "E10 \u6863\u6848\u5B9A\u4F4D\u4E0E OA \u5546\u52A1\u5408\u540C\u501F\u9605 CLI",
1244
+ category: "shortcut",
1245
+ register({ program, action }) {
1246
+ const command = program.command("archive-oa").description("E10 \u6863\u6848\u5B9A\u4F4D\u4E0E OA \u5546\u52A1\u5408\u540C\u501F\u9605");
1247
+ command.command("schema").description("Print archive-oa operation manifest for agents").action(action((ctx) => {
1248
+ ctx.output.write(archiveOaManifest, { json: true });
1249
+ }));
1250
+ withJsonInputOptions(command.command("run").description("Run an archive-oa operation with JSON input").argument("<operation>", "operation name, e.g. archive-oa.contract.list")).action(action(async (ctx, operation, options) => {
1251
+ await executeAndPrint(ctx, String(operation), await archiveOaInputFrom(options));
1252
+ }));
1253
+ withJsonInputOptions(command.command("locate").description("Locate archive records by contract number").option("--contract-no <no>", "contract number (htbh)").option("--page-no <page>", "page number, starts from 1")).action(action(async (ctx, options) => {
1254
+ const opts = asOptions(options);
1255
+ await executeAndPrint(ctx, "archive-oa.archive.locate", await archiveOaInputFrom(options, {
1256
+ contractNo: stringOption(opts.contractNo),
1257
+ pageNo: intOption(opts.pageNo)
1258
+ }));
1259
+ }));
1260
+ const contract = command.command("contract").description("Business contract query commands");
1261
+ withJsonInputOptions(contract.command("list").description("Query Weaver business contracts").option("--page-no <page>", "page number, starts from 1")).action(action(async (ctx, options) => {
1262
+ const opts = asOptions(options);
1263
+ await executeAndPrint(ctx, "archive-oa.contract.list", await archiveOaInputFrom(options, {
1264
+ pageNo: intOption(opts.pageNo)
1265
+ }));
1266
+ }));
1267
+ contract.command("fields").description("List searchable fields of Weaver business contracts").action(action(async (ctx) => {
1268
+ await executeAndPrint(ctx, "archive-oa.contract.fields", {});
1269
+ }));
1270
+ const qys = command.command("qys").description("Qiyuesuo (case) contract commands");
1271
+ withJsonInputOptions(qys.command("list").description("Query Qiyuesuo collaboration contracts (default archived only)").option("--page-no <page>", "page number, starts from 1")).action(action(async (ctx, options) => {
1272
+ const opts = asOptions(options);
1273
+ await executeAndPrint(ctx, "archive-oa.qys.contract.list", await archiveOaInputFrom(options, {
1274
+ pageNo: intOption(opts.pageNo)
1275
+ }));
1276
+ }));
1277
+ const borrowCar = command.command("borrow-car").description("Borrow car commands");
1278
+ withJsonInputOptions(borrowCar.command("list").description("List contract borrow car entries").option("--source <source>", "weaver or qys, default weaver").option("--page-no <page>", "page number, starts from 1")).action(action(async (ctx, options) => {
1279
+ const opts = asOptions(options);
1280
+ const source = resolveSource(opts.source);
1281
+ await executeAndPrint(ctx, borrowCarOperation("list", source), await archiveOaInputFrom(options, {
1282
+ pageNo: intOption(opts.pageNo)
1283
+ }));
1284
+ }));
1285
+ withJsonInputOptions(borrowCar.command("add-prepare").description("Prepare adding contracts to borrow car (max 6)").option("--source <source>", "weaver or qys, default weaver").option("--data-ids <ids>", "comma separated contract row ids")).action(action(async (ctx, options) => {
1286
+ const opts = asOptions(options);
1287
+ const source = resolveSource(opts.source);
1288
+ await executeAndPrint(ctx, borrowCarOperation("add.prepare", source), await archiveOaInputFrom(options, {
1289
+ dataIds: stringListOption(opts.dataIds)
1290
+ }));
1291
+ }));
1292
+ withJsonInputOptions(borrowCar.command("add-apply").description("Apply adding contracts to borrow car").option("--continuation <token>", "continuation token from prepare").option("--source <source>", "weaver or qys, default weaver").option("--yes", "confirm the write operation")).action(action(async (ctx, options) => {
1293
+ const opts = asOptions(options);
1294
+ const source = resolveSource(opts.source);
1295
+ await executeAndPrint(ctx, borrowCarOperation("add.apply", source), await archiveOaInputFrom(options, {
1296
+ continuation: stringOption(opts.continuation),
1297
+ confirm: opts.yes === true ? true : void 0
1298
+ }));
1299
+ }));
1300
+ const borrow = command.command("borrow").description("Borrow workflow commands");
1301
+ withJsonInputOptions(borrow.command("start-url").description("Build the borrow workflow page URL from borrow car entries").option("--source <source>", "weaver or qys, default weaver").option("--contract-nos <nos>", "comma separated contract numbers from borrow car, max 6")).action(action(async (ctx, options) => {
1302
+ const opts = asOptions(options);
1303
+ const source = resolveSource(opts.source);
1304
+ await executeAndPrint(
1305
+ ctx,
1306
+ source === "qys" ? "archive-oa.qys.borrow.start.url" : "archive-oa.borrow.start.url",
1307
+ await archiveOaInputFrom(options, {
1308
+ contractNos: stringListOption(opts.contractNos)
1309
+ })
1310
+ );
1311
+ }));
1312
+ }
1313
+ };
1314
+ export {
1315
+ archiveOaInputFrom,
1316
+ archiveOaShortcut
1317
+ };