* 获取项目的任务列表(支持按状态过滤和分页)
(projectId: string, params: FindTasksParams = {})
| 258 | return description ?? undefined; |
| 259 | } |
| 260 | if (!description?.trim()) { |
| 261 | return body; |
| 262 | } |
| 263 | return `${body}\n\n${description}`; |
| 264 | } |
| 265 | |
| 266 | function normalizeCreateTaskInput(input: CreateTaskInput): Required<Pick<CreateTaskInput, 'title'>> & Pick<CreateTaskInput, 'description' | 'priority'> { |
| 267 | const rawTitle = input.title; |
| 268 | const compactTitle = compactWhitespace(rawTitle); |
| 269 | if (compactTitle.length === 0) { |
| 270 | throw new ValidationError('Task title is required'); |
| 271 | } |
| 272 | |
| 273 | if (!needsBodySplit(rawTitle, compactTitle)) { |
| 274 | return { |
| 275 | title: normalizeTaskTitle(rawTitle), |
| 276 | description: input.description, |
| 277 | priority: input.priority, |
| 278 | }; |
| 279 | } |
| 280 | |
| 281 | const split = deriveTaskTitleBodySplit(rawTitle); |
| 282 | return { |
| 283 | title: split.title, |
| 284 | description: mergeAutosplitDescription(split.body, input.description), |
| 285 | priority: input.priority, |
| 286 | }; |
| 287 | } |
| 288 | |
| 289 | function normalizeUpdateTaskInput( |
| 290 | current: { description?: string | null }, |
| 291 | input: UpdateTaskInput |
| 292 | ): UpdateTaskInput { |
| 293 | if (input.title === undefined) { |
| 294 | return input; |
| 295 | } |
| 296 | |
| 297 | const rawTitle = input.title; |
| 298 | const compactTitle = compactWhitespace(rawTitle); |
| 299 | if (compactTitle.length === 0) { |
| 300 | throw new ValidationError('Task title is required'); |
| 301 | } |
| 302 | |
| 303 | if (!needsBodySplit(rawTitle, compactTitle)) { |
| 304 | return { |
| 305 | ...input, |
| 306 | title: normalizeTaskTitle(rawTitle), |
| 307 | }; |
| 308 | } |
| 309 | |
| 310 | return { |
| 311 | ...input, |
| 312 | title: deriveTitleFromBody(rawTitle), |
| 313 | description: mergeDescriptionParts([ |
| 314 | rawTitle, |
| 315 | input.description, |
| 316 | current.description, |
| 317 | ]), |
no test coverage detected