mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-02 14:38:20 +08:00
wreck: Updating type definitions to v14.0.0.
This commit is contained in:
@@ -25,6 +25,9 @@
|
||||
],
|
||||
"inert": [
|
||||
"inert/v4"
|
||||
],
|
||||
"wreck": [
|
||||
"wreck/v7"
|
||||
]
|
||||
},
|
||||
"noEmit": true,
|
||||
|
||||
70
types/wreck/index.d.ts
vendored
70
types/wreck/index.d.ts
vendored
@@ -1,27 +1,70 @@
|
||||
// Type definitions for wreck 7.0.0
|
||||
// Type definitions for wreck 14.0.0
|
||||
// Project: https://github.com/hapijs/wreck
|
||||
// Definitions by: Marcin Porębski <https://github.com/marcinporebski>
|
||||
// Rodrigo Saboya <https://github.com/saboya>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
|
||||
import http = require('http');
|
||||
import stream = require('stream');
|
||||
import * as Boom from "boom";
|
||||
import * as events from "events";
|
||||
import * as http from "http";
|
||||
import * as stream from "stream";
|
||||
import * as Url from "url";
|
||||
|
||||
interface RequestOptions {
|
||||
baseUrl?: string;
|
||||
socketPath? : string;
|
||||
payload?: any;
|
||||
headers?: { [key: string]: any };
|
||||
redirects?: number;
|
||||
redirect303?: boolean;
|
||||
beforeRedirect?: (redirectMethod: string, statusCode: number, location: string, resHeaders: { [key: string]: any }, redirectOptions: any, next: () => {}) => void;
|
||||
redirected?: (statusCode: number, location: string, req: http.ClientRequest) => void;
|
||||
timeout?: number;
|
||||
maxBytes?: number;
|
||||
rejectUnauthorized?: boolean;
|
||||
downstreamRes?: any;
|
||||
agent?: WreckObject["agents"] | false;
|
||||
secureProtocol?: string;
|
||||
ciphers?: string;
|
||||
events?: boolean;
|
||||
}
|
||||
|
||||
interface ReadOptions {
|
||||
timeout?: number;
|
||||
json?: true | "strict" | "force";
|
||||
gunzip?: boolean | "force";
|
||||
maxBytes?: number;
|
||||
}
|
||||
|
||||
interface RequestResponse {
|
||||
res: http.IncomingMessage,
|
||||
payload: any,
|
||||
}
|
||||
|
||||
declare type RequestCallback = (uri: string, options: RequestOptions & { payload?: any }) => void;
|
||||
declare type ResponseCallback = (err: Boom | undefined, details: { req: http.ClientRequest, res: http.IncomingMessage | undefined, start: number, url: Url.URL }) => void;
|
||||
|
||||
declare class WreckEventEmitter extends events.EventEmitter {
|
||||
on(event: "request", listener: RequestCallback): this;
|
||||
on(event: "response", listener: ResponseCallback): this;
|
||||
}
|
||||
|
||||
interface WreckObject {
|
||||
defaults: (options: any) => WreckObject;
|
||||
defaults: (options: RequestOptions) => WreckObject;
|
||||
|
||||
request: (method: string, uri: string, options: any, callback?: (err: any, response: http.IncomingMessage) => void) => http.ClientRequest;
|
||||
request: (method: string, uri: string, options: RequestOptions) => Promise<http.IncomingMessage> & { req: http.ClientRequest };
|
||||
|
||||
read: (response: http.IncomingMessage, options: any, callback: (err: any, payload: any) => void) => void;
|
||||
read: (response: http.IncomingMessage, options: ReadOptions) => Promise<any>;
|
||||
|
||||
get: (uri: string, options: any, callback: (err: any, response: http.IncomingMessage, payload: any) => void) => http.ClientRequest;
|
||||
post: (uri: string, options: any, callback: (err: any, response: http.IncomingMessage, payload: any) => void) => http.ClientRequest;
|
||||
patch: (uri: string, options: any, callback: (err: any, response: http.IncomingMessage, payload: any) => void) => http.ClientRequest;
|
||||
put: (uri: string, options: any, callback: (err: any, response: http.IncomingMessage, payload: any) => void) => http.ClientRequest;
|
||||
delete: (uri: string, options: any, callback: (err: any, response: http.IncomingMessage, payload: any) => void) => http.ClientRequest;
|
||||
get: (uri: string, options: RequestOptions & ReadOptions) => Promise<RequestResponse>;
|
||||
post: (uri: string, options: RequestOptions & ReadOptions) => Promise<RequestResponse>;
|
||||
patch: (uri: string, options: RequestOptions & ReadOptions) => Promise<RequestResponse>;
|
||||
put: (uri: string, options: RequestOptions & ReadOptions) => Promise<RequestResponse>;
|
||||
delete: (uri: string, options: RequestOptions & ReadOptions) => Promise<RequestResponse>;
|
||||
|
||||
toReadableStream: (payload: any, encoding?: string) => stream.Readable;
|
||||
|
||||
@@ -29,8 +72,11 @@ interface WreckObject {
|
||||
|
||||
agents: {
|
||||
http: http.Agent,
|
||||
https: http.Agent
|
||||
https: http.Agent,
|
||||
httpsAllowUnauthorized: http.Agent
|
||||
};
|
||||
|
||||
events?: WreckEventEmitter;
|
||||
}
|
||||
|
||||
declare var wreck: WreckObject;
|
||||
|
||||
38
types/wreck/v7/index.d.ts
vendored
Normal file
38
types/wreck/v7/index.d.ts
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
// Type definitions for wreck 7.0.0
|
||||
// Project: https://github.com/hapijs/wreck
|
||||
// Definitions by: Marcin Porębski <https://github.com/marcinporebski>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
|
||||
import http = require('http');
|
||||
import stream = require('stream');
|
||||
|
||||
|
||||
interface WreckObject {
|
||||
defaults: (options: any) => WreckObject;
|
||||
|
||||
request: (method: string, uri: string, options: any, callback?: (err: any, response: http.IncomingMessage) => void) => http.ClientRequest;
|
||||
|
||||
read: (response: http.IncomingMessage, options: any, callback: (err: any, payload: any) => void) => void;
|
||||
|
||||
get: (uri: string, options: any, callback: (err: any, response: http.IncomingMessage, payload: any) => void) => http.ClientRequest;
|
||||
post: (uri: string, options: any, callback: (err: any, response: http.IncomingMessage, payload: any) => void) => http.ClientRequest;
|
||||
patch: (uri: string, options: any, callback: (err: any, response: http.IncomingMessage, payload: any) => void) => http.ClientRequest;
|
||||
put: (uri: string, options: any, callback: (err: any, response: http.IncomingMessage, payload: any) => void) => http.ClientRequest;
|
||||
delete: (uri: string, options: any, callback: (err: any, response: http.IncomingMessage, payload: any) => void) => http.ClientRequest;
|
||||
|
||||
toReadableStream: (payload: any, encoding?: string) => stream.Readable;
|
||||
|
||||
parseCacheControl: (field: string) => any;
|
||||
|
||||
agents: {
|
||||
http: http.Agent,
|
||||
https: http.Agent
|
||||
};
|
||||
}
|
||||
|
||||
declare var wreck: WreckObject;
|
||||
|
||||
export = wreck;
|
||||
28
types/wreck/v7/tsconfig.json
Normal file
28
types/wreck/v7/tsconfig.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../../",
|
||||
"typeRoots": [
|
||||
"../../"
|
||||
],
|
||||
"paths": {
|
||||
"wreck": [
|
||||
"wreck/v7"
|
||||
]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"wreck-tests.ts"
|
||||
]
|
||||
}
|
||||
79
types/wreck/v7/tslint.json
Normal file
79
types/wreck/v7/tslint.json
Normal file
@@ -0,0 +1,79 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"adjacent-overload-signatures": false,
|
||||
"array-type": false,
|
||||
"arrow-return-shorthand": false,
|
||||
"ban-types": false,
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"eofline": false,
|
||||
"export-just-namespace": false,
|
||||
"import-spacing": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-construct": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-duplicate-imports": false,
|
||||
"no-duplicate-variable": false,
|
||||
"no-empty-interface": false,
|
||||
"no-for-in-array": false,
|
||||
"no-inferrable-types": false,
|
||||
"no-internal-module": false,
|
||||
"no-irregular-whitespace": false,
|
||||
"no-mergeable-namespace": false,
|
||||
"no-misused-new": false,
|
||||
"no-namespace": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-padding": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"no-redundant-undefined": false,
|
||||
"no-reference-import": false,
|
||||
"no-relative-import-in-test": false,
|
||||
"no-self-import": false,
|
||||
"no-single-declare-module": false,
|
||||
"no-string-throw": false,
|
||||
"no-unnecessary-callback-wrapper": false,
|
||||
"no-unnecessary-class": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"no-unnecessary-type-assertion": false,
|
||||
"no-useless-files": false,
|
||||
"no-var-keyword": false,
|
||||
"no-var-requires": false,
|
||||
"no-void-expression": false,
|
||||
"no-trailing-whitespace": false,
|
||||
"object-literal-key-quotes": false,
|
||||
"object-literal-shorthand": false,
|
||||
"one-line": false,
|
||||
"one-variable-per-declaration": false,
|
||||
"only-arrow-functions": false,
|
||||
"prefer-conditional-expression": false,
|
||||
"prefer-const": false,
|
||||
"prefer-declare-function": false,
|
||||
"prefer-for-of": false,
|
||||
"prefer-method-signature": false,
|
||||
"prefer-template": false,
|
||||
"radix": false,
|
||||
"semicolon": false,
|
||||
"space-before-function-paren": false,
|
||||
"space-within-parens": false,
|
||||
"strict-export-declare-modifiers": false,
|
||||
"trim-file": false,
|
||||
"triple-equals": false,
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
}
|
||||
}
|
||||
38
types/wreck/v7/wreck-tests.ts
Normal file
38
types/wreck/v7/wreck-tests.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
|
||||
import Wreck = require('wreck');
|
||||
|
||||
Wreck.get('https://google.com/', {}, function (err: any, res: any, payload: any) {
|
||||
/* do stuff */
|
||||
});
|
||||
|
||||
|
||||
var method = 'GET'; // GET, POST, PUT, DELETE
|
||||
var uri = 'https://google.com/';
|
||||
var readableStream = Wreck.toReadableStream('foo=bar');
|
||||
|
||||
var wreck = Wreck.defaults({
|
||||
headers: { 'x-foo-bar': 123 }
|
||||
});
|
||||
|
||||
// cascading example -- does not alter `wreck`
|
||||
var wreckWithTimeout = wreck.defaults({
|
||||
timeout: 5
|
||||
});
|
||||
|
||||
// all attributes are optional
|
||||
var options = {
|
||||
maxBytes: 1048576, // 1 MB, default: unlimited
|
||||
rejectUnauthorized: true
|
||||
};
|
||||
|
||||
var optionalCallback = function (err: any, res: any) {
|
||||
|
||||
/* handle err if it exists, in which case res will be undefined */
|
||||
|
||||
// buffer the response stream
|
||||
Wreck.read(res, null, function (err: any, body: any) {
|
||||
/* do stuff */
|
||||
});
|
||||
};
|
||||
|
||||
var req = wreck.request(method, uri, options, optionalCallback);
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
import Wreck = require('wreck');
|
||||
|
||||
Wreck.get('https://google.com/', {}, function (err: any, res: any, payload: any) {
|
||||
Wreck.get('https://google.com/', {}).then((response) => {
|
||||
/* do stuff */
|
||||
});
|
||||
|
||||
@@ -30,9 +30,11 @@ var optionalCallback = function (err: any, res: any) {
|
||||
/* handle err if it exists, in which case res will be undefined */
|
||||
|
||||
// buffer the response stream
|
||||
Wreck.read(res, null, function (err: any, body: any) {
|
||||
Wreck.read(res, null).then((payload) => {
|
||||
/* do stuff */
|
||||
});
|
||||
};
|
||||
|
||||
var req = wreck.request(method, uri, options, optionalCallback);
|
||||
var req = wreck.request(method, uri, options).then((response) => {
|
||||
/* do stuff */
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user