forked from ionic-team/ionic-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsuperagent.d.ts
More file actions
137 lines (125 loc) · 5.54 KB
/
superagent.d.ts
File metadata and controls
137 lines (125 loc) · 5.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// Type definitions for SuperAgent v3.5.1
// Project: https://github.com/visionmedia/superagent
// Definitions by: Alex Varju <https://github.com/varju/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
declare module "superagent" {
import http = require('http');
import stream = require('stream');
type CallbackHandler = (err: any, res: request.Response) => void;
var request: request.SuperAgentStatic;
namespace request {
interface SuperAgentRequest extends Request { }
interface SuperAgentStatic extends SuperAgent<SuperAgentRequest> {
(url: string): SuperAgentRequest;
(method: string, url: string): SuperAgentRequest;
agent(): SuperAgent<SuperAgentRequest>;
}
interface SuperAgent<Req> extends stream.Stream {
get(url: string, callback?: CallbackHandler): Req;
post(url: string, callback?: CallbackHandler): Req;
put(url: string, callback?: CallbackHandler): Req;
head(url: string, callback?: CallbackHandler): Req;
del(url: string, callback?: CallbackHandler): Req;
delete(url: string, callback?: CallbackHandler): Req;
options(url: string, callback?: CallbackHandler): Req;
trace(url: string, callback?: CallbackHandler): Req;
copy(url: string, callback?: CallbackHandler): Req;
lock(url: string, callback?: CallbackHandler): Req;
mkcol(url: string, callback?: CallbackHandler): Req;
move(url: string, callback?: CallbackHandler): Req;
purge(url: string, callback?: CallbackHandler): Req;
propfind(url: string, callback?: CallbackHandler): Req;
proppatch(url: string, callback?: CallbackHandler): Req;
unlock(url: string, callback?: CallbackHandler): Req;
report(url: string, callback?: CallbackHandler): Req;
mkactivity(url: string, callback?: CallbackHandler): Req;
checkout(url: string, callback?: CallbackHandler): Req;
merge(url: string, callback?: CallbackHandler): Req;
// m-search(url: string, callback?: CallbackHandler): Req;
notify(url: string, callback?: CallbackHandler): Req;
subscribe(url: string, callback?: CallbackHandler): Req;
unsubscribe(url: string, callback?: CallbackHandler): Req;
patch(url: string, callback?: CallbackHandler): Req;
search(url: string, callback?: CallbackHandler): Req;
connect(url: string, callback?: CallbackHandler): Req;
parse(fn: (res: Response, callback: (err: Error | null, body: any) => void) => void): this;
saveCookies(res: Response): void;
attachCookies(req: Req): void;
}
interface Response extends NodeJS.ReadableStream {
text: string;
body: any;
files: any;
header: any;
type: string;
charset: string;
status: number;
statusType: number;
info: boolean;
ok: boolean;
redirect: boolean;
clientError: boolean;
serverError: boolean;
error: Error;
accepted: boolean;
noContent: boolean;
badRequest: boolean;
unauthorized: boolean;
notAcceptable: boolean;
notFound: boolean;
forbidden: boolean;
request: Request;
// xhr: XMLHttpRequest;
get(header: string): string;
}
interface Request extends Promise<Response>, NodeJS.ReadableStream /* (extending ReadableStream is a lie) */{
method: string;
url: string;
qs: { [key: string]: string };
request(): any;
header: any;
_data: any;
_buffer: any;
_timeout: number;
abort(): void;
accept(type: string): this;
attach(field: string, file: string, filename?: string): this;
auth(user: string, name: string): this;
buffer(val?: boolean): this;
clearTimeout(): this;
end(callback?: CallbackHandler): this;
field(name: string, val: string | Buffer): this;
field(fields: Object): this;
get(field: string): string;
on(name: string, handler: Function): this;
on(name: 'progress', handler: (event: { direction: string; lengthComputable: boolean; loaded: number; total: number; }) => void): this;
on(name: 'error', handler: (err: any) => void): this;
on(name: 'end', handler: () => void): this;
on(name: 'response', handler: (err: http.IncomingMessage) => void): this;
part(): this;
pipe<T extends NodeJS.WritableStream>(destination: T, options?: { end?: boolean | undefined; }): T;
query(val: Object): this;
redirects(n: number): this;
responseType(type: string): this;
send(data: string): this;
send(data: Object): this;
send(): this;
set(field: string, val: string): this;
set(field: Object): this;
timeout(ms: number | { response?: number, read?: number, deadline?: number }): this;
ca(v: string | string[]): this;
key(v: string | string[]): this;
cert(v: string | string[]): this;
type(val: string): this;
unset(field: string): this;
use(fn: Function): this;
withCredentials(): this;
write(data: string, encoding?: string): this;
write(data: Buffer, encoding?: string): this;
parse(fn: (res: Response, callback: (err: Error | null, body: any) => void) => void): this;
proxy?(uri: string): this;
}
}
export = request;
}