|
| 1 | +import _Vue = require('vue'); |
| 2 | + |
| 3 | +// augment typings of Vue.js |
| 4 | +import './vue'; |
| 5 | + |
| 6 | +export interface HttpHeaders { |
| 7 | + put?: { [key: string]: string }; |
| 8 | + post?: { [key: string]: string }; |
| 9 | + patch?: { [key: string]: string }; |
| 10 | + delete?: { [key: string]: string }; |
| 11 | + common?: { [key: string]: string }; |
| 12 | + custom?: { [key: string]: string }; |
| 13 | + [key: string]: any; |
| 14 | +} |
| 15 | + |
| 16 | +export interface HttpResponse { |
| 17 | + data: any; |
| 18 | + ok: boolean; |
| 19 | + status: number; |
| 20 | + statusText: string; |
| 21 | + headers: Function; |
| 22 | + text():string; |
| 23 | + json():any; |
| 24 | + blob():Blob; |
| 25 | +} |
| 26 | + |
| 27 | +export interface HttpOptions { |
| 28 | + url?: string; |
| 29 | + method?: string; |
| 30 | + body?: any; |
| 31 | + params?: any; |
| 32 | + headers?: any; |
| 33 | + before?(request: any): any; |
| 34 | + progress?(event: any): any; |
| 35 | + credentials?:boolean; |
| 36 | + emulateHTTP?: boolean; |
| 37 | + emulateJSON?: boolean; |
| 38 | +} |
| 39 | + |
| 40 | +export interface $http { |
| 41 | + (url: string, data?: any, options?: HttpOptions): PromiseLike<HttpResponse>; |
| 42 | + (url: string, options?: HttpOptions): PromiseLike<HttpResponse>; |
| 43 | +} |
| 44 | + |
| 45 | +export interface HttpInterceptor { |
| 46 | + request?(request: HttpOptions): HttpOptions; |
| 47 | + response?(response: HttpResponse): HttpResponse; |
| 48 | +} |
| 49 | + |
| 50 | +export interface Http { |
| 51 | + options: HttpOptions & { root: string }; |
| 52 | + headers: HttpHeaders; |
| 53 | + interceptors: (HttpInterceptor | (() => HttpInterceptor))[]; |
| 54 | + get: $http; |
| 55 | + post: $http; |
| 56 | + put: $http; |
| 57 | + patch: $http; |
| 58 | + delete: $http; |
| 59 | + jsonp: $http; |
| 60 | +} |
| 61 | + |
| 62 | +export interface ResourceActions { |
| 63 | + get: { method: string }; |
| 64 | + save: { method: string }; |
| 65 | + query: { method: string }; |
| 66 | + update: { method: string }; |
| 67 | + remove: { method: string }; |
| 68 | + delete: { method: string }; |
| 69 | +} |
| 70 | + |
| 71 | +export interface ResourceMethod { |
| 72 | + (params: any, data?: any, success?: Function, error?: Function): PromiseLike<HttpResponse>; |
| 73 | + (params: any, success?: Function, error?: Function): PromiseLike<HttpResponse>; |
| 74 | + (success?: Function, error?: Function): PromiseLike<HttpResponse>; |
| 75 | +} |
| 76 | + |
| 77 | +export interface ResourceMethods { |
| 78 | + get: ResourceMethod; |
| 79 | + save: ResourceMethod; |
| 80 | + query: ResourceMethod; |
| 81 | + update: ResourceMethod; |
| 82 | + remove: ResourceMethod; |
| 83 | + delete: ResourceMethod; |
| 84 | +} |
| 85 | + |
| 86 | +export interface $resource { |
| 87 | + (url: string, params?: any, actions?: any, options?: HttpOptions): ResourceMethods; |
| 88 | +} |
| 89 | + |
| 90 | +export interface Resource extends $resource { |
| 91 | + actions: ResourceActions; |
| 92 | +} |
| 93 | + |
| 94 | +export declare function install(vue: typeof _Vue): void; |
0 commit comments