ismx-nexo-node-app 0.4.47 → 0.4.49
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/js/business/BusinessProxy.js +3 -3
- package/dist/js/business/BusinessServer.js +1 -0
- package/dist/js/repository/RepositoryRest.js +3 -3
- package/dist/types/api/Service.d.ts +1 -1
- package/package.json +1 -1
- package/src/main/node/api/Service.ts +1 -1
- package/src/main/node/business/BusinessProxy.ts +2 -4
- package/src/main/node/business/BusinessServer.ts +1 -0
- package/src/main/node/repository/RepositoryRest.ts +2 -2
|
@@ -46,7 +46,7 @@ class BusinessProxy {
|
|
|
46
46
|
}
|
|
47
47
|
call(tag, method, endpoint, request) {
|
|
48
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
var _a, _b, _c;
|
|
49
|
+
var _a, _b, _c, _d;
|
|
50
50
|
let module = this.modules[tag];
|
|
51
51
|
if (!module)
|
|
52
52
|
throw new Error(`Module ${tag} does not exist`);
|
|
@@ -58,8 +58,8 @@ class BusinessProxy {
|
|
|
58
58
|
for (const header of Object.keys(headers))
|
|
59
59
|
headers.set(header, (_b = (_a = request.headers) === null || _a === void 0 ? void 0 : _a[header]) !== null && _b !== void 0 ? _b : "");
|
|
60
60
|
// Si el body especificado es un objeto, lo convierte a JSON.
|
|
61
|
-
let body = request.body;
|
|
62
|
-
if ((
|
|
61
|
+
let body = (_c = request.body) === null || _c === void 0 ? void 0 : _c.toString();
|
|
62
|
+
if (request.body && ((_d = headers.get('Content-Type')) === null || _d === void 0 ? void 0 : _d.startsWith('application/json')))
|
|
63
63
|
body = JSON.stringify(request.body);
|
|
64
64
|
// Realiza la llamada a la API con las cabeceras y la URL base de la llamada.
|
|
65
65
|
try {
|
|
@@ -83,6 +83,7 @@ class BusinessServer extends Business_1.default {
|
|
|
83
83
|
case 'xml': return this.express.xml();
|
|
84
84
|
case 'stream': return this.express.raw({ type: 'application/octet-stream', limit: '10mb' });
|
|
85
85
|
case 'image': return this.express.raw({ type: 'image/*', limit: '10mb' });
|
|
86
|
+
case '*': return this.express.raw({ limit: '10mb' });
|
|
86
87
|
default: return this.express.json();
|
|
87
88
|
}
|
|
88
89
|
})();
|
|
@@ -24,7 +24,7 @@ class RepositoryRest extends Repository_1.default {
|
|
|
24
24
|
}
|
|
25
25
|
call() {
|
|
26
26
|
return __awaiter(this, arguments, void 0, function* (method = 'GET', endpoint = '/', request = {}) {
|
|
27
|
-
var _a, _b, _c, _d, _e, _f;
|
|
27
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
28
28
|
// Especifica el método de la llamada HTTP al recurso.
|
|
29
29
|
request.method = method;
|
|
30
30
|
request.endpoint = endpoint;
|
|
@@ -38,8 +38,8 @@ class RepositoryRest extends Repository_1.default {
|
|
|
38
38
|
for (const header of Object.keys(headers))
|
|
39
39
|
headers.set(header, (_e = (_d = request.headers) === null || _d === void 0 ? void 0 : _d[header]) !== null && _e !== void 0 ? _e : "");
|
|
40
40
|
// Si el body especificado es un objeto, lo convierte a JSON.
|
|
41
|
-
let body = request.body;
|
|
42
|
-
if ((
|
|
41
|
+
let body = (_f = request.body) === null || _f === void 0 ? void 0 : _f.toString();
|
|
42
|
+
if (request.body && ((_g = headers.get('Content-Type')) === null || _g === void 0 ? void 0 : _g.startsWith('application/json')))
|
|
43
43
|
body = JSON.stringify(request.body);
|
|
44
44
|
// Realiza la llamada a la API con las cabeceras y la URL base de la llamada.
|
|
45
45
|
let call = fetch(this.baseUrl + endpoint + QueryUtils_1.default.map(request.query), Object.assign(Object.assign({}, request), { body: method !== "GET" ? body : undefined, headers }));
|
|
@@ -24,7 +24,7 @@ export declare class HttpResponse<T = any> {
|
|
|
24
24
|
static ok<T = any>(content: T): HttpResponse<any>;
|
|
25
25
|
static ko<T = any>(httpCode: number, content: T): HttpResponse<any>;
|
|
26
26
|
}
|
|
27
|
-
export type ServiceType = "json" | "xml" | 'stream' | 'image';
|
|
27
|
+
export type ServiceType = "json" | "xml" | 'stream' | 'image' | '*';
|
|
28
28
|
export default abstract class Service<Req, Res> {
|
|
29
29
|
static readonly services: Service<any, any>[];
|
|
30
30
|
readonly method: string;
|
package/package.json
CHANGED
|
@@ -29,7 +29,7 @@ export class HttpResponse<T = any> {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export type ServiceType = "json" | "xml" | 'stream' | 'image';
|
|
32
|
+
export type ServiceType = "json" | "xml" | 'stream' | 'image' | '*';
|
|
33
33
|
export default abstract class Service<Req, Res>
|
|
34
34
|
{
|
|
35
35
|
public static readonly services: Service<any, any>[] = []
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { HttpResponse, HttpRequest } from "../api/Service"
|
|
2
2
|
import fetch, {Body, Headers} from 'node-fetch';
|
|
3
|
-
import {Wrapper} from "../api/ServiceRestFormal";
|
|
4
3
|
import QueryUtils from "../repository/utils/QueryUtils";
|
|
5
4
|
|
|
6
5
|
export interface Module {
|
|
@@ -21,7 +20,6 @@ export default class BusinessProxy
|
|
|
21
20
|
let module = this.modules[tag];
|
|
22
21
|
if (!module) throw new Error(`Module ${tag} does not exist`);
|
|
23
22
|
|
|
24
|
-
|
|
25
23
|
// Completa la información de las cabeceras con cabeceras comunes por llamada a API.
|
|
26
24
|
let headers = new Headers(request.headers);
|
|
27
25
|
headers.set('Content-Type', 'application/json');
|
|
@@ -31,8 +29,8 @@ export default class BusinessProxy
|
|
|
31
29
|
headers.set(header, request.headers?.[header] ?? "");
|
|
32
30
|
|
|
33
31
|
// Si el body especificado es un objeto, lo convierte a JSON.
|
|
34
|
-
let body: string = request.body
|
|
35
|
-
if (headers.get('Content-Type')?.startsWith('application/json'))
|
|
32
|
+
let body: string | undefined = request.body?.toString();
|
|
33
|
+
if (request.body && headers.get('Content-Type')?.startsWith('application/json'))
|
|
36
34
|
body = JSON.stringify(request.body);
|
|
37
35
|
|
|
38
36
|
// Realiza la llamada a la API con las cabeceras y la URL base de la llamada.
|
|
@@ -65,6 +65,7 @@ export default class BusinessServer extends Business
|
|
|
65
65
|
case 'xml': return this.express.xml();
|
|
66
66
|
case 'stream': return this.express.raw({ type: 'application/octet-stream', limit: '10mb' });
|
|
67
67
|
case 'image': return this.express.raw({ type: 'image/*', limit: '10mb' });
|
|
68
|
+
case '*': return this.express.raw({ limit: '10mb' });
|
|
68
69
|
default: return this.express.json();
|
|
69
70
|
}})();
|
|
70
71
|
|
|
@@ -47,8 +47,8 @@ export default class RepositoryRest<Body=any,Res=any> extends Repository
|
|
|
47
47
|
headers.set(header, request.headers?.[header] ?? "");
|
|
48
48
|
|
|
49
49
|
// Si el body especificado es un objeto, lo convierte a JSON.
|
|
50
|
-
let body: string = request.body
|
|
51
|
-
if (headers.get('Content-Type')?.startsWith('application/json'))
|
|
50
|
+
let body: string | undefined = request.body?.toString();
|
|
51
|
+
if (request.body && headers.get('Content-Type')?.startsWith('application/json'))
|
|
52
52
|
body = JSON.stringify(request.body);
|
|
53
53
|
|
|
54
54
|
// Realiza la llamada a la API con las cabeceras y la URL base de la llamada.
|