diff --git a/src/commands/form/create.ts b/src/commands/form/create.ts index bab322e..811dff4 100644 --- a/src/commands/form/create.ts +++ b/src/commands/form/create.ts @@ -1717,7 +1717,13 @@ export function buildFormCreateCommand(): Command { // 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 + // web 端: web/apps/jnpf-web-apps-main/src/api/onlineDev/visualDev.ts:43-45 release(id) → POST /visualdev/Base/{id}/Actions/Release + // + // ⚠ 铁律 3 audit (2026-07-29): retry + backoff 是 dacli ADDITIVE SAFETY NET, 不在 web 镜像范围. + // web 端 release() 简单 POST 无 retry, 因为浏览器交互是一次性的 (用户点发布, 失败看错误); + // dacli 跑 CI / agent loop 不能中断, 加 retry 兜底后端 saveOrUpdate 竞态 (base_visual_release 表). + // 此机制不属于"镜像", 是 dacli 的工程化改进 (跟 BS-新149 注释同根). + // // 历史 BS-新149: 测试场偶发后端 400 "Data does not exist" 是 base_visual_release 表 saveOrUpdate 竞态, // 单次 500ms 重试命中率低 (实测 ~30%), 升级到 3 次指数 backoff 命中率 ~85%. const tryRelease = async (): Promise => { diff --git a/src/commands/workflow/_approver_resolve.ts b/src/commands/workflow/_approver_resolve.ts index c11c917..c12abf4 100644 --- a/src/commands/workflow/_approver_resolve.ts +++ b/src/commands/workflow/_approver_resolve.ts @@ -92,10 +92,18 @@ export async function resolveApproverExpr(expr: string, ctx: ResolveCtx): Promis const me = await safeCall(() => ctx.webapi?.getCurrentUser?.()) if (me === undefined) return { candidates: [], reason: 'api error' } if (!me) return { candidates: [], reason: 'no current user' } - // 真实 JNPF /api/oauth/CurrentUser 响应结构: {menuList, permissionList, userInfo: {userId, realName, ...}, sysConfigInfo}. - // 历史 BS-新148: 顶层读 me.userId 永远 undefined (顶层无此字段, 在 userInfo 子层). - // → currentUserId 空 → ${currentUser} lint 永远 'no current user'. - // 修复: 优先 me.userInfo.userId, fallback 顶层 me.userId (兼容旧的扁平响应). + // 真实 JNPF /api/oauth/CurrentUser 响应结构 (铁律 1 audit, 2026-07-29): + // web 端 web/packages/@core/base/typings/src/basic.d.ts:93-99 GetUserInfoModel: + // { menuList, permissionList, routerList, sysConfigInfo, userInfo: UserInfo } + // web 端 web/store/auth.ts:121 fetchUserInfo: + // const { userInfo, sysConfigInfo, menuList, permissionList } = res.data + // 即 userId 在 me.userInfo.userId, 顶层 me.userId 是 undefined. + // + // 历史 BS-新148: 顶层读 me.userId 永远 undefined → currentUserId 空 → ${currentUser} lint 永远 'no current user'. + // 修复: 优先 me.userInfo.userId (跟 web store/auth.ts:121 一致), fallback 顶层 me.userId (兼容老的扁平响应). + // + // 注: dacli 端未 import web GetUserInfoModel (跨包类型解析成本高), 用 inline duck typing + // + 此 audit 注释保证跟 web 端响应结构一致. const info = (me as { userInfo?: Record }).userInfo ?? me const id = String( (info as Record).userId || diff --git a/src/commands/workflow/launch.ts b/src/commands/workflow/launch.ts index f08c931..1a3c2f4 100644 --- a/src/commands/workflow/launch.ts +++ b/src/commands/workflow/launch.ts @@ -107,15 +107,15 @@ export function buildWorkflowLaunchCommand(): Command { log.warn(`verify: 当前用户 id 拿不到 (CurrentUser 返 data=${JSON.stringify(meData)}), actionable 检查会失效`) } - // 内联 webapi 走 loadOperator (BS-新147 + v2.2+ 抽离) - // - getFlowTaskOperatorList: loadOperator 单进程缓存代理 - // - postAuthorize: 简单 endpoint, 保留 inline + // webapi 镜像 web task.ts:71-73 getFlowBeforeList (P0 严格镜像, BS-新147 修) + // - loadOperator.getFlowBeforeList({ category, flowId, taskId }) → JnpfResp + // - 镜像后无任何自写解析 (0 漂移, 跟 web task.ts 一致) + // - LaunchVerifyWebapi 契约需要 array of {id?, userId?}, 从 .data.list 取 + 边界 userId 类型 cast const verifyWebapi: LaunchVerifyWebapi = { getFlowTaskOperatorList: async (input) => { - // 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 })) + const resp = await loadOperator.getFlowBeforeList({ category: 2, flowId: input.flowId, taskId: input.taskId }) + const list: Array<{ id?: string; taskNodeId?: string; userId?: string | number }> = resp?.data?.list ?? [] + return list.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 }) diff --git a/src/webapi/_loader.ts b/src/webapi/_loader.ts index 9c4239c..a49db06 100644 --- a/src/webapi/_loader.ts +++ b/src/webapi/_loader.ts @@ -84,12 +84,20 @@ export async function loadWebModule(sourcePath: string, opts: LoadOptio // 3. 替换其他 #/... → WEB_SRC/... (但已替换的 #/api/request 不再被命中) src = src.replace(/from\s+['"]#\/(.+?)['"]/g, (_, p) => `from '${WEB_SRC}/${p}'`) - // 4. 替换 @jnpf/utils → uuid (避开 Vite env) - src = src.replace(/from\s+['"]@jnpf\/utils['"]/g, `from '${JNPF_UTILS_UUID}'`) + // 4. v2.3+ P0 镜像: 替换 @jnpf/utils → _jnpf_utils_shim (含 buildUUID + AesEncryption stub) + // 历史 (v0.11~v2.2): 直接用 uuid.ts, 但 task.ts:1 还要 AesEncryption/buildBitUUID, 失败. + // 修复: 提供 _jnpf_utils_shim.ts 同时 export buildUUID + AesEncryption + buildBitUUID, + // 让 web task.ts ES module 解析通过. + src = src.replace(/from\s+['"]@jnpf\/utils['"]/g, `from '${join(SHIM_DIR, '_jnpf_utils_shim.ts')}'`) // 5. v3.0+ 替换 @vben/request → vben request shim (ContentTypeEnum/RequestEnum/ResultEnum) src = src.replace(/from\s+['"]@vben\/request['"]/g, `from '${vbenShimPath}'`) + // 5.6 v2.3+ P0 镜像: 替换 @vben/stores → vben stores shim (Pinia useUserStore 等) + // web/api/workFlow/task.ts:3 import { useUserStore } from '@vben/stores' (运行时无状态 HTTP 调用用不到, + // 但 ES module import 必须在顶层解析, 故需 stub). + src = src.replace(/from\s+['"]@vben\/stores['"]/g, `from '${join(SHIM_DIR, '_vben_stores_shim.ts')}'`) + // 5.5 v0.14+ BS-新31: 替换 import 路径 → aliasMap / aliasSrc // aliasMap 优先 (任何精确路径, 包括相对路径 '../xxx') // aliasSrc 兜底 (只匹配 Vite @/ 前缀)