/** * Importing npm packages */ import { Promisable } from 'type-fest'; import { Fn } from '../interfaces/index.js'; /** * Defining types */ export type RetryCallback = (error: unknown, attempt: number) => Promisable; export type RollbackFn = (data: T) => Promisable; export type ShouldRetryFn = (error: unknown, attempt: number) => Promisable; /** * Declaring the constants */ export declare class Task { private readonly fn; private static readonly logger; private taskName; private retries; private delayMs; private backoffFactor; private result?; private retryCallback?; private rollbackFn?; private shouldRetryFn?; private constructor(); static create(fn: Fn): Task; name(name: string): this; retry(retries: number): this; delay(delayMs: number): this; backoff(backoffFactor: number): this; onRetry(callback: RetryCallback): this; hasRollback(): boolean; rollback(rollbackFn: RollbackFn): this; shouldRetry(fn: ShouldRetryFn): this; execute(): Promise; executeRollback(): Promise; }