@wise/dynamic-flow-client-internal 3.11.2-experimental-26093dd → 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.
- package/build/dynamicFlow/DynamicFlow.js +1 -2
- package/build/dynamicFlow/DynamicFlow.test.js +9 -49
- package/build/dynamicFlow/utils/mergeRequestInit.js +1 -1
- package/build/dynamicFlow/utils/mergeRequestInit.test.js +0 -30
- package/build/main.js +3 -4
- package/build/main.min.js +1 -1
- package/build/main.mjs +3 -4
- package/build/types/dynamicFlow/utils/mergeRequestInit.d.ts +1 -1
- package/package.json +2 -2
|
@@ -52,8 +52,7 @@ import { DynamicFlow as DynamicFlowCoreLegacy, DynamicFlowRevamp as DynamicFlowC
|
|
|
52
52
|
import { mergeRequestInit } from './utils/mergeRequestInit';
|
|
53
53
|
export function DynamicFlowLegacy(props) {
|
|
54
54
|
var _a = props.customFetch, customFetch = _a === void 0 ? globalThis.fetch : _a;
|
|
55
|
-
var
|
|
56
|
-
var coreProps = __assign(__assign({}, props), { httpClient: httpClient });
|
|
55
|
+
var coreProps = __assign(__assign({}, props), { httpClient: customFetch });
|
|
57
56
|
return _jsx(DynamicFlowCoreLegacy, __assign({}, coreProps));
|
|
58
57
|
}
|
|
59
58
|
export function DynamicFlowRevamp(props) {
|
|
@@ -49,77 +49,37 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
49
49
|
import { waitFor } from '@testing-library/react';
|
|
50
50
|
import { renderWithProviders } from '../test-utils/rtl-utils';
|
|
51
51
|
import { DynamicFlowLegacy, DynamicFlowRevamp, DynamicFragment } from './DynamicFlow';
|
|
52
|
-
import { makeCustomFetch } from '..';
|
|
53
52
|
describe.each([
|
|
54
53
|
{ name: 'DynamicFlowLegacy', DFComponent: DynamicFlowLegacy },
|
|
55
54
|
{ name: 'DynamicFlowRevamp', DFComponent: DynamicFlowRevamp },
|
|
56
55
|
{ name: 'DynamicFragment', DFComponent: DynamicFragment },
|
|
57
56
|
])('Wise-Specific Headers', function (_a) {
|
|
58
57
|
var name = _a.name, DFComponent = _a.DFComponent;
|
|
59
|
-
var originalFetch;
|
|
60
|
-
var spyFetch;
|
|
61
|
-
beforeEach(function () {
|
|
62
|
-
originalFetch = global.fetch;
|
|
63
|
-
spyFetch = jest.spyOn(global, 'fetch').mockImplementation();
|
|
64
|
-
});
|
|
65
|
-
afterEach(function () {
|
|
66
|
-
global.fetch = originalFetch;
|
|
67
|
-
jest.clearAllMocks();
|
|
68
|
-
});
|
|
69
58
|
it("".concat(name, " - makes an initial request with additional RequestInit parameters, as specified in the wise-specific fetcher"), function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
70
|
-
var props, requestInit, credentials;
|
|
59
|
+
var props, customFetch, requestInit, credentials;
|
|
71
60
|
return __generator(this, function (_a) {
|
|
72
61
|
switch (_a.label) {
|
|
73
62
|
case 0:
|
|
74
63
|
props = {
|
|
75
64
|
flowId: 'test',
|
|
65
|
+
customFetch: jest.fn(),
|
|
76
66
|
initialAction: { url: '/initial' },
|
|
77
67
|
onCompletion: jest.fn(),
|
|
78
68
|
onError: jest.fn(),
|
|
79
69
|
};
|
|
80
|
-
|
|
70
|
+
customFetch = jest.fn();
|
|
71
|
+
renderWithProviders(_jsx(DFComponent, __assign({}, props, { customFetch: customFetch })));
|
|
81
72
|
return [4 /*yield*/, waitFor(function () {
|
|
82
|
-
expect(
|
|
73
|
+
expect(customFetch).toHaveBeenCalledWith('/initial', expect.anything());
|
|
83
74
|
})];
|
|
84
75
|
case 1:
|
|
85
76
|
_a.sent();
|
|
86
|
-
requestInit =
|
|
77
|
+
requestInit = customFetch.mock.calls[0][1];
|
|
87
78
|
credentials = requestInit === null || requestInit === void 0 ? void 0 : requestInit.credentials;
|
|
88
79
|
expect(credentials).toBe('include');
|
|
89
|
-
expect(requestInit === null || requestInit === void 0 ? void 0 : requestInit.headers).
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
});
|
|
93
|
-
return [2 /*return*/];
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
}); });
|
|
97
|
-
it("".concat(name, " - makes an initial reques with the 'content-type': 'application/json' header, regardless of the additional headers from makeCustomFetch"), function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
98
|
-
var props, requestInit;
|
|
99
|
-
return __generator(this, function (_a) {
|
|
100
|
-
switch (_a.label) {
|
|
101
|
-
case 0:
|
|
102
|
-
props = {
|
|
103
|
-
flowId: 'test',
|
|
104
|
-
initialAction: { url: '/initial' },
|
|
105
|
-
customFetch: makeCustomFetch('', {
|
|
106
|
-
'content-type': 'WRONG-CONTENT-TYPE',
|
|
107
|
-
'x-other': 'something else',
|
|
108
|
-
}),
|
|
109
|
-
onCompletion: jest.fn(),
|
|
110
|
-
onError: jest.fn(),
|
|
111
|
-
};
|
|
112
|
-
renderWithProviders(_jsx(DFComponent, __assign({}, props)));
|
|
113
|
-
return [4 /*yield*/, waitFor(function () {
|
|
114
|
-
expect(spyFetch).toHaveBeenCalledWith('/initial', expect.anything());
|
|
115
|
-
})];
|
|
116
|
-
case 1:
|
|
117
|
-
_a.sent();
|
|
118
|
-
requestInit = spyFetch.mock.calls[0][1];
|
|
119
|
-
expect(requestInit === null || requestInit === void 0 ? void 0 : requestInit.headers).toEqual({
|
|
120
|
-
'content-type': 'application/json',
|
|
121
|
-
'accept-language': 'en-GB',
|
|
122
|
-
'x-other': 'something else',
|
|
80
|
+
expect(requestInit === null || requestInit === void 0 ? void 0 : requestInit.headers).toMatchObject({
|
|
81
|
+
// 'content-type': 'application/json',
|
|
82
|
+
// 'accept-language': 'en-GB',
|
|
123
83
|
});
|
|
124
84
|
return [2 /*return*/];
|
|
125
85
|
}
|
|
@@ -9,7 +9,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
export var mergeRequestInit = function (
|
|
12
|
+
export var mergeRequestInit = function (init, additionalInit) { return (__assign(__assign(__assign({}, init), additionalInit), { headers: mergeHeaders(init === null || init === void 0 ? void 0 : init.headers, additionalInit === null || additionalInit === void 0 ? void 0 : additionalInit.headers) })); };
|
|
13
13
|
var mergeHeaders = function () {
|
|
14
14
|
var headersInits = [];
|
|
15
15
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
@@ -13,36 +13,6 @@ describe('mergeRequestInit', function () {
|
|
|
13
13
|
});
|
|
14
14
|
});
|
|
15
15
|
});
|
|
16
|
-
it('merges the two objects and the headers, prioritising the additionalInit headers in case they match', function () {
|
|
17
|
-
var result = mergeRequestInit({ credentials: 'include', headers: { 'Content-Type': 'lhs-header' } }, { method: 'POST', headers: { 'Content-Type': 'rhs-header' } });
|
|
18
|
-
expect(result).toMatchObject({
|
|
19
|
-
credentials: 'include',
|
|
20
|
-
method: 'POST',
|
|
21
|
-
});
|
|
22
|
-
expect(result.headers).toMatchObject({
|
|
23
|
-
'content-type': 'rhs-header',
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
describe('when called with RequestInits with Headers instances', function () {
|
|
27
|
-
it('merges the two objects and the headers, prioritising the init headers in case they match', function () {
|
|
28
|
-
var result = mergeRequestInit({ headers: new Headers([['Content-Type', 'lhs-header']]) }, {
|
|
29
|
-
headers: new Headers([['Content-Type', 'rhs-header']]),
|
|
30
|
-
});
|
|
31
|
-
expect(result.headers).toMatchObject({
|
|
32
|
-
'content-type': 'rhs-header',
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
describe('when called with RequestInits with Array headers', function () {
|
|
37
|
-
it('merges the two objects and the headers, prioritising the init headers in case they match', function () {
|
|
38
|
-
var result = mergeRequestInit({ headers: [['Content-Type', 'lhs-header']] }, {
|
|
39
|
-
headers: [['Content-Type', 'rhs-header']],
|
|
40
|
-
});
|
|
41
|
-
expect(result.headers).toMatchObject({
|
|
42
|
-
'content-type': 'rhs-header',
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
16
|
describe('when called with undefined as a first argument', function () {
|
|
47
17
|
it('returns the second argument and empty headers', function () {
|
|
48
18
|
var result = mergeRequestInit(undefined, { method: 'POST' });
|
package/build/main.js
CHANGED
|
@@ -56,8 +56,8 @@ var import_react_intl = require("react-intl");
|
|
|
56
56
|
var import_dynamic_flow_client = require("@wise/dynamic-flow-client");
|
|
57
57
|
|
|
58
58
|
// src/dynamicFlow/utils/mergeRequestInit.ts
|
|
59
|
-
var mergeRequestInit = (
|
|
60
|
-
headers: mergeHeaders(
|
|
59
|
+
var mergeRequestInit = (init, additionalInit) => __spreadProps(__spreadValues(__spreadValues({}, init), additionalInit), {
|
|
60
|
+
headers: mergeHeaders(init == null ? void 0 : init.headers, additionalInit == null ? void 0 : additionalInit.headers)
|
|
61
61
|
});
|
|
62
62
|
var mergeHeaders = (...headersInits) => headersInits.reduce(
|
|
63
63
|
(acc, headers) => __spreadValues(__spreadValues({}, acc), Object.fromEntries(new Headers(headers).entries())),
|
|
@@ -68,8 +68,7 @@ var mergeHeaders = (...headersInits) => headersInits.reduce(
|
|
|
68
68
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
69
69
|
function DynamicFlowLegacy(props) {
|
|
70
70
|
const { customFetch = globalThis.fetch } = props;
|
|
71
|
-
const
|
|
72
|
-
const coreProps = __spreadProps(__spreadValues({}, props), { httpClient });
|
|
71
|
+
const coreProps = __spreadProps(__spreadValues({}, props), { httpClient: customFetch });
|
|
73
72
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dynamic_flow_client.DynamicFlow, __spreadValues({}, coreProps));
|
|
74
73
|
}
|
|
75
74
|
function DynamicFlowRevamp(props) {
|
package/build/main.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var s=Object.defineProperty,d=Object.defineProperties,v=Object.getOwnPropertyDescriptor,I=Object.getOwnPropertyDescriptors,W=Object.getOwnPropertyNames,F=Object.getOwnPropertySymbols;var D=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable;var w=(t,e,o)=>e in t?s(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,a=(t,e)=>{for(var o in e||(e={}))D.call(e,o)&&w(t,o,e[o]);if(F)for(var o of F(e))x.call(e,o)&&w(t,o,e[o]);return t},r=(t,e)=>d(t,I(e));var L=(t,e)=>{for(var o in e)s(t,o,{get:e[o],enumerable:!0})},b=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of W(e))!D.call(t,c)&&c!==o&&s(t,c,{get:()=>e[c],enumerable:!(n=v(e,c))||n.enumerable});return t};var S=t=>b(s({},"__esModule",{value:!0}),t);var H={};L(H,{DynamicFlow:()=>y,DynamicFlowLegacy:()=>y,DynamicFlowRevamp:()=>f,DynamicFragment:()=>P,JsonSchemaForm:()=>m.JsonSchemaForm,isValidSchema:()=>m.isValidSchema,makeCustomFetch:()=>A,translations:()=>m.translations});module.exports=S(H);var R=require("@wise/dynamic-flow-client"),m=require("@wise/dynamic-flow-client");var l=require("react"),g=require("react-intl"),i=require("@wise/dynamic-flow-client");var h=(t,e)=>r(a(a({},t),e),{headers:q(t==null?void 0:t.headers,e==null?void 0:e.headers)}),q=(...t)=>t.reduce((e,o)=>a(a({},e),Object.fromEntries(new Headers(o).entries())),{});var p=require("react/jsx-runtime");function y(t){let{customFetch:e=globalThis.fetch}=t,o=r(a({},t),{httpClient:e});return(0,p.jsx)(i.DynamicFlow,a({},o))}function f(t){let{customFetch:e=globalThis.fetch}=t,o=u(e),n=r(a({},t),{httpClient:o});return(0,p.jsx)(i.DynamicFlowRevamp,a({},n))}var P=(0,l.forwardRef)(function(e,o){let{customFetch:n=globalThis.fetch}=e,c=u(n),C=r(a({},e),{httpClient:c});return(0,p.jsx)(i.DynamicFragmentWise,r(a({},C),{ref:o}))}),u=t=>{let{locale:e}=(0,g.useIntl)();return(0,l.useCallback)(async(o,n)=>t(o,h(n,{credentials:"include",headers:{"accept-language":e}})),[t,e])};var A=R.makeHttpClient;
|
package/build/main.mjs
CHANGED
|
@@ -32,8 +32,8 @@ import {
|
|
|
32
32
|
} from "@wise/dynamic-flow-client";
|
|
33
33
|
|
|
34
34
|
// src/dynamicFlow/utils/mergeRequestInit.ts
|
|
35
|
-
var mergeRequestInit = (
|
|
36
|
-
headers: mergeHeaders(
|
|
35
|
+
var mergeRequestInit = (init, additionalInit) => __spreadProps(__spreadValues(__spreadValues({}, init), additionalInit), {
|
|
36
|
+
headers: mergeHeaders(init == null ? void 0 : init.headers, additionalInit == null ? void 0 : additionalInit.headers)
|
|
37
37
|
});
|
|
38
38
|
var mergeHeaders = (...headersInits) => headersInits.reduce(
|
|
39
39
|
(acc, headers) => __spreadValues(__spreadValues({}, acc), Object.fromEntries(new Headers(headers).entries())),
|
|
@@ -44,8 +44,7 @@ var mergeHeaders = (...headersInits) => headersInits.reduce(
|
|
|
44
44
|
import { jsx } from "react/jsx-runtime";
|
|
45
45
|
function DynamicFlowLegacy(props) {
|
|
46
46
|
const { customFetch = globalThis.fetch } = props;
|
|
47
|
-
const
|
|
48
|
-
const coreProps = __spreadProps(__spreadValues({}, props), { httpClient });
|
|
47
|
+
const coreProps = __spreadProps(__spreadValues({}, props), { httpClient: customFetch });
|
|
49
48
|
return /* @__PURE__ */ jsx(DynamicFlowCoreLegacy, __spreadValues({}, coreProps));
|
|
50
49
|
}
|
|
51
50
|
function DynamicFlowRevamp(props) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const mergeRequestInit: (
|
|
1
|
+
export declare const mergeRequestInit: (init?: RequestInit, additionalInit?: RequestInit) => RequestInit;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wise/dynamic-flow-client-internal",
|
|
3
|
-
"version": "3.11.2-experimental-
|
|
3
|
+
"version": "3.11.2-experimental-revert-2-1b1276e",
|
|
4
4
|
"description": "Dynamic Flow web client for Wise",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./build/main.min.js",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"react-intl": "^6"
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@wise/dynamic-flow-client": "3.11.2-experimental-
|
|
83
|
+
"@wise/dynamic-flow-client": "3.11.2-experimental-revert-2-1b1276e"
|
|
84
84
|
},
|
|
85
85
|
"scripts": {
|
|
86
86
|
"dev": "storybook dev -p 3005",
|