@wise/dynamic-flow-client 3.11.2-experimental-7d4fc19 → 3.11.2-experimental-revert-2-1b1276e
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.
|
@@ -14,15 +14,7 @@ export var makeHttpClient = function (baseUrl, additionalHeaders) {
|
|
|
14
14
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
15
15
|
return function (input, init) {
|
|
16
16
|
var resource = applyBaseUrl(input, baseUrl || '');
|
|
17
|
-
|
|
18
|
-
var requestHeaders = requestInit.headers;
|
|
19
|
-
return fetch(resource, requestInit).then(function (response) {
|
|
20
|
-
if (response.status === 415) {
|
|
21
|
-
// eslint-disable-next-line no-console
|
|
22
|
-
console.warn("DF request to ".concat(String(resource), " failed with status 415. Request headers: ").concat(stringifyHeadersInit(requestHeaders)));
|
|
23
|
-
}
|
|
24
|
-
return response;
|
|
25
|
-
});
|
|
17
|
+
return fetch(resource, mergeRequestInit(init !== null && init !== void 0 ? init : {}, { headers: additionalHeaders }));
|
|
26
18
|
};
|
|
27
19
|
};
|
|
28
20
|
var applyBaseUrl = function (input, baseUrl) {
|
|
@@ -36,19 +28,3 @@ var mergeHeaders = function () {
|
|
|
36
28
|
}
|
|
37
29
|
return headersInits.reduce(function (acc, headers) { return (__assign(__assign({}, acc), Object.fromEntries(new Headers(headers).entries()))); }, {});
|
|
38
30
|
};
|
|
39
|
-
var stringifyHeadersInit = function (headersInit) {
|
|
40
|
-
if (headersInit === undefined) {
|
|
41
|
-
return 'undefined';
|
|
42
|
-
}
|
|
43
|
-
if (headersInit === null) {
|
|
44
|
-
return 'null';
|
|
45
|
-
}
|
|
46
|
-
if (headersInit instanceof Headers) {
|
|
47
|
-
var entries = Array.from(headersInit.entries());
|
|
48
|
-
return "(Headers instance) ".concat(JSON.stringify(entries));
|
|
49
|
-
}
|
|
50
|
-
if (Array.isArray(headersInit)) {
|
|
51
|
-
return "(Array) ".concat(JSON.stringify(headersInit));
|
|
52
|
-
}
|
|
53
|
-
return "(Object) ".concat(JSON.stringify(headersInit));
|
|
54
|
-
};
|
|
@@ -4,7 +4,7 @@ describe('makeHttpClient', function () {
|
|
|
4
4
|
var spyFetch;
|
|
5
5
|
beforeEach(function () {
|
|
6
6
|
originalFetch = global.fetch;
|
|
7
|
-
spyFetch = jest.spyOn(global, 'fetch').
|
|
7
|
+
spyFetch = jest.spyOn(global, 'fetch').mockImplementation();
|
|
8
8
|
});
|
|
9
9
|
afterEach(function () {
|
|
10
10
|
global.fetch = originalFetch;
|
|
@@ -88,7 +88,8 @@ var DynamicFlowComponent = function (_a) {
|
|
|
88
88
|
var url = action.url, _b = action.method, method = _b === void 0 ? 'POST' : _b;
|
|
89
89
|
return httpClient(url !== null && url !== void 0 ? url : '', {
|
|
90
90
|
method: method,
|
|
91
|
-
|
|
91
|
+
credentials: 'include',
|
|
92
|
+
headers: __assign({ 'Content-Type': 'application/json', 'accept-language': 'en-GB' }, (etag ? { 'If-None-Match': etag } : {})),
|
|
92
93
|
body: method === 'GET' ? undefined : JSON.stringify(data),
|
|
93
94
|
});
|
|
94
95
|
}, [httpClient]);
|
package/build/main.js
CHANGED
|
@@ -312,16 +312,7 @@ var makeHttpClient = (baseUrl, additionalHeaders) => (
|
|
|
312
312
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
313
313
|
(input, init) => {
|
|
314
314
|
const resource = applyBaseUrl(input, baseUrl || "");
|
|
315
|
-
|
|
316
|
-
const requestHeaders = requestInit.headers;
|
|
317
|
-
return fetch(resource, requestInit).then((response) => {
|
|
318
|
-
if (response.status === 415) {
|
|
319
|
-
console.warn(
|
|
320
|
-
`DF request to ${String(resource)} failed with status 415. Request headers: ${stringifyHeadersInit(requestHeaders)}`
|
|
321
|
-
);
|
|
322
|
-
}
|
|
323
|
-
return response;
|
|
324
|
-
});
|
|
315
|
+
return fetch(resource, mergeRequestInit(init != null ? init : {}, { headers: additionalHeaders }));
|
|
325
316
|
}
|
|
326
317
|
);
|
|
327
318
|
var applyBaseUrl = (input, baseUrl) => typeof input === "string" && isRelativePath(input) ? baseUrl + input : input;
|
|
@@ -332,22 +323,6 @@ var mergeHeaders = (...headersInits) => headersInits.reduce(
|
|
|
332
323
|
(acc, headers2) => __spreadValues(__spreadValues({}, acc), Object.fromEntries(new Headers(headers2).entries())),
|
|
333
324
|
{}
|
|
334
325
|
);
|
|
335
|
-
var stringifyHeadersInit = (headersInit) => {
|
|
336
|
-
if (headersInit === void 0) {
|
|
337
|
-
return "undefined";
|
|
338
|
-
}
|
|
339
|
-
if (headersInit === null) {
|
|
340
|
-
return "null";
|
|
341
|
-
}
|
|
342
|
-
if (headersInit instanceof Headers) {
|
|
343
|
-
const entries = Array.from(headersInit.entries());
|
|
344
|
-
return `(Headers instance) ${JSON.stringify(entries)}`;
|
|
345
|
-
}
|
|
346
|
-
if (Array.isArray(headersInit)) {
|
|
347
|
-
return `(Array) ${JSON.stringify(headersInit)}`;
|
|
348
|
-
}
|
|
349
|
-
return `(Object) ${JSON.stringify(headersInit)}`;
|
|
350
|
-
};
|
|
351
326
|
|
|
352
327
|
// src/i18n/de.json
|
|
353
328
|
var de_default = {
|
|
@@ -19051,7 +19026,11 @@ var DynamicFlowComponent = ({
|
|
|
19051
19026
|
const { url, method = "POST" } = action;
|
|
19052
19027
|
return httpClient(url != null ? url : "", {
|
|
19053
19028
|
method,
|
|
19054
|
-
|
|
19029
|
+
credentials: "include",
|
|
19030
|
+
headers: __spreadValues({
|
|
19031
|
+
"Content-Type": "application/json",
|
|
19032
|
+
"accept-language": "en-GB"
|
|
19033
|
+
}, etag2 ? { "If-None-Match": etag2 } : {}),
|
|
19055
19034
|
body: method === "GET" ? void 0 : JSON.stringify(data)
|
|
19056
19035
|
});
|
|
19057
19036
|
},
|