中性化运行上下文字段
This commit is contained in:
@@ -15,7 +15,7 @@ import type {
|
||||
type TaskQueryExecutor = (text: string, params?: unknown[]) => Promise<{ rows: unknown[] }>
|
||||
|
||||
type TaskRuntimeContextRow = {
|
||||
browser_session_id: string
|
||||
runtime_session_id: string
|
||||
login_type: string
|
||||
nickname: string
|
||||
role_id: string
|
||||
@@ -33,7 +33,7 @@ const TASK_FIELDS = `
|
||||
ct.token AS primary_claim_token,
|
||||
ct.status AS primary_claim_token_status,
|
||||
ct.expired_at AS primary_claim_expires_at,
|
||||
ctx.browser_session_id,
|
||||
ctx.runtime_session_id,
|
||||
ctx.login_type,
|
||||
ctx.nickname,
|
||||
ctx.role_id,
|
||||
@@ -222,7 +222,7 @@ export async function updateTask(taskId: number | string, patch: TaskUpdatePatch
|
||||
|
||||
if (containsRuntimeContextPatch(patch)) {
|
||||
await upsertTaskRuntimeContextWithClient(client, Number(taskId), {
|
||||
runtimeSessionId: patch.browser_session_id,
|
||||
runtimeSessionId: patch.runtime_session_id,
|
||||
loginType: patch.login_type,
|
||||
nickname: patch.nickname,
|
||||
roleId: patch.role_id,
|
||||
@@ -346,7 +346,7 @@ async function upsertTaskRuntimeContextWithClient(
|
||||
const current = currentResult.rows[0] || null
|
||||
|
||||
const next = {
|
||||
browser_session_id: patch.runtimeSessionId ?? current?.browser_session_id ?? '',
|
||||
runtime_session_id: patch.runtimeSessionId ?? current?.runtime_session_id ?? '',
|
||||
login_type: patch.loginType ?? current?.login_type ?? '',
|
||||
nickname: patch.nickname ?? current?.nickname ?? '',
|
||||
role_id: patch.roleId ?? current?.role_id ?? '',
|
||||
@@ -364,7 +364,7 @@ async function upsertTaskRuntimeContextWithClient(
|
||||
`
|
||||
INSERT INTO task_runtime_contexts (
|
||||
task_id,
|
||||
browser_session_id,
|
||||
runtime_session_id,
|
||||
login_type,
|
||||
nickname,
|
||||
role_id,
|
||||
@@ -380,7 +380,7 @@ async function upsertTaskRuntimeContextWithClient(
|
||||
`,
|
||||
[
|
||||
Number(taskId),
|
||||
next.browser_session_id,
|
||||
next.runtime_session_id,
|
||||
next.login_type,
|
||||
next.nickname,
|
||||
next.role_id,
|
||||
@@ -401,7 +401,7 @@ async function upsertTaskRuntimeContextWithClient(
|
||||
`
|
||||
UPDATE task_runtime_contexts
|
||||
SET
|
||||
browser_session_id = $1,
|
||||
runtime_session_id = $1,
|
||||
login_type = $2,
|
||||
nickname = $3,
|
||||
role_id = $4,
|
||||
@@ -415,7 +415,7 @@ async function upsertTaskRuntimeContextWithClient(
|
||||
WHERE task_id = $12
|
||||
`,
|
||||
[
|
||||
next.browser_session_id,
|
||||
next.runtime_session_id,
|
||||
next.login_type,
|
||||
next.nickname,
|
||||
next.role_id,
|
||||
@@ -446,7 +446,7 @@ async function getTaskByIdWithExecutor(
|
||||
|
||||
function containsRuntimeContextPatch(patch: TaskUpdatePatch = {}): boolean {
|
||||
return [
|
||||
'browser_session_id',
|
||||
'runtime_session_id',
|
||||
'login_type',
|
||||
'nickname',
|
||||
'role_id',
|
||||
|
||||
Reference in New Issue
Block a user