统一前后端代码格式化配置

This commit is contained in:
yml2213
2026-08-16 17:27:12 +08:00
parent 8705f6a6a1
commit 5c7c3e14e3
278 changed files with 6386 additions and 5500 deletions
+65 -34
View File
@@ -9,10 +9,7 @@ import type {
TaskRuntimeContextPatch,
TaskUpdatePatch,
} from '../types/repository/inputs.js'
import type {
TaskListQueryResult,
TaskRow,
} from '../types/repository/rows.js'
import type { TaskListQueryResult, TaskRow } from '../types/repository/rows.js'
type TaskQueryExecutor = (text: string, params?: unknown[]) => Promise<{ rows: unknown[] }>
const KUAISHOU_FEIFEI_EXECUTOR_KEY = 'kuaishou_feifei'
@@ -150,21 +147,32 @@ export async function createTask(input: TaskCreateInput): Promise<TaskRow | null
const taskId = Number(taskResult.rows[0]?.id || 0)
if (input.runtimeContext) {
await upsertTaskRuntimeContextWithClient(client, taskId, input.runtimeContext, input.createdAt)
await upsertTaskRuntimeContextWithClient(
client,
taskId,
input.runtimeContext,
input.createdAt,
)
}
await syncKuaishouCloudTaskStateForTask({
taskId,
executorKey: input.executorKey,
contextJson: input.contextJson || '{}',
updatedAt: input.updatedAt,
}, client.query.bind(client) as TaskQueryExecutor)
await syncKuaishouCloudTaskStateForTask(
{
taskId,
executorKey: input.executorKey,
contextJson: input.contextJson || '{}',
updatedAt: input.updatedAt,
},
client.query.bind(client) as TaskQueryExecutor,
)
return getTaskByIdWithExecutor(client.query.bind(client) as TaskQueryExecutor, taskId)
})
}
export async function updateTask(taskId: number | string, patch: TaskUpdatePatch): Promise<TaskRow | null> {
export async function updateTask(
taskId: number | string,
patch: TaskUpdatePatch,
): Promise<TaskRow | null> {
const current = await getTaskById(taskId)
if (!current) {
return null
@@ -218,26 +226,38 @@ export async function updateTask(taskId: number | string, patch: TaskUpdatePatch
if (containsRuntimeContextPatch(patch)) {
const runtimeContextPatch: TaskRuntimeContextPatch = {}
if (patch.runtime_session_id !== undefined) runtimeContextPatch.runtimeSessionId = patch.runtime_session_id
if (patch.runtime_session_id !== undefined)
runtimeContextPatch.runtimeSessionId = patch.runtime_session_id
if (patch.login_type !== undefined) runtimeContextPatch.loginType = patch.login_type
if (patch.nickname !== undefined) runtimeContextPatch.nickname = patch.nickname
if (patch.role_id !== undefined) runtimeContextPatch.roleId = patch.role_id
if (patch.role_name !== undefined) runtimeContextPatch.roleName = patch.role_name
if (patch.area !== undefined) runtimeContextPatch.area = patch.area
if (patch.partition_name !== undefined) runtimeContextPatch.partitionName = patch.partition_name
if (patch.screenshot_path !== undefined) runtimeContextPatch.screenshotPath = patch.screenshot_path
if (patch.artifacts_json !== undefined) runtimeContextPatch.artifactsJson = patch.artifacts_json
if (patch.partition_name !== undefined)
runtimeContextPatch.partitionName = patch.partition_name
if (patch.screenshot_path !== undefined)
runtimeContextPatch.screenshotPath = patch.screenshot_path
if (patch.artifacts_json !== undefined)
runtimeContextPatch.artifactsJson = patch.artifacts_json
if (patch.state_json !== undefined) runtimeContextPatch.stateJson = patch.state_json
await upsertTaskRuntimeContextWithClient(client, Number(taskId), runtimeContextPatch, patch.updated_at || current.updated_at)
await upsertTaskRuntimeContextWithClient(
client,
Number(taskId),
runtimeContextPatch,
patch.updated_at || current.updated_at,
)
}
await syncKuaishouCloudTaskStateForTask({
taskId,
executorKey: next.executor_key,
contextJson: next.context_json,
updatedAt: next.updated_at,
}, client.query.bind(client) as TaskQueryExecutor)
await syncKuaishouCloudTaskStateForTask(
{
taskId,
executorKey: next.executor_key,
contextJson: next.context_json,
updatedAt: next.updated_at,
},
client.query.bind(client) as TaskQueryExecutor,
)
return getTaskByIdWithExecutor(client.query.bind(client) as TaskQueryExecutor, taskId)
})
@@ -296,12 +316,15 @@ export async function updateTaskStatusIfCurrent(
return null
}
await syncKuaishouCloudTaskStateForTask({
taskId: updated.id,
executorKey: updated.executor_key,
contextJson: updated.context_json,
updatedAt: updated.updated_at,
}, client.query.bind(client) as TaskQueryExecutor)
await syncKuaishouCloudTaskStateForTask(
{
taskId: updated.id,
executorKey: updated.executor_key,
contextJson: updated.context_json,
updatedAt: updated.updated_at,
},
client.query.bind(client) as TaskQueryExecutor,
)
return getTaskByIdWithExecutor(client.query.bind(client) as TaskQueryExecutor, taskId)
})
@@ -311,7 +334,9 @@ export async function getTaskById(taskId: number | string): Promise<TaskRow | nu
return getTaskByIdWithExecutor(query, taskId)
}
export async function findTaskByClaimTokenId(claimTokenId: number | string): Promise<TaskRow | null> {
export async function findTaskByClaimTokenId(
claimTokenId: number | string,
): Promise<TaskRow | null> {
const result = await query<TaskRow>(
`${buildTaskSelect()}
JOIN claim_tokens ctf ON ctf.task_id = ft.id
@@ -441,7 +466,7 @@ export async function listTasks({
}
const whereClause = filters.length > 0 ? `WHERE ${filters.join(' AND ')}` : ''
const totalResult = await query<{ [column: string]: unknown, total: number }>(
const totalResult = await query<{ [column: string]: unknown; total: number }>(
`
SELECT COUNT(*)::int AS total
FROM fulfillment_tasks ft
@@ -525,8 +550,12 @@ async function upsertTaskRuntimeContextWithClient(
next.area,
next.partition_name,
next.screenshot_path,
typeof next.artifacts_json === 'string' ? next.artifacts_json : JSON.stringify(next.artifacts_json || {}),
typeof next.state_json === 'string' ? next.state_json : JSON.stringify(next.state_json || {}),
typeof next.artifacts_json === 'string'
? next.artifacts_json
: JSON.stringify(next.artifacts_json || {}),
typeof next.state_json === 'string'
? next.state_json
: JSON.stringify(next.state_json || {}),
timestamp,
timestamp,
],
@@ -560,7 +589,9 @@ async function upsertTaskRuntimeContextWithClient(
next.area,
next.partition_name,
next.screenshot_path,
typeof next.artifacts_json === 'string' ? next.artifacts_json : JSON.stringify(next.artifacts_json || {}),
typeof next.artifacts_json === 'string'
? next.artifacts_json
: JSON.stringify(next.artifacts_json || {}),
typeof next.state_json === 'string' ? next.state_json : JSON.stringify(next.state_json || {}),
timestamp,
Number(taskId),