import type { IResponseError } from "@webiny/api-core/features/task/TaskDefinition"; import type { TaskDataStatus } from "../../../api/types.js"; import { type ITaskTriggerParams, TaskService } from "@webiny/api-core/features/task/TaskService/index.js"; import { TaskDefinition } from "@webiny/api-core/features/task/TaskDefinition/index.js"; import type { ITaskResponse } from "../../../api/response/abstractions/index.js"; import { Result } from "@webiny/feature/api"; import { BaseError } from "@webiny/feature/api/index.js"; /** * Augment the TaskController interface from api-core with implementation details. * This allows developers to import from @webiny/api-core but get the full interface. */ declare module "@webiny/api-core/features/task/TaskController/abstractions.js" { interface ITaskController { /** * Response object */ response: ITaskResponse; /** * State management - access and update task state */ state: { getTask(): TaskService.Task; getStatus(): TaskDataStatus; getInput(): I; getOutput(): O | undefined; updateInput(input: Partial): Promise; updateOutput(output: Partial): Promise; }; /** * Logging - add log entries to task */ logger: { info(params: { message: string; data?: Record; }): Promise; error(params: { message: string; error?: Error | IResponseError; data?: Record; }): Promise; }; /** * Task management - trigger and query child tasks */ task: { trigger(params: ITaskTriggerParams): Promise, BaseError>>; listChildren(definitionId?: string): Promise[]>; }; /** * Runtime checks */ runtime: { isCloseToTimeout(seconds?: number): boolean; isAborted(): boolean; getRemainingSeconds(): number; getRemainingMilliseconds(): number; }; } }