import { Observable, Observer, Subject } from 'rxjs'; /** * Step operation execution manager * * Template type T: the event type. It's the return type of each operations * Template type DataType: context additional DataType * @experimental */ export declare class StepOperations> { private operationContainers; private _state; _taskErrorHandler?: StepOperations.ErrorHandler; _currentExecutionEvents?: Subject; _events: Subject; get isCancelled(): boolean; get isCompleted(): boolean; get state(): StepOperations.State; get events(): Observable; set taskErrorHandler(errorHandler: StepOperations.ErrorHandler | undefined); get operations(): StepOperations.Operation[]; constructor(operationContainers: StepOperations.OperationContainer[]); static createSequentialContainers = any>(operations: StepOperations.OperationType[]): StepOperations.OperationContainer[]; static sequential = any>(operations: StepOperations.OperationType[]): StepOperations; runEvents(): Observable; /** * Reset as if operations were never executed. * Will call onReset callback for each Operation if defined. * @returns this */ reset(): this; /** * Will retry from the last failed operation. * Call 'onRetry' callback for each Operation if definied. * * If all operations where successfully executed, it will do nothing. * * Call reset() first if you want to run operations again. */ retry(): Observable; /** * Execute operations * If it already running, do nothing * */ run(): Observable; /** * Cancel running operations */ cancel(): void; /** * Transform this operation as an observable * Subscribe to observable to run operation * Unsubscribe to cancel operation * * Each time you call this method, a new observable is created */ asObservable(): Observable; private checkIsCancelled; private checkIsRunning; private _onTaskError; private _start; private onComplete; private onError; } export declare class StepOperationsError extends Error { code: string; constructor(code: string, msg: string); static cancel(): StepOperationsError; static unknown(msg: string): StepOperationsError; } export declare namespace StepOperationsError { enum Code { UNKNOWN_ERROR = "STEP_OPERATION_UNKNOWN_ERROR", STEP_OPERATION_CANCEL = "STEP_OPERATION_CANCEL" } } export declare namespace StepOperations { interface OperationContainer> { index: number; done?: boolean; result?: T; error?: Error; operation: Operation; } interface ErrorHandler { handle(err: Error, context: Context): void; } type OperationFct = any> = (observer: Observer, context: Context) => Promise; interface Operation = any> { alias?: string; onRetry?: () => void; onReset?: () => void; perform(observer: Observer, context: Context): Promise; } type OperationType = any> = Operation | OperationFct | Observable; interface Context = any> { position: number; total: number; index: number; prevOperation?: StepOperations.OperationContainer; data: DataType; } enum State { PENDING = "PENDING", RUNNING = "RUNNING", COMPLETED = "COMPLETED", CANCELED = "CANCELED", ERRORED = "ERRORED" } } export declare class IgnoreErrorStrategy { }