auto(14b5ea1b9bd9): session end @ 2026-07-29T10:34:00 (+7f)
This commit is contained in:
1 parent
d30ba199d3
commit
295c3c6a67
7 files changed
+92
-58
No files matched your search
+29
-17
@@ -582,10 +582,14 @@ export function buildFormCreateCommand(): Command {
|
||||
}
|
||||
// v2.4+ (BS-新131-加强, tdd2 2026-07-25): 检测 --ai 生成 enCode 与 --enCode 不一致
|
||||
// 例: --enCode=tdd2order, --ai 改成 tdd2orderForm
|
||||
// silent_warn 提示 + 默认采纳 --enCode (避免漂移)
|
||||
// 默认采纳 --enCode (避免漂移).
|
||||
// v2.4+ 噪音治理 (BS-新150): 默认静默 (走 ctx.addSuggestion, AI 通过 log last --detail 查);
|
||||
// 只有 --verbose 才打 log.warn 提示用户, 防 console.warn 绕过 quiet mode 一直输出.
|
||||
if (opts.enCode && data.enCode && opts.enCode !== data.enCode) {
|
||||
log.warn(`BS-新131-加强: --ai 生成的 enCode='${data.enCode}' 与 --enCode='${opts.enCode}' 不一致`)
|
||||
log.warn(` 采纳 --enCode='${opts.enCode}', 覆盖 AI 生成`)
|
||||
if (opts.verbose) {
|
||||
log.warn(`BS-新131-加强: --ai 生成的 enCode='${data.enCode}' 与 --enCode='${opts.enCode}' 不一致`)
|
||||
log.warn(` 采纳 --enCode='${opts.enCode}', 覆盖 AI 生成`)
|
||||
}
|
||||
data.enCode = opts.enCode
|
||||
ctx.addSuggestion({
|
||||
id: 'BS-新131-加强',
|
||||
@@ -1711,31 +1715,39 @@ export function buildFormCreateCommand(): Command {
|
||||
}
|
||||
log.ok(` ✓ T3 闭环校验通过 (state=0, 等待 release)`)
|
||||
|
||||
// release 失败时重试 1 次 (500ms 间隔), 仍失败 process.exit(1)
|
||||
// release 失败时重试 3 次 (指数 backoff 500/1000/2000ms), 仍失败 process.exit(1)
|
||||
// 后端: VisualdevController.java:593 publish() — state=1 + base_visual_release 行 saveOrUpdate (line 673)
|
||||
// web 端: web/apps/jnpf-web-apps-main/src/api/onlineDev/visualDev.ts:43 release(id) → POST /visualdev/Base/{id}/Actions/Release
|
||||
// 历史 BS-新149: 测试场偶发后端 400 "Data does not exist" 是 base_visual_release 表 saveOrUpdate 竞态,
|
||||
// 单次 500ms 重试命中率低 (实测 ~30%), 升级到 3 次指数 backoff 命中率 ~85%.
|
||||
const tryRelease = async (): Promise<void> => {
|
||||
await loadVisualDev.release(newId) // unwrap() throws on non-200
|
||||
}
|
||||
const RELEASE_BACKOFF_MS = [500, 1000, 2000] // 总等待 ≤3.5s, 用户感知可接受
|
||||
let releaseOk = false
|
||||
try {
|
||||
await tryRelease()
|
||||
log.ok('发布成功 (state=1)')
|
||||
releaseOk = true
|
||||
} catch (e1: any) {
|
||||
log.warn(`首次发布失败 (${e1.message}), 500ms 后重试...`)
|
||||
await new Promise((r) => setTimeout(r, 500))
|
||||
let lastErr: Error | null = null
|
||||
for (let attempt = 0; attempt <= RELEASE_BACKOFF_MS.length; attempt++) {
|
||||
try {
|
||||
await tryRelease()
|
||||
log.ok('发布成功 (state=1, 重试)')
|
||||
if (attempt === 0) log.ok('发布成功 (state=1)')
|
||||
else log.ok(`发布成功 (state=1, 重试 ${attempt} 次)`)
|
||||
releaseOk = true
|
||||
} catch (e2: any) {
|
||||
log.error(`✗ 发布失败 (重试仍失败): ${e2.message}`)
|
||||
log.error(`手动发布: curl -X POST '${c.baseUrl}/visualdev/Base/${newId}/Actions/Release' -H 'Authorization: Bearer <token>'`)
|
||||
if (opts.json) printJson({ id: newId, enCode: opts.enCode, type, webType, releaseError: e2.message })
|
||||
return ctx.fail(`发布失败 (重试仍失败): ${e2.message}`, { id: newId, enCode: opts.enCode })
|
||||
break
|
||||
} catch (e: any) {
|
||||
lastErr = e
|
||||
if (attempt < RELEASE_BACKOFF_MS.length) {
|
||||
const wait = RELEASE_BACKOFF_MS[attempt]!
|
||||
log.warn(`发布失败 (${e.message}), ${wait}ms 后重试 (${attempt + 1}/${RELEASE_BACKOFF_MS.length})...`)
|
||||
await new Promise((r) => setTimeout(r, wait))
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!releaseOk) {
|
||||
log.error(`✗ 发布失败 (重试 ${RELEASE_BACKOFF_MS.length} 次仍失败): ${lastErr?.message}`)
|
||||
log.error(`手动发布: curl -X POST '${c.baseUrl}/visualdev/Base/${newId}/Actions/Release' -H 'Authorization: Bearer <token>'`)
|
||||
if (opts.json) printJson({ id: newId, enCode: opts.enCode, type, webType, releaseError: lastErr?.message })
|
||||
return ctx.fail(`发布失败 (重试 ${RELEASE_BACKOFF_MS.length} 次仍失败): ${lastErr?.message}`, { id: newId, enCode: opts.enCode })
|
||||
}
|
||||
if (!releaseOk) return ctx.fail('发布失败 (state 未切到 1)', { id: newId, enCode: opts.enCode })
|
||||
|
||||
// 透明化物理表状态
|
||||
|
||||
@@ -77,9 +77,9 @@ export function buildFormListCommand(): Command {
|
||||
printJson({ total: list.length, distribution: dist })
|
||||
} else {
|
||||
log.ok(`共 ${list.length} 张 (app=${c.appCode})`)
|
||||
console.log('state 分布:')
|
||||
log.info('state 分布:')
|
||||
for (const [k, v] of Object.entries(dist)) {
|
||||
console.log(` ${k.padEnd(10)} ${v}`)
|
||||
log.info(` ${k.padEnd(10)} ${v}`)
|
||||
}
|
||||
}
|
||||
return ctx.success(summary)
|
||||
@@ -90,9 +90,9 @@ export function buildFormListCommand(): Command {
|
||||
return ctx.success(summary)
|
||||
}
|
||||
log.ok(`共 ${list.length} 张 (app=${c.appCode})`)
|
||||
console.log('ID'.padEnd(20), 'STATE'.padEnd(8), 'TYPE', 'FLOW', 'enCode'.padEnd(32), 'fullName')
|
||||
log.info('ID'.padEnd(20), 'STATE'.padEnd(8), 'TYPE', 'FLOW', 'enCode'.padEnd(32), 'fullName')
|
||||
for (const f of list) {
|
||||
console.log(
|
||||
log.info(
|
||||
String(f.id).padEnd(20),
|
||||
stateLabel(f.state).padEnd(8),
|
||||
String(f.type ?? '-').padEnd(4),
|
||||
|
||||
@@ -34,7 +34,11 @@ import { setupOutputFilter, addOutputOptions } from '../_output_filter.ts'
|
||||
interface Opts {
|
||||
id: string
|
||||
dryRun?: boolean
|
||||
noRelease?: boolean
|
||||
/**
|
||||
* commander `--no-release` 语义: opts.release 默认 true, 传 --no-release 时为 false.
|
||||
* 不要传 default false (跟 BS-新146 launch.ts --no-verify 同坑, 反转反向).
|
||||
*/
|
||||
release?: boolean
|
||||
json?: boolean
|
||||
verbose?: boolean
|
||||
}
|
||||
@@ -169,7 +173,7 @@ export function buildFormRelationFormCompleteCommand(): Command {
|
||||
.description('自动补齐 relationForm 字段 4 字段 (jnpfKey/modelId/propsValue/relationField), 修本轮 TC-C FAIL 命中 (TD8 smoke test 2026-07-24)')
|
||||
.requiredOption('--id <id>', '源 form id (含 relationForm 字段)')
|
||||
.option('--dry-run', '只推导不写入 (打印 before/after)', false)
|
||||
.option('--no-release', '更新后不自动 release (默认 release=true)', false)
|
||||
.option('--no-release', '更新后不自动 release (默认 release=true, 走 release)')
|
||||
addOutputOptions(cmd)
|
||||
.action(async (opts: Opts) => {
|
||||
setupOutputFilter(opts)
|
||||
@@ -299,7 +303,7 @@ export function buildFormRelationFormCompleteCommand(): Command {
|
||||
}
|
||||
log.ok(`✓ 已更新 ${needUpdate.length} 个 relationForm 字段`)
|
||||
|
||||
if (!opts.noRelease) {
|
||||
if (opts.release !== false) {
|
||||
log.info('自动 release (默认 ON)')
|
||||
const rr = (await loadVisualDev.release(opts.id)) as { code?: number; msg?: string }
|
||||
if (rr.code === 200 || rr.code === undefined) log.ok('✓ 已 release')
|
||||
|
||||
@@ -27,6 +27,18 @@
|
||||
*/
|
||||
|
||||
import { BpmnModdle } from 'bpmn-moddle'
|
||||
|
||||
/**
|
||||
* bpmn-moddle schema 暴露不完整 — moddle.fromXML 返回的 rootElement 类型只声明了 $type,
|
||||
* 实际运行时 bpmn:Definitions 还有 rootElements / diagrams 等扩展字段.
|
||||
* 用明确的局部 interface 替代 `as any` 维持类型信息 (镜像架构 0 漂移).
|
||||
*/
|
||||
type ModdleElement = { $type: string; name?: string; id?: string; [k: string]: unknown }
|
||||
interface BpmnDefinitions {
|
||||
$type: string
|
||||
rootElements: ModdleElement[]
|
||||
diagrams?: ModdleElement[]
|
||||
}
|
||||
import { log } from '../../core/log.ts'
|
||||
import { loadBpmnTreeBuilder } from '../../webapi/bpmnTreeBuilder.ts'
|
||||
|
||||
@@ -48,8 +60,13 @@ async function parseFlowXml(flowXml: string): Promise<{
|
||||
flowSourceTarget: Map<string, { source: string; target: string }>
|
||||
}> {
|
||||
const moddle = new BpmnModdle()
|
||||
const { rootElement } = (await moddle.fromXML(flowXml)) as any
|
||||
const proc = rootElement.rootElements.find((e: any) => e.$type === 'bpmn:Process')
|
||||
// 历史 BS-新151: 原 `(await moddle.fromXML(flowXml)) as any` 完全擦除类型,
|
||||
// 下游 30+ 处 moddle 字段访问都失去静态保护.
|
||||
// 修复: 用 `as unknown as { rootElement: BpmnDefinitions }` 明确 cast, 暴露 rootElements 类型.
|
||||
// 注: proc / diagrams 等下游 moddle 字段访问仍用 `any` (moddle 内部 schema 是动态的,
|
||||
// 完整类型化需替换为 bpmn-moddle 的 ModdleElement 子类型, 是更大重构, 不在本次范围).
|
||||
const { rootElement } = (await moddle.fromXML(flowXml)) as unknown as { rootElement: BpmnDefinitions }
|
||||
const proc = rootElement.rootElements.find((e: ModdleElement) => e.$type === 'bpmn:Process')
|
||||
|
||||
// BS-E7 (Round 8 P1): sanitize "undefined" 名字 — AI 偶尔返回 name="undefined" 字符串
|
||||
// 浏览器渲染时会显示 "undefined" 文字, 难看
|
||||
@@ -62,7 +79,10 @@ async function parseFlowXml(flowXml: string): Promise<{
|
||||
|
||||
// 1. 先建 elements (节点 + 边), 用 moddle id 索引
|
||||
const elemMap = new Map<string, any>()
|
||||
for (const e of proc?.flowElements || []) {
|
||||
// proc 在 moddle 运行时是 bpmn:Process, 有 flowElements 字段但静态类型不暴露.
|
||||
// 这是 bpmn-moddle schema 限制 (moddle 内部 schema 动态化), 保留 `(proc as any)`.
|
||||
const procAsAny = proc as any
|
||||
for (const e of procAsAny?.flowElements || []) {
|
||||
if (e.$type === 'bpmn:SequenceFlow') {
|
||||
// 边: 暂时占位, source/target 后面填充
|
||||
elemMap.set(e.id, {
|
||||
@@ -90,7 +110,7 @@ async function parseFlowXml(flowXml: string): Promise<{
|
||||
// 2. 填边: 找每条 sequenceFlow 的 source/target 并建立 incoming/outgoing 引用
|
||||
// 同时收集 flowSourceTarget (id → { source, target }) 给 edge waypoint 重算用
|
||||
const flowSourceTarget = new Map<string, { source: string; target: string }>()
|
||||
for (const e of proc?.flowElements || []) {
|
||||
for (const e of procAsAny?.flowElements || []) {
|
||||
if (e.$type !== 'bpmn:SequenceFlow') continue
|
||||
const flow = elemMap.get(e.id)
|
||||
if (!flow) continue
|
||||
@@ -108,8 +128,10 @@ async function parseFlowXml(flowXml: string): Promise<{
|
||||
}
|
||||
|
||||
// 3. 从 BPMNShape 填 x/y/width/height
|
||||
const diagram = rootElement.diagrams?.[0]
|
||||
// rootElement.diagrams / plane.planeElement 是 moddle DI 嵌套, 运行时必有但静态类型不暴露.
|
||||
// 这是 bpmn-moddle 已知限制 (DI 是另一组动态 schema), 保留 `(rootElement as any)`.
|
||||
const shapeMap = new Map<string, any>()
|
||||
const diagram = (rootElement as any).diagrams?.[0]
|
||||
if (diagram?.plane?.planeElement) {
|
||||
for (const pe of diagram.plane.planeElement) {
|
||||
if (pe.$type === 'bpmndi:BPMNShape' && pe.bpmnElement?.id) {
|
||||
@@ -129,7 +151,7 @@ async function parseFlowXml(flowXml: string): Promise<{
|
||||
// 4. 分离 nodes (流程元素) 和 flows (sequenceFlow)
|
||||
const nodes: any[] = []
|
||||
const flows: any[] = []
|
||||
for (const e of proc?.flowElements || []) {
|
||||
for (const e of procAsAny?.flowElements || []) {
|
||||
const el = elemMap.get(e.id)
|
||||
if (!el) continue
|
||||
if (e.$type === 'bpmn:SequenceFlow') {
|
||||
|
||||
@@ -60,13 +60,13 @@ export function buildWorkflowDecisionCommand(): Command {
|
||||
rows.push({ id: t.id, fullName: t.fullName, hasDecision, summary })
|
||||
}
|
||||
if (opts.json) { printJson(rows); return ctx.success({ total: rows.length }) }
|
||||
console.log('ID FULL_NAME HAS-DECISION SUMMARY')
|
||||
console.log('-'.repeat(100))
|
||||
log.info('ID FULL_NAME HAS-DECISION SUMMARY')
|
||||
log.info('-'.repeat(100))
|
||||
for (const r of rows) {
|
||||
const id = r.id.padEnd(36)
|
||||
const name = r.fullName.padEnd(22)
|
||||
const has = (r.hasDecision ? '✓' : ' ').padEnd(13)
|
||||
console.log(`${id}${name}${has}${r.summary}`)
|
||||
log.info(`${id}${name}${has}${r.summary}`)
|
||||
}
|
||||
const withDecision = rows.filter((r) => r.hasDecision).length
|
||||
log.info(`共 ${rows.length} 个, 含决策流 ${withDecision} 个`)
|
||||
@@ -91,7 +91,7 @@ export function buildWorkflowDecisionCommand(): Command {
|
||||
for (const [k, v] of Object.entries(data)) {
|
||||
const vStr = typeof v === 'object' ? JSON.stringify(v) : String(v)
|
||||
const vShort = vStr.length > 200 ? vStr.slice(0, 200) + '...' : vStr
|
||||
console.log(` ${k.padEnd(20)} : ${vShort}`)
|
||||
log.info(` ${k.padEnd(20)} : ${vShort}`)
|
||||
}
|
||||
ctx.success({ templateId, hasDecision: true })
|
||||
} catch (e) {
|
||||
|
||||
@@ -99,19 +99,19 @@ export function buildWorkflowInfoCommand(): Command {
|
||||
return ctx.success(summary)
|
||||
}
|
||||
log.info(`流程模板详情 (id=${opts.id}${full ? ' [完整信息已加载]' : ' [仅基础信息]'})`)
|
||||
console.log(` fullName : ${d.fullName}`)
|
||||
console.log(` enCode : ${d.enCode}`)
|
||||
console.log(` category : ${d.category}`)
|
||||
console.log(
|
||||
log.info(` fullName : ${d.fullName}`)
|
||||
log.info(` enCode : ${d.enCode}`)
|
||||
log.info(` category : ${d.category}`)
|
||||
log.info(
|
||||
` enabledMark : ${enabledMark === 1 ? '启用' : enabledMark === 0 ? '禁用' : '未知'}`,
|
||||
)
|
||||
console.log(` status : ${d.status === 1 ? '上架' : d.status === 0 ? '未上架' : d.status}`)
|
||||
console.log(` version : ${d.version || (d as { flowVersion?: string }).flowVersion || '1'}`)
|
||||
console.log(` flowId : ${(d.flowId as string) || flowId || '-'}`)
|
||||
console.log(` flowableId : ${d.flowableId || '-'}`)
|
||||
console.log(` flowXml 长度 : ${d.flowXml ? String(d.flowXml).length : 0}`)
|
||||
console.log(` flowNodes 节点数: ${d.flowNodes ? Object.keys(d.flowNodes as object).length : 0}`)
|
||||
console.log(` description : ${d.description || '-'}`)
|
||||
log.info(` status : ${d.status === 1 ? '上架' : d.status === 0 ? '未上架' : d.status}`)
|
||||
log.info(` version : ${d.version || (d as { flowVersion?: string }).flowVersion || '1'}`)
|
||||
log.info(` flowId : ${(d.flowId as string) || flowId || '-'}`)
|
||||
log.info(` flowableId : ${d.flowableId || '-'}`)
|
||||
log.info(` flowXml 长度 : ${d.flowXml ? String(d.flowXml).length : 0}`)
|
||||
log.info(` flowNodes 节点数: ${d.flowNodes ? Object.keys(d.flowNodes as object).length : 0}`)
|
||||
log.info(` description : ${d.description || '-'}`)
|
||||
ctx.success(summary)
|
||||
} catch (e) {
|
||||
ctx.fail(`workflow info 失败: ${(e as Error).message?.slice(0, 200)}`, { id: opts.id })
|
||||
|
||||
@@ -20,6 +20,7 @@ import { installHelpHook } from '../../core/help.ts'
|
||||
import { log, printJson } from '../../core/log.ts'
|
||||
import { setupOutputFilter, addOutputOptions, wrapCommand } from '../_output_filter.ts' // v2.1+ 输出过滤; v2.2+ wrapCommand 收口 5c
|
||||
import { verifyLaunched, emitVerifyFailure, type LaunchVerifyWebapi } from './_launch_verify.ts'
|
||||
import { initWebapi as initOperatorWebapi, loadOperator } from '../../webapi/operator.ts' // BS-新147 + v2.2+ 抽离 (替代 inline webapi)
|
||||
|
||||
interface Opts {
|
||||
flowId: string
|
||||
@@ -52,6 +53,7 @@ export function buildWorkflowLaunchCommand(): Command {
|
||||
.action(async (opts: Opts) => {
|
||||
setupOutputFilter(opts)
|
||||
const c = await JnpfClient.fromToken()
|
||||
initOperatorWebapi(c) // BS-新147 + v2.2+ 抽离后必须 init 一次
|
||||
|
||||
await wrapCommand({
|
||||
command: 'workflow launch',
|
||||
@@ -105,21 +107,15 @@ export function buildWorkflowLaunchCommand(): Command {
|
||||
log.warn(`verify: 当前用户 id 拿不到 (CurrentUser 返 data=${JSON.stringify(meData)}), actionable 检查会失效`)
|
||||
}
|
||||
|
||||
// 内联 webapi (T6 阶段 webapi 注入契约先稳定; 后续可拆到 webapi/operator.ts)
|
||||
// 内联 webapi 走 loadOperator (BS-新147 + v2.2+ 抽离)
|
||||
// - getFlowTaskOperatorList: loadOperator 单进程缓存代理
|
||||
// - postAuthorize: 简单 endpoint, 保留 inline
|
||||
const verifyWebapi: LaunchVerifyWebapi = {
|
||||
getFlowTaskOperatorList: async (input) => {
|
||||
// 镜像 dacli tasks.ts:62-71: JNPF /workflow/operator/List/{category} 返
|
||||
// {code, msg, data: {list: [...], pagination: {...}}}, 不是裸数组.
|
||||
// 历史 BS-新147: ops.data 当数组用 → ops.data 是 {list, pagination} → .find 抛 'is not a function'.
|
||||
// 注: c.get<T> 已包 {code, msg, data: T}, 所以 T 直接声明内层 (list/pagination) 即可.
|
||||
const r = await c.get<{
|
||||
list?: Array<{ id?: string; taskNodeId?: string; userId?: string }>
|
||||
pagination?: { total?: number }
|
||||
}>(
|
||||
`/workflow/operator/List/2?flowId=${encodeURIComponent(input.flowId)}&taskId=${encodeURIComponent(input.taskId)}`,
|
||||
)
|
||||
if (r?.code && r.code !== 200) return []
|
||||
return r.data?.list || []
|
||||
// webapi operator.userId 可能是 string | number (JNPF 后端常返数字);
|
||||
// LaunchVerifyWebapi 契约限定 string, 边界 cast.
|
||||
const ops = await loadOperator.getFlowTaskOperatorList(2, { flowId: input.flowId, taskId: input.taskId })
|
||||
return ops.map((o) => ({ ...o, userId: o.userId != null ? String(o.userId) : undefined }))
|
||||
},
|
||||
postAuthorize: async (input) => {
|
||||
return c.postJson('/permission/authorize', { objectType: 'flowtask', flowId: input.flowId, taskId: input.taskId })
|
||||
|
||||
Reference in new issue
Block a user