mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-01 19:45:48 +08:00
74 lines
2.8 KiB
TypeScript
74 lines
2.8 KiB
TypeScript
// Type definitions for request-promise-native 1.0
|
|
// Project: https://github.com/request/request-promise-native
|
|
// Definitions by: Gustavo Henke <https://github.com/gustavohenke>
|
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
|
|
declare module 'request-promise-native' {
|
|
import request = require('request');
|
|
import http = require('http');
|
|
|
|
namespace requestPromise {
|
|
interface RequestPromise extends request.Request, Promise<any> {
|
|
promise(): Promise<any>;
|
|
}
|
|
|
|
interface RequestPromiseOptions extends request.CoreOptions {
|
|
simple?: boolean;
|
|
transform?(body: any, response: http.IncomingMessage, resolveWithFullResponse?: boolean): any;
|
|
resolveWithFullResponse?: boolean;
|
|
}
|
|
|
|
type FullResponse = request.RequestResponse;
|
|
type OptionsWithUri = request.UriOptions & RequestPromiseOptions;
|
|
type OptionsWithUrl = request.UrlOptions & RequestPromiseOptions;
|
|
type Options = OptionsWithUri | OptionsWithUrl;
|
|
}
|
|
|
|
let requestPromise: request.RequestAPI<requestPromise.RequestPromise, requestPromise.RequestPromiseOptions, request.RequiredUriUrl>;
|
|
export = requestPromise;
|
|
}
|
|
|
|
declare module 'request-promise-native/errors' {
|
|
import rp = require('request-promise-native');
|
|
import http = require('http');
|
|
|
|
interface RequestError extends Error {
|
|
cause: any;
|
|
error: any;
|
|
options: rp.Options;
|
|
response: http.IncomingMessage;
|
|
}
|
|
interface RequestErrorConstructor {
|
|
new(cause: any, options: rp.Options, response: http.IncomingMessage): RequestError;
|
|
(cause: any, options: rp.Options, response: http.IncomingMessage): RequestError;
|
|
prototype: RequestError;
|
|
}
|
|
const RequestError: RequestErrorConstructor;
|
|
|
|
interface StatusCodeError extends Error {
|
|
statusCode: number;
|
|
error: any;
|
|
options: rp.Options;
|
|
response: http.IncomingMessage;
|
|
}
|
|
interface StatusCodeErrorConstructor extends Error {
|
|
new(statusCode: number, body: any, options: rp.Options, response: http.IncomingMessage): StatusCodeError;
|
|
(statusCode: number, body: any, options: rp.Options, response: http.IncomingMessage): StatusCodeError;
|
|
prototype: StatusCodeError;
|
|
}
|
|
const StatusCodeError: StatusCodeErrorConstructor;
|
|
|
|
interface TransformError extends Error {
|
|
cause: any;
|
|
error: any;
|
|
options: rp.Options;
|
|
response: http.IncomingMessage;
|
|
}
|
|
interface TransformErrorConstructor extends Error {
|
|
new(cause: any, options: rp.Options, response: http.IncomingMessage): TransformError;
|
|
(cause: any, options: rp.Options, response: http.IncomingMessage): TransformError;
|
|
prototype: TransformError;
|
|
}
|
|
const TransformError: TransformErrorConstructor;
|
|
}
|