ismx-nexo-node-app 0.4.177 → 0.4.179
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.
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
const Repository_1 = __importDefault(require("./Repository"));
|
|
16
16
|
const QueryUtils_1 = __importDefault(require("./utils/QueryUtils"));
|
|
17
17
|
const DateUtils_1 = __importDefault(require("../business/utils/DateUtils"));
|
|
18
|
+
const ObjectUtils_1 = __importDefault(require("../business/utils/ObjectUtils"));
|
|
18
19
|
class RepositoryRest extends Repository_1.default {
|
|
19
20
|
constructor(baseUrl, options = {}) {
|
|
20
21
|
super();
|
|
@@ -46,13 +47,13 @@ class RepositoryRest extends Repository_1.default {
|
|
|
46
47
|
headers.set(header, (_g = (_f = request.headers) === null || _f === void 0 ? void 0 : _f[header]) !== null && _g !== void 0 ? _g : "");
|
|
47
48
|
// Realiza la llamada a la API con las cabeceras y la URL base de la llamada.
|
|
48
49
|
const _fetch = (_h = this.options.fetch) !== null && _h !== void 0 ? _h : fetch;
|
|
49
|
-
let call = _fetch(request.url + QueryUtils_1.default.map(request.query), Object.assign(Object.assign({}, request), { body: method !== "GET" ? body : undefined, headers: headers }));
|
|
50
|
+
let call = _fetch(request.url + QueryUtils_1.default.map(request.query), Object.assign(Object.assign({}, request), { body: method !== "GET" ? body : undefined, headers: ObjectUtils_1.default.fromEntries(Array.from(headers.entries())) }));
|
|
50
51
|
// Añade información adicional a la respuesta y devuelve el resultado (o el error en su caso).
|
|
51
52
|
// @ts-ignore
|
|
52
53
|
return call.then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
53
54
|
var _a, _b, _c, _d, _e;
|
|
54
55
|
let headers = {};
|
|
55
|
-
res.headers.forEach((
|
|
56
|
+
Object.entries(res.headers).forEach(([key, value]) => headers[key.toLowerCase()] = value);
|
|
56
57
|
let content = yield res.text();
|
|
57
58
|
(_b = (_a = this.options).onRawResponse) === null || _b === void 0 ? void 0 : _b.call(_a, request, content);
|
|
58
59
|
if ((_c = headers['content-type']) === null || _c === void 0 ? void 0 : _c.startsWith('application/json'))
|
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ import Repository from "./Repository";
|
|
|
2
2
|
import {HttpRequest, HttpResponse} from "../api/Service";
|
|
3
3
|
import QueryUtils from "./utils/QueryUtils";
|
|
4
4
|
import DateUtils from "../business/utils/DateUtils";
|
|
5
|
+
import ObjectUtils from "../business/utils/ObjectUtils";
|
|
5
6
|
|
|
6
7
|
export interface RestOptions {
|
|
7
8
|
interceptor?: (endpoint: string, request: HttpRequest) => HttpRequest | undefined
|
|
@@ -59,13 +60,14 @@ export default class RepositoryRest<Body=any,Res=any> extends Repository
|
|
|
59
60
|
// Realiza la llamada a la API con las cabeceras y la URL base de la llamada.
|
|
60
61
|
const _fetch = this.options.fetch ?? fetch;
|
|
61
62
|
let call = _fetch(request.url + QueryUtils.map(request.query), {
|
|
62
|
-
...request, body: method !== "GET" ? body : undefined, headers: headers
|
|
63
|
+
...request, body: method !== "GET" ? body : undefined, headers: ObjectUtils.fromEntries(Array.from(headers.entries()))
|
|
63
64
|
});
|
|
64
65
|
|
|
65
66
|
// Añade información adicional a la respuesta y devuelve el resultado (o el error en su caso).
|
|
66
67
|
// @ts-ignore
|
|
67
68
|
return call.then(async (res: Response) => {
|
|
68
|
-
let headers: any = {};
|
|
69
|
+
let headers: any = {};
|
|
70
|
+
Object.entries(res.headers).forEach(([key, value]) => headers[key.toLowerCase()] = value);
|
|
69
71
|
let content: string | E = await res.text();
|
|
70
72
|
this.options.onRawResponse?.(request, content);
|
|
71
73
|
|