UNPKG

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