/************************************************************************* * ADOBE CONFIDENTIAL * ___________________ * * Copyright 2024 Adobe * All Rights Reserved. * * NOTICE: All information contained herein is, and remains * the property of Adobe and its suppliers, if any. The intellectual * and technical concepts contained herein are proprietary to Adobe * and its suppliers and are protected by all applicable intellectual * property laws, including trade secret and copyright laws. * Dissemination of this information or reproduction of this material * is strictly forbidden unless prior written permission is obtained * from Adobe. **************************************************************************/ import { ApiError } from "./ApiError"; import { ApiResponse } from "./ApiResponse"; export declare enum AsyncJobState { PENDING = "PENDING", IN_PROGRESS = "IN_PROGRESS", COMPLETED = "COMPLETED", FAILED = "FAILED", CANCELLED = "CANCELLED" } export type StatusChangeCallback = (state: AsyncJobState) => void; export declare abstract class AsyncJobPromise implements PromiseLike> { private _oldState; protected _state: AsyncJobState; private _deferred; protected _response?: ApiResponse; protected _error?: ApiError | Error | undefined; private _stautsChangeHandlers; constructor(); /** * This method should be implemented by the concrete class to check the status of the job. */ protected abstract _fetchJobStatus(): Promise; then, TResult2 = never>(onfulfilled?: ((value: ApiResponse) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined): PromiseLike; catch(onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise | TResult>; finally(onfinally?: () => void): Promise>; /** * @returns The result of the job if the job has completed successfully. */ getResult(): ApiResponse; /** * @returns The error details if the job has failed. */ getError(): ApiError | Error | undefined; /** * Gets the next time in milliseconds when the job status should be checked again. * This method should be implemented by the concrete class to provide an accurate value based on the value provided by the server. * @returns The next time in milliseconds when the job status should be checked again. Default value is 2000 milliseconds. */ protected _getNextRetryTimeInMilliSecs(): number; /** * Checks if the job is done. * @returns true if the job is done, false otherwise. */ private _isDone; /** * When the job is done, this method is called to resolve or reject the promise. */ private _fullfillPromise; /** * Polls the status of the job at regular intervals, till the job is done. */ private _pollJobStatus; /** * Check for status change and Notify listeners */ private _checkNDispatchStateChange; }