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,2109 @@
|
|
|
1
|
+
import { createRequire as __esbuildCreateRequire } from 'node:module';
|
|
2
|
+
const require = __esbuildCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
createE10RequestRuntime,
|
|
5
|
+
requireE10Session
|
|
6
|
+
} from "./chunk-H3WDBYJW.js";
|
|
7
|
+
import {
|
|
8
|
+
E10_SESSION_EXPIRED_MESSAGE,
|
|
9
|
+
getActiveProfile
|
|
10
|
+
} from "./chunk-324YPTC2.js";
|
|
11
|
+
import {
|
|
12
|
+
CliError,
|
|
13
|
+
isCliError,
|
|
14
|
+
toErrorEnvelope
|
|
15
|
+
} from "./chunk-LUSPKZKY.js";
|
|
16
|
+
import "./chunk-BUSC6UAE.js";
|
|
17
|
+
|
|
18
|
+
// src/shortcuts/asset/index.ts
|
|
19
|
+
import { readFile as readFile2 } from "node:fs/promises";
|
|
20
|
+
|
|
21
|
+
// src/shortcuts/asset/continuation.ts
|
|
22
|
+
import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
|
|
23
|
+
import { existsSync } from "node:fs";
|
|
24
|
+
import { chmod, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
25
|
+
import { homedir } from "node:os";
|
|
26
|
+
import { resolve } from "node:path";
|
|
27
|
+
|
|
28
|
+
// src/shortcuts/asset/errors.ts
|
|
29
|
+
var ZiguanjiaCliError = class extends CliError {
|
|
30
|
+
type;
|
|
31
|
+
subtype;
|
|
32
|
+
code;
|
|
33
|
+
retryable;
|
|
34
|
+
stage;
|
|
35
|
+
details;
|
|
36
|
+
partialData;
|
|
37
|
+
constructor(type, subtype, message, options = {}) {
|
|
38
|
+
super(message, options.exitCode ?? 5 /* InternalError */);
|
|
39
|
+
this.name = "ZiguanjiaCliError";
|
|
40
|
+
this.type = type;
|
|
41
|
+
this.subtype = subtype;
|
|
42
|
+
this.code = options.code;
|
|
43
|
+
this.retryable = options.retryable ?? false;
|
|
44
|
+
this.stage = options.stage;
|
|
45
|
+
this.details = options.details;
|
|
46
|
+
this.partialData = options.partialData;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
function ziguanjiaValidationError(subtype, message, details) {
|
|
50
|
+
return new ZiguanjiaCliError("validation", subtype, message, {
|
|
51
|
+
details,
|
|
52
|
+
exitCode: 2 /* UsageError */
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function ziguanjiaAuthError(subtype, message, details) {
|
|
56
|
+
return new ZiguanjiaCliError("authentication", subtype, message, {
|
|
57
|
+
details,
|
|
58
|
+
exitCode: 3 /* AuthError */
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function ziguanjiaNetworkError(subtype, message, options = {}) {
|
|
62
|
+
return new ZiguanjiaCliError("network", subtype, message, {
|
|
63
|
+
...options,
|
|
64
|
+
retryable: options.retryable ?? true,
|
|
65
|
+
exitCode: 4 /* NetworkError */
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function ziguanjiaBusinessError(subtype, message, options = {}) {
|
|
69
|
+
return new ZiguanjiaCliError("api", subtype, message, {
|
|
70
|
+
code: options.code,
|
|
71
|
+
details: options.details,
|
|
72
|
+
retryable: options.retryable ?? false,
|
|
73
|
+
exitCode: 1 /* GeneralError */
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// src/shortcuts/asset/continuation.ts
|
|
78
|
+
function stateRoot(ctx) {
|
|
79
|
+
const configured = ctx?.config?.path();
|
|
80
|
+
if (configured) return resolve(configured, "..");
|
|
81
|
+
return process.env.WEAVER_WORK_CLI_HOME || process.env.WORK_CLI_HOME || resolve(homedir(), ".weaver-work-cli");
|
|
82
|
+
}
|
|
83
|
+
async function loadKey(ctx) {
|
|
84
|
+
const keysDir = resolve(stateRoot(ctx), "keys");
|
|
85
|
+
const filename = resolve(keysDir, "ziguanjia-continuation.key");
|
|
86
|
+
await mkdir(keysDir, { recursive: true, mode: 448 });
|
|
87
|
+
if (existsSync(filename)) return readFile(filename);
|
|
88
|
+
const key = randomBytes(32);
|
|
89
|
+
try {
|
|
90
|
+
await writeFile(filename, key, { flag: "wx", mode: 384 });
|
|
91
|
+
if (process.platform !== "win32") await chmod(filename, 384).catch(() => void 0);
|
|
92
|
+
return key;
|
|
93
|
+
} catch {
|
|
94
|
+
return readFile(filename);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function encode(value) {
|
|
98
|
+
return Buffer.from(JSON.stringify(value)).toString("base64url");
|
|
99
|
+
}
|
|
100
|
+
function signature(payload, key) {
|
|
101
|
+
return createHmac("sha256", key).update(payload).digest("base64url");
|
|
102
|
+
}
|
|
103
|
+
function createZiguanjiaContinuationSigner(ctx) {
|
|
104
|
+
return {
|
|
105
|
+
async issue(payload, ttlMs = 10 * 6e4) {
|
|
106
|
+
const issuedAt = Date.now();
|
|
107
|
+
const body = encode({ ...payload, issuedAt, expiresAt: issuedAt + ttlMs });
|
|
108
|
+
const sig = signature(body, await loadKey(ctx));
|
|
109
|
+
return `${body}.${sig}`;
|
|
110
|
+
},
|
|
111
|
+
async verify(token, expectedOperation) {
|
|
112
|
+
if (typeof token !== "string" || !token.includes(".")) {
|
|
113
|
+
throw ziguanjiaValidationError("continuation_invalid", "continuation \u65E0\u6548");
|
|
114
|
+
}
|
|
115
|
+
const [body, provided] = token.split(".");
|
|
116
|
+
const expected = signature(body, await loadKey(ctx));
|
|
117
|
+
const valid = provided.length === expected.length && timingSafeEqual(Buffer.from(provided), Buffer.from(expected));
|
|
118
|
+
if (!valid) throw ziguanjiaValidationError("continuation_invalid", "continuation \u7B7E\u540D\u6821\u9A8C\u5931\u8D25");
|
|
119
|
+
let value;
|
|
120
|
+
try {
|
|
121
|
+
value = JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
|
|
122
|
+
} catch {
|
|
123
|
+
throw ziguanjiaValidationError("continuation_invalid", "continuation \u5185\u5BB9\u65E0\u6CD5\u89E3\u6790");
|
|
124
|
+
}
|
|
125
|
+
if (value.operation !== expectedOperation) {
|
|
126
|
+
throw ziguanjiaValidationError("continuation_mismatch", "continuation \u4E0D\u5C5E\u4E8E\u5F53\u524D\u64CD\u4F5C");
|
|
127
|
+
}
|
|
128
|
+
if (!Number.isSafeInteger(value.expiresAt) || value.expiresAt < Date.now()) {
|
|
129
|
+
throw ziguanjiaValidationError("continuation_expired", "continuation \u5DF2\u8FC7\u671F");
|
|
130
|
+
}
|
|
131
|
+
return value;
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// src/shortcuts/asset/host.ts
|
|
137
|
+
var EBUILDER_PREFIX = process.env.WEAVER_EBUILDER_PREFIX || "/api/ebuilder";
|
|
138
|
+
var ESB_TRIGGER_PATH = "/api/esb/server/event/triggerActionFlow";
|
|
139
|
+
var ASSET_APP_TAG = "weaver-asset-eb";
|
|
140
|
+
var GET_APP_IDS_PATH = "/api/bs/ebuilder/app/tags/getAppIds";
|
|
141
|
+
var GET_OBJS_BY_TAG_PATH = "/api/ebuilder/form/obj/getObjsByTag";
|
|
142
|
+
var FORM_FIELDS_PATH = "/api/ebuilder/common/ds/fields";
|
|
143
|
+
var SEARCH_SUBCOMPANY_PATH = "/api/hrm/common/browser/data/subcompany";
|
|
144
|
+
var FORBIDDEN_INPUT_KEYS = /* @__PURE__ */ new Set([
|
|
145
|
+
"access_token",
|
|
146
|
+
"app_key",
|
|
147
|
+
"app_secret",
|
|
148
|
+
"cookie",
|
|
149
|
+
"eteamsid",
|
|
150
|
+
"token",
|
|
151
|
+
"sedit"
|
|
152
|
+
]);
|
|
153
|
+
function pickPersonField(fields, candidates) {
|
|
154
|
+
const lower = new Set(candidates.map((c) => c.toLowerCase()));
|
|
155
|
+
const byKey = fields.find(
|
|
156
|
+
(f) => f.name && lower.has(f.name.toLowerCase()) || f.dataKey && lower.has(f.dataKey.toLowerCase())
|
|
157
|
+
);
|
|
158
|
+
if (byKey) return byKey;
|
|
159
|
+
const byText = fields.find((f) => {
|
|
160
|
+
const t = f.text ?? "";
|
|
161
|
+
return /领用|使用/.test(t) && /人|人员/.test(t);
|
|
162
|
+
});
|
|
163
|
+
return byText;
|
|
164
|
+
}
|
|
165
|
+
function ebuilderPath(endpoint, interfacePk) {
|
|
166
|
+
return `${EBUILDER_PREFIX}/form/formdata/v2/${endpoint}/${interfacePk}`;
|
|
167
|
+
}
|
|
168
|
+
function wrapEbuilderBody(body, operator) {
|
|
169
|
+
return {
|
|
170
|
+
datajson: {
|
|
171
|
+
...body,
|
|
172
|
+
header: { operator, ...body.header && typeof body.header === "object" ? body.header : {} }
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function assertPath(requestPath) {
|
|
177
|
+
if (typeof requestPath !== "string" || !requestPath.startsWith("/") || requestPath.startsWith("//")) {
|
|
178
|
+
throw ziguanjiaValidationError("path_invalid", "\u8BF7\u6C42\u8DEF\u5F84\u5FC5\u987B\u662F\u76F8\u5BF9\u7EDD\u5BF9\u8DEF\u5F84");
|
|
179
|
+
}
|
|
180
|
+
if (/^https?:/i.test(requestPath) || /[\r\n]/.test(requestPath) || requestPath.includes("/../")) {
|
|
181
|
+
throw ziguanjiaValidationError("path_invalid", "\u8BF7\u6C42\u8DEF\u5F84\u4E0D\u5141\u8BB8\u8DE8\u57DF\u6216\u8DEF\u5F84\u9003\u9038");
|
|
182
|
+
}
|
|
183
|
+
if (!requestPath.startsWith("/api/")) {
|
|
184
|
+
throw ziguanjiaValidationError("path_not_allowed", "E10 API \u53EA\u80FD\u8C03\u7528 /api/ \u8DEF\u5F84");
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
function responseDatajson(value) {
|
|
188
|
+
if (value && typeof value === "object" && "datajson" in value) return value.datajson;
|
|
189
|
+
return value;
|
|
190
|
+
}
|
|
191
|
+
function isEbSessionExpired(value) {
|
|
192
|
+
const root = responseDatajson(value);
|
|
193
|
+
const code = root?.ret ?? root?.code ?? root?.status;
|
|
194
|
+
return code !== void 0 && (String(code) === "-2" || String(code) === "401" || String(code) === "403");
|
|
195
|
+
}
|
|
196
|
+
function ebMessage(value) {
|
|
197
|
+
const root = responseDatajson(value);
|
|
198
|
+
return typeof root?.message === "string" ? root.message : typeof root?.msg === "string" ? root.msg : "\u6CDB\u5FAE\u63A5\u53E3\u8FD4\u56DE\u4E1A\u52A1\u5931\u8D25";
|
|
199
|
+
}
|
|
200
|
+
function ebCode(value) {
|
|
201
|
+
const root = responseDatajson(value);
|
|
202
|
+
return root?.ret ?? root?.code ?? root?.status;
|
|
203
|
+
}
|
|
204
|
+
function isEbSuccessCode(code) {
|
|
205
|
+
if (code === void 0) return true;
|
|
206
|
+
if (code === 0 || code === 200) return true;
|
|
207
|
+
if (code === true || code === "true") return true;
|
|
208
|
+
if (typeof code === "string") {
|
|
209
|
+
const text = code.trim();
|
|
210
|
+
return text === "0" || text === "200";
|
|
211
|
+
}
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
function normalizeBigId(raw) {
|
|
215
|
+
if (raw === void 0 || raw === null) return void 0;
|
|
216
|
+
if (typeof raw === "object") return void 0;
|
|
217
|
+
const text = String(raw).trim();
|
|
218
|
+
return text === "" ? void 0 : text;
|
|
219
|
+
}
|
|
220
|
+
function tagDataRoot(value) {
|
|
221
|
+
const root = value && typeof value === "object" && "datajson" in value ? value.datajson : value;
|
|
222
|
+
return root && typeof root === "object" ? root : void 0;
|
|
223
|
+
}
|
|
224
|
+
function pickAppId(value) {
|
|
225
|
+
const data = tagDataRoot(value)?.data;
|
|
226
|
+
if (!Array.isArray(data) || data.length === 0) return void 0;
|
|
227
|
+
const first = data[0];
|
|
228
|
+
const raw = first && typeof first === "object" ? first.appId ?? first.id : first;
|
|
229
|
+
return normalizeBigId(raw);
|
|
230
|
+
}
|
|
231
|
+
function pickObjId(value, formTag) {
|
|
232
|
+
const data = tagDataRoot(value)?.data;
|
|
233
|
+
if (!Array.isArray(data)) return void 0;
|
|
234
|
+
const match = data.find((item) => item && typeof item === "object" && String(item.tag ?? "") === formTag);
|
|
235
|
+
if (!match) return void 0;
|
|
236
|
+
return normalizeBigId(match.objId ?? match.id);
|
|
237
|
+
}
|
|
238
|
+
function createZiguanjiaHost(ctx) {
|
|
239
|
+
let e10Session = null;
|
|
240
|
+
let sessionContext = null;
|
|
241
|
+
async function ensureSession() {
|
|
242
|
+
if (!e10Session) {
|
|
243
|
+
e10Session = await requireE10Session(ctx);
|
|
244
|
+
sessionContext = {
|
|
245
|
+
baseUrl: e10Session.getBaseUrl(),
|
|
246
|
+
profile: ctx.getGlobalOptions().profile || getActiveProfile(),
|
|
247
|
+
userId: e10Session.userId,
|
|
248
|
+
subcompany: e10Session.subcompany
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
return e10Session;
|
|
252
|
+
}
|
|
253
|
+
async function getSession() {
|
|
254
|
+
await ensureSession();
|
|
255
|
+
return sessionContext;
|
|
256
|
+
}
|
|
257
|
+
async function runtime() {
|
|
258
|
+
return createE10RequestRuntime(ctx, await ensureSession(), {});
|
|
259
|
+
}
|
|
260
|
+
const appIdCache = /* @__PURE__ */ new Map();
|
|
261
|
+
const formIdCache = /* @__PURE__ */ new Map();
|
|
262
|
+
const formFieldsCache = /* @__PURE__ */ new Map();
|
|
263
|
+
const subcompanyIdCache = /* @__PURE__ */ new Map();
|
|
264
|
+
async function ebuilderGetJson(path2, query, operation) {
|
|
265
|
+
assertPath(path2);
|
|
266
|
+
const response = await (await runtime()).requestJson({
|
|
267
|
+
module: "asset",
|
|
268
|
+
operation,
|
|
269
|
+
method: "GET",
|
|
270
|
+
path: path2,
|
|
271
|
+
query,
|
|
272
|
+
bigIntStrings: true
|
|
273
|
+
});
|
|
274
|
+
if (response.status === 401 || response.status === 302) {
|
|
275
|
+
throw ziguanjiaAuthError(
|
|
276
|
+
"session_expired",
|
|
277
|
+
E10_SESSION_EXPIRED_MESSAGE,
|
|
278
|
+
{ httpStatus: response.status }
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
if (response.parseError) {
|
|
282
|
+
throw ziguanjiaNetworkError("protocol", `\u63A5\u53E3\u8FD4\u56DE\u4E0D\u662F\u5408\u6CD5 JSON\uFF08HTTP ${response.status}\uFF09`, { retryable: false });
|
|
283
|
+
}
|
|
284
|
+
if (response.status < 200 || response.status >= 300) {
|
|
285
|
+
throw ziguanjiaBusinessError("http_error", `\u6CDB\u5FAE\u63A5\u53E3 HTTP ${response.status}`, { code: response.status, details: { message: ebMessage(response.value) } });
|
|
286
|
+
}
|
|
287
|
+
return response.value;
|
|
288
|
+
}
|
|
289
|
+
async function resolveAppId(appTag, envKey, operation) {
|
|
290
|
+
const cacheKey = `${envKey}|app|${appTag}`;
|
|
291
|
+
const cached = appIdCache.get(cacheKey);
|
|
292
|
+
if (cached) return cached;
|
|
293
|
+
const value = await ebuilderGetJson(GET_APP_IDS_PATH, { tag: appTag }, operation);
|
|
294
|
+
const appId = pickAppId(value);
|
|
295
|
+
if (!appId) {
|
|
296
|
+
throw ziguanjiaValidationError("resolve_not_found", `\u672A\u89E3\u6790\u5230\u5E94\u7528\u6807\u7B7E ${appTag} \u5BF9\u5E94\u7684\u5E94\u7528 ID\uFF0C\u94FE\u63A5\u6682\u4E0D\u53EF\u7528`);
|
|
297
|
+
}
|
|
298
|
+
appIdCache.set(cacheKey, appId);
|
|
299
|
+
return appId;
|
|
300
|
+
}
|
|
301
|
+
async function resolveFormId(request) {
|
|
302
|
+
const appTag = request.appTag && request.appTag.trim() !== "" ? request.appTag : ASSET_APP_TAG;
|
|
303
|
+
const { formTag, operation } = request;
|
|
304
|
+
const session = await getSession();
|
|
305
|
+
const cacheKey = `${session.baseUrl}|${appTag}|${formTag}`;
|
|
306
|
+
const cached = formIdCache.get(cacheKey);
|
|
307
|
+
if (cached) return cached;
|
|
308
|
+
const appId = await resolveAppId(appTag, session.baseUrl, operation);
|
|
309
|
+
const value = await ebuilderGetJson(GET_OBJS_BY_TAG_PATH, { appId, tag: formTag }, operation);
|
|
310
|
+
const objId = pickObjId(value, formTag);
|
|
311
|
+
if (!objId) {
|
|
312
|
+
throw ziguanjiaValidationError("resolve_not_found", `\u672A\u89E3\u6790\u5230\u8868\u5355\u6807\u8BC6 ${formTag} \u5BF9\u5E94\u7684\u8868\u5355 ID\uFF08objId\uFF09\uFF0C\u94FE\u63A5\u6682\u4E0D\u53EF\u7528`);
|
|
313
|
+
}
|
|
314
|
+
formIdCache.set(cacheKey, objId);
|
|
315
|
+
return objId;
|
|
316
|
+
}
|
|
317
|
+
async function getFormFields(formTag) {
|
|
318
|
+
const session = await getSession();
|
|
319
|
+
const cacheKey = `${session.baseUrl}|${formTag}`;
|
|
320
|
+
const cached = formFieldsCache.get(cacheKey);
|
|
321
|
+
if (cached) return cached;
|
|
322
|
+
const objId = await resolveFormId({ formTag, operation: `getFormFields:${formTag}` });
|
|
323
|
+
const fd = new FormData();
|
|
324
|
+
fd.set("groupId", objId);
|
|
325
|
+
fd.set("sourceId", objId);
|
|
326
|
+
fd.set("sourceType", "FORM");
|
|
327
|
+
fd.set("detailFieldsGroup", "true");
|
|
328
|
+
fd.set("enableMerge", "true");
|
|
329
|
+
fd.set("customParam", '{"terminal":""}');
|
|
330
|
+
fd.set("params", "[]");
|
|
331
|
+
const response = await (await runtime()).requestJson({
|
|
332
|
+
module: "asset",
|
|
333
|
+
operation: `getFormFields:${formTag}`,
|
|
334
|
+
method: "POST",
|
|
335
|
+
path: FORM_FIELDS_PATH,
|
|
336
|
+
formData: fd,
|
|
337
|
+
bigIntStrings: false
|
|
338
|
+
});
|
|
339
|
+
if (response.status === 401 || response.status === 302) {
|
|
340
|
+
throw ziguanjiaAuthError(
|
|
341
|
+
"session_expired",
|
|
342
|
+
E10_SESSION_EXPIRED_MESSAGE,
|
|
343
|
+
{ httpStatus: response.status }
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
if (response.parseError) {
|
|
347
|
+
throw ziguanjiaNetworkError("protocol", `\u63A5\u53E3\u8FD4\u56DE\u4E0D\u662F\u5408\u6CD5 JSON\uFF08HTTP ${response.status}\uFF09`, { retryable: false });
|
|
348
|
+
}
|
|
349
|
+
if (response.status < 200 || response.status >= 300) {
|
|
350
|
+
throw ziguanjiaBusinessError("http_error", `\u6CDB\u5FAE\u63A5\u53E3 HTTP ${response.status}`, { code: response.status, details: { message: ebMessage(response.value) } });
|
|
351
|
+
}
|
|
352
|
+
const value = response.value;
|
|
353
|
+
if (!isEbSuccessCode(value?.code ?? value?.status)) {
|
|
354
|
+
throw ziguanjiaBusinessError("form_fields_failed", ebMessage(value), { code: String(value?.code ?? value?.status), details: { result: value } });
|
|
355
|
+
}
|
|
356
|
+
const groups = Array.isArray(value?.data) ? value.data : [];
|
|
357
|
+
const fields = [];
|
|
358
|
+
for (const group of groups) {
|
|
359
|
+
if (!group || typeof group !== "object") continue;
|
|
360
|
+
const groupFields = group.fields;
|
|
361
|
+
if (!Array.isArray(groupFields)) continue;
|
|
362
|
+
for (const f of groupFields) {
|
|
363
|
+
if (!f || typeof f !== "object") continue;
|
|
364
|
+
fields.push({
|
|
365
|
+
name: typeof f.name === "string" ? f.name : String(f.name ?? ""),
|
|
366
|
+
dataKey: f.config?.dataKey !== void 0 ? String(f.config.dataKey) : void 0,
|
|
367
|
+
text: f.text !== void 0 ? String(f.text) : void 0,
|
|
368
|
+
compType: f.compType !== void 0 ? String(f.compType) : void 0,
|
|
369
|
+
mainField: f.mainField === true
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
formFieldsCache.set(cacheKey, fields);
|
|
374
|
+
return fields;
|
|
375
|
+
}
|
|
376
|
+
async function resolveSubcompanyIdByName(name) {
|
|
377
|
+
const trimmed = typeof name === "string" ? name.trim() : "";
|
|
378
|
+
if (trimmed === "") {
|
|
379
|
+
throw ziguanjiaValidationError(
|
|
380
|
+
"company_unresolved",
|
|
381
|
+
"\u65E0\u6CD5\u4ECE\u767B\u5F55\u4F1A\u8BDD\u786E\u5B9A\u5F53\u524D\u767B\u5F55\u4EBA\u6240\u5C5E\u5206\u90E8\u540D\u79F0\uFF0C\u8BF7\u5728\u8F93\u5165\u4E2D\u663E\u5F0F\u63D0\u4F9B company_ids"
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
const session = await getSession();
|
|
385
|
+
const cacheKey = `${session.baseUrl}|subcompany|${trimmed}`;
|
|
386
|
+
const cached = subcompanyIdCache.get(cacheKey);
|
|
387
|
+
if (cached) return cached;
|
|
388
|
+
assertPath(SEARCH_SUBCOMPANY_PATH);
|
|
389
|
+
const response = await (await runtime()).requestJson({
|
|
390
|
+
module: "asset",
|
|
391
|
+
operation: "resolveSubcompany",
|
|
392
|
+
method: "POST",
|
|
393
|
+
path: SEARCH_SUBCOMPANY_PATH,
|
|
394
|
+
body: {
|
|
395
|
+
browserMultiple: true,
|
|
396
|
+
authWecahtBook: false,
|
|
397
|
+
wxDepNeedConvertCount: 0,
|
|
398
|
+
wxEmpNeedConvertCount: 0,
|
|
399
|
+
wxTotalNeedConvertCount: 0,
|
|
400
|
+
virtualType: "ALL",
|
|
401
|
+
cmd: "list",
|
|
402
|
+
current: 1,
|
|
403
|
+
pageSize: 200,
|
|
404
|
+
formDatas: { name: [{ nameCondition: { id: "eq", content: "\u7B49\u4E8E", disabled: false }, name: trimmed }] },
|
|
405
|
+
quickSearchDatas: {},
|
|
406
|
+
type: "and",
|
|
407
|
+
stopDepartment: false
|
|
408
|
+
},
|
|
409
|
+
bigIntStrings: true
|
|
410
|
+
});
|
|
411
|
+
if (response.status === 401 || response.status === 302) {
|
|
412
|
+
throw ziguanjiaAuthError(
|
|
413
|
+
"session_expired",
|
|
414
|
+
E10_SESSION_EXPIRED_MESSAGE,
|
|
415
|
+
{ httpStatus: response.status }
|
|
416
|
+
);
|
|
417
|
+
}
|
|
418
|
+
if (response.parseError) {
|
|
419
|
+
throw ziguanjiaNetworkError("protocol", `\u63A5\u53E3\u8FD4\u56DE\u4E0D\u662F\u5408\u6CD5 JSON\uFF08HTTP ${response.status}\uFF09`, { retryable: false });
|
|
420
|
+
}
|
|
421
|
+
if (response.status < 200 || response.status >= 300) {
|
|
422
|
+
throw ziguanjiaBusinessError("http_error", `\u6CDB\u5FAE\u63A5\u53E3 HTTP ${response.status}`, { code: response.status, details: { message: ebMessage(response.value) } });
|
|
423
|
+
}
|
|
424
|
+
const value = response.value;
|
|
425
|
+
const rows = Array.isArray(value?.data?.data) ? value.data.data : [];
|
|
426
|
+
if (rows.length === 0) {
|
|
427
|
+
throw ziguanjiaValidationError("company_unresolved", `\u672A\u627E\u5230\u5206\u90E8\u300C${trimmed}\u300D\u5BF9\u5E94\u7684 ID\uFF0C\u8BF7\u5728\u8F93\u5165\u4E2D\u663E\u5F0F\u63D0\u4F9B company_ids`);
|
|
428
|
+
}
|
|
429
|
+
if (rows.length > 1) {
|
|
430
|
+
throw ziguanjiaValidationError("company_ambiguous", `\u5206\u90E8\u540D\u79F0\u300C${trimmed}\u300D\u547D\u4E2D ${rows.length} \u6761\uFF0C\u65E0\u6CD5\u552F\u4E00\u786E\u5B9A\uFF0C\u8BF7\u5728\u8F93\u5165\u4E2D\u663E\u5F0F\u63D0\u4F9B company_ids`);
|
|
431
|
+
}
|
|
432
|
+
const id = normalizeBigId(rows[0]?.id ?? rows[0]?.subcompanyId);
|
|
433
|
+
if (!id) {
|
|
434
|
+
throw ziguanjiaValidationError("company_unresolved", `\u5206\u90E8\u300C${trimmed}\u300D\u8FD4\u56DE\u7F3A\u5C11 ID\uFF0C\u8BF7\u5728\u8F93\u5165\u4E2D\u663E\u5F0F\u63D0\u4F9B company_ids`);
|
|
435
|
+
}
|
|
436
|
+
subcompanyIdCache.set(cacheKey, id);
|
|
437
|
+
return id;
|
|
438
|
+
}
|
|
439
|
+
function handleEbusiness(value) {
|
|
440
|
+
if (isEbSessionExpired(value)) {
|
|
441
|
+
throw ziguanjiaAuthError(
|
|
442
|
+
"session_expired",
|
|
443
|
+
E10_SESSION_EXPIRED_MESSAGE,
|
|
444
|
+
{ ret: ebCode(value) }
|
|
445
|
+
);
|
|
446
|
+
}
|
|
447
|
+
const code = ebCode(value);
|
|
448
|
+
if (!isEbSuccessCode(code)) {
|
|
449
|
+
throw ziguanjiaBusinessError("business_error", ebMessage(value), { code: String(code), details: { result: value } });
|
|
450
|
+
}
|
|
451
|
+
return value;
|
|
452
|
+
}
|
|
453
|
+
async function ebuilderRequest(request) {
|
|
454
|
+
const { endpoint, interfacePk, body, operation, query } = request;
|
|
455
|
+
assertPath(ebuilderPath(endpoint, interfacePk));
|
|
456
|
+
const session = await getSession();
|
|
457
|
+
const fullBody = wrapEbuilderBody(body, session.userId);
|
|
458
|
+
const response = await (await runtime()).requestJson({
|
|
459
|
+
module: "asset",
|
|
460
|
+
operation,
|
|
461
|
+
method: "POST",
|
|
462
|
+
path: ebuilderPath(endpoint, interfacePk),
|
|
463
|
+
query,
|
|
464
|
+
body: fullBody,
|
|
465
|
+
bigIntStrings: true
|
|
466
|
+
});
|
|
467
|
+
if (response.status === 401 || response.status === 302) {
|
|
468
|
+
throw ziguanjiaAuthError(
|
|
469
|
+
"session_expired",
|
|
470
|
+
E10_SESSION_EXPIRED_MESSAGE,
|
|
471
|
+
{ httpStatus: response.status }
|
|
472
|
+
);
|
|
473
|
+
}
|
|
474
|
+
if (response.parseError) {
|
|
475
|
+
throw ziguanjiaNetworkError("protocol", `\u63A5\u53E3\u8FD4\u56DE\u4E0D\u662F\u5408\u6CD5 JSON\uFF08HTTP ${response.status}\uFF09`, { retryable: false });
|
|
476
|
+
}
|
|
477
|
+
if (response.status < 200 || response.status >= 300) {
|
|
478
|
+
throw ziguanjiaBusinessError("http_error", `\u6CDB\u5FAE\u63A5\u53E3 HTTP ${response.status}`, { code: response.status, details: { message: ebMessage(response.value) } });
|
|
479
|
+
}
|
|
480
|
+
return handleEbusiness(response.value);
|
|
481
|
+
}
|
|
482
|
+
async function actionFlow(request) {
|
|
483
|
+
const { uniqueIndent, mainTable, operation, moduleSource } = request;
|
|
484
|
+
assertPath(ESB_TRIGGER_PATH);
|
|
485
|
+
const session = await getSession();
|
|
486
|
+
const payload = {
|
|
487
|
+
customParams: { mainTable },
|
|
488
|
+
uniqueIndent,
|
|
489
|
+
employeeId: session.userId
|
|
490
|
+
};
|
|
491
|
+
if (moduleSource) payload.moduleSource = moduleSource;
|
|
492
|
+
const response = await (await runtime()).requestJson({
|
|
493
|
+
module: "asset",
|
|
494
|
+
operation,
|
|
495
|
+
method: "POST",
|
|
496
|
+
path: ESB_TRIGGER_PATH,
|
|
497
|
+
body: payload,
|
|
498
|
+
bigIntStrings: true
|
|
499
|
+
});
|
|
500
|
+
if (response.status === 401 || response.status === 302) {
|
|
501
|
+
throw ziguanjiaAuthError(
|
|
502
|
+
"session_expired",
|
|
503
|
+
E10_SESSION_EXPIRED_MESSAGE,
|
|
504
|
+
{ httpStatus: response.status }
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
if (response.parseError) {
|
|
508
|
+
throw ziguanjiaNetworkError("protocol", `\u63A5\u53E3\u8FD4\u56DE\u4E0D\u662F\u5408\u6CD5 JSON\uFF08HTTP ${response.status}\uFF09`, { retryable: false });
|
|
509
|
+
}
|
|
510
|
+
if (response.status < 200 || response.status >= 300) {
|
|
511
|
+
throw ziguanjiaBusinessError("http_error", `ESB \u63A5\u53E3 HTTP ${response.status}`, { code: response.status, details: { message: ebMessage(response.value) } });
|
|
512
|
+
}
|
|
513
|
+
const value = response.value;
|
|
514
|
+
const resultCode = value?.resultCode;
|
|
515
|
+
if (resultCode === void 0) {
|
|
516
|
+
throw ziguanjiaBusinessError("actionflow_no_code", "\u52A8\u4F5C\u6D41\u8FD4\u56DE\u7F3A\u5C11 resultCode", { details: { result: value } });
|
|
517
|
+
}
|
|
518
|
+
if (resultCode !== 200) {
|
|
519
|
+
throw ziguanjiaBusinessError(
|
|
520
|
+
"actionflow_failed",
|
|
521
|
+
`\u52A8\u4F5C\u6D41\u6267\u884C\u672A\u6210\u529F\uFF08resultCode=${resultCode}\uFF09\uFF1A${value?.resultMsg || ""}`,
|
|
522
|
+
{ code: resultCode, details: { result: value }, retryable: resultCode === 507 || resultCode === 508 || resultCode === 511 }
|
|
523
|
+
);
|
|
524
|
+
}
|
|
525
|
+
return value;
|
|
526
|
+
}
|
|
527
|
+
return { ebuilderRequest, actionFlow, getSession, resolveFormId, getFormFields, resolveSubcompanyIdByName };
|
|
528
|
+
}
|
|
529
|
+
function buildCardLink(baseUrl, objId, dataId) {
|
|
530
|
+
if (typeof baseUrl !== "string" || baseUrl.trim() === "" || !objId || !dataId) return null;
|
|
531
|
+
return `${baseUrl.replace(/\/+$/u, "")}/sp/ebdfpage/card/0/${objId}/${dataId}`;
|
|
532
|
+
}
|
|
533
|
+
function assertNoForbiddenKeys(value, location = "input") {
|
|
534
|
+
if (!value || typeof value !== "object") return;
|
|
535
|
+
if (Array.isArray(value)) {
|
|
536
|
+
value.forEach((item, index) => assertNoForbiddenKeys(item, `${location}[${index}]`));
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
for (const [key, child] of Object.entries(value)) {
|
|
540
|
+
if (FORBIDDEN_INPUT_KEYS.has(key) || FORBIDDEN_INPUT_KEYS.has(key.toLowerCase())) {
|
|
541
|
+
throw ziguanjiaValidationError("field_forbidden", `\u7981\u6B62\u4E1A\u52A1\u8F93\u5165\u5B57\u6BB5\uFF1A${location}.${key}`);
|
|
542
|
+
}
|
|
543
|
+
assertNoForbiddenKeys(child, `${location}.${key}`);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// src/shortcuts/asset/manifest.ts
|
|
548
|
+
var EB_INTERFACE_PK = {
|
|
549
|
+
appver: "zgjasset_search_appver",
|
|
550
|
+
baseList: "zgjasset_base_list",
|
|
551
|
+
baseDetail: "zgjasset_base_detail",
|
|
552
|
+
useList: "zgjasset_uselist",
|
|
553
|
+
repairList: "zgjasset_repaillist",
|
|
554
|
+
purchList: "zgjasset_purch_applylist",
|
|
555
|
+
create: "zgjasset_create_baseinfo",
|
|
556
|
+
update: "zgjasset_update_baseinfo",
|
|
557
|
+
location: "zgjasset_location_info",
|
|
558
|
+
status: "zgjasset_status_info",
|
|
559
|
+
type: "zgjasset_type_info",
|
|
560
|
+
depreSetting: "depreSetting",
|
|
561
|
+
depreTask: "zgjasset_depretask_create"
|
|
562
|
+
};
|
|
563
|
+
var ES_UNIQUE_INDENT = {
|
|
564
|
+
use: "A972BB58A29C44208F51C12A6F3AF879",
|
|
565
|
+
returnQuery: "78205C1A40CC4AB69412510515A61D96",
|
|
566
|
+
returnCreate: "09CDE8C246E046F3874120B0C2853E95",
|
|
567
|
+
repairQuery: "5A19DF0B37164417BC4C2E81A424BCA4",
|
|
568
|
+
repairCreate: "13DD5662227A4F5EACF47A74FB6E0B17",
|
|
569
|
+
purch: "41439299554143BAB36FD108B191C214",
|
|
570
|
+
deprePrecheck: "37D3EAC1C5A44A93A3AF93C1420925FE"
|
|
571
|
+
};
|
|
572
|
+
var VIEW_LINK_APP_TAG = "weaver-asset-eb";
|
|
573
|
+
var VIEW_LINK_CARD_TEMPLATE = "/sp/ebdfpage/card/0/{formId}/{dataId}";
|
|
574
|
+
var DEPRE_VIEWPORT_PATH = "/sp/ebdfpage/viewport/1267093228679077888";
|
|
575
|
+
var VIEW_LINK_SCENE_TAGS = {
|
|
576
|
+
asset_info: "uf_asset_info",
|
|
577
|
+
asset_use: "uf_asset_use",
|
|
578
|
+
asset_return: "uf_asset_return",
|
|
579
|
+
asset_repail: "uf_asset_repail",
|
|
580
|
+
asset_purch_apply: "uf_asset_purch_apply"
|
|
581
|
+
};
|
|
582
|
+
var ziguanjiaViewLink = {
|
|
583
|
+
appTag: VIEW_LINK_APP_TAG,
|
|
584
|
+
cardPathTemplate: VIEW_LINK_CARD_TEMPLATE,
|
|
585
|
+
depreViewportPath: DEPRE_VIEWPORT_PATH,
|
|
586
|
+
sceneFormTags: VIEW_LINK_SCENE_TAGS
|
|
587
|
+
};
|
|
588
|
+
var ziguanjiaFixed = { EB_INTERFACE_PK, ES_UNIQUE_INDENT, VIEW_LINK_SCENE_TAGS, DEPRE_VIEWPORT_PATH };
|
|
589
|
+
var ziguanjiaOperations = [
|
|
590
|
+
{
|
|
591
|
+
name: "asset.gate.check",
|
|
592
|
+
risk: "read",
|
|
593
|
+
fixed: { interfacePk: EB_INTERFACE_PK.appver },
|
|
594
|
+
inputSchema: { type: "object", additionalProperties: false, properties: {} }
|
|
595
|
+
},
|
|
596
|
+
{
|
|
597
|
+
name: "asset.list",
|
|
598
|
+
risk: "read",
|
|
599
|
+
fixed: { interfacePk: EB_INTERFACE_PK.baseList },
|
|
600
|
+
inputSchema: {
|
|
601
|
+
type: "object",
|
|
602
|
+
additionalProperties: false,
|
|
603
|
+
properties: {
|
|
604
|
+
id: { type: "string" },
|
|
605
|
+
asset_name: { type: "string" },
|
|
606
|
+
asset_number: { type: "string" },
|
|
607
|
+
stateid: { type: "string", description: "\u8D44\u4EA7\u72B6\u6001 ID\uFF0C\u7ECF asset.resolve.status \u89E3\u6790" },
|
|
608
|
+
asset_type_browse: { type: "string", description: "\u8D44\u4EA7\u7C7B\u578B ID\uFF0C\u7ECF asset.resolve.type \u89E3\u6790" },
|
|
609
|
+
location_browse: { type: "string", description: "\u5B58\u653E\u5730\u70B9 ID\uFF0C\u7ECF asset.resolve.location \u89E3\u6790" },
|
|
610
|
+
admin_istrator: { type: "string", description: "\u7BA1\u7406\u4EBA ID" },
|
|
611
|
+
resourceid: { type: "string", description: "\u4F7F\u7528\u4EBA ID" },
|
|
612
|
+
page_no: { type: "integer", minimum: 1, default: 1 },
|
|
613
|
+
page_size: { type: "integer", minimum: 1, maximum: 200, default: 10 },
|
|
614
|
+
with_view_link: { type: "boolean", default: true, description: "\u662F\u5426\u7ED9\u6BCF\u6761\u8BB0\u5F55\u9644\u5E26\u300C\u67E5\u770B\u8BE6\u60C5\u300D\u94FE\u63A5\uFF08\u9ED8\u8BA4 true\uFF09" }
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
name: "asset.detail",
|
|
620
|
+
risk: "read",
|
|
621
|
+
fixed: { interfacePk: EB_INTERFACE_PK.baseDetail },
|
|
622
|
+
inputSchema: {
|
|
623
|
+
type: "object",
|
|
624
|
+
additionalProperties: false,
|
|
625
|
+
properties: {
|
|
626
|
+
id: { type: "string" },
|
|
627
|
+
asset_number: { type: "string" },
|
|
628
|
+
asset_name: { type: "string" },
|
|
629
|
+
with_view_link: { type: "boolean", default: true, description: "\u662F\u5426\u7ED9\u547D\u4E2D\u8BB0\u5F55\u9644\u5E26\u300C\u67E5\u770B\u8BE6\u60C5\u300D\u94FE\u63A5\uFF08\u9ED8\u8BA4 true\uFF09" }
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
},
|
|
633
|
+
{
|
|
634
|
+
name: "asset.uselist",
|
|
635
|
+
risk: "read",
|
|
636
|
+
fixed: { interfacePk: EB_INTERFACE_PK.useList },
|
|
637
|
+
inputSchema: {
|
|
638
|
+
type: "object",
|
|
639
|
+
additionalProperties: false,
|
|
640
|
+
properties: {
|
|
641
|
+
person_id: { type: "string", description: "\u4EBA\u5458 ID\uFF08\u9886\u7528\u4EBA\uFF09\uFF1B\u7F3A\u7701\u65F6\u67E5\u8BE2\u5F53\u524D\u767B\u5F55\u4EBA\u3002\u5B9E\u9645\u5199\u5165\u5B57\u6BB5\u4EE5 zgjasset_uselist \u8868\u5355\u5B57\u6BB5\u5B9A\u4E49\u4E3A\u51C6\uFF08\u5019\u9009 resourceid/apply_person/use_person\uFF09\uFF0C\u8FD0\u884C\u65F6\u89E3\u6790" },
|
|
642
|
+
page_no: { type: "integer", minimum: 1, default: 1 },
|
|
643
|
+
page_size: { type: "integer", minimum: 1, maximum: 200, default: 5 },
|
|
644
|
+
with_view_link: { type: "boolean", default: true, description: "\u662F\u5426\u7ED9\u6BCF\u6761\u8BB0\u5F55\u9644\u5E26\u300C\u67E5\u770B\u8BE6\u60C5\u300D\u94FE\u63A5\uFF08\u9ED8\u8BA4 true\uFF09" }
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
},
|
|
648
|
+
{
|
|
649
|
+
name: "asset.repaillist",
|
|
650
|
+
risk: "read",
|
|
651
|
+
fixed: { interfacePk: EB_INTERFACE_PK.repairList },
|
|
652
|
+
inputSchema: {
|
|
653
|
+
type: "object",
|
|
654
|
+
additionalProperties: false,
|
|
655
|
+
properties: {
|
|
656
|
+
person_id: { type: "string", description: "\u62A5\u4FEE\u4EBA ID\uFF1B\u7F3A\u7701\u65F6\u67E5\u8BE2\u5F53\u524D\u767B\u5F55\u4EBA\uFF0C\u5199\u5165\u4E3B\u8868 repair_user" },
|
|
657
|
+
page_no: { type: "integer", minimum: 1, default: 1 },
|
|
658
|
+
page_size: { type: "integer", minimum: 1, maximum: 200, default: 5 },
|
|
659
|
+
with_view_link: { type: "boolean", default: true, description: "\u662F\u5426\u7ED9\u6BCF\u6761\u8BB0\u5F55\u9644\u5E26\u300C\u67E5\u770B\u8BE6\u60C5\u300D\u94FE\u63A5\uFF08\u9ED8\u8BA4 true\uFF09" }
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
},
|
|
663
|
+
{
|
|
664
|
+
name: "asset.purchaselist",
|
|
665
|
+
risk: "read",
|
|
666
|
+
fixed: { interfacePk: EB_INTERFACE_PK.purchList },
|
|
667
|
+
inputSchema: {
|
|
668
|
+
type: "object",
|
|
669
|
+
additionalProperties: false,
|
|
670
|
+
properties: {
|
|
671
|
+
person_id: { type: "string", description: "\u7533\u8BF7\u4EBA ID\uFF0C\u62FC URL ?person_id=\uFF1B\u7F3A\u7701\u65F6\u67E5\u8BE2\u5F53\u524D\u767B\u5F55\u4EBA" },
|
|
672
|
+
purchaser: { type: "string", description: "\u91C7\u8D2D\u5458 ID\uFF0C\u653E\u5165\u4E3B\u8868\uFF1B\u4E0E person_id \u4E8C\u9009\u4E00" },
|
|
673
|
+
page_no: { type: "integer", minimum: 1, default: 1 },
|
|
674
|
+
page_size: { type: "integer", minimum: 1, maximum: 200, default: 5 },
|
|
675
|
+
with_view_link: { type: "boolean", default: true, description: "\u662F\u5426\u7ED9\u6BCF\u6761\u8BB0\u5F55\u9644\u5E26\u300C\u67E5\u770B\u8BE6\u60C5\u300D\u94FE\u63A5\uFF08\u9ED8\u8BA4 true\uFF09" }
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
},
|
|
679
|
+
{
|
|
680
|
+
name: "asset.resolve.location",
|
|
681
|
+
risk: "read",
|
|
682
|
+
fixed: { interfacePk: EB_INTERFACE_PK.location },
|
|
683
|
+
inputSchema: {
|
|
684
|
+
type: "object",
|
|
685
|
+
additionalProperties: false,
|
|
686
|
+
properties: {
|
|
687
|
+
house_name: { type: "string", description: "\u5730\u70B9\u540D\u79F0\uFF0C\u6309\u540D\u79F0\u8FC7\u6EE4\u53D6 ID" },
|
|
688
|
+
page_no: { type: "integer", minimum: 1, default: 1 },
|
|
689
|
+
page_size: { type: "integer", minimum: 1, maximum: 200, default: 50 }
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
},
|
|
693
|
+
{
|
|
694
|
+
name: "asset.resolve.status",
|
|
695
|
+
risk: "read",
|
|
696
|
+
fixed: { interfacePk: EB_INTERFACE_PK.status },
|
|
697
|
+
inputSchema: {
|
|
698
|
+
type: "object",
|
|
699
|
+
additionalProperties: false,
|
|
700
|
+
properties: {
|
|
701
|
+
status_name: { type: "string", description: "\u72B6\u6001\u540D\u79F0\uFF0C\u6309\u540D\u79F0\u8FC7\u6EE4\u53D6 ID" },
|
|
702
|
+
page_no: { type: "integer", minimum: 1, default: 1 },
|
|
703
|
+
page_size: { type: "integer", minimum: 1, maximum: 200, default: 50 }
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
},
|
|
707
|
+
{
|
|
708
|
+
name: "asset.resolve.type",
|
|
709
|
+
risk: "read",
|
|
710
|
+
fixed: { interfacePk: EB_INTERFACE_PK.type },
|
|
711
|
+
inputSchema: {
|
|
712
|
+
type: "object",
|
|
713
|
+
additionalProperties: false,
|
|
714
|
+
properties: {
|
|
715
|
+
type_name: { type: "string", description: "\u7C7B\u578B\u540D\u79F0\uFF0C\u6309\u540D\u79F0\u8FC7\u6EE4\u53D6 ID" },
|
|
716
|
+
page_no: { type: "integer", minimum: 1, default: 1 },
|
|
717
|
+
page_size: { type: "integer", minimum: 1, maximum: 200, default: 50 }
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
},
|
|
721
|
+
{
|
|
722
|
+
name: "asset.create",
|
|
723
|
+
risk: "high-risk-write",
|
|
724
|
+
inputSchema: {
|
|
725
|
+
type: "object",
|
|
726
|
+
additionalProperties: false,
|
|
727
|
+
properties: {
|
|
728
|
+
asset_name: { type: "string", minLength: 1 },
|
|
729
|
+
asset_type_browse: { type: "string", description: "\u8D44\u4EA7\u7C7B\u578B ID\uFF0C\u7ECF asset.resolve.type \u89E3\u6790" },
|
|
730
|
+
asset_spec: { type: "string" },
|
|
731
|
+
stockindate: { type: "string", pattern: "^\\d{4}-\\d{2}-\\d{2}$", description: "\u5165\u5E93\u65E5\u671F\uFF0C\u9ED8\u8BA4\u4ECA\u5929" },
|
|
732
|
+
startprice: { type: "string", pattern: "^\\d+(\\.\\d{1,2})?$" },
|
|
733
|
+
original_value: { type: "string", pattern: "^\\d+(\\.\\d{1,2})?$" },
|
|
734
|
+
image_id: { type: "string", description: "\u56FE\u7247\u88F8 file_id\uFF08\u53EF\u9009\uFF09" },
|
|
735
|
+
asset_data_attr: { type: "string", const: "0", default: "0" },
|
|
736
|
+
admin_istrator: { type: "string", description: "\u7BA1\u7406\u4EBA ID\uFF0C\u9ED8\u8BA4\u5F53\u524D\u64CD\u4F5C\u4EBA" },
|
|
737
|
+
blongdepartment: { type: "string", description: "\u7BA1\u7406\u90E8\u95E8 ID" },
|
|
738
|
+
resourceid: { type: "string", description: "\u4F7F\u7528\u4EBA ID" },
|
|
739
|
+
stateid: { type: "string", description: "\u72B6\u6001 ID\uFF0C\u7ECF asset.resolve.status \u89E3\u6790" },
|
|
740
|
+
confirm: { const: true },
|
|
741
|
+
continuation: { type: "string", minLength: 1 }
|
|
742
|
+
},
|
|
743
|
+
required: ["asset_name", "asset_type_browse"]
|
|
744
|
+
}
|
|
745
|
+
},
|
|
746
|
+
{
|
|
747
|
+
name: "asset.update",
|
|
748
|
+
risk: "high-risk-write",
|
|
749
|
+
inputSchema: {
|
|
750
|
+
type: "object",
|
|
751
|
+
additionalProperties: false,
|
|
752
|
+
properties: {
|
|
753
|
+
id: { type: "string" },
|
|
754
|
+
asset_number: { type: "string" },
|
|
755
|
+
asset_name: { type: "string" },
|
|
756
|
+
changes: {
|
|
757
|
+
type: "object",
|
|
758
|
+
minProperties: 1,
|
|
759
|
+
additionalProperties: false,
|
|
760
|
+
properties: {
|
|
761
|
+
asset_name: { type: "string" },
|
|
762
|
+
stateid: { type: "string" },
|
|
763
|
+
admin_istrator: { type: "string" },
|
|
764
|
+
resourceid: { type: "string" },
|
|
765
|
+
location_browse: { type: "string" },
|
|
766
|
+
unit_price: { type: "string", pattern: "^\\d+(\\.\\d{1,2})?$" },
|
|
767
|
+
value: { type: "string", pattern: "^\\d+(\\.\\d{1,2})?$" }
|
|
768
|
+
}
|
|
769
|
+
},
|
|
770
|
+
confirm: { const: true },
|
|
771
|
+
continuation: { type: "string", minLength: 1 }
|
|
772
|
+
},
|
|
773
|
+
required: ["changes"]
|
|
774
|
+
}
|
|
775
|
+
},
|
|
776
|
+
{
|
|
777
|
+
name: "asset.use",
|
|
778
|
+
risk: "high-risk-write",
|
|
779
|
+
fixed: { uniqueIndent: ES_UNIQUE_INDENT.use },
|
|
780
|
+
inputSchema: {
|
|
781
|
+
type: "object",
|
|
782
|
+
additionalProperties: false,
|
|
783
|
+
properties: {
|
|
784
|
+
use_location: { type: "string", description: "\u9886\u7528\u540E\u5730\u70B9 ID\uFF0C\u7ECF asset.resolve.location \u89E3\u6790" },
|
|
785
|
+
purpose: { type: "string" },
|
|
786
|
+
detail1: {
|
|
787
|
+
type: "array",
|
|
788
|
+
minItems: 1,
|
|
789
|
+
items: {
|
|
790
|
+
type: "object",
|
|
791
|
+
additionalProperties: false,
|
|
792
|
+
properties: {
|
|
793
|
+
apply_info: { type: "string", minLength: 1 },
|
|
794
|
+
asset_spec: { type: "string" },
|
|
795
|
+
asset_remark: { type: "string" },
|
|
796
|
+
asset_type: { type: "string", description: "\u8D44\u4EA7\u7C7B\u578B ID" },
|
|
797
|
+
use_count: { type: "integer", minimum: 1, default: 1 }
|
|
798
|
+
},
|
|
799
|
+
required: ["apply_info"]
|
|
800
|
+
}
|
|
801
|
+
},
|
|
802
|
+
confirm: { const: true },
|
|
803
|
+
continuation: { type: "string", minLength: 1 }
|
|
804
|
+
},
|
|
805
|
+
required: ["detail1"]
|
|
806
|
+
}
|
|
807
|
+
},
|
|
808
|
+
{
|
|
809
|
+
name: "asset.return.query",
|
|
810
|
+
risk: "read-before-write",
|
|
811
|
+
fixed: { uniqueIndent: ES_UNIQUE_INDENT.returnQuery },
|
|
812
|
+
inputSchema: {
|
|
813
|
+
type: "object",
|
|
814
|
+
additionalProperties: false,
|
|
815
|
+
properties: {
|
|
816
|
+
return_type: { type: "string", enum: ["0", "1"], description: "0=\u5168\u90E8\u5F52\u8FD8\uFF0C1=\u90E8\u5206\u5F52\u8FD8" },
|
|
817
|
+
detail1: {
|
|
818
|
+
type: "array",
|
|
819
|
+
items: {
|
|
820
|
+
type: "object",
|
|
821
|
+
additionalProperties: false,
|
|
822
|
+
properties: { asset_name: { type: "string" } }
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
},
|
|
828
|
+
{
|
|
829
|
+
name: "asset.return.create",
|
|
830
|
+
risk: "high-risk-write",
|
|
831
|
+
fixed: { uniqueIndent: ES_UNIQUE_INDENT.returnCreate },
|
|
832
|
+
inputSchema: {
|
|
833
|
+
type: "object",
|
|
834
|
+
additionalProperties: false,
|
|
835
|
+
properties: {
|
|
836
|
+
data_ids: { type: "string", minLength: 1, description: "\u786E\u8BA4\u8D44\u4EA7\u6570\u636E ID\uFF0C\u534A\u89D2\u9017\u53F7\u62FC\u63A5" },
|
|
837
|
+
confirm: { const: true },
|
|
838
|
+
continuation: { type: "string", minLength: 1 }
|
|
839
|
+
},
|
|
840
|
+
required: ["data_ids"]
|
|
841
|
+
}
|
|
842
|
+
},
|
|
843
|
+
{
|
|
844
|
+
name: "asset.repair.query",
|
|
845
|
+
risk: "read-before-write",
|
|
846
|
+
fixed: { uniqueIndent: ES_UNIQUE_INDENT.repairQuery },
|
|
847
|
+
inputSchema: {
|
|
848
|
+
type: "object",
|
|
849
|
+
additionalProperties: false,
|
|
850
|
+
properties: {
|
|
851
|
+
detail1: {
|
|
852
|
+
type: "array",
|
|
853
|
+
minItems: 1,
|
|
854
|
+
items: {
|
|
855
|
+
type: "object",
|
|
856
|
+
additionalProperties: false,
|
|
857
|
+
properties: { asset_name: { type: "string", minLength: 1 } },
|
|
858
|
+
required: ["asset_name"]
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
},
|
|
862
|
+
required: ["detail1"]
|
|
863
|
+
}
|
|
864
|
+
},
|
|
865
|
+
{
|
|
866
|
+
name: "asset.repair.create",
|
|
867
|
+
risk: "high-risk-write",
|
|
868
|
+
fixed: { uniqueIndent: ES_UNIQUE_INDENT.repairCreate },
|
|
869
|
+
inputSchema: {
|
|
870
|
+
type: "object",
|
|
871
|
+
additionalProperties: false,
|
|
872
|
+
properties: {
|
|
873
|
+
repail_name: { type: "string" },
|
|
874
|
+
repail_remark: { type: "string" },
|
|
875
|
+
detail1: {
|
|
876
|
+
type: "array",
|
|
877
|
+
minItems: 1,
|
|
878
|
+
items: {
|
|
879
|
+
type: "object",
|
|
880
|
+
additionalProperties: false,
|
|
881
|
+
properties: {
|
|
882
|
+
asset_id: { type: "string", minLength: 1 },
|
|
883
|
+
fault_desc: { type: "string", minLength: 1 },
|
|
884
|
+
fault_time: {
|
|
885
|
+
type: "string",
|
|
886
|
+
pattern: "^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}$",
|
|
887
|
+
description: "\u6545\u969C\u53D1\u751F\u65F6\u95F4\uFF0C\u5F3A\u5236 YYYY-MM-DD HH:mm\uFF08\u5FC5\u987B\u5E26\u65F6\u5206\uFF0C\u7EAF\u65E5\u671F\u4F1A\u88AB\u521B\u5EFA\u52A8\u4F5C\u6D41\u62D2\u7EDD\uFF09\uFF1B\u7528\u6237\u672A\u8BF4\u660E\u65F6\u7531 Agent \u53D6\u5F53\u524D\u65F6\u95F4"
|
|
888
|
+
}
|
|
889
|
+
},
|
|
890
|
+
required: ["asset_id", "fault_desc"]
|
|
891
|
+
}
|
|
892
|
+
},
|
|
893
|
+
confirm: { const: true },
|
|
894
|
+
continuation: { type: "string", minLength: 1 }
|
|
895
|
+
},
|
|
896
|
+
required: ["detail1"]
|
|
897
|
+
}
|
|
898
|
+
},
|
|
899
|
+
{
|
|
900
|
+
name: "asset.purch",
|
|
901
|
+
risk: "high-risk-write",
|
|
902
|
+
fixed: { uniqueIndent: ES_UNIQUE_INDENT.purch },
|
|
903
|
+
inputSchema: {
|
|
904
|
+
type: "object",
|
|
905
|
+
additionalProperties: false,
|
|
906
|
+
properties: {
|
|
907
|
+
purchase_name: { type: "string" },
|
|
908
|
+
detail1: {
|
|
909
|
+
type: "array",
|
|
910
|
+
minItems: 1,
|
|
911
|
+
items: {
|
|
912
|
+
type: "object",
|
|
913
|
+
additionalProperties: false,
|
|
914
|
+
properties: {
|
|
915
|
+
apply_info: { type: "string", minLength: 1 },
|
|
916
|
+
apply_count: { type: "integer", minimum: 1, default: 1 },
|
|
917
|
+
apply_remark: { type: "string" },
|
|
918
|
+
apply_spec: { type: "string" },
|
|
919
|
+
apply_asset_type: { type: "string", description: "\u8D44\u4EA7\u7C7B\u578B ID" }
|
|
920
|
+
},
|
|
921
|
+
required: ["apply_info"]
|
|
922
|
+
}
|
|
923
|
+
},
|
|
924
|
+
confirm: { const: true },
|
|
925
|
+
continuation: { type: "string", minLength: 1 }
|
|
926
|
+
},
|
|
927
|
+
required: ["detail1"]
|
|
928
|
+
}
|
|
929
|
+
},
|
|
930
|
+
{
|
|
931
|
+
name: "asset.depre",
|
|
932
|
+
risk: "high-risk-write",
|
|
933
|
+
fixed: {
|
|
934
|
+
settingInterfacePk: EB_INTERFACE_PK.depreSetting,
|
|
935
|
+
precheckUniqueIndent: ES_UNIQUE_INDENT.deprePrecheck,
|
|
936
|
+
taskInterfacePk: EB_INTERFACE_PK.depreTask
|
|
937
|
+
},
|
|
938
|
+
inputSchema: {
|
|
939
|
+
type: "object",
|
|
940
|
+
additionalProperties: false,
|
|
941
|
+
properties: {
|
|
942
|
+
calc_month: { type: "string", pattern: "^\\d{4}-\\d{2}$", description: "\u8BA1\u63D0\u5E74\u6708\uFF0C\u987B\u65E9\u4E8E\u5F53\u524D\u6708\u4EFD" },
|
|
943
|
+
company_ids: {
|
|
944
|
+
type: "string",
|
|
945
|
+
minLength: 1,
|
|
946
|
+
description: "\u5F53\u524D\u767B\u5F55\u4EBA\u6240\u5C5E\u5206\u90E8 ID\uFF08\u5927\u6574\u6570\u6309\u5B57\u7B26\u4E32\u4F20\uFF09\u3002\u4EC5\u5F53\u6298\u65E7\u8BBE\u7F6E\u4E3A\u5206\u7EC4\u8BA1\u63D0\u65F6\u9700\u8981\uFF1B\u4E0D\u4F20\u65F6\u6309\u767B\u5F55\u4F1A\u8BDD\u7684\u5206\u90E8\u540D\u79F0\u81EA\u52A8\u89E3\u6790"
|
|
947
|
+
},
|
|
948
|
+
confirm: { const: true },
|
|
949
|
+
continuation: { type: "string", minLength: 1 }
|
|
950
|
+
},
|
|
951
|
+
required: ["calc_month"]
|
|
952
|
+
}
|
|
953
|
+
},
|
|
954
|
+
{
|
|
955
|
+
name: "asset.viewlink",
|
|
956
|
+
risk: "read",
|
|
957
|
+
fixed: ziguanjiaViewLink,
|
|
958
|
+
inputSchema: {
|
|
959
|
+
type: "object",
|
|
960
|
+
additionalProperties: false,
|
|
961
|
+
properties: {
|
|
962
|
+
scene: {
|
|
963
|
+
type: "string",
|
|
964
|
+
enum: ["asset_info", "asset_use", "asset_return", "asset_repail", "asset_purch_apply", "depre_task"],
|
|
965
|
+
description: "\u94FE\u63A5\u573A\u666F\uFF1Aasset_info=\u8D44\u4EA7\u4FE1\u606F\uFF08\u5217\u8868/\u8BE6\u60C5/\u62A5\u4FEE\xB7\u5F52\u8FD8\u5019\u9009\u8D44\u4EA7\u540D\uFF09\uFF0Casset_use=\u9886\u7528\uFF0Casset_return=\u5F52\u8FD8\uFF0Casset_repail=\u62A5\u4FEE\uFF0Casset_purch_apply=\u91C7\u8D2D\u7533\u8BF7\uFF0Cdepre_task=\u8BA1\u63D0\u4EFB\u52A1\uFF08\u56FA\u5B9A viewport \u9875\u9762\uFF0C\u65E0\u9700\u89E3\u6790\u8868\u5355 ID\uFF09"
|
|
966
|
+
},
|
|
967
|
+
ids: {
|
|
968
|
+
type: "array",
|
|
969
|
+
items: { type: "string", minLength: 1 },
|
|
970
|
+
minItems: 1,
|
|
971
|
+
maxItems: 200,
|
|
972
|
+
description: "\u6570\u636EID \u5217\u8868\uFF0C\u4E00\u5F8B\u6309\u5B57\u7B26\u4E32\u4F20\u5165\uFF08\u5927\u6574\u6570\uFF0C\u907F\u514D\u7CBE\u5EA6\u4E22\u5931\uFF09\uFF1B\u53D6\u81EA\u67E5\u8BE2\u7ED3\u679C\u5404\u6761\u8BB0\u5F55\u7684 mainTable.id"
|
|
973
|
+
},
|
|
974
|
+
calc_month: {
|
|
975
|
+
type: "string",
|
|
976
|
+
pattern: "^\\d{4}-\\d{2}$",
|
|
977
|
+
description: "\u4EC5 depre_task \u573A\u666F\u9700\u8981\uFF0C\u53D6\u81EA\u8BA1\u63D0\u64CD\u4F5C\u7684 calc_month"
|
|
978
|
+
},
|
|
979
|
+
anchor: {
|
|
980
|
+
type: "string",
|
|
981
|
+
minLength: 1,
|
|
982
|
+
description: "\u53EF\u9009\uFF0C\u8986\u76D6\u9ED8\u8BA4\u951A\u70B9\u6587\u5B57\u300C\u67E5\u770B\u8BE6\u60C5\u300D\uFF1B\u62A5\u4FEE/\u5F52\u8FD8\u5019\u9009\u8D44\u4EA7\u540D\u7B49\u300C\u8D44\u4EA7\u540D\u79F0\u5185\u8054\u94FE\u63A5\u300D\u573A\u666F\u4F20\u8D44\u4EA7\u540D\u79F0\u672C\u8EAB"
|
|
983
|
+
}
|
|
984
|
+
},
|
|
985
|
+
required: ["scene"],
|
|
986
|
+
anyOf: [{ required: ["ids"] }, { required: ["calc_month"] }]
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
];
|
|
990
|
+
var ziguanjiaManifest = {
|
|
991
|
+
schemaVersion: 1,
|
|
992
|
+
name: "asset",
|
|
993
|
+
title: "\u6CDB\u5FAEE10\u8D44\u4EA7\u7BA1\u7406",
|
|
994
|
+
version: "0.1.0",
|
|
995
|
+
host: "e10-ziguanjia",
|
|
996
|
+
status: "builtin",
|
|
997
|
+
sourceSkill: "weaver-e10-ziguanjia",
|
|
998
|
+
operations: ziguanjiaOperations,
|
|
999
|
+
withheldOperations: [
|
|
1000
|
+
{
|
|
1001
|
+
name: "asset.transfer",
|
|
1002
|
+
reason: "\u8D44\u4EA7\u8C03\u62E8\u4E0D\u5728\u6E90\u8D44\u6599\u8986\u76D6\u8303\u56F4\u5185\uFF0C\u672A\u63D0\u4F9B\u7A33\u5B9A\u63A5\u53E3\u4E0E\u56DE\u67E5\u5951\u7EA6\u3002"
|
|
1003
|
+
},
|
|
1004
|
+
{
|
|
1005
|
+
name: "asset.approve",
|
|
1006
|
+
reason: "\u6D41\u7A0B\u5BA1\u6279\u5904\u7406\u672A\u8986\u76D6\uFF0C\u6E90\u8D44\u6599\u672A\u63D0\u4F9B\u5BA1\u6279\u52A8\u4F5C\u6D41\u6216\u56DE\u67E5\u5951\u7EA6\u3002"
|
|
1007
|
+
},
|
|
1008
|
+
{
|
|
1009
|
+
name: "asset.file.upload",
|
|
1010
|
+
reason: "\u56FE\u7247\u4E0A\u4F20\u4F9D\u8D56 weaver-e10-caizhilian \u6587\u4EF6\u4E0A\u4F20\u6A21\u5757\uFF0CCLI \u4E0D\u5185\u7F6E\u6587\u4EF6\u4E0A\u4F20\u80FD\u529B\uFF0Ccreate \u4EC5\u63A5\u53D7\u5DF2\u4E0A\u4F20\u5F97\u5230\u7684\u88F8 file_id\u3002"
|
|
1011
|
+
}
|
|
1012
|
+
]
|
|
1013
|
+
};
|
|
1014
|
+
|
|
1015
|
+
// src/shortcuts/asset/operations/type-cache.ts
|
|
1016
|
+
import { promises as fs } from "node:fs";
|
|
1017
|
+
import path from "node:path";
|
|
1018
|
+
import os from "node:os";
|
|
1019
|
+
var CACHE_DIR = path.join(os.homedir(), ".workbuddy", "data", "weaver-e10-ziguanjia");
|
|
1020
|
+
var TTL_MS = 24 * 60 * 60 * 1e3;
|
|
1021
|
+
async function loadTypeCache(env) {
|
|
1022
|
+
try {
|
|
1023
|
+
const raw = await fs.readFile(path.join(CACHE_DIR, `asset_type_cache_${env}.json`), "utf8");
|
|
1024
|
+
const data = JSON.parse(raw);
|
|
1025
|
+
if (data.env !== env) return null;
|
|
1026
|
+
const age = Date.now() - new Date(data.updated_at).getTime();
|
|
1027
|
+
if (!Number.isFinite(age) || age >= TTL_MS) return null;
|
|
1028
|
+
if (!Array.isArray(data.items)) return null;
|
|
1029
|
+
return data;
|
|
1030
|
+
} catch {
|
|
1031
|
+
return null;
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
async function saveTypeCache(env, items) {
|
|
1035
|
+
try {
|
|
1036
|
+
await fs.mkdir(CACHE_DIR, { recursive: true });
|
|
1037
|
+
await fs.writeFile(
|
|
1038
|
+
path.join(CACHE_DIR, `asset_type_cache_${env}.json`),
|
|
1039
|
+
JSON.stringify({ env, updated_at: (/* @__PURE__ */ new Date()).toISOString(), count: items.length, items }, null, 2)
|
|
1040
|
+
);
|
|
1041
|
+
} catch {
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
function matchTypeName(items, name) {
|
|
1045
|
+
const exact = items.find((i) => i.type_name === name);
|
|
1046
|
+
if (exact) return { id: exact.id, matched: "exact" };
|
|
1047
|
+
const contains = items.filter((i) => i.type_name.includes(name) || name.includes(i.type_name));
|
|
1048
|
+
if (contains.length === 1) return { id: contains[0].id, matched: "contains" };
|
|
1049
|
+
return null;
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
// src/shortcuts/asset/operations/shared.ts
|
|
1053
|
+
function ok(status, data) {
|
|
1054
|
+
return { status, data };
|
|
1055
|
+
}
|
|
1056
|
+
function asObject(value, name = "\u4E1A\u52A1\u8F93\u5165") {
|
|
1057
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
1058
|
+
throw ziguanjiaValidationError("input_invalid", `${name}\u5FC5\u987B\u662F JSON \u5BF9\u8C61`);
|
|
1059
|
+
}
|
|
1060
|
+
return value;
|
|
1061
|
+
}
|
|
1062
|
+
function getDatas(value) {
|
|
1063
|
+
const root = value && typeof value === "object" && "datajson" in value ? value.datajson : value;
|
|
1064
|
+
if (!root || !Array.isArray(root.datas)) return [];
|
|
1065
|
+
return root.datas;
|
|
1066
|
+
}
|
|
1067
|
+
function mainTableOf(item) {
|
|
1068
|
+
if (!item || typeof item !== "object") return {};
|
|
1069
|
+
if (item.mainTable && typeof item.mainTable === "object") return item.mainTable;
|
|
1070
|
+
return item;
|
|
1071
|
+
}
|
|
1072
|
+
function buildPageInfo(pageNo, pageSize, defaultPageSize = 10) {
|
|
1073
|
+
const norm = (value, fallback) => {
|
|
1074
|
+
const num = typeof value === "number" && Number.isFinite(value) ? value : Number(value);
|
|
1075
|
+
return String(typeof num === "number" && Number.isFinite(num) && num >= 1 ? Math.trunc(num) : fallback);
|
|
1076
|
+
};
|
|
1077
|
+
return {
|
|
1078
|
+
pageNo: norm(pageNo, 1),
|
|
1079
|
+
pageSize: norm(pageSize, defaultPageSize)
|
|
1080
|
+
};
|
|
1081
|
+
}
|
|
1082
|
+
function actionFlowResult(result) {
|
|
1083
|
+
const actionData = result?.actionData ?? {};
|
|
1084
|
+
const responseData = actionData?.responseData ?? {};
|
|
1085
|
+
const customData = responseData?.customData ?? actionData?.customData ?? {};
|
|
1086
|
+
return {
|
|
1087
|
+
resultCode: result?.resultCode,
|
|
1088
|
+
resultMsg: result?.resultMsg,
|
|
1089
|
+
actionData,
|
|
1090
|
+
responseData,
|
|
1091
|
+
customData,
|
|
1092
|
+
mainTable: customData?.mainTable ?? {}
|
|
1093
|
+
};
|
|
1094
|
+
}
|
|
1095
|
+
function extractVersionField(mainTable) {
|
|
1096
|
+
const raw = mainTable?.ver_name ?? mainTable?.current_ver;
|
|
1097
|
+
if (raw === void 0 || raw === null) return void 0;
|
|
1098
|
+
return String(raw).trim();
|
|
1099
|
+
}
|
|
1100
|
+
function parseVersion(value) {
|
|
1101
|
+
const cleaned = value.replace(/^v/iu, "").replace(/\s+/gu, "");
|
|
1102
|
+
const match = cleaned.match(/\d+/u);
|
|
1103
|
+
return match ? Number(match[0]) : void 0;
|
|
1104
|
+
}
|
|
1105
|
+
function evaluateVersionGate(value) {
|
|
1106
|
+
const datas = getDatas(value);
|
|
1107
|
+
const first = datas[0] ? mainTableOf(datas[0]) : void 0;
|
|
1108
|
+
const raw = first ? extractVersionField(first) : void 0;
|
|
1109
|
+
if (!raw) return { passed: false, raw };
|
|
1110
|
+
const version = parseVersion(raw);
|
|
1111
|
+
if (version === void 0) return { passed: false, raw, versionField: raw };
|
|
1112
|
+
return { passed: version >= 14, raw, version };
|
|
1113
|
+
}
|
|
1114
|
+
async function ensureVersionGate(host, operation) {
|
|
1115
|
+
const result = await host.ebuilderRequest({
|
|
1116
|
+
endpoint: "getFormDataList",
|
|
1117
|
+
interfacePk: "zgjasset_search_appver",
|
|
1118
|
+
operation,
|
|
1119
|
+
body: { mainTable: {}, pageInfo: { pageNo: "1", pageSize: "10" } }
|
|
1120
|
+
});
|
|
1121
|
+
const gate = evaluateVersionGate(result);
|
|
1122
|
+
if (!gate.passed) {
|
|
1123
|
+
throw ziguanjiaValidationError(
|
|
1124
|
+
"version_gate_failed",
|
|
1125
|
+
`\u7248\u672C\u95E8\u7981\u672A\u901A\u8FC7\uFF08zgjasset_search_appver \u65E0 ver_name \u2265 V14 \u8BB0\u5F55\uFF0C\u5B9E\u9645=${gate.raw ?? "\u7A7A"}\uFF09\uFF0C\u5DF2\u505C\u6B62\uFF0C\u4E0D\u6267\u884C\u4EFB\u4F55\u8D44\u4EA7\u67E5\u8BE2 / \u5199\u64CD\u4F5C\u3002\u5F85\u95E8\u7981\u771F\u6B63\u901A\u8FC7\u540E\u518D\u5904\u7406\u3002`,
|
|
1126
|
+
{ gate }
|
|
1127
|
+
);
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
// src/shortcuts/asset/operations/query.ts
|
|
1132
|
+
var SCENE_TAGS = ziguanjiaFixed.VIEW_LINK_SCENE_TAGS;
|
|
1133
|
+
var ZiguanjiaQueryOperation = class {
|
|
1134
|
+
constructor(name, config) {
|
|
1135
|
+
this.name = name;
|
|
1136
|
+
this.config = config;
|
|
1137
|
+
}
|
|
1138
|
+
name;
|
|
1139
|
+
config;
|
|
1140
|
+
async execute(input, context) {
|
|
1141
|
+
const { host } = context;
|
|
1142
|
+
const body = asObject(input, this.name);
|
|
1143
|
+
for (const key of Object.keys(body)) {
|
|
1144
|
+
if (!this.config.bodyFields.includes(key) && key !== "page_no" && key !== "page_size" && key !== "person_id" && key !== "with_view_link") {
|
|
1145
|
+
throw ziguanjiaValidationError("input_field_unsupported", `\u67E5\u8BE2\u4E0D\u652F\u6301\u5B57\u6BB5\uFF1A${key}`);
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
if (this.config.requireAtLeastOne && !this.config.requireAtLeastOne.some((f) => body[f] !== void 0 && body[f] !== "")) {
|
|
1149
|
+
throw ziguanjiaValidationError("input_required", `\u81F3\u5C11\u9700\u8981\u63D0\u4F9B\u4E00\u4E2A\u5B57\u6BB5\uFF1A${this.config.requireAtLeastOne.join(" / ")}`);
|
|
1150
|
+
}
|
|
1151
|
+
const session = await host.getSession();
|
|
1152
|
+
const mainTable = {};
|
|
1153
|
+
const query = {};
|
|
1154
|
+
for (const field of this.config.bodyFields) {
|
|
1155
|
+
if (field === "person_id") continue;
|
|
1156
|
+
if (body[field] !== void 0 && body[field] !== "") mainTable[field] = body[field];
|
|
1157
|
+
}
|
|
1158
|
+
const providedPersonId = body.person_id !== void 0 && body.person_id !== "" ? body.person_id : void 0;
|
|
1159
|
+
const hasPurchaser = body.purchaser !== void 0 && body.purchaser !== "";
|
|
1160
|
+
const personValue = providedPersonId !== void 0 ? providedPersonId : this.config.defaultPersonIdFromSession && !hasPurchaser ? session.userId : void 0;
|
|
1161
|
+
if (personValue !== void 0) {
|
|
1162
|
+
if (this.config.personQueryParam) {
|
|
1163
|
+
query[this.config.personQueryParam] = personValue;
|
|
1164
|
+
} else if (this.config.personField) {
|
|
1165
|
+
const fields = await host.getFormFields(this.config.personField.formTag);
|
|
1166
|
+
const field = pickPersonField(fields, this.config.personField.candidates);
|
|
1167
|
+
if (!field || !field.name) {
|
|
1168
|
+
throw ziguanjiaValidationError(
|
|
1169
|
+
"person_field_unresolved",
|
|
1170
|
+
`\u65E0\u6CD5\u4ECE\u8868\u5355 ${this.config.personField.formTag} \u7684\u5B57\u6BB5\u5B9A\u4E49\u4E2D\u786E\u5B9A\u9886\u7528\u4EBA\u5B57\u6BB5\uFF08\u5019\u9009\uFF1A${this.config.personField.candidates.join(" / ")}\uFF09\uFF1B\u8BF7\u660E\u786E\u63D0\u4F9B\u5177\u4F53\u7684\u9886\u7528\u4EBA\u5B57\u6BB5\u540D\u6216\u4EBA\u5458 ID`
|
|
1171
|
+
);
|
|
1172
|
+
}
|
|
1173
|
+
mainTable[field.name] = personValue;
|
|
1174
|
+
} else if (this.config.writePersonIdTo) {
|
|
1175
|
+
mainTable[this.config.writePersonIdTo] = personValue;
|
|
1176
|
+
} else {
|
|
1177
|
+
mainTable.person_id = personValue;
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
const pageInfo = buildPageInfo(body.page_no, body.page_size, this.config.pageSizeDefault);
|
|
1181
|
+
const request = {
|
|
1182
|
+
endpoint: "getFormDataList",
|
|
1183
|
+
interfacePk: this.config.interfacePk,
|
|
1184
|
+
operation: this.name,
|
|
1185
|
+
body: { mainTable, pageInfo }
|
|
1186
|
+
};
|
|
1187
|
+
if (Object.keys(query).length > 0) request.query = query;
|
|
1188
|
+
const result = await host.ebuilderRequest(request);
|
|
1189
|
+
const datas = getDatas(result).map(mainTableOf);
|
|
1190
|
+
let viewLinkWarning;
|
|
1191
|
+
if (this.config.viewLinkScene && body.with_view_link !== false) {
|
|
1192
|
+
const formTag = SCENE_TAGS[this.config.viewLinkScene];
|
|
1193
|
+
try {
|
|
1194
|
+
const objId = await host.resolveFormId({ formTag, operation: this.name });
|
|
1195
|
+
for (const item of datas) {
|
|
1196
|
+
const dataId = item.id ?? item.mainTable?.id;
|
|
1197
|
+
const link = dataId !== void 0 && dataId !== null ? buildCardLink(session.baseUrl, objId, String(dataId)) : null;
|
|
1198
|
+
if (link) item.view_link = link;
|
|
1199
|
+
}
|
|
1200
|
+
} catch (error) {
|
|
1201
|
+
viewLinkWarning = `\u67E5\u770B\u94FE\u63A5\u6682\u4E0D\u53EF\u7528\uFF1A${error instanceof Error ? error.message : String(error)}\uFF1B\u4E3B\u67E5\u8BE2\u5DF2\u6210\u529F\uFF0C\u4E0D\u8981\u56E0\u6B64\u91CD\u8BD5\u67E5\u8BE2\u3002`;
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
return ok("COMPLETE", {
|
|
1205
|
+
items: datas,
|
|
1206
|
+
count: datas.length,
|
|
1207
|
+
...viewLinkWarning ? { view_link_warning: viewLinkWarning } : {}
|
|
1208
|
+
});
|
|
1209
|
+
}
|
|
1210
|
+
};
|
|
1211
|
+
var ZiguanjiaResolveOperation = class {
|
|
1212
|
+
constructor(name, interfacePk, nameField, enableTypeCache = false) {
|
|
1213
|
+
this.name = name;
|
|
1214
|
+
this.interfacePk = interfacePk;
|
|
1215
|
+
this.nameField = nameField;
|
|
1216
|
+
this.enableTypeCache = enableTypeCache;
|
|
1217
|
+
}
|
|
1218
|
+
name;
|
|
1219
|
+
interfacePk;
|
|
1220
|
+
nameField;
|
|
1221
|
+
enableTypeCache;
|
|
1222
|
+
async execute(input, context) {
|
|
1223
|
+
const { host } = context;
|
|
1224
|
+
const body = asObject(input, this.name);
|
|
1225
|
+
const nameValue = typeof body[this.nameField] === "string" ? body[this.nameField].trim() : "";
|
|
1226
|
+
if (nameValue === "") throw ziguanjiaValidationError("input_required", `\u5FC5\u987B\u63D0\u4F9B ${this.nameField}`);
|
|
1227
|
+
if (this.enableTypeCache) {
|
|
1228
|
+
const session = await host.getSession();
|
|
1229
|
+
const cache = await loadTypeCache(session.baseUrl);
|
|
1230
|
+
if (cache) {
|
|
1231
|
+
const m = matchTypeName(cache.items, nameValue);
|
|
1232
|
+
if (m) {
|
|
1233
|
+
return this.resolved(nameValue, m.id, m.matched, cache.items.length);
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
const all = await this.enumerateAll(host);
|
|
1237
|
+
if (!cache) await saveTypeCache(session.baseUrl, all);
|
|
1238
|
+
const m2 = matchTypeName(all, nameValue);
|
|
1239
|
+
if (m2) return this.resolved(nameValue, m2.id, m2.matched, all.length);
|
|
1240
|
+
const contains2 = all.filter((i) => i.type_name.includes(nameValue) || nameValue.includes(i.type_name));
|
|
1241
|
+
if (contains2.length > 1) {
|
|
1242
|
+
throw ziguanjiaValidationError("resolve_ambiguous", `\u6309 ${this.nameField}=${nameValue} \u6A21\u7CCA\u89E3\u6790\u5230\u591A\u6761\u5019\u9009\uFF0C\u8BF7\u6539\u7528 ID \u6216\u63D0\u4F9B\u66F4\u7CBE\u786E\u540D\u79F0`, {
|
|
1243
|
+
candidates: contains2.slice(0, 10).map((i) => ({ id: i.id, name: i.type_name }))
|
|
1244
|
+
});
|
|
1245
|
+
}
|
|
1246
|
+
throw ziguanjiaValidationError("resolve_not_found", `\u672A\u89E3\u6790\u5230 ${this.nameField}=${nameValue} \u7684\u8D44\u4EA7\u7C7B\u578B\uFF08\u672C\u73AF\u5883\u6B63\u5F0F\u540D\u5982\u300C\u4FBF\u643A\u5F0F\u8BA1\u7B97\u673A\u300D\u800C\u975E\u300C\u7B14\u8BB0\u672C\u7535\u8111\u300D\uFF09`);
|
|
1247
|
+
}
|
|
1248
|
+
const filtered = await host.ebuilderRequest({
|
|
1249
|
+
endpoint: "getFormDataList",
|
|
1250
|
+
interfacePk: this.interfacePk,
|
|
1251
|
+
operation: this.name,
|
|
1252
|
+
body: { mainTable: { [this.nameField]: nameValue }, pageInfo: buildPageInfo(void 0, void 0, 50) }
|
|
1253
|
+
});
|
|
1254
|
+
const exact = getDatas(filtered).map(mainTableOf).filter((item) => String(item[this.nameField] ?? "") === nameValue);
|
|
1255
|
+
if (exact.length >= 1) {
|
|
1256
|
+
if (exact.length > 1) {
|
|
1257
|
+
throw ziguanjiaValidationError("resolve_ambiguous", `\u6309 ${this.nameField}=${nameValue} \u89E3\u6790\u5230\u591A\u6761\u8BB0\u5F55\uFF0C\u8BF7\u6539\u7528 ID \u660E\u786E\u6307\u5B9A`, {
|
|
1258
|
+
candidates: exact.slice(0, 10).map((item) => item.id ?? item.mainTable?.id)
|
|
1259
|
+
});
|
|
1260
|
+
}
|
|
1261
|
+
return this.resolved(nameValue, String(exact[0].id ?? exact[0].mainTable?.id), "exact", exact.length);
|
|
1262
|
+
}
|
|
1263
|
+
const full = await host.ebuilderRequest({
|
|
1264
|
+
endpoint: "getFormDataList",
|
|
1265
|
+
interfacePk: this.interfacePk,
|
|
1266
|
+
operation: this.name,
|
|
1267
|
+
body: { mainTable: {}, pageInfo: buildPageInfo(void 0, void 0, 50) }
|
|
1268
|
+
});
|
|
1269
|
+
const allItems = getDatas(full).map(mainTableOf);
|
|
1270
|
+
const exactAll = allItems.filter((item) => String(item[this.nameField] ?? "") === nameValue);
|
|
1271
|
+
if (exactAll.length >= 1) {
|
|
1272
|
+
if (exactAll.length > 1) {
|
|
1273
|
+
throw ziguanjiaValidationError("resolve_ambiguous", `\u6309 ${this.nameField}=${nameValue} \u89E3\u6790\u5230\u591A\u6761\u8BB0\u5F55\uFF0C\u8BF7\u6539\u7528 ID \u660E\u786E\u6307\u5B9A`, {
|
|
1274
|
+
candidates: exactAll.slice(0, 10).map((item) => item.id ?? item.mainTable?.id)
|
|
1275
|
+
});
|
|
1276
|
+
}
|
|
1277
|
+
return this.resolved(nameValue, String(exactAll[0].id ?? exactAll[0].mainTable?.id), "exact", allItems.length);
|
|
1278
|
+
}
|
|
1279
|
+
const contains = allItems.filter((item) => {
|
|
1280
|
+
const v = String(item[this.nameField] ?? "");
|
|
1281
|
+
return v !== "" && (v.includes(nameValue) || nameValue.includes(v));
|
|
1282
|
+
});
|
|
1283
|
+
if (contains.length === 1) {
|
|
1284
|
+
return this.resolved(nameValue, String(contains[0].id ?? contains[0].mainTable?.id), "contains", allItems.length);
|
|
1285
|
+
}
|
|
1286
|
+
if (contains.length > 1) {
|
|
1287
|
+
throw ziguanjiaValidationError("resolve_ambiguous", `\u6309 ${this.nameField}=${nameValue} \u6A21\u7CCA\u89E3\u6790\u5230\u591A\u6761\u5019\u9009\uFF0C\u8BF7\u6539\u7528 ID \u6216\u63D0\u4F9B\u66F4\u7CBE\u786E\u540D\u79F0`, {
|
|
1288
|
+
candidates: contains.slice(0, 10).map((item) => ({ id: item.id ?? item.mainTable?.id, name: item[this.nameField] }))
|
|
1289
|
+
});
|
|
1290
|
+
}
|
|
1291
|
+
throw ziguanjiaValidationError("resolve_not_found", `\u672A\u89E3\u6790\u5230 ${this.nameField}=${nameValue} \u7684\u5F15\u7528\u8BB0\u5F55`);
|
|
1292
|
+
}
|
|
1293
|
+
resolved(nameValue, id, matched, total) {
|
|
1294
|
+
const items = [{ id, name: nameValue }];
|
|
1295
|
+
return ok(matched === "contains" ? "RESOLVED_FUZZY" : "COMPLETE", {
|
|
1296
|
+
items,
|
|
1297
|
+
count: items.length,
|
|
1298
|
+
nameField: this.nameField,
|
|
1299
|
+
resolved_id: id,
|
|
1300
|
+
matched,
|
|
1301
|
+
...matched === "contains" ? { note: `\u540D\u79F0\u300C${nameValue}\u300D\u6620\u5C04\u5230\u6B63\u5F0F\u540D\uFF0C\u5DF2\u91C7\u7528\u5BF9\u5E94 ID` } : {},
|
|
1302
|
+
total_scanned: total
|
|
1303
|
+
});
|
|
1304
|
+
}
|
|
1305
|
+
/** 资产类型全量枚举(pageSize 50,封顶 40 页 = 2000 条),用于缓存与兜底匹配。 */
|
|
1306
|
+
async enumerateAll(host) {
|
|
1307
|
+
const out = [];
|
|
1308
|
+
for (let page = 1; page <= 40; page++) {
|
|
1309
|
+
const result = await host.ebuilderRequest({
|
|
1310
|
+
endpoint: "getFormDataList",
|
|
1311
|
+
interfacePk: this.interfacePk,
|
|
1312
|
+
operation: this.name,
|
|
1313
|
+
body: { mainTable: {}, pageInfo: { pageNo: String(page), pageSize: "50" } }
|
|
1314
|
+
});
|
|
1315
|
+
const datas = getDatas(result).map(mainTableOf);
|
|
1316
|
+
if (datas.length === 0) break;
|
|
1317
|
+
for (const item of datas) {
|
|
1318
|
+
const id = item.id ?? item.mainTable?.id;
|
|
1319
|
+
const typeName = item[this.nameField];
|
|
1320
|
+
if (id !== void 0 && id !== null && typeName !== void 0 && typeName !== null) {
|
|
1321
|
+
out.push({ id: String(id), type_name: String(typeName) });
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
if (datas.length < 50) break;
|
|
1325
|
+
}
|
|
1326
|
+
return out;
|
|
1327
|
+
}
|
|
1328
|
+
};
|
|
1329
|
+
var ZiguanjiaGateCheckOperation = class {
|
|
1330
|
+
name = "asset.gate.check";
|
|
1331
|
+
async execute(_input, context) {
|
|
1332
|
+
const { host } = context;
|
|
1333
|
+
const result = await host.ebuilderRequest({
|
|
1334
|
+
endpoint: "getFormDataList",
|
|
1335
|
+
interfacePk: "zgjasset_search_appver",
|
|
1336
|
+
operation: this.name,
|
|
1337
|
+
body: { mainTable: {}, pageInfo: { pageNo: "1", pageSize: "10" } }
|
|
1338
|
+
});
|
|
1339
|
+
const gate = evaluateVersionGate(result);
|
|
1340
|
+
if (!gate.passed) {
|
|
1341
|
+
return ok("VERSION_GATE_FAILED", {
|
|
1342
|
+
passed: false,
|
|
1343
|
+
raw: gate.raw ?? null,
|
|
1344
|
+
version: gate.version ?? null,
|
|
1345
|
+
message: "\u7248\u672C\u95E8\u7981\u672A\u901A\u8FC7\uFF0C\u9700\u8981 zgjasset_search_appver \u5B58\u5728 ver_name \u2265 V14 \u7684\u8BB0\u5F55"
|
|
1346
|
+
});
|
|
1347
|
+
}
|
|
1348
|
+
return ok("VERSION_GATE_PASSED", { passed: true, raw: gate.raw ?? null, version: gate.version ?? null });
|
|
1349
|
+
}
|
|
1350
|
+
};
|
|
1351
|
+
|
|
1352
|
+
// src/shortcuts/asset/operations/viewlink.ts
|
|
1353
|
+
var SCENE_TAGS2 = ziguanjiaFixed.VIEW_LINK_SCENE_TAGS;
|
|
1354
|
+
var DEPRE_VIEWPORT_PATH2 = ziguanjiaFixed.DEPRE_VIEWPORT_PATH;
|
|
1355
|
+
var APP_TAG = "weaver-asset-eb";
|
|
1356
|
+
var DEFAULT_ANCHOR = "\u67E5\u770B\u8BE6\u60C5";
|
|
1357
|
+
function isCardScene(scene) {
|
|
1358
|
+
return Object.prototype.hasOwnProperty.call(SCENE_TAGS2, scene);
|
|
1359
|
+
}
|
|
1360
|
+
function joinUrl(baseUrl, path2) {
|
|
1361
|
+
if (typeof baseUrl !== "string" || baseUrl.trim() === "") return null;
|
|
1362
|
+
return `${baseUrl.replace(/\/+$/u, "")}${path2}`;
|
|
1363
|
+
}
|
|
1364
|
+
function assertSafeDataId(dataId) {
|
|
1365
|
+
if (/[\s/\\?#]/u.test(dataId)) {
|
|
1366
|
+
throw ziguanjiaValidationError("input_invalid", `\u6570\u636E ID \u542B\u6709\u4E0D\u5141\u8BB8\u7684\u5B57\u7B26\uFF1A${dataId}`);
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
var ZiguanjiaViewLinkOperation = class {
|
|
1370
|
+
name = "asset.viewlink";
|
|
1371
|
+
async execute(input, context) {
|
|
1372
|
+
const body = asObject(input, this.name);
|
|
1373
|
+
assertNoForbiddenKeys(body);
|
|
1374
|
+
const scene = typeof body.scene === "string" ? body.scene.trim() : "";
|
|
1375
|
+
if (scene === "") {
|
|
1376
|
+
throw ziguanjiaValidationError("input_required", "scene \u5FC5\u586B");
|
|
1377
|
+
}
|
|
1378
|
+
const anchor = typeof body.anchor === "string" && body.anchor.trim() !== "" ? body.anchor.trim() : DEFAULT_ANCHOR;
|
|
1379
|
+
const session = await context.host.getSession();
|
|
1380
|
+
if (scene === "depre_task") {
|
|
1381
|
+
const calcMonth = typeof body.calc_month === "string" ? body.calc_month.trim() : "";
|
|
1382
|
+
if (!/^\d{4}-\d{2}$/u.test(calcMonth)) {
|
|
1383
|
+
throw ziguanjiaValidationError("input_invalid", "depre_task \u573A\u666F\u5FC5\u987B\u63D0\u4F9B calc_month\uFF0C\u683C\u5F0F YYYY-MM");
|
|
1384
|
+
}
|
|
1385
|
+
const path2 = `${DEPRE_VIEWPORT_PATH2}?calc_month=${calcMonth}`;
|
|
1386
|
+
return ok("COMPLETE", {
|
|
1387
|
+
scene,
|
|
1388
|
+
mode: "viewport",
|
|
1389
|
+
formTag: null,
|
|
1390
|
+
objId: null,
|
|
1391
|
+
anchor,
|
|
1392
|
+
links: [{ dataId: null, calc_month: calcMonth, path: path2, url: joinUrl(session.baseUrl, path2), anchor }],
|
|
1393
|
+
available: true,
|
|
1394
|
+
warnings: []
|
|
1395
|
+
});
|
|
1396
|
+
}
|
|
1397
|
+
if (!isCardScene(scene)) {
|
|
1398
|
+
throw ziguanjiaValidationError("input_invalid", `\u4E0D\u652F\u6301\u7684 scene\uFF1A${scene}`);
|
|
1399
|
+
}
|
|
1400
|
+
const ids = body.ids;
|
|
1401
|
+
if (!Array.isArray(ids) || ids.length === 0) {
|
|
1402
|
+
throw ziguanjiaValidationError("input_required", "ids \u5FC5\u586B\uFF0C\u81F3\u5C11\u63D0\u4F9B\u4E00\u4E2A\u6570\u636E ID\uFF08\u5B57\u7B26\u4E32\uFF09");
|
|
1403
|
+
}
|
|
1404
|
+
const dataIds = ids.map((item) => item === void 0 || item === null ? "" : String(item).trim()).filter((item) => item !== "");
|
|
1405
|
+
if (dataIds.length === 0) {
|
|
1406
|
+
throw ziguanjiaValidationError("input_invalid", "ids \u4E0D\u80FD\u5168\u4E3A\u7A7A\u503C");
|
|
1407
|
+
}
|
|
1408
|
+
for (const dataId of dataIds) assertSafeDataId(dataId);
|
|
1409
|
+
const formTag = SCENE_TAGS2[scene];
|
|
1410
|
+
let objId = null;
|
|
1411
|
+
let warnings = [];
|
|
1412
|
+
try {
|
|
1413
|
+
objId = await context.host.resolveFormId({ formTag, appTag: APP_TAG, operation: this.name });
|
|
1414
|
+
} catch (error) {
|
|
1415
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
1416
|
+
warnings = [`\u94FE\u63A5\u6682\u4E0D\u53EF\u7528\uFF1A${reason}\uFF1B\u4E3B\u64CD\u4F5C\u5DF2\u6210\u529F\uFF0C\u4E0D\u8981\u56E0\u6B64\u91CD\u8BD5\u67E5\u8BE2 / \u5EFA\u5355 / \u6539\u5355\u3002`];
|
|
1417
|
+
}
|
|
1418
|
+
if (!objId) {
|
|
1419
|
+
return ok("VIEWLINK_UNAVAILABLE", {
|
|
1420
|
+
scene,
|
|
1421
|
+
mode: "card",
|
|
1422
|
+
formTag,
|
|
1423
|
+
objId: null,
|
|
1424
|
+
anchor,
|
|
1425
|
+
links: [],
|
|
1426
|
+
available: false,
|
|
1427
|
+
warnings
|
|
1428
|
+
});
|
|
1429
|
+
}
|
|
1430
|
+
const links = dataIds.map((dataId) => {
|
|
1431
|
+
const path2 = `/sp/ebdfpage/card/0/${objId}/${dataId}`;
|
|
1432
|
+
return { dataId, path: path2, url: joinUrl(session.baseUrl, path2), anchor };
|
|
1433
|
+
});
|
|
1434
|
+
return ok("COMPLETE", {
|
|
1435
|
+
scene,
|
|
1436
|
+
mode: "card",
|
|
1437
|
+
formTag,
|
|
1438
|
+
objId,
|
|
1439
|
+
anchor,
|
|
1440
|
+
links,
|
|
1441
|
+
available: true,
|
|
1442
|
+
warnings
|
|
1443
|
+
});
|
|
1444
|
+
}
|
|
1445
|
+
};
|
|
1446
|
+
|
|
1447
|
+
// src/shortcuts/asset/operations/write.ts
|
|
1448
|
+
var EB = ziguanjiaFixed.EB_INTERFACE_PK;
|
|
1449
|
+
var ES = ziguanjiaFixed.ES_UNIQUE_INDENT;
|
|
1450
|
+
function todayStr() {
|
|
1451
|
+
const d = /* @__PURE__ */ new Date();
|
|
1452
|
+
const m = String(d.getMonth() + 1).padStart(2, "0");
|
|
1453
|
+
const day = String(d.getDate()).padStart(2, "0");
|
|
1454
|
+
return `${d.getFullYear()}-${m}-${day}`;
|
|
1455
|
+
}
|
|
1456
|
+
var ZiguanjiaPreparedWriteOperation = class {
|
|
1457
|
+
constructor(name) {
|
|
1458
|
+
this.name = name;
|
|
1459
|
+
}
|
|
1460
|
+
name;
|
|
1461
|
+
async execute(input, context) {
|
|
1462
|
+
const body = asObject(input, this.name);
|
|
1463
|
+
await ensureVersionGate(context.host, this.name);
|
|
1464
|
+
if (body.confirm !== true || typeof body.continuation !== "string" || body.continuation === "") {
|
|
1465
|
+
const prepared = await this.prepare(body, context);
|
|
1466
|
+
const token = await context.continuation.issue({ operation: this.name, ...prepared.commit });
|
|
1467
|
+
return ok("NEED_CONFIRM", {
|
|
1468
|
+
operation: this.name,
|
|
1469
|
+
confirmation: prepared.confirmationText || `\u5373\u5C06\u6267\u884C ${this.name}\uFF0C\u8BF7\u786E\u8BA4\u9884\u89C8\u65E0\u8BEF\u540E\uFF0C\u643A\u5E26\u672C continuation \u5E76\u8BBE\u7F6E confirm:true \u91CD\u65B0\u6267\u884C\u3002`,
|
|
1470
|
+
continuation: token,
|
|
1471
|
+
preview: prepared.preview
|
|
1472
|
+
});
|
|
1473
|
+
}
|
|
1474
|
+
const verified = await context.continuation.verify(String(body.continuation), this.name);
|
|
1475
|
+
const result = await this.apply(verified, context);
|
|
1476
|
+
return ok("COMPLETE", result);
|
|
1477
|
+
}
|
|
1478
|
+
};
|
|
1479
|
+
async function resolveAssetId(host, interfacePk, filters, operation) {
|
|
1480
|
+
const result = await host.ebuilderRequest({
|
|
1481
|
+
endpoint: "getFormDataList",
|
|
1482
|
+
interfacePk,
|
|
1483
|
+
operation,
|
|
1484
|
+
body: { mainTable: filters, pageInfo: { pageNo: "1", pageSize: "10" } }
|
|
1485
|
+
});
|
|
1486
|
+
const datas = getDatas(result).map(mainTableOf);
|
|
1487
|
+
if (datas.length === 0) {
|
|
1488
|
+
throw ziguanjiaValidationError("resolve_not_found", `\u672A\u627E\u5230\u5339\u914D\u7684\u8D44\u4EA7\uFF08${JSON.stringify(filters)}\uFF09`);
|
|
1489
|
+
}
|
|
1490
|
+
if (datas.length > 1) {
|
|
1491
|
+
throw ziguanjiaValidationError("resolve_ambiguous", "\u5339\u914D\u5230\u591A\u6761\u8D44\u4EA7\uFF0C\u8BF7\u6539\u7528 id \u660E\u786E\u6307\u5B9A", {
|
|
1492
|
+
candidates: datas.slice(0, 10).map((d) => d.id ?? d.mainTable?.id)
|
|
1493
|
+
});
|
|
1494
|
+
}
|
|
1495
|
+
const id = datas[0].id ?? datas[0].mainTable?.id;
|
|
1496
|
+
if (id === void 0 || id === null || String(id).trim() === "") {
|
|
1497
|
+
throw ziguanjiaValidationError("resolve_missing_id", "\u5339\u914D\u5230\u8D44\u4EA7\u4F46\u7F3A\u5C11\u53EF\u5F15\u7528 ID");
|
|
1498
|
+
}
|
|
1499
|
+
return String(id);
|
|
1500
|
+
}
|
|
1501
|
+
var OPERATIONINFO = { printCost: false, asyncPostProcess: false, asyncMark: false };
|
|
1502
|
+
var ZiguanjiaCreateOperation = class extends ZiguanjiaPreparedWriteOperation {
|
|
1503
|
+
constructor() {
|
|
1504
|
+
super("asset.create");
|
|
1505
|
+
}
|
|
1506
|
+
async prepare(body, context) {
|
|
1507
|
+
const assetName = typeof body.asset_name === "string" ? body.asset_name : "";
|
|
1508
|
+
const assetType = typeof body.asset_type_browse === "string" ? body.asset_type_browse : "";
|
|
1509
|
+
if (assetName.trim() === "") throw ziguanjiaValidationError("input_required", "asset_name \u5FC5\u586B");
|
|
1510
|
+
if (assetType.trim() === "") throw ziguanjiaValidationError("input_required", "asset_type_browse \u5FC5\u586B\uFF08\u8D44\u4EA7\u7C7B\u578B ID\uFF0C\u7ECF asset.resolve.type \u89E3\u6790\uFF09");
|
|
1511
|
+
const session = await context.host.getSession();
|
|
1512
|
+
const mainTable = {
|
|
1513
|
+
asset_name: assetName,
|
|
1514
|
+
asset_type_browse: assetType,
|
|
1515
|
+
asset_data_attr: typeof body.asset_data_attr === "string" ? body.asset_data_attr : "0",
|
|
1516
|
+
admin_istrator: typeof body.admin_istrator === "string" && body.admin_istrator !== "" ? body.admin_istrator : session.userId
|
|
1517
|
+
};
|
|
1518
|
+
if (typeof body.asset_spec === "string" && body.asset_spec !== "") mainTable.asset_spec = body.asset_spec;
|
|
1519
|
+
mainTable.stockindate = typeof body.stockindate === "string" && body.stockindate !== "" ? body.stockindate : todayStr();
|
|
1520
|
+
if (typeof body.startprice === "string" && body.startprice !== "") mainTable.startprice = body.startprice;
|
|
1521
|
+
if (typeof body.original_value === "string" && body.original_value !== "") mainTable.original_value = body.original_value;
|
|
1522
|
+
if (typeof body.image_id === "string" && body.image_id !== "") mainTable.image_id = body.image_id;
|
|
1523
|
+
if (typeof body.blongdepartment === "string" && body.blongdepartment !== "") mainTable.blongdepartment = body.blongdepartment;
|
|
1524
|
+
if (typeof body.resourceid === "string" && body.resourceid !== "") mainTable.resourceid = body.resourceid;
|
|
1525
|
+
if (typeof body.stateid === "string" && body.stateid !== "") mainTable.stateid = body.stateid;
|
|
1526
|
+
return {
|
|
1527
|
+
preview: { operation: "create", interfacePk: EB.create, mainTable },
|
|
1528
|
+
confirmationText: `\u5373\u5C06\u5728 E10 \u8D44\u4EA7\u5E93\u65B0\u589E\u8D44\u4EA7\u300C${assetName}\u300D\uFF08\u7C7B\u578B ${assetType}\uFF09\u3002\u786E\u8BA4\u540E\u6267\u884C\u3002`,
|
|
1529
|
+
commit: { endpoint: "saveFormData", interfacePk: EB.create, mainTable }
|
|
1530
|
+
};
|
|
1531
|
+
}
|
|
1532
|
+
async apply(commit, context) {
|
|
1533
|
+
const result = await context.host.ebuilderRequest({
|
|
1534
|
+
endpoint: "saveFormData",
|
|
1535
|
+
interfacePk: String(commit.interfacePk),
|
|
1536
|
+
operation: this.name,
|
|
1537
|
+
body: { operationinfo: OPERATIONINFO, datas: [{ mainTable: commit.mainTable }] }
|
|
1538
|
+
});
|
|
1539
|
+
const dataIds = result?.datajson?.dataIds ?? [];
|
|
1540
|
+
return { dataIds, count: Array.isArray(dataIds) ? dataIds.length : 0, mainTable: commit.mainTable };
|
|
1541
|
+
}
|
|
1542
|
+
};
|
|
1543
|
+
var ZiguanjiaUpdateOperation = class extends ZiguanjiaPreparedWriteOperation {
|
|
1544
|
+
constructor() {
|
|
1545
|
+
super("asset.update");
|
|
1546
|
+
}
|
|
1547
|
+
async prepare(body, context) {
|
|
1548
|
+
const changes = body.changes;
|
|
1549
|
+
if (!changes || typeof changes !== "object" || Array.isArray(changes) || Object.keys(changes).length === 0) {
|
|
1550
|
+
throw ziguanjiaValidationError("input_required", "changes \u5FC5\u586B\u4E14\u81F3\u5C11\u5305\u542B\u4E00\u4E2A\u5B57\u6BB5");
|
|
1551
|
+
}
|
|
1552
|
+
let id = typeof body.id === "string" && body.id !== "" ? body.id : void 0;
|
|
1553
|
+
if (!id) {
|
|
1554
|
+
const filters = {};
|
|
1555
|
+
if (typeof body.asset_number === "string" && body.asset_number !== "") filters.asset_number = body.asset_number;
|
|
1556
|
+
if (typeof body.asset_name === "string" && body.asset_name !== "") filters.asset_name = body.asset_name;
|
|
1557
|
+
if (Object.keys(filters).length === 0) {
|
|
1558
|
+
throw ziguanjiaValidationError("input_required", "\u9700\u63D0\u4F9B id\uFF0C\u6216 asset_number / asset_name \u7528\u4E8E\u5B9A\u4F4D\u8D44\u4EA7");
|
|
1559
|
+
}
|
|
1560
|
+
id = await resolveAssetId(context.host, EB.baseDetail, filters, this.name);
|
|
1561
|
+
}
|
|
1562
|
+
const mainTable = { id, ...changes };
|
|
1563
|
+
return {
|
|
1564
|
+
preview: { operation: "update", id, changes, interfacePk: EB.update },
|
|
1565
|
+
confirmationText: `\u5373\u5C06\u4FEE\u6539\u8D44\u4EA7 ${id} \u7684\u5B57\u6BB5\uFF1A${Object.keys(changes).join(", ")}\u3002\u786E\u8BA4\u540E\u6267\u884C\u3002`,
|
|
1566
|
+
commit: { endpoint: "updateFormData", interfacePk: EB.update, mainTable }
|
|
1567
|
+
};
|
|
1568
|
+
}
|
|
1569
|
+
async apply(commit, context) {
|
|
1570
|
+
const result = await context.host.ebuilderRequest({
|
|
1571
|
+
endpoint: "updateFormData",
|
|
1572
|
+
interfacePk: String(commit.interfacePk),
|
|
1573
|
+
operation: this.name,
|
|
1574
|
+
body: { operationinfo: OPERATIONINFO, datas: [{ mainTable: commit.mainTable }] }
|
|
1575
|
+
});
|
|
1576
|
+
const dataIds = result?.datajson?.dataIds ?? [];
|
|
1577
|
+
return { dataIds, count: Array.isArray(dataIds) ? dataIds.length : 0, id: commit.mainTable.id };
|
|
1578
|
+
}
|
|
1579
|
+
};
|
|
1580
|
+
var ZiguanjiaUseOperation = class extends ZiguanjiaPreparedWriteOperation {
|
|
1581
|
+
constructor() {
|
|
1582
|
+
super("asset.use");
|
|
1583
|
+
}
|
|
1584
|
+
async prepare(body, _context) {
|
|
1585
|
+
const detail1 = Array.isArray(body.detail1) ? body.detail1 : [];
|
|
1586
|
+
if (detail1.length === 0) throw ziguanjiaValidationError("input_required", "detail1 \u81F3\u5C11\u4E00\u6761\u9886\u7528\u660E\u7EC6");
|
|
1587
|
+
const mainTable = { detail1 };
|
|
1588
|
+
if (typeof body.use_location === "string" && body.use_location !== "") mainTable.use_location = body.use_location;
|
|
1589
|
+
if (typeof body.purpose === "string" && body.purpose !== "") mainTable.purpose = body.purpose;
|
|
1590
|
+
return {
|
|
1591
|
+
preview: { operation: "use", uniqueIndent: ES.use, mainTable },
|
|
1592
|
+
confirmationText: `\u5373\u5C06\u63D0\u4EA4\u8D44\u4EA7\u9886\u7528\uFF08${detail1.length} \u6761\u660E\u7EC6\uFF09\u3002\u786E\u8BA4\u540E\u6267\u884C\u3002`,
|
|
1593
|
+
commit: { uniqueIndent: ES.use, mainTable }
|
|
1594
|
+
};
|
|
1595
|
+
}
|
|
1596
|
+
async apply(commit, context) {
|
|
1597
|
+
const result = await context.host.actionFlow({
|
|
1598
|
+
uniqueIndent: String(commit.uniqueIndent),
|
|
1599
|
+
mainTable: commit.mainTable,
|
|
1600
|
+
operation: this.name
|
|
1601
|
+
});
|
|
1602
|
+
return actionFlowResult(result);
|
|
1603
|
+
}
|
|
1604
|
+
};
|
|
1605
|
+
var ZiguanjiaReturnQueryOperation = class {
|
|
1606
|
+
name = "asset.return.query";
|
|
1607
|
+
async execute(input, context) {
|
|
1608
|
+
const body = asObject(input, this.name);
|
|
1609
|
+
assertNoForbiddenKeys(body);
|
|
1610
|
+
const mainTable = {
|
|
1611
|
+
return_type: typeof body.return_type === "string" ? body.return_type : "",
|
|
1612
|
+
detail1: Array.isArray(body.detail1) ? body.detail1 : []
|
|
1613
|
+
};
|
|
1614
|
+
const result = await context.host.actionFlow({
|
|
1615
|
+
uniqueIndent: ES.returnQuery,
|
|
1616
|
+
mainTable,
|
|
1617
|
+
operation: this.name
|
|
1618
|
+
});
|
|
1619
|
+
return ok("COMPLETE", actionFlowResult(result));
|
|
1620
|
+
}
|
|
1621
|
+
};
|
|
1622
|
+
var ZiguanjiaReturnCreateOperation = class extends ZiguanjiaPreparedWriteOperation {
|
|
1623
|
+
constructor() {
|
|
1624
|
+
super("asset.return.create");
|
|
1625
|
+
}
|
|
1626
|
+
async prepare(body, _context) {
|
|
1627
|
+
const dataIds = typeof body.data_ids === "string" && body.data_ids.trim() !== "" ? body.data_ids : void 0;
|
|
1628
|
+
if (!dataIds) throw ziguanjiaValidationError("input_required", "data_ids \u5FC5\u586B\uFF08\u534A\u89D2\u9017\u53F7\u62FC\u63A5\u7684\u786E\u8BA4\u8D44\u4EA7\u6570\u636E ID\uFF0C\u6765\u81EA asset.return.query\uFF09");
|
|
1629
|
+
const mainTable = { data_ids: dataIds };
|
|
1630
|
+
return {
|
|
1631
|
+
preview: { operation: "return.create", uniqueIndent: ES.returnCreate, mainTable },
|
|
1632
|
+
confirmationText: `\u5373\u5C06\u5F52\u8FD8\u8D44\u4EA7\u6570\u636E ID\uFF1A${dataIds}\u3002\u786E\u8BA4\u540E\u6267\u884C\u3002`,
|
|
1633
|
+
commit: { uniqueIndent: ES.returnCreate, mainTable }
|
|
1634
|
+
};
|
|
1635
|
+
}
|
|
1636
|
+
async apply(commit, context) {
|
|
1637
|
+
const result = await context.host.actionFlow({
|
|
1638
|
+
uniqueIndent: String(commit.uniqueIndent),
|
|
1639
|
+
mainTable: commit.mainTable,
|
|
1640
|
+
operation: this.name
|
|
1641
|
+
});
|
|
1642
|
+
return actionFlowResult(result);
|
|
1643
|
+
}
|
|
1644
|
+
};
|
|
1645
|
+
var ZiguanjiaRepairQueryOperation = class {
|
|
1646
|
+
name = "asset.repair.query";
|
|
1647
|
+
async execute(input, context) {
|
|
1648
|
+
const body = asObject(input, this.name);
|
|
1649
|
+
assertNoForbiddenKeys(body);
|
|
1650
|
+
const mainTable = { detail1: Array.isArray(body.detail1) ? body.detail1 : [] };
|
|
1651
|
+
const result = await context.host.actionFlow({
|
|
1652
|
+
uniqueIndent: ES.repairQuery,
|
|
1653
|
+
mainTable,
|
|
1654
|
+
operation: this.name
|
|
1655
|
+
});
|
|
1656
|
+
return ok("COMPLETE", actionFlowResult(result));
|
|
1657
|
+
}
|
|
1658
|
+
};
|
|
1659
|
+
var ZiguanjiaRepairCreateOperation = class extends ZiguanjiaPreparedWriteOperation {
|
|
1660
|
+
constructor() {
|
|
1661
|
+
super("asset.repair.create");
|
|
1662
|
+
}
|
|
1663
|
+
async prepare(body, _context) {
|
|
1664
|
+
const detail1 = Array.isArray(body.detail1) ? body.detail1 : [];
|
|
1665
|
+
if (detail1.length === 0) throw ziguanjiaValidationError("input_required", "detail1 \u81F3\u5C11\u4E00\u6761\u62A5\u4FEE\u660E\u7EC6");
|
|
1666
|
+
const mainTable = { detail1 };
|
|
1667
|
+
if (typeof body.repail_name === "string" && body.repail_name !== "") mainTable.repail_name = body.repail_name;
|
|
1668
|
+
if (typeof body.repail_remark === "string" && body.repail_remark !== "") mainTable.repail_remark = body.repail_remark;
|
|
1669
|
+
return {
|
|
1670
|
+
preview: { operation: "repair.create", uniqueIndent: ES.repairCreate, mainTable },
|
|
1671
|
+
confirmationText: `\u5373\u5C06\u63D0\u4EA4\u8D44\u4EA7\u62A5\u4FEE\uFF08${detail1.length} \u6761\u660E\u7EC6\uFF09\u3002\u786E\u8BA4\u540E\u6267\u884C\u3002`,
|
|
1672
|
+
commit: { uniqueIndent: ES.repairCreate, mainTable }
|
|
1673
|
+
};
|
|
1674
|
+
}
|
|
1675
|
+
async apply(commit, context) {
|
|
1676
|
+
const result = await context.host.actionFlow({
|
|
1677
|
+
uniqueIndent: String(commit.uniqueIndent),
|
|
1678
|
+
mainTable: commit.mainTable,
|
|
1679
|
+
operation: this.name
|
|
1680
|
+
});
|
|
1681
|
+
return actionFlowResult(result);
|
|
1682
|
+
}
|
|
1683
|
+
};
|
|
1684
|
+
var ZiguanjiaPurchOperation = class extends ZiguanjiaPreparedWriteOperation {
|
|
1685
|
+
constructor() {
|
|
1686
|
+
super("asset.purch");
|
|
1687
|
+
}
|
|
1688
|
+
async prepare(body, _context) {
|
|
1689
|
+
const detail1 = Array.isArray(body.detail1) ? body.detail1 : [];
|
|
1690
|
+
if (detail1.length === 0) throw ziguanjiaValidationError("input_required", "detail1 \u81F3\u5C11\u4E00\u6761\u91C7\u8D2D\u7533\u8BF7\u660E\u7EC6");
|
|
1691
|
+
const mainTable = { detail1 };
|
|
1692
|
+
if (typeof body.purchase_name === "string" && body.purchase_name !== "") mainTable.purchase_name = body.purchase_name;
|
|
1693
|
+
return {
|
|
1694
|
+
preview: { operation: "purch", uniqueIndent: ES.purch, mainTable },
|
|
1695
|
+
confirmationText: `\u5373\u5C06\u63D0\u4EA4\u8D44\u4EA7\u91C7\u8D2D\u7533\u8BF7\uFF08${detail1.length} \u6761\u660E\u7EC6\uFF09\u3002\u786E\u8BA4\u540E\u6267\u884C\u3002`,
|
|
1696
|
+
commit: { uniqueIndent: ES.purch, mainTable }
|
|
1697
|
+
};
|
|
1698
|
+
}
|
|
1699
|
+
async apply(commit, context) {
|
|
1700
|
+
const result = await context.host.actionFlow({
|
|
1701
|
+
uniqueIndent: String(commit.uniqueIndent),
|
|
1702
|
+
mainTable: commit.mainTable,
|
|
1703
|
+
operation: this.name
|
|
1704
|
+
});
|
|
1705
|
+
return actionFlowResult(result);
|
|
1706
|
+
}
|
|
1707
|
+
};
|
|
1708
|
+
function normalizeBinaryFlag(value) {
|
|
1709
|
+
if (value === void 0 || value === null || value === "") return void 0;
|
|
1710
|
+
if (value === true) return "1";
|
|
1711
|
+
if (value === false) return "0";
|
|
1712
|
+
const text = String(value).trim().toLowerCase();
|
|
1713
|
+
if (text === "1" || text === "true") return "1";
|
|
1714
|
+
if (text === "0" || text === "false") return "0";
|
|
1715
|
+
return void 0;
|
|
1716
|
+
}
|
|
1717
|
+
function toFiniteNumber(value) {
|
|
1718
|
+
if (value === void 0 || value === null || value === "") return void 0;
|
|
1719
|
+
const num = Number(value);
|
|
1720
|
+
return Number.isFinite(num) ? num : void 0;
|
|
1721
|
+
}
|
|
1722
|
+
function assertDeprePrecheckAllowed(table) {
|
|
1723
|
+
const normal = toFiniteNumber(table?.normalCount);
|
|
1724
|
+
const divide = toFiniteNumber(table?.divideCount);
|
|
1725
|
+
const voucher = toFiniteNumber(table?.voucherCount);
|
|
1726
|
+
const afterResult = toFiniteNumber(table?.afterResultCount);
|
|
1727
|
+
const afterMonth = toFiniteNumber(table?.afterMonthRecordCount);
|
|
1728
|
+
if (normal === 0) {
|
|
1729
|
+
throw ziguanjiaValidationError("depre_not_allowed", "\u5F53\u524D\u5468\u671F\u65E0\u7B26\u5408\u6761\u4EF6\u7684\u8D44\u4EA7\uFF0C\u65E0\u6CD5\u53D1\u8D77\u8BA1\u63D0\u64CD\u4F5C");
|
|
1730
|
+
}
|
|
1731
|
+
if ((divide ?? 0) > 0 || (voucher ?? 0) > 0) {
|
|
1732
|
+
throw ziguanjiaValidationError("depre_not_allowed", "\u76EE\u6807\u5468\u671F\u5DF2\u5B58\u5728\u5173\u8054\u4E1A\u52A1\u8BB0\u5F55\uFF0C\u65E0\u6CD5\u91CD\u590D\u8BA1\u63D0");
|
|
1733
|
+
}
|
|
1734
|
+
if ((afterResult ?? 0) > 0 || (afterMonth ?? 0) > 0) {
|
|
1735
|
+
throw ziguanjiaValidationError("depre_not_allowed", "\u540E\u7EED\u5468\u671F\u5DF2\u6267\u884C\u7ED3\u8D26\u6216\u8BA1\u63D0\u64CD\u4F5C\uFF0C\u65E0\u6CD5\u8865\u5F55");
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
var ZiguanjiaDepreOperation = class extends ZiguanjiaPreparedWriteOperation {
|
|
1739
|
+
constructor() {
|
|
1740
|
+
super("asset.depre");
|
|
1741
|
+
}
|
|
1742
|
+
async prepare(body, context) {
|
|
1743
|
+
const calcMonth = typeof body.calc_month === "string" ? body.calc_month.trim() : "";
|
|
1744
|
+
if (!/^\d{4}-\d{2}$/u.test(calcMonth)) {
|
|
1745
|
+
throw ziguanjiaValidationError("input_invalid", "calc_month \u5FC5\u586B\uFF0C\u683C\u5F0F YYYY-MM\uFF0C\u4E14\u987B\u65E9\u4E8E\u5F53\u524D\u6708\u4EFD");
|
|
1746
|
+
}
|
|
1747
|
+
const now = /* @__PURE__ */ new Date();
|
|
1748
|
+
const currentMonth = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}`;
|
|
1749
|
+
if (calcMonth >= currentMonth) {
|
|
1750
|
+
throw ziguanjiaValidationError("input_invalid", `\u8BA1\u63D0\u5E74\u6708\u5FC5\u987B\u65E9\u4E8E\u5F53\u524D\u6708\u4EFD\uFF08\u5F53\u524D ${currentMonth}\uFF09\uFF0C${calcMonth} \u4E0D\u5408\u6CD5\uFF0C\u5DF2\u505C\u6B62`);
|
|
1751
|
+
}
|
|
1752
|
+
const setting = await context.host.ebuilderRequest({
|
|
1753
|
+
endpoint: "getFormDataList",
|
|
1754
|
+
interfacePk: EB.depreSetting,
|
|
1755
|
+
operation: this.name,
|
|
1756
|
+
body: { mainTable: {}, pageInfo: { pageNo: "1", pageSize: "10" } }
|
|
1757
|
+
});
|
|
1758
|
+
const settingItems = getDatas(setting).map(mainTableOf);
|
|
1759
|
+
const isGroupCalc = normalizeBinaryFlag(settingItems[0]?.is_group_calc) ?? "0";
|
|
1760
|
+
const taskMode = isGroupCalc === "1" ? "1" : "0";
|
|
1761
|
+
let companyIds;
|
|
1762
|
+
let companyName;
|
|
1763
|
+
if (isGroupCalc === "1") {
|
|
1764
|
+
const explicit = typeof body.company_ids === "string" ? body.company_ids.trim() : "";
|
|
1765
|
+
const session = await context.host.getSession();
|
|
1766
|
+
companyName = session.subcompany || void 0;
|
|
1767
|
+
companyIds = explicit !== "" ? explicit : await context.host.resolveSubcompanyIdByName(session.subcompany);
|
|
1768
|
+
}
|
|
1769
|
+
const precheckMainTable = { calcMonth };
|
|
1770
|
+
if (companyIds) precheckMainTable.companyIds = companyIds;
|
|
1771
|
+
const precheck = await context.host.actionFlow({
|
|
1772
|
+
uniqueIndent: ES.deprePrecheck,
|
|
1773
|
+
mainTable: precheckMainTable,
|
|
1774
|
+
operation: this.name
|
|
1775
|
+
});
|
|
1776
|
+
const precheckTable = actionFlowResult(precheck).mainTable;
|
|
1777
|
+
assertDeprePrecheckAllowed(precheckTable);
|
|
1778
|
+
const normalCount = toFiniteNumber(precheckTable?.normalCount);
|
|
1779
|
+
const modeText = isGroupCalc === "1" ? "\u5206\u7EC4\u8BA1\u63D0\uFF08\u6309\u5206\u90E8\uFF09" : "\u975E\u5206\u7EC4\u8BA1\u63D0\uFF08\u5168\u91CF\uFF09";
|
|
1780
|
+
const companyText = isGroupCalc === "1" ? `\uFF0C\u5206\u90E8\uFF1A${companyName ?? companyIds}` : "";
|
|
1781
|
+
const countText = normalCount !== void 0 ? `\uFF0C\u672C\u671F\u53EF\u8BA1\u63D0\u8D44\u4EA7 ${normalCount} \u9879` : "";
|
|
1782
|
+
return {
|
|
1783
|
+
preview: {
|
|
1784
|
+
operation: "depre",
|
|
1785
|
+
calc_month: calcMonth,
|
|
1786
|
+
is_group_calc: isGroupCalc,
|
|
1787
|
+
task_mode: taskMode,
|
|
1788
|
+
...companyIds ? { company_ids: companyIds } : {},
|
|
1789
|
+
precheckResultCode: precheck?.resultCode,
|
|
1790
|
+
precheckResultMsg: precheck?.resultMsg,
|
|
1791
|
+
precheck: precheckTable,
|
|
1792
|
+
settingCount: settingItems.length
|
|
1793
|
+
},
|
|
1794
|
+
confirmationText: `\u5373\u5C06\u5BF9 ${calcMonth} \u6267\u884C\u8D44\u4EA7\u6298\u65E7\u8BA1\u63D0\uFF08${modeText}${companyText}${countText}\uFF09\u3002\u786E\u8BA4\u540E\u6267\u884C\u3002`,
|
|
1795
|
+
commit: {
|
|
1796
|
+
calc_month: calcMonth,
|
|
1797
|
+
is_group_calc: isGroupCalc,
|
|
1798
|
+
task_mode: taskMode,
|
|
1799
|
+
task_status: "0",
|
|
1800
|
+
...companyIds ? { company_ids: companyIds } : {},
|
|
1801
|
+
settingInterfacePk: EB.depreSetting,
|
|
1802
|
+
taskInterfacePk: EB.depreTask
|
|
1803
|
+
}
|
|
1804
|
+
};
|
|
1805
|
+
}
|
|
1806
|
+
async apply(commit, context) {
|
|
1807
|
+
const mainTable = {
|
|
1808
|
+
calc_month: commit.calc_month,
|
|
1809
|
+
task_mode: commit.task_mode,
|
|
1810
|
+
is_group_calc: commit.is_group_calc,
|
|
1811
|
+
task_status: commit.task_status ?? "0"
|
|
1812
|
+
};
|
|
1813
|
+
if (typeof commit.company_ids === "string" && commit.company_ids !== "") {
|
|
1814
|
+
mainTable.company_ids = commit.company_ids;
|
|
1815
|
+
}
|
|
1816
|
+
const result = await context.host.ebuilderRequest({
|
|
1817
|
+
endpoint: "saveFormData",
|
|
1818
|
+
interfacePk: String(commit.taskInterfacePk ?? EB.depreTask),
|
|
1819
|
+
operation: this.name,
|
|
1820
|
+
body: { operationinfo: OPERATIONINFO, datas: [{ mainTable }] }
|
|
1821
|
+
});
|
|
1822
|
+
const dataIds = result?.datajson?.dataIds ?? [];
|
|
1823
|
+
return {
|
|
1824
|
+
dataIds,
|
|
1825
|
+
count: Array.isArray(dataIds) ? dataIds.length : 0,
|
|
1826
|
+
calc_month: commit.calc_month,
|
|
1827
|
+
is_group_calc: commit.is_group_calc,
|
|
1828
|
+
task_mode: commit.task_mode
|
|
1829
|
+
};
|
|
1830
|
+
}
|
|
1831
|
+
};
|
|
1832
|
+
|
|
1833
|
+
// src/shortcuts/asset/operations/registry.ts
|
|
1834
|
+
var EB2 = ziguanjiaFixed.EB_INTERFACE_PK;
|
|
1835
|
+
function buildRegistry() {
|
|
1836
|
+
const registry = /* @__PURE__ */ new Map();
|
|
1837
|
+
const handlers = [
|
|
1838
|
+
new ZiguanjiaGateCheckOperation(),
|
|
1839
|
+
new ZiguanjiaQueryOperation("asset.list", {
|
|
1840
|
+
interfacePk: EB2.baseList,
|
|
1841
|
+
bodyFields: ["id", "asset_name", "asset_number", "stateid", "asset_type_browse", "location_browse", "admin_istrator", "resourceid"],
|
|
1842
|
+
pageSizeDefault: 10,
|
|
1843
|
+
// 资产列表:给了人员才拼 ?person_id=,未给人员不拼(不设置 defaultPersonIdFromSession)。
|
|
1844
|
+
personQueryParam: "person_id",
|
|
1845
|
+
viewLinkScene: "asset_info"
|
|
1846
|
+
}),
|
|
1847
|
+
new ZiguanjiaQueryOperation("asset.detail", {
|
|
1848
|
+
interfacePk: EB2.baseDetail,
|
|
1849
|
+
bodyFields: ["id", "asset_number", "asset_name"],
|
|
1850
|
+
pageSizeDefault: 10,
|
|
1851
|
+
requireAtLeastOne: ["id", "asset_number", "asset_name"],
|
|
1852
|
+
viewLinkScene: "asset_info"
|
|
1853
|
+
}),
|
|
1854
|
+
new ZiguanjiaQueryOperation("asset.uselist", {
|
|
1855
|
+
interfacePk: EB2.useList,
|
|
1856
|
+
bodyFields: [],
|
|
1857
|
+
pageSizeDefault: 5,
|
|
1858
|
+
// 领用人字段以运行时字段定义为准(候选 resourceid/apply_person/use_person),不硬编码 person_id。
|
|
1859
|
+
defaultPersonIdFromSession: true,
|
|
1860
|
+
personField: { formTag: "uf_asset_use", candidates: ["resourceid", "apply_person", "use_person"] },
|
|
1861
|
+
viewLinkScene: "asset_use"
|
|
1862
|
+
}),
|
|
1863
|
+
new ZiguanjiaQueryOperation("asset.repaillist", {
|
|
1864
|
+
interfacePk: EB2.repairList,
|
|
1865
|
+
bodyFields: [],
|
|
1866
|
+
pageSizeDefault: 5,
|
|
1867
|
+
// 报修记录:人员写入主表 repair_user(来源 _person.md 契约)。
|
|
1868
|
+
defaultPersonIdFromSession: true,
|
|
1869
|
+
writePersonIdTo: "repair_user",
|
|
1870
|
+
viewLinkScene: "asset_repail"
|
|
1871
|
+
}),
|
|
1872
|
+
new ZiguanjiaQueryOperation("asset.purchaselist", {
|
|
1873
|
+
interfacePk: EB2.purchList,
|
|
1874
|
+
bodyFields: ["purchaser"],
|
|
1875
|
+
pageSizeDefault: 5,
|
|
1876
|
+
// 采购申请:人员拼 ?person_id=(默认当前登录人);purchaser 走 body,二者同一请求只用其一。
|
|
1877
|
+
defaultPersonIdFromSession: true,
|
|
1878
|
+
personQueryParam: "person_id",
|
|
1879
|
+
viewLinkScene: "asset_purch_apply"
|
|
1880
|
+
}),
|
|
1881
|
+
new ZiguanjiaResolveOperation("asset.resolve.location", EB2.location, "house_name"),
|
|
1882
|
+
new ZiguanjiaResolveOperation("asset.resolve.status", EB2.status, "status_name"),
|
|
1883
|
+
new ZiguanjiaResolveOperation("asset.resolve.type", EB2.type, "type_name", true),
|
|
1884
|
+
new ZiguanjiaCreateOperation(),
|
|
1885
|
+
new ZiguanjiaUpdateOperation(),
|
|
1886
|
+
new ZiguanjiaUseOperation(),
|
|
1887
|
+
new ZiguanjiaReturnQueryOperation(),
|
|
1888
|
+
new ZiguanjiaReturnCreateOperation(),
|
|
1889
|
+
new ZiguanjiaRepairQueryOperation(),
|
|
1890
|
+
new ZiguanjiaRepairCreateOperation(),
|
|
1891
|
+
new ZiguanjiaPurchOperation(),
|
|
1892
|
+
new ZiguanjiaDepreOperation(),
|
|
1893
|
+
new ZiguanjiaViewLinkOperation()
|
|
1894
|
+
];
|
|
1895
|
+
for (const handler of handlers) {
|
|
1896
|
+
if (registry.has(handler.name)) throw new Error(`duplicate ziguanjia operation handler: ${handler.name}`);
|
|
1897
|
+
registry.set(handler.name, handler);
|
|
1898
|
+
}
|
|
1899
|
+
for (const contract of ziguanjiaOperations) {
|
|
1900
|
+
if (!registry.has(contract.name)) throw new Error(`missing ziguanjia operation handler: ${contract.name}`);
|
|
1901
|
+
}
|
|
1902
|
+
return registry;
|
|
1903
|
+
}
|
|
1904
|
+
var ziguanjiaOperationRegistry = buildRegistry();
|
|
1905
|
+
function getZiguanjiaOperation(operation) {
|
|
1906
|
+
const handler = ziguanjiaOperationRegistry.get(operation);
|
|
1907
|
+
if (!handler) {
|
|
1908
|
+
throw ziguanjiaValidationError("operation_unknown", `\u8D44\u7BA1\u5BB6\u4E0D\u652F\u6301\u64CD\u4F5C\uFF1A${operation}`);
|
|
1909
|
+
}
|
|
1910
|
+
return handler;
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1913
|
+
// src/shortcuts/asset/operations.ts
|
|
1914
|
+
async function executeZiguanjiaOperation(operation, rawInput, context) {
|
|
1915
|
+
const handler = getZiguanjiaOperation(operation);
|
|
1916
|
+
const input = asObject(rawInput);
|
|
1917
|
+
assertNoForbiddenKeys(input);
|
|
1918
|
+
return handler.execute(input, context);
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1921
|
+
// src/shortcuts/asset/index.ts
|
|
1922
|
+
function asOptions(value) {
|
|
1923
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
1924
|
+
}
|
|
1925
|
+
async function readStdin() {
|
|
1926
|
+
const chunks = [];
|
|
1927
|
+
for await (const chunk of process.stdin) {
|
|
1928
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
1929
|
+
}
|
|
1930
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
1931
|
+
}
|
|
1932
|
+
async function inputFrom(options, extra = {}) {
|
|
1933
|
+
const opts = asOptions(options);
|
|
1934
|
+
let input = {};
|
|
1935
|
+
if (opts.input && opts.inputJson) {
|
|
1936
|
+
throw ziguanjiaValidationError("input_conflict", "\u4E0D\u80FD\u540C\u65F6\u4F20 --input \u548C --input-json");
|
|
1937
|
+
}
|
|
1938
|
+
if (opts.inputJson) {
|
|
1939
|
+
input = parseJsonInput(String(opts.inputJson), "--input-json");
|
|
1940
|
+
}
|
|
1941
|
+
if (opts.input) {
|
|
1942
|
+
let raw;
|
|
1943
|
+
try {
|
|
1944
|
+
raw = opts.input === "-" ? await readStdin() : await readFile2(String(opts.input), "utf8");
|
|
1945
|
+
} catch {
|
|
1946
|
+
throw ziguanjiaValidationError("input_unreadable", `\u65E0\u6CD5\u8BFB\u53D6 --input\uFF1A${String(opts.input)}`);
|
|
1947
|
+
}
|
|
1948
|
+
input = parseJsonInput(raw, "--input");
|
|
1949
|
+
}
|
|
1950
|
+
return {
|
|
1951
|
+
...input,
|
|
1952
|
+
...Object.fromEntries(Object.entries(extra).filter(([, value]) => value !== void 0 && value !== ""))
|
|
1953
|
+
};
|
|
1954
|
+
}
|
|
1955
|
+
function parseJsonInput(raw, label) {
|
|
1956
|
+
try {
|
|
1957
|
+
const parsed = JSON.parse(raw.replace(/^\uFEFF/u, ""));
|
|
1958
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
1959
|
+
throw new Error("input must be an object");
|
|
1960
|
+
}
|
|
1961
|
+
return parsed;
|
|
1962
|
+
} catch {
|
|
1963
|
+
throw ziguanjiaValidationError("input_invalid", `${label} \u4E0D\u662F\u5408\u6CD5 JSON \u5BF9\u8C61`);
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
function withJsonInputOptions(command) {
|
|
1967
|
+
command.option("--input <path>", "JSON input file, or - for stdin").option("--input-json <json>", "inline JSON input object");
|
|
1968
|
+
return command;
|
|
1969
|
+
}
|
|
1970
|
+
function successEnvelope(operation, result) {
|
|
1971
|
+
return {
|
|
1972
|
+
schemaVersion: 1,
|
|
1973
|
+
ok: true,
|
|
1974
|
+
operation,
|
|
1975
|
+
data: result.data,
|
|
1976
|
+
meta: { status: result.status },
|
|
1977
|
+
warnings: []
|
|
1978
|
+
};
|
|
1979
|
+
}
|
|
1980
|
+
function failureEnvelope(error) {
|
|
1981
|
+
const structured = error;
|
|
1982
|
+
return {
|
|
1983
|
+
schemaVersion: 1,
|
|
1984
|
+
ok: false,
|
|
1985
|
+
...structured?.partialData === void 0 ? {} : { data: structured.partialData },
|
|
1986
|
+
error: toErrorEnvelope(error)
|
|
1987
|
+
};
|
|
1988
|
+
}
|
|
1989
|
+
async function executeAndPrint(ctx, operation, input) {
|
|
1990
|
+
try {
|
|
1991
|
+
const result = await executeZiguanjiaOperation(operation, input, {
|
|
1992
|
+
host: createZiguanjiaHost(ctx),
|
|
1993
|
+
continuation: createZiguanjiaContinuationSigner(ctx)
|
|
1994
|
+
});
|
|
1995
|
+
ctx.output.write(successEnvelope(operation, result), { json: true });
|
|
1996
|
+
} catch (error) {
|
|
1997
|
+
console.error(JSON.stringify(failureEnvelope(error), null, 2));
|
|
1998
|
+
process.exitCode = isCliError(error) ? error.exitCode : 1 /* GeneralError */;
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
var assetShortcut = {
|
|
2002
|
+
name: "asset",
|
|
2003
|
+
description: "E10 \u8D44\u4EA7\u7BA1\u7406\uFF08\u8D44\u7BA1\u5BB6\uFF09CLI",
|
|
2004
|
+
category: "shortcut",
|
|
2005
|
+
register({ program, action }) {
|
|
2006
|
+
const asset = program.command("asset").description("E10 \u8D44\u4EA7\u7BA1\u7406\uFF08\u8D44\u7BA1\u5BB6\uFF09");
|
|
2007
|
+
asset.command("schema").description("Print asset operation manifest for agents").action(action((ctx) => {
|
|
2008
|
+
ctx.output.write(ziguanjiaManifest, { json: true });
|
|
2009
|
+
}));
|
|
2010
|
+
withJsonInputOptions(asset.command("run").description("Run an asset operation with JSON input").argument("<operation>", "operation name, e.g. asset.list")).action(action(async (ctx, operation, options) => {
|
|
2011
|
+
await executeAndPrint(ctx, String(operation), await inputFrom(options));
|
|
2012
|
+
}));
|
|
2013
|
+
withJsonInputOptions(asset.command("gate.check").description("\u68C0\u67E5\u7248\u672C\u95E8\u7981\uFF08zgjasset_search_appver \u662F\u5426\u5B58\u5728 ver_name \u2265 V14\uFF09")).action(action(async (ctx, options) => {
|
|
2014
|
+
await executeAndPrint(ctx, "asset.gate.check", await inputFrom(options));
|
|
2015
|
+
}));
|
|
2016
|
+
withJsonInputOptions(asset.command("list").description("\u67E5\u8BE2\u8D44\u4EA7\u5217\u8868").option("--asset-name <name>", "\u8D44\u4EA7\u540D\u79F0").option("--asset-number <number>", "\u8D44\u4EA7\u7F16\u53F7").option("--stateid <id>", "\u8D44\u4EA7\u72B6\u6001 ID").option("--asset-type-browse <id>", "\u8D44\u4EA7\u7C7B\u578B ID").option("--location-browse <id>", "\u5B58\u653E\u5730\u70B9 ID").option("--admin-istrator <id>", "\u7BA1\u7406\u4EBA ID").option("--resourceid <id>", "\u4F7F\u7528\u4EBA ID").option("--page-no <no>", "\u9875\u7801").option("--page-size <size>", "\u6BCF\u9875\u6761\u6570")).action(action(async (ctx, options) => {
|
|
2017
|
+
const opts = asOptions(options);
|
|
2018
|
+
await executeAndPrint(ctx, "asset.list", await inputFrom(options, {
|
|
2019
|
+
asset_name: opts.assetName,
|
|
2020
|
+
asset_number: opts.assetNumber,
|
|
2021
|
+
stateid: opts.stateid,
|
|
2022
|
+
asset_type_browse: opts.assetTypeBrowse,
|
|
2023
|
+
location_browse: opts.locationBrowse,
|
|
2024
|
+
admin_istrator: opts.adminIstrator,
|
|
2025
|
+
resourceid: opts.resourceid,
|
|
2026
|
+
page_no: opts.pageNo,
|
|
2027
|
+
page_size: opts.pageSize
|
|
2028
|
+
}));
|
|
2029
|
+
}));
|
|
2030
|
+
withJsonInputOptions(asset.command("detail").description("\u67E5\u8BE2\u8D44\u4EA7\u8BE6\u60C5").option("--id <id>", "\u8D44\u4EA7\u6570\u636E ID").option("--asset-number <number>", "\u8D44\u4EA7\u7F16\u53F7").option("--asset-name <name>", "\u8D44\u4EA7\u540D\u79F0")).action(action(async (ctx, options) => {
|
|
2031
|
+
const opts = asOptions(options);
|
|
2032
|
+
await executeAndPrint(ctx, "asset.detail", await inputFrom(options, {
|
|
2033
|
+
id: opts.id,
|
|
2034
|
+
asset_number: opts.assetNumber,
|
|
2035
|
+
asset_name: opts.assetName
|
|
2036
|
+
}));
|
|
2037
|
+
}));
|
|
2038
|
+
withJsonInputOptions(asset.command("uselist").description("\u67E5\u8BE2\u6211\u7684\u9886\u7528\u5217\u8868").option("--person-id <id>", "\u9886\u7528\u4EBA ID\uFF0C\u7F3A\u7701\u4E3A\u5F53\u524D\u767B\u5F55\u4EBA").option("--page-no <no>", "\u9875\u7801").option("--page-size <size>", "\u6BCF\u9875\u6761\u6570")).action(action(async (ctx, options) => {
|
|
2039
|
+
const opts = asOptions(options);
|
|
2040
|
+
await executeAndPrint(ctx, "asset.uselist", await inputFrom(options, {
|
|
2041
|
+
person_id: opts.personId,
|
|
2042
|
+
page_no: opts.pageNo,
|
|
2043
|
+
page_size: opts.pageSize
|
|
2044
|
+
}));
|
|
2045
|
+
}));
|
|
2046
|
+
withJsonInputOptions(asset.command("repaillist").description("\u67E5\u8BE2\u6211\u7684\u62A5\u4FEE\u5217\u8868").option("--person-id <id>", "\u62A5\u4FEE\u4EBA ID\uFF0C\u7F3A\u7701\u4E3A\u5F53\u524D\u767B\u5F55\u4EBA").option("--page-no <no>", "\u9875\u7801").option("--page-size <size>", "\u6BCF\u9875\u6761\u6570")).action(action(async (ctx, options) => {
|
|
2047
|
+
const opts = asOptions(options);
|
|
2048
|
+
await executeAndPrint(ctx, "asset.repaillist", await inputFrom(options, {
|
|
2049
|
+
person_id: opts.personId,
|
|
2050
|
+
page_no: opts.pageNo,
|
|
2051
|
+
page_size: opts.pageSize
|
|
2052
|
+
}));
|
|
2053
|
+
}));
|
|
2054
|
+
withJsonInputOptions(asset.command("purchaselist").description("\u67E5\u8BE2\u91C7\u8D2D\u7533\u8BF7\u5217\u8868").option("--person-id <id>", "\u7533\u8BF7\u4EBA ID\uFF0C\u7F3A\u7701\u4E3A\u5F53\u524D\u767B\u5F55\u4EBA").option("--purchaser <id>", "\u91C7\u8D2D\u5458 ID").option("--page-no <no>", "\u9875\u7801").option("--page-size <size>", "\u6BCF\u9875\u6761\u6570")).action(action(async (ctx, options) => {
|
|
2055
|
+
const opts = asOptions(options);
|
|
2056
|
+
await executeAndPrint(ctx, "asset.purchaselist", await inputFrom(options, {
|
|
2057
|
+
person_id: opts.personId,
|
|
2058
|
+
purchaser: opts.purchaser,
|
|
2059
|
+
page_no: opts.pageNo,
|
|
2060
|
+
page_size: opts.pageSize
|
|
2061
|
+
}));
|
|
2062
|
+
}));
|
|
2063
|
+
const resolve2 = asset.command("resolve").description("\u6309\u540D\u79F0\u89E3\u6790\u6D4F\u89C8\u5B57\u6BB5 ID");
|
|
2064
|
+
withJsonInputOptions(resolve2.command("location").description("\u89E3\u6790\u5B58\u653E\u5730\u70B9\u540D\u79F0\u5230 ID").option("--house-name <name>", "\u5730\u70B9\u540D\u79F0")).action(action(async (ctx, options) => {
|
|
2065
|
+
const opts = asOptions(options);
|
|
2066
|
+
await executeAndPrint(ctx, "asset.resolve.location", await inputFrom(options, { house_name: opts.houseName }));
|
|
2067
|
+
}));
|
|
2068
|
+
withJsonInputOptions(resolve2.command("status").description("\u89E3\u6790\u8D44\u4EA7\u72B6\u6001\u540D\u79F0\u5230 ID").option("--status-name <name>", "\u72B6\u6001\u540D\u79F0")).action(action(async (ctx, options) => {
|
|
2069
|
+
const opts = asOptions(options);
|
|
2070
|
+
await executeAndPrint(ctx, "asset.resolve.status", await inputFrom(options, { status_name: opts.statusName }));
|
|
2071
|
+
}));
|
|
2072
|
+
withJsonInputOptions(resolve2.command("type").description("\u89E3\u6790\u8D44\u4EA7\u7C7B\u578B\u540D\u79F0\u5230 ID").option("--type-name <name>", "\u7C7B\u578B\u540D\u79F0")).action(action(async (ctx, options) => {
|
|
2073
|
+
const opts = asOptions(options);
|
|
2074
|
+
await executeAndPrint(ctx, "asset.resolve.type", await inputFrom(options, { type_name: opts.typeName }));
|
|
2075
|
+
}));
|
|
2076
|
+
const registerWrite = (parent, command, operation, description) => {
|
|
2077
|
+
withJsonInputOptions(parent.command(command).description(description).option("--yes", "\u786E\u8BA4\u6267\u884C\u5199\u64CD\u4F5C\uFF08prepare \u9636\u6BB5\u540E\u4F7F\u7528\uFF09").option("--continuation <token>", "prepare \u9636\u6BB5\u8FD4\u56DE\u7684 continuation \u4EE4\u724C")).action(action(async (ctx, options) => {
|
|
2078
|
+
const opts = asOptions(options);
|
|
2079
|
+
await executeAndPrint(ctx, operation, await inputFrom(options, {
|
|
2080
|
+
confirm: opts.yes === true ? true : void 0,
|
|
2081
|
+
continuation: opts.continuation
|
|
2082
|
+
}));
|
|
2083
|
+
}));
|
|
2084
|
+
};
|
|
2085
|
+
registerWrite(asset, "create", "asset.create", "\u65B0\u589E\u8D44\u4EA7\uFF08\u9700 confirm + continuation\uFF09");
|
|
2086
|
+
registerWrite(asset, "update", "asset.update", "\u4FEE\u6539\u8D44\u4EA7\uFF08\u9700 confirm + continuation\uFF09");
|
|
2087
|
+
registerWrite(asset, "use", "asset.use", "\u63D0\u4EA4\u8D44\u4EA7\u9886\u7528\uFF08\u9700 confirm + continuation\uFF09");
|
|
2088
|
+
const ret = asset.command("return").description("\u8D44\u4EA7\u5F52\u8FD8");
|
|
2089
|
+
withJsonInputOptions(ret.command("query").description("\u67E5\u8BE2\u53EF\u5F52\u8FD8\u8D44\u4EA7\uFF08\u53EA\u8BFB\uFF0C\u5199\u524D\u9884\u89C8\uFF09").option("--return-type <type>", "0=\u5168\u90E8\u5F52\u8FD8\uFF0C1=\u90E8\u5206\u5F52\u8FD8")).action(action(async (ctx, options) => {
|
|
2090
|
+
const opts = asOptions(options);
|
|
2091
|
+
await executeAndPrint(ctx, "asset.return.query", await inputFrom(options, { return_type: opts.returnType }));
|
|
2092
|
+
}));
|
|
2093
|
+
registerWrite(ret, "create", "asset.return.create", "\u6267\u884C\u8D44\u4EA7\u5F52\u8FD8\uFF08\u9700 confirm + continuation\uFF09");
|
|
2094
|
+
const repair = asset.command("repair").description("\u8D44\u4EA7\u62A5\u4FEE");
|
|
2095
|
+
withJsonInputOptions(repair.command("query").description("\u67E5\u8BE2\u62A5\u4FEE\u5019\u9009\uFF08\u53EA\u8BFB\uFF0C\u5199\u524D\u9884\u89C8\uFF09")).action(action(async (ctx, options) => {
|
|
2096
|
+
await executeAndPrint(ctx, "asset.repair.query", await inputFrom(options));
|
|
2097
|
+
}));
|
|
2098
|
+
registerWrite(repair, "create", "asset.repair.create", "\u63D0\u4EA4\u8D44\u4EA7\u62A5\u4FEE\uFF08\u9700 confirm + continuation\uFF09");
|
|
2099
|
+
registerWrite(asset, "purch", "asset.purch", "\u63D0\u4EA4\u91C7\u8D2D\u7533\u8BF7\uFF08\u9700 confirm + continuation\uFF09");
|
|
2100
|
+
registerWrite(asset, "depre", "asset.depre", "\u6267\u884C\u6298\u65E7\u8BA1\u63D0\uFF08\u9700 confirm + continuation\uFF09");
|
|
2101
|
+
withJsonInputOptions(asset.command("viewlink").description("\u6784\u9020\u300C\u67E5\u770B\u8BE6\u60C5\u300D\u94FE\u63A5\uFF08scene + ids\uFF1Bdepre_task \u573A\u666F\u7528 calc_month\uFF09")).action(action(async (ctx, options) => {
|
|
2102
|
+
await executeAndPrint(ctx, "asset.viewlink", await inputFrom(options));
|
|
2103
|
+
}));
|
|
2104
|
+
}
|
|
2105
|
+
};
|
|
2106
|
+
export {
|
|
2107
|
+
assetShortcut,
|
|
2108
|
+
inputFrom
|
|
2109
|
+
};
|