forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hellojs.d.ts
127 lines (106 loc) · 3.62 KB
/
hellojs.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
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
// Type definitions for hello.js 0.2.3
// Project: http://adodson.com/hello.js/
// Definitions by: Pavel Zika <https://github.com/PavelPZ>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface HelloJSLoginOptions {
redirect_uri?: string;
display?: string;
scope?: string;
response_type?: string;
force?: boolean;
oauth_proxy?: string;
timeout?: number;
default_service?: string;
}
interface HelloJSLogoutOptions {
force?: boolean;
}
interface HelloJSImmediateSuccessCB<T, TP> {
(value: T): TP;
}
interface HelloJSImmediateErrorCB<TP> {
(err: any): TP;
}
interface HelloJSDeferredSuccessCB<T, TP> {
(value: T): HelloJSThenable<TP>;
}
interface HelloJSDeferredErrorCB<TP> {
(error: any): HelloJSThenable<TP>;
}
interface HelloJSThenable<T> {
then<TP>(
successCB?: HelloJSDeferredSuccessCB<T, TP>,
errorCB?: HelloJSDeferredErrorCB<TP>
): HelloJSThenable<TP>;
then<TP>(
successCB?: HelloJSDeferredSuccessCB<T, TP>,
errorCB?: HelloJSImmediateErrorCB<TP>
): HelloJSThenable<TP>;
then<TP>(
successCB?: HelloJSImmediateSuccessCB<T, TP>,
errorCB?: HelloJSDeferredErrorCB<TP>
): HelloJSThenable<TP>;
then<TP>(
successCB?: HelloJSImmediateSuccessCB<T, TP>,
errorCB?: HelloJSImmediateErrorCB<TP>
): HelloJSThenable<TP>;
}
interface HelloJSEvent extends HelloJSThenable<void> {
on(event: string, callback: (auth: HelloJSEventArgument) => void): HelloJSStatic;
off(event: string, callback: (auth: HelloJSEventArgument) => void): HelloJSStatic;
findEvents(event: string, callback: (name: string, index: number) => void): void;
emit(event: string, data: any): HelloJSStatic;
emitAfter(): HelloJSStatic;
success(callback: (json?: any) => void): HelloJSStatic;
error(callback: (json?: any) => void): HelloJSStatic;
complete(callback: (json?: any) => void): HelloJSStatic;
}
interface HelloJSEventArgument {
network: string;
authResponse?: any;
}
interface HelloJSStatic extends HelloJSEvent {
init(serviceAppIds: { [id: string]: string; }, options?: HelloJSLoginOptions): void;
login(network: string, options?: HelloJSLoginOptions, callback?: () => void): HelloJSStatic;
logout(network: string, options?: HelloJSLogoutOptions, callback?: () => void): HelloJSStatic;
getAuthResponse(network: string): any;
service(network: string): HelloJSServiceDef;
settings: HelloJSLoginOptions;
(network: string): HelloJSStaticNamed;
init(servicesDef: { [id: string]: HelloJSServiceDef; }): void;
}
interface HelloJSStaticNamed {
login(option?: HelloJSLoginOptions, callback?: () => void): void;
logout(callback?: () => void): void;
getAuthResponse(): any;
api(path?: string, method?: string, data?: any, callback?: (json?: any) => void): HelloJSStatic;
}
interface HelloJSOAuthDef {
version: number;
auth: string;
request: string;
token: string;
}
interface HelloJSServiceDef {
name: string;
oauth: HelloJSOAuthDef;
scope?: { [id: string]: string; };
scope_delim?: string;
autorefresh?: boolean;
base?: string;
root?: string;
get?: { [id: string]: any; };
post?: { [id: string]: any; };
del?: { [id: string]: string; };
put?: { [id: string]: any; };
wrap?: { [id: string]: (par: any) => void; };
xhr?: (par: any) => void;
jsonp?: (par: any) => void;
form?: (par: any) => void;
api?: (...par: any[]) => void;
}
declare var hello: HelloJSStatic;
// Support AMD require
declare module 'hellojs' {
export = hello;
}