feat(dict-dataupdate): v0.11e+ enhanceFromBackend (Phase C2)

dict/dataupdate.ts: 加 enhanceFromBackend (EXIST007 字典项编码重复 等)
This commit is contained in:
ssw committed 2026-06-27 04:11:24 +08:00
1 parent 58ea281b7d
commit 20c2df2a60
1 file changed
+5 -2
+5 -2
View File
@@ -9,6 +9,7 @@ import { JnpfClient } from '../../core/client.ts'
import { installAiHelpHook } from '../../core/help.ts'
import { log, printJson } from '../../core/log.ts'
import { initWebapi, loadDict } from '../../webapi/dict.ts'
import { enhanceFromBackend, formatErrorLine } from '../_error_codes.ts'
interface Opts {
id: string
@@ -35,7 +36,8 @@ export function buildDictDataUpdateCommand(): Command {
// v0.11+ Phase 2: 用 webapi 镜像 (loadDict.getDictionaryDataInfo + updateDictionaryData)
const orig = (await loadDict.getDictionaryDataInfo(opts.id)) as Record<string, unknown>
if (!orig) {
log.error(`dict dataUpdate 失败: 拉原字典项 id=${opts.id} 失败`)
const enhanced = enhanceFromBackend('拉原字典项失败, id 不存在', 'id', { entity: 'dict' })
log.error(` ${formatErrorLine(enhanced, { step: 0, stepName: '配置拉取' })}`)
process.exit(1)
}
const body: Record<string, unknown> = { ...orig, id: opts.id }
@@ -46,7 +48,8 @@ export function buildDictDataUpdateCommand(): Command {
log.info(`loadDict.updateDictionaryData (id=${opts.id})`)
const r = (await loadDict.updateDictionaryData(body)) as { code?: number; msg?: string; data?: unknown }
if (r.code !== 200 && r.code !== undefined) {
log.error(`dict dataUpdate 失败 (code=${r.code}): ${r.msg}`)
const enhanced = enhanceFromBackend(r.msg || '', 'dictData', { entity: 'dict' })
log.error(` ${formatErrorLine(enhanced, { step: 1, stepName: '后端API' })}`)
if (opts.json) printJson(r)
process.exit(1)
}