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.
- package/dist/chunks/archive-U766FTFH.js +2537 -0
- package/dist/chunks/archive-oa-DMWEKX3L.js +1317 -0
- package/dist/chunks/asset-TCR7VDEV.js +2109 -0
- package/dist/chunks/attachment-content-AQNX5N3S.js +23 -0
- package/dist/chunks/blog-EVZWGDVM.js +2157 -0
- package/dist/chunks/caizhilian-JOWS6SL5.js +10087 -0
- package/dist/chunks/calendar-5WNCV66Q.js +1195 -0
- package/dist/chunks/chunk-2DUV44UX.js +15606 -0
- package/dist/chunks/chunk-324YPTC2.js +1607 -0
- package/dist/chunks/chunk-65QMVWHS.js +231 -0
- package/dist/chunks/chunk-6V7ZLF34.js +387 -0
- package/dist/chunks/chunk-AC7KJWC5.js +358 -0
- package/dist/chunks/chunk-AJ62BGAW.js +29 -0
- package/dist/chunks/chunk-BUSC6UAE.js +43 -0
- package/dist/chunks/chunk-CVZ2JOSW.js +62 -0
- package/dist/chunks/chunk-D4LTJSJD.js +477 -0
- package/dist/chunks/chunk-EG6ZU444.js +654 -0
- package/dist/chunks/chunk-EZALDOQH.js +383 -0
- package/dist/chunks/chunk-FMPJJYYI.js +106 -0
- package/dist/chunks/chunk-G2JSIUWF.js +769 -0
- package/dist/chunks/chunk-GCG2NMWR.js +703 -0
- package/dist/chunks/chunk-GPMFD4RD.js +75 -0
- package/dist/chunks/chunk-H3WDBYJW.js +508 -0
- package/dist/chunks/chunk-H6XSTSLM.js +2357 -0
- package/dist/chunks/chunk-J7RJTZSV.js +5556 -0
- package/dist/chunks/chunk-LUSPKZKY.js +53 -0
- package/dist/chunks/chunk-NIAJ5ZCG.js +73 -0
- package/dist/chunks/chunk-NOODWMCL.js +584 -0
- package/dist/chunks/chunk-OOUTBLZ4.js +51 -0
- package/dist/chunks/chunk-P26ZWSKU.js +73 -0
- package/dist/chunks/chunk-QWY6PGL6.js +3472 -0
- package/dist/chunks/chunk-R2IJAK7T.js +464 -0
- package/dist/chunks/chunk-R7O5PUWO.js +205 -0
- package/dist/chunks/chunk-RCGYCOMG.js +6962 -0
- package/dist/chunks/chunk-VZTXRG6X.js +403 -0
- package/dist/chunks/chunk-WHD4XMRP.js +161 -0
- package/dist/chunks/chunk-YLCYX7LE.js +371 -0
- package/dist/chunks/chunk-ZEDWSH32.js +68 -0
- package/dist/chunks/continuation-2CKSBLA6.js +11 -0
- package/dist/chunks/continuation-HZIZRZBX.js +13 -0
- package/dist/chunks/continuation-NLECEJPX.js +11 -0
- package/dist/chunks/ebuilder-form-NJ4YK6CC.js +2276 -0
- package/dist/chunks/ehr-MMYN36VA.js +5241 -0
- package/dist/chunks/employee-SAK2QYXX.js +11 -0
- package/dist/chunks/esb-HIWHOU7Q.js +141 -0
- package/dist/chunks/fna-KBACQTA5.js +1444 -0
- package/dist/chunks/host-3OHS5QUX.js +21 -0
- package/dist/chunks/host-IG6KEH5Q.js +19 -0
- package/dist/chunks/host-KQL5N4HO.js +23 -0
- package/dist/chunks/host-LLSZQCWR.js +17 -0
- package/dist/chunks/hrm-LYEC67ZQ.js +244 -0
- package/dist/chunks/im-RN2UKAEU.js +252 -0
- package/dist/chunks/invoice-EEPHLAF6.js +5179 -0
- package/dist/chunks/jiuchuanhui-WVVZYSJE.js +1940 -0
- package/dist/chunks/lazy-dispatch-MDOFFL2S.js +28 -0
- package/dist/chunks/mail-LNQLTF6L.js +2695 -0
- package/dist/chunks/meeting-XSD3BDVQ.js +504 -0
- package/dist/chunks/msg-parse-4GSQ2WTO.js +41 -0
- package/dist/chunks/okr-TMWTIU2K.js +2482 -0
- package/dist/chunks/plan-A2FSFA7T.js +2025 -0
- package/dist/chunks/project-T26QLBQF.js +1361 -0
- package/dist/chunks/registry-2VLUAESA.js +14 -0
- package/dist/chunks/registry-JCFEYXOE.js +18 -0
- package/dist/chunks/registry-NYPYMZXG.js +16 -0
- package/dist/chunks/registry-Q7OQJ3SU.js +19 -0
- package/dist/chunks/registry-ZJMJVWFA.js +19 -0
- package/dist/chunks/room-recommend-UR4ZDZS6.js +20 -0
- package/dist/chunks/schedule-5L2PM4M6.js +24 -0
- package/dist/chunks/state-Y2XBP6YE.js +15 -0
- package/dist/chunks/workflow-TR6PG2SL.js +245 -0
- package/dist/cmd/argv.js +45 -0
- package/dist/cmd/docs/index.js +3 -3
- package/dist/cmd/lazy-dispatch.js +20 -0
- package/dist/cmd/root.js +2 -4
- package/dist/cmd/setup/index.js +2 -2
- package/dist/cmd/skills/index.js +2 -2
- package/dist/core/package-paths.js +47 -0
- package/dist/index.js +163 -7
- package/dist/internal/e10/auth/xiaoe.js +3 -3
- package/dist/internal/e10/request-runtime.js +18 -62
- package/dist/internal/skills/detector.js +2 -2
- package/dist/shortcuts/contract/data/performance-catalog.js +1306 -0
- package/dist/shortcuts/contract/host.js +91 -35
- package/dist/shortcuts/contract/index.js +213 -0
- package/dist/shortcuts/contract/manifest.js +928 -0
- package/dist/shortcuts/contract/ooxml/docx.js +295 -0
- package/dist/shortcuts/contract/ooxml/xlsx.js +221 -0
- package/dist/shortcuts/contract/ooxml/zip.js +158 -0
- package/dist/shortcuts/contract/operations/assistant.js +1156 -0
- package/dist/shortcuts/contract/operations/clause-library.js +522 -0
- package/dist/shortcuts/contract/operations/compare.js +193 -0
- package/dist/shortcuts/contract/operations/credit-page.js +34 -0
- package/dist/shortcuts/contract/operations/flow.js +98 -0
- package/dist/shortcuts/contract/operations/page.js +66 -0
- package/dist/shortcuts/contract/operations/performance.js +733 -0
- package/dist/shortcuts/contract/operations/quote.js +557 -0
- package/dist/shortcuts/contract/operations/recommend.js +78 -0
- package/dist/shortcuts/contract/operations/registry.js +18 -0
- package/dist/shortcuts/contract/operations/review.js +83 -0
- package/dist/shortcuts/contract/operations/shared.js +37 -0
- package/dist/shortcuts/contract/operations/upload.js +108 -0
- package/dist/shortcuts/contract/operations/write.js +3 -2
- package/dist/shortcuts/index.js +140 -40
- package/dist/shortcuts/invoice/manifest.js +34 -11
- package/dist/shortcuts/invoice/operations/reim-auto.js +9 -0
- package/dist/shortcuts/invoice/operations/reim.js +81 -5
- package/dist/shortcuts/invoice/operations/shared.js +12 -5
- package/dist/shortcuts/meeting/host.js +45 -3
- package/dist/shortcuts/meeting/invitation/docx.js +442 -0
- package/dist/shortcuts/meeting/operations/attachment-content.js +418 -0
- package/dist/shortcuts/meeting/operations/attachment.js +442 -0
- package/dist/shortcuts/meeting/operations/eb/cache.js +57 -0
- package/dist/shortcuts/meeting/operations/eb/catalog.js +343 -28
- package/dist/shortcuts/meeting/operations/eb/conflict.js +372 -11
- package/dist/shortcuts/meeting/operations/eb/create-flow.js +710 -0
- package/dist/shortcuts/meeting/operations/eb/decision.js +47 -1
- package/dist/shortcuts/meeting/operations/eb/factory.js +129 -11
- package/dist/shortcuts/meeting/operations/eb/index.js +122 -2
- package/dist/shortcuts/meeting/operations/eb/room-recommend.js +378 -0
- package/dist/shortcuts/meeting/operations/eb/room-summary.js +84 -0
- package/dist/shortcuts/meeting/operations/eb/schedule.js +450 -0
- package/dist/shortcuts/meeting/operations/from-group-chat.js +576 -0
- package/dist/shortcuts/meeting/operations/invitation.js +458 -0
- package/dist/shortcuts/meeting/operations/minute-content.js +266 -0
- package/dist/shortcuts/meeting/operations/pipeline.js +489 -0
- package/dist/shortcuts/meeting/operations/qrcode.js +131 -0
- package/dist/shortcuts/meeting/operations/receipts.js +1 -1
- package/dist/shortcuts/meeting/operations/registry.js +18 -0
- package/dist/shortcuts/meeting/operations/summary.js +276 -0
- package/dist/shortcuts/meeting/operations/task-notify.js +325 -0
- package/dist/shortcuts/meeting/operations.js +42 -1
- package/dist/shortcuts/meeting/qr/encoder.js +427 -0
- package/dist/shortcuts/meeting/qr/render.js +103 -0
- package/dist/shortcuts/workflow/operations/form.js +17 -5
- package/docs/contract.md +39 -4
- package/docs/invoice.md +5 -5
- package/package.json +3 -2
- package/scripts/bundle.mjs +63 -0
- package/skill-template/business-info.json +25 -4
- package/skill-template/domains/jinchengda.md +16 -3
- package/skill-template/domains/yepiaotong.md +1 -1
- package/skills/weaver-e10-jinchengda/SKILL.md +111 -31
- package/skills/weaver-e10-jinchengda/references/contract-agent-entry.md +7 -13
- package/skills/weaver-e10-jinchengda/references/contract-ai-assistant.md +150 -0
- package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +87 -0
- package/skills/weaver-e10-jinchengda/references/contract-clause-library-crud.md +111 -0
- package/skills/weaver-e10-jinchengda/references/contract-clause-recommender.md +0 -15
- package/skills/weaver-e10-jinchengda/references/contract-clause-reference-save.md +0 -13
- package/skills/weaver-e10-jinchengda/references/contract-credit-page.md +50 -0
- package/skills/weaver-e10-jinchengda/references/contract-disabled-capabilities.md +4 -2
- package/skills/weaver-e10-jinchengda/references/contract-doc-compare.md +74 -0
- package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +84 -0
- package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +29 -0
- package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +28 -0
- package/skills/weaver-e10-jinchengda/references/contract-request-status.md +2 -21
- package/skills/weaver-e10-jinchengda/references/contract-request-write.md +0 -24
- package/skills/weaver-e10-jinchengda/references/contract-signing-subjects.md +0 -15
- package/skills/weaver-e10-jinchengda/references/contract-subject-create.md +0 -17
- package/skills/weaver-e10-jinchengda/references/contract-template-recommend.md +70 -0
- package/skills/weaver-e10-jinchengda/references/contract-template-selector.md +0 -15
- package/skills/weaver-e10-jinchengda/references/contract-workflow-discovery.md +0 -15
- package/skills/weaver-e10-jinchengda/references/source-manifest.json +1168 -152
- package/skills/weaver-e10-meeting/SKILL.md +493 -17
- package/skills/weaver-e10-meeting/references/meeting-change.md +4 -4
- package/skills/weaver-e10-meeting/references/meeting-create.md +6 -6
- package/skills/weaver-e10-meeting/references/meeting-eb.md +503 -27
- package/skills/weaver-e10-meeting/references/meeting-invitation.md +113 -0
- package/skills/weaver-e10-meeting/references/meeting-lifecycle.md +6 -6
- package/skills/weaver-e10-meeting/references/meeting-minute-file.md +425 -0
- package/skills/weaver-e10-meeting/references/meeting-queries.md +4 -4
- package/skills/weaver-e10-meeting/references/meeting-receipts-signs.md +15 -15
- package/skills/weaver-e10-meeting/references/meeting-verification.md +19 -11
- package/skills/weaver-e10-meeting.zip +0 -0
- package/skills/weaver-e10-yepiaotong/SKILL.md +9 -5
- package/skills/weaver-e10-yepiaotong/references/invoice-enterprise-list.md +1 -1
- package/skills/weaver-e10-yepiaotong/references/invoice-personal-list.md +6 -5
- package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +14 -11
- package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +97 -56
- package/skills/weaver-e10-yepiaotong/references/reim-examples.md +84 -60
- package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +142 -105
- package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +53 -194
- package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +7 -7
- package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +164 -72
- package/skills/weaver-e10-yepiaotong/references/source-manifest.json +6 -0
- package/templates/meeting/invitation.docx +0 -0
|
@@ -0,0 +1,2537 @@
|
|
|
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/index.ts
|
|
20
|
+
import { readFile as readFile3, writeFile as writeFile3 } from "node:fs/promises";
|
|
21
|
+
import { resolve as resolve4 } from "node:path";
|
|
22
|
+
|
|
23
|
+
// src/shortcuts/archive/render/search-view.ts
|
|
24
|
+
var EBDATA_PREFIX = "EBDATA_OBJID";
|
|
25
|
+
function parseSearchFormId(module) {
|
|
26
|
+
const text = typeof module === "string" ? module : "";
|
|
27
|
+
if (!text.startsWith(EBDATA_PREFIX)) return void 0;
|
|
28
|
+
const id = text.slice(EBDATA_PREFIX.length);
|
|
29
|
+
return /^\d+$/.test(id) ? id : void 0;
|
|
30
|
+
}
|
|
31
|
+
function stripHtmlTags(value) {
|
|
32
|
+
return String(value ?? "").replace(/<[^>]+>/g, "").replace(/ /g, " ").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/[ \t]+/g, " ").trim();
|
|
33
|
+
}
|
|
34
|
+
function textOf(field) {
|
|
35
|
+
const value = field?.value;
|
|
36
|
+
return value === void 0 || value === null ? "" : String(value).trim();
|
|
37
|
+
}
|
|
38
|
+
function keyOf(field) {
|
|
39
|
+
return String(field.key ?? field.originalKey ?? "");
|
|
40
|
+
}
|
|
41
|
+
function isHiddenMetaField(key, showName) {
|
|
42
|
+
if (/^(电子原文数|实体|实体数|原文数)$/.test(showName)) return true;
|
|
43
|
+
return /^elec/i.test(key) || /entity/i.test(key) || /originalcount/i.test(key);
|
|
44
|
+
}
|
|
45
|
+
function toDateInfo(fields) {
|
|
46
|
+
for (const field of fields) {
|
|
47
|
+
const showName = String(field.showName ?? "");
|
|
48
|
+
const value = textOf(field);
|
|
49
|
+
if (!value) continue;
|
|
50
|
+
if (/日期|时间|立卷|形成|创建/.test(showName) && /^\d{4}-\d{2}-\d{2}/.test(value)) {
|
|
51
|
+
return { label: showName, value };
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return { label: "", value: "" };
|
|
55
|
+
}
|
|
56
|
+
function toSearchRowView(input) {
|
|
57
|
+
const headList = Array.isArray(input.headList) ? input.headList : [];
|
|
58
|
+
const footList = Array.isArray(input.footList) ? input.footList : [];
|
|
59
|
+
const fields = [...headList, ...footList];
|
|
60
|
+
let title = "";
|
|
61
|
+
let level = "";
|
|
62
|
+
let fonds = "";
|
|
63
|
+
let category = "";
|
|
64
|
+
for (const field of fields) {
|
|
65
|
+
const key = keyOf(field);
|
|
66
|
+
const showName = String(field.showName ?? "");
|
|
67
|
+
const value = textOf(field);
|
|
68
|
+
if (!value || isHiddenMetaField(key, showName)) continue;
|
|
69
|
+
if (!title && (key === "folder_title" || showName === "\u9898\u540D" || showName === "\u6807\u9898")) {
|
|
70
|
+
title = value;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (!level && (key === "arc_level" || showName === "\u7C7B\u578B" || showName === "\u5C42\u7EA7")) {
|
|
74
|
+
level = value;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (!fonds && (showName === "\u5168\u5B97\u540D\u79F0" || key === "fonds_name")) {
|
|
78
|
+
fonds = value;
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
if (!category && (showName === "\u5206\u7C7B" || key === "category_code")) {
|
|
82
|
+
category = value;
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (!fonds) {
|
|
87
|
+
for (const field of fields) {
|
|
88
|
+
const showName = String(field.showName ?? "");
|
|
89
|
+
if (showName.includes("\u5168\u5B97")) {
|
|
90
|
+
fonds = textOf(field);
|
|
91
|
+
if (fonds) break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (!title) {
|
|
96
|
+
const rowTitle = String(input.title ?? "").trim();
|
|
97
|
+
if (rowTitle) title = rowTitle;
|
|
98
|
+
}
|
|
99
|
+
const id = String(input.id ?? "");
|
|
100
|
+
let formId = input.formId === void 0 || input.formId === null ? "" : String(input.formId).trim();
|
|
101
|
+
if (!/^\d+$/.test(formId)) formId = parseSearchFormId(input.module) ?? "";
|
|
102
|
+
const { label: dateLabel, value: dateValue } = toDateInfo(fields);
|
|
103
|
+
return {
|
|
104
|
+
id,
|
|
105
|
+
formId,
|
|
106
|
+
title,
|
|
107
|
+
level,
|
|
108
|
+
highlight: stripHtmlTags(input.highLightContent ?? input.content ?? ""),
|
|
109
|
+
fonds,
|
|
110
|
+
category,
|
|
111
|
+
dateLabel,
|
|
112
|
+
dateValue,
|
|
113
|
+
viewPath: id && formId ? `/sp/custom/archive/archiveView?arcId=${id}&arcFormId=${formId}` : ""
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function withBaseUrl(view, baseUrl) {
|
|
117
|
+
const normalized = baseUrl.trim().replace(/\/+$/, "");
|
|
118
|
+
return normalized && view.viewPath ? { ...view, viewUrl: `${normalized}${view.viewPath}` } : view;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// src/shortcuts/archive/render/search-format.ts
|
|
122
|
+
function escapeHtml(value) {
|
|
123
|
+
return String(value).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
124
|
+
}
|
|
125
|
+
function hasLink(view) {
|
|
126
|
+
return Boolean(view.id && view.formId);
|
|
127
|
+
}
|
|
128
|
+
function describeDate(view) {
|
|
129
|
+
return view.dateLabel && view.dateValue ? `${view.dateLabel}\uFF1A${view.dateValue}` : "";
|
|
130
|
+
}
|
|
131
|
+
function textMetaItems(view) {
|
|
132
|
+
const parts = [];
|
|
133
|
+
parts.push(`\u5168\u5B97\uFF1A${view.fonds || "-"}`);
|
|
134
|
+
parts.push(`\u5206\u7C7B\uFF1A${view.category || "-"}`);
|
|
135
|
+
const datePart = describeDate(view);
|
|
136
|
+
if (datePart) parts.push(datePart);
|
|
137
|
+
return parts;
|
|
138
|
+
}
|
|
139
|
+
function textTitleLine(index, view) {
|
|
140
|
+
return `${index}. \u3010${view.level || "\u672A\u5206\u7C7B"}\u3011 ${view.title || "(\u65E0\u9898\u540D)"}`;
|
|
141
|
+
}
|
|
142
|
+
function textMetaLine(view) {
|
|
143
|
+
return textMetaItems(view).join(" ");
|
|
144
|
+
}
|
|
145
|
+
function pageLabel(meta) {
|
|
146
|
+
if (!meta) return "";
|
|
147
|
+
const pageNo = Number(meta.pageNo);
|
|
148
|
+
const totalPage = Number(meta.totalPage);
|
|
149
|
+
const bits = [];
|
|
150
|
+
if (meta.total !== void 0) bits.push(`\u547D\u4E2D ${meta.total} \u6761`);
|
|
151
|
+
if (!Number.isNaN(pageNo)) bits.push(`\u7B2C ${pageNo + 1} \u9875`);
|
|
152
|
+
if (!Number.isNaN(totalPage) && totalPage > 0) bits.push(`\u5171 ${totalPage} \u9875`);
|
|
153
|
+
return bits.join(" \xB7 ");
|
|
154
|
+
}
|
|
155
|
+
function highlightSourceOf(raw, view) {
|
|
156
|
+
const direct = String(raw.highLightContent ?? raw.content ?? "").trim();
|
|
157
|
+
return direct || view.highlight;
|
|
158
|
+
}
|
|
159
|
+
var EMPH_OPEN = "";
|
|
160
|
+
var EMPH_CLOSE = "";
|
|
161
|
+
function segmentsOfHighlight(value) {
|
|
162
|
+
const source = String(value ?? "").replace(/<\/em>\s*<em>/gi, "").replace(/<em>([\s\S]*?)<\/em>/gi, (_all, inner) => `${EMPH_OPEN}${inner}${EMPH_CLOSE}`).replace(/<[^>]+>/g, " ");
|
|
163
|
+
const segments = [];
|
|
164
|
+
let buffer = "";
|
|
165
|
+
let inEm = false;
|
|
166
|
+
const flush = () => {
|
|
167
|
+
const text = buffer.replace(/ /g, " ").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/�*39;/g, "'").replace(/\s+/g, " ").trim();
|
|
168
|
+
if (text) segments.push({ em: inEm, text });
|
|
169
|
+
buffer = "";
|
|
170
|
+
};
|
|
171
|
+
for (const char of source) {
|
|
172
|
+
if (char === EMPH_OPEN) {
|
|
173
|
+
flush();
|
|
174
|
+
inEm = true;
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
if (char === EMPH_CLOSE) {
|
|
178
|
+
flush();
|
|
179
|
+
inEm = false;
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
buffer += char;
|
|
183
|
+
}
|
|
184
|
+
flush();
|
|
185
|
+
return segments;
|
|
186
|
+
}
|
|
187
|
+
function markdownHighlight(value, max = 200) {
|
|
188
|
+
const segments = segmentsOfHighlight(value);
|
|
189
|
+
let out = "";
|
|
190
|
+
let remaining = max;
|
|
191
|
+
let truncated = false;
|
|
192
|
+
const isWordChar = (char) => Boolean(char && /[\w\u3400-\u9fff]/.test(char));
|
|
193
|
+
for (let i = 0; i < segments.length; i += 1) {
|
|
194
|
+
const segment = segments[i];
|
|
195
|
+
if (remaining <= 0) {
|
|
196
|
+
truncated = true;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
if (segment.em) {
|
|
200
|
+
const overhead = "**__**".length - 2;
|
|
201
|
+
const bodyMax = Math.max(1, remaining - overhead);
|
|
202
|
+
const body = segment.text.slice(0, bodyMax);
|
|
203
|
+
if (body.length < segment.text.length) truncated = true;
|
|
204
|
+
const leadPad = isWordChar(out.slice(-1)) ? " " : "";
|
|
205
|
+
const tailPad = isWordChar(segments[i + 1]?.text[0]) ? " " : "";
|
|
206
|
+
out += `${leadPad}**${body}**${tailPad}`;
|
|
207
|
+
remaining -= overhead + body.length + leadPad.length + tailPad.length;
|
|
208
|
+
} else {
|
|
209
|
+
const take = Math.min(segment.text.length, remaining);
|
|
210
|
+
out += segment.text.slice(0, take);
|
|
211
|
+
remaining -= take;
|
|
212
|
+
if (take < segment.text.length) {
|
|
213
|
+
truncated = true;
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return (truncated ? `${out.replace(/…$/, "")}\u2026` : out).trim();
|
|
219
|
+
}
|
|
220
|
+
function htmlHighlight(value, max = 300) {
|
|
221
|
+
const segments = segmentsOfHighlight(value);
|
|
222
|
+
let out = "";
|
|
223
|
+
let remaining = max;
|
|
224
|
+
let truncated = false;
|
|
225
|
+
for (const segment of segments) {
|
|
226
|
+
if (remaining <= 0) {
|
|
227
|
+
truncated = true;
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
if (segment.em) {
|
|
231
|
+
const overhead = "<mark>__</mark>".length - 2;
|
|
232
|
+
const bodyMax = Math.max(1, remaining - overhead);
|
|
233
|
+
const body = segment.text.slice(0, bodyMax);
|
|
234
|
+
if (body.length < segment.text.length) truncated = true;
|
|
235
|
+
out += `<mark>${escapeHtml(body)}</mark>`;
|
|
236
|
+
remaining -= overhead + body.length;
|
|
237
|
+
} else {
|
|
238
|
+
const take = Math.min(segment.text.length, remaining);
|
|
239
|
+
out += escapeHtml(segment.text.slice(0, take));
|
|
240
|
+
remaining -= take;
|
|
241
|
+
if (take < segment.text.length) {
|
|
242
|
+
truncated = true;
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return truncated ? `${out.replace(/…$/, "")}\u2026` : out;
|
|
248
|
+
}
|
|
249
|
+
function formatSearchText(rows, meta = void 0) {
|
|
250
|
+
const views = rows.map((row) => toSearchRowView(row));
|
|
251
|
+
const keyword = String(meta?.keyword ?? "").trim();
|
|
252
|
+
const headerBits = [];
|
|
253
|
+
if (keyword) headerBits.push(`\u300C${keyword}\u300D\u68C0\u7D22`);
|
|
254
|
+
const pages = pageLabel(meta);
|
|
255
|
+
if (pages) headerBits.push(pages);
|
|
256
|
+
const lines = [];
|
|
257
|
+
if (headerBits.length) lines.push(headerBits.join(" | "));
|
|
258
|
+
if (lines.length) lines.push("=".repeat(60));
|
|
259
|
+
views.forEach((view, index) => {
|
|
260
|
+
lines.push(textTitleLine(index + 1, view));
|
|
261
|
+
if (view.highlight) lines.push(` ${view.highlight}`);
|
|
262
|
+
lines.push(` ${textMetaLine(view)}`);
|
|
263
|
+
if (index < views.length - 1) lines.push("");
|
|
264
|
+
});
|
|
265
|
+
return lines.join("\n");
|
|
266
|
+
}
|
|
267
|
+
function indentContinuation(text) {
|
|
268
|
+
return text.split("\n").map((line) => line.trim() ? ` ${line}` : "").join("\n");
|
|
269
|
+
}
|
|
270
|
+
function formatSearchCard(rows, options = {}) {
|
|
271
|
+
const baseUrl = String(options.baseUrl ?? "").trim().replace(/\/+$/, "");
|
|
272
|
+
const items = rows.map((row) => {
|
|
273
|
+
const raw = row;
|
|
274
|
+
const view = toSearchRowView(raw);
|
|
275
|
+
return { raw, view: view.viewPath && baseUrl ? withBaseUrl(view, baseUrl) : view };
|
|
276
|
+
});
|
|
277
|
+
const blocks = [];
|
|
278
|
+
items.forEach(({ raw, view }, index) => {
|
|
279
|
+
const url = view.viewUrl || view.viewPath || "";
|
|
280
|
+
const titleLink = url ? `[${view.title || "(\u65E0\u9898\u540D)"}](${url})` : view.title || "(\u65E0\u9898\u540D)";
|
|
281
|
+
const parts = [];
|
|
282
|
+
parts.push(`${index + 1}. **\u3010${view.level || "\u672A\u5206\u7C7B"}\u3011** ${titleLink}`);
|
|
283
|
+
const highlight = markdownHighlight(highlightSourceOf(raw, view));
|
|
284
|
+
if (highlight) {
|
|
285
|
+
parts.push("");
|
|
286
|
+
parts.push(indentContinuation(highlight));
|
|
287
|
+
}
|
|
288
|
+
parts.push("");
|
|
289
|
+
parts.push(indentContinuation(textMetaItems(view).join("\u3000")));
|
|
290
|
+
blocks.push(parts.join("\n"));
|
|
291
|
+
});
|
|
292
|
+
return blocks.join("\n\n");
|
|
293
|
+
}
|
|
294
|
+
function formatSearchHtml(rows, options = {}) {
|
|
295
|
+
const baseUrl = String(options.baseUrl ?? "").trim().replace(/\/+$/, "");
|
|
296
|
+
const items = rows.map((row) => {
|
|
297
|
+
const raw = row;
|
|
298
|
+
const view = toSearchRowView(raw);
|
|
299
|
+
return { raw, view: hasLink(view) && baseUrl ? withBaseUrl(view, baseUrl) : view };
|
|
300
|
+
});
|
|
301
|
+
const keyword = String(options.keyword ?? "").trim();
|
|
302
|
+
const heading = options.heading ?? (keyword ? `\u300C${keyword}\u300D\u6863\u6848\u68C0\u7D22\u7ED3\u679C` : "\u6863\u6848\u68C0\u7D22\u7ED3\u679C");
|
|
303
|
+
const cards = items.map(({ raw, view }, index) => {
|
|
304
|
+
const linkHref = view.viewUrl || view.viewPath;
|
|
305
|
+
const titleEl = linkHref ? `<a class="tlink" href="${escapeHtml(linkHref)}" target="_blank" title="\u6253\u5F00\u6863\u6848\u89C6\u56FE">${escapeHtml(view.title || "(\u65E0\u9898\u540D)")}</a>` : `<span class="tlink plain">${escapeHtml(view.title || "(\u65E0\u9898\u540D)")}</span>`;
|
|
306
|
+
const highlight = htmlHighlight(highlightSourceOf(raw, view));
|
|
307
|
+
return `<article class="card">
|
|
308
|
+
<div class="trow"><span class="idx">${index + 1}.</span><span class="lvl">${escapeHtml(view.level || "\u672A\u5206\u7C7B")}</span>${titleEl}</div>
|
|
309
|
+
${highlight ? `<p class="hl">${highlight}</p>` : ""}
|
|
310
|
+
<div class="meta"><span>\u5168\u5B97\uFF1A${escapeHtml(view.fonds || "-")}</span><span>\u5206\u7C7B\uFF1A${escapeHtml(view.category || "-")}</span>${view.dateLabel && view.dateValue ? `<span>${escapeHtml(describeDate(view))}</span>` : ""}</div>
|
|
311
|
+
</article>`;
|
|
312
|
+
}).join("\n");
|
|
313
|
+
const pages = pageLabel(options);
|
|
314
|
+
return `<!DOCTYPE html>
|
|
315
|
+
<html lang="zh-CN"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
316
|
+
<title>${escapeHtml(heading)}</title><style>
|
|
317
|
+
*{box-sizing:border-box;margin:0;padding:0}
|
|
318
|
+
body{font:14px/1.7 -apple-system,"PingFang SC","Microsoft YaHei",sans-serif;background:#f0f2f5;color:#1f2d3d;padding:28px}
|
|
319
|
+
.wrap{max-width:980px;margin:0 auto}
|
|
320
|
+
h1{font-size:20px;margin-bottom:4px}
|
|
321
|
+
.sub{color:#64748b;font-size:13px;margin-bottom:18px}
|
|
322
|
+
.card{background:#fff;border:1px solid #e2e8f0;border-radius:10px;padding:14px 18px;margin-bottom:12px;box-shadow:0 1px 2px rgba(0,0,0,.04)}
|
|
323
|
+
.trow{display:flex;align-items:baseline;gap:10px;flex-wrap:wrap}
|
|
324
|
+
.idx{color:#94a3b8;font-weight:600}
|
|
325
|
+
.lvl{flex:none;background:#eef4ff;color:#2563eb;border:1px solid #bfdbfe;border-radius:4px;padding:0 8px;font-size:12px}
|
|
326
|
+
.tlink{font-size:15px;font-weight:600;color:#0f2c5c;text-decoration:none;word-wrap:break-word;overflow-wrap:break-word}
|
|
327
|
+
.tlink:hover{color:#1d6ae5;text-decoration:underline}
|
|
328
|
+
.tlink.plain{cursor:default}
|
|
329
|
+
.hl{margin:8px 0 6px;color:#475569;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;font-size:13px}
|
|
330
|
+
.hl mark{background:#ffe58f;color:#7c2d12;padding:0 2px;border-radius:3px;font-weight:600}
|
|
331
|
+
.meta{display:flex;gap:22px;color:#334155;font-size:13px;border-top:1px dashed #e2e8f0;padding-top:8px;flex-wrap:wrap}
|
|
332
|
+
.meta span:first-child{color:#0f766e}
|
|
333
|
+
</style></head><body><div class="wrap">
|
|
334
|
+
<h1>${escapeHtml(heading)}</h1>
|
|
335
|
+
${pages ? `<div class="sub">${escapeHtml(pages)} \xB7 \u70B9\u51FB\u9898\u540D\u6253\u5F00\u6863\u6848\u89C6\u56FE</div>` : ""}
|
|
336
|
+
${cards}
|
|
337
|
+
</div></body></html>`;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// src/shortcuts/archive/continuation.ts
|
|
341
|
+
import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
|
|
342
|
+
import { existsSync } from "node:fs";
|
|
343
|
+
import { chmod, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
344
|
+
import { homedir } from "node:os";
|
|
345
|
+
import { resolve } from "node:path";
|
|
346
|
+
|
|
347
|
+
// src/shortcuts/archive/errors.ts
|
|
348
|
+
var ArchiveCliError = class extends CliError {
|
|
349
|
+
type;
|
|
350
|
+
subtype;
|
|
351
|
+
code;
|
|
352
|
+
retryable;
|
|
353
|
+
stage;
|
|
354
|
+
details;
|
|
355
|
+
partialData;
|
|
356
|
+
constructor(type, subtype, message, options = {}) {
|
|
357
|
+
super(message, options.exitCode ?? 5 /* InternalError */);
|
|
358
|
+
this.name = "ArchiveCliError";
|
|
359
|
+
this.type = type;
|
|
360
|
+
this.subtype = subtype;
|
|
361
|
+
this.code = options.code;
|
|
362
|
+
this.retryable = options.retryable ?? false;
|
|
363
|
+
this.stage = options.stage;
|
|
364
|
+
this.details = options.details;
|
|
365
|
+
this.partialData = options.partialData;
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
function archiveValidationError(subtype, message, details) {
|
|
369
|
+
return new ArchiveCliError("validation", subtype, message, {
|
|
370
|
+
details,
|
|
371
|
+
exitCode: 2 /* UsageError */
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
function archiveAuthError(subtype, message, details) {
|
|
375
|
+
return new ArchiveCliError("authentication", subtype, message, {
|
|
376
|
+
details,
|
|
377
|
+
exitCode: 3 /* AuthError */
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
function archiveNetworkError(subtype, message, options = {}) {
|
|
381
|
+
return new ArchiveCliError("network", subtype, message, {
|
|
382
|
+
...options,
|
|
383
|
+
retryable: options.retryable ?? true,
|
|
384
|
+
exitCode: 4 /* NetworkError */
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
function archiveConfirmationError(action, details) {
|
|
388
|
+
return new ArchiveCliError("confirmation", "required", "\u8BE5\u64CD\u4F5C\u9700\u8981\u660E\u786E\u786E\u8BA4", {
|
|
389
|
+
details: { action, ...details },
|
|
390
|
+
exitCode: 10 /* ConfirmationRequired */
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// src/shortcuts/archive/continuation.ts
|
|
395
|
+
function stateRoot(ctx) {
|
|
396
|
+
const configured = ctx?.config?.path();
|
|
397
|
+
if (configured) return resolve(configured, "..");
|
|
398
|
+
return process.env.WEAVER_WORK_CLI_HOME || process.env.WORK_CLI_HOME || resolve(homedir(), ".weaver-work-cli");
|
|
399
|
+
}
|
|
400
|
+
async function loadKey(ctx) {
|
|
401
|
+
const keysDir = resolve(stateRoot(ctx), "keys");
|
|
402
|
+
const filename = resolve(keysDir, "archive-continuation.key");
|
|
403
|
+
await mkdir(keysDir, { recursive: true, mode: 448 });
|
|
404
|
+
if (existsSync(filename)) return readFile(filename);
|
|
405
|
+
const key = randomBytes(32);
|
|
406
|
+
try {
|
|
407
|
+
await writeFile(filename, key, { flag: "wx", mode: 384 });
|
|
408
|
+
if (process.platform !== "win32") await chmod(filename, 384).catch(() => void 0);
|
|
409
|
+
return key;
|
|
410
|
+
} catch {
|
|
411
|
+
return readFile(filename);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
function encode(value) {
|
|
415
|
+
return Buffer.from(JSON.stringify(value)).toString("base64url");
|
|
416
|
+
}
|
|
417
|
+
function signature(payload, key) {
|
|
418
|
+
return createHmac("sha256", key).update(payload).digest("base64url");
|
|
419
|
+
}
|
|
420
|
+
function createArchiveContinuationSigner(ctx) {
|
|
421
|
+
return {
|
|
422
|
+
async issue(payload, ttlMs = 10 * 6e4) {
|
|
423
|
+
const issuedAt = Date.now();
|
|
424
|
+
const body = encode({ ...payload, issuedAt, expiresAt: issuedAt + ttlMs });
|
|
425
|
+
const sig = signature(body, await loadKey(ctx));
|
|
426
|
+
return `${body}.${sig}`;
|
|
427
|
+
},
|
|
428
|
+
async verify(token, expectedOperation) {
|
|
429
|
+
if (typeof token !== "string" || !token.includes(".")) {
|
|
430
|
+
throw archiveValidationError("continuation_invalid", "continuation \u65E0\u6548");
|
|
431
|
+
}
|
|
432
|
+
const [body, provided] = token.split(".");
|
|
433
|
+
const expected = signature(body, await loadKey(ctx));
|
|
434
|
+
const valid = provided.length === expected.length && timingSafeEqual(Buffer.from(provided), Buffer.from(expected));
|
|
435
|
+
if (!valid) throw archiveValidationError("continuation_invalid", "continuation \u7B7E\u540D\u6821\u9A8C\u5931\u8D25");
|
|
436
|
+
let value;
|
|
437
|
+
try {
|
|
438
|
+
value = JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
|
|
439
|
+
} catch {
|
|
440
|
+
throw archiveValidationError("continuation_invalid", "continuation \u5185\u5BB9\u65E0\u6CD5\u89E3\u6790");
|
|
441
|
+
}
|
|
442
|
+
if (value.operation !== expectedOperation) {
|
|
443
|
+
throw archiveValidationError("continuation_mismatch", "continuation \u4E0D\u5C5E\u4E8E\u5F53\u524D\u64CD\u4F5C");
|
|
444
|
+
}
|
|
445
|
+
if (!Number.isSafeInteger(value.expiresAt) || value.expiresAt < Date.now()) {
|
|
446
|
+
throw archiveValidationError("continuation_expired", "continuation \u5DF2\u8FC7\u671F");
|
|
447
|
+
}
|
|
448
|
+
return value;
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// src/shortcuts/archive/host.ts
|
|
454
|
+
function inferProfile(ctx) {
|
|
455
|
+
const options = ctx.getGlobalOptions();
|
|
456
|
+
return options.profile || getActiveProfile();
|
|
457
|
+
}
|
|
458
|
+
function isArchiveBusinessSuccess(value) {
|
|
459
|
+
if (!value || typeof value !== "object") return false;
|
|
460
|
+
if (typeof value.success === "boolean") return value.success;
|
|
461
|
+
if (typeof value.status === "boolean") return value.status;
|
|
462
|
+
if (value.datajson && typeof value.datajson === "object" && typeof value.datajson.status === "boolean") {
|
|
463
|
+
return value.datajson.status;
|
|
464
|
+
}
|
|
465
|
+
if (value.code !== void 0 && value.code !== null) return Number(value.code) === 200;
|
|
466
|
+
return false;
|
|
467
|
+
}
|
|
468
|
+
function archiveBusinessMessage(value) {
|
|
469
|
+
if (!value || typeof value !== "object") return "\u6863\u6848\u6838\u5FC3\u7CFB\u7EDF\u63A5\u53E3\u8FD4\u56DE\u4E1A\u52A1\u5931\u8D25";
|
|
470
|
+
const candidates = [
|
|
471
|
+
value.msg,
|
|
472
|
+
value.message,
|
|
473
|
+
value.errMsg,
|
|
474
|
+
value.data?.message,
|
|
475
|
+
value.data?.msg,
|
|
476
|
+
value.datajson?.msg,
|
|
477
|
+
value.datajson?.message
|
|
478
|
+
];
|
|
479
|
+
for (const item of candidates) {
|
|
480
|
+
if (typeof item === "string" && item.trim()) return item;
|
|
481
|
+
}
|
|
482
|
+
return "\u6863\u6848\u6838\u5FC3\u7CFB\u7EDF\u63A5\u53E3\u8FD4\u56DE\u4E1A\u52A1\u5931\u8D25";
|
|
483
|
+
}
|
|
484
|
+
function archiveBusinessCode(value) {
|
|
485
|
+
if (!value || typeof value !== "object") return void 0;
|
|
486
|
+
const code = value.code ?? value.status;
|
|
487
|
+
if (typeof code === "string" || typeof code === "number") return code;
|
|
488
|
+
return void 0;
|
|
489
|
+
}
|
|
490
|
+
function assertArchivePath(requestPath) {
|
|
491
|
+
if (typeof requestPath !== "string" || !requestPath.startsWith("/") || requestPath.startsWith("//")) {
|
|
492
|
+
throw archiveValidationError("path_invalid", "\u8BF7\u6C42\u8DEF\u5F84\u5FC5\u987B\u662F\u76F8\u5BF9\u7EDD\u5BF9\u8DEF\u5F84");
|
|
493
|
+
}
|
|
494
|
+
if (/^https?:/i.test(requestPath) || /[\r\n]/.test(requestPath) || requestPath.includes("/../")) {
|
|
495
|
+
throw archiveValidationError("path_invalid", "\u8BF7\u6C42\u8DEF\u5F84\u4E0D\u5141\u8BB8\u8DE8\u57DF\u6216\u8DEF\u5F84\u9003\u9038");
|
|
496
|
+
}
|
|
497
|
+
if (!requestPath.startsWith("/api/")) {
|
|
498
|
+
throw archiveValidationError("path_not_allowed", "\u6863\u6848\u6A21\u5757\u53EA\u80FD\u8C03\u7528 /api/ \u8DEF\u5F84");
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
function formBody(form) {
|
|
502
|
+
if (!form) return void 0;
|
|
503
|
+
const params = new URLSearchParams();
|
|
504
|
+
for (const [key, value] of Object.entries(form)) {
|
|
505
|
+
if (value === void 0 || value === null) continue;
|
|
506
|
+
params.set(key, typeof value === "string" ? value : JSON.stringify(value));
|
|
507
|
+
}
|
|
508
|
+
return params;
|
|
509
|
+
}
|
|
510
|
+
function omitEmptyQueryValues(query) {
|
|
511
|
+
if (!query) return void 0;
|
|
512
|
+
return Object.fromEntries(Object.entries(query).filter(([, value]) => value !== ""));
|
|
513
|
+
}
|
|
514
|
+
function mapRuntimeNetworkError(error) {
|
|
515
|
+
if (error instanceof E10ApiError && error.type === "network") {
|
|
516
|
+
throw archiveNetworkError(error.subtype, error.message, {
|
|
517
|
+
retryable: error.retryable,
|
|
518
|
+
details: error.details
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
throw error;
|
|
522
|
+
}
|
|
523
|
+
function createArchiveHost(ctx, dependencies = {}) {
|
|
524
|
+
let e10Session = null;
|
|
525
|
+
let sessionContext = null;
|
|
526
|
+
const requireSession = dependencies.requireSession || requireE10Session;
|
|
527
|
+
async function ensureSession() {
|
|
528
|
+
if (!e10Session) {
|
|
529
|
+
e10Session = await requireSession(ctx);
|
|
530
|
+
sessionContext = {
|
|
531
|
+
baseUrl: e10Session.getBaseUrl(),
|
|
532
|
+
profile: inferProfile(ctx),
|
|
533
|
+
userId: e10Session.userId,
|
|
534
|
+
tenantKey: e10Session.tenantKey,
|
|
535
|
+
eteamsId: e10Session.eteamsId
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
return e10Session;
|
|
539
|
+
}
|
|
540
|
+
async function getSession() {
|
|
541
|
+
await ensureSession();
|
|
542
|
+
return sessionContext;
|
|
543
|
+
}
|
|
544
|
+
async function runtime() {
|
|
545
|
+
return createE10RequestRuntime(ctx, await ensureSession(), {
|
|
546
|
+
interceptors: dependencies.interceptors,
|
|
547
|
+
fetch: dependencies.fetch
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
async function doRequest(request2, binary) {
|
|
551
|
+
const {
|
|
552
|
+
method,
|
|
553
|
+
path,
|
|
554
|
+
query,
|
|
555
|
+
body,
|
|
556
|
+
operation,
|
|
557
|
+
form,
|
|
558
|
+
multipart,
|
|
559
|
+
headers: extraHeaders = {},
|
|
560
|
+
timeoutMs = 6e4
|
|
561
|
+
} = request2;
|
|
562
|
+
assertArchivePath(path);
|
|
563
|
+
const resolvedMethod = method || (body === void 0 && form === void 0 && multipart === void 0 ? "GET" : "POST");
|
|
564
|
+
const rt = await runtime();
|
|
565
|
+
const response = binary ? await rt.requestBinary({
|
|
566
|
+
module: "archive",
|
|
567
|
+
operation,
|
|
568
|
+
method: resolvedMethod,
|
|
569
|
+
path,
|
|
570
|
+
query: omitEmptyQueryValues(query),
|
|
571
|
+
body: multipart === void 0 ? body : void 0,
|
|
572
|
+
form: multipart === void 0 && form === void 0 ? void 0 : formBody(form ?? {}),
|
|
573
|
+
formData: multipart,
|
|
574
|
+
headers: { "X-Requested-With": "XMLHttpRequest", ...extraHeaders },
|
|
575
|
+
timeoutMs
|
|
576
|
+
}) : await rt.requestJson({
|
|
577
|
+
module: "archive",
|
|
578
|
+
operation,
|
|
579
|
+
method: resolvedMethod,
|
|
580
|
+
path,
|
|
581
|
+
query: omitEmptyQueryValues(query),
|
|
582
|
+
body: multipart === void 0 ? body : void 0,
|
|
583
|
+
form: multipart === void 0 && form === void 0 ? void 0 : formBody(form ?? {}),
|
|
584
|
+
formData: multipart,
|
|
585
|
+
headers: { "X-Requested-With": "XMLHttpRequest", ...extraHeaders },
|
|
586
|
+
timeoutMs
|
|
587
|
+
});
|
|
588
|
+
return response;
|
|
589
|
+
}
|
|
590
|
+
async function request(request2) {
|
|
591
|
+
const response = await doRequest(request2, false).catch((error) => mapRuntimeNetworkError(error));
|
|
592
|
+
if (response.status === 401 || response.status === 302) {
|
|
593
|
+
throw archiveAuthError("session_expired", E10_SESSION_EXPIRED_MESSAGE, { httpStatus: response.status });
|
|
594
|
+
}
|
|
595
|
+
if (response.parseError) {
|
|
596
|
+
if (response.status < 200 || response.status >= 300) {
|
|
597
|
+
throw new ArchiveCliError("api", "http_error", `\u6863\u6848\u6838\u5FC3\u7CFB\u7EDF\u63A5\u53E3 HTTP ${response.status}`, {
|
|
598
|
+
code: response.status,
|
|
599
|
+
details: { status: response.status },
|
|
600
|
+
exitCode: 1
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
throw archiveNetworkError("protocol", `\u63A5\u53E3\u8FD4\u56DE\u4E0D\u662F\u5408\u6CD5 JSON\uFF08HTTP ${response.status}\uFF09`, { retryable: false });
|
|
604
|
+
}
|
|
605
|
+
if (response.status < 200 || response.status >= 300) {
|
|
606
|
+
throw new ArchiveCliError("api", "http_error", `\u6863\u6848\u6838\u5FC3\u7CFB\u7EDF\u63A5\u53E3 HTTP ${response.status}`, {
|
|
607
|
+
code: response.status,
|
|
608
|
+
details: { status: response.status, message: archiveBusinessMessage(response.value) },
|
|
609
|
+
exitCode: 1
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
if (!isArchiveBusinessSuccess(response.value)) {
|
|
613
|
+
throw new ArchiveCliError("api", "business_error", archiveBusinessMessage(response.value), {
|
|
614
|
+
code: archiveBusinessCode(response.value),
|
|
615
|
+
details: { code: archiveBusinessCode(response.value), message: archiveBusinessMessage(response.value) },
|
|
616
|
+
exitCode: 1
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
return response.value;
|
|
620
|
+
}
|
|
621
|
+
async function requestBinary(request2) {
|
|
622
|
+
const response = await doRequest(request2, true).catch((error) => mapRuntimeNetworkError(error));
|
|
623
|
+
if (response.status === 401 || response.status === 302) {
|
|
624
|
+
throw archiveAuthError("session_expired", E10_SESSION_EXPIRED_MESSAGE, { httpStatus: response.status });
|
|
625
|
+
}
|
|
626
|
+
if (response.status < 200 || response.status >= 300) {
|
|
627
|
+
throw new ArchiveCliError("api", "http_error", `\u6863\u6848\u4E0B\u8F7D HTTP ${response.status}`, {
|
|
628
|
+
code: response.status,
|
|
629
|
+
details: { status: response.status },
|
|
630
|
+
exitCode: 1
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
return { status: response.status, contentType: response.contentType, content: response.content };
|
|
634
|
+
}
|
|
635
|
+
return { request, requestBinary, getSession };
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
// src/shortcuts/archive/operations/types.ts
|
|
639
|
+
var READ = "read";
|
|
640
|
+
var WRITE = "write";
|
|
641
|
+
function archiveSuccess(action, data, meta) {
|
|
642
|
+
const payload = { ok: true, action, data };
|
|
643
|
+
if (meta && Object.keys(meta).length > 0) payload.meta = meta;
|
|
644
|
+
return payload;
|
|
645
|
+
}
|
|
646
|
+
function schemaOf(properties, options = {}) {
|
|
647
|
+
return {
|
|
648
|
+
type: "object",
|
|
649
|
+
additionalProperties: false,
|
|
650
|
+
properties,
|
|
651
|
+
...options.required?.length ? { required: options.required } : {},
|
|
652
|
+
...options.description ? { description: options.description } : {}
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
// src/shortcuts/archive/operations/shared.ts
|
|
657
|
+
var FORBIDDEN_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
658
|
+
function asObject(value) {
|
|
659
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
660
|
+
throw archiveValidationError("input_not_object", "\u8F93\u5165\u5FC5\u987B\u662F JSON \u5BF9\u8C61");
|
|
661
|
+
}
|
|
662
|
+
return value;
|
|
663
|
+
}
|
|
664
|
+
function assertNoForbiddenKeys(input) {
|
|
665
|
+
for (const key of Object.keys(input)) {
|
|
666
|
+
if (FORBIDDEN_KEYS.has(key)) {
|
|
667
|
+
throw archiveValidationError("forbidden_key", `\u8F93\u5165\u5305\u542B\u975E\u6CD5\u5B57\u6BB5\uFF1A${key}`);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
function compact(body) {
|
|
672
|
+
for (const key of Object.keys(body)) {
|
|
673
|
+
if (body[key] === void 0) delete body[key];
|
|
674
|
+
}
|
|
675
|
+
return body;
|
|
676
|
+
}
|
|
677
|
+
function unwrapData(response) {
|
|
678
|
+
if (!response || typeof response !== "object") return response;
|
|
679
|
+
return response.data;
|
|
680
|
+
}
|
|
681
|
+
function unwrapDatajson(response) {
|
|
682
|
+
if (!response || typeof response !== "object") return void 0;
|
|
683
|
+
const value = response;
|
|
684
|
+
if (value.datajson && typeof value.datajson === "object") return value.datajson;
|
|
685
|
+
const data = value.data;
|
|
686
|
+
if (data && typeof data === "object" && data.datajson) {
|
|
687
|
+
return data.datajson;
|
|
688
|
+
}
|
|
689
|
+
return void 0;
|
|
690
|
+
}
|
|
691
|
+
function positiveInt(value, field, fallback) {
|
|
692
|
+
if (value === void 0 || value === null || value === "") return fallback;
|
|
693
|
+
const parsed = Number(value);
|
|
694
|
+
if (!Number.isInteger(parsed) || parsed <= 0) {
|
|
695
|
+
throw archiveValidationError("number_invalid", `${field} \u5FC5\u987B\u662F\u6B63\u6574\u6570`);
|
|
696
|
+
}
|
|
697
|
+
return parsed;
|
|
698
|
+
}
|
|
699
|
+
function requireText(value, field) {
|
|
700
|
+
if (typeof value !== "string" || !value.trim()) {
|
|
701
|
+
throw archiveValidationError("field_required", `${field} \u5FC5\u586B`);
|
|
702
|
+
}
|
|
703
|
+
return value.trim();
|
|
704
|
+
}
|
|
705
|
+
function toStringId(value, field) {
|
|
706
|
+
if (value === void 0 || value === null || value === "") return void 0;
|
|
707
|
+
const text = typeof value === "string" ? value.trim() : String(value);
|
|
708
|
+
if (!/^\d+$/.test(text)) throw archiveValidationError("id_invalid", `${field} \u5FC5\u987B\u662F\u6570\u5B57 ID`);
|
|
709
|
+
return text;
|
|
710
|
+
}
|
|
711
|
+
function toStringIdList(value, field) {
|
|
712
|
+
if (value === void 0 || value === null) return void 0;
|
|
713
|
+
if (!Array.isArray(value)) throw archiveValidationError("id_list_invalid", `${field} \u5FC5\u987B\u662F ID \u6570\u7EC4`);
|
|
714
|
+
return value.map((item, index) => {
|
|
715
|
+
const text = toStringId(item, `${field}[${index}]`);
|
|
716
|
+
if (text === void 0) throw archiveValidationError("id_list_invalid", `${field}[${index}] \u4E0D\u80FD\u4E3A\u7A7A`);
|
|
717
|
+
return text;
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
function assertEnum(value, allowed, field) {
|
|
721
|
+
const text = typeof value === "string" ? value : String(value);
|
|
722
|
+
if (!allowed.includes(text)) {
|
|
723
|
+
throw archiveValidationError("enum_invalid", `${field} \u53D6\u503C\u5FC5\u987B\u662F ${allowed.join(" / ")} \u4E4B\u4E00`);
|
|
724
|
+
}
|
|
725
|
+
return text;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
// src/shortcuts/archive/operations/fonds.ts
|
|
729
|
+
var fondsList = {
|
|
730
|
+
name: "archive.fonds.list",
|
|
731
|
+
resource: "fonds",
|
|
732
|
+
method: "list",
|
|
733
|
+
action: "archive.fonds.list",
|
|
734
|
+
summary: "\u83B7\u53D6\u5F53\u524D\u8D26\u53F7\u6709\u6743\u9650\u7684\u5168\u5B97\u5217\u8868\uFF08\u6536\u96C6\u5E93/\u7BA1\u7406\u5E93\uFF09\uFF1B\u5168\u5B97 ID \u4F9B getTree\u3001\u9884\u5F52\u6863\u4E0A\u4F20\u7B49\u540E\u7EED\u94FE\u8DEF\u590D\u7528",
|
|
735
|
+
capability: "fonds",
|
|
736
|
+
risk: READ,
|
|
737
|
+
inputSchema: schemaOf(
|
|
738
|
+
{
|
|
739
|
+
menuSign: { type: "string", enum: ["collectLib", "manageLib"], description: "\u6536\u96C6\u5E93/\u7BA1\u7406\u5E93\uFF0C\u9ED8\u8BA4 collectLib" },
|
|
740
|
+
needControl: { type: "boolean", description: "\u662F\u5426\u6309\u5F53\u524D\u7528\u6237\u6743\u9650\u8FC7\u6EE4\u5168\u5B97\uFF0C\u9ED8\u8BA4 true" }
|
|
741
|
+
},
|
|
742
|
+
{ description: "\u67E5\u8BE2\u6863\u6848\u5168\u5B97\u5217\u8868" }
|
|
743
|
+
),
|
|
744
|
+
handler: async (args, { host }) => {
|
|
745
|
+
const menuSign = assertEnum(args.menuSign ?? "collectLib", ["collectLib", "manageLib"], "menuSign");
|
|
746
|
+
const needControl = args.needControl === void 0 ? true : Boolean(args.needControl);
|
|
747
|
+
const response = await host.request({
|
|
748
|
+
method: "POST",
|
|
749
|
+
path: "/api/archive/core/archivetree/getFonds",
|
|
750
|
+
body: compact({
|
|
751
|
+
treeType: "1",
|
|
752
|
+
menuSign,
|
|
753
|
+
needControl,
|
|
754
|
+
extraData: false,
|
|
755
|
+
extraSign: "0",
|
|
756
|
+
logFlag: menuSign
|
|
757
|
+
})
|
|
758
|
+
});
|
|
759
|
+
const data = unwrapData(response);
|
|
760
|
+
const rows = Array.isArray(data) ? data : [];
|
|
761
|
+
return archiveSuccess(
|
|
762
|
+
"archive.fonds.list",
|
|
763
|
+
rows.map((item) => ({
|
|
764
|
+
id: item.id,
|
|
765
|
+
fonds_name: item.fonds_name,
|
|
766
|
+
fonds_code: item.fonds_code,
|
|
767
|
+
easy_name: item.easy_name ?? "",
|
|
768
|
+
classification: item.classification,
|
|
769
|
+
is_use: item.is_use,
|
|
770
|
+
fonds_parent: item.fonds_parent,
|
|
771
|
+
own_company: item.own_company
|
|
772
|
+
})),
|
|
773
|
+
{ count: rows.length, menuSign }
|
|
774
|
+
);
|
|
775
|
+
}
|
|
776
|
+
};
|
|
777
|
+
function isEfileLibNode(item) {
|
|
778
|
+
const id = typeof item?.id === "string" ? item.id : "";
|
|
779
|
+
if (!id || !id.includes("_")) return false;
|
|
780
|
+
const [left, right] = id.split("_");
|
|
781
|
+
return Boolean(left && left === right);
|
|
782
|
+
}
|
|
783
|
+
var prelibTree = {
|
|
784
|
+
name: "archive.prelib.tree",
|
|
785
|
+
resource: "prelib",
|
|
786
|
+
method: "tree",
|
|
787
|
+
action: "archive.prelib.tree",
|
|
788
|
+
summary: "\u83B7\u53D6\u5F53\u524D\u8D26\u53F7\u7684\u9884\u5F52\u6863\u6811\u8282\u70B9\uFF0C\u5E76\u8BC6\u522B\u7535\u5B50\u6587\u4EF6\u5E93\u8282\u70B9\uFF08id \u5F62\u5982 {appId}_{appId}\uFF09\uFF1B\u7535\u5B50\u6587\u4EF6\u5E93\u8282\u70B9 id \u5373\u9884\u5F52\u6863\u4E0A\u4F20 saveFile \u7684 treeId",
|
|
789
|
+
capability: "fonds",
|
|
790
|
+
risk: READ,
|
|
791
|
+
inputSchema: schemaOf({}, { description: "\u67E5\u8BE2\u9884\u5F52\u6863\u6811\uFF08\u9ED8\u8BA4\u6309\u5F53\u524D\u7528\u6237\u6743\u9650\uFF09" }),
|
|
792
|
+
handler: async (_args, { host }) => {
|
|
793
|
+
const response = await host.request({
|
|
794
|
+
method: "POST",
|
|
795
|
+
path: "/api/archive/core/archivetree/getTree",
|
|
796
|
+
body: {
|
|
797
|
+
treeType: "4",
|
|
798
|
+
menuSign: "preLib",
|
|
799
|
+
logFlag: "preLib",
|
|
800
|
+
needControl: true,
|
|
801
|
+
needSysn: true
|
|
802
|
+
}
|
|
803
|
+
});
|
|
804
|
+
const data = unwrapData(response);
|
|
805
|
+
if (!Array.isArray(data)) {
|
|
806
|
+
throw archiveValidationError("tree_invalid", "getTree \u8FD4\u56DE\u5F02\u5E38\uFF1Adata \u4E0D\u662F\u6570\u7EC4");
|
|
807
|
+
}
|
|
808
|
+
const nodes = data;
|
|
809
|
+
const efileLibraries = nodes.filter(isEfileLibNode).map((item) => ({ id: item.id, content: item.content }));
|
|
810
|
+
return archiveSuccess(
|
|
811
|
+
"archive.prelib.tree",
|
|
812
|
+
efileLibraries,
|
|
813
|
+
{
|
|
814
|
+
count: efileLibraries.length,
|
|
815
|
+
hint: "\u8282\u70B9 id \u4E0B\u5212\u7EBF\u524D\u540E\u4E00\u81F4\u5373\u4E3A\u7535\u5B50\u6587\u4EF6\u5E93 treeId\uFF0C\u7528\u4E8E\u9884\u5F52\u6863\u4E0A\u4F20"
|
|
816
|
+
}
|
|
817
|
+
);
|
|
818
|
+
}
|
|
819
|
+
};
|
|
820
|
+
var fondsOperations = [fondsList, prelibTree];
|
|
821
|
+
|
|
822
|
+
// src/shortcuts/archive/operations/archive-info.ts
|
|
823
|
+
function splitArcId(arcDangan, field) {
|
|
824
|
+
const text = typeof arcDangan === "string" ? arcDangan : String(arcDangan ?? "");
|
|
825
|
+
const [dataId, formId] = text.split("_");
|
|
826
|
+
if (!dataId || !formId || !/^\d+$/.test(dataId) || !/^\d+$/.test(formId)) {
|
|
827
|
+
throw archiveValidationError("arc_id_invalid", `${field} \u5FC5\u987B\u662F {\u6863\u6848ID}_{\u8868\u5355ID} \u683C\u5F0F\u7684\u6570\u5B57 ID \u5BF9`);
|
|
828
|
+
}
|
|
829
|
+
return { dataId, formId };
|
|
830
|
+
}
|
|
831
|
+
var archiveInfoGet = {
|
|
832
|
+
name: "archive.info.get",
|
|
833
|
+
resource: "info",
|
|
834
|
+
method: "get",
|
|
835
|
+
action: "archive.info.get",
|
|
836
|
+
summary: "\u67E5\u770B\u6863\u6848\u6761\u76EE\u7684\u57FA\u672C\u4FE1\u606F\uFF08\u5E74\u5EA6/\u6848\u5377\u53F7/\u8D77\u6B62\u4EF6\u53F7/\u6587\u4EF6\u65E5\u671F/\u4FDD\u7BA1\u671F\u9650/\u5BC6\u7EA7/\u5E93\u4F4D\u7B49\uFF09\uFF1B\u8F93\u5165\u4E3A\u6863\u6848\u6807\u8BC6 {\u6863\u6848ID}_{\u8868\u5355ID}\uFF08\u53EF\u6765\u81EA\u501F\u9605\u8F66 arc_dangan\uFF09",
|
|
837
|
+
capability: "archive",
|
|
838
|
+
risk: READ,
|
|
839
|
+
inputSchema: schemaOf(
|
|
840
|
+
{
|
|
841
|
+
arcDangan: { type: "string", description: "{\u6863\u6848ID}_{\u8868\u5355ID}\uFF0C\u4E0E dataId+formId \u4E8C\u9009\u4E00" },
|
|
842
|
+
dataId: { type: "string", pattern: "^\\d+$", description: "\u6863\u6848\u6570\u636E ID\uFF08arc_dangan \u62C6\u89E3\u524D\u534A\u6BB5\uFF09" },
|
|
843
|
+
formId: { type: "string", pattern: "^\\d+$", description: "\u6863\u6848\u6240\u5C5E\u8868\u5355 ID\uFF08arc_dangan \u62C6\u89E3\u540E\u534A\u6BB5\uFF09" }
|
|
844
|
+
},
|
|
845
|
+
{ description: "\u67E5\u8BE2\u6863\u6848\u57FA\u672C\u4FE1\u606F\uFF1BarcDangan \u4E0E dataId+formId \u81F3\u5C11\u63D0\u4F9B\u4E00\u7EC4" }
|
|
846
|
+
),
|
|
847
|
+
handler: async (args, { host }) => {
|
|
848
|
+
let pair;
|
|
849
|
+
if (args.arcDangan !== void 0) {
|
|
850
|
+
pair = splitArcId(args.arcDangan, "arcDangan");
|
|
851
|
+
} else {
|
|
852
|
+
const dataId = args.dataId;
|
|
853
|
+
const formId = args.formId;
|
|
854
|
+
if (dataId === void 0 || dataId === null || dataId === "" || formId === void 0 || formId === null || formId === "") {
|
|
855
|
+
throw archiveValidationError("id_pair_required", "arcDangan \u6216 dataId+formId \u5FC5\u586B\u4E00\u7EC4");
|
|
856
|
+
}
|
|
857
|
+
if (!/^\d+$/.test(String(dataId)) || !/^\d+$/.test(String(formId))) {
|
|
858
|
+
throw archiveValidationError("id_pair_invalid", "dataId/formId \u5FC5\u987B\u662F\u6570\u5B57 ID");
|
|
859
|
+
}
|
|
860
|
+
pair = { dataId: String(dataId), formId: String(formId) };
|
|
861
|
+
}
|
|
862
|
+
const response = await host.request({
|
|
863
|
+
method: "POST",
|
|
864
|
+
path: "/api/archive/core/borrow/getBorrowDetails",
|
|
865
|
+
body: { dataId: pair.dataId, formId: pair.formId }
|
|
866
|
+
});
|
|
867
|
+
const data = unwrapData(response);
|
|
868
|
+
const rows = Array.isArray(data) ? data : [];
|
|
869
|
+
return archiveSuccess("archive.info.get", rows, { count: rows.length });
|
|
870
|
+
}
|
|
871
|
+
};
|
|
872
|
+
var archiveInfoOperations = [archiveInfoGet];
|
|
873
|
+
|
|
874
|
+
// src/shortcuts/archive/operations/search.ts
|
|
875
|
+
var EBDATA_PREFIX2 = "EBDATA_OBJID";
|
|
876
|
+
function parseFormId(module) {
|
|
877
|
+
const text = typeof module === "string" ? module : "";
|
|
878
|
+
if (!text.startsWith(EBDATA_PREFIX2)) return void 0;
|
|
879
|
+
const id = text.slice(EBDATA_PREFIX2.length);
|
|
880
|
+
return /^\d+$/.test(id) ? id : void 0;
|
|
881
|
+
}
|
|
882
|
+
var searchRun = {
|
|
883
|
+
name: "archive.search.run",
|
|
884
|
+
resource: "search",
|
|
885
|
+
method: "run",
|
|
886
|
+
action: "archive.search.run",
|
|
887
|
+
summary: "\u6309\u5173\u952E\u8BCD\u5168\u6587\u68C0\u7D22\u6863\u6848\uFF08\u53EF\u501F\u6863\u6848\u5217\u8868\uFF09\uFF0C\u652F\u6301\u5206\u9875\uFF1B\u6BCF\u884C\u9664\u539F\u59CB\u5B57\u6BB5\u5916\u4F1A\u9644\u5E26 level/fonds/category/dateLabel/dateValue/viewPath \u5C55\u793A\u5B57\u6BB5\uFF0C\u7ED3\u679C\u884C\u7684 id \u4E0E formId \u7528\u4E8E\u52A0\u5165\u501F\u9605\u8F66\u3001\u53D1\u8D77\u501F\u9605\u6216\u62FC\u63A5 archiveView \u94FE\u63A5",
|
|
888
|
+
capability: "search",
|
|
889
|
+
risk: READ,
|
|
890
|
+
inputSchema: schemaOf(
|
|
891
|
+
{
|
|
892
|
+
key: { type: "string", minLength: 1, description: "\u641C\u7D22\u5173\u952E\u8BCD\uFF08\u5FC5\u586B\uFF09" },
|
|
893
|
+
pageNo: { type: "integer", minimum: 0, description: "\u9875\u7801\uFF0C\u4ECE 0 \u5F00\u59CB\uFF0C\u9ED8\u8BA4 0" },
|
|
894
|
+
pageSize: { type: "integer", minimum: 1, maximum: 100, description: "\u6BCF\u9875\u6761\u6570\uFF0C\u9ED8\u8BA4 10" },
|
|
895
|
+
type1: { type: "string", description: "\u68C0\u7D22\u8303\u56F4\u4E00\u7EA7\u5206\u7C7B\uFF0C\u7F3A\u7701 0=\u5168\u90E8\u8303\u56F4" },
|
|
896
|
+
type2: { type: "string", description: "\u68C0\u7D22\u8303\u56F4\u4E8C\u7EA7\u5206\u7C7B\uFF0C\u7F3A\u7701 0=\u5168\u90E8\u8303\u56F4" }
|
|
897
|
+
},
|
|
898
|
+
{ required: ["key"], description: "\u5168\u6587\u68C0\u7D22\u6863\u6848\uFF08\u7F3A\u7701\u5728\u5168\u90E8\u8303\u56F4\u5185\u68C0\u7D22\uFF09" }
|
|
899
|
+
),
|
|
900
|
+
handler: async (args, { host }) => {
|
|
901
|
+
const key = requireText(args.key, "key");
|
|
902
|
+
const pageNo = args.pageNo === void 0 ? 0 : Number(args.pageNo);
|
|
903
|
+
const pageSize = args.pageSize === void 0 ? 10 : Number(args.pageSize);
|
|
904
|
+
const body = { key, pageNo, pageSize, type1: "0", type2: "0" };
|
|
905
|
+
if (args.type1 !== void 0) body.type1 = String(args.type1);
|
|
906
|
+
if (args.type2 !== void 0) body.type2 = String(args.type2);
|
|
907
|
+
const response = await host.request({
|
|
908
|
+
method: "POST",
|
|
909
|
+
path: "/api/archive/core/fullSearch/searchByModule",
|
|
910
|
+
body
|
|
911
|
+
});
|
|
912
|
+
const data = unwrapData(response);
|
|
913
|
+
if (!data || typeof data !== "object") {
|
|
914
|
+
throw archiveValidationError("search_invalid", "\u5168\u6587\u68C0\u7D22\u8FD4\u56DE\u5F02\u5E38\uFF1Adata \u7F3A\u5931");
|
|
915
|
+
}
|
|
916
|
+
const result = data;
|
|
917
|
+
const rows = Array.isArray(result.archiveResult) ? result.archiveResult : [];
|
|
918
|
+
return archiveSuccess(
|
|
919
|
+
"archive.search.run",
|
|
920
|
+
rows.map((item) => {
|
|
921
|
+
const row = {
|
|
922
|
+
id: item.id,
|
|
923
|
+
formId: parseFormId(item.module) ?? parseFormId(item.showModule) ?? void 0,
|
|
924
|
+
title: String(item.title ?? ""),
|
|
925
|
+
content: item.content ?? "",
|
|
926
|
+
highLightContent: item.highLightContent ?? "",
|
|
927
|
+
module: item.module,
|
|
928
|
+
footInfo: item.footInfo,
|
|
929
|
+
headList: item.archiveMess?.headList ?? [],
|
|
930
|
+
footList: item.archiveMess?.footList ?? [],
|
|
931
|
+
createTime: item.createTime ?? ""
|
|
932
|
+
};
|
|
933
|
+
const view = toSearchRowView(row);
|
|
934
|
+
return {
|
|
935
|
+
...row,
|
|
936
|
+
...row.title ? {} : view.title ? { title: view.title } : {},
|
|
937
|
+
level: view.level,
|
|
938
|
+
fonds: view.fonds,
|
|
939
|
+
category: view.category,
|
|
940
|
+
dateLabel: view.dateLabel,
|
|
941
|
+
dateValue: view.dateValue,
|
|
942
|
+
viewPath: view.viewPath
|
|
943
|
+
};
|
|
944
|
+
}),
|
|
945
|
+
{
|
|
946
|
+
pageNo: result.pageNo ?? pageNo,
|
|
947
|
+
pageSize: result.pageSize ?? pageSize,
|
|
948
|
+
total: result.total ?? 0,
|
|
949
|
+
totalPage: result.totalPage ?? 0,
|
|
950
|
+
hasNext: Boolean(result.hasNext),
|
|
951
|
+
keyword: result.keyword ?? key
|
|
952
|
+
}
|
|
953
|
+
);
|
|
954
|
+
}
|
|
955
|
+
};
|
|
956
|
+
var searchOperations = [searchRun];
|
|
957
|
+
|
|
958
|
+
// src/shortcuts/archive/operations/getPageUrl.ts
|
|
959
|
+
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
960
|
+
var ARCHIVE_APP_TAG = "archive_wsd";
|
|
961
|
+
var BORROW_CAR_TAG = "uf_arc_borrow_car";
|
|
962
|
+
var BORROWING_TAG = "uf_arc_borrowing";
|
|
963
|
+
function asRecordArray(value) {
|
|
964
|
+
return Array.isArray(value) ? value.filter((item) => item && typeof item === "object") : [];
|
|
965
|
+
}
|
|
966
|
+
function firstText(value) {
|
|
967
|
+
if (typeof value === "string") return value.trim();
|
|
968
|
+
if (typeof value === "number") return String(value);
|
|
969
|
+
return "";
|
|
970
|
+
}
|
|
971
|
+
async function fetchAppId(host) {
|
|
972
|
+
const response = await host.request({
|
|
973
|
+
method: "GET",
|
|
974
|
+
path: "/api/bs/ebuilder/app/tags/getAppIds",
|
|
975
|
+
query: { tag: ARCHIVE_APP_TAG }
|
|
976
|
+
});
|
|
977
|
+
const data = unwrapData(response);
|
|
978
|
+
const first = Array.isArray(data) ? data[0] : void 0;
|
|
979
|
+
const appId = firstText(first && typeof first === "object" ? first.id : first);
|
|
980
|
+
if (!appId) throw archiveValidationError("app_id_missing", `\u672A\u53D6\u5230\u6863\u6848\u5E94\u7528 ID\uFF08tag=${ARCHIVE_APP_TAG}\uFF09`);
|
|
981
|
+
return appId;
|
|
982
|
+
}
|
|
983
|
+
async function fetchObjId(host, tag, appId) {
|
|
984
|
+
const response = await host.request({
|
|
985
|
+
method: "GET",
|
|
986
|
+
path: "/api/ebuilder/form/obj/getObjsByTag",
|
|
987
|
+
query: { tag, appId }
|
|
988
|
+
});
|
|
989
|
+
const data = unwrapData(response);
|
|
990
|
+
const first = Array.isArray(data) ? data[0] : void 0;
|
|
991
|
+
const objId = firstText(first && typeof first === "object" ? first.id : void 0);
|
|
992
|
+
if (!objId) throw archiveValidationError("form_obj_missing", `\u672A\u53D6\u5230\u8868\u5355\u5BF9\u8C61 ID\uFF08tag=${tag}\uFF09`);
|
|
993
|
+
return objId;
|
|
994
|
+
}
|
|
995
|
+
function viewIdFromUrl(url) {
|
|
996
|
+
if (typeof url !== "string") return void 0;
|
|
997
|
+
const matched = url.match(/\/(\d+)\s*$/u);
|
|
998
|
+
return matched?.[1];
|
|
999
|
+
}
|
|
1000
|
+
async function fetchViewId(host, objId, appId, viewMode) {
|
|
1001
|
+
const response = await host.request({
|
|
1002
|
+
method: "GET",
|
|
1003
|
+
path: `/api/ebuilder/form/fs/viewlist/getViewlist/${objId}`,
|
|
1004
|
+
query: { apid: appId, tpaid: objId }
|
|
1005
|
+
});
|
|
1006
|
+
const data = unwrapData(response);
|
|
1007
|
+
const views = asRecordArray(data?.tableView?.detail);
|
|
1008
|
+
if (views.length === 0) throw archiveValidationError("view_missing", "\u672A\u53D6\u5230\u5217\u8868\u89C6\u56FE\u914D\u7F6E");
|
|
1009
|
+
if (viewMode === "myBorrow") {
|
|
1010
|
+
const matched = views.find((view) => String(view.name ?? "") === "\u6211\u7684\u501F\u9605");
|
|
1011
|
+
if (!matched) throw archiveValidationError("view_missing", "\u672A\u627E\u5230\u300C\u6211\u7684\u501F\u9605\u300D\u89C6\u56FE\uFF0C\u65E0\u6CD5\u56DE\u9000\u67E5\u8BE2\u501F\u9605\u5355\u5217\u8868");
|
|
1012
|
+
return firstText(matched.id);
|
|
1013
|
+
}
|
|
1014
|
+
const defaultView = views.find((view) => String(view.isDefault ?? "") === "1") ?? views[0];
|
|
1015
|
+
return firstText(defaultView.id);
|
|
1016
|
+
}
|
|
1017
|
+
async function resolveArchiveListTarget(host, options) {
|
|
1018
|
+
const viewMode = options.viewMode ?? "default";
|
|
1019
|
+
let appId = "";
|
|
1020
|
+
let viewId;
|
|
1021
|
+
try {
|
|
1022
|
+
const response = await host.request({
|
|
1023
|
+
method: "POST",
|
|
1024
|
+
path: "/api/archive/core/form/getPageUrl",
|
|
1025
|
+
query: { terminalType: "pc", type: "1", sign: options.sign }
|
|
1026
|
+
});
|
|
1027
|
+
const data = unwrapData(response);
|
|
1028
|
+
appId = firstText(data?.appId);
|
|
1029
|
+
viewId = viewIdFromUrl(data?.url);
|
|
1030
|
+
} catch {
|
|
1031
|
+
}
|
|
1032
|
+
if (!appId) appId = await fetchAppId(host);
|
|
1033
|
+
const objId = await fetchObjId(host, options.sign, appId);
|
|
1034
|
+
if (!viewId) {
|
|
1035
|
+
return { appId, objId, viewId: await fetchViewId(host, objId, appId, viewMode), viewSource: "getViewlist" };
|
|
1036
|
+
}
|
|
1037
|
+
return { appId, objId, viewId, viewSource: "getPageUrl" };
|
|
1038
|
+
}
|
|
1039
|
+
async function fetchArchiveListDatas(host, target, pageNo, logFlag) {
|
|
1040
|
+
const current = Number.isInteger(pageNo) && pageNo > 0 ? pageNo : 1;
|
|
1041
|
+
const body = {
|
|
1042
|
+
current,
|
|
1043
|
+
listId: target.viewId,
|
|
1044
|
+
searchParamData: { searchType: "2", type: "and", commonSearchFields: {}, groupFields: {} },
|
|
1045
|
+
requiredMatch: 1,
|
|
1046
|
+
tableuid: randomBytes2(16).toString("hex"),
|
|
1047
|
+
mapResult: "1",
|
|
1048
|
+
recheckQuery: "1",
|
|
1049
|
+
isFollow: 0,
|
|
1050
|
+
isShareToMe: 0,
|
|
1051
|
+
filterCondition: {},
|
|
1052
|
+
browser: "Chrome"
|
|
1053
|
+
};
|
|
1054
|
+
if (logFlag) body.logFlag = logFlag;
|
|
1055
|
+
const response = await host.request({
|
|
1056
|
+
method: "POST",
|
|
1057
|
+
path: "/api/ebuilder/form/list/getListDatas",
|
|
1058
|
+
query: { passid: target.objId, cid: target.objId },
|
|
1059
|
+
body
|
|
1060
|
+
});
|
|
1061
|
+
const data = unwrapData(response);
|
|
1062
|
+
const pageSize = data?.pageSize === void 0 ? void 0 : Number(data.pageSize);
|
|
1063
|
+
const total = data?.total === void 0 ? void 0 : Number(data.total);
|
|
1064
|
+
return {
|
|
1065
|
+
columns: asRecordArray(data?.columns),
|
|
1066
|
+
rows: asRecordArray(data?.data),
|
|
1067
|
+
displayRows: asRecordArray(data?.displayData),
|
|
1068
|
+
pageNo: Number(data?.current ?? current),
|
|
1069
|
+
...pageSize === void 0 ? {} : { pageSize },
|
|
1070
|
+
// getPageUrl 视图下 total 可能为 0,但 data 数组仍有完整数据,因此只作参考
|
|
1071
|
+
...total === void 0 ? {} : { total }
|
|
1072
|
+
};
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
// src/shortcuts/archive/operations/borrow-car.ts
|
|
1076
|
+
var CAR_ADD = "archive.borrow-car.add";
|
|
1077
|
+
function namesOf(value) {
|
|
1078
|
+
if (!Array.isArray(value)) return [];
|
|
1079
|
+
return value.map((item) => item && typeof item === "object" ? String(item.name ?? "") : "").filter((name) => name !== "");
|
|
1080
|
+
}
|
|
1081
|
+
function normalizeBorrowCarRow(mainTable, index) {
|
|
1082
|
+
const row = mainTable && typeof mainTable === "object" ? mainTable : {};
|
|
1083
|
+
const arcDangan = Array.isArray(row.arc_dangan) ? row.arc_dangan.filter((item) => item && typeof item === "object").map((item) => ({ name: String(item.name ?? ""), id: String(item.id ?? "") })) : [];
|
|
1084
|
+
return {
|
|
1085
|
+
index: index + 1,
|
|
1086
|
+
dataId: String(row.id ?? ""),
|
|
1087
|
+
title: String(row.folder_title ?? ""),
|
|
1088
|
+
className: String(row.class_name ?? ""),
|
|
1089
|
+
archivalCode: String(row.archival_code ?? ""),
|
|
1090
|
+
fondsCode: String(row.fonds_code ?? ""),
|
|
1091
|
+
categoryNames: namesOf(row.category_code),
|
|
1092
|
+
fileDate: String(row.file_date ?? ""),
|
|
1093
|
+
retentionPeriod: String(row.retention_period ?? ""),
|
|
1094
|
+
state: String(row.state ?? ""),
|
|
1095
|
+
arcDangan
|
|
1096
|
+
};
|
|
1097
|
+
}
|
|
1098
|
+
async function listByCustomApi(host, operator, pageNo, pageSize) {
|
|
1099
|
+
try {
|
|
1100
|
+
const response = await host.request({
|
|
1101
|
+
method: "POST",
|
|
1102
|
+
path: "/api/ebuilder/form/formdata/v2/getFormDataList/myBorrowCar",
|
|
1103
|
+
body: {
|
|
1104
|
+
datajson: {
|
|
1105
|
+
mainTable: {},
|
|
1106
|
+
pageInfo: { pageNo: String(pageNo), pageSize: String(pageSize) },
|
|
1107
|
+
header: { operator }
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
});
|
|
1111
|
+
const box = unwrapDatajson(response);
|
|
1112
|
+
const datas = Array.isArray(box?.datas) ? box.datas : [];
|
|
1113
|
+
const rows = datas.map(
|
|
1114
|
+
(item, index) => normalizeBorrowCarRow(item && typeof item === "object" ? item.mainTable : void 0, index)
|
|
1115
|
+
);
|
|
1116
|
+
return { count: rows.length, rows };
|
|
1117
|
+
} catch (error) {
|
|
1118
|
+
if (error instanceof ArchiveCliError && error.type === "api") return null;
|
|
1119
|
+
throw error;
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
var borrowCarList = {
|
|
1123
|
+
name: "archive.borrow-car.list",
|
|
1124
|
+
resource: "borrow-car",
|
|
1125
|
+
method: "list",
|
|
1126
|
+
action: "archive.borrow-car.list",
|
|
1127
|
+
summary: "\u67E5\u8BE2\u5F53\u524D\u7528\u6237\u7684\u501F\u9605\u8F66\u5217\u8868\uFF1B\u4F18\u5148\u81EA\u5B9A\u4E49\u63A5\u53E3 myBorrowCar\uFF0C\u4E0D\u53EF\u7528\u65F6\u56DE\u9000 ebuilder \u5217\u8868\u94FE\u8DEF\uFF08getPageUrl \u2192 getListDatas\uFF09",
|
|
1128
|
+
capability: "archive",
|
|
1129
|
+
risk: READ,
|
|
1130
|
+
inputSchema: schemaOf({
|
|
1131
|
+
pageNo: { type: "integer", minimum: 1, description: "\u9875\u7801\uFF0C\u9ED8\u8BA4 1" },
|
|
1132
|
+
pageSize: { type: "integer", minimum: 1, description: "\u6BCF\u9875\u6761\u6570\uFF0C\u9ED8\u8BA4 10" }
|
|
1133
|
+
}),
|
|
1134
|
+
handler: async (args, { host }) => {
|
|
1135
|
+
const pageNo = positiveInt(args.pageNo, "pageNo", 1);
|
|
1136
|
+
const pageSize = positiveInt(args.pageSize, "pageSize", 10);
|
|
1137
|
+
const session = await host.getSession();
|
|
1138
|
+
const custom = await listByCustomApi(host, session.userId, pageNo, pageSize);
|
|
1139
|
+
if (custom) {
|
|
1140
|
+
return archiveSuccess(
|
|
1141
|
+
"archive.borrow-car.list",
|
|
1142
|
+
{ source: "myBorrowCar", pageNo, pageSize, count: custom.count, rows: custom.rows },
|
|
1143
|
+
{ source: "myBorrowCar" }
|
|
1144
|
+
);
|
|
1145
|
+
}
|
|
1146
|
+
const target = await resolveArchiveListTarget(host, { sign: BORROW_CAR_TAG, viewMode: "default" });
|
|
1147
|
+
const page = await fetchArchiveListDatas(host, target, pageNo, "borrowCart");
|
|
1148
|
+
const rows = page.rows.map((row, index) => ({
|
|
1149
|
+
index: index + 1,
|
|
1150
|
+
dataId: String(row.id ?? ""),
|
|
1151
|
+
fields: row,
|
|
1152
|
+
...page.displayRows[index] ? { display: page.displayRows[index] } : {}
|
|
1153
|
+
}));
|
|
1154
|
+
return archiveSuccess(
|
|
1155
|
+
"archive.borrow-car.list",
|
|
1156
|
+
{ source: "ebuilder", pageNo: page.pageNo, count: rows.length, rows },
|
|
1157
|
+
{ source: "ebuilder", viewSource: target.viewSource }
|
|
1158
|
+
);
|
|
1159
|
+
}
|
|
1160
|
+
};
|
|
1161
|
+
function parseFormAndIds(value) {
|
|
1162
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
1163
|
+
throw archiveValidationError("form_and_ids_required", "formAndIds \u5FC5\u586B\u4E14\u81F3\u5C11\u4E00\u7EC4");
|
|
1164
|
+
}
|
|
1165
|
+
return value.map((item, index) => {
|
|
1166
|
+
if (!item || typeof item !== "object") {
|
|
1167
|
+
throw archiveValidationError("form_and_ids_invalid", `formAndIds[${index}] \u5FC5\u987B\u662F\u5BF9\u8C61`);
|
|
1168
|
+
}
|
|
1169
|
+
const group = item;
|
|
1170
|
+
const formId = toStringId(group.formId, `formAndIds[${index}].formId`);
|
|
1171
|
+
const ids = toStringIdList(group.ids, `formAndIds[${index}].ids`);
|
|
1172
|
+
if (!formId) throw archiveValidationError("form_id_required", `formAndIds[${index}].formId \u5FC5\u586B`);
|
|
1173
|
+
if (!ids || ids.length === 0) throw archiveValidationError("ids_required", `formAndIds[${index}].ids \u81F3\u5C11\u4E00\u9879`);
|
|
1174
|
+
return { formId, ids };
|
|
1175
|
+
});
|
|
1176
|
+
}
|
|
1177
|
+
var borrowCarAdd = {
|
|
1178
|
+
name: CAR_ADD,
|
|
1179
|
+
resource: "borrow-car",
|
|
1180
|
+
method: "add",
|
|
1181
|
+
action: CAR_ADD,
|
|
1182
|
+
summary: "\u52A0\u5165\u501F\u9605\u8F66\uFF08\u5199\u64CD\u4F5C\uFF0C\u65E0\u9700\u786E\u8BA4\uFF09\uFF1A\u628A\u6863\u6848\u76F4\u63A5\u52A0\u5165\u5F53\u524D\u7528\u6237\u501F\u9605\u8F66",
|
|
1183
|
+
capability: "archive",
|
|
1184
|
+
risk: WRITE,
|
|
1185
|
+
inputSchema: schemaOf(
|
|
1186
|
+
{
|
|
1187
|
+
formAndIds: {
|
|
1188
|
+
type: "array",
|
|
1189
|
+
minItems: 1,
|
|
1190
|
+
description: "\u6309\u8868\u5355\u5206\u7EC4\uFF1A[{ formId, ids: [\u6863\u6848ID...] }]",
|
|
1191
|
+
items: {
|
|
1192
|
+
type: "object",
|
|
1193
|
+
properties: { formId: { type: "string" }, ids: { type: "array", items: { type: "string" } } },
|
|
1194
|
+
required: ["formId", "ids"]
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
},
|
|
1198
|
+
{ required: ["formAndIds"], description: "\u52A0\u5165\u501F\u9605\u8F66" }
|
|
1199
|
+
),
|
|
1200
|
+
handler: async (args, env) => {
|
|
1201
|
+
const formAndIds = parseFormAndIds(args.formAndIds);
|
|
1202
|
+
const response = await env.host.request({
|
|
1203
|
+
method: "POST",
|
|
1204
|
+
path: "/api/archive/core/borrow/addBorrowCar",
|
|
1205
|
+
body: { formAndIds, logFlag: "archiveSet" }
|
|
1206
|
+
});
|
|
1207
|
+
const total = formAndIds.reduce(
|
|
1208
|
+
(sum, group) => sum + group.ids.length,
|
|
1209
|
+
0
|
|
1210
|
+
);
|
|
1211
|
+
return archiveSuccess(
|
|
1212
|
+
CAR_ADD,
|
|
1213
|
+
{ accepted: true, groups: formAndIds.length, total, message: response ?? "\u5DF2\u52A0\u5165\u501F\u9605\u8F66" },
|
|
1214
|
+
{ wrote: true }
|
|
1215
|
+
);
|
|
1216
|
+
}
|
|
1217
|
+
};
|
|
1218
|
+
var borrowCarOperations = [borrowCarList, borrowCarAdd];
|
|
1219
|
+
|
|
1220
|
+
// src/shortcuts/archive/operations/borrow-list.ts
|
|
1221
|
+
function textOrName(value) {
|
|
1222
|
+
if (Array.isArray(value)) {
|
|
1223
|
+
const first = value.find((item) => item !== void 0 && item !== null);
|
|
1224
|
+
if (first === void 0) return "";
|
|
1225
|
+
if (first && typeof first === "object") {
|
|
1226
|
+
const record = first;
|
|
1227
|
+
return String(record.name ?? record.id ?? "");
|
|
1228
|
+
}
|
|
1229
|
+
return String(first);
|
|
1230
|
+
}
|
|
1231
|
+
if (value === void 0 || value === null) return "";
|
|
1232
|
+
if (typeof value === "object") {
|
|
1233
|
+
const record = value;
|
|
1234
|
+
return String(record.name ?? record.id ?? "");
|
|
1235
|
+
}
|
|
1236
|
+
return String(value);
|
|
1237
|
+
}
|
|
1238
|
+
function idOf(value) {
|
|
1239
|
+
if (Array.isArray(value)) {
|
|
1240
|
+
const first = value.find((item) => item !== void 0 && item !== null);
|
|
1241
|
+
if (first === void 0) return "";
|
|
1242
|
+
if (first && typeof first === "object") return String(first.id ?? "");
|
|
1243
|
+
return String(first);
|
|
1244
|
+
}
|
|
1245
|
+
if (value === void 0 || value === null) return "";
|
|
1246
|
+
if (typeof value === "object") return String(value.id ?? "");
|
|
1247
|
+
return String(value);
|
|
1248
|
+
}
|
|
1249
|
+
function entriesOf(value) {
|
|
1250
|
+
if (!Array.isArray(value)) return [];
|
|
1251
|
+
return value.filter((item) => item && typeof item === "object").map((item) => {
|
|
1252
|
+
const record = item;
|
|
1253
|
+
return { name: String(record.name ?? ""), id: String(record.id ?? "") };
|
|
1254
|
+
});
|
|
1255
|
+
}
|
|
1256
|
+
function parseDateTime(value) {
|
|
1257
|
+
const text = typeof value === "string" ? value.trim() : "";
|
|
1258
|
+
if (!text) return void 0;
|
|
1259
|
+
const normalized = text.includes("T") ? text : text.replace(" ", "T");
|
|
1260
|
+
const parsed = Date.parse(normalized);
|
|
1261
|
+
return Number.isNaN(parsed) ? void 0 : parsed;
|
|
1262
|
+
}
|
|
1263
|
+
function isExpired(returnDateTime, now = Date.now()) {
|
|
1264
|
+
const due = parseDateTime(returnDateTime);
|
|
1265
|
+
return due === void 0 ? false : now > due;
|
|
1266
|
+
}
|
|
1267
|
+
function normalizeBorrowListRow(mainTable, index) {
|
|
1268
|
+
const row = mainTable && typeof mainTable === "object" ? mainTable : {};
|
|
1269
|
+
return {
|
|
1270
|
+
index: index + 1,
|
|
1271
|
+
dataId: String(row.id ?? ""),
|
|
1272
|
+
name: String(row.name ?? ""),
|
|
1273
|
+
borrowDateTime: String(row.borrow_date_time ?? ""),
|
|
1274
|
+
returnDateTime: String(row.return_date_time ?? ""),
|
|
1275
|
+
reason: String(row.reason ?? ""),
|
|
1276
|
+
backStatus: String(row.back_status ?? ""),
|
|
1277
|
+
returnStatus: String(row.return_status ?? ""),
|
|
1278
|
+
waterMark: String(row.water_mark ?? ""),
|
|
1279
|
+
workflowId: idOf(row.workflow_id),
|
|
1280
|
+
workflowName: Array.isArray(row.workflow_id) ? textOrName(row.workflow_id) : "",
|
|
1281
|
+
borrowPerson: textOrName(row.borrow_person),
|
|
1282
|
+
state: String(row.data_status ?? ""),
|
|
1283
|
+
createTime: String(row.create_time ?? ""),
|
|
1284
|
+
updateTime: String(row.update_time ?? ""),
|
|
1285
|
+
expired: isExpired(row.return_date_time)
|
|
1286
|
+
};
|
|
1287
|
+
}
|
|
1288
|
+
async function listByCustomApi2(host, operator, pageNo, pageSize) {
|
|
1289
|
+
try {
|
|
1290
|
+
const response = await host.request({
|
|
1291
|
+
method: "POST",
|
|
1292
|
+
path: "/api/ebuilder/form/formdata/v2/getFormDataList/myBorrowList",
|
|
1293
|
+
body: {
|
|
1294
|
+
datajson: {
|
|
1295
|
+
mainTable: {},
|
|
1296
|
+
pageInfo: { pageNo: String(pageNo), pageSize: String(pageSize) },
|
|
1297
|
+
header: { operator }
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
});
|
|
1301
|
+
const box = unwrapDatajson(response);
|
|
1302
|
+
const datas = Array.isArray(box?.datas) ? box.datas : [];
|
|
1303
|
+
const rows = datas.map(
|
|
1304
|
+
(item, index) => normalizeBorrowListRow(item && typeof item === "object" ? item.mainTable : void 0, index)
|
|
1305
|
+
);
|
|
1306
|
+
return { count: rows.length, rows };
|
|
1307
|
+
} catch (error) {
|
|
1308
|
+
if (error instanceof ArchiveCliError && error.type === "api") return null;
|
|
1309
|
+
throw error;
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
var borrowListList = {
|
|
1313
|
+
name: "archive.borrow-list.list",
|
|
1314
|
+
resource: "borrow-list",
|
|
1315
|
+
method: "list",
|
|
1316
|
+
action: "archive.borrow-list.list",
|
|
1317
|
+
summary: "\u67E5\u8BE2\u5F53\u524D\u7528\u6237\u7684\u501F\u9605\u5355\u5217\u8868\uFF1B\u4F18\u5148\u81EA\u5B9A\u4E49\u63A5\u53E3 myBorrowList\uFF0C\u4E0D\u53EF\u7528\u65F6\u56DE\u9000\u300C\u6211\u7684\u501F\u9605\u300D\u89C6\u56FE\u94FE\u8DEF",
|
|
1318
|
+
capability: "archive",
|
|
1319
|
+
risk: READ,
|
|
1320
|
+
inputSchema: schemaOf({
|
|
1321
|
+
pageNo: { type: "integer", minimum: 1, description: "\u9875\u7801\uFF0C\u9ED8\u8BA4 1" },
|
|
1322
|
+
pageSize: { type: "integer", minimum: 1, description: "\u6BCF\u9875\u6761\u6570\uFF0C\u9ED8\u8BA4 10" }
|
|
1323
|
+
}),
|
|
1324
|
+
handler: async (args, { host }) => {
|
|
1325
|
+
const pageNo = positiveInt(args.pageNo, "pageNo", 1);
|
|
1326
|
+
const pageSize = positiveInt(args.pageSize, "pageSize", 10);
|
|
1327
|
+
const session = await host.getSession();
|
|
1328
|
+
const custom = await listByCustomApi2(host, session.userId, pageNo, pageSize);
|
|
1329
|
+
if (custom) {
|
|
1330
|
+
return archiveSuccess(
|
|
1331
|
+
"archive.borrow-list.list",
|
|
1332
|
+
{ source: "myBorrowList", pageNo, pageSize, count: custom.count, rows: custom.rows },
|
|
1333
|
+
{ source: "myBorrowList" }
|
|
1334
|
+
);
|
|
1335
|
+
}
|
|
1336
|
+
const target = await resolveArchiveListTarget(host, { sign: BORROWING_TAG, viewMode: "myBorrow" });
|
|
1337
|
+
const page = await fetchArchiveListDatas(host, target, pageNo);
|
|
1338
|
+
const rows = page.rows.map((row, index) => ({
|
|
1339
|
+
index: index + 1,
|
|
1340
|
+
dataId: String(row.id ?? ""),
|
|
1341
|
+
fields: row,
|
|
1342
|
+
...page.displayRows[index] ? { display: page.displayRows[index] } : {}
|
|
1343
|
+
}));
|
|
1344
|
+
return archiveSuccess(
|
|
1345
|
+
"archive.borrow-list.list",
|
|
1346
|
+
{ source: "ebuilder", pageNo: page.pageNo, count: rows.length, rows },
|
|
1347
|
+
{ source: "ebuilder", viewSource: target.viewSource }
|
|
1348
|
+
);
|
|
1349
|
+
}
|
|
1350
|
+
};
|
|
1351
|
+
async function fetchBorrowDetail(host, operator, dataId) {
|
|
1352
|
+
const response = await host.request({
|
|
1353
|
+
method: "POST",
|
|
1354
|
+
path: "/api/ebuilder/form/formdata/v2/getFormDataByPk/myBorrowDetail",
|
|
1355
|
+
body: { datajson: { mainTable: { id: dataId }, header: { operator } } }
|
|
1356
|
+
});
|
|
1357
|
+
const box = unwrapDatajson(response);
|
|
1358
|
+
const datas = Array.isArray(box?.datas) ? box.datas : [];
|
|
1359
|
+
if (datas.length === 0) {
|
|
1360
|
+
throw archiveValidationError("borrow_not_found", `\u672A\u627E\u5230\u501F\u9605\u5355\uFF08dataId=${dataId}\uFF09`);
|
|
1361
|
+
}
|
|
1362
|
+
const record = datas[0] && typeof datas[0] === "object" ? datas[0] : {};
|
|
1363
|
+
const mainTable = record.mainTable && typeof record.mainTable === "object" ? record.mainTable : {};
|
|
1364
|
+
const details = (Array.isArray(record.detail1) ? record.detail1 : []).map((item) => {
|
|
1365
|
+
const detail = item && typeof item === "object" ? item : {};
|
|
1366
|
+
return {
|
|
1367
|
+
id: String(detail.id ?? ""),
|
|
1368
|
+
arcDangan: entriesOf(detail.arc_dangan),
|
|
1369
|
+
archivalCode: String(detail.archival_code ?? ""),
|
|
1370
|
+
fondsCode: String(detail.fonds_code ?? ""),
|
|
1371
|
+
fileDate: String(detail.file_date ?? ""),
|
|
1372
|
+
borrowTypes: entriesOf(detail.borrow_type)
|
|
1373
|
+
};
|
|
1374
|
+
});
|
|
1375
|
+
return {
|
|
1376
|
+
dataId: String(mainTable.id ?? dataId),
|
|
1377
|
+
name: String(mainTable.name ?? ""),
|
|
1378
|
+
borrowDateTime: String(mainTable.borrow_date_time ?? ""),
|
|
1379
|
+
returnDateTime: String(mainTable.return_date_time ?? ""),
|
|
1380
|
+
reason: String(mainTable.reason ?? ""),
|
|
1381
|
+
waterMark: String(mainTable.water_mark ?? ""),
|
|
1382
|
+
workflowId: idOf(mainTable.workflow_id),
|
|
1383
|
+
borrowPerson: textOrName(mainTable.borrow_person),
|
|
1384
|
+
state: String(mainTable.data_status ?? ""),
|
|
1385
|
+
expired: isExpired(mainTable.return_date_time),
|
|
1386
|
+
downloadable: details.some((detail) => detail.borrowTypes.some((type) => type.id === "2")),
|
|
1387
|
+
details
|
|
1388
|
+
};
|
|
1389
|
+
}
|
|
1390
|
+
var borrowListDetail = {
|
|
1391
|
+
name: "archive.borrow-list.detail",
|
|
1392
|
+
resource: "borrow-list",
|
|
1393
|
+
method: "detail",
|
|
1394
|
+
action: "archive.borrow-list.detail",
|
|
1395
|
+
summary: "\u67E5\u770B\u501F\u9605\u5355\u8BE6\u60C5\uFF08\u542B\u501F\u9605\u660E\u7EC6\u4E0E\u539F\u6587\u501F\u9605\u65B9\u5F0F\uFF09\uFF0C\u4E0B\u8F7D\u524D\u7684\u524D\u7F6E\u6821\u9A8C\u4E5F\u4F9D\u8D56\u672C\u63A5\u53E3",
|
|
1396
|
+
capability: "archive",
|
|
1397
|
+
risk: READ,
|
|
1398
|
+
inputSchema: schemaOf(
|
|
1399
|
+
{ dataId: { type: "string", pattern: "^\\d+$", description: "\u501F\u9605\u5355\u4E3B\u8868\u6570\u636E ID" } },
|
|
1400
|
+
{ required: ["dataId"], description: "\u501F\u9605\u5355\u8BE6\u60C5" }
|
|
1401
|
+
),
|
|
1402
|
+
handler: async (args, { host }) => {
|
|
1403
|
+
const dataId = args.dataId;
|
|
1404
|
+
if (dataId === void 0 || dataId === null || !/^\d+$/.test(String(dataId))) {
|
|
1405
|
+
throw archiveValidationError("data_id_invalid", "dataId \u5FC5\u586B\u4E14\u4E3A\u6570\u5B57 ID");
|
|
1406
|
+
}
|
|
1407
|
+
const session = await host.getSession();
|
|
1408
|
+
const detail = await fetchBorrowDetail(host, session.userId, String(dataId));
|
|
1409
|
+
return archiveSuccess("archive.borrow-list.detail", detail, { count: detail.details.length });
|
|
1410
|
+
}
|
|
1411
|
+
};
|
|
1412
|
+
var borrowListOperations = [borrowListList, borrowListDetail];
|
|
1413
|
+
|
|
1414
|
+
// src/shortcuts/archive/operations/download.ts
|
|
1415
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
1416
|
+
import { mkdir as mkdir2, writeFile as writeFile2 } from "node:fs/promises";
|
|
1417
|
+
import { homedir as homedir2 } from "node:os";
|
|
1418
|
+
import { basename, dirname, extname, resolve as resolve2 } from "node:path";
|
|
1419
|
+
|
|
1420
|
+
// src/shortcuts/archive/operations/confirm.ts
|
|
1421
|
+
function requireConfirm(args, action) {
|
|
1422
|
+
if (args.confirm !== true) {
|
|
1423
|
+
throw archiveConfirmationError(action, {
|
|
1424
|
+
hint: `\u6267\u884C ${action} \u5FC5\u987B\u663E\u5F0F\u786E\u8BA4\uFF1A\u4F20\u5165 confirm=true\uFF08CLI \u7528 --yes\uFF09`
|
|
1425
|
+
});
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
async function issueLease(env, action, payload, ttlMs = 10 * 6e4) {
|
|
1429
|
+
const session = await env.host.getSession();
|
|
1430
|
+
const continuation = await env.continuation.issue(
|
|
1431
|
+
{
|
|
1432
|
+
operation: action,
|
|
1433
|
+
baseUrl: session.baseUrl,
|
|
1434
|
+
userId: session.userId,
|
|
1435
|
+
...payload
|
|
1436
|
+
},
|
|
1437
|
+
ttlMs
|
|
1438
|
+
);
|
|
1439
|
+
return { continuation, expiresInMs: ttlMs };
|
|
1440
|
+
}
|
|
1441
|
+
async function verifyLease(args, action, env) {
|
|
1442
|
+
requireConfirm(args, action);
|
|
1443
|
+
if (typeof args.continuation !== "string" || !args.continuation.trim()) {
|
|
1444
|
+
throw archiveValidationError("continuation_required", `${action} \u5FC5\u987B\u4F20\u5165 prepare \u8FD4\u56DE\u7684 continuation`);
|
|
1445
|
+
}
|
|
1446
|
+
const lease = await env.continuation.verify(args.continuation.trim(), action);
|
|
1447
|
+
const session = await env.host.getSession();
|
|
1448
|
+
if (lease.baseUrl !== session.baseUrl || lease.userId !== session.userId) {
|
|
1449
|
+
throw archiveValidationError(
|
|
1450
|
+
"continuation_context_mismatch",
|
|
1451
|
+
"\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"
|
|
1452
|
+
);
|
|
1453
|
+
}
|
|
1454
|
+
return lease;
|
|
1455
|
+
}
|
|
1456
|
+
function assertLeaseTarget(lease, args, keys, action) {
|
|
1457
|
+
for (const key of keys) {
|
|
1458
|
+
if (args[key] === void 0 || args[key] === null || args[key] === "") continue;
|
|
1459
|
+
if (String(lease[key] ?? "") !== String(args[key])) {
|
|
1460
|
+
throw archiveValidationError(
|
|
1461
|
+
"continuation_target_changed",
|
|
1462
|
+
`${action} \u7684\u53C2\u6570 ${key} \u4E0E prepare \u65F6\u4E0D\u4E00\u81F4\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C prepare`
|
|
1463
|
+
);
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
// src/shortcuts/archive/operations/download.ts
|
|
1469
|
+
var DOWNLOAD_APPLY = "archive.borrow-list.download.apply";
|
|
1470
|
+
var EXPORT_TYPES = ["0", "1"];
|
|
1471
|
+
var EXPORT_STRUCTURES = ["", "0", "1", "2"];
|
|
1472
|
+
var GROUP_FIELDS = [
|
|
1473
|
+
"archival_code",
|
|
1474
|
+
"folder_title",
|
|
1475
|
+
"fonds_code",
|
|
1476
|
+
"arc_class_code",
|
|
1477
|
+
"category_code",
|
|
1478
|
+
"month",
|
|
1479
|
+
"year",
|
|
1480
|
+
"retention_period",
|
|
1481
|
+
"security_classificat",
|
|
1482
|
+
"owner_user",
|
|
1483
|
+
"owner_dept",
|
|
1484
|
+
"owner_company"
|
|
1485
|
+
];
|
|
1486
|
+
var POLL_INTERVAL_MS = 2e3;
|
|
1487
|
+
var POLL_MAX_ATTEMPTS = 150;
|
|
1488
|
+
function sleep(ms) {
|
|
1489
|
+
return new Promise((done) => {
|
|
1490
|
+
setTimeout(done, ms);
|
|
1491
|
+
});
|
|
1492
|
+
}
|
|
1493
|
+
function optionalText(value, field) {
|
|
1494
|
+
if (value === void 0 || value === null || value === "") return void 0;
|
|
1495
|
+
if (typeof value !== "string") {
|
|
1496
|
+
throw archiveValidationError("field_invalid", `${field} \u5FC5\u987B\u662F\u5B57\u7B26\u4E32`);
|
|
1497
|
+
}
|
|
1498
|
+
return value;
|
|
1499
|
+
}
|
|
1500
|
+
function parseExportParams(args) {
|
|
1501
|
+
const exportType = args.exportType === void 0 || args.exportType === null || args.exportType === "" ? "0" : String(args.exportType);
|
|
1502
|
+
if (!EXPORT_TYPES.includes(exportType)) {
|
|
1503
|
+
throw archiveValidationError("export_type_invalid", "exportType \u53EA\u80FD\u662F 0\uFF08\u76F4\u63A5\u5BFC\u51FA\uFF09\u6216 1\uFF08\u5206\u7EC4\u5BFC\u51FA\uFF09");
|
|
1504
|
+
}
|
|
1505
|
+
const exportStructure = optionalText(args.exportStructure, "exportStructure") ?? "";
|
|
1506
|
+
const groupField = optionalText(args.groupField, "groupField") ?? "";
|
|
1507
|
+
const documentField = optionalText(args.documentField, "documentField") ?? "";
|
|
1508
|
+
if (!EXPORT_STRUCTURES.includes(exportStructure)) {
|
|
1509
|
+
throw archiveValidationError("export_structure_invalid", "exportStructure \u53EA\u80FD\u662F\u7A7A\u30010\u30011\u30012");
|
|
1510
|
+
}
|
|
1511
|
+
if (exportType === "0" && (exportStructure !== "" || groupField !== "" || documentField !== "")) {
|
|
1512
|
+
throw archiveValidationError("export_params_conflict", "\u76F4\u63A5\u5BFC\u51FA\uFF08exportType=0\uFF09\u65F6\u5176\u4F59\u4E09\u4E2A\u5206\u7EC4\u5B57\u6BB5\u5FC5\u987B\u4E3A\u7A7A");
|
|
1513
|
+
}
|
|
1514
|
+
if (exportType === "1") {
|
|
1515
|
+
if (exportStructure === "") {
|
|
1516
|
+
throw archiveValidationError("export_structure_required", "\u5206\u7EC4\u5BFC\u51FA\uFF08exportType=1\uFF09\u65F6 exportStructure \u5FC5\u586B");
|
|
1517
|
+
}
|
|
1518
|
+
if (exportStructure === "0" && !groupField) {
|
|
1519
|
+
throw archiveValidationError("group_field_required", "\u6309\u6761\u76EE\u5BFC\u51FA\u65F6 groupField \u5FC5\u586B");
|
|
1520
|
+
}
|
|
1521
|
+
if (exportStructure === "1" && !documentField) {
|
|
1522
|
+
throw archiveValidationError("document_field_required", "\u6309\u539F\u6587\u5BFC\u51FA\u65F6 documentField \u5FC5\u586B");
|
|
1523
|
+
}
|
|
1524
|
+
if (exportStructure === "2" && (!groupField || !documentField)) {
|
|
1525
|
+
throw archiveValidationError("group_fields_required", "\u6309\u6761\u76EE+\u539F\u6587\u5BFC\u51FA\u65F6 groupField \u4E0E documentField \u5747\u5FC5\u586B");
|
|
1526
|
+
}
|
|
1527
|
+
for (const [field, value] of [["groupField", groupField], ["documentField", documentField]]) {
|
|
1528
|
+
if (value && !GROUP_FIELDS.includes(value)) {
|
|
1529
|
+
throw archiveValidationError("group_field_invalid", `${field} \u53D6\u503C\u4E0D\u5728\u6863\u6848\u57FA\u7840\u5B57\u6BB5\u5019\u9009\u5185`);
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
return { exportType, exportStructure, groupField, documentField };
|
|
1534
|
+
}
|
|
1535
|
+
async function assertDownloadable(host, operator, dataId) {
|
|
1536
|
+
const detail = await fetchBorrowDetail(host, operator, dataId);
|
|
1537
|
+
if (detail.expired) {
|
|
1538
|
+
throw archiveValidationError("borrow_expired", "\u501F\u9605\u5DF2\u8FC7\u671F\uFF0C\u65E0\u6743\u9650\u4E0B\u8F7D\uFF01");
|
|
1539
|
+
}
|
|
1540
|
+
if (!detail.downloadable) {
|
|
1541
|
+
throw archiveValidationError("borrow_no_downloadable", "\u8BE5\u501F\u9605\u5355\u6CA1\u6709\u53EF\u4E0B\u8F7D\u7684\u7535\u5B50\u539F\u6587\uFF0C\u65E0\u6743\u9650\u4E0B\u8F7D\uFF01");
|
|
1542
|
+
}
|
|
1543
|
+
if (!detail.workflowId) {
|
|
1544
|
+
throw archiveValidationError("workflow_id_missing", "\u501F\u9605\u5355\u7F3A\u5C11\u6D41\u7A0B requestId\uFF08workflow_id\uFF09\uFF0C\u65E0\u6CD5\u6253\u5305\u4E0B\u8F7D");
|
|
1545
|
+
}
|
|
1546
|
+
return { workflowId: detail.workflowId, returnDateTime: detail.returnDateTime };
|
|
1547
|
+
}
|
|
1548
|
+
function defaultDownloadDir() {
|
|
1549
|
+
return resolve2(homedir2(), "Downloads");
|
|
1550
|
+
}
|
|
1551
|
+
function resolveOutputPath(fileName, output) {
|
|
1552
|
+
const safeName = basename(String(fileName || "").replace(/[\\/]/g, "_")) || "borrow.zip";
|
|
1553
|
+
const target = output && String(output).trim() ? resolve2(String(output)) : resolve2(defaultDownloadDir(), safeName);
|
|
1554
|
+
let candidate = target;
|
|
1555
|
+
if (existsSync2(candidate)) {
|
|
1556
|
+
const ext = extname(safeName);
|
|
1557
|
+
const stem = ext ? safeName.slice(0, -ext.length) : safeName;
|
|
1558
|
+
for (let index = 1; index < 1e3; index += 1) {
|
|
1559
|
+
candidate = resolve2(dirname(target), `${stem} (${index})${ext}`);
|
|
1560
|
+
if (!existsSync2(candidate)) break;
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
return candidate;
|
|
1564
|
+
}
|
|
1565
|
+
var downloadPrepare = {
|
|
1566
|
+
name: "archive.borrow-list.download.prepare",
|
|
1567
|
+
resource: "borrow-list",
|
|
1568
|
+
method: "download",
|
|
1569
|
+
action: "archive.borrow-list.download.prepare",
|
|
1570
|
+
summary: "\u4E0B\u8F7D\u501F\u9605\u5355\u539F\u6587\u524D\u7684\u9884\u68C0\uFF1A\u6821\u9A8C\u672A\u8D85\u671F\u4E14\u5B58\u5728\u53EF\u4E0B\u8F7D\u539F\u6587\uFF0C\u5E76\u751F\u6210\u786E\u8BA4\u7968\u636E",
|
|
1571
|
+
capability: "archive",
|
|
1572
|
+
risk: READ,
|
|
1573
|
+
inputSchema: schemaOf(
|
|
1574
|
+
{
|
|
1575
|
+
dataId: { type: "string", pattern: "^\\d+$", description: "\u501F\u9605\u5355\u4E3B\u8868\u6570\u636E ID" },
|
|
1576
|
+
exportType: { type: "string", description: "0=\u76F4\u63A5\u5BFC\u51FA\uFF08\u9ED8\u8BA4\uFF09\uFF0C1=\u5206\u7EC4\u5BFC\u51FA" },
|
|
1577
|
+
exportStructure: { type: "string", description: "\u5206\u7EC4\u5BFC\u51FA\u7ED3\u6784\uFF1A0 \u6309\u6761\u76EE / 1 \u6309\u539F\u6587 / 2 \u6309\u6761\u76EE+\u539F\u6587" },
|
|
1578
|
+
groupField: { type: "string", description: "\u6761\u76EE\u5206\u7EC4\u5B57\u6BB5 ID" },
|
|
1579
|
+
documentField: { type: "string", description: "\u539F\u6587\u5206\u7EC4\u5B57\u6BB5 ID" },
|
|
1580
|
+
output: { type: "string", description: "\u53EF\u9009\uFF0Czip \u843D\u76D8\u8DEF\u5F84\uFF1B\u9ED8\u8BA4\u4FDD\u5B58\u5230\u7528\u6237\u300C\u4E0B\u8F7D\u300D\u76EE\u5F55" }
|
|
1581
|
+
},
|
|
1582
|
+
{ required: ["dataId"], description: "\u501F\u9605\u5355\u4E0B\u8F7D\u9884\u68C0" }
|
|
1583
|
+
),
|
|
1584
|
+
handler: async (args, env) => {
|
|
1585
|
+
const dataId = args.dataId;
|
|
1586
|
+
if (dataId === void 0 || dataId === null || !/^\d+$/.test(String(dataId))) {
|
|
1587
|
+
throw archiveValidationError("data_id_invalid", "dataId \u5FC5\u586B\u4E14\u4E3A\u6570\u5B57 ID");
|
|
1588
|
+
}
|
|
1589
|
+
const exportParams = parseExportParams(args);
|
|
1590
|
+
const session = await env.host.getSession();
|
|
1591
|
+
const { workflowId, returnDateTime } = await assertDownloadable(env.host, session.userId, String(dataId));
|
|
1592
|
+
const output = optionalText(args.output, "output");
|
|
1593
|
+
const { continuation, expiresInMs } = await issueLease(env, DOWNLOAD_APPLY, {
|
|
1594
|
+
dataId: String(dataId),
|
|
1595
|
+
requestId: workflowId,
|
|
1596
|
+
exportParams,
|
|
1597
|
+
...output ? { output } : {}
|
|
1598
|
+
});
|
|
1599
|
+
return archiveSuccess(
|
|
1600
|
+
"archive.borrow-list.download.prepare",
|
|
1601
|
+
{
|
|
1602
|
+
preview: {
|
|
1603
|
+
dataId: String(dataId),
|
|
1604
|
+
requestId: workflowId,
|
|
1605
|
+
returnDateTime,
|
|
1606
|
+
...exportParams,
|
|
1607
|
+
...output ? { output } : { outputDir: defaultDownloadDir() }
|
|
1608
|
+
},
|
|
1609
|
+
hint: "\u786E\u8BA4\u540E\u8C03\u7528 archive.borrow-list.download.apply\uFF08CLI\uFF1Aarchive borrow-list download-apply --continuation <token> --yes\uFF09",
|
|
1610
|
+
continuation
|
|
1611
|
+
},
|
|
1612
|
+
{ requiresConfirmation: true, expiresInMs }
|
|
1613
|
+
);
|
|
1614
|
+
}
|
|
1615
|
+
};
|
|
1616
|
+
async function pollExport(host, bizId) {
|
|
1617
|
+
const query = { moduleName: "archive", functionName: "downloadBorrowZip", bizId, flag: "export" };
|
|
1618
|
+
for (let attempt = 0; attempt < POLL_MAX_ATTEMPTS; attempt += 1) {
|
|
1619
|
+
await sleep(POLL_INTERVAL_MS);
|
|
1620
|
+
const response2 = await host.request({ method: "GET", path: "/api/ebatch/getImportOrExportRate", query });
|
|
1621
|
+
const percent = Number(unwrapData(response2));
|
|
1622
|
+
if (process.stderr.isTTY) {
|
|
1623
|
+
const value = Number.isFinite(percent) ? Math.max(0, Math.min(100, Math.round(percent))) : 0;
|
|
1624
|
+
process.stderr.write(`\r${"#".repeat(Math.floor(value / 2))} ${value}%`);
|
|
1625
|
+
}
|
|
1626
|
+
if (Number.isFinite(percent) && percent >= 100) break;
|
|
1627
|
+
}
|
|
1628
|
+
if (process.stderr.isTTY) process.stderr.write("\n");
|
|
1629
|
+
const response = await host.request({ method: "GET", path: "/api/ebatch/getImportOrExportRateNum", query });
|
|
1630
|
+
const data = unwrapData(response) ?? {};
|
|
1631
|
+
if (!data.fileId || data.status !== true) {
|
|
1632
|
+
throw new ArchiveCliError("api", "export_not_ready", "\u501F\u9605\u5355\u6253\u5305\u672A\u5B8C\u6210\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5", {
|
|
1633
|
+
details: { bizId, ...data.fileName ? { fileName: data.fileName } : {} },
|
|
1634
|
+
exitCode: 1
|
|
1635
|
+
});
|
|
1636
|
+
}
|
|
1637
|
+
return data;
|
|
1638
|
+
}
|
|
1639
|
+
var downloadApply = {
|
|
1640
|
+
name: DOWNLOAD_APPLY,
|
|
1641
|
+
resource: "borrow-list",
|
|
1642
|
+
method: "download",
|
|
1643
|
+
action: DOWNLOAD_APPLY,
|
|
1644
|
+
summary: "\u4E0B\u8F7D\u501F\u9605\u5355\u539F\u6587\uFF08\u5199\u64CD\u4F5C\uFF09\uFF1A\u63D0\u4EA4\u5F02\u6B65\u6253\u5305\u4EFB\u52A1 \u2192 \u8F6E\u8BE2\u8FDB\u5EA6 \u2192 \u4E0B\u8F7D zip \u5E76\u843D\u76D8",
|
|
1645
|
+
capability: "archive",
|
|
1646
|
+
risk: WRITE,
|
|
1647
|
+
requiresConfirmation: true,
|
|
1648
|
+
inputSchema: schemaOf(
|
|
1649
|
+
{
|
|
1650
|
+
continuation: { type: "string", description: "prepare \u8FD4\u56DE\u7684\u786E\u8BA4\u7968\u636E" },
|
|
1651
|
+
confirm: { type: "boolean", description: "\u5FC5\u987B\u4E3A true\uFF08CLI --yes\uFF09" },
|
|
1652
|
+
dataId: { type: "string", description: "\u53EF\u9009\u56DE\u4F20\uFF0C\u7528\u4E8E\u4E0E prepare \u5FEB\u7167\u6BD4\u5BF9" }
|
|
1653
|
+
},
|
|
1654
|
+
{ required: ["continuation", "confirm"], description: "\u4E0B\u8F7D\u501F\u9605\u5355\u539F\u6587" }
|
|
1655
|
+
),
|
|
1656
|
+
handler: async (args, env) => {
|
|
1657
|
+
const lease = await verifyLease(args, DOWNLOAD_APPLY, env);
|
|
1658
|
+
const dataId = String(lease.dataId ?? "");
|
|
1659
|
+
const requestId = String(lease.requestId ?? "");
|
|
1660
|
+
if (!dataId || !requestId) {
|
|
1661
|
+
throw archiveValidationError("continuation_payload_invalid", "\u786E\u8BA4\u7968\u636E\u7F3A\u5C11 dataId / requestId");
|
|
1662
|
+
}
|
|
1663
|
+
assertLeaseTarget(lease, args, ["dataId"], DOWNLOAD_APPLY);
|
|
1664
|
+
const exportParams = lease.exportParams ?? {};
|
|
1665
|
+
const session = await env.host.getSession();
|
|
1666
|
+
await assertDownloadable(env.host, session.userId, dataId);
|
|
1667
|
+
const submit = await env.host.request({
|
|
1668
|
+
method: "POST",
|
|
1669
|
+
path: "/api/archive/core/borrow/batchDownloadBorrowZip",
|
|
1670
|
+
body: {
|
|
1671
|
+
dataId,
|
|
1672
|
+
requestId,
|
|
1673
|
+
exportType: String(exportParams.exportType ?? "0"),
|
|
1674
|
+
exportStructure: String(exportParams.exportStructure ?? ""),
|
|
1675
|
+
groupField: String(exportParams.groupField ?? ""),
|
|
1676
|
+
documentField: String(exportParams.documentField ?? "")
|
|
1677
|
+
}
|
|
1678
|
+
});
|
|
1679
|
+
const submitData = unwrapData(submit) ?? {};
|
|
1680
|
+
const bizId = String(submitData.bizId ?? "");
|
|
1681
|
+
if (!bizId) {
|
|
1682
|
+
throw new ArchiveCliError("api", "export_submit_failed", "\u63D0\u4EA4\u501F\u9605\u5355\u6253\u5305\u4EFB\u52A1\u5931\u8D25", { exitCode: 1 });
|
|
1683
|
+
}
|
|
1684
|
+
const rate = await pollExport(env.host, bizId);
|
|
1685
|
+
const fileId = String(rate.fileId ?? "");
|
|
1686
|
+
const fileName = String(rate.fileName ?? submitData.fileName ?? `borrow-${dataId}.zip`);
|
|
1687
|
+
const binary = await env.host.requestBinary({
|
|
1688
|
+
method: "GET",
|
|
1689
|
+
path: `/api/file/remotedownload/${fileId}/token/true`,
|
|
1690
|
+
query: { authModule: "ebatch" }
|
|
1691
|
+
});
|
|
1692
|
+
const output = typeof lease.output === "string" && lease.output ? lease.output : void 0;
|
|
1693
|
+
const target = resolveOutputPath(fileName, output);
|
|
1694
|
+
await mkdir2(dirname(target), { recursive: true });
|
|
1695
|
+
await writeFile2(target, binary.content, { flag: "wx", mode: 384 });
|
|
1696
|
+
return archiveSuccess(
|
|
1697
|
+
DOWNLOAD_APPLY,
|
|
1698
|
+
{ savedPath: target, fileName: basename(target), fileId, bizId, size: binary.content.length },
|
|
1699
|
+
{ wrote: true, contentType: binary.contentType }
|
|
1700
|
+
);
|
|
1701
|
+
}
|
|
1702
|
+
};
|
|
1703
|
+
var downloadOperations = [downloadPrepare, downloadApply];
|
|
1704
|
+
|
|
1705
|
+
// src/shortcuts/archive/operations/flow-url.ts
|
|
1706
|
+
var BORROW_CAR_APPLY = "archive.flow.borrow-car.apply";
|
|
1707
|
+
var SEARCH_APPLY = "archive.flow.search.apply";
|
|
1708
|
+
var RENEW_APPLY = "archive.flow.renew.apply";
|
|
1709
|
+
var ARC_ID_PATTERN = /^\d+_\d+$/;
|
|
1710
|
+
var NUMERIC_PATTERN = /^\d+$/;
|
|
1711
|
+
function requireArcIds(value, field) {
|
|
1712
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
1713
|
+
throw archiveValidationError("arc_ids_required", `${field} \u5FC5\u586B\u4E14\u81F3\u5C11\u4E00\u9879`);
|
|
1714
|
+
}
|
|
1715
|
+
return value.map((item, index) => {
|
|
1716
|
+
const text = String(item ?? "").trim();
|
|
1717
|
+
if (!ARC_ID_PATTERN.test(text)) {
|
|
1718
|
+
throw archiveValidationError("arc_id_invalid", `${field}[${index}] \u5FC5\u987B\u662F {\u6863\u6848ID}_{\u8868\u5355ID} \u683C\u5F0F`);
|
|
1719
|
+
}
|
|
1720
|
+
return text;
|
|
1721
|
+
});
|
|
1722
|
+
}
|
|
1723
|
+
function requireIdList(value, field) {
|
|
1724
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
1725
|
+
throw archiveValidationError("id_list_required", `${field} \u5FC5\u586B\u4E14\u81F3\u5C11\u4E00\u9879`);
|
|
1726
|
+
}
|
|
1727
|
+
return value.map((item, index) => {
|
|
1728
|
+
const text = String(item ?? "").trim();
|
|
1729
|
+
if (!NUMERIC_PATTERN.test(text)) {
|
|
1730
|
+
throw archiveValidationError("id_list_invalid", `${field}[${index}] \u5FC5\u987B\u662F\u6570\u5B57 ID`);
|
|
1731
|
+
}
|
|
1732
|
+
return text;
|
|
1733
|
+
});
|
|
1734
|
+
}
|
|
1735
|
+
async function fetchWorkflowId(host) {
|
|
1736
|
+
const response = await host.request({
|
|
1737
|
+
method: "GET",
|
|
1738
|
+
path: "/api/archive/core/archiveSet/getSetValue",
|
|
1739
|
+
query: { keyname: "borrow_flow_check" }
|
|
1740
|
+
});
|
|
1741
|
+
const workflowId = String(unwrapData(response) ?? "").trim();
|
|
1742
|
+
if (!workflowId) {
|
|
1743
|
+
throw archiveValidationError(
|
|
1744
|
+
"borrow_flow_unbound",
|
|
1745
|
+
"\u672A\u7ED1\u5B9A\u501F\u9605\u6D41\u7A0B\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u5728\u6863\u6848\u8BBE\u7F6E\u4E2D\u7ED1\u5B9A\u501F\u9605\u6D41\u7A0B\u540E\u518D\u53D1\u8D77\u501F\u9605"
|
|
1746
|
+
);
|
|
1747
|
+
}
|
|
1748
|
+
return workflowId;
|
|
1749
|
+
}
|
|
1750
|
+
async function addCache(host, value, logFlag) {
|
|
1751
|
+
const body = { key: "arcActionIds", value, time: "86400" };
|
|
1752
|
+
if (logFlag) body.logFlag = logFlag;
|
|
1753
|
+
const response = await host.request({ method: "POST", path: "/api/archive/core/form/addCache", body });
|
|
1754
|
+
const data = unwrapData(response) ?? {};
|
|
1755
|
+
const index = String(data.index ?? "").trim();
|
|
1756
|
+
if (!index) {
|
|
1757
|
+
throw archiveValidationError("cache_index_missing", "\u53C2\u6570\u7F13\u5B58\u5931\u8D25\uFF0C\u672A\u53D6\u5230\u7F13\u5B58\u7D22\u5F15");
|
|
1758
|
+
}
|
|
1759
|
+
return index;
|
|
1760
|
+
}
|
|
1761
|
+
function buildFlowUrl(baseUrl, workflowId, params) {
|
|
1762
|
+
const root = baseUrl.replace(/\/+$/, "");
|
|
1763
|
+
const search = new URLSearchParams(params).toString();
|
|
1764
|
+
return `${root}/sp/workflow/flowpage/fullCreate/${workflowId}?${search}`;
|
|
1765
|
+
}
|
|
1766
|
+
function flowResult(action, baseUrl, workflowId, params, extra = {}) {
|
|
1767
|
+
return archiveSuccess(
|
|
1768
|
+
action,
|
|
1769
|
+
{
|
|
1770
|
+
...extra,
|
|
1771
|
+
workflowId,
|
|
1772
|
+
url: buildFlowUrl(baseUrl, workflowId, params),
|
|
1773
|
+
params,
|
|
1774
|
+
hint: "CLI \u4E0D\u81EA\u52A8\u6253\u5F00\u6D4F\u89C8\u5668\uFF0C\u8BF7\u5728\u6D4F\u89C8\u5668\u4E2D\u6253\u5F00\u8BE5 URL \u5B8C\u6210\u540E\u7EED\u586B\u5199\u4E0E\u63D0\u4EA4"
|
|
1775
|
+
},
|
|
1776
|
+
{ wrote: true }
|
|
1777
|
+
);
|
|
1778
|
+
}
|
|
1779
|
+
var flowBorrowCarPrepare = {
|
|
1780
|
+
name: "archive.flow.borrow-car.prepare",
|
|
1781
|
+
resource: "flow",
|
|
1782
|
+
method: "borrow-car",
|
|
1783
|
+
action: "archive.flow.borrow-car.prepare",
|
|
1784
|
+
summary: "\u4ECE\u501F\u9605\u8F66\u53D1\u8D77\u501F\u9605\uFF1A\u68C0\u67E5\u6D41\u7A0B\u7ED1\u5B9A\u5E76\u751F\u6210\u786E\u8BA4\u7968\u636E\uFF08\u4E0D\u5199\u6570\u636E\uFF09",
|
|
1785
|
+
capability: "archive",
|
|
1786
|
+
risk: READ,
|
|
1787
|
+
inputSchema: schemaOf(
|
|
1788
|
+
{
|
|
1789
|
+
arcIds: { type: "array", items: { type: "string" }, description: "\u6863\u6848\u6807\u8BC6\u6570\u7EC4\uFF0C\u5143\u7D20\u4E3A {\u6863\u6848ID}_{\u8868\u5355ID}" },
|
|
1790
|
+
carIds: { type: "array", items: { type: "string" }, description: "\u501F\u9605\u8F66\u8BB0\u5F55 ID \u6570\u7EC4\uFF0C\u4E0E arcIds \u4E00\u4E00\u5BF9\u5E94" }
|
|
1791
|
+
},
|
|
1792
|
+
{ required: ["arcIds", "carIds"], description: "\u4ECE\u501F\u9605\u8F66\u53D1\u8D77\u501F\u9605" }
|
|
1793
|
+
),
|
|
1794
|
+
handler: async (args, env) => {
|
|
1795
|
+
const arcIds = requireArcIds(args.arcIds, "arcIds");
|
|
1796
|
+
const carIds = requireIdList(args.carIds, "carIds");
|
|
1797
|
+
if (arcIds.length !== carIds.length) {
|
|
1798
|
+
throw archiveValidationError("id_count_mismatch", "arcIds \u4E0E carIds \u6570\u91CF\u5FC5\u987B\u4E00\u81F4");
|
|
1799
|
+
}
|
|
1800
|
+
const workflowId = await fetchWorkflowId(env.host);
|
|
1801
|
+
const { continuation, expiresInMs } = await issueLease(env, BORROW_CAR_APPLY, { workflowId, arcIds, carIds });
|
|
1802
|
+
return archiveSuccess(
|
|
1803
|
+
"archive.flow.borrow-car.prepare",
|
|
1804
|
+
{
|
|
1805
|
+
preview: { workflowId, count: arcIds.length, arcIds, carIds },
|
|
1806
|
+
hint: "\u786E\u8BA4\u540E\u8C03\u7528 archive.flow.borrow-car.apply\uFF08CLI\uFF1Aarchive flow borrow-car-apply --continuation <token> --yes\uFF09",
|
|
1807
|
+
continuation
|
|
1808
|
+
},
|
|
1809
|
+
{ requiresConfirmation: true, expiresInMs }
|
|
1810
|
+
);
|
|
1811
|
+
}
|
|
1812
|
+
};
|
|
1813
|
+
var flowBorrowCarApply = {
|
|
1814
|
+
name: BORROW_CAR_APPLY,
|
|
1815
|
+
resource: "flow",
|
|
1816
|
+
method: "borrow-car",
|
|
1817
|
+
action: BORROW_CAR_APPLY,
|
|
1818
|
+
summary: "\u4ECE\u501F\u9605\u8F66\u53D1\u8D77\u501F\u9605\uFF08\u5199\u64CD\u4F5C\uFF09\uFF1A\u7F13\u5B58\u6863\u6848\u4E0E\u501F\u9605\u8F66\u53C2\u6570\uFF0C\u8FD4\u56DE\u501F\u9605\u6D41\u7A0B\u521B\u5EFA\u9875 URL",
|
|
1819
|
+
capability: "archive",
|
|
1820
|
+
risk: WRITE,
|
|
1821
|
+
requiresConfirmation: true,
|
|
1822
|
+
inputSchema: schemaOf(
|
|
1823
|
+
{
|
|
1824
|
+
continuation: { type: "string", description: "prepare \u8FD4\u56DE\u7684\u786E\u8BA4\u7968\u636E" },
|
|
1825
|
+
confirm: { type: "boolean", description: "\u5FC5\u987B\u4E3A true\uFF08CLI --yes\uFF09" }
|
|
1826
|
+
},
|
|
1827
|
+
{ required: ["continuation", "confirm"], description: "\u4ECE\u501F\u9605\u8F66\u53D1\u8D77\u501F\u9605" }
|
|
1828
|
+
),
|
|
1829
|
+
handler: async (args, env) => {
|
|
1830
|
+
const lease = await verifyLease(args, BORROW_CAR_APPLY, env);
|
|
1831
|
+
const workflowId = String(lease.workflowId ?? "");
|
|
1832
|
+
const arcIds = Array.isArray(lease.arcIds) ? lease.arcIds.map(String) : [];
|
|
1833
|
+
const carIds = Array.isArray(lease.carIds) ? lease.carIds.map(String) : [];
|
|
1834
|
+
if (!workflowId || arcIds.length === 0 || arcIds.length !== carIds.length) {
|
|
1835
|
+
throw archiveValidationError("continuation_payload_invalid", "\u786E\u8BA4\u7968\u636E\u7F3A\u5C11 workflowId / arcIds / carIds");
|
|
1836
|
+
}
|
|
1837
|
+
const arcIndex = await addCache(env.host, arcIds.join(","), "borrowCart");
|
|
1838
|
+
const carIndex = await addCache(env.host, carIds.join(","), "borrowCart");
|
|
1839
|
+
const session = await env.host.getSession();
|
|
1840
|
+
return flowResult(
|
|
1841
|
+
BORROW_CAR_APPLY,
|
|
1842
|
+
session.baseUrl,
|
|
1843
|
+
workflowId,
|
|
1844
|
+
{
|
|
1845
|
+
workflowId,
|
|
1846
|
+
isCreate: "1",
|
|
1847
|
+
isAddIdentify: "1",
|
|
1848
|
+
isBorrow: "1",
|
|
1849
|
+
arcDataId: `arcCache_${arcIndex}`,
|
|
1850
|
+
arcBorrowCarIds: `arcCache_${carIndex}`
|
|
1851
|
+
},
|
|
1852
|
+
{ mode: "borrowCar", count: arcIds.length, caches: { arcDataId: arcIndex, arcBorrowCarIds: carIndex } }
|
|
1853
|
+
);
|
|
1854
|
+
}
|
|
1855
|
+
};
|
|
1856
|
+
var flowSearchPrepare = {
|
|
1857
|
+
name: "archive.flow.search.prepare",
|
|
1858
|
+
resource: "flow",
|
|
1859
|
+
method: "search",
|
|
1860
|
+
action: "archive.flow.search.prepare",
|
|
1861
|
+
summary: "\u4ECE\u5168\u6587\u68C0\u7D22\u7ED3\u679C\u76F4\u63A5\u53D1\u8D77\u501F\u9605\uFF1A\u68C0\u67E5\u6D41\u7A0B\u7ED1\u5B9A\u5E76\u751F\u6210\u786E\u8BA4\u7968\u636E\uFF08\u4E0D\u5199\u6570\u636E\uFF09",
|
|
1862
|
+
capability: "archive",
|
|
1863
|
+
risk: READ,
|
|
1864
|
+
inputSchema: schemaOf(
|
|
1865
|
+
{ arcIds: { type: "array", items: { type: "string" }, description: "\u6863\u6848\u6807\u8BC6\u6570\u7EC4\uFF0C\u5143\u7D20\u4E3A {\u6863\u6848ID}_{\u8868\u5355ID}" } },
|
|
1866
|
+
{ required: ["arcIds"], description: "\u4ECE\u68C0\u7D22\u7ED3\u679C\u53D1\u8D77\u501F\u9605" }
|
|
1867
|
+
),
|
|
1868
|
+
handler: async (args, env) => {
|
|
1869
|
+
const arcIds = requireArcIds(args.arcIds, "arcIds");
|
|
1870
|
+
const workflowId = await fetchWorkflowId(env.host);
|
|
1871
|
+
const { continuation, expiresInMs } = await issueLease(env, SEARCH_APPLY, { workflowId, arcIds });
|
|
1872
|
+
return archiveSuccess(
|
|
1873
|
+
"archive.flow.search.prepare",
|
|
1874
|
+
{
|
|
1875
|
+
preview: { workflowId, count: arcIds.length, arcIds },
|
|
1876
|
+
hint: "\u786E\u8BA4\u540E\u8C03\u7528 archive.flow.search.apply\uFF08CLI\uFF1Aarchive flow search-apply --continuation <token> --yes\uFF09",
|
|
1877
|
+
continuation
|
|
1878
|
+
},
|
|
1879
|
+
{ requiresConfirmation: true, expiresInMs }
|
|
1880
|
+
);
|
|
1881
|
+
}
|
|
1882
|
+
};
|
|
1883
|
+
var flowSearchApply = {
|
|
1884
|
+
name: SEARCH_APPLY,
|
|
1885
|
+
resource: "flow",
|
|
1886
|
+
method: "search",
|
|
1887
|
+
action: SEARCH_APPLY,
|
|
1888
|
+
summary: "\u4ECE\u5168\u6587\u68C0\u7D22\u7ED3\u679C\u76F4\u63A5\u53D1\u8D77\u501F\u9605\uFF08\u5199\u64CD\u4F5C\uFF09\uFF1A\u53EA\u7F13\u5B58\u6863\u6848\u53C2\u6570\uFF0C\u8FD4\u56DE\u501F\u9605\u6D41\u7A0B\u521B\u5EFA\u9875 URL",
|
|
1889
|
+
capability: "archive",
|
|
1890
|
+
risk: WRITE,
|
|
1891
|
+
requiresConfirmation: true,
|
|
1892
|
+
inputSchema: schemaOf(
|
|
1893
|
+
{
|
|
1894
|
+
continuation: { type: "string", description: "prepare \u8FD4\u56DE\u7684\u786E\u8BA4\u7968\u636E" },
|
|
1895
|
+
confirm: { type: "boolean", description: "\u5FC5\u987B\u4E3A true\uFF08CLI --yes\uFF09" }
|
|
1896
|
+
},
|
|
1897
|
+
{ required: ["continuation", "confirm"], description: "\u4ECE\u68C0\u7D22\u7ED3\u679C\u53D1\u8D77\u501F\u9605" }
|
|
1898
|
+
),
|
|
1899
|
+
handler: async (args, env) => {
|
|
1900
|
+
const lease = await verifyLease(args, SEARCH_APPLY, env);
|
|
1901
|
+
const workflowId = String(lease.workflowId ?? "");
|
|
1902
|
+
const arcIds = Array.isArray(lease.arcIds) ? lease.arcIds.map(String) : [];
|
|
1903
|
+
if (!workflowId || arcIds.length === 0) {
|
|
1904
|
+
throw archiveValidationError("continuation_payload_invalid", "\u786E\u8BA4\u7968\u636E\u7F3A\u5C11 workflowId / arcIds");
|
|
1905
|
+
}
|
|
1906
|
+
const arcIndex = await addCache(env.host, arcIds.join(","));
|
|
1907
|
+
const session = await env.host.getSession();
|
|
1908
|
+
return flowResult(
|
|
1909
|
+
SEARCH_APPLY,
|
|
1910
|
+
session.baseUrl,
|
|
1911
|
+
workflowId,
|
|
1912
|
+
{
|
|
1913
|
+
workflowId,
|
|
1914
|
+
isCreate: "1",
|
|
1915
|
+
isAddIdentify: "1",
|
|
1916
|
+
isBorrow: "1",
|
|
1917
|
+
arcDataId: `arcCache_${arcIndex}`
|
|
1918
|
+
},
|
|
1919
|
+
{ mode: "search", count: arcIds.length, caches: { arcDataId: arcIndex } }
|
|
1920
|
+
);
|
|
1921
|
+
}
|
|
1922
|
+
};
|
|
1923
|
+
var flowRenewPrepare = {
|
|
1924
|
+
name: "archive.flow.renew.prepare",
|
|
1925
|
+
resource: "flow",
|
|
1926
|
+
method: "renew",
|
|
1927
|
+
action: "archive.flow.renew.prepare",
|
|
1928
|
+
summary: "\u501F\u9605\u5355\u7EED\u501F\uFF1A\u68C0\u67E5\u6D41\u7A0B\u7ED1\u5B9A\u5E76\u751F\u6210\u786E\u8BA4\u7968\u636E\uFF08\u4E0D\u5199\u6570\u636E\uFF09",
|
|
1929
|
+
capability: "archive",
|
|
1930
|
+
risk: READ,
|
|
1931
|
+
inputSchema: schemaOf(
|
|
1932
|
+
{ dataId: { type: "string", pattern: "^\\d+$", description: "\u501F\u9605\u5355\u4E3B\u8868\u6570\u636E ID" } },
|
|
1933
|
+
{ required: ["dataId"], description: "\u501F\u9605\u5355\u7EED\u501F" }
|
|
1934
|
+
),
|
|
1935
|
+
handler: async (args, env) => {
|
|
1936
|
+
const dataId = String(args.dataId ?? "").trim();
|
|
1937
|
+
if (!NUMERIC_PATTERN.test(dataId)) {
|
|
1938
|
+
throw archiveValidationError("data_id_invalid", "dataId \u5FC5\u586B\u4E14\u4E3A\u6570\u5B57 ID");
|
|
1939
|
+
}
|
|
1940
|
+
const workflowId = await fetchWorkflowId(env.host);
|
|
1941
|
+
const { continuation, expiresInMs } = await issueLease(env, RENEW_APPLY, { workflowId, dataId });
|
|
1942
|
+
return archiveSuccess(
|
|
1943
|
+
"archive.flow.renew.prepare",
|
|
1944
|
+
{
|
|
1945
|
+
preview: { workflowId, dataId },
|
|
1946
|
+
hint: "\u786E\u8BA4\u540E\u8C03\u7528 archive.flow.renew.apply\uFF08CLI\uFF1Aarchive flow renew-apply --continuation <token> --yes\uFF09",
|
|
1947
|
+
continuation
|
|
1948
|
+
},
|
|
1949
|
+
{ requiresConfirmation: true, expiresInMs }
|
|
1950
|
+
);
|
|
1951
|
+
}
|
|
1952
|
+
};
|
|
1953
|
+
var flowRenewApply = {
|
|
1954
|
+
name: RENEW_APPLY,
|
|
1955
|
+
resource: "flow",
|
|
1956
|
+
method: "renew",
|
|
1957
|
+
action: RENEW_APPLY,
|
|
1958
|
+
summary: "\u501F\u9605\u5355\u7EED\u501F\uFF08\u5199\u64CD\u4F5C\uFF09\uFF1A\u8FD4\u56DE\u7EED\u501F\u6D41\u7A0B\u521B\u5EFA\u9875 URL\uFF08\u4E0D\u8C03\u7528 addCache\uFF09",
|
|
1959
|
+
capability: "archive",
|
|
1960
|
+
risk: WRITE,
|
|
1961
|
+
requiresConfirmation: true,
|
|
1962
|
+
inputSchema: schemaOf(
|
|
1963
|
+
{
|
|
1964
|
+
continuation: { type: "string", description: "prepare \u8FD4\u56DE\u7684\u786E\u8BA4\u7968\u636E" },
|
|
1965
|
+
confirm: { type: "boolean", description: "\u5FC5\u987B\u4E3A true\uFF08CLI --yes\uFF09" }
|
|
1966
|
+
},
|
|
1967
|
+
{ required: ["continuation", "confirm"], description: "\u501F\u9605\u5355\u7EED\u501F" }
|
|
1968
|
+
),
|
|
1969
|
+
handler: async (args, env) => {
|
|
1970
|
+
const lease = await verifyLease(args, RENEW_APPLY, env);
|
|
1971
|
+
const workflowId = String(lease.workflowId ?? "");
|
|
1972
|
+
const dataId = String(lease.dataId ?? "").trim();
|
|
1973
|
+
if (!workflowId || !NUMERIC_PATTERN.test(dataId)) {
|
|
1974
|
+
throw archiveValidationError("continuation_payload_invalid", "\u786E\u8BA4\u7968\u636E\u7F3A\u5C11 workflowId / dataId");
|
|
1975
|
+
}
|
|
1976
|
+
assertLeaseTarget(lease, args, ["dataId"], RENEW_APPLY);
|
|
1977
|
+
const session = await env.host.getSession();
|
|
1978
|
+
return flowResult(
|
|
1979
|
+
RENEW_APPLY,
|
|
1980
|
+
session.baseUrl,
|
|
1981
|
+
workflowId,
|
|
1982
|
+
{ workflowId, isCreate: "1", arcDataId: dataId, isReNew: "1" },
|
|
1983
|
+
{ mode: "renew", dataId }
|
|
1984
|
+
);
|
|
1985
|
+
}
|
|
1986
|
+
};
|
|
1987
|
+
var flowUrlOperations = [
|
|
1988
|
+
flowBorrowCarPrepare,
|
|
1989
|
+
flowBorrowCarApply,
|
|
1990
|
+
flowSearchPrepare,
|
|
1991
|
+
flowSearchApply,
|
|
1992
|
+
flowRenewPrepare,
|
|
1993
|
+
flowRenewApply
|
|
1994
|
+
];
|
|
1995
|
+
|
|
1996
|
+
// src/shortcuts/archive/operations/upload.ts
|
|
1997
|
+
import { createHash } from "node:crypto";
|
|
1998
|
+
import { stat } from "node:fs/promises";
|
|
1999
|
+
import { basename as basename2, resolve as resolve3 } from "node:path";
|
|
2000
|
+
import { readFile as readFile2 } from "node:fs/promises";
|
|
2001
|
+
var UPLOAD_APPLY = "archive.upload.prelib.apply";
|
|
2002
|
+
var MAX_UPLOAD_BYTES = 200 * 1024 * 1024;
|
|
2003
|
+
function isEfileLibNode2(item) {
|
|
2004
|
+
const id = typeof item?.id === "string" ? item.id : "";
|
|
2005
|
+
if (!id || !id.includes("_")) return false;
|
|
2006
|
+
const [left, right] = id.split("_");
|
|
2007
|
+
return Boolean(left && left === right);
|
|
2008
|
+
}
|
|
2009
|
+
async function resolveDefaultTreeId(host) {
|
|
2010
|
+
const response = await host.request({
|
|
2011
|
+
method: "POST",
|
|
2012
|
+
path: "/api/archive/core/archivetree/getTree",
|
|
2013
|
+
body: { treeType: "4", menuSign: "preLib", logFlag: "preLib", needControl: true, needSysn: true }
|
|
2014
|
+
});
|
|
2015
|
+
const data = unwrapData(response);
|
|
2016
|
+
if (!Array.isArray(data)) {
|
|
2017
|
+
throw archiveValidationError("tree_invalid", "getTree \u8FD4\u56DE\u5F02\u5E38\uFF1Adata \u4E0D\u662F\u6570\u7EC4");
|
|
2018
|
+
}
|
|
2019
|
+
const nodes = data.filter(isEfileLibNode2);
|
|
2020
|
+
if (nodes.length === 0) {
|
|
2021
|
+
throw archiveValidationError("tree_id_required", "\u672A\u627E\u5230\u7535\u5B50\u6587\u4EF6\u5E93\u8282\u70B9\uFF0C\u8BF7\u663E\u5F0F\u4F20\u5165 treeId");
|
|
2022
|
+
}
|
|
2023
|
+
if (nodes.length > 1) {
|
|
2024
|
+
throw archiveValidationError(
|
|
2025
|
+
"tree_id_ambiguous",
|
|
2026
|
+
`\u5B58\u5728\u591A\u4E2A\u7535\u5B50\u6587\u4EF6\u5E93\u8282\u70B9\uFF08${nodes.map((item) => item.id).join("\u3001")}\uFF09\uFF0C\u8BF7\u663E\u5F0F\u4F20\u5165 treeId`
|
|
2027
|
+
);
|
|
2028
|
+
}
|
|
2029
|
+
return String(nodes[0].id);
|
|
2030
|
+
}
|
|
2031
|
+
var uploadPrepare = {
|
|
2032
|
+
name: "archive.upload.prelib.prepare",
|
|
2033
|
+
resource: "upload",
|
|
2034
|
+
method: "prelib",
|
|
2035
|
+
action: "archive.upload.prelib.prepare",
|
|
2036
|
+
summary: "\u9884\u5F52\u6863\u4E0A\u4F20\u9884\u68C0\uFF1A\u6821\u9A8C\u672C\u5730\u6587\u4EF6\u4E0E\u76EE\u6807\u5168\u5B97/\u7535\u5B50\u6587\u4EF6\u5E93\u8282\u70B9\uFF0C\u5E76\u751F\u6210\u786E\u8BA4\u7968\u636E\uFF08\u4E0D\u4E0A\u4F20\uFF09",
|
|
2037
|
+
capability: "archive",
|
|
2038
|
+
risk: READ,
|
|
2039
|
+
inputSchema: schemaOf(
|
|
2040
|
+
{
|
|
2041
|
+
file: { type: "string", description: "\u672C\u5730\u6587\u4EF6\u8DEF\u5F84" },
|
|
2042
|
+
fondsId: { type: "string", pattern: "^\\d+$", description: "\u76EE\u6807\u5168\u5B97 ID\uFF08archive.fonds.list \u8FD4\u56DE\u7684 id\uFF09" },
|
|
2043
|
+
treeId: { type: "string", description: "\u53EF\u9009\uFF0C\u7535\u5B50\u6587\u4EF6\u5E93\u8282\u70B9 id\uFF1B\u4E0D\u4F20\u65F6\u53D6\u552F\u4E00\u7684\u7535\u5B50\u6587\u4EF6\u5E93\u8282\u70B9" }
|
|
2044
|
+
},
|
|
2045
|
+
{ required: ["file", "fondsId"], description: "\u9884\u5F52\u6863\u4E0A\u4F20\u9884\u68C0" }
|
|
2046
|
+
),
|
|
2047
|
+
handler: async (args, env) => {
|
|
2048
|
+
const filePath = typeof args.file === "string" && args.file.trim() ? resolve3(args.file.trim()) : "";
|
|
2049
|
+
if (!filePath) throw archiveValidationError("file_required", "file \u5FC5\u586B\uFF08\u672C\u5730\u6587\u4EF6\u8DEF\u5F84\uFF09");
|
|
2050
|
+
const fondsId = String(args.fondsId ?? "").trim();
|
|
2051
|
+
if (!/^\d+$/.test(fondsId)) throw archiveValidationError("fonds_id_invalid", "fondsId \u5FC5\u586B\u4E14\u4E3A\u6570\u5B57 ID");
|
|
2052
|
+
let info;
|
|
2053
|
+
try {
|
|
2054
|
+
info = await stat(filePath);
|
|
2055
|
+
} catch {
|
|
2056
|
+
throw archiveValidationError("file_unreadable", `\u65E0\u6CD5\u8BFB\u53D6\u672C\u5730\u6587\u4EF6\uFF1A${filePath}`);
|
|
2057
|
+
}
|
|
2058
|
+
if (!info.isFile()) throw archiveValidationError("file_invalid", `\u4E0D\u662F\u6587\u4EF6\uFF1A${filePath}`);
|
|
2059
|
+
if (info.size === 0) throw archiveValidationError("file_empty", `\u6587\u4EF6\u4E3A\u7A7A\uFF1A${filePath}`);
|
|
2060
|
+
if (info.size > MAX_UPLOAD_BYTES) {
|
|
2061
|
+
throw archiveValidationError("file_too_large", `\u6587\u4EF6\u8D85\u8FC7 ${MAX_UPLOAD_BYTES} \u5B57\u8282\u4E0A\u9650\uFF1A${filePath}`);
|
|
2062
|
+
}
|
|
2063
|
+
const treeId = args.treeId === void 0 || args.treeId === null || args.treeId === "" ? await resolveDefaultTreeId(env.host) : String(args.treeId);
|
|
2064
|
+
const { continuation, expiresInMs } = await issueLease(env, UPLOAD_APPLY, {
|
|
2065
|
+
file: filePath,
|
|
2066
|
+
fileName: basename2(filePath),
|
|
2067
|
+
size: info.size,
|
|
2068
|
+
fondsId,
|
|
2069
|
+
treeId
|
|
2070
|
+
});
|
|
2071
|
+
return archiveSuccess(
|
|
2072
|
+
"archive.upload.prelib.prepare",
|
|
2073
|
+
{
|
|
2074
|
+
preview: {
|
|
2075
|
+
file: filePath,
|
|
2076
|
+
fileName: basename2(filePath),
|
|
2077
|
+
size: info.size,
|
|
2078
|
+
fondsId,
|
|
2079
|
+
treeId
|
|
2080
|
+
},
|
|
2081
|
+
hint: "\u786E\u8BA4\u540E\u8C03\u7528 archive.upload.prelib.apply\uFF08CLI\uFF1Aarchive upload apply --continuation <token> --yes\uFF09",
|
|
2082
|
+
continuation
|
|
2083
|
+
},
|
|
2084
|
+
{ requiresConfirmation: true, expiresInMs }
|
|
2085
|
+
);
|
|
2086
|
+
}
|
|
2087
|
+
};
|
|
2088
|
+
var uploadApply = {
|
|
2089
|
+
name: UPLOAD_APPLY,
|
|
2090
|
+
resource: "upload",
|
|
2091
|
+
method: "prelib",
|
|
2092
|
+
action: UPLOAD_APPLY,
|
|
2093
|
+
summary: "\u9884\u5F52\u6863\u4E0A\u4F20\uFF08\u5199\u64CD\u4F5C\uFF09\uFF1ApreUploadCheck \u2192 module/upload \u2192 saveFile\uFF0C\u628A\u672C\u5730\u6587\u4EF6\u5B58\u5165\u9884\u5F52\u6863\u7535\u5B50\u6587\u4EF6\u5E93",
|
|
2094
|
+
capability: "archive",
|
|
2095
|
+
risk: WRITE,
|
|
2096
|
+
requiresConfirmation: true,
|
|
2097
|
+
inputSchema: schemaOf(
|
|
2098
|
+
{
|
|
2099
|
+
continuation: { type: "string", description: "prepare \u8FD4\u56DE\u7684\u786E\u8BA4\u7968\u636E" },
|
|
2100
|
+
confirm: { type: "boolean", description: "\u5FC5\u987B\u4E3A true\uFF08CLI --yes\uFF09" },
|
|
2101
|
+
fondsId: { type: "string", description: "\u53EF\u9009\u56DE\u4F20\uFF0C\u7528\u4E8E\u4E0E prepare \u5FEB\u7167\u6BD4\u5BF9" }
|
|
2102
|
+
},
|
|
2103
|
+
{ required: ["continuation", "confirm"], description: "\u9884\u5F52\u6863\u4E0A\u4F20" }
|
|
2104
|
+
),
|
|
2105
|
+
handler: async (args, env) => {
|
|
2106
|
+
const lease = await verifyLease(args, UPLOAD_APPLY, env);
|
|
2107
|
+
const filePath = String(lease.file ?? "");
|
|
2108
|
+
const fileName = String(lease.fileName ?? basename2(filePath));
|
|
2109
|
+
const fondsId = String(lease.fondsId ?? "");
|
|
2110
|
+
const treeId = String(lease.treeId ?? "");
|
|
2111
|
+
if (!filePath || !fondsId || !treeId) {
|
|
2112
|
+
throw archiveValidationError("continuation_payload_invalid", "\u786E\u8BA4\u7968\u636E\u7F3A\u5C11 file / fondsId / treeId");
|
|
2113
|
+
}
|
|
2114
|
+
assertLeaseTarget(lease, args, ["fondsId"], UPLOAD_APPLY);
|
|
2115
|
+
const content = await readFile2(filePath);
|
|
2116
|
+
if (content.length === 0) throw archiveValidationError("file_empty", `\u6587\u4EF6\u4E3A\u7A7A\uFF1A${filePath}`);
|
|
2117
|
+
const md5 = createHash("md5").update(content).digest("hex");
|
|
2118
|
+
const lastModified = Date.now();
|
|
2119
|
+
const checkForm = new FormData();
|
|
2120
|
+
checkForm.append("module", "archive");
|
|
2121
|
+
checkForm.append("name", fileName);
|
|
2122
|
+
checkForm.append("size", String(content.length));
|
|
2123
|
+
checkForm.append("MD5", md5);
|
|
2124
|
+
checkForm.append("lastModified", String(lastModified));
|
|
2125
|
+
checkForm.append("lastModifiedDate", String(lastModified));
|
|
2126
|
+
checkForm.append("compressImg", "false");
|
|
2127
|
+
const check = await env.host.request({
|
|
2128
|
+
method: "POST",
|
|
2129
|
+
path: "/api/file/preUploadCheck",
|
|
2130
|
+
multipart: checkForm
|
|
2131
|
+
});
|
|
2132
|
+
const checkData = unwrapData(check) ?? {};
|
|
2133
|
+
if (checkData.permissionType?.upload === false) {
|
|
2134
|
+
throw archiveValidationError("upload_forbidden", "\u5F53\u524D\u8D26\u53F7\u6CA1\u6709\u4E0A\u4F20\u6743\u9650");
|
|
2135
|
+
}
|
|
2136
|
+
const uploadForm = new FormData();
|
|
2137
|
+
uploadForm.append("module", "archive");
|
|
2138
|
+
uploadForm.append("name", fileName);
|
|
2139
|
+
uploadForm.append("size", String(content.length));
|
|
2140
|
+
uploadForm.append("MD5", md5);
|
|
2141
|
+
uploadForm.append("lastModified", String(lastModified));
|
|
2142
|
+
uploadForm.append("lastModifiedDate", String(lastModified));
|
|
2143
|
+
uploadForm.append("compressImg", "false");
|
|
2144
|
+
uploadForm.append("file", new Blob([content], { type: "application/octet-stream" }), fileName);
|
|
2145
|
+
const uploaded = await env.host.request({
|
|
2146
|
+
method: "POST",
|
|
2147
|
+
path: "/api/file/module/upload",
|
|
2148
|
+
multipart: uploadForm
|
|
2149
|
+
});
|
|
2150
|
+
const uploadData = unwrapData(uploaded) ?? {};
|
|
2151
|
+
const fileId = String(uploadData.fileid ?? "");
|
|
2152
|
+
if (!fileId) throw archiveValidationError("upload_failed", "\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25\uFF0C\u672A\u53D6\u5230 fileid");
|
|
2153
|
+
await env.host.request({
|
|
2154
|
+
method: "POST",
|
|
2155
|
+
path: "/api/archive/core/intelligent/saveFile",
|
|
2156
|
+
body: {
|
|
2157
|
+
docIds: fileId,
|
|
2158
|
+
docNames: String(uploadData.name ?? fileName),
|
|
2159
|
+
treeId,
|
|
2160
|
+
fonds_code: fondsId,
|
|
2161
|
+
logFlag: "preLib"
|
|
2162
|
+
}
|
|
2163
|
+
});
|
|
2164
|
+
return archiveSuccess(
|
|
2165
|
+
UPLOAD_APPLY,
|
|
2166
|
+
{
|
|
2167
|
+
saved: true,
|
|
2168
|
+
fileId,
|
|
2169
|
+
docId: String(uploadData.docId ?? ""),
|
|
2170
|
+
fileName: String(uploadData.name ?? fileName),
|
|
2171
|
+
size: Number(uploadData.size ?? content.length),
|
|
2172
|
+
treeId,
|
|
2173
|
+
fondsId,
|
|
2174
|
+
md5
|
|
2175
|
+
},
|
|
2176
|
+
{ wrote: true }
|
|
2177
|
+
);
|
|
2178
|
+
}
|
|
2179
|
+
};
|
|
2180
|
+
var uploadOperations = [uploadPrepare, uploadApply];
|
|
2181
|
+
|
|
2182
|
+
// src/shortcuts/archive/operations/registry.ts
|
|
2183
|
+
function buildRegistry() {
|
|
2184
|
+
const registry = /* @__PURE__ */ new Map();
|
|
2185
|
+
const definitions = [
|
|
2186
|
+
...fondsOperations,
|
|
2187
|
+
...archiveInfoOperations,
|
|
2188
|
+
...searchOperations,
|
|
2189
|
+
...borrowCarOperations,
|
|
2190
|
+
...borrowListOperations,
|
|
2191
|
+
...downloadOperations,
|
|
2192
|
+
...flowUrlOperations,
|
|
2193
|
+
...uploadOperations
|
|
2194
|
+
];
|
|
2195
|
+
for (const definition of definitions) {
|
|
2196
|
+
if (registry.has(definition.name)) {
|
|
2197
|
+
throw new Error(`duplicate archive operation: ${definition.name}`);
|
|
2198
|
+
}
|
|
2199
|
+
registry.set(definition.name, definition);
|
|
2200
|
+
}
|
|
2201
|
+
return registry;
|
|
2202
|
+
}
|
|
2203
|
+
var archiveOperationRegistry = buildRegistry();
|
|
2204
|
+
function archiveOperationDefinitions() {
|
|
2205
|
+
return [...archiveOperationRegistry.values()];
|
|
2206
|
+
}
|
|
2207
|
+
function getArchiveOperation(operation) {
|
|
2208
|
+
const definition = archiveOperationRegistry.get(operation);
|
|
2209
|
+
if (!definition) {
|
|
2210
|
+
throw archiveValidationError("operation_unknown", `\u6587\u4E66\u5B9A\u6863\u6848\u4E0D\u652F\u6301\u64CD\u4F5C\uFF1A${operation}`);
|
|
2211
|
+
}
|
|
2212
|
+
return definition;
|
|
2213
|
+
}
|
|
2214
|
+
|
|
2215
|
+
// src/shortcuts/archive/manifest.ts
|
|
2216
|
+
var archiveOperations = archiveOperationDefinitions().map((definition) => ({
|
|
2217
|
+
name: definition.name,
|
|
2218
|
+
resource: definition.resource,
|
|
2219
|
+
summary: definition.summary,
|
|
2220
|
+
...definition.capability ? { capability: definition.capability } : {},
|
|
2221
|
+
risk: definition.risk,
|
|
2222
|
+
...definition.requiresConfirmation ? { requiresConfirmation: true } : {},
|
|
2223
|
+
inputSchema: definition.inputSchema
|
|
2224
|
+
}));
|
|
2225
|
+
var archiveManifest = {
|
|
2226
|
+
schemaVersion: 1,
|
|
2227
|
+
name: "archive",
|
|
2228
|
+
title: "\u6CDB\u5FAEE10\u6587\u4E66\u5B9A\u6863\u6848\u7BA1\u7406",
|
|
2229
|
+
version: "0.1.0",
|
|
2230
|
+
host: "e10-archive",
|
|
2231
|
+
status: "builtin",
|
|
2232
|
+
sourceSkill: "weaver-e10-wenshuding",
|
|
2233
|
+
capabilities: ["fonds", "prelib", "search", "borrowCar", "borrowList", "flow", "download", "upload"],
|
|
2234
|
+
auth: {
|
|
2235
|
+
required: "e10-session",
|
|
2236
|
+
note: "\u6240\u6709\u64CD\u4F5C\u90FD\u8981\u6C42\u5DF2\u767B\u5F55 E10\uFF1B\u672A\u767B\u5F55\u65F6\u8FD4\u56DE auth_error\uFF0C\u8C03\u7528\u65B9\u5E94\u6839\u636E\u5F53\u524D\u5BBF\u4E3B\u73AF\u5883\u9009\u62E9\u767B\u5F55\u65B9\u5F0F\u3002"
|
|
2237
|
+
},
|
|
2238
|
+
rules: [
|
|
2239
|
+
"\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",
|
|
2240
|
+
"\u501F\u9605\u5355\u4E0B\u8F7D\u4E3A\u5F02\u6B65\u4EFB\u52A1\uFF1Aapply \u4F1A\u8F6E\u8BE2\u6253\u5305\u8FDB\u5EA6\uFF0C\u5B8C\u6210\u540E\u628A zip \u4FDD\u5B58\u5230\u5F53\u524D\u7528\u6237\u7684\u300C\u4E0B\u8F7D\u300D\u76EE\u5F55\uFF08\u53EF\u7528 output \u6307\u5B9A\u8DEF\u5F84\uFF09\u3002",
|
|
2241
|
+
"\u53D1\u8D77\u501F\u9605/\u7EED\u501F\u53EA\u8FD4\u56DE\u6D41\u7A0B\u521B\u5EFA\u9875 URL\uFF0CCLI \u4E0D\u81EA\u52A8\u6253\u5F00\u6D4F\u89C8\u5668\uFF0C\u9700\u7531\u7528\u6237\u6216\u4E0A\u5C42\u5728\u6D4F\u89C8\u5668\u4E2D\u6253\u5F00\u3002",
|
|
2242
|
+
"\u501F\u9605\u8F66/\u501F\u9605\u5355\u5217\u8868\u4F18\u5148\u81EA\u5B9A\u4E49\u63A5\u53E3\uFF0C\u63A5\u53E3\u672A\u53D1\u5E03\u65F6\u81EA\u52A8\u56DE\u9000 ebuilder \u5217\u8868\u94FE\u8DEF\uFF0C\u56DE\u9000\u65F6\u884C\u7684\u5B57\u6BB5\u66F4\u5C11\uFF08\u63D0\u4F9B fields/display\uFF09\u3002"
|
|
2243
|
+
],
|
|
2244
|
+
operations: archiveOperations,
|
|
2245
|
+
withheldOperations: [
|
|
2246
|
+
{
|
|
2247
|
+
name: "archive.borrow.submit",
|
|
2248
|
+
reason: "\u501F\u9605\u7533\u8BF7\u8868\u5355\u7684\u5B57\u6BB5\u7ED3\u6784\u3001\u5FC5\u586B\u9879\u4E0E\u63D0\u4EA4\u5951\u7EA6\u5C1A\u672A\u56FA\u5316\u4E3A\u63A5\u53E3\uFF0C\u76EE\u524D\u53EA\u80FD\u901A\u8FC7\u6D41\u7A0B\u521B\u5EFA\u9875 URL \u7531\u7528\u6237\u5728\u6D4F\u89C8\u5668\u5B8C\u6210\u3002"
|
|
2249
|
+
},
|
|
2250
|
+
{
|
|
2251
|
+
name: "archive.borrow-car.remove",
|
|
2252
|
+
reason: "\u7F3A\u5C11\u501F\u9605\u8F66\u79FB\u9664\u63A5\u53E3\u7684\u8BF7\u6C42\u5951\u7EA6\u4E0E\u6743\u9650\u56DE\u67E5\u65B9\u5F0F\uFF0C\u6682\u4E0D\u5F00\u653E\u3002"
|
|
2253
|
+
}
|
|
2254
|
+
]
|
|
2255
|
+
};
|
|
2256
|
+
|
|
2257
|
+
// src/shortcuts/archive/operations.ts
|
|
2258
|
+
async function executeArchiveOperation(operation, rawInput, env) {
|
|
2259
|
+
const definition = getArchiveOperation(operation);
|
|
2260
|
+
const input = asObject(rawInput);
|
|
2261
|
+
assertNoForbiddenKeys(input);
|
|
2262
|
+
return definition.handler(input, { ctx: env.ctx, host: env.host, continuation: env.continuation });
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2265
|
+
// src/shortcuts/archive/index.ts
|
|
2266
|
+
function asOptions(value) {
|
|
2267
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
2268
|
+
}
|
|
2269
|
+
async function readStdin() {
|
|
2270
|
+
const chunks = [];
|
|
2271
|
+
for await (const chunk of process.stdin) {
|
|
2272
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
2273
|
+
}
|
|
2274
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
2275
|
+
}
|
|
2276
|
+
async function inputFrom(options, extra = {}) {
|
|
2277
|
+
const opts = asOptions(options);
|
|
2278
|
+
let input = {};
|
|
2279
|
+
if (opts.input && opts.inputJson) {
|
|
2280
|
+
throw archiveValidationError("input_conflict", "\u4E0D\u80FD\u540C\u65F6\u4F20 --input \u548C --input-json");
|
|
2281
|
+
}
|
|
2282
|
+
if (opts.inputJson) {
|
|
2283
|
+
input = parseJsonInput(String(opts.inputJson), "--input-json");
|
|
2284
|
+
}
|
|
2285
|
+
if (opts.input) {
|
|
2286
|
+
let raw;
|
|
2287
|
+
try {
|
|
2288
|
+
raw = opts.input === "-" ? await readStdin() : await readFile3(String(opts.input), "utf8");
|
|
2289
|
+
} catch {
|
|
2290
|
+
throw archiveValidationError("input_unreadable", `\u65E0\u6CD5\u8BFB\u53D6 --input\uFF1A${String(opts.input)}`);
|
|
2291
|
+
}
|
|
2292
|
+
input = parseJsonInput(raw, "--input");
|
|
2293
|
+
}
|
|
2294
|
+
return {
|
|
2295
|
+
...input,
|
|
2296
|
+
...Object.fromEntries(Object.entries(extra).filter(([, value]) => value !== void 0 && value !== ""))
|
|
2297
|
+
};
|
|
2298
|
+
}
|
|
2299
|
+
function parseJsonInput(raw, label) {
|
|
2300
|
+
try {
|
|
2301
|
+
const parsed = JSON.parse(raw.replace(/^\uFEFF/u, ""));
|
|
2302
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
2303
|
+
throw new Error("input must be an object");
|
|
2304
|
+
}
|
|
2305
|
+
return parsed;
|
|
2306
|
+
} catch {
|
|
2307
|
+
throw archiveValidationError("input_invalid", `${label} \u4E0D\u662F\u5408\u6CD5 JSON \u5BF9\u8C61`);
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2310
|
+
function withJsonInputOptions(command) {
|
|
2311
|
+
command.option("--input <path>", "JSON input file, or - for stdin").option("--input-json <json>", "inline JSON input object");
|
|
2312
|
+
return command;
|
|
2313
|
+
}
|
|
2314
|
+
function intOption(value) {
|
|
2315
|
+
if (value === void 0 || value === null || value === "") return void 0;
|
|
2316
|
+
const parsed = Number(value);
|
|
2317
|
+
return Number.isInteger(parsed) ? parsed : void 0;
|
|
2318
|
+
}
|
|
2319
|
+
function stringOption(value) {
|
|
2320
|
+
if (value === void 0 || value === null || value === "") return void 0;
|
|
2321
|
+
return String(value);
|
|
2322
|
+
}
|
|
2323
|
+
function successEnvelope(result) {
|
|
2324
|
+
return {
|
|
2325
|
+
schemaVersion: 1,
|
|
2326
|
+
ok: true,
|
|
2327
|
+
operation: result.action,
|
|
2328
|
+
data: result.data,
|
|
2329
|
+
...result.meta ? { meta: result.meta } : {},
|
|
2330
|
+
warnings: []
|
|
2331
|
+
};
|
|
2332
|
+
}
|
|
2333
|
+
function failureEnvelope(error) {
|
|
2334
|
+
const structured = error;
|
|
2335
|
+
return {
|
|
2336
|
+
schemaVersion: 1,
|
|
2337
|
+
ok: false,
|
|
2338
|
+
...structured?.partialData === void 0 ? {} : { data: structured.partialData },
|
|
2339
|
+
error: toErrorEnvelope(error)
|
|
2340
|
+
};
|
|
2341
|
+
}
|
|
2342
|
+
async function executeAndPrint(ctx, operation, input) {
|
|
2343
|
+
try {
|
|
2344
|
+
const result = await executeArchiveOperation(operation, input, {
|
|
2345
|
+
ctx,
|
|
2346
|
+
host: createArchiveHost(ctx),
|
|
2347
|
+
continuation: createArchiveContinuationSigner(ctx)
|
|
2348
|
+
});
|
|
2349
|
+
ctx.output.write(successEnvelope(result), { json: true });
|
|
2350
|
+
} catch (error) {
|
|
2351
|
+
console.error(JSON.stringify(failureEnvelope(error), null, 2));
|
|
2352
|
+
process.exitCode = isCliError(error) ? error.exitCode : 1 /* GeneralError */;
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
async function executeSearchPrint(ctx, input, format, outputPath) {
|
|
2356
|
+
const env = {
|
|
2357
|
+
ctx,
|
|
2358
|
+
host: createArchiveHost(ctx),
|
|
2359
|
+
continuation: createArchiveContinuationSigner(ctx)
|
|
2360
|
+
};
|
|
2361
|
+
try {
|
|
2362
|
+
const result = await executeArchiveOperation("archive.search.run", input, env);
|
|
2363
|
+
const rows = Array.isArray(result.data) ? result.data : [];
|
|
2364
|
+
const meta = result.meta ?? {};
|
|
2365
|
+
const baseUrl = (await env.host.getSession()).baseUrl;
|
|
2366
|
+
if (format === "html") {
|
|
2367
|
+
const html = formatSearchHtml(rows, {
|
|
2368
|
+
baseUrl,
|
|
2369
|
+
keyword: meta.keyword,
|
|
2370
|
+
total: meta.total,
|
|
2371
|
+
pageNo: meta.pageNo,
|
|
2372
|
+
totalPage: meta.totalPage,
|
|
2373
|
+
heading: `\u300C${String(meta.keyword ?? "").trim() || "\u6863\u6848"}\u300D\u68C0\u7D22\u7ED3\u679C`
|
|
2374
|
+
});
|
|
2375
|
+
if (outputPath) {
|
|
2376
|
+
const absolutePath = resolve4(outputPath);
|
|
2377
|
+
await writeFile3(absolutePath, html, "utf8");
|
|
2378
|
+
ctx.output.raw(`HTML \u5DF2\u5199\u5165\uFF1A${absolutePath}`);
|
|
2379
|
+
return;
|
|
2380
|
+
}
|
|
2381
|
+
ctx.output.raw(html);
|
|
2382
|
+
return;
|
|
2383
|
+
}
|
|
2384
|
+
if (format === "card") {
|
|
2385
|
+
ctx.output.raw(formatSearchCard(rows, { baseUrl, ...meta }));
|
|
2386
|
+
return;
|
|
2387
|
+
}
|
|
2388
|
+
ctx.output.raw(formatSearchText(rows, meta));
|
|
2389
|
+
} catch (error) {
|
|
2390
|
+
console.error(JSON.stringify(failureEnvelope(error), null, 2));
|
|
2391
|
+
process.exitCode = isCliError(error) ? error.exitCode : 1 /* GeneralError */;
|
|
2392
|
+
}
|
|
2393
|
+
}
|
|
2394
|
+
var archiveShortcut = {
|
|
2395
|
+
name: "archive",
|
|
2396
|
+
description: "E10 \u6587\u4E66\u5B9A\u6863\u6848\u7BA1\u7406 CLI",
|
|
2397
|
+
category: "shortcut",
|
|
2398
|
+
register({ program, action }) {
|
|
2399
|
+
const archive = program.command("archive").description("E10 \u6587\u4E66\u5B9A\u6863\u6848\u7BA1\u7406");
|
|
2400
|
+
archive.command("schema").description("Print archive operation manifest for agents").action(action((ctx) => {
|
|
2401
|
+
ctx.output.write(archiveManifest, { json: true });
|
|
2402
|
+
}));
|
|
2403
|
+
withJsonInputOptions(archive.command("run").description("Run an archive operation with JSON input").argument("<operation>", "operation name, e.g. archive.borrow-car.list")).action(action(async (ctx, operation, options) => {
|
|
2404
|
+
await executeAndPrint(ctx, String(operation), await inputFrom(options));
|
|
2405
|
+
}));
|
|
2406
|
+
withJsonInputOptions(archive.command("fonds").description("List fonds of collect/manage library").option("--menu-sign <sign>", "collectLib or manageLib, default collectLib")).action(action(async (ctx, options) => {
|
|
2407
|
+
const opts = asOptions(options);
|
|
2408
|
+
await executeAndPrint(ctx, "archive.fonds.list", await inputFrom(options, {
|
|
2409
|
+
menuSign: stringOption(opts.menuSign)
|
|
2410
|
+
}));
|
|
2411
|
+
}));
|
|
2412
|
+
archive.command("prelib").description("List pre-archive efile library nodes").action(action(async (ctx) => {
|
|
2413
|
+
await executeAndPrint(ctx, "archive.prelib.tree", {});
|
|
2414
|
+
}));
|
|
2415
|
+
withJsonInputOptions(archive.command("search").description("Full-text search borrowable archives").option("--key <keyword>", "search keyword").option("--page-no <page>", "page number, starts from 0").option("--page-size <size>", "page size").option("--format <fmt>", "output format: json (default), text, card (in-chat), html").option("--output <path>", "save html output to file (html format only)")).action(action(async (ctx, options) => {
|
|
2416
|
+
const opts = asOptions(options);
|
|
2417
|
+
const input = await inputFrom(options, {
|
|
2418
|
+
key: stringOption(opts.key),
|
|
2419
|
+
pageNo: intOption(opts.pageNo),
|
|
2420
|
+
pageSize: intOption(opts.pageSize)
|
|
2421
|
+
});
|
|
2422
|
+
const format = String(stringOption(opts.format) ?? "json").toLowerCase();
|
|
2423
|
+
if (format === "text" || format === "card" || format === "html") {
|
|
2424
|
+
await executeSearchPrint(ctx, input, format, stringOption(opts.output));
|
|
2425
|
+
return;
|
|
2426
|
+
}
|
|
2427
|
+
await executeAndPrint(ctx, "archive.search.run", input);
|
|
2428
|
+
}));
|
|
2429
|
+
withJsonInputOptions(archive.command("info").description("Get archive basic info by arc id or dataId+formId").option("--arc-dangan <id>", "{\u6863\u6848ID}_{\u8868\u5355ID}").option("--data-id <id>", "archive data id").option("--form-id <id>", "archive form id")).action(action(async (ctx, options) => {
|
|
2430
|
+
const opts = asOptions(options);
|
|
2431
|
+
await executeAndPrint(ctx, "archive.info.get", await inputFrom(options, {
|
|
2432
|
+
arcDangan: stringOption(opts.arcDangan),
|
|
2433
|
+
dataId: stringOption(opts.dataId),
|
|
2434
|
+
formId: stringOption(opts.formId)
|
|
2435
|
+
}));
|
|
2436
|
+
}));
|
|
2437
|
+
const borrowCar = archive.command("borrow-car").description("Borrow car commands");
|
|
2438
|
+
withJsonInputOptions(borrowCar.command("list").description("List my borrow car entries").option("--page-no <page>", "page number, starts from 1").option("--page-size <size>", "page size")).action(action(async (ctx, options) => {
|
|
2439
|
+
const opts = asOptions(options);
|
|
2440
|
+
await executeAndPrint(ctx, "archive.borrow-car.list", await inputFrom(options, {
|
|
2441
|
+
pageNo: intOption(opts.pageNo),
|
|
2442
|
+
pageSize: intOption(opts.pageSize)
|
|
2443
|
+
}));
|
|
2444
|
+
}));
|
|
2445
|
+
withJsonInputOptions(borrowCar.command("add").description("Add archives to my borrow car directly (no confirmation)")).action(action(async (ctx, options) => {
|
|
2446
|
+
await executeAndPrint(ctx, "archive.borrow-car.add", await inputFrom(options));
|
|
2447
|
+
}));
|
|
2448
|
+
const borrowList = archive.command("borrow-list").description("Borrow order commands");
|
|
2449
|
+
withJsonInputOptions(borrowList.command("list").description("List my borrow orders").option("--page-no <page>", "page number, starts from 1").option("--page-size <size>", "page size")).action(action(async (ctx, options) => {
|
|
2450
|
+
const opts = asOptions(options);
|
|
2451
|
+
await executeAndPrint(ctx, "archive.borrow-list.list", await inputFrom(options, {
|
|
2452
|
+
pageNo: intOption(opts.pageNo),
|
|
2453
|
+
pageSize: intOption(opts.pageSize)
|
|
2454
|
+
}));
|
|
2455
|
+
}));
|
|
2456
|
+
withJsonInputOptions(borrowList.command("detail").description("Get borrow order detail").option("--data-id <id>", "borrow order data id")).action(action(async (ctx, options) => {
|
|
2457
|
+
const opts = asOptions(options);
|
|
2458
|
+
await executeAndPrint(ctx, "archive.borrow-list.detail", await inputFrom(options, {
|
|
2459
|
+
dataId: stringOption(opts.dataId)
|
|
2460
|
+
}));
|
|
2461
|
+
}));
|
|
2462
|
+
withJsonInputOptions(borrowList.command("download-prepare").description("Prepare downloading borrow order original files").option("--data-id <id>", "borrow order data id").option("--export-type <type>", "0 direct export, 1 grouped export").option("--export-structure <value>", "0 by entry, 1 by original text, 2 both").option("--group-field <field>", "entry group field id").option("--document-field <field>", "original text group field id").option("--output <path>", "output zip path, default is the user Downloads directory")).action(action(async (ctx, options) => {
|
|
2463
|
+
const opts = asOptions(options);
|
|
2464
|
+
await executeAndPrint(ctx, "archive.borrow-list.download.prepare", await inputFrom(options, {
|
|
2465
|
+
dataId: stringOption(opts.dataId),
|
|
2466
|
+
exportType: stringOption(opts.exportType),
|
|
2467
|
+
exportStructure: stringOption(opts.exportStructure),
|
|
2468
|
+
groupField: stringOption(opts.groupField),
|
|
2469
|
+
documentField: stringOption(opts.documentField),
|
|
2470
|
+
output: stringOption(opts.output)
|
|
2471
|
+
}));
|
|
2472
|
+
}));
|
|
2473
|
+
withJsonInputOptions(borrowList.command("download-apply").description("Apply downloading borrow order original files").option("--data-id <id>", "optional echo of borrow order data id").option("--continuation <token>", "continuation token from prepare").option("--yes", "confirm the write operation")).action(action(async (ctx, options) => {
|
|
2474
|
+
const opts = asOptions(options);
|
|
2475
|
+
await executeAndPrint(ctx, "archive.borrow-list.download.apply", await inputFrom(options, {
|
|
2476
|
+
dataId: stringOption(opts.dataId),
|
|
2477
|
+
continuation: stringOption(opts.continuation),
|
|
2478
|
+
confirm: opts.yes === true ? true : void 0
|
|
2479
|
+
}));
|
|
2480
|
+
}));
|
|
2481
|
+
const flow = archive.command("flow").description("Borrow workflow URL commands");
|
|
2482
|
+
withJsonInputOptions(flow.command("borrow-car-prepare").description("Prepare starting a borrow workflow from borrow car")).action(action(async (ctx, options) => {
|
|
2483
|
+
await executeAndPrint(ctx, "archive.flow.borrow-car.prepare", await inputFrom(options));
|
|
2484
|
+
}));
|
|
2485
|
+
withJsonInputOptions(flow.command("borrow-car-apply").description("Apply starting a borrow workflow from borrow car").option("--continuation <token>", "continuation token from prepare").option("--yes", "confirm the write operation")).action(action(async (ctx, options) => {
|
|
2486
|
+
const opts = asOptions(options);
|
|
2487
|
+
await executeAndPrint(ctx, "archive.flow.borrow-car.apply", await inputFrom(options, {
|
|
2488
|
+
continuation: stringOption(opts.continuation),
|
|
2489
|
+
confirm: opts.yes === true ? true : void 0
|
|
2490
|
+
}));
|
|
2491
|
+
}));
|
|
2492
|
+
withJsonInputOptions(flow.command("search-prepare").description("Prepare starting a borrow workflow from search results")).action(action(async (ctx, options) => {
|
|
2493
|
+
await executeAndPrint(ctx, "archive.flow.search.prepare", await inputFrom(options));
|
|
2494
|
+
}));
|
|
2495
|
+
withJsonInputOptions(flow.command("search-apply").description("Apply starting a borrow workflow from search results").option("--continuation <token>", "continuation token from prepare").option("--yes", "confirm the write operation")).action(action(async (ctx, options) => {
|
|
2496
|
+
const opts = asOptions(options);
|
|
2497
|
+
await executeAndPrint(ctx, "archive.flow.search.apply", await inputFrom(options, {
|
|
2498
|
+
continuation: stringOption(opts.continuation),
|
|
2499
|
+
confirm: opts.yes === true ? true : void 0
|
|
2500
|
+
}));
|
|
2501
|
+
}));
|
|
2502
|
+
withJsonInputOptions(flow.command("renew-prepare").description("Prepare renewing a borrow order").option("--data-id <id>", "borrow order data id")).action(action(async (ctx, options) => {
|
|
2503
|
+
const opts = asOptions(options);
|
|
2504
|
+
await executeAndPrint(ctx, "archive.flow.renew.prepare", await inputFrom(options, {
|
|
2505
|
+
dataId: stringOption(opts.dataId)
|
|
2506
|
+
}));
|
|
2507
|
+
}));
|
|
2508
|
+
withJsonInputOptions(flow.command("renew-apply").description("Apply renewing a borrow order").option("--continuation <token>", "continuation token from prepare").option("--yes", "confirm the write operation")).action(action(async (ctx, options) => {
|
|
2509
|
+
const opts = asOptions(options);
|
|
2510
|
+
await executeAndPrint(ctx, "archive.flow.renew.apply", await inputFrom(options, {
|
|
2511
|
+
continuation: stringOption(opts.continuation),
|
|
2512
|
+
confirm: opts.yes === true ? true : void 0
|
|
2513
|
+
}));
|
|
2514
|
+
}));
|
|
2515
|
+
const upload = archive.command("upload").description("Pre-archive upload commands");
|
|
2516
|
+
withJsonInputOptions(upload.command("prepare").description("Prepare uploading a local file to the pre-archive efile library").option("--file <path>", "local file path").option("--fonds-id <id>", "target fonds id").option("--tree-id <id>", "efile library node id, resolved automatically when omitted")).action(action(async (ctx, options) => {
|
|
2517
|
+
const opts = asOptions(options);
|
|
2518
|
+
await executeAndPrint(ctx, "archive.upload.prelib.prepare", await inputFrom(options, {
|
|
2519
|
+
file: stringOption(opts.file),
|
|
2520
|
+
fondsId: stringOption(opts.fondsId),
|
|
2521
|
+
treeId: stringOption(opts.treeId)
|
|
2522
|
+
}));
|
|
2523
|
+
}));
|
|
2524
|
+
withJsonInputOptions(upload.command("apply").description("Apply uploading a local file to the pre-archive efile library").option("--fonds-id <id>", "optional echo of target fonds id").option("--continuation <token>", "continuation token from prepare").option("--yes", "confirm the write operation")).action(action(async (ctx, options) => {
|
|
2525
|
+
const opts = asOptions(options);
|
|
2526
|
+
await executeAndPrint(ctx, "archive.upload.prelib.apply", await inputFrom(options, {
|
|
2527
|
+
fondsId: stringOption(opts.fondsId),
|
|
2528
|
+
continuation: stringOption(opts.continuation),
|
|
2529
|
+
confirm: opts.yes === true ? true : void 0
|
|
2530
|
+
}));
|
|
2531
|
+
}));
|
|
2532
|
+
}
|
|
2533
|
+
};
|
|
2534
|
+
export {
|
|
2535
|
+
archiveShortcut,
|
|
2536
|
+
inputFrom
|
|
2537
|
+
};
|