import { DefaultOutput, ParamValues, DefaultParams } from "../../client/executeTask"; import { ExecuteError, TaskMutation, RefetchQuery } from "../../components/query"; export type MutationHookOptions = { /** * The params of the task to execute. */ params?: TParams; /** * If set, the provided tasks will be refetched on success. * * This can be useful if you expect the task mutation to invalidate data. */ refetchTasks?: RefetchQuery | RefetchQuery[]; /** * Callback on successful task execution. */ onSuccess?: (output: TOutput, runID: string) => void; /** * Callback on failed task execution. */ onError?: (output: TOutput | undefined, error: ExecuteError, runID?: string) => void; }; export type MutationFn = (options?: MutationHookOptions) => void; export type MutationState = { /** * The output of the last successfully executed task. */ output?: TOutput; /** * Will be true when the task is currently executing. */ loading?: boolean; /** * Will be set with the error message if the task failed to execute. */ error?: ExecuteError; /** * The ID of the run. */ runID?: string; }; export type MutationResult = { /** * Function that executes the task mutation. */ mutate: MutationFn; } & MutationState; /** * useTaskMutation executes a task. * * This should be used for tasks that create/update/delete data. */ export declare const useTaskMutation: (mutation: TaskMutation) => MutationResult;