UNPKG

2.2 kBTypeScriptView Raw
1import { ApiResponse } from "./xhr";
2/**
3 * Utility methods. Mostly private
4 *
5 * @module util
6 * @class util
7 *
8 */
9/**
10 * Gooddata-js package signature
11 * @private
12 */
13export declare const thisPackage: {
14 name: string;
15 version: string;
16};
17/**
18 * Create getter function for accessing nested objects
19 *
20 * @param {String} path Target path to nested object
21 * @method getIn
22 * @private
23 */
24export declare const getIn: (path: string) => (object: any) => any;
25export interface IPollingOptions {
26 attempts?: number;
27 maxAttempts?: number;
28 pollStep?: number;
29}
30/**
31 * Helper for polling
32 *
33 * @param xhrRequest xhr module
34 * @param {String} uri
35 * @param {Function} isPollingDone
36 * @param {Object} options for polling (maxAttempts, pollStep)
37 * @private
38 */
39export declare const handlePolling: (xhrRequest: any, uri: string, isPollingDone: (response: any) => boolean, options?: IPollingOptions) => any;
40/**
41 * Helper for polling with header status
42 *
43 * @param xhrRequest xhr module
44 * @param {String} uri
45 * @param {Function} isPollingDone
46 * @param {Object} options for polling (maxAttempts, pollStep)
47 * @private
48 */
49export declare const handleHeadPolling: (xhrRequest: any, uri: string, isPollingDone: (responseHeaders: Response, response: ApiResponse) => boolean, options?: IPollingOptions) => any;
50/**
51 * Builds query string from plain object
52 * (Refactored from admin/routes.js)
53 *
54 * @param {Object} query parameters possibly including arrays inside
55 * @returns {string} querystring
56 */
57export declare function queryString(query: any): string;
58/**
59 * Get all results from paged api by traversing all resulting pages
60 * This is usable for apis which support offset and limit (i.e. not those with next paging links)
61 *
62 * @param xhrGet xhr module
63 * @param {string} uri uri to be fetched, will append offset and limit for next pages
64 * @param {string} itemKey key under which to look for results (differs for different apis)
65 * @param {number} optional offset starting offset, default 0
66 * @param pagesData optional data to be pre-filled
67 */
68export declare function getAllPagesByOffsetLimit(xhr: any, uri: string, itemKey: string, offset?: number, pagesData?: any[]): Promise<{}>;