@types/needle
Advanced tools
Comparing version 1.4.0 to 2.0.0
@@ -1,118 +0,327 @@ | ||
// Type definitions for needle 1.4 | ||
// Type definitions for needle 2.0 | ||
// Project: https://github.com/tomas/needle | ||
// Definitions by: San Chen <https://github.com/bigsan>, Niklas Mollenhauer <https://github.com/nikeee> | ||
// Definitions by: San Chen <https://github.com/bigsan>, Niklas Mollenhauer <https://github.com/nikeee>, Matanel Sindilevich <https://github.com/sindilevich> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
// TypeScript Version: 2.2 | ||
/// <reference types="node" /> | ||
declare module "needle" { | ||
import * as http from 'http'; | ||
import * as Buffer from 'buffer'; | ||
import * as https from 'https'; | ||
namespace Needle { | ||
interface NeedleResponse extends http.IncomingMessage { | ||
body: any; | ||
raw: Buffer; | ||
bytes: number; | ||
} | ||
import * as http from 'http'; | ||
import * as Buffer from 'buffer'; | ||
import * as https from 'https'; | ||
type ReadableStream = NodeJS.ReadableStream; | ||
declare namespace core { | ||
interface NeedleResponse extends http.IncomingMessage { | ||
body: any; | ||
raw: Buffer; | ||
bytes: number; | ||
} | ||
type NeedleCallback = (error: Error, response: NeedleResponse, body: any) => void; | ||
type ReadableStream = NodeJS.ReadableStream; | ||
interface Cookies { | ||
[name: string]: any; | ||
} | ||
type NeedleCallback = (error: Error, response: NeedleResponse, body: any) => void; | ||
type NeedleOptions = RequestOptions & ResponseOptions & RedirectOptions & https.RequestOptions; | ||
interface Cookies { | ||
[name: string]: any; | ||
} | ||
interface RequestOptions { | ||
open_timeout?: number; | ||
read_timeout?: number; | ||
/** | ||
* Alias for open_timeout | ||
*/ | ||
timeout?: number; | ||
type NeedleOptions = RequestOptions & ResponseOptions & RedirectOptions & https.RequestOptions; | ||
follow_max?: number; | ||
/** | ||
* Alias for follow_max | ||
*/ | ||
follow?: number; | ||
type NeedleReadonlyHttpVerbs = 'get' | 'head'; | ||
multipart?: boolean; | ||
agent?: http.Agent | boolean; | ||
proxy?: string; | ||
headers?: {}; | ||
auth?: "auto" | "digest" | "basic"; | ||
json?: boolean; | ||
type NeedleReadWriteHttpVerbs = 'delete' | 'patch' | 'post' | 'put'; | ||
// These properties are overwritten by those in the 'headers' field | ||
cookies?: Cookies; | ||
compressed?: boolean; | ||
// Overwritten if present in the URI | ||
username?: string; | ||
password?: string; | ||
accept?: string; | ||
connection?: string; | ||
user_agent?: string; | ||
} | ||
type NeedleHttpVerbs = NeedleReadonlyHttpVerbs | NeedleReadWriteHttpVerbs; | ||
interface ResponseOptions { | ||
decode_response?: boolean; | ||
/** | ||
* Alias for decode_response | ||
*/ | ||
decode?: boolean; | ||
parse_response?: boolean; | ||
/** | ||
* Alias for parse_response | ||
*/ | ||
parse?: boolean; | ||
interface RequestOptions { | ||
/** | ||
* Returns error if connection takes longer than X milisecs to establish. | ||
* Defaults to 10000 (10 secs). 0 means no timeout. | ||
*/ | ||
open_timeout?: number; | ||
/** | ||
* Alias for open_timeout | ||
*/ | ||
timeout?: number; | ||
parse_cookies?: boolean; | ||
output?: string; | ||
} | ||
/** | ||
* Returns error if data transfer takes longer than X milisecs, | ||
* after connection is established. Defaults to 0 (no timeout). | ||
*/ | ||
read_timeout?: number; | ||
/** | ||
* Number of redirects to follow. Defaults to 0. | ||
*/ | ||
follow_max?: number; | ||
/** | ||
* Alias for follow_max | ||
*/ | ||
follow?: number; | ||
interface RedirectOptions { | ||
follow_set_cookie?: boolean; | ||
follow_set_referer?: boolean; | ||
follow_keep_method?: boolean; | ||
follow_if_same_host?: boolean; | ||
follow_if_same_protocol?: boolean; | ||
} | ||
/** | ||
* Enables multipart/form-data encoding. Defaults to false. | ||
* Use it when uploading files. | ||
*/ | ||
multipart?: boolean; | ||
/** | ||
* Uses an http.Agent of your choice, instead of the global, default one. | ||
* Useful for tweaking the behaviour at the connection level, such as when doing tunneling. | ||
*/ | ||
agent?: http.Agent | boolean; | ||
/** | ||
* Forwards request through HTTP(s) proxy. | ||
* Eg. proxy: 'http://user:pass@proxy.server.com:3128'. | ||
* For more advanced proxying/tunneling use a custom agent. | ||
*/ | ||
proxy?: string; | ||
/** | ||
* Object containing custom HTTP headers for request. | ||
*/ | ||
headers?: {}; | ||
/** | ||
* Determines what to do with provided username/password. | ||
* Options are auto, digest or basic (default). | ||
* auto will detect the type of authentication depending on the response headers. | ||
*/ | ||
auth?: "auto" | "digest" | "basic"; | ||
/** | ||
* When true, sets content type to application/json and sends request body as JSON string, | ||
* instead of a query string. | ||
*/ | ||
json?: boolean; | ||
/** | ||
* When sending streams, this lets manually set the Content-Length header | ||
* --if the stream's bytecount is known beforehand--, | ||
* preventing ECONNRESET (socket hang up) errors on some servers that misbehave | ||
* when receiving payloads of unknown size. | ||
* Set it to 0 and Needle will get and set the stream's length, | ||
* or leave unset for the default behavior, | ||
* which is no Content-Length header for stream payloads. | ||
*/ | ||
stream_length?: number; | ||
interface KeyValue { | ||
[key: string]: any; | ||
} | ||
// These properties are overwritten by those in the 'headers' field | ||
/** | ||
* Builds and sets a Cookie header from a { key: 'value' } object. | ||
*/ | ||
cookies?: Cookies; | ||
/** | ||
* If true, sets 'Accept-Encoding' header to 'gzip,deflate', | ||
* and inflates content if zipped. | ||
* Defaults to false. | ||
*/ | ||
compressed?: boolean; | ||
// Overwritten if present in the URI | ||
/** | ||
* For HTTP basic auth. | ||
*/ | ||
username?: string; | ||
/** | ||
* For HTTP basic auth. Requires username to be passed, but is optional. | ||
*/ | ||
password?: string; | ||
/** | ||
* Sets 'Accept' HTTP header. Defaults to */*. | ||
*/ | ||
accept?: string; | ||
/** | ||
* Sets 'Connection' HTTP header. | ||
* Not set by default, unless running Node < 0.11.4 | ||
* in which case it defaults to close. | ||
*/ | ||
connection?: string; | ||
/** | ||
* Sets the 'User-Agent' HTTP header. | ||
* Defaults to Needle/{version} (Node.js {node_version}). | ||
*/ | ||
user_agent?: string; | ||
/** | ||
* Sets the 'Content-Type' header. | ||
* Unset by default, unless you're sending data | ||
* in which case it's set accordingly to whatever is being sent | ||
* (application/x-www-form-urlencoded, application/json or multipart/form-data). | ||
* That is, of course, unless the option is passed, | ||
* either here or through options.headers. | ||
*/ | ||
content_type?: string; | ||
} | ||
type BodyData = Buffer | KeyValue | NodeJS.ReadableStream | string | null; | ||
interface ResponseOptions { | ||
/** | ||
* Whether to decode the text responses to UTF-8, | ||
* if Content-Type header shows a different charset. Defaults to true. | ||
*/ | ||
decode_response?: boolean; | ||
/** | ||
* Alias for decode_response | ||
*/ | ||
decode?: boolean; | ||
interface NeedleStatic { | ||
defaults(options: NeedleOptions): void; | ||
/** | ||
* Whether to parse XML or JSON response bodies automagically. | ||
* Defaults to true. | ||
* You can also set this to 'xml' or 'json' in which case Needle | ||
* will only parse the response if the content type matches. | ||
*/ | ||
parse_response?: boolean; | ||
/** | ||
* Alias for parse_response | ||
*/ | ||
parse?: boolean; | ||
head(url: string, callback?: NeedleCallback): ReadableStream; | ||
head(url: string, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream; | ||
/** | ||
* Whether to parse response’s Set-Cookie header. | ||
* Defaults to true. | ||
* If parsed, response cookies will be available at resp.cookies. | ||
*/ | ||
parse_cookies?: boolean; | ||
/** | ||
* Dump response output to file. | ||
* This occurs after parsing and charset decoding is done. | ||
*/ | ||
output?: string; | ||
} | ||
get(url: string, callback?: NeedleCallback): ReadableStream; | ||
get(url: string, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream; | ||
interface RedirectOptions { | ||
/** | ||
* Sends the cookies received in the set-cookie header | ||
* as part of the following request. | ||
* false by default. | ||
*/ | ||
follow_set_cookie?: boolean; | ||
/** | ||
* Sets the 'Referer' header to the requested URI | ||
* when following a redirect. | ||
* false by default. | ||
*/ | ||
follow_set_referer?: boolean; | ||
/** | ||
* If enabled, resends the request using the original verb | ||
* instead of being rewritten to get with no data. | ||
* false by default. | ||
*/ | ||
follow_keep_method?: boolean; | ||
/** | ||
* When true, Needle will only follow redirects that point to the same host | ||
* as the original request. | ||
* false by default. | ||
*/ | ||
follow_if_same_host?: boolean; | ||
/** | ||
* When true, Needle will only follow redirects that point to the same protocol | ||
* as the original request. | ||
* false by default. | ||
*/ | ||
follow_if_same_protocol?: boolean; | ||
} | ||
post(url: string, data: BodyData, callback?: NeedleCallback): ReadableStream; | ||
post(url: string, data: BodyData, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream; | ||
interface KeyValue { | ||
[key: string]: any; | ||
} | ||
put(url: string, data: BodyData, callback?: NeedleCallback): ReadableStream; | ||
put(url: string, data: BodyData, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream; | ||
type BodyData = Buffer | KeyValue | NodeJS.ReadableStream | string | null; | ||
} | ||
patch(url: string, data: BodyData, callback?: NeedleCallback): ReadableStream; | ||
patch(url: string, data: BodyData, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream; | ||
/** | ||
* Calling needle() directly returns a Promise. | ||
* | ||
* Since needle 2.0 | ||
* @param method Designates an HTTP verb for the request. | ||
*/ | ||
declare function needle(method: core.NeedleReadonlyHttpVerbs, url: string, options?: core.NeedleOptions): Promise<core.NeedleResponse>; | ||
/** | ||
* Calling needle() directly returns a Promise. | ||
* | ||
* Since needle 2.0 | ||
* @param method Designates an HTTP verb for the request. | ||
* @param data May be null when issuing an HTTP DELETE request, but you need to explicity pass it. | ||
*/ | ||
declare function needle(method: core.NeedleHttpVerbs, url: string, data: core.BodyData, options?: core.NeedleOptions): Promise<core.NeedleResponse>; | ||
delete(url: string, data: BodyData, callback?: NeedleCallback): ReadableStream; | ||
delete(url: string, data: BodyData, options?: NeedleOptions, callback ?: NeedleCallback): ReadableStream; | ||
declare namespace needle { | ||
type BodyData = core.BodyData; | ||
type NeedleCallback = core.NeedleCallback; | ||
type NeedleHttpVerbs = core.NeedleHttpVerbs; | ||
export type NeedleOptions = core.NeedleOptions; | ||
type ReadableStream = core.ReadableStream; | ||
request(method: string, url: string, data: BodyData, callback?: NeedleCallback): ReadableStream; | ||
request(method: string, url: string, data: BodyData, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream; | ||
} | ||
} | ||
const needle: Needle.NeedleStatic; | ||
export = needle; | ||
/** | ||
* Lets override the defaults for all future requests. | ||
*/ | ||
export function defaults(options: NeedleOptions): NeedleOptions; | ||
/** | ||
* Issues an HTTP HEAD request. | ||
*/ | ||
export function head(url: string, callback?: NeedleCallback): ReadableStream; | ||
/** | ||
* Issues an HTTP HEAD request. | ||
*/ | ||
export function head(url: string, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream; | ||
/** | ||
* Issues an HTTP GET request. | ||
*/ | ||
export function get(url: string, callback?: NeedleCallback): ReadableStream; | ||
/** | ||
* Issues an HTTP GET request. | ||
*/ | ||
export function get(url: string, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream; | ||
/** | ||
* Issues an HTTP POST request. | ||
*/ | ||
export function post(url: string, data: BodyData, callback?: NeedleCallback): ReadableStream; | ||
/** | ||
* Issues an HTTP POST request. | ||
*/ | ||
export function post(url: string, data: BodyData, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream; | ||
/** | ||
* Issues an HTTP PUT request. | ||
*/ | ||
export function put(url: string, data: BodyData, callback?: NeedleCallback): ReadableStream; | ||
/** | ||
* Issues an HTTP PUT request. | ||
*/ | ||
export function put(url: string, data: BodyData, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream; | ||
/** | ||
* Same behaviour as PUT. | ||
*/ | ||
export function patch(url: string, data: BodyData, callback?: NeedleCallback): ReadableStream; | ||
/** | ||
* Same behaviour as PUT. | ||
*/ | ||
export function patch(url: string, data: BodyData, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream; | ||
/** | ||
* Issues an HTTP DELETE request. | ||
*/ | ||
function deleteFunc(url: string, data: BodyData, callback?: NeedleCallback): ReadableStream; | ||
/** | ||
* Issues an HTTP DELETE request. | ||
*/ | ||
function deleteFunc(url: string, data: BodyData, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream; | ||
// See https://github.com/Microsoft/TypeScript/issues/1784#issuecomment-258720219 | ||
export { deleteFunc as delete }; | ||
/** | ||
* Generic request. | ||
* This not only allows for flexibility, but also lets you perform a GET request with data, | ||
* in which case will be appended to the request as a query string, | ||
* unless you pass a json: true option. | ||
* @param method Designates an HTTP verb for the request. | ||
*/ | ||
export function request(method: NeedleHttpVerbs, url: string, data: BodyData, callback?: NeedleCallback): ReadableStream; | ||
/** | ||
* Generic request. | ||
* This not only allows for flexibility, but also lets you perform a GET request with data, | ||
* in which case will be appended to the request as a query string, | ||
* unless you pass a json: true option. | ||
* @param method Designates an HTTP verb for the request. | ||
*/ | ||
export function request(method: NeedleHttpVerbs, url: string, data: BodyData, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream; | ||
} | ||
export = needle; |
{ | ||
"name": "@types/needle", | ||
"version": "1.4.0", | ||
"version": "2.0.0", | ||
"description": "TypeScript definitions for needle", | ||
"license": "MIT", | ||
"author": "San Chen <https://github.com/bigsan>, Niklas Mollenhauer <https://github.com/nikeee>", | ||
"contributors": [ | ||
{ | ||
"name": "San Chen", | ||
"url": "https://github.com/bigsan", | ||
"githubUsername": "bigsan" | ||
}, | ||
{ | ||
"name": "Niklas Mollenhauer", | ||
"url": "https://github.com/nikeee", | ||
"githubUsername": "nikeee" | ||
}, | ||
{ | ||
"name": "Matanel Sindilevich", | ||
"url": "https://github.com/sindilevich", | ||
"githubUsername": "sindilevich" | ||
} | ||
], | ||
"main": "", | ||
@@ -16,5 +32,4 @@ "repository": { | ||
}, | ||
"peerDependencies": {}, | ||
"typesPublisherContentHash": "26c49b640f3bf2de9a114ad95b02e5c8cf6c3fa3be80c7c8daf52481e401b099", | ||
"typeScriptVersion": "2.0" | ||
"typesPublisherContentHash": "43e510e112182ba21759902c7ca2473da357dd06b5d54f91ad1bc9906b80070d", | ||
"typeScriptVersion": "2.2" | ||
} |
@@ -8,6 +8,6 @@ # Installation | ||
# Details | ||
Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/needle | ||
Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/needle | ||
Additional Details | ||
* Last updated: Tue, 07 Feb 2017 20:01:00 GMT | ||
* Last updated: Thu, 07 Sep 2017 22:03:13 GMT | ||
* Dependencies: http, buffer, https, node | ||
@@ -17,2 +17,2 @@ * Global values: none | ||
# Credits | ||
These definitions were written by San Chen <https://github.com/bigsan>, Niklas Mollenhauer <https://github.com/nikeee>. | ||
These definitions were written by San Chen <https://github.com/bigsan>, Niklas Mollenhauer <https://github.com/nikeee>, Matanel Sindilevich <https://github.com/sindilevich>. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
14151
296