forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
imap.d.ts
102 lines (81 loc) · 2.75 KB
/
imap.d.ts
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
// Type definitions for node imap
// Project: https://github.com/mscdex/node-imap
// Definitions by: Steve Fenton <https://github.com/Steve-Fenton>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
declare module "imap" {
interface ImapOptions {
user: string;
password: string;
host: string;
port: number;
tls: boolean;
}
interface ImapBox {
name: string;
readOnly: boolean;
newKeywords: boolean;
uidvalidity: number;
uidnext: number;
flags: any[]; // TODO
permFlags: any[]; // TODO
persistentUIDs: boolean;
messages: {
total: number;
'new': number;
unseen: number;
}
}
interface ImapChunk {
toString(charset: string): string;
length: number;
}
interface ImapFetch {
once(event: 'end', callback: () => void): void;
once(event: 'error', callback: (error: Error) => void): void;
once(event: string, callback: Function): void;
on(event: 'message', callback: (msg: ImapMessage, seqno: number) => void): void;
on(event: string, callback: Function): void;
}
interface ImapBodyStream {
once(event: 'end', callback: () => void): void;
once(event: string, callback: Function): void;
on(event: 'data', callback: (chunk: ImapChunk) => void): void;
on(event: string, callback: Function): void;
pipe(stream: any): void;
}
interface ImapMessage {
// TODO: typeof attributes
once(event: 'attributes', callback: (attributes: any) => void): void;
once(event: string, callback: Function): void;
// TODO: typeof info
on(event: 'body', callback: (stream: ImapBodyStream, info: any) => void): void;
on(event: string, callback: Function): void;
}
class Imap {
constructor(options: ImapOptions);
connect(): void;
//TODO:
// param a
openBox(name: string, a: boolean, callback: (err: Error, box: ImapBox) => void) : void;
//TODO:
// param a
// param b
once(event: 'end', callback: () => void): void;
once(event: 'error', callback: (error: Error) => void): void;
once(a: string, callback: Function) : void;
end(): void;
//TODO:
// return type
parseHeader(header: string): any;
static parseHeader(header: string): any;
search(searchTerms: any[], callback: Function): void;
fetch(results: any, options: {}): ImapFetch;
//TODO:
// type
seq: {
fetch(messageSourceQuery: string, options: {}): ImapFetch;
};
}
export = Imap;
}