weaver-work-cli 0.1.44 → 0.1.46
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/README.md +9 -5
- package/dist/chunks/{archive-P6TBQGKL.js → archive-ZQ4A4TV6.js} +388 -44
- package/dist/chunks/{archive-oa-7TQ2NXOH.js → archive-oa-BBDP7AKJ.js} +2 -2
- package/dist/chunks/{asset-3ELRG37G.js → asset-ZOJVBWZH.js} +2 -2
- package/dist/chunks/{asset-idle-WIGMUFMD.js → asset-idle-XGB5IPGT.js} +2 -2
- package/dist/chunks/{attachment-content-E3276UOV.js → attachment-content-MCXQBD6N.js} +3 -3
- package/dist/chunks/{blog-C5NMZAAC.js → blog-QSHLZSFW.js} +2 -2
- package/dist/chunks/caizhilian-KCQYFH72.js +204 -0
- package/dist/chunks/{calendar-FI2WNSBO.js → calendar-DLGMRJQA.js} +2 -2
- package/dist/chunks/{chunk-PUQS5MWL.js → chunk-3YV7PKRL.js} +1 -1
- package/dist/chunks/{chunk-FAZTGX7S.js → chunk-4RWS2YYL.js} +5 -5
- package/dist/chunks/{chunk-GM6J7Q4B.js → chunk-6AXKWFKG.js} +32 -12
- package/dist/chunks/{chunk-ETNJSKMM.js → chunk-6NXT4ICB.js} +148 -21
- package/dist/chunks/{chunk-QVSWRLLU.js → chunk-6V5ZPKHV.js} +56 -12
- package/dist/chunks/chunk-762M5XJS.js +215 -0
- package/dist/chunks/{chunk-PC7VKEB5.js → chunk-76H3IKH6.js} +178 -37
- package/dist/chunks/{chunk-FRZKBMSW.js → chunk-AD46OMQK.js} +239 -41
- package/dist/chunks/{chunk-WSF4NNMR.js → chunk-CZNZKOHR.js} +2 -2
- package/dist/chunks/{chunk-TA7FXXJD.js → chunk-DLY5GUXX.js} +1 -1
- package/dist/chunks/{chunk-BCVYBYYT.js → chunk-GR76ZDDX.js} +2 -2
- package/dist/chunks/{chunk-CWYGFU5B.js → chunk-GSZTA43P.js} +2 -2
- package/dist/chunks/{chunk-GRDRG6HP.js → chunk-HFXK54M4.js} +2 -2
- package/dist/chunks/{chunk-N4M2DDFE.js → chunk-IP4CWQCF.js} +11 -11
- package/dist/chunks/{chunk-GAMZLAG2.js → chunk-IRMIEDXN.js} +1 -1
- package/dist/chunks/{chunk-XNIK66I4.js → chunk-JB34OE7R.js} +790 -77
- package/dist/chunks/{chunk-HIT4Y6OI.js → chunk-JFAWZX53.js} +134 -13
- package/dist/chunks/{chunk-D4ADSZ7H.js → chunk-O6CMPO65.js} +24 -1
- package/dist/chunks/{chunk-Z7VYWPZV.js → chunk-OXHHJWNC.js} +1 -1
- package/dist/chunks/chunk-P5GQRWDC.js +60 -0
- package/dist/chunks/{caizhilian-5XSM2DFP.js → chunk-PGO4ILMQ.js} +41 -521
- package/dist/chunks/{chunk-OF4S23UB.js → chunk-PSOMGA3U.js} +4 -4
- package/dist/chunks/{chunk-F4E4EM35.js → chunk-TGAGQV4I.js} +2 -2
- package/dist/chunks/{chunk-UFIT2UU3.js → chunk-U6R6FZHD.js} +168 -14
- package/dist/chunks/{chunk-XHK4MDR5.js → chunk-UFIFZ4YC.js} +48 -14
- package/dist/chunks/chunk-VRPH24IC.js +76 -0
- package/dist/chunks/{chunk-3YBDYOC4.js → chunk-YIKSL36S.js} +2 -2
- package/dist/chunks/{chunk-IAZ3UPY6.js → chunk-Z6UUBY37.js} +2 -2
- package/dist/chunks/{conflict-ARLSZJ6V.js → conflict-H7EHQXYY.js} +2 -2
- package/dist/chunks/continuation-GW6PRWK3.js +12 -0
- package/dist/chunks/{contract-DNIIW5VJ.js → contract-3QLAGYQL.js} +5793 -4591
- package/dist/chunks/{cowork-GMLRGVIW.js → cowork-3ACICHDQ.js} +2 -2
- package/dist/chunks/{create-flow-J22BO65E.js → create-flow-VRVJEOBX.js} +6 -6
- package/dist/chunks/{ebuilder-form-ANV2FHYV.js → ebuilder-form-GWDTKEI2.js} +5 -5
- package/dist/chunks/{ehr-GSTGAIY3.js → ehr-SH2LM3NK.js} +648 -88
- package/dist/chunks/{employee-22BGJ3QS.js → employee-NOHNXC46.js} +1 -1
- package/dist/chunks/{env-BX3VRFS7.js → env-66FPSJDV.js} +2 -2
- package/dist/chunks/{esb-ATAIASX2.js → esb-4BQHNP5C.js} +4 -4
- package/dist/chunks/{factory-PETTFME6.js → factory-UH2TZBVA.js} +1 -1
- package/dist/chunks/{fna-YEKBSFSX.js → fna-ZVB2IILI.js} +2 -2
- package/dist/chunks/{group-chat-BFVXAYFX.js → group-chat-CAKMMV7K.js} +3 -3
- package/dist/chunks/{host-WIKN2EJ5.js → host-3TNBMDTR.js} +3 -3
- package/dist/chunks/host-7NTIBSPK.js +25 -0
- package/dist/chunks/{host-SZGV4UNT.js → host-7OWWPLM4.js} +3 -3
- package/dist/chunks/{host-HRBXEPDQ.js → host-G3VU7SDW.js} +3 -3
- package/dist/chunks/{host-LR55CTHP.js → host-M4XP5URR.js} +3 -3
- package/dist/chunks/{host-SUOY6VYQ.js → host-TUOIOEMC.js} +3 -3
- package/dist/chunks/{hrm-NRDO4W5G.js → hrm-UNKCCCGP.js} +5 -5
- package/dist/chunks/{im-IQ2HN23S.js → im-NJB7ZYMH.js} +3 -3
- package/dist/chunks/{invoice-MNRW76PP.js → invoice-OQP3TMKQ.js} +3 -3
- package/dist/chunks/{jiuchuanhui-DTRBAX4N.js → jiuchuanhui-ASFZBMPU.js} +2 -2
- package/dist/chunks/{lazy-dispatch-ZVWAI25B.js → lazy-dispatch-DD6ULZ3I.js} +4 -4
- package/dist/chunks/{mail-ZVAUXOJA.js → mail-M3HJF5ER.js} +2 -2
- package/dist/chunks/{meeting-FEVPZ67S.js → meeting-VTBFW4HI.js} +12 -12
- package/dist/chunks/{okr-SDH3E5RA.js → okr-EVX7FB5G.js} +2 -2
- package/dist/chunks/operations-J7PUIVWZ.js +15 -0
- package/dist/chunks/{plan-E35JFDI7.js → plan-2QJQEPBO.js} +2 -2
- package/dist/chunks/{project-73QXBAB2.js → project-XELELW2T.js} +2 -2
- package/dist/chunks/{reception-UWZVACBN.js → reception-5WITA44R.js} +2 -2
- package/dist/chunks/{recruit-stage-4MAOCKFY.js → recruit-stage-CAKZTUA7.js} +1343 -178
- package/dist/chunks/{registry-JDUS4E7D.js → registry-AQVGHUM6.js} +2 -2
- package/dist/chunks/{registry-IM5G23LS.js → registry-JVQBLFQ5.js} +10 -10
- package/dist/chunks/{registry-KNKSCJNT.js → registry-QJCZ2GVG.js} +4 -4
- package/dist/chunks/{registry-PO7SI256.js → registry-VWXWPVAG.js} +2 -2
- package/dist/chunks/{room-recommend-H7KLXA5R.js → room-recommend-5U55FMXZ.js} +6 -4
- package/dist/chunks/{schedule-ESZIBAUO.js → schedule-IDETODCA.js} +4 -4
- package/dist/chunks/{workflow-CWJFJLQU.js → workflow-BSYT5TGL.js} +6 -4
- package/dist/cmd/action.js +14 -10
- package/dist/index.js +30 -30
- package/dist/internal/e10/auth/commands.js +32 -0
- package/dist/internal/e10/auth/error-log.js +156 -26
- package/dist/internal/e10/auth/xiaoe.js +176 -13
- package/dist/internal/e10/context.js +12 -1
- package/dist/shortcuts/archive/operations/borrow-list.js +105 -14
- package/dist/shortcuts/archive/operations/flow-url.js +182 -22
- package/dist/shortcuts/archive/operations/getPageUrl.js +75 -0
- package/dist/shortcuts/archive/operations/prelib.js +33 -4
- package/dist/shortcuts/archive/operations/shared.js +52 -0
- package/dist/shortcuts/contract/host.js +111 -4
- package/dist/shortcuts/contract/index.js +19 -0
- package/dist/shortcuts/contract/manifest.js +125 -0
- package/dist/shortcuts/contract/ooxml/clause-insert.js +249 -0
- package/dist/shortcuts/contract/operations/clause-insert.js +56 -0
- package/dist/shortcuts/contract/operations/customer.js +192 -0
- package/dist/shortcuts/contract/operations/file-download.js +75 -0
- package/dist/shortcuts/contract/operations/flow.js +44 -2
- package/dist/shortcuts/contract/operations/form-info.js +162 -62
- package/dist/shortcuts/contract/operations/registry.js +8 -0
- package/dist/shortcuts/contract/operations/review.js +116 -1
- package/dist/shortcuts/contract/operations/summary.js +177 -0
- package/dist/shortcuts/contract/operations/upload.js +64 -4
- package/dist/shortcuts/contract/upload-cache.js +104 -0
- package/dist/shortcuts/ehr/host.js +2 -2
- package/dist/shortcuts/ehr/index.js +14 -3
- package/dist/shortcuts/ehr/manifest.js +5 -1
- package/dist/shortcuts/ehr/operations/recruit-candidate-import.js +44 -12
- package/dist/shortcuts/ehr/operations/recruit-interview-overview.js +258 -0
- package/dist/shortcuts/ehr/operations/recruit-position.js +146 -43
- package/dist/shortcuts/ehr/operations/recruit-stats.js +14 -1
- package/dist/shortcuts/ehr/operations/recruit-tag.js +173 -0
- package/dist/shortcuts/ehr/operations/recruit-write.js +154 -36
- package/dist/shortcuts/ehr/operations/recruit.js +196 -12
- package/dist/shortcuts/ehr/operations/registry.js +4 -0
- package/dist/shortcuts/ehr/operations.js +24 -0
- package/dist/shortcuts/ehr/recruit-stage/batch-store.js +78 -0
- package/dist/shortcuts/ehr/recruit-stage/context.js +231 -0
- package/dist/shortcuts/ehr/recruit-stage/continuation.js +74 -0
- package/dist/shortcuts/ehr/recruit-stage/errors.js +65 -0
- package/dist/shortcuts/ehr/recruit-stage/fs-scan.js +165 -0
- package/dist/shortcuts/ehr/recruit-stage/host.js +109 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/interview-arrange.js +1049 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/interview-feedback.js +295 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/jd-create.js +961 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/list.js +431 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/registry.js +50 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/resume-import.js +1647 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/search.js +158 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/types.js +34 -0
- package/dist/shortcuts/ehr/recruit-stage/runtime.js +31 -0
- package/dist/shortcuts/ehr/recruit-stage/school-tiers.json +318 -0
- package/dist/shortcuts/ehr/recruit-stage/shared.js +805 -0
- package/dist/shortcuts/hrm/operations/employee.js +29 -1
- package/dist/shortcuts/meeting/operations/eb/create-flow.js +274 -75
- package/dist/shortcuts/meeting/operations/eb/draft-memory.js +56 -0
- package/dist/shortcuts/meeting/operations/eb/factory.js +63 -11
- package/dist/shortcuts/meeting/operations/eb/person-cache.js +2 -2
- package/dist/shortcuts/meeting/operations/eb/room-recommend.js +38 -7
- package/dist/shortcuts/meeting/operations/invitation-publish.js +132 -0
- package/dist/shortcuts/meeting/operations/invitation.js +27 -4
- package/dist/shortcuts/meeting/operations/registry.js +2 -0
- package/dist/shortcuts/recruit-stage/batch-store.js +78 -0
- package/dist/shortcuts/recruit-stage/fs-scan.js +165 -0
- package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +356 -29
- package/dist/shortcuts/recruit-stage/operations/interview-feedback.js +36 -10
- package/dist/shortcuts/recruit-stage/operations/jd-create.js +309 -67
- package/dist/shortcuts/recruit-stage/operations/registry.js +12 -0
- package/dist/shortcuts/recruit-stage/operations/resume-import.js +310 -17
- package/dist/shortcuts/recruit-stage/operations/types.js +9 -0
- package/dist/shortcuts/recruit-stage/shared.js +221 -24
- package/dist/shortcuts/workflow/index.js +2 -0
- package/dist/shortcuts/workflow/operations/read.js +8 -3
- package/dist/shortcuts/workflow/operations/todoSmartConvert/aigroupRules.js +92 -5
- package/dist/shortcuts/workflow/operations/todoSmartConvert/priorityExpr.js +509 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoListRows.js +22 -1
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +32 -6
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +57 -11
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.group.js +165 -52
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +57 -14
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.smartGroup.js +44 -18
- package/docs/contract.md +1 -0
- package/docs/e10-auth.md +4 -2
- package/docs/todo-smart-convert/data-contract.md +7 -0
- package/package.json +1 -1
- package/skill-template/domains/jinchengda.md +2 -0
- package/skills/weaver-e10-jinchengda/SKILL.md +198 -205
- package/skills/weaver-e10-jinchengda/references/contract-action-card.md +759 -0
- package/skills/weaver-e10-jinchengda/references/contract-action-engine.md +250 -0
- package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +146 -7
- package/skills/weaver-e10-jinchengda/references/contract-clause-insert.md +178 -0
- package/skills/weaver-e10-jinchengda/references/contract-command-index.md +75 -0
- package/skills/weaver-e10-jinchengda/references/contract-compare-report-template.html +137 -0
- package/skills/weaver-e10-jinchengda/references/contract-compare-report.md +163 -0
- package/skills/weaver-e10-jinchengda/references/contract-credit-page.md +52 -3
- package/skills/weaver-e10-jinchengda/references/contract-doc-compare.md +92 -5
- package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +602 -0
- package/skills/weaver-e10-jinchengda/references/contract-element-extract.md +209 -0
- package/skills/weaver-e10-jinchengda/references/contract-execution-rules.md +126 -0
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +312 -0
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +555 -0
- package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +47 -12
- package/skills/weaver-e10-jinchengda/references/contract-object-detect.md +469 -0
- package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +154 -1
- package/skills/weaver-e10-jinchengda/references/contract-type-fingerprints.md +224 -0
- package/skills/weaver-e10-jinchengda/references/orchestration.md +355 -0
- package/skills/weaver-e10-jucailin/SKILL.md +12 -3
- package/skills/weaver-e10-jucailin/archive/LEGACY-README.md +18 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-SKILL.md +239 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-openai.yaml +131 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-position-templates.md +221 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-arrange-interview.md +334 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-capability-check.md +127 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-check-install.md +65 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-detail-process.md +63 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-edit-interview-feedback.md +142 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-jd-create.md +114 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-jd-template.md +56 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-list-candidate.md +101 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-list-interview.md +148 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-match-candidates.md +77 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-output-links.md +72 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resolve-creator.md +69 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resolve-metadata.md +241 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resume-import.md +457 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resume-parse.md +128 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-search-candidate.md +146 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-urge-feedback.md +69 -0
- package/skills/weaver-e10-jucailin/lib/recruit-xiaoe-file.mjs +192 -0
- package/skills/weaver-e10-jucailin/lib/xiaoe-session.mjs +66 -0
- package/skills/weaver-e10-jucailin/references/recruit-create.md +19 -91
- package/skills/weaver-e10-jucailin/references/recruit-interview-overview.md +64 -0
- package/skills/weaver-e10-jucailin/references/recruit-read.md +63 -1
- package/skills/weaver-e10-jucailin/references/recruit-screening-to-interview-sop.md +95 -0
- package/skills/weaver-e10-jucailin/references/recruit-stage-ops.md +89 -0
- package/skills/weaver-e10-jucailin/references/recruit-tag.md +81 -0
- package/skills/weaver-e10-jucailin/references/recruit-write.md +55 -11
- package/skills/weaver-e10-meeting/SKILL.md +103 -11
- package/skills/weaver-e10-meeting/references/meeting-eb.md +1 -1
- package/skills/weaver-e10-recruit-stage/SKILL.md +19 -11
- package/skills/weaver-e10-recruit-stage/agents/openai.yaml +26 -8
- package/skills/weaver-e10-recruit-stage/lib/recruit-xiaoe-file.mjs +5 -1
- package/skills/weaver-e10-recruit-stage/references/position-templates.md +23 -2
- package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +13 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +40 -18
- package/skills/weaver-e10-recruit-stage/references/recruit-output-links.md +27 -14
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +11 -1
- package/skills/weaver-e10-shared/references/e10-auth-and-session.md +4 -2
- package/skills/weaver-e10-wenshuding/SKILL.md +17 -7
- package/skills/weaver-e10-wenshuding/references/archive-borrow-list.md +28 -0
- package/skills/weaver-e10-wenshuding/references/archive-flow.md +24 -8
- package/skills/weaver-e10-wenshuding/references/archive-prelib-list.md +3 -0
- package/skills/weaver-e10-wenshuding/references/archive-prelib-open.md +4 -0
- package/skills/weaver-e10-wenshuding/references/archive-search.md +3 -1
- package/skills/weaver-e10-workflow/SKILL.md +19 -17
- package/skills/weaver-e10-workflow/aigroup/default.json +10 -6
- package/skills/weaver-e10-workflow/references/todo-smart-convert.md +36 -3
- package/skills/weaver-e10-workflow/references/workflow-memory.md +1 -1
- package/skills/weaver-e10-workflow/references/workflow-query.md +9 -6
- package/skills/weaver-e10-workflow/tools/todo-summary.cjs +152 -1
- package/skills/weaver-e10-yimiaoban/SKILL.md +17 -5
- package/skills/weaver-e10-yimiaoban/references/msg-write.md +30 -0
- package/skills/weaver-e10-yimiaoban/references/session-sysmsg.md +72 -0
- package/skills/weaver-e10-yimiaoban/references/source-manifest.json +7 -7
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
startFetchTiming,
|
|
18
18
|
summarizeXiaoEFailureKind,
|
|
19
19
|
tryXiaoEUnifiedLogin
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-U6R6FZHD.js";
|
|
21
21
|
import {
|
|
22
22
|
CliError,
|
|
23
23
|
toErrorEnvelope
|
|
@@ -25,14 +25,101 @@ import {
|
|
|
25
25
|
|
|
26
26
|
// src/internal/e10/auth/error-log.ts
|
|
27
27
|
import { randomUUID } from "node:crypto";
|
|
28
|
-
import { appendFile, chmod, mkdir, readFile, unlink } from "node:fs/promises";
|
|
28
|
+
import { appendFile, chmod, mkdir, readFile, rmdir, stat, unlink, writeFile } from "node:fs/promises";
|
|
29
29
|
import { dirname, resolve } from "node:path";
|
|
30
30
|
var XIAOE_AUTH_ERROR_LOG_NAME = "xiaoe-auth-errors.ndjson";
|
|
31
31
|
var DEFAULT_LOG_LIMIT = 50;
|
|
32
|
+
var XIAOE_AUTH_ERROR_LOG_LOCK_SUFFIX = ".lock";
|
|
33
|
+
var XIAOE_AUTH_ERROR_LOG_LOCK_RETRY_MS = 25;
|
|
34
|
+
var XIAOE_AUTH_ERROR_LOG_LOCK_TIMEOUT_MS = 5e3;
|
|
35
|
+
var XIAOE_AUTH_ERROR_LOG_STALE_LOCK_MS = 3e4;
|
|
32
36
|
var MAX_XIAOE_AUTH_ERROR_LOG_LIMIT = 500;
|
|
37
|
+
var XIAOE_AUTH_ERROR_LOG_RETENTION_DAYS = 15;
|
|
38
|
+
var XIAOE_AUTH_ERROR_LOG_RETENTION_MS = XIAOE_AUTH_ERROR_LOG_RETENTION_DAYS * 24 * 60 * 60 * 1e3;
|
|
33
39
|
function getXiaoEAuthErrorLogPath() {
|
|
34
40
|
return resolve(getE10AuthRoot(), "logs", XIAOE_AUTH_ERROR_LOG_NAME);
|
|
35
41
|
}
|
|
42
|
+
function waitForXiaoEAuthLogLock() {
|
|
43
|
+
return new Promise((resolveWait) => setTimeout(resolveWait, XIAOE_AUTH_ERROR_LOG_LOCK_RETRY_MS));
|
|
44
|
+
}
|
|
45
|
+
async function acquireXiaoEAuthLogLock(path) {
|
|
46
|
+
const lockPath = `${path}${XIAOE_AUTH_ERROR_LOG_LOCK_SUFFIX}`;
|
|
47
|
+
const startedAt = Date.now();
|
|
48
|
+
for (; ; ) {
|
|
49
|
+
try {
|
|
50
|
+
await mkdir(lockPath, { mode: 448 });
|
|
51
|
+
return async () => {
|
|
52
|
+
await rmdir(lockPath).catch((error) => {
|
|
53
|
+
if (error?.code !== "ENOENT") throw error;
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
} catch (error) {
|
|
57
|
+
if (error?.code !== "EEXIST") throw error;
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
const lockStat = await stat(lockPath);
|
|
61
|
+
if (Date.now() - lockStat.mtimeMs > XIAOE_AUTH_ERROR_LOG_STALE_LOCK_MS) {
|
|
62
|
+
await rmdir(lockPath);
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
} catch (error) {
|
|
66
|
+
if (error?.code === "ENOENT") continue;
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
if (Date.now() - startedAt >= XIAOE_AUTH_ERROR_LOG_LOCK_TIMEOUT_MS) {
|
|
70
|
+
throw new Error(`Timed out waiting for XiaoE auth error log lock: ${lockPath}`);
|
|
71
|
+
}
|
|
72
|
+
await waitForXiaoEAuthLogLock();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
async function withXiaoEAuthLogLock(path, action) {
|
|
76
|
+
await mkdir(dirname(path), { recursive: true, mode: 448 });
|
|
77
|
+
await chmod(dirname(path), 448).catch(() => void 0);
|
|
78
|
+
const release = await acquireXiaoEAuthLogLock(path);
|
|
79
|
+
try {
|
|
80
|
+
return await action();
|
|
81
|
+
} finally {
|
|
82
|
+
await release();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async function readXiaoEAuthErrorLogContent(path) {
|
|
86
|
+
try {
|
|
87
|
+
return await readFile(path, "utf8");
|
|
88
|
+
} catch (error) {
|
|
89
|
+
if (error?.code === "ENOENT") return "";
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function pruneExpiredXiaoEAuthErrorLogContent(content, now = Date.now()) {
|
|
94
|
+
const cutoff = now - XIAOE_AUTH_ERROR_LOG_RETENTION_MS;
|
|
95
|
+
const keptLines = [];
|
|
96
|
+
let expiredRemoved = 0;
|
|
97
|
+
for (const line of content.split(/\r?\n/u)) {
|
|
98
|
+
if (!line.trim()) continue;
|
|
99
|
+
try {
|
|
100
|
+
const value = JSON.parse(line);
|
|
101
|
+
if (isLogEntry(value)) {
|
|
102
|
+
const timestamp = Date.parse(value.timestamp);
|
|
103
|
+
if (Number.isFinite(timestamp) && timestamp < cutoff) {
|
|
104
|
+
expiredRemoved += 1;
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
} catch {
|
|
109
|
+
}
|
|
110
|
+
keptLines.push(line);
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
content: keptLines.length ? `${keptLines.join("\n")}
|
|
114
|
+
` : "",
|
|
115
|
+
expiredRemoved
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
async function persistPrunedXiaoEAuthErrorLog(path, content, expiredRemoved) {
|
|
119
|
+
if (!expiredRemoved) return;
|
|
120
|
+
await writeFile(path, content, { encoding: "utf8", mode: 384 });
|
|
121
|
+
await chmod(path, 384).catch(() => void 0);
|
|
122
|
+
}
|
|
36
123
|
function xiaoEAuthLogSecrets(env) {
|
|
37
124
|
return Object.entries(env).filter(([key, value]) => Boolean(
|
|
38
125
|
value && (key.startsWith("XIAOE_") || key.startsWith("WEAVER_XIAOE_")) && /(?:TOKEN|AUTH|ETEAMSID|COOKIE|SESSION|SECRET|PASSWORD)/iu.test(key)
|
|
@@ -70,7 +157,31 @@ function sanitizeFailure(failure, secrets) {
|
|
|
70
157
|
kind: failure.kind,
|
|
71
158
|
message: redactSensitiveText(failure.message, secrets),
|
|
72
159
|
...failure.causeCode ? { causeCode: redactSensitiveText(failure.causeCode, secrets) } : {},
|
|
73
|
-
...failure.httpStatus === void 0 ? {} : { httpStatus: failure.httpStatus }
|
|
160
|
+
...failure.httpStatus === void 0 ? {} : { httpStatus: failure.httpStatus },
|
|
161
|
+
...failure.request ? { request: sanitizeExchangeRequest(failure.request, secrets) } : {}
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function sanitizeExchangeRequest(request, secrets) {
|
|
165
|
+
const endpoint = sanitizeBaseUrl(request.endpoint, secrets) || redactSensitiveText(request.endpoint, secrets);
|
|
166
|
+
const finalEndpoint = request.finalEndpoint ? sanitizeBaseUrl(request.finalEndpoint, secrets) || redactSensitiveText(request.finalEndpoint, secrets) : void 0;
|
|
167
|
+
const domain = sanitizeBaseUrl(request.body.domain, secrets) || redactSensitiveText(request.body.domain, secrets);
|
|
168
|
+
return {
|
|
169
|
+
transport: request.transport,
|
|
170
|
+
method: "POST",
|
|
171
|
+
endpoint,
|
|
172
|
+
...finalEndpoint && finalEndpoint !== endpoint ? { finalEndpoint } : {},
|
|
173
|
+
redirect: request.redirect,
|
|
174
|
+
headers: {
|
|
175
|
+
"content-type": "application/json",
|
|
176
|
+
authorization: "<redacted>"
|
|
177
|
+
},
|
|
178
|
+
authorizationPresent: request.authorizationPresent,
|
|
179
|
+
authorizationLength: request.authorizationLength,
|
|
180
|
+
body: { domain },
|
|
181
|
+
bodyBytes: request.bodyBytes,
|
|
182
|
+
timeoutMs: request.timeoutMs,
|
|
183
|
+
elapsedMs: request.elapsedMs,
|
|
184
|
+
...request.redirectCount ? { redirectCount: request.redirectCount } : {}
|
|
74
185
|
};
|
|
75
186
|
}
|
|
76
187
|
function sanitizeError(error, secrets) {
|
|
@@ -109,12 +220,15 @@ function createEntry(input) {
|
|
|
109
220
|
}
|
|
110
221
|
async function appendXiaoEAuthErrorLog(input) {
|
|
111
222
|
const path = getXiaoEAuthErrorLogPath();
|
|
112
|
-
await mkdir(dirname(path), { recursive: true, mode: 448 });
|
|
113
|
-
await chmod(dirname(path), 448).catch(() => void 0);
|
|
114
223
|
const entry = createEntry(input);
|
|
115
|
-
await
|
|
224
|
+
await withXiaoEAuthLogLock(path, async () => {
|
|
225
|
+
const current = await readXiaoEAuthErrorLogContent(path);
|
|
226
|
+
const pruned = pruneExpiredXiaoEAuthErrorLogContent(current);
|
|
227
|
+
await persistPrunedXiaoEAuthErrorLog(path, pruned.content, pruned.expiredRemoved);
|
|
228
|
+
await appendFile(path, `${JSON.stringify(entry)}
|
|
116
229
|
`, { encoding: "utf8", mode: 384 });
|
|
117
|
-
|
|
230
|
+
await chmod(path, 384).catch(() => void 0);
|
|
231
|
+
});
|
|
118
232
|
return entry;
|
|
119
233
|
}
|
|
120
234
|
function isLogEntry(value) {
|
|
@@ -133,12 +247,12 @@ function normalizeXiaoEAuthErrorLogLimit(value) {
|
|
|
133
247
|
async function readXiaoEAuthErrorLog(limit = DEFAULT_LOG_LIMIT) {
|
|
134
248
|
const normalizedLimit = normalizeXiaoEAuthErrorLogLimit(limit);
|
|
135
249
|
const path = getXiaoEAuthErrorLogPath();
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
250
|
+
const { content, expiredRemoved } = await withXiaoEAuthLogLock(path, async () => {
|
|
251
|
+
const current = await readXiaoEAuthErrorLogContent(path);
|
|
252
|
+
const pruned = pruneExpiredXiaoEAuthErrorLogContent(current);
|
|
253
|
+
await persistPrunedXiaoEAuthErrorLog(path, pruned.content, pruned.expiredRemoved);
|
|
254
|
+
return pruned;
|
|
255
|
+
});
|
|
142
256
|
let invalidLines = 0;
|
|
143
257
|
const entries = [];
|
|
144
258
|
for (const line of content.split(/\r?\n/u)) {
|
|
@@ -157,18 +271,21 @@ async function readXiaoEAuthErrorLog(limit = DEFAULT_LOG_LIMIT) {
|
|
|
157
271
|
total: entries.length,
|
|
158
272
|
returned: recent.length,
|
|
159
273
|
invalidLines,
|
|
274
|
+
expiredRemoved,
|
|
160
275
|
entries: recent
|
|
161
276
|
};
|
|
162
277
|
}
|
|
163
278
|
async function clearXiaoEAuthErrorLog() {
|
|
164
279
|
const path = getXiaoEAuthErrorLogPath();
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
280
|
+
return withXiaoEAuthLogLock(path, async () => {
|
|
281
|
+
try {
|
|
282
|
+
await unlink(path);
|
|
283
|
+
return { path, cleared: true };
|
|
284
|
+
} catch (error) {
|
|
285
|
+
if (error?.code === "ENOENT") return { path, cleared: false };
|
|
286
|
+
throw error;
|
|
287
|
+
}
|
|
288
|
+
});
|
|
172
289
|
}
|
|
173
290
|
|
|
174
291
|
// src/internal/e10/auth-recovery.ts
|
|
@@ -408,9 +525,19 @@ function sameE10SessionIdentity(current, recovered) {
|
|
|
408
525
|
}
|
|
409
526
|
|
|
410
527
|
// src/internal/e10/context.ts
|
|
528
|
+
function xiaoEFailureForErrorDetails(failure) {
|
|
529
|
+
return {
|
|
530
|
+
stage: failure.stage,
|
|
531
|
+
kind: failure.kind,
|
|
532
|
+
message: failure.message,
|
|
533
|
+
...failure.causeCode ? { causeCode: failure.causeCode } : {},
|
|
534
|
+
...failure.httpStatus === void 0 ? {} : { httpStatus: failure.httpStatus }
|
|
535
|
+
};
|
|
536
|
+
}
|
|
411
537
|
function xiaoERecoveryFailedError(diagnostics, resultSessionExpired = false) {
|
|
412
538
|
const failureKind = summarizeXiaoEFailureKind(diagnostics);
|
|
413
539
|
const lastFailure = lastXiaoEFailure(diagnostics);
|
|
540
|
+
const publicFailures = diagnostics?.failures?.map(xiaoEFailureForErrorDetails);
|
|
414
541
|
const networkUnavailable = failureKind === "network";
|
|
415
542
|
const hostCredentialMissing = diagnostics?.clientType === "cloud" && diagnostics.platformCredentialDetected === false && diagnostics.attemptedSteps.includes("platform_token:missing") && diagnostics.attemptedSteps.includes("environment_map:empty");
|
|
416
543
|
const details = diagnostics ? {
|
|
@@ -421,7 +548,7 @@ function xiaoERecoveryFailedError(diagnostics, resultSessionExpired = false) {
|
|
|
421
548
|
...diagnostics.lastError ? { lastError: diagnostics.lastError } : {},
|
|
422
549
|
...failureKind ? { errorKind: failureKind } : {},
|
|
423
550
|
...lastFailure ? { failureStage: lastFailure.stage } : {},
|
|
424
|
-
...
|
|
551
|
+
...publicFailures?.length ? { failures: publicFailures } : {},
|
|
425
552
|
...hostCredentialMissing ? { reason: "host_credential_not_injected" } : {},
|
|
426
553
|
...resultSessionExpired ? { resultSessionExpired: true } : {}
|
|
427
554
|
} : void 0;
|
|
@@ -1562,7 +1562,7 @@ async function buildPersonnelText(env, data) {
|
|
|
1562
1562
|
if (ids.length === 0) return {};
|
|
1563
1563
|
const names = /* @__PURE__ */ new Map();
|
|
1564
1564
|
try {
|
|
1565
|
-
const { hrmEmployeeOperations } = await import("./employee-
|
|
1565
|
+
const { hrmEmployeeOperations } = await import("./employee-NOHNXC46.js");
|
|
1566
1566
|
const batch = hrmEmployeeOperations.find((operation) => operation.name === "hrm.employee.batch");
|
|
1567
1567
|
if (batch) {
|
|
1568
1568
|
const result = await batch.handler({ ids: [...new Set(ids)] }, env);
|
|
@@ -1709,16 +1709,14 @@ function buildReadInputSchema(endpoint) {
|
|
|
1709
1709
|
};
|
|
1710
1710
|
}
|
|
1711
1711
|
properties.pageNo = { type: "integer", minimum: 1, description: "\u9875\u7801\uFF0C\u9ED8\u8BA4 1" };
|
|
1712
|
-
properties.pageSize = { type: "integer", minimum: 1, maximum: 200, description: "\u6BCF\u9875\u6761\u6570\uFF0C\u9ED8\u8BA4 20" };
|
|
1712
|
+
properties.pageSize = { type: "integer", minimum: 1, maximum: 200, description: "\u6BCF\u9875\u6761\u6570\uFF0C\u9ED8\u8BA4 50\uFF08\u6CE8\u610F\uFF1A\u672C\u73AF\u5883\u670D\u52A1\u7AEF\u5355\u9875\u5B9E\u9645\u53EA\u56DE 10~20 \u6761\uFF0C\u4F20\u66F4\u5927\u4E5F\u65E0\u6548\uFF1B\u8981\u5168\u91CF\u8BF7\u4F20 all:true\uFF09" };
|
|
1713
|
+
properties.all = {
|
|
1714
|
+
type: "boolean",
|
|
1715
|
+
description: 'true = \u81EA\u52A8\u7FFB\u9875\u62C9\u5168\u91CF\uFF08\u6700\u591A 50 \u9875\uFF09\u3002\u67E5\u53F0\u8D26/\u5217\u6E05\u5355\u65F6**\u5EFA\u8BAE\u76F4\u63A5\u4F20 true**\uFF0C\u5426\u5219\u53EA\u56DE\u7B2C 1 \u9875\uFF08\u672C\u73AF\u5883\u5B9E\u6D4B 10 \u6761\uFF09\uFF0C\u5BB9\u6613\u8BEF\u5224"\u63A5\u53E3\u8BFB\u4E0D\u5168"'
|
|
1716
|
+
};
|
|
1713
1717
|
if (endpoint.countPk) {
|
|
1714
1718
|
properties.withCount = { type: "boolean", description: "\u662F\u5426\u5148\u67E5\u603B\u6570\uFF08\u9ED8\u8BA4 true\uFF0C\u6761\u4EF6\u4E0E\u5217\u8868\u4E00\u81F4\uFF09" };
|
|
1715
1719
|
}
|
|
1716
|
-
if ((endpoint.mainTableParams ?? []).length > 0) {
|
|
1717
|
-
properties.noFallback = {
|
|
1718
|
-
type: "boolean",
|
|
1719
|
-
description: "\u8DF3\u8FC7\u300C\u6A21\u7CCA\u515C\u5E95\u300D\uFF1A\u670D\u52A1\u7AEF\u7CBE\u786E\u5339\u914D\u4E0D\u5230\u65F6\uFF0C\u4E0D\u518D\u7FFB\u9875\u626B\u5168\u91CF\uFF08\u9ED8\u8BA4 false=\u4F1A\u626B\uFF0C\u4FDD\u8BC1\u90E8\u5206\u8BCD\u4E5F\u80FD\u67E5\u5230\uFF09"
|
|
1720
|
-
};
|
|
1721
|
-
}
|
|
1722
1720
|
}
|
|
1723
1721
|
return {
|
|
1724
1722
|
type: "object",
|
|
@@ -1813,8 +1811,54 @@ function buildReadOperation(endpoint) {
|
|
|
1813
1811
|
return meetingSuccess(endpoint.operation, { data, count: rows2.length }, endpoint.notes ? { meta: { notes: endpoint.notes } } : {});
|
|
1814
1812
|
}
|
|
1815
1813
|
const pageNo = typeof args.pageNo === "number" ? args.pageNo : 1;
|
|
1816
|
-
const pageSize = typeof args.pageSize === "number" ? args.pageSize :
|
|
1814
|
+
const pageSize = typeof args.pageSize === "number" ? args.pageSize : 50;
|
|
1817
1815
|
const mainTableFilters = pickMainTableFilters(args, endpoint.mainTableParams);
|
|
1816
|
+
if (args.all === true) {
|
|
1817
|
+
const collected = [];
|
|
1818
|
+
let pages = 0;
|
|
1819
|
+
let totalKnown = 0;
|
|
1820
|
+
for (let p = 1; p <= 50; p += 1) {
|
|
1821
|
+
const pageResponse = await env.host.request({
|
|
1822
|
+
method: "POST",
|
|
1823
|
+
path,
|
|
1824
|
+
operation: endpoint.operation,
|
|
1825
|
+
query: { ...query, pageNo: p, pageSize },
|
|
1826
|
+
body: queryBody(session.userId, { pageNo: p, pageSize }, mainTableFilters),
|
|
1827
|
+
acceptBusiness
|
|
1828
|
+
});
|
|
1829
|
+
const { rows: pageRows, total: pageTotal } = extractEbRows(pageResponse);
|
|
1830
|
+
pages = p;
|
|
1831
|
+
totalKnown = Number(pageTotal ?? totalKnown) || totalKnown;
|
|
1832
|
+
if (pageRows.length === 0) break;
|
|
1833
|
+
collected.push(...pageRows);
|
|
1834
|
+
if (totalKnown > 0 && collected.length >= totalKnown) break;
|
|
1835
|
+
if (pageRows.length < 10) break;
|
|
1836
|
+
}
|
|
1837
|
+
const allRows = Object.keys(mainTableFilters).length === 0 ? collected : collected.filter((row) => {
|
|
1838
|
+
const main = row?.mainTable ?? row ?? {};
|
|
1839
|
+
return Object.entries(mainTableFilters).every(([key, value]) => {
|
|
1840
|
+
const cell = main[key];
|
|
1841
|
+
return cell !== void 0 && cell !== null && String(cell).includes(String(value));
|
|
1842
|
+
});
|
|
1843
|
+
});
|
|
1844
|
+
return meetingSuccess(
|
|
1845
|
+
endpoint.operation,
|
|
1846
|
+
{
|
|
1847
|
+
total: allRows.length,
|
|
1848
|
+
pageNo: 1,
|
|
1849
|
+
pageSize: allRows.length,
|
|
1850
|
+
count: allRows.length,
|
|
1851
|
+
pagesFetched: pages,
|
|
1852
|
+
all: true,
|
|
1853
|
+
rows: allRows,
|
|
1854
|
+
filters: { ...query, ...mainTableFilters }
|
|
1855
|
+
},
|
|
1856
|
+
{
|
|
1857
|
+
...endpoint.notes ? { meta: { notes: endpoint.notes } } : {},
|
|
1858
|
+
...allRows.length === 0 && endpoint.emptyHint ? { warnings: [endpoint.emptyHint] } : {}
|
|
1859
|
+
}
|
|
1860
|
+
);
|
|
1861
|
+
}
|
|
1818
1862
|
let total;
|
|
1819
1863
|
if (endpoint.countPk && args.withCount !== false) {
|
|
1820
1864
|
const countResponse = await env.host.request({
|
|
@@ -1848,7 +1892,7 @@ function buildReadOperation(endpoint) {
|
|
|
1848
1892
|
};
|
|
1849
1893
|
let rows = filterKeys.length === 0 ? rawRows : rawRows.filter(matchesFilters);
|
|
1850
1894
|
let fallback;
|
|
1851
|
-
if (filterKeys.length > 0 && rows.length === 0
|
|
1895
|
+
if (filterKeys.length > 0 && rows.length === 0) {
|
|
1852
1896
|
const maxPages = readFallbackMaxPages();
|
|
1853
1897
|
const collected = [];
|
|
1854
1898
|
let pages = 0;
|
|
@@ -2176,7 +2220,7 @@ function buildWriteInputSchema(endpoint, includeConfirm) {
|
|
|
2176
2220
|
}
|
|
2177
2221
|
async function lookupEmployeeDepartmentId(env, userId) {
|
|
2178
2222
|
try {
|
|
2179
|
-
const { hrmEmployeeOperations } = await import("./employee-
|
|
2223
|
+
const { hrmEmployeeOperations } = await import("./employee-NOHNXC46.js");
|
|
2180
2224
|
const batch = hrmEmployeeOperations.find((operation) => operation.name === "hrm.employee.batch");
|
|
2181
2225
|
if (!batch) return null;
|
|
2182
2226
|
const result = await batch.handler({ ids: [userId] }, env);
|
|
@@ -2285,7 +2329,7 @@ function buildWriteOperations(endpoint, preflight, afterWrite) {
|
|
|
2285
2329
|
);
|
|
2286
2330
|
}
|
|
2287
2331
|
if (endpoint.interfacePk === "create_meeting") {
|
|
2288
|
-
const { fetchEbAppSettings, assertEbCreatePathAllowed } = await import("./conflict-
|
|
2332
|
+
const { fetchEbAppSettings, assertEbCreatePathAllowed } = await import("./conflict-H7EHQXYY.js");
|
|
2289
2333
|
assertEbCreatePathAllowed(await fetchEbAppSettings(env, applyName));
|
|
2290
2334
|
}
|
|
2291
2335
|
const pkQuery = writePkQuery(endpoint, payload);
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { createRequire as __esbuildCreateRequire } from 'node:module';
|
|
2
|
+
const require = __esbuildCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
CaizhilianCliError,
|
|
5
|
+
caizhilianAuthError,
|
|
6
|
+
caizhilianNetworkError,
|
|
7
|
+
caizhilianValidationError
|
|
8
|
+
} from "./chunk-P5GQRWDC.js";
|
|
9
|
+
import {
|
|
10
|
+
E10ApiError,
|
|
11
|
+
createE10RequestRuntime,
|
|
12
|
+
isE10SessionExpiredResponse,
|
|
13
|
+
requireE10Session
|
|
14
|
+
} from "./chunk-6NXT4ICB.js";
|
|
15
|
+
import {
|
|
16
|
+
E10_SESSION_EXPIRED_MESSAGE,
|
|
17
|
+
getActiveProfile
|
|
18
|
+
} from "./chunk-U6R6FZHD.js";
|
|
19
|
+
|
|
20
|
+
// src/shortcuts/caizhilian/host.ts
|
|
21
|
+
var CAIZHILAN_TIMEOUT_MS = 12e3;
|
|
22
|
+
var CAIZHILAN_TRANSFER_TIMEOUT_MS = 12e4;
|
|
23
|
+
var CAIZHILAN_MAX_DOWNLOAD_BYTES = 100 * 1024 * 1024;
|
|
24
|
+
function inferProfile(ctx) {
|
|
25
|
+
const options = ctx.getGlobalOptions();
|
|
26
|
+
return options.profile || getActiveProfile();
|
|
27
|
+
}
|
|
28
|
+
function isCaizhilianBusinessSuccess(value) {
|
|
29
|
+
if (!value || typeof value !== "object") return false;
|
|
30
|
+
if (value.code !== void 0 && value.code !== null) return Number(value.code) === 200;
|
|
31
|
+
if (typeof value.success === "boolean") return value.success;
|
|
32
|
+
if (typeof value.status === "boolean") return value.status;
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
function caizhilianBusinessMessage(value) {
|
|
36
|
+
if (!value || typeof value !== "object") return "\u91C7\u77E5\u8FDE\u63A5\u53E3\u8FD4\u56DE\u4E1A\u52A1\u5931\u8D25";
|
|
37
|
+
const candidates = [value.msg, value.message, value.errMsg, value.data?.msg, value.data?.message];
|
|
38
|
+
for (const item of candidates) {
|
|
39
|
+
if (typeof item === "string" && item.trim()) return item;
|
|
40
|
+
}
|
|
41
|
+
return "\u91C7\u77E5\u8FDE\u63A5\u53E3\u8FD4\u56DE\u4E1A\u52A1\u5931\u8D25";
|
|
42
|
+
}
|
|
43
|
+
function caizhilianBusinessCode(value) {
|
|
44
|
+
if (!value || typeof value !== "object") return void 0;
|
|
45
|
+
const code = value.code ?? value.status;
|
|
46
|
+
if (typeof code === "string" || typeof code === "number") return code;
|
|
47
|
+
return void 0;
|
|
48
|
+
}
|
|
49
|
+
function assertCaizhilianPath(requestPath) {
|
|
50
|
+
if (typeof requestPath !== "string" || !requestPath.startsWith("/") || requestPath.startsWith("//")) {
|
|
51
|
+
throw caizhilianValidationError("path_invalid", "\u8BF7\u6C42\u8DEF\u5F84\u5FC5\u987B\u662F\u76F8\u5BF9\u7EDD\u5BF9\u8DEF\u5F84");
|
|
52
|
+
}
|
|
53
|
+
if (/^https?:/i.test(requestPath) || /[\r\n]/.test(requestPath) || requestPath.includes("/../")) {
|
|
54
|
+
throw caizhilianValidationError("path_invalid", "\u8BF7\u6C42\u8DEF\u5F84\u4E0D\u5141\u8BB8\u8DE8\u57DF\u6216\u8DEF\u5F84\u9003\u9038");
|
|
55
|
+
}
|
|
56
|
+
if (!requestPath.startsWith("/api/")) {
|
|
57
|
+
throw caizhilianValidationError("path_not_allowed", "\u91C7\u77E5\u8FDE\u6A21\u5757\u53EA\u80FD\u8C03\u7528 /api/ \u8DEF\u5F84");
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function formBody(form) {
|
|
61
|
+
if (!form) return void 0;
|
|
62
|
+
const params = new URLSearchParams();
|
|
63
|
+
for (const [key, value] of Object.entries(form)) {
|
|
64
|
+
if (value === void 0 || value === null) continue;
|
|
65
|
+
params.set(key, typeof value === "string" ? value : JSON.stringify(value));
|
|
66
|
+
}
|
|
67
|
+
return params;
|
|
68
|
+
}
|
|
69
|
+
function omitEmptyQueryValues(query) {
|
|
70
|
+
if (!query) return void 0;
|
|
71
|
+
return Object.fromEntries(Object.entries(query).filter(([, value]) => value !== ""));
|
|
72
|
+
}
|
|
73
|
+
function mapRuntimeNetworkError(error) {
|
|
74
|
+
if (error instanceof E10ApiError && error.type === "network") {
|
|
75
|
+
throw caizhilianNetworkError(error.subtype, error.message, {
|
|
76
|
+
retryable: error.retryable,
|
|
77
|
+
details: error.details
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
function createCaizhilianHost(ctx, dependencies = {}) {
|
|
83
|
+
let e10Session = null;
|
|
84
|
+
let sessionContext = null;
|
|
85
|
+
const requireSession = dependencies.requireSession || requireE10Session;
|
|
86
|
+
async function ensureSession() {
|
|
87
|
+
if (!e10Session) {
|
|
88
|
+
e10Session = await requireSession(ctx);
|
|
89
|
+
sessionContext = {
|
|
90
|
+
baseUrl: e10Session.getBaseUrl(),
|
|
91
|
+
profile: inferProfile(ctx),
|
|
92
|
+
userId: e10Session.userId,
|
|
93
|
+
tenantKey: e10Session.tenantKey,
|
|
94
|
+
eteamsId: e10Session.eteamsId
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return e10Session;
|
|
98
|
+
}
|
|
99
|
+
async function getSession() {
|
|
100
|
+
await ensureSession();
|
|
101
|
+
return sessionContext;
|
|
102
|
+
}
|
|
103
|
+
async function runtime() {
|
|
104
|
+
return createE10RequestRuntime(ctx, await ensureSession(), {
|
|
105
|
+
interceptors: dependencies.interceptors,
|
|
106
|
+
fetch: dependencies.fetch
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
async function doRequest(request2, binary) {
|
|
110
|
+
const {
|
|
111
|
+
method,
|
|
112
|
+
path,
|
|
113
|
+
query,
|
|
114
|
+
body,
|
|
115
|
+
operation,
|
|
116
|
+
form,
|
|
117
|
+
multipart,
|
|
118
|
+
streamMultipart,
|
|
119
|
+
maxResponseBytes,
|
|
120
|
+
headers: extraHeaders = {},
|
|
121
|
+
timeoutMs = CAIZHILAN_TIMEOUT_MS
|
|
122
|
+
} = request2;
|
|
123
|
+
assertCaizhilianPath(path);
|
|
124
|
+
const resolvedMethod = method || (body === void 0 && form === void 0 && multipart === void 0 && streamMultipart === void 0 ? "GET" : "POST");
|
|
125
|
+
const headers = { "X-Requested-With": "XMLHttpRequest", ...extraHeaders, ...streamMultipart ? {
|
|
126
|
+
"Content-Type": streamMultipart.contentType,
|
|
127
|
+
"Content-Length": String(streamMultipart.contentLength)
|
|
128
|
+
} : {} };
|
|
129
|
+
const rt = await runtime();
|
|
130
|
+
const response = binary ? await rt.requestBinary({
|
|
131
|
+
module: "caizhilian",
|
|
132
|
+
operation,
|
|
133
|
+
method: resolvedMethod,
|
|
134
|
+
path,
|
|
135
|
+
query: omitEmptyQueryValues(query),
|
|
136
|
+
body: multipart === void 0 ? body : void 0,
|
|
137
|
+
form: multipart === void 0 && form === void 0 ? void 0 : formBody(form ?? {}),
|
|
138
|
+
formData: multipart,
|
|
139
|
+
streamBody: streamMultipart?.body,
|
|
140
|
+
maxResponseBytes,
|
|
141
|
+
headers,
|
|
142
|
+
timeoutMs
|
|
143
|
+
}) : await rt.requestJson({
|
|
144
|
+
module: "caizhilian",
|
|
145
|
+
operation,
|
|
146
|
+
method: resolvedMethod,
|
|
147
|
+
path,
|
|
148
|
+
query: omitEmptyQueryValues(query),
|
|
149
|
+
body: multipart === void 0 ? body : void 0,
|
|
150
|
+
form: multipart === void 0 && form === void 0 ? void 0 : formBody(form ?? {}),
|
|
151
|
+
formData: multipart,
|
|
152
|
+
streamBody: streamMultipart?.body,
|
|
153
|
+
maxResponseBytes,
|
|
154
|
+
headers,
|
|
155
|
+
timeoutMs
|
|
156
|
+
});
|
|
157
|
+
return response;
|
|
158
|
+
}
|
|
159
|
+
async function request(request2) {
|
|
160
|
+
const response = await doRequest(request2, false).catch((error) => mapRuntimeNetworkError(error));
|
|
161
|
+
if (isE10SessionExpiredResponse(response)) {
|
|
162
|
+
throw caizhilianAuthError("session_expired", E10_SESSION_EXPIRED_MESSAGE, { httpStatus: response.status });
|
|
163
|
+
}
|
|
164
|
+
if (response.parseError) {
|
|
165
|
+
if (response.status < 200 || response.status >= 300) {
|
|
166
|
+
throw new CaizhilianCliError("api", "http_error", `\u91C7\u77E5\u8FDE\u63A5\u53E3 HTTP ${response.status}`, {
|
|
167
|
+
code: response.status,
|
|
168
|
+
details: { status: response.status },
|
|
169
|
+
exitCode: 1
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
throw caizhilianNetworkError("protocol", `\u63A5\u53E3\u8FD4\u56DE\u4E0D\u662F\u5408\u6CD5 JSON\uFF08HTTP ${response.status}\uFF09`, { retryable: false });
|
|
173
|
+
}
|
|
174
|
+
if (response.status < 200 || response.status >= 300 || request2.requireHttp200 && response.status !== 200) {
|
|
175
|
+
throw new CaizhilianCliError("api", "http_error", `\u91C7\u77E5\u8FDE\u63A5\u53E3 HTTP ${response.status}`, {
|
|
176
|
+
code: response.status,
|
|
177
|
+
details: { status: response.status, message: caizhilianBusinessMessage(response.value) },
|
|
178
|
+
exitCode: 1
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
if (!request2.tolerateBusinessError && !isCaizhilianBusinessSuccess(response.value)) {
|
|
182
|
+
throw new CaizhilianCliError("api", "business_error", caizhilianBusinessMessage(response.value), {
|
|
183
|
+
code: caizhilianBusinessCode(response.value),
|
|
184
|
+
details: { code: caizhilianBusinessCode(response.value), message: caizhilianBusinessMessage(response.value) },
|
|
185
|
+
exitCode: 1
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
return response.value;
|
|
189
|
+
}
|
|
190
|
+
async function requestBinary(request2) {
|
|
191
|
+
const response = await doRequest(request2, true).catch((error) => mapRuntimeNetworkError(error));
|
|
192
|
+
if (isE10SessionExpiredResponse(response)) {
|
|
193
|
+
throw caizhilianAuthError("session_expired", E10_SESSION_EXPIRED_MESSAGE, { httpStatus: response.status });
|
|
194
|
+
}
|
|
195
|
+
if (response.status < 200 || response.status >= 300) {
|
|
196
|
+
throw new CaizhilianCliError("api", "http_error", `\u91C7\u77E5\u8FDE\u4E0B\u8F7D HTTP ${response.status}`, {
|
|
197
|
+
code: response.status,
|
|
198
|
+
details: { status: response.status },
|
|
199
|
+
exitCode: 1
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
return { status: response.status, contentType: response.contentType, content: response.content, headers: response.headers };
|
|
203
|
+
}
|
|
204
|
+
return { request, requestBinary, getSession };
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export {
|
|
208
|
+
CAIZHILAN_TIMEOUT_MS,
|
|
209
|
+
CAIZHILAN_TRANSFER_TIMEOUT_MS,
|
|
210
|
+
CAIZHILAN_MAX_DOWNLOAD_BYTES,
|
|
211
|
+
isCaizhilianBusinessSuccess,
|
|
212
|
+
caizhilianBusinessMessage,
|
|
213
|
+
assertCaizhilianPath,
|
|
214
|
+
createCaizhilianHost
|
|
215
|
+
};
|