import { BaseError, Result } from "@webiny/feature/api"; import type { GenericRecord } from "@webiny/api/types.js"; import { type ITaskOutput, TaskDefinition } from "../../../features/task/TaskDefinition/index.js"; /** Trigger and manage long-running background tasks. */ export declare const TaskService: import("@webiny/di").Abstraction; export declare namespace TaskService { type Interface = ITaskService; /** * This is the output of `trigger` and `abort` actions. */ type GenericOutput = IGenericOutput; type TaskInput = TaskDefinition.TaskInput; type Task = ITask; } export type IServiceInfo = GenericRecord; export interface IResponseError { message: string; code?: string | null; data?: GenericRecord | null; stack?: string; } export interface ITaskAbortParams { id: string; message?: string; } export interface ITaskService { trigger: (params: ITaskTriggerParams) => Promise, BaseError>>; abort: (params: ITaskAbortParams) => Promise, BaseError>>; fetchServiceInfo: (input: ITask | string) => Promise>; } export interface IGenericOutput { error?: IResponseError; [key: string]: string | string[] | number | boolean | undefined | Record | IResponseError; } export interface ITaskTriggerParams { parent?: Pick; definition: string; name?: string; input?: I; delay?: number; } export interface ITaskValues { startedOn?: string; finishedOn?: string; eventResponse: GenericRecord | undefined; iterations: number; parentId?: string; name: string; taskStatus: TaskDataStatus; definitionId: string; executionName: string; input: T; output?: O; } export interface ITask extends ITaskValues { /** * ID without the revision number (for example: #0001). */ id: string; createdOn: string; savedOn: string; createdBy: ITaskIdentity; } export declare enum TaskDataStatus { PENDING = "pending", RUNNING = "running", FAILED = "failed", SUCCESS = "success", ABORTED = "aborted" } export interface ITaskIdentity { id: string; displayName: string; type: string; }