* 更新任务位置(用于拖拽排序) * 如果同时传了 status,会进行状态流转并通知前端
(id: string, position: number, status?: TaskStatus)
| 523 | description: true, |
| 524 | }, |
| 525 | }); |
| 526 | |
| 527 | if (!task) { |
| 528 | throw new NotFoundError('Task', id); |
| 529 | } |
| 530 | |
| 531 | const hasDescription = Boolean(task.description?.trim()); |
| 532 | const titlePreview = buildTextPreview(task.title, TASK_TITLE_MAX_LENGTH); |
| 533 | const usesHistoricalTitleBody = |
| 534 | !hasDescription |
| 535 | && (task.title.length > TASK_HISTORICAL_TITLE_BODY_THRESHOLD || task.title !== titlePreview); |
| 536 | const body = hasDescription |
| 537 | ? task.description! |
| 538 | : usesHistoricalTitleBody |
| 539 | ? task.title |
| 540 | : ''; |
| 541 | const prompt = hasDescription |
| 542 | ? buildTaskPrompt(task) |
| 543 | : usesHistoricalTitleBody |
| 544 | ? task.title |
| 545 | : task.title.trim(); |
| 546 | |
| 547 | return { |
| 548 | taskId: task.id, |
| 549 | title: titlePreview, |
| 550 | titlePreview, |
| 551 | body, |
| 552 | bodySource: hasDescription ? 'description' : usesHistoricalTitleBody ? 'historical_title' : 'none', |
| 553 | prompt, |
| 554 | isTruncated: task.title !== titlePreview, |
| 555 | }; |
| 556 | } |
| 557 | |
| 558 | /** |
| 559 | * 创建任务 |
| 560 | * - 校验项目存在 |
| 561 | * - 自动计算 position(同状态下最大 position + 1) |
| 562 | */ |
| 563 | async create(projectId: string, input: CreateTaskInput) { |
| 564 | const normalizedInput = normalizeCreateTaskInput(input); |
no test coverage detected