forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue-resource.d.ts
124 lines (107 loc) · 3.3 KB
/
vue-resource.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
// Type definitions for vue-resoure 0.9.3
// Project: https://github.com/vuejs/vue-resource
// Definitions by: kaorun343 <https://github.com/kaorun343>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../vue/vue.d.ts" />
declare namespace vuejs {
interface HttpHeaders {
put?: { [key: string]: string };
post?: { [key: string]: string };
patch?: { [key: string]: string };
delete?: { [key: string]: string };
common?: { [key: string]: string };
custom?: { [key: string]: string };
[key: string]: any;
}
interface HttpResponse {
data: Object;
ok: boolean;
status: number;
statusText: string;
headers: Function;
text():string;
json():any;
blob():Blob;
}
interface HttpOptions {
url?: string;
method?: string;
body?: any;
params?: any;
headers?: any;
before?(request: any): any;
progress?(event: any): any;
credentials?:boolean;
emulateHTTP?: boolean;
emulateJSON?: boolean;
}
interface $http {
(url: string, data?: any, options?: HttpOptions): PromiseLike<HttpResponse>;
(url: string, options?: HttpOptions): PromiseLike<HttpResponse>;
}
interface HttpInterceptor {
request?(request: HttpOptions): HttpOptions;
response?(response: HttpResponse): HttpResponse;
}
interface Http {
options: HttpOptions & { root: string };
headers: HttpHeaders;
interceptors: (HttpInterceptor | (() => HttpInterceptor))[];
get: $http;
post: $http;
put: $http;
patch: $http;
delete: $http;
jsonp: $http;
}
interface ResourceActions {
get: { method: string };
save: { method: string };
query: { method: string };
update: { method: string };
remove: { method: string };
delete: { method: string };
}
interface ResourceMethod {
(params: any, data?: any, success?: Function, error?: Function): PromiseLike<HttpResponse>;
(params: any, success?: Function, error?: Function): PromiseLike<HttpResponse>;
(success?: Function, error?: Function): PromiseLike<HttpResponse>;
}
interface ResourceMethods {
get: ResourceMethod;
save: ResourceMethod;
query: ResourceMethod;
update: ResourceMethod;
remove: ResourceMethod;
delete: ResourceMethod;
}
interface $resource {
(url: string, params?: Object, actions?: any, options?: HttpOptions): ResourceMethods;
}
interface Resource extends $resource {
actions: ResourceActions;
}
interface Vue {
$http: {
(options: HttpOptions): PromiseLike<HttpResponse>;
get: $http;
post: $http;
put: $http;
patch: $http;
delete: $http;
jsonp: $http;
};
$resource: $resource;
}
interface VueStatic {
http: Http;
resource: Resource;
}
interface ComponentOption {
http?: (HttpOptions & { headers?: HttpHeaders } & { [key: string]: any })
}
}
declare module "vue-resource" {
const install: (vue: vuejs.VueStatic) => void;
export = install;
}