ismx-nexo-node-app 0.4.94 → 0.4.96

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.
@@ -75,6 +75,15 @@ class ArrayUtils {
75
75
  static unify(value) {
76
76
  return Array.isArray(value) ? value : [value];
77
77
  }
78
+ /**
79
+ * Flattens a two-dimensional array (array of arrays) into a single-dimensional array.
80
+ *
81
+ * @param {T[][]} array - The two-dimensional array to be flattened.
82
+ * @return {T[]} A new array containing all elements from the nested arrays in a single, flat structure.
83
+ */
84
+ static flatten(array) {
85
+ return array.reduce((acc, val) => acc.concat(val), []);
86
+ }
78
87
  /**
79
88
  * Returns elements from the first array that are not present in the second array.
80
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;
@@ -36,13 +36,13 @@ class RepositoryRest extends Repository_1.default {
36
36
  headers.set('Pragma', 'no-cache');
37
37
  // Si el body especificado es un objeto, lo convierte a JSON.
38
38
  let body = request.body;
39
- if (request.body && typeof request.body !== 'string' && (typeof Buffer === 'undefined' || !Buffer.isBuffer(request.body))) {
39
+ if (!((_d = request.headers) === null || _d === void 0 ? void 0 : _d["Content-Type"]) && request.body && typeof request.body !== 'string' && (typeof Buffer === 'undefined' || !Buffer.isBuffer(request.body))) {
40
40
  headers.set('Content-Type', 'application/json');
41
41
  body = JSON.stringify(request.body);
42
42
  }
43
- // Añade el resto de cabeceras provistas en la llamda
44
- for (const [header, value] of Object.entries((_d = request.headers) !== null && _d !== void 0 ? _d : {}))
45
- headers.set(header, (_f = (_e = request.headers) === null || _e === void 0 ? void 0 : _e[header]) !== null && _f !== void 0 ? _f : "");
43
+ // Añade el resto de cabeceras provistas en la llamda.
44
+ for (const [header, value] of Object.entries((_e = request.headers) !== null && _e !== void 0 ? _e : {}))
45
+ headers.set(header, (_g = (_f = request.headers) === null || _f === void 0 ? void 0 : _f[header]) !== null && _g !== void 0 ? _g : "");
46
46
  // Realiza la llamada a la API con las cabeceras y la URL base de la llamada.
47
47
  let call = fetch(this.baseUrl + endpoint + QueryUtils_1.default.map(request.query), Object.assign(Object.assign({}, request), { body: method !== "GET" ? body : undefined, headers }));
48
48
  // Añade información adicional a la respuesta y devuelve el resultado (o el error en su caso).
@@ -42,6 +42,13 @@ export default abstract class ArrayUtils {
42
42
  * @return {T[]} An array containing the input value(s).
43
43
  */
44
44
  static unify<T>(value: T | T[]): T[];
45
+ /**
46
+ * Flattens a two-dimensional array (array of arrays) into a single-dimensional array.
47
+ *
48
+ * @param {T[][]} array - The two-dimensional array to be flattened.
49
+ * @return {T[]} A new array containing all elements from the nested arrays in a single, flat structure.
50
+ */
51
+ static flatten<T>(array: T[][]): T[];
45
52
  /**
46
53
  * Returns elements from the first array that are not present in the second array.
47
54
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ismx-nexo-node-app",
3
- "version": "0.4.94",
3
+ "version": "0.4.96",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build": "rm -rf ./dist && npx tsc",
@@ -66,6 +66,16 @@ export default abstract class ArrayUtils {
66
66
  return Array.isArray(value) ? value : [value];
67
67
  }
68
68
 
69
+ /**
70
+ * Flattens a two-dimensional array (array of arrays) into a single-dimensional array.
71
+ *
72
+ * @param {T[][]} array - The two-dimensional array to be flattened.
73
+ * @return {T[]} A new array containing all elements from the nested arrays in a single, flat structure.
74
+ */
75
+ static flatten<T>(array: T[][]): T[] {
76
+ return array.reduce((acc, val) => acc.concat(val), []);
77
+ }
78
+
69
79
  /**
70
80
  * Returns elements from the first array that are not present in the second array.
71
81
  *
@@ -45,12 +45,12 @@ export default class RepositoryRest<Body=any,Res=any> extends Repository
45
45
 
46
46
  // Si el body especificado es un objeto, lo convierte a JSON.
47
47
  let body: string | undefined = request.body as string;
48
- if (request.body && typeof request.body !== 'string' && (typeof Buffer === 'undefined' || !Buffer.isBuffer(request.body))) {
48
+ if (!request.headers?.["Content-Type"] && request.body && typeof request.body !== 'string' && (typeof Buffer === 'undefined' || !Buffer.isBuffer(request.body))) {
49
49
  headers.set('Content-Type', 'application/json');
50
50
  body = JSON.stringify(request.body);
51
51
  }
52
52
 
53
- // Añade el resto de cabeceras provistas en la llamda
53
+ // Añade el resto de cabeceras provistas en la llamda.
54
54
  for (const [header, value] of Object.entries(request.headers ?? {}))
55
55
  headers.set(header, request.headers?.[header] ?? "");
56
56