import { TransportStatusErrorClassType, CustomErrorClassType } from "@ledgerhq/errors"; import { Observable } from "rxjs"; import { Transport, TransportRef } from "../transports/core"; import { DmkError } from "@ledgerhq/device-management-kit"; export type SharedTaskEvent = { type: "error"; error: Error; retrying: boolean; }; export declare const NO_RESPONSE_TIMEOUT_MS = 30000; export declare const RETRY_ON_ERROR_DELAY_MS = 500; export declare const LOG_TYPE = "device-sdk-task"; /** * Wraps a task function to add some common logic to it: * - Timeout for no response * - Retry strategy on specific errors: those errors are fixed for all tasks * - Catch errors and emit them as events * * @param task The task function to wrap * @returns A wrapped task function */ export declare function sharedLogicTaskWrapper(task: (args: TaskArgsType) => Observable, defaultTimeoutOverride?: number): (args: TaskArgsType) => Observable; type ErrorClass = CustomErrorClassType | TransportStatusErrorClassType; type CommandTransportArgs = { transport: Transport; }; export declare const isDmkError: (error: unknown) => error is DmkError; /** * Calls a command and retries it on given errors. The transport is refreshed before each retry. * * The no response timeout is handled at the task level * * @param command the command to wrap, it should take as argument an object containing a transport * @param transportRef a reference to the transport, that can be updated/refreshed * @param allowedErrors a list of errors to retry on * - errorClass: the error class to retry on * - maxRetries: the maximum number of retries for this error */ export declare function retryOnErrorsCommandWrapper({ command, allowedErrors, allowedDmkErrors, }: { command: (args: CommandArgsWithoutTransportType & CommandTransportArgs) => Observable; allowedErrors: { errorClass: ErrorClass; maxRetries: number | "infinite"; }[]; allowedDmkErrors?: DmkError[]; }): (transportRef: TransportRef, argsWithoutTransport: CommandArgsWithoutTransportType) => Observable; export {}; //# sourceMappingURL=core.d.ts.map