forked from pagekit/vue-resource
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue_resource.ts
94 lines (81 loc) · 2.32 KB
/
vue_resource.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
import _Vue from 'vue';
// augment typings of Vue.js
import './vue';
export 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;
}
export interface HttpResponse {
data: any;
ok: boolean;
status: number;
statusText: string;
headers: Function;
text(): string;
json(): any;
blob(): Blob;
}
export 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;
}
export interface $http {
(url: string, data?: any, options?: HttpOptions): PromiseLike<HttpResponse>;
(url: string, options?: HttpOptions): PromiseLike<HttpResponse>;
}
export interface HttpInterceptor {
request?(request: HttpOptions): HttpOptions;
response?(response: HttpResponse): HttpResponse;
}
export interface Http {
options: HttpOptions & { root: string };
headers: HttpHeaders;
interceptors: (HttpInterceptor | (() => HttpInterceptor))[];
get: $http;
post: $http;
put: $http;
patch: $http;
delete: $http;
jsonp: $http;
}
export interface ResourceActions {
get: { method: string };
save: { method: string };
query: { method: string };
update: { method: string };
remove: { method: string };
delete: { method: string };
}
export 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>;
}
export interface ResourceMethods {
get: ResourceMethod;
save: ResourceMethod;
query: ResourceMethod;
update: ResourceMethod;
remove: ResourceMethod;
delete: ResourceMethod;
}
export interface $resource {
(url: string, params?: any, actions?: any, options?: HttpOptions): ResourceMethods;
}
export interface Resource extends $resource {
actions: ResourceActions;
}
export declare function install(vue: typeof _Vue): void;