clientnode
Version:
upgrade to object orientated rock solid plugins
71 lines (70 loc) • 3.98 kB
TypeScript
import { $T, CheckReachabilityOptions, Mapping, RecursivePartial } from './type';
/**
* Checks if given url response with given status code.
* @param url - Url to check reachability.
* @param givenOptions - Options to configure.
* @param givenOptions.wait - Boolean indicating if we should retry until a
* status code will be given.
* @param givenOptions.statusCodes - Status codes to check for.
* @param givenOptions.timeoutInSeconds - Delay after assuming given resource
* isn't available if no response is coming.
* @param givenOptions.pollIntervallInSeconds - Seconds between two tries to
* reach given url.
* @param givenOptions.options - Fetch options to use.
* @param givenOptions.expectedIntermediateStatusCodes - A list of expected but
* unwanted response codes. If detecting them waiting will continue until an
* expected (positive) code occurs or timeout is reached.
* @returns A promise which will be resolved if a request to given url has
* finished and resulting status code matches given expected status code.
* Otherwise, returned promise will be rejected.
*/
export declare const checkReachability: (url: string, givenOptions?: RecursivePartial<CheckReachabilityOptions>) => ReturnType<typeof fetch>;
/**
* Checks if given url isn't reachable.
* @param url - Url to check reachability.
* @param givenOptions - Options to configure.
* @param givenOptions.wait - Boolean indicating if we should retry until a
* status code will be given.
* @param givenOptions.timeoutInSeconds - Delay after assuming given resource
* will stay available.
* @param givenOptions.pollIntervallInSeconds - Seconds between two tries to
* reach given url.
* @param givenOptions.statusCodes - Status codes to check for.
* @param givenOptions.options - Fetch options to use.
* @returns A promise which will be resolved if a request to given url couldn't
* be finished. Otherwise, returned promise will be rejected. If "wait" is set
* to "true" we will resolve to another promise still resolving when final
* timeout is reached or the endpoint is unreachable (after some tries).
*/
export declare const checkUnreachability: (url: string, givenOptions?: RecursivePartial<CheckReachabilityOptions>) => Promise<Error | null | Promise<Error | null>>;
/**
* Preloads a given url via a temporary created image element.
* @param url - To image which should be downloaded.
* @returns A Promise indicating whether the image was loaded.
*/
export declare const cacheImage: (url: string) => Promise<void>;
/**
* Send given data to a given iframe.
* @param target - Name of the target iframe or the target iframe itself.
* @param url - URL to send to data to.
* @param data - Data holding object to send data to.
* @param requestType - The forms action attribute value. If nothing is
* provided "post" will be used as default.
* @param removeAfterLoad - Indicates if created iframe should be removed right
* after load event. Only works if an iframe object is given instead of a
* simple target name.
* @returns Returns the given target as extended dom node.
*/
export declare const sendToIFrame: (target: $T<HTMLIFrameElement> | HTMLIFrameElement | string, url: string, data: Mapping<unknown>, requestType?: string, removeAfterLoad?: boolean) => $T<HTMLIFrameElement>;
/**
* Send given data to a temporary created iframe.
* @param url - URL to send to data to.
* @param data - Data holding object to send data to.
* @param requestType - The forms action attribute value. If nothing is
* provided "post" will be used as default.
* @param removeAfterLoad - Indicates if created iframe should be removed right
* after load event.
* @param domNode - Optional dom node to append dynamically created iframe to.
* @returns Returns the dynamically created iframe.
*/
export declare const sendToExternalURL: (url: string, data: Mapping<unknown>, requestType?: string, removeAfterLoad?: boolean, domNode?: HTMLElement | null) => $T<HTMLIFrameElement>;