UNPKG

4.82 kBTypeScriptView Raw
1import { Observable } from 'rxjs/internal/Observable';
2import 'reflect-metadata';
3import { RxHttpRequest } from "@akanass/rx-http-request/lib/rx-http-request";
4/**
5 *
6 */
7export interface HttpInterceptor {
8 intercep: (req: Request_) => Request_;
9}
10/**
11 *
12 */
13export declare type Handler = (...request: any[]) => HttpRequestException;
14/**
15 *
16 */
17export declare class Http extends RxHttpRequest {
18 private static interceptors;
19 /**
20 *
21 * @param {T} interceptor
22 */
23 static addInterceptor<T extends {
24 new (): HttpInterceptor;
25 }>(interceptor: T): void;
26 /**
27 *
28 * @param {string | Partial<ConfigHttp>} config
29 * @returns {(target) => void}
30 */
31 static client(config: string | Partial<ConfigHttp>): (target: any) => void;
32 /**
33 *
34 * @param {string} url
35 * @param {Function} component
36 * @param {number} statusCodeOk
37 * @returns {Function}
38 */
39 static get(url: string, component: Function, statusCodeOk?: number): Function;
40 /**
41 *
42 * @param {string} url
43 * @param {Function} component
44 * @param {number} statusCodeOk
45 * @returns {Function}
46 */
47 static post(url: string, component: Function, statusCodeOk?: number): Function;
48 /**
49 *
50 * @param {string} url
51 * @param {Function} component
52 * @param {number} statusCodeOk
53 * @returns {Function}
54 */
55 static put(url: string, component: Function, statusCodeOk?: number): Function;
56 /**
57 *
58 * @param {string} url
59 * @param {Function} component
60 * @param {number} statusCodeOk
61 * @returns {Function}
62 */
63 static patch(url: string, component: Function, statusCodeOk?: number): Function;
64 /**
65 *
66 * @param {string} url
67 * @param {Function} component
68 * @param {number} statusCodeOk
69 * @returns {Function}
70 */
71 static delete(url: string, component: Function, statusCodeOk?: number): Function;
72 /**
73 * @param {string} method
74 * @param {string} url
75 * @param {Function} component
76 * @param {number} statusCodeOk
77 * @returns {(target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>) => void}
78 */
79 private static request;
80 /**
81 *
82 * @param value
83 * @param {Handler} exceptionHandler
84 * @param statusCodeOk
85 * @returns {any}
86 */
87 private static mapBodyAndControlError;
88 /**
89 *
90 * @param {string} param
91 * @returns {Function}
92 */
93 static pathParam(param?: string): Function;
94 /**
95 *
96 * @param {string} param_
97 * @returns {Function}
98 */
99 static query(param_?: string): Function;
100 /**
101 *
102 * @param {Object} target
103 * @param {string | symbol} propertyKey
104 * @param {number} parameterIndex
105 */
106 static body(target: Object, propertyKey: string | symbol, parameterIndex: number): void;
107 /**
108 *
109 * @param {boolean} enable
110 * @returns {Function}
111 */
112 static pathParamProperty(enable?: boolean): Function;
113 /**
114 *
115 * @param {Function} mapper
116 * @returns {Function}
117 */
118 static mapper(mapper: Function): Function;
119 /**
120 *
121 * @param {{[p: string]: T}} headers
122 * @returns {Function}
123 */
124 static headers<T extends any>(headers: {
125 [key: string]: T;
126 }): Function;
127 /**
128 *
129 * @param {(request: Request_) => Request_} before_
130 * @returns {(target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>) => void}
131 */
132 static before(before_: (request: Request_) => Request_): (target: Object, propertyKey: string) => void;
133 /**
134 *
135 * @param {Handler} handler
136 * @returns {(target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>) => void}
137 */
138 static handlerError(handler: Handler): (target: Object, propertyKey: string) => void;
139}
140/**
141 *
142 */
143export declare class HttpRequestException {
144 error: string;
145 statusCode: number;
146 message: string;
147 constructor(error: string, statusCode: number, message: string);
148}
149/**
150 *
151 */
152declare class Headers {
153 /**
154 *
155 * @type {Map<any, any>}
156 */
157 private headers;
158 constructor();
159 /**
160 *
161 * @param {string} key
162 * @returns {boolean}
163 */
164 has(key: string): boolean;
165 /**
166 *
167 * @param {string} key
168 * @param header
169 * @returns {this}
170 */
171 set(key: string, header: any): this;
172 /**
173 *
174 * @returns {any}
175 */
176 getHeaders(): any;
177}
178/**
179 *
180 */
181export declare type HttpObservable<t> = Observable<t> & void;
182/**
183 *
184 */
185interface ConfigHttp {
186 url: string;
187 headers: {
188 [key: string]: any;
189 };
190}
191/**
192 *
193 */
194export interface Request_ {
195 readonly method: string;
196 body: any;
197 readonly headers: Headers;
198 readonly url: string;
199}
200export {};