fix: compact wechat archive status output

This commit is contained in:
Codex
2026-06-13 04:55:53 +00:00
parent c818d0cd44
commit edb040d31a
+98 -4
View File
@@ -8,7 +8,6 @@ import {
asRecord,
assertProxyOk,
booleanField,
compactProxyResponse,
compactUnknown,
containerPathToHostPath,
fetchJsonWithTimeout,
@@ -241,9 +240,9 @@ async function status(options: OpsCommonOptions): Promise<Record<string, unknown
activeDesired: archive.n8n.workflow.active,
},
baiduNetdisk: {
health: options.full ? redactSensitiveUnknown(health.raw) : compactProxyResponse(health),
auth: options.full ? redactSensitiveUnknown(auth.raw) : compactProxyResponse(auth),
recentTransfers: options.full ? redactSensitiveUnknown(transfers.raw) : compactProxyResponse(transfers),
health: compactBaiduHealth(health),
auth: compactBaiduAuth(auth),
recentTransfers: compactBaiduTransfers(transfers),
},
valuesPrinted: false,
...(options.raw ? { raw: redactSensitiveUnknown({ health, auth, transfers }) } : {}),
@@ -1031,6 +1030,101 @@ function compactDownload(downloaded: Record<string, unknown>): Record<string, un
};
}
function compactBaiduHealth(response: ReturnType<typeof microserviceProxy>): Record<string, unknown> {
const body = typeof response.body === "object" && response.body !== null && !Array.isArray(response.body)
? response.body as Record<string, unknown>
: {};
const storage = typeof body.storage === "object" && body.storage !== null && !Array.isArray(body.storage) ? body.storage as Record<string, unknown> : {};
const queue = typeof body.queue === "object" && body.queue !== null && !Array.isArray(body.queue) ? body.queue as Record<string, unknown> : {};
const transfers = typeof queue.transfers === "object" && queue.transfers !== null && !Array.isArray(queue.transfers) ? queue.transfers as Record<string, unknown> : {};
return {
ok: response.ok,
status: response.status,
service: body.service,
storage: {
postgres: storage.postgres,
stagingDir: storage.stagingDir,
},
queue: {
transfers: {
succeeded: transfers.succeeded,
failed: transfers.failed,
},
},
};
}
function compactBaiduAuth(response: ReturnType<typeof microserviceProxy>): Record<string, unknown> {
const body = typeof response.body === "object" && response.body !== null && !Array.isArray(response.body)
? response.body as Record<string, unknown>
: {};
const auth = typeof body.auth === "object" && body.auth !== null && !Array.isArray(body.auth) ? body.auth as Record<string, unknown> : {};
const account = typeof auth.account === "object" && auth.account !== null && !Array.isArray(auth.account) ? auth.account as Record<string, unknown> : {};
return {
ok: response.ok,
status: response.status,
configured: auth.configured,
loggedIn: auth.loggedIn,
account: {
present: Object.keys(account).length > 0,
rootPath: account.rootPath,
quota: compactBaiduQuota(account.quota),
},
valuesPrinted: false,
};
}
function compactBaiduQuota(value: unknown): Record<string, unknown> | null {
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
const quota = value as Record<string, unknown>;
return {
total: quota.total,
used: quota.used,
free: quota.free,
usedPercent: quota.usedPercent,
};
}
function compactBaiduTransfers(response: ReturnType<typeof microserviceProxy>): Record<string, unknown> {
const body = typeof response.body === "object" && response.body !== null && !Array.isArray(response.body)
? response.body as Record<string, unknown>
: {};
const counts = typeof body.counts === "object" && body.counts !== null && !Array.isArray(body.counts) ? body.counts as Record<string, unknown> : {};
const jobs = typeof body.jobs === "object" && body.jobs !== null && !Array.isArray(body.jobs) ? body.jobs as Record<string, unknown> : {};
const items = Array.isArray(jobs.items)
? jobs.items
: Array.isArray(jobs.arrayPreview)
? jobs.arrayPreview
: [];
return {
ok: response.ok,
status: response.status,
counts,
jobs: {
count: typeof jobs.count === "number" ? jobs.count : items.length,
items: items.slice(0, 10).map(compactBaiduTransferJob),
},
};
}
function compactBaiduTransferJob(value: unknown): Record<string, unknown> {
const job = typeof value === "object" && value !== null && !Array.isArray(value) ? value as Record<string, unknown> : {};
const result = typeof job.result === "object" && job.result !== null && !Array.isArray(job.result) ? job.result as Record<string, unknown> : {};
const baidu = typeof result.baidu === "object" && result.baidu !== null && !Array.isArray(result.baidu) ? result.baidu as Record<string, unknown> : {};
return {
id: job.id,
direction: job.direction,
status: job.status,
createdAt: job.createdAt,
updatedAt: job.updatedAt,
remotePath: job.remotePath ?? result.remotePath,
fsId: job.fsId || baidu.fs_id || result.fsId,
sizeBytes: job.sizeBytes ?? result.sizeBytes ?? baidu.size,
progressPercent: job.progressPercent,
error: job.error || undefined,
};
}
function redactBaiduFileEntry(value: Record<string, unknown> | null): Record<string, unknown> | null {
if (value === null) return null;
const copy: Record<string, unknown> = { ...value };