import { TaskStore } from './store.js';
import { TaskLifecycleService } from './taskLifecycleService.js';
import { TaskQueryService } from './taskQueryService.js';
import { TaskDeletionService } from './taskDeletionService.js';
import { TaskExceedService } from './taskExceedService.js';
import { TaskRetryService } from './taskRetryService.js';
export class TaskRunner {
    projectDir;
    store;
    tasksFile;
    lifecycle;
    query;
    deletion;
    exceed;
    retry;
    constructor(projectDir, options) {
        this.projectDir = projectDir;
        this.store = new TaskStore(projectDir);
        this.tasksFile = this.store.getTasksFilePath();
        this.lifecycle = new TaskLifecycleService(projectDir, this.tasksFile, this.store, options?.onWarning);
        this.query = new TaskQueryService(projectDir, this.tasksFile, this.store);
        this.deletion = new TaskDeletionService(this.store);
        this.exceed = new TaskExceedService(this.store);
        this.retry = new TaskRetryService(projectDir, this.tasksFile, this.store);
    }
    ensureDirs() {
        this.store.ensureDirs();
    }
    getTasksFilePath() {
        return this.tasksFile;
    }
    addTask(content, options) {
        return this.lifecycle.addTask(content, options);
    }
    listTasks() {
        return this.query.listTasks();
    }
    claimNextTasks(count) {
        return this.lifecycle.claimNextTasks(count);
    }
    recoverInterruptedRunningTasks() {
        return this.lifecycle.recoverInterruptedRunningTasks();
    }
    completeTask(result) {
        return this.lifecycle.completeTask(result);
    }
    failTask(result) {
        return this.lifecycle.failTask(result);
    }
    forceFailRunningTask(taskName, failure) {
        return this.lifecycle.forceFailRunningTask(taskName, failure);
    }
    updateRunningTaskExecution(taskName, execution) {
        return this.lifecycle.updateRunningTaskExecution(taskName, execution);
    }
    prFailTask(result, prError) {
        return this.lifecycle.prFailTask(result, prError);
    }
    listPendingTaskItems() {
        return this.query.listPendingTaskItems();
    }
    listAllTaskItems() {
        return this.query.listAllTaskItems();
    }
    listFailedTasks() {
        return this.query.listFailedTasks();
    }
    listExceededTasks() {
        return this.query.listExceededTasks();
    }
    requeueFailedTask(taskRef, startStep, retryNote) {
        return this.retry.requeueFailedTask(taskRef, startStep, retryNote);
    }
    requeueTask(taskRef, allowedStatuses, startStep, retryNote, resumePoint, workflow, taskDir) {
        return this.retry.requeueTask(taskRef, allowedStatuses, startStep, retryNote, resumePoint, workflow, taskDir);
    }
    startReExecution(taskRef, allowedStatuses, startStep, retryNote, resumePoint, workflow, taskDir) {
        return this.retry.startReExecution(taskRef, allowedStatuses, startStep, retryNote, resumePoint, workflow, taskDir);
    }
    deleteTask(name, kind) {
        this.deletion.deleteTaskByNameAndStatus(name, kind);
    }
    exceedTask(taskName, options) {
        this.exceed.exceedTask(taskName, options);
    }
    requeueExceededTask(taskName) {
        this.exceed.requeueExceededTask(taskName);
    }
}
//# sourceMappingURL=runner.js.map