chayns-api 1.0.6 → 1.0.8
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/dist/cjs/host/ChaynsHost.js +10 -5
- package/dist/cjs/host/iframe/HostIframe.js +5 -3
- package/dist/cjs/host/module/ModuleHost.js +8 -2
- package/dist/cjs/util/url.js +19 -0
- package/dist/cjs/wrapper/AppWrapper.js +1 -4
- package/dist/esm/host/ChaynsHost.js +10 -5
- package/dist/esm/host/iframe/HostIframe.js +5 -3
- package/dist/esm/host/module/ModuleHost.js +8 -2
- package/dist/esm/util/url.js +12 -0
- package/dist/esm/wrapper/AppWrapper.js +3 -7
- package/dist/types/host/ChaynsHost.d.ts +1 -0
- package/dist/types/host/iframe/HostIframe.d.ts +1 -0
- package/dist/types/host/module/ModuleHost.d.ts +1 -0
- package/dist/types/util/url.d.ts +1 -0
- package/package.json +1 -1
|
@@ -27,7 +27,8 @@ const ChaynsHost = ({
|
|
|
27
27
|
device,
|
|
28
28
|
parameters,
|
|
29
29
|
customData,
|
|
30
|
-
environment
|
|
30
|
+
environment,
|
|
31
|
+
preventStagingReplacement
|
|
31
32
|
}) => {
|
|
32
33
|
switch (type) {
|
|
33
34
|
case 'client-iframe':
|
|
@@ -45,7 +46,8 @@ const ChaynsHost = ({
|
|
|
45
46
|
language: language,
|
|
46
47
|
parameters: parameters,
|
|
47
48
|
environment: environment,
|
|
48
|
-
customData: customData
|
|
49
|
+
customData: customData,
|
|
50
|
+
preventStagingReplacement: preventStagingReplacement
|
|
49
51
|
});
|
|
50
52
|
case 'client-module':
|
|
51
53
|
return /*#__PURE__*/_react.default.createElement(_ModuleHost.default, {
|
|
@@ -61,7 +63,8 @@ const ChaynsHost = ({
|
|
|
61
63
|
language: language,
|
|
62
64
|
parameters: parameters,
|
|
63
65
|
customData: customData,
|
|
64
|
-
environment: environment
|
|
66
|
+
environment: environment,
|
|
67
|
+
preventStagingReplacement: preventStagingReplacement
|
|
65
68
|
});
|
|
66
69
|
case 'server-iframe':
|
|
67
70
|
return /*#__PURE__*/_react.default.createElement(_HostIframe.default, {
|
|
@@ -79,7 +82,8 @@ const ChaynsHost = ({
|
|
|
79
82
|
language: language,
|
|
80
83
|
parameters: parameters,
|
|
81
84
|
environment: environment,
|
|
82
|
-
customData: customData
|
|
85
|
+
customData: customData,
|
|
86
|
+
preventStagingReplacement: preventStagingReplacement
|
|
83
87
|
});
|
|
84
88
|
case 'server-module':
|
|
85
89
|
return /*#__PURE__*/_react.default.createElement(_ModuleHost.default, {
|
|
@@ -94,7 +98,8 @@ const ChaynsHost = ({
|
|
|
94
98
|
language: language,
|
|
95
99
|
parameters: parameters,
|
|
96
100
|
customData: customData,
|
|
97
|
-
environment: environment
|
|
101
|
+
environment: environment,
|
|
102
|
+
preventStagingReplacement: preventStagingReplacement
|
|
98
103
|
}, children);
|
|
99
104
|
default:
|
|
100
105
|
return null;
|
|
@@ -8,6 +8,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
8
8
|
var comlink = _interopRequireWildcard(require("comlink"));
|
|
9
9
|
var _postIframeForm = _interopRequireDefault(require("../../util/postIframeForm"));
|
|
10
10
|
var _useUpdateData = _interopRequireDefault(require("./utils/useUpdateData"));
|
|
11
|
+
var _url = require("../../util/url");
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
13
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
14
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -28,7 +29,8 @@ const HostIframe = ({
|
|
|
28
29
|
language,
|
|
29
30
|
parameters,
|
|
30
31
|
environment,
|
|
31
|
-
customData
|
|
32
|
+
customData,
|
|
33
|
+
preventStagingReplacement
|
|
32
34
|
}) => {
|
|
33
35
|
const eventTarget = (0, _react.useRef)();
|
|
34
36
|
const ref = (0, _react.useRef)();
|
|
@@ -66,7 +68,7 @@ const HostIframe = ({
|
|
|
66
68
|
if (postForm) {
|
|
67
69
|
var _await$functions$getA;
|
|
68
70
|
const accessToken = (_await$functions$getA = await functions.getAccessToken()) !== null && _await$functions$getA !== void 0 ? _await$functions$getA : {};
|
|
69
|
-
void (0, _postIframeForm.default)(src, JSON.stringify({
|
|
71
|
+
void (0, _postIframeForm.default)((0, _url.replaceStagingUrl)(preventStagingReplacement, src, environment.runtimeEnvironment), JSON.stringify({
|
|
70
72
|
...initialData,
|
|
71
73
|
pages: undefined,
|
|
72
74
|
...accessToken
|
|
@@ -126,7 +128,7 @@ const HostIframe = ({
|
|
|
126
128
|
},
|
|
127
129
|
title: " "
|
|
128
130
|
}, iFrameProps, {
|
|
129
|
-
src: postForm ? undefined : src
|
|
131
|
+
src: postForm ? undefined : (0, _url.replaceStagingUrl)(preventStagingReplacement, src, environment.runtimeEnvironment)
|
|
130
132
|
}));
|
|
131
133
|
};
|
|
132
134
|
var _default = HostIframe;
|
|
@@ -7,6 +7,7 @@ exports.default = void 0;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _useDynamicScript = _interopRequireDefault(require("./utils/useDynamicScript"));
|
|
9
9
|
var _loadComponent = _interopRequireDefault(require("./utils/loadComponent"));
|
|
10
|
+
var _url = require("../../util/url");
|
|
10
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
12
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
13
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -49,7 +50,8 @@ const ModuleHost = ({
|
|
|
49
50
|
language,
|
|
50
51
|
parameters,
|
|
51
52
|
customData,
|
|
52
|
-
environment
|
|
53
|
+
environment,
|
|
54
|
+
preventStagingReplacement
|
|
53
55
|
}) => {
|
|
54
56
|
// region initialData
|
|
55
57
|
const initialData = {
|
|
@@ -71,7 +73,11 @@ const ModuleHost = ({
|
|
|
71
73
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
72
74
|
className: "module-css"
|
|
73
75
|
}), /*#__PURE__*/_react.default.createElement(System, {
|
|
74
|
-
system:
|
|
76
|
+
system: {
|
|
77
|
+
scope: system.scope,
|
|
78
|
+
url: (0, _url.replaceStagingUrl)(preventStagingReplacement, system.url, environment.runtimeEnvironment),
|
|
79
|
+
module: system.module
|
|
80
|
+
},
|
|
75
81
|
data: initialData,
|
|
76
82
|
functions: functions,
|
|
77
83
|
fallback: children,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.replaceStagingUrl = void 0;
|
|
7
|
+
var _IChaynsReact = require("../types/IChaynsReact");
|
|
8
|
+
const replaceStagingUrl = (prevent, url, environment) => {
|
|
9
|
+
if (prevent) return url;
|
|
10
|
+
let replacedUrl = url;
|
|
11
|
+
if (environment === _IChaynsReact.Environment.Qa || environment === _IChaynsReact.Environment.Development) {
|
|
12
|
+
replacedUrl = replacedUrl.replace('tapp.chayns-static.space', 'tapp-dev.chayns-static.space');
|
|
13
|
+
}
|
|
14
|
+
if (environment === _IChaynsReact.Environment.Staging) {
|
|
15
|
+
replacedUrl = replacedUrl.replace('tapp.chayns-static.space', 'tapp-staging.chayns-static.space');
|
|
16
|
+
}
|
|
17
|
+
return replacedUrl;
|
|
18
|
+
};
|
|
19
|
+
exports.replaceStagingUrl = replaceStagingUrl;
|
|
@@ -66,10 +66,7 @@ class AppWrapper {
|
|
|
66
66
|
locationPersonId: AppInfo.LocationPersonId,
|
|
67
67
|
urlHash: (_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.location.hash.replace('#', '')
|
|
68
68
|
},
|
|
69
|
-
parameters:
|
|
70
|
-
p[k] = v;
|
|
71
|
-
return p;
|
|
72
|
-
}, {}),
|
|
69
|
+
parameters: Object.fromEntries(new URLSearchParams(location.search)),
|
|
73
70
|
user: {
|
|
74
71
|
firstName: AppUser.FirstName,
|
|
75
72
|
lastName: AppUser.LastName,
|
|
@@ -21,7 +21,8 @@ const ChaynsHost = _ref => {
|
|
|
21
21
|
device,
|
|
22
22
|
parameters,
|
|
23
23
|
customData,
|
|
24
|
-
environment
|
|
24
|
+
environment,
|
|
25
|
+
preventStagingReplacement
|
|
25
26
|
} = _ref;
|
|
26
27
|
switch (type) {
|
|
27
28
|
case 'client-iframe':
|
|
@@ -39,7 +40,8 @@ const ChaynsHost = _ref => {
|
|
|
39
40
|
language: language,
|
|
40
41
|
parameters: parameters,
|
|
41
42
|
environment: environment,
|
|
42
|
-
customData: customData
|
|
43
|
+
customData: customData,
|
|
44
|
+
preventStagingReplacement: preventStagingReplacement
|
|
43
45
|
});
|
|
44
46
|
case 'client-module':
|
|
45
47
|
return /*#__PURE__*/React.createElement(ModuleHost, {
|
|
@@ -55,7 +57,8 @@ const ChaynsHost = _ref => {
|
|
|
55
57
|
language: language,
|
|
56
58
|
parameters: parameters,
|
|
57
59
|
customData: customData,
|
|
58
|
-
environment: environment
|
|
60
|
+
environment: environment,
|
|
61
|
+
preventStagingReplacement: preventStagingReplacement
|
|
59
62
|
});
|
|
60
63
|
case 'server-iframe':
|
|
61
64
|
return /*#__PURE__*/React.createElement(HostIframe, {
|
|
@@ -73,7 +76,8 @@ const ChaynsHost = _ref => {
|
|
|
73
76
|
language: language,
|
|
74
77
|
parameters: parameters,
|
|
75
78
|
environment: environment,
|
|
76
|
-
customData: customData
|
|
79
|
+
customData: customData,
|
|
80
|
+
preventStagingReplacement: preventStagingReplacement
|
|
77
81
|
});
|
|
78
82
|
case 'server-module':
|
|
79
83
|
return /*#__PURE__*/React.createElement(ModuleHost, {
|
|
@@ -88,7 +92,8 @@ const ChaynsHost = _ref => {
|
|
|
88
92
|
language: language,
|
|
89
93
|
parameters: parameters,
|
|
90
94
|
customData: customData,
|
|
91
|
-
environment: environment
|
|
95
|
+
environment: environment,
|
|
96
|
+
preventStagingReplacement: preventStagingReplacement
|
|
92
97
|
}, children);
|
|
93
98
|
default:
|
|
94
99
|
return null;
|
|
@@ -3,6 +3,7 @@ import React, { useEffect, useRef } from 'react';
|
|
|
3
3
|
import * as comlink from 'comlink';
|
|
4
4
|
import postIframeForm from '../../util/postIframeForm';
|
|
5
5
|
import useUpdateData from './utils/useUpdateData';
|
|
6
|
+
import { replaceStagingUrl } from "../../util/url";
|
|
6
7
|
const HostIframe = _ref => {
|
|
7
8
|
let {
|
|
8
9
|
iFrameProps,
|
|
@@ -20,7 +21,8 @@ const HostIframe = _ref => {
|
|
|
20
21
|
language,
|
|
21
22
|
parameters,
|
|
22
23
|
environment,
|
|
23
|
-
customData
|
|
24
|
+
customData,
|
|
25
|
+
preventStagingReplacement
|
|
24
26
|
} = _ref;
|
|
25
27
|
const eventTarget = useRef();
|
|
26
28
|
const ref = useRef();
|
|
@@ -58,7 +60,7 @@ const HostIframe = _ref => {
|
|
|
58
60
|
if (postForm) {
|
|
59
61
|
var _await$functions$getA;
|
|
60
62
|
const accessToken = (_await$functions$getA = await functions.getAccessToken()) !== null && _await$functions$getA !== void 0 ? _await$functions$getA : {};
|
|
61
|
-
void postIframeForm(src, JSON.stringify({
|
|
63
|
+
void postIframeForm(replaceStagingUrl(preventStagingReplacement, src, environment.runtimeEnvironment), JSON.stringify({
|
|
62
64
|
...initialData,
|
|
63
65
|
pages: undefined,
|
|
64
66
|
...accessToken
|
|
@@ -118,7 +120,7 @@ const HostIframe = _ref => {
|
|
|
118
120
|
},
|
|
119
121
|
title: " "
|
|
120
122
|
}, iFrameProps, {
|
|
121
|
-
src: postForm ? undefined : src
|
|
123
|
+
src: postForm ? undefined : replaceStagingUrl(preventStagingReplacement, src, environment.runtimeEnvironment)
|
|
122
124
|
}));
|
|
123
125
|
};
|
|
124
126
|
export default HostIframe;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
import useDynamicScript from './utils/useDynamicScript';
|
|
3
3
|
import loadComponent from './utils/loadComponent';
|
|
4
|
+
import { replaceStagingUrl } from "../../util/url";
|
|
4
5
|
const System = _ref => {
|
|
5
6
|
let {
|
|
6
7
|
system,
|
|
@@ -42,7 +43,8 @@ const ModuleHost = _ref2 => {
|
|
|
42
43
|
language,
|
|
43
44
|
parameters,
|
|
44
45
|
customData,
|
|
45
|
-
environment
|
|
46
|
+
environment,
|
|
47
|
+
preventStagingReplacement
|
|
46
48
|
} = _ref2;
|
|
47
49
|
// region initialData
|
|
48
50
|
const initialData = {
|
|
@@ -64,7 +66,11 @@ const ModuleHost = _ref2 => {
|
|
|
64
66
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
65
67
|
className: "module-css"
|
|
66
68
|
}), /*#__PURE__*/React.createElement(System, {
|
|
67
|
-
system:
|
|
69
|
+
system: {
|
|
70
|
+
scope: system.scope,
|
|
71
|
+
url: replaceStagingUrl(preventStagingReplacement, system.url, environment.runtimeEnvironment),
|
|
72
|
+
module: system.module
|
|
73
|
+
},
|
|
68
74
|
data: initialData,
|
|
69
75
|
functions: functions,
|
|
70
76
|
fallback: children,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Environment } from "../types/IChaynsReact";
|
|
2
|
+
export const replaceStagingUrl = (prevent, url, environment) => {
|
|
3
|
+
if (prevent) return url;
|
|
4
|
+
let replacedUrl = url;
|
|
5
|
+
if (environment === Environment.Qa || environment === Environment.Development) {
|
|
6
|
+
replacedUrl = replacedUrl.replace('tapp.chayns-static.space', 'tapp-dev.chayns-static.space');
|
|
7
|
+
}
|
|
8
|
+
if (environment === Environment.Staging) {
|
|
9
|
+
replacedUrl = replacedUrl.replace('tapp.chayns-static.space', 'tapp-staging.chayns-static.space');
|
|
10
|
+
}
|
|
11
|
+
return replacedUrl;
|
|
12
|
+
};
|
|
@@ -56,11 +56,7 @@ export class AppWrapper {
|
|
|
56
56
|
locationPersonId: AppInfo.LocationPersonId,
|
|
57
57
|
urlHash: (_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.location.hash.replace('#', '')
|
|
58
58
|
},
|
|
59
|
-
parameters:
|
|
60
|
-
let [k, v] = _ref;
|
|
61
|
-
p[k] = v;
|
|
62
|
-
return p;
|
|
63
|
-
}, {}),
|
|
59
|
+
parameters: Object.fromEntries(new URLSearchParams(location.search)),
|
|
64
60
|
user: {
|
|
65
61
|
firstName: AppUser.FirstName,
|
|
66
62
|
lastName: AppUser.LastName,
|
|
@@ -183,10 +179,10 @@ export class AppWrapper {
|
|
|
183
179
|
},
|
|
184
180
|
invokeDialogCall: async (value, callback) => {
|
|
185
181
|
const callbackName = `chaynsApiV5Callback_${this.counter++}`;
|
|
186
|
-
window[callbackName] =
|
|
182
|
+
window[callbackName] = _ref => {
|
|
187
183
|
let {
|
|
188
184
|
retVal
|
|
189
|
-
} =
|
|
185
|
+
} = _ref;
|
|
190
186
|
callback === null || callback === void 0 ? void 0 : callback(retVal);
|
|
191
187
|
delete window[callbackName];
|
|
192
188
|
};
|
|
@@ -23,6 +23,7 @@ type ChaynsHostType = {
|
|
|
23
23
|
parameters: ChaynsReactValues["parameters"];
|
|
24
24
|
customData: any;
|
|
25
25
|
environment: ChaynsReactValues["environment"];
|
|
26
|
+
preventStagingReplacement?: boolean;
|
|
26
27
|
};
|
|
27
28
|
declare const ChaynsHost: FC<ChaynsHostType>;
|
|
28
29
|
export default ChaynsHost;
|
|
@@ -19,6 +19,7 @@ type HostIframeProps = {
|
|
|
19
19
|
parameters: ChaynsReactValues["parameters"];
|
|
20
20
|
environment: ChaynsReactValues["environment"];
|
|
21
21
|
customData: ChaynsReactValues["customData"];
|
|
22
|
+
preventStagingReplacement?: boolean;
|
|
22
23
|
};
|
|
23
24
|
declare const HostIframe: FC<HostIframeProps>;
|
|
24
25
|
export default HostIframe;
|
|
@@ -18,6 +18,7 @@ type ModulePropTypes = {
|
|
|
18
18
|
parameters: ChaynsReactValues["parameters"];
|
|
19
19
|
customData: any;
|
|
20
20
|
environment: ChaynsReactValues["environment"];
|
|
21
|
+
preventStagingReplacement?: boolean;
|
|
21
22
|
};
|
|
22
23
|
declare const ModuleHost: FC<ModulePropTypes>;
|
|
23
24
|
export default ModuleHost;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const replaceStagingUrl: (prevent: any, url: any, environment: any) => any;
|