@tableau/taco-toolkit
Version:
Tableau Connector Toolkit
25 lines (24 loc) • 1.18 kB
TypeScript
import superagent from 'superagent';
import { HTTPMethod } from '../../shared/types/http';
import { NetworkAdapterFetchOptions } from '../modules/network-adapter';
export interface ResponseError extends Error {
status: number;
response: superagent.Response;
}
/**
* Check if Error is thrown from superagent due to reponse with 4xx, 5xx status.
* For 4xx, 5xx status, superagent throws Error object with status and response.
*/
export declare function isResponseError(value: unknown): value is ResponseError;
export declare function composeFetchOption(method: Extract<HTTPMethod, 'GET' | 'POST'>, headers: Record<string, unknown> | undefined, body: string | object | undefined): NetworkAdapterFetchOptions;
/**
* Get media type part from Content-Type header value, and returns it in lowercase.
*
* Reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type#syntax
*/
export declare function getContentType(contentTypeHeader: string): string;
/**
* Parse form string into key-value pair object.
*/
export declare function parseFormData(value: string): Record<string, string>;
export declare function isRedirectCode(code: number): boolean;