UNPKG

1.68 kBTypeScriptView Raw
1// Type definitions for request-promise 4.1
2// Project: https://github.com/request/request-promise
3// Definitions by: Christopher Glantschnig <https://github.com/cglantschnig>
4// Joe Skeen <https://github.com/joeskeen>
5// Aya Morisawa <https://github.com/AyaMorisawa>
6// Matt R. Wilson <https://github.com/mastermatt>
7// Sergey Bakulin <https://github.com/vansergen>
8// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
9// TypeScript Version: 3.2
10
11import request = require('request');
12import http = require('http');
13import errors = require('./errors');
14import Promise = require('bluebird');
15
16declare namespace requestPromise {
17 interface RequestPromise<T = any> extends request.Request {
18 then: Promise<T>['then'];
19 catch: Promise<T>['catch'];
20 finally: Promise<T>['finally'];
21 cancel: Promise<T>['cancel'];
22 promise(): Promise<T>;
23 }
24
25 interface RequestPromiseOptions extends request.CoreOptions {
26 simple?: boolean | undefined;
27 transform?(body: any, response: request.Response, resolveWithFullResponse?: boolean): any;
28 transform2xxOnly?: boolean | undefined;
29 resolveWithFullResponse?: boolean | undefined;
30 }
31
32 type RequestPromiseAPI<T= any> = request.RequestAPI<RequestPromise<T>, RequestPromiseOptions, request.RequiredUriUrl>;
33 type OptionsWithUri = request.UriOptions & RequestPromiseOptions;
34 type OptionsWithUrl = request.UrlOptions & RequestPromiseOptions;
35 type Options = OptionsWithUri | OptionsWithUrl;
36}
37
38declare const requestPromise: requestPromise.RequestPromiseAPI;
39export = requestPromise;