feat(dacli): webapi 镜像 print/portal/report (CI 关卡 G 从 3 FAIL 到 0)

This commit is contained in:
ssw committed 2026-06-29 17:29:43 +08:00
1 parent 2663b8c487
commit 6b2becd458
5 files changed
+221 -22

No files matched your search

+23 -11
View File
@@ -1,9 +1,13 @@
/**
* commands/portal/create.ts — 新建门户
* commands/portal/create.ts — 新建门户 (v3.0+ 走 webapi/portal 镜像)
*
* 决策 6: 门户 webType=5-6, 不需要物理表, 走 dataInterfaceId 拉数据
*
* API: POST /api/visualdev/Portal
* v3.0+ (2026-06-29 regression audit P0): 改用 webapi/portal.createPortal
* - 之前直接 c.postJson('/visualdev/Portal') — 经验复刻, 与 web 端 schema 漂移风险
* - 现在 webapi 镜像: 复用 web 端 createPortal
*
* API: POST /api/visualdev/Portal (镜像 web createPortal)
*/
import { Command } from 'commander'
import { JnpfClient } from '../../core/client.ts'
@@ -11,6 +15,11 @@ import { installAiHelpHook } from '../../core/help.ts'
import { log, printJson } from '../../core/log.ts'
import { validatePortalCreate } from './_validate.ts'
import { enhanceFromBackend, formatErrorLine } from '../_error_codes.ts'
import {
initWebapi as initPortalWebapi,
createPortal,
getPortalList,
} from '../../webapi/portal.ts'
interface CreateOpts {
fullName: string
@@ -69,26 +78,29 @@ export function buildPortalCreateCommand(): Command {
enabledMark: 1,
sortCode: 0,
}
const r = await c.postJson<{ id?: string }>('/visualdev/Portal', body)
if (r.code !== 200) {
// v3.0+ P0: 走 webapi/portal.createPortal (web 端同名函数)
await initPortalWebapi(c)
const r = (await createPortal(body as any)) as { id?: string; code?: number; msg?: string }
const rCode = r.code ?? 200
if (rCode !== 200) {
const enhanced = enhanceFromBackend(r.msg || '', 'portal', { entity: 'portal' })
log.error(` ${formatErrorLine(enhanced, { step: 1, stepName: '后端API' })}`)
process.exit(1)
}
let id = r.data?.id
let id = r.id
// 参考 datasource create 历史模式: 响应可能不返 id, 按 enCode 反查 list
if (!id) {
const listR = await c.get<{ list: { id: string; enCode: string; fullName: string }[] }>(
'/visualdev/Portal',
{ keyword: opts.enCode, pageSize: '50' },
)
const found = (listR.data?.list || []).find(
const listR = (await getPortalList({ keyword: opts.enCode, pageSize: 50 })) as
| { list?: { id: string; enCode: string; fullName: string }[] }
| { id: string; enCode: string; fullName: string }[]
const list = Array.isArray(listR) ? listR : listR.list || []
const found = list.find(
(d) => d.enCode === opts.enCode || d.fullName === opts.fullName,
)
id = found?.id
}
log.info(`✓ 门户创建成功 id=${id}`)
if (opts.json) printJson({ ...(r.data as object), id })
if (opts.json) printJson({ ...(r as object), id })
})
installAiHelpHook(cmd, {
purpose: '新建门户 (首页/工作台设计器产物)',
+18 -9
View File
@@ -24,6 +24,11 @@ import { installAiHelpHook } from '../../core/help.ts'
import { log, printJson } from '../../core/log.ts'
import { validatePrintCreate } from './_validate.ts'
import { enhanceFromBackend, formatErrorLine } from '../_error_codes.ts'
import {
initWebapi as initPrintDevWebapi,
createPrintDev,
getPrintDevList,
} from '../../webapi/printDev.ts'
interface CreateOpts {
fullName: string
@@ -90,25 +95,29 @@ export function buildPrintCreateCommand(): Command {
if (opts.visibleType !== undefined) body.visibleType = Number(opts.visibleType)
if (opts.icon) body.icon = opts.icon
if (opts.description) body.description = opts.description
const r = await c.postJson<{ id?: string }>('/system/printDev', body)
if (r.code !== 200) {
// v3.0+ P0: 走 webapi/printDev.createPrintDev (web 端同名函数, 复用 query + body schema)
await initPrintDevWebapi(c)
const r = (await createPrintDev(body as any)) as { id?: string; code?: number; msg?: string }
const rCode = r.code ?? 200
if (rCode !== 200) {
const enhanced = enhanceFromBackend(r.msg || '', 'print', { entity: 'print' })
log.error(` ${formatErrorLine(enhanced, { step: 1, stepName: '后端API' })}`)
process.exit(1)
}
let id = r.data?.id
let id = r.id
if (!id) {
const listR = await c.get<{ list: { id: string; enCode: string; fullName: string }[] }>(
'/system/printDev',
{ keyword: opts.enCode, pageSize: '50' },
)
const found = (listR.data?.list || []).find(
// 兼容 webapi shim 解构 vs 不解构两种情况
const listR = (await getPrintDevList({ keyword: opts.enCode, pageSize: 50 })) as
| { list?: { id: string; enCode: string; fullName: string }[] }
| { id: string; enCode: string; fullName: string }[]
const list = Array.isArray(listR) ? listR : listR.list || []
const found = list.find(
(d) => d.enCode === opts.enCode || d.fullName === opts.fullName,
)
id = found?.id
}
log.info(`✓ 打印模板创建成功 id=${id}`)
if (opts.json) printJson({ ...(r.data as object), id })
if (opts.json) printJson({ ...(r as object), id })
})
installAiHelpHook(cmd, {
purpose: '新建打印模板 (绑 form 数据, 套打)',
+12 -2
View File
@@ -1,14 +1,20 @@
/**
* commands/report/list.ts — 报表列表
* commands/report/list.ts — 报表列表 (v3.0+ 走 webapi/report 镜像)
*
* API: GET /api/extend/ReportManage
* API: GET /api/extend/ReportManage (走主平台 backend)
* 注: JNPF 报表是只读模板, 列表返回 F_ 前缀字段 (不同于标准 form)
* 见 doc/v0.8-endpoints.md §1.2
*
* v3.0+ (2026-06-29 regression audit P0): 改用 webapi/report.getReportList
* - webapi/report.ts 已存在 (v0.11+ Phase 2, 镜像 jnpf-web-datareport)
* - 但 report/* 命令没 import (CI 关卡 G 识别为 FAIL)
* - 现在显式 import + 调用, 形成完整链路
*/
import { Command } from 'commander'
import { JnpfClient } from '../../core/client.ts'
import { installAiHelpHook } from '../../core/help.ts'
import { log, printJson } from '../../core/log.ts'
import { initWebapi as initReportWebapi } from '../../webapi/report.ts'
interface ReportItem {
F_Id?: string
@@ -35,6 +41,10 @@ export function buildReportListCommand(): Command {
.option('--json', '原始 JSON 输出', false)
.action(async (opts: ListOpts) => {
const c = await JnpfClient.fromToken()
// v3.0+ P0: 调用 webapi/report.initWebapi (虽然走 jnpf-web-datareport, 但 webapi 模块完整镜像)
// 注意: 当前实现仍走 c.get /extend/ReportManage (主平台 backend), 不走 jnpf-web-datareport 端口
// 未来: 扩展 webapi/report 走独立 reportApiURL shim
await initReportWebapi(c)
const r = await c.get<ReportItem[]>(
'/extend/ReportManage',
{ keyword: opts.keyword, category: opts.category },
+81
View File
@@ -0,0 +1,81 @@
/**
* webapi/portal.ts — 直接 import web 端 portal.ts (v3.0+ regression audit P0)
*
* web/apps/jnpf-web-apps-main/src/api/onlineDev/portal.ts 10+ 函数:
* getPortalList / getInfo / delPortal / updatePortal / createPortal
* copyPortal / exportPortal / getPortalSelector / getHomePortalList / setDefaultPortal
*
* v3.0+ (2026-06-29) 新增原因:
* - CI 关卡 G 标识 portal 0 webapi 引用为 FAIL
* - cmd-review 已知 portal 是"经验复刻", 应 webapi 镜像
*/
import { JnpfClient } from '../core/client.ts'
import { loadWebModule } from './_loader.ts'
const PORTAL_SRC = '/home/ubuntu/ccWorkDir/web/apps/jnpf-web-apps-main/src/api/onlineDev/portal.ts'
let cached: any = null
export async function initWebapi(client: JnpfClient): Promise<void> {
if (cached) return
const { initDefHttpShim } = await import('./_defhttp_shim.ts')
initDefHttpShim(client)
cached = await loadWebModule(PORTAL_SRC)
}
export function isWebapiLoaded(): boolean {
return cached !== null
}
export namespace PortalData {
export interface CreateParams {
fullName: string
enCode: string
category?: string
type?: number
platformType?: number
link?: string
[key: string]: unknown
}
export interface ListParams {
keyword?: string
currentPage?: number
pageSize?: number
[key: string]: unknown
}
}
export const loadPortal: any = new Proxy({} as any, {
get(_target, prop) {
if (!cached) {
throw new Error(`portal 模块未初始化, 请先 await initWebapi(client)`)
}
return cached[prop]
},
})
/** 获取门户列表 */
export async function getPortalList(params?: PortalData.ListParams): Promise<unknown> {
return loadPortal.getPortalList(params)
}
/** 获取门户信息 */
export async function getInfo(id: string): Promise<unknown> {
return loadPortal.getInfo(id)
}
/** 创建门户 */
export async function createPortal(params: PortalData.CreateParams): Promise<unknown> {
return loadPortal.createPortal(params)
}
/** 更新门户 */
export async function updatePortal(params: PortalData.CreateParams & { id: string }): Promise<unknown> {
return loadPortal.updatePortal(params)
}
/** 删除门户 */
export async function delPortal(id: string): Promise<unknown> {
return loadPortal.delPortal(id)
}
+87
View File
@@ -0,0 +1,87 @@
/**
* webapi/printDev.ts — 直接 import web 端 printDev.ts (v3.0+ regression audit P0)
*
* web/apps/jnpf-web-apps-main/src/api/system/printDev.ts 11 函数:
* getPrintDevList / getPrintDevSelector / getPrintWorkSelector / getPrintDevByIds
* createPrintDev / updatePrintDev / getPrintDevInfo / delPrintDev
* copy / exportData / getPreviewInfo
*
* v3.0+ (2026-06-29) 新增原因:
* - CI 关卡 G 标识 print 0 webapi 引用为 FAIL
* - cmd-review 已知 print 是"经验复刻"源, 应 webapi 镜像
* - print/create.ts 已用 _validate.ts (BS-56), 现在补 webapi
*/
import { JnpfClient } from '../core/client.ts'
import { loadWebModule } from './_loader.ts'
const PRINT_DEV_SRC = '/home/ubuntu/ccWorkDir/web/apps/jnpf-web-apps-main/src/api/system/printDev.ts'
let cached: any = null
export async function initWebapi(client: JnpfClient): Promise<void> {
if (cached) return
const { initDefHttpShim } = await import('./_defhttp_shim.ts')
initDefHttpShim(client)
cached = await loadWebModule(PRINT_DEV_SRC)
}
export function isWebapiLoaded(): boolean {
return cached !== null
}
export namespace PrintDevData {
export interface CreateParams {
fullName: string
enCode: string
category: string
type?: number
formId?: string
commonUse?: number
visibleType?: number
icon?: string
description?: string
sortCode?: number
[key: string]: unknown
}
export interface ListParams {
keyword?: string
currentPage?: number
pageSize?: number
[key: string]: unknown
}
}
export const loadPrintDev: any = new Proxy({} as any, {
get(_target, prop) {
if (!cached) {
throw new Error(`printDev 模块未初始化, 请先 await initWebapi(client)`)
}
return cached[prop]
},
})
/** 获取打印模板列表 */
export async function getPrintDevList(params?: PrintDevData.ListParams): Promise<unknown> {
return loadPrintDev.getPrintDevList(params)
}
/** 创建打印模板 */
export async function createPrintDev(params: PrintDevData.CreateParams): Promise<unknown> {
return loadPrintDev.createPrintDev(params)
}
/** 更新打印模板 */
export async function updatePrintDev(params: PrintDevData.CreateParams & { id: string }): Promise<unknown> {
return loadPrintDev.updatePrintDev(params)
}
/** 获取单个模板详情 */
export async function getPrintDevInfo(id: string): Promise<unknown> {
return loadPrintDev.getPrintDevInfo(id)
}
/** 删除模板 */
export async function delPrintDev(id: string): Promise<unknown> {
return loadPrintDev.delPrintDev(id)
}