( path: string, options?: CompleteTaskOptions, context?: TaskNotesMutationContext )
| 1958 | } |
| 1959 | |
| 1960 | async completeTask( |
| 1961 | path: string, |
| 1962 | options?: CompleteTaskOptions, |
| 1963 | context?: TaskNotesMutationContext |
| 1964 | ): Promise<TaskInfo> { |
| 1965 | const task = await this.requireTask(path); |
| 1966 | const targetStatus = |
| 1967 | options?.status ?? this.plugin.statusManager.getCompletedStatuses()[0] ?? "done"; |
| 1968 | |
| 1969 | if (!this.plugin.statusManager.isCompletedStatus(targetStatus)) { |
| 1970 | throw new TaskNotesApiError( |
| 1971 | "invalid_status", |
| 1972 | `Status "${targetStatus}" is not configured as a completed status`, |
| 1973 | { status: 400, details: { status: targetStatus } } |
| 1974 | ); |
| 1975 | } |
| 1976 | |
| 1977 | if (!options?.status && this.plugin.statusManager.isCompletedStatus(task.status)) { |
| 1978 | return copyTaskInfo(task); |
| 1979 | } |
| 1980 | |
| 1981 | const updatedTask = await this.withMutationContext([task.path], context, () => |
| 1982 | this.plugin.taskService.updateProperty(task, "status", targetStatus) |
| 1983 | ); |
| 1984 | return copyTaskInfo(updatedTask); |
| 1985 | } |
| 1986 | |
| 1987 | async rescheduleTask( |
| 1988 | path: string, |
no test coverage detected