auto(14b5ea1b9bd9): session end @ 2026-07-30T10:32:46 (+3f)
This commit is contained in:
1 parent
ce3ee63bd5
commit
cfb7702ce1
3 files changed
+21
-20
No files matched your search
@@ -32,6 +32,7 @@ export interface ResolveWebapi {
|
||||
userName?: string
|
||||
account?: string
|
||||
userAccount?: string
|
||||
userInfo?: Record<string, unknown>
|
||||
} | null | undefined>
|
||||
}
|
||||
|
||||
@@ -49,6 +50,16 @@ export interface ResolveResult {
|
||||
* 注: ${currentUser} 这种变量包装形式是合法的 getter 调用, 不在此列. */
|
||||
const RESERVED = new Set(['initiator', 'any', 'starter'])
|
||||
|
||||
/** 镜像 web auth store 对 CurrentUser.userInfo 的解包,同时兼容历史扁平响应。 */
|
||||
export function resolveCurrentUserIdentity(me: Record<string, unknown>): { id: string; name: string } {
|
||||
const info = (me.userInfo as Record<string, unknown> | undefined) ?? me
|
||||
const id = String(info.userId || info.id || me.userId || me.id || '')
|
||||
const name = id
|
||||
? String(info.realName || info.userName || info.userAccount || info.account || id)
|
||||
: ''
|
||||
return { id, name }
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析 BPMN userTask assignee 表达式.
|
||||
*
|
||||
@@ -104,23 +115,9 @@ export async function resolveApproverExpr(expr: string, ctx: ResolveCtx): Promis
|
||||
//
|
||||
// 注: dacli 端未 import web GetUserInfoModel (跨包类型解析成本高), 用 inline duck typing
|
||||
// + 此 audit 注释保证跟 web 端响应结构一致.
|
||||
const info = (me as { userInfo?: Record<string, unknown> }).userInfo ?? me
|
||||
const id = String(
|
||||
(info as Record<string, unknown>).userId ||
|
||||
(info as Record<string, unknown>).id ||
|
||||
(me as Record<string, unknown>).userId ||
|
||||
(me as Record<string, unknown>).id ||
|
||||
'',
|
||||
)
|
||||
const displayName = String(
|
||||
(info as Record<string, unknown>).realName ||
|
||||
(info as Record<string, unknown>).userName ||
|
||||
(info as Record<string, unknown>).userAccount ||
|
||||
(info as Record<string, unknown>).account ||
|
||||
id,
|
||||
)
|
||||
if (!id) return { candidates: [], reason: 'no current user' }
|
||||
return { candidates: [{ id, name: displayName }] }
|
||||
const identity = resolveCurrentUserIdentity(me as Record<string, unknown>)
|
||||
if (!identity.id) return { candidates: [], reason: 'no current user' }
|
||||
return { candidates: [identity] }
|
||||
}
|
||||
|
||||
return { candidates: [], reason: 'unknown expression' }
|
||||
|
||||
@@ -16,6 +16,7 @@ import { buildWorkflowDecisionCommand } from './decision.ts'
|
||||
import { buildWorkflowSelectorCommand } from './selector.ts'
|
||||
import { buildWorkflowTasksCommand } from './tasks.ts'
|
||||
import { buildWorkflowSyncFormCommand } from './syncForm.ts'
|
||||
import { buildWorkflowAssignApproversCommand } from './assignApprovers.ts'
|
||||
|
||||
export function buildWorkflowCommand(): Command {
|
||||
const cmd = new Command('workflow').description('流程引擎 (模板 CRUD + 发起/审批 + 我的任务)')
|
||||
@@ -30,5 +31,6 @@ export function buildWorkflowCommand(): Command {
|
||||
cmd.addCommand(buildWorkflowSelectorCommand())
|
||||
cmd.addCommand(buildWorkflowTasksCommand())
|
||||
cmd.addCommand(buildWorkflowSyncFormCommand()) // BS-新27 (jxcj 2026-07-01): 同步 form.formData
|
||||
cmd.addCommand(buildWorkflowAssignApproversCommand())
|
||||
return cmd
|
||||
}
|
||||
@@ -21,6 +21,7 @@ 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)
|
||||
import { resolveCurrentUserIdentity } from './_approver_resolve.ts'
|
||||
|
||||
interface Opts {
|
||||
flowId: string
|
||||
@@ -101,10 +102,11 @@ export function buildWorkflowLaunchCommand(): Command {
|
||||
const meResp = await c.get<{ id?: string; userId?: string; account?: string }>(
|
||||
`/oauth/CurrentUser?systemCode=${encodeURIComponent(c.appCode)}&isBackend=1&_t=${Date.now()}`,
|
||||
)
|
||||
const meData = (meResp.data || {}) as { id?: string; userId?: string; account?: string }
|
||||
const currentUserId = String(meData.userId || meData.id || meData.account || '')
|
||||
const meData = (meResp.data || {}) as Record<string, unknown>
|
||||
const identity = resolveCurrentUserIdentity(meData)
|
||||
const currentUserId = identity.id
|
||||
if (!currentUserId) {
|
||||
log.warn(`verify: 当前用户 id 拿不到 (CurrentUser 返 data=${JSON.stringify(meData)}), actionable 检查会失效`)
|
||||
return ctx.fail(`verify: CurrentUser 未返回 userInfo.userId`, { flowId: opts.flowId, taskId })
|
||||
}
|
||||
|
||||
// webapi 镜像 web task.ts:71-73 getFlowBeforeList (P0 严格镜像, BS-新147 修)
|
||||
|
||||
Reference in new issue
Block a user