fiscalia_bo-nest-helpers 0.0.20 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/http-service/http-service.pipes.d.ts +4 -0
- package/dist/http-service/http-service.pipes.js +121 -0
- package/dist/http-service/http-service.pipes.js.map +1 -0
- package/dist/http-service/index.d.ts +1 -0
- package/dist/http-service/index.js +18 -0
- package/dist/http-service/index.js.map +1 -0
- package/package.json +2 -1
@@ -0,0 +1,4 @@
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
2
|
+
import { ResponseDTO } from 'src/types';
|
3
|
+
export declare const TransformHttpServiceResponse: import("rxjs").OperatorFunction<AxiosResponse<any, any>, ResponseDTO<any>>;
|
4
|
+
export declare const FilterHttpServiceResponse: import("rxjs").OperatorFunction<unknown, any>;
|
@@ -0,0 +1,121 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.FilterHttpServiceResponse = exports.TransformHttpServiceResponse = void 0;
|
4
|
+
const rxjs_1 = require("rxjs");
|
5
|
+
const axiosResponseStatusMessages = {
|
6
|
+
100: 'Continuar',
|
7
|
+
101: 'Cambiando Protocolos',
|
8
|
+
102: 'Procesando',
|
9
|
+
103: 'Indicios Tempranos',
|
10
|
+
200: 'Correcto',
|
11
|
+
201: 'Creado',
|
12
|
+
202: 'Aceptado',
|
13
|
+
203: 'Información no Autoritativa',
|
14
|
+
204: 'Sin Contenido',
|
15
|
+
205: 'Contenido Reiniciado',
|
16
|
+
206: 'Contenido Parcial',
|
17
|
+
207: 'Estado',
|
18
|
+
208: 'Ya Informado',
|
19
|
+
226: 'Usado IM',
|
20
|
+
300: 'Elecciones Múltiples',
|
21
|
+
301: 'Movido Permanentemente',
|
22
|
+
302: 'Encontrado',
|
23
|
+
303: 'Ver Otro',
|
24
|
+
304: 'No Modificado',
|
25
|
+
305: 'Usar Proxy',
|
26
|
+
306: 'Cambiar Proxy',
|
27
|
+
307: 'Redirección Temporal',
|
28
|
+
308: 'Redirección Permanente',
|
29
|
+
400: 'Solicitud Incorrecta',
|
30
|
+
401: 'No Autorizado',
|
31
|
+
402: 'Pago Requerido',
|
32
|
+
403: 'Prohibido',
|
33
|
+
404: 'No Encontrado',
|
34
|
+
405: 'Método no Permitido',
|
35
|
+
406: 'No Aceptable',
|
36
|
+
407: 'Autenticación de Proxy Requerida',
|
37
|
+
408: 'Tiempo de Solicitud Agotado',
|
38
|
+
409: 'Conflicto',
|
39
|
+
410: 'Desaparecido',
|
40
|
+
411: 'Longitud Requerida',
|
41
|
+
412: 'Precondición Fallida',
|
42
|
+
413: 'Carga Útil Demasiado Grande',
|
43
|
+
414: 'URI Demasiado Largo',
|
44
|
+
415: 'Tipo de Medio No Soportado',
|
45
|
+
416: 'Rango no Satisfactorio',
|
46
|
+
417: 'Expectativa Fallida',
|
47
|
+
418: 'Soy una tetera',
|
48
|
+
421: 'Solicitud Mal Dirigida',
|
49
|
+
422: 'Entidad No Procesable',
|
50
|
+
423: 'Bloqueado',
|
51
|
+
424: 'Dependencia Fallida',
|
52
|
+
425: 'Demasiado Temprano',
|
53
|
+
426: 'Actualización Requerida',
|
54
|
+
428: 'Precondición Requerida',
|
55
|
+
429: 'Demasiadas Solicitudes',
|
56
|
+
431: 'Campos de Encabezado de Solicitud Demasiado Grandes',
|
57
|
+
451: 'No Disponible por Razones Legales',
|
58
|
+
500: 'Error Interno del Servidor',
|
59
|
+
501: 'No Implementado',
|
60
|
+
502: 'Gateway Incorrecto',
|
61
|
+
503: 'Servicio No Disponible',
|
62
|
+
504: 'Tiempo de Espera del Gateway Agotado',
|
63
|
+
505: 'Versión HTTP No Soportada',
|
64
|
+
506: 'Variante También Negocia',
|
65
|
+
507: 'Almacenamiento Insuficiente',
|
66
|
+
508: 'Detección de Bucle',
|
67
|
+
509: 'Límite de Ancho de Banda Excedido',
|
68
|
+
510: 'No Extendido',
|
69
|
+
511: 'Autenticación de Red Requerida',
|
70
|
+
};
|
71
|
+
exports.TransformHttpServiceResponse = (0, rxjs_1.map)((resp) => {
|
72
|
+
let response = {
|
73
|
+
error: true,
|
74
|
+
message: 'Error en el micro servicio ms-files',
|
75
|
+
response: {},
|
76
|
+
status: 500,
|
77
|
+
};
|
78
|
+
response = resp.data;
|
79
|
+
if (typeof response.error === 'boolean' && typeof response.status === 'number')
|
80
|
+
return response;
|
81
|
+
else {
|
82
|
+
response = {
|
83
|
+
response: resp.data,
|
84
|
+
error: resp.status >= 400,
|
85
|
+
message: resp.statusText,
|
86
|
+
status: resp.status,
|
87
|
+
};
|
88
|
+
}
|
89
|
+
});
|
90
|
+
exports.FilterHttpServiceResponse = (0, rxjs_1.catchError)((error) => {
|
91
|
+
let resp = {
|
92
|
+
error: true,
|
93
|
+
message: 'Sucedió un error',
|
94
|
+
response: null,
|
95
|
+
status: 500,
|
96
|
+
};
|
97
|
+
if (error.isAxiosError) {
|
98
|
+
if (error.code === 'ENOTFOUND') {
|
99
|
+
resp.message = `Error: no se pudo connecter al servicio ${error.config.baseURL}${error.config.url}`;
|
100
|
+
}
|
101
|
+
else if (error.response) {
|
102
|
+
const respData = error.response.data;
|
103
|
+
if (typeof respData.status === 'number' && typeof respData.error === 'boolean') {
|
104
|
+
resp = respData;
|
105
|
+
}
|
106
|
+
else {
|
107
|
+
console.log('response fields: ', Object.keys(error.response));
|
108
|
+
resp = {
|
109
|
+
error: true,
|
110
|
+
message: axiosResponseStatusMessages[error.response.status],
|
111
|
+
response: null,
|
112
|
+
status: error.response.status,
|
113
|
+
};
|
114
|
+
}
|
115
|
+
}
|
116
|
+
}
|
117
|
+
if (resp.message === 'Sucedió un error')
|
118
|
+
console.error(error);
|
119
|
+
return (0, rxjs_1.of)(resp);
|
120
|
+
});
|
121
|
+
//# sourceMappingURL=http-service.pipes.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"http-service.pipes.js","sourceRoot":"","sources":["../../src/http-service/http-service.pipes.ts"],"names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BAAkB;QAC3B,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,GAAG;KACZ,CAAC;IACF,IAAI,KAAK,CAAC,YAAY,EAAE;QACtB,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,EAAE;YAC9B,IAAI,CAAC,OAAO,GAAG,2CAA2C,KAAK,CAAC,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;SACrG;aAAM,IAAI,KAAK,CAAC,QAAQ,EAAE;YACzB,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAW,CAAC;YAC5C,IAAI,OAAO,QAAQ,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,QAAQ,CAAC,KAAK,KAAK,SAAS,EAAE;gBAC9E,IAAI,GAAG,QAA4B,CAAC;aACrC;iBAAM;gBACL,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAC9D,IAAI,GAAG;oBACL,KAAK,EAAE,IAAI;oBACX,OAAO,EAAE,2BAA2B,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;oBAC3D,QAAQ,EAAE,IAAI;oBACd,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM;iBAC9B,CAAC;aACH;SACF;KACF;IACD,IAAI,IAAI,CAAC,OAAO,KAAK,kBAAkB;QAAE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC9D,OAAO,IAAA,SAAE,EAAC,IAAI,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './http-service.pipes';
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./http-service.pipes"), exports);
|
18
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/http-service/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "fiscalia_bo-nest-helpers",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.21",
|
4
4
|
"author": "UTIC",
|
5
5
|
"contact": {
|
6
6
|
"name": "Unidad de Tecnologías de la Información y Comunicación - Ministerio Público",
|
@@ -11,6 +11,7 @@
|
|
11
11
|
"dist/ms-seguridad/*",
|
12
12
|
"dist/ms-redis/*",
|
13
13
|
"dist/ms-personas/*",
|
14
|
+
"dist/http-service/*",
|
14
15
|
"dist/services/*",
|
15
16
|
"dist/helpers/*",
|
16
17
|
"dist/types/*",
|