ismx-nexo-node-app 0.4.48 → 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.
@@ -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 ((_c = headers.get('Content-Type')) === null || _c === void 0 ? void 0 : _c.startsWith('application/json'))
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 {
@@ -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 ((_f = headers.get('Content-Type')) === null || _f === void 0 ? void 0 : _f.startsWith('application/json'))
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 }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ismx-nexo-node-app",
3
- "version": "0.4.48",
3
+ "version": "0.4.49",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build": "rm -rf ./dist && npx tsc",
@@ -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 as string;
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.
@@ -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 as string;
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.