@reltio/components 1.4.1830 → 1.4.1831
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/cjs/hooks/useAPI/useAPI.js +20 -15
- package/cjs/hooks/useCustomScripts.js +16 -16
- package/esm/hooks/useAPI/useAPI.js +20 -15
- package/esm/hooks/useCustomScripts.js +16 -16
- package/package.json +2 -2
|
@@ -21,16 +21,18 @@ var contexts_1 = require("../../contexts");
|
|
|
21
21
|
var API_1 = require("./API");
|
|
22
22
|
var helpers_1 = require("./helpers");
|
|
23
23
|
var useAPI = function (config) {
|
|
24
|
+
var _a;
|
|
24
25
|
if (config === void 0) { config = {}; }
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
var
|
|
30
|
-
var
|
|
31
|
-
var
|
|
32
|
-
var
|
|
26
|
+
var _b = config.action || {}, processApiRequest = _b.processApiRequest, processApiResponse = _b.processApiResponse, platform = _b.platform;
|
|
27
|
+
var _c = (0, react_1.useState)(), html = _c[0], setHtml = _c[1];
|
|
28
|
+
var _d = (0, react_1.useState)([]), listenersToReset = _d[0], setListenersToReset = _d[1];
|
|
29
|
+
var _e = (0, react_1.useState)([]), popupListenersToReset = _e[0], setPopupListenersToReset = _e[1];
|
|
30
|
+
var _f = (0, react_1.useState)(true), visible = _f[0], setVisible = _f[1];
|
|
31
|
+
var _g = (0, react_1.useState)(), popup = _g[0], setPopup = _g[1];
|
|
32
|
+
var _h = (0, react_1.useState)(null), tooltip = _h[0], setTooltip = _h[1];
|
|
33
|
+
var _j = (0, react_1.useState)({}), customStyles = _j[0], setCustomStyles = _j[1];
|
|
33
34
|
var workerRef = (0, react_1.useRef)();
|
|
35
|
+
var entityRef = (0, react_1.useRef)();
|
|
34
36
|
var requestListeners = (0, react_1.useRef)({});
|
|
35
37
|
var responseListeners = (0, react_1.useRef)({});
|
|
36
38
|
var sanitizeHtml = (0, useHtmlSanitizer_1.useHtmlSanitizer)();
|
|
@@ -42,8 +44,8 @@ var useAPI = function (config) {
|
|
|
42
44
|
var qxApi = (0, react_1.useContext)(contexts_1.SandboxAPIContext);
|
|
43
45
|
var interceptHandlers = (0, react_1.useContext)(contexts_1.InterceptHandlersContext);
|
|
44
46
|
var workflowCheckPermission = (0, workflow_1.useWorkflowCheckPermission)();
|
|
45
|
-
var metadata = (0, contexts_1.useMdmMetadata)()
|
|
46
|
-
var entity = (0, contexts_1.useMdmEntity)()
|
|
47
|
+
var metadata = (0, contexts_1.useMdmMetadata)();
|
|
48
|
+
var entity = (0, contexts_1.useMdmEntity)();
|
|
47
49
|
var apiPath = (0, contexts_1.useMdmApiPath)();
|
|
48
50
|
var servicesPath = (0, contexts_1.useMdmServicesPath)();
|
|
49
51
|
var reltioPath = (0, contexts_1.useMdmReltioPath)();
|
|
@@ -52,8 +54,8 @@ var useAPI = function (config) {
|
|
|
52
54
|
var entityUri = (0, contexts_1.useMdmEntityUri)();
|
|
53
55
|
var isEditableMode = (0, contexts_1.useMdmIsEditableMode)();
|
|
54
56
|
var environment = (0, contexts_1.useMdmWorkflowEnvironmentUrl)();
|
|
55
|
-
var
|
|
56
|
-
var searchQuery =
|
|
57
|
+
var searchProviderData = (0, contexts_1.useMdmSearchProviderData)();
|
|
58
|
+
var searchQuery = (searchProviderData === null || searchProviderData === void 0 ? void 0 : searchProviderData.type) === 'search' ? (_a = searchProviderData === null || searchProviderData === void 0 ? void 0 : searchProviderData.data) === null || _a === void 0 ? void 0 : _a.query : null;
|
|
57
59
|
var innerText = '';
|
|
58
60
|
var popupText = '';
|
|
59
61
|
var process = function (_a) {
|
|
@@ -142,7 +144,7 @@ var useAPI = function (config) {
|
|
|
142
144
|
}
|
|
143
145
|
case mdm_sdk_1.CustomAction.REQUEST: {
|
|
144
146
|
var processedTask = (0, helpers_1.getProcessedTask)(task, apiPath, reltioPath, tenant);
|
|
145
|
-
(0, API_1.processRequest)(__assign({ params: processedTask.params, permissions: config.action.permissions, worker: worker, metadata: metadata, config: config, user: user, servicesPath: servicesPath, apiPath: reltioPath, tenant: tenant, workflowPath: workflowPath, entity:
|
|
147
|
+
(0, API_1.processRequest)(__assign({ params: processedTask.params, permissions: config.action.permissions, worker: worker, metadata: metadata, config: config, user: user, servicesPath: servicesPath, apiPath: reltioPath, tenant: tenant, workflowPath: workflowPath, entity: entityRef.current, entityUri: entityUri, environment: environment, query: searchQuery, openSearch: openSearch, workflowCheckPermission: workflowCheckPermission }, qxApi));
|
|
146
148
|
break;
|
|
147
149
|
}
|
|
148
150
|
case mdm_sdk_1.CustomAction.RETURN_PROCESSED_API_RESPONSE: {
|
|
@@ -209,9 +211,12 @@ var useAPI = function (config) {
|
|
|
209
211
|
interceptHandlers.finishInterceptorInit();
|
|
210
212
|
pendingInterceptors.current = false;
|
|
211
213
|
}
|
|
212
|
-
postEventMessage('updateEntity', entity);
|
|
213
214
|
}
|
|
214
|
-
}, [
|
|
215
|
+
}, [config]);
|
|
216
|
+
(0, react_1.useEffect)(function () {
|
|
217
|
+
postEventMessage('updateEntity', entity);
|
|
218
|
+
entityRef.current = entity;
|
|
219
|
+
}, [entity]);
|
|
215
220
|
(0, react_1.useEffect)(function () {
|
|
216
221
|
postEventMessage('editMode', isEditableMode);
|
|
217
222
|
}, [isEditableMode]);
|
|
@@ -56,8 +56,8 @@ var useCustomScripts = function (config) {
|
|
|
56
56
|
var _b = (0, react_1.useContext)(contexts_1.InterceptHandlersContext), addInternalRequestInterceptor = _b.addInternalRequestInterceptor, addInternalResponseInterceptor = _b.addInternalResponseInterceptor, removeInternalRequestInterceptor = _b.removeInternalRequestInterceptor, removeInternalResponseInterceptor = _b.removeInternalResponseInterceptor;
|
|
57
57
|
var qxApi = (0, react_1.useContext)(contexts_1.SandboxAPIContext);
|
|
58
58
|
var openSearch = (0, contexts_1.useMdmAction)('openSearch');
|
|
59
|
-
var metadata = (
|
|
60
|
-
var entity = (0, contexts_1.useMdmEntity)()
|
|
59
|
+
var metadata = (0, contexts_1.useMdmMetadata)();
|
|
60
|
+
var entity = (0, contexts_1.useMdmEntity)();
|
|
61
61
|
var uiPath = (0, contexts_1.useMdmUiPath)();
|
|
62
62
|
var servicesPath = (0, contexts_1.useMdmServicesPath)();
|
|
63
63
|
var reltioPath = (0, contexts_1.useMdmReltioPath)();
|
|
@@ -69,7 +69,8 @@ var useCustomScripts = function (config) {
|
|
|
69
69
|
var entityUri = (0, contexts_1.useMdmEntityUri)();
|
|
70
70
|
var environment = (0, contexts_1.useMdmWorkflowEnvironmentUrl)();
|
|
71
71
|
var workflowCheckPermission = (0, workflow_1.useWorkflowCheckPermission)();
|
|
72
|
-
var
|
|
72
|
+
var searchProviderData = (0, contexts_1.useMdmSearchProviderData)();
|
|
73
|
+
var searchQuery = (searchProviderData === null || searchProviderData === void 0 ? void 0 : searchProviderData.type) === 'search' ? (_a = searchProviderData === null || searchProviderData === void 0 ? void 0 : searchProviderData.data) === null || _a === void 0 ? void 0 : _a.query : null;
|
|
73
74
|
var requestListeners = (0, react_1.useRef)({});
|
|
74
75
|
var responseListeners = (0, react_1.useRef)({});
|
|
75
76
|
var workers = (0, react_1.useRef)({});
|
|
@@ -87,7 +88,7 @@ var useCustomScripts = function (config) {
|
|
|
87
88
|
}
|
|
88
89
|
case mdm_sdk_1.CustomAction.REQUEST: {
|
|
89
90
|
var processedTask = (0, helpers_1.getProcessedTask)(task, apiPath, reltioPath, tenant);
|
|
90
|
-
(0, useAPI_1.processRequest)(__assign({ params: processedTask.params, permissions: config.action.permissions, worker: worker, metadata: metadata, config: config, user: user, apiPath: reltioPath, servicesPath: servicesPath, tenant: tenant, workflowPath: workflowPath, entity: entity, entityUri: entityUri, environment: environment, query:
|
|
91
|
+
(0, useAPI_1.processRequest)(__assign({ params: processedTask.params, permissions: config.action.permissions, worker: worker, metadata: metadata, config: config, user: user, apiPath: reltioPath, servicesPath: servicesPath, tenant: tenant, workflowPath: workflowPath, entity: entity, entityUri: entityUri, environment: environment, query: searchQuery, openSearch: openSearch, workflowCheckPermission: workflowCheckPermission }, qxApi));
|
|
91
92
|
break;
|
|
92
93
|
}
|
|
93
94
|
case mdm_sdk_1.CustomAction.RETURN_PROCESSED_API_RESPONSE: {
|
|
@@ -110,19 +111,18 @@ var useCustomScripts = function (config) {
|
|
|
110
111
|
}
|
|
111
112
|
};
|
|
112
113
|
(0, react_1.useEffect)(function () {
|
|
113
|
-
if (metadata
|
|
114
|
-
|
|
114
|
+
if (metadata) {
|
|
115
|
+
workers.current = customScripts.reduce(function (acc, customScript) {
|
|
116
|
+
var _a;
|
|
117
|
+
var customViewConfig = getCustomViewConfig(customScript);
|
|
118
|
+
return __assign(__assign({}, acc), (_a = {}, _a[customScript.actionId] = (0, mdm_sdk_1.initializeWebWorker)(workerUrl, processMessageFromWorker, customViewConfig), _a));
|
|
119
|
+
}, workers.current);
|
|
120
|
+
return function () {
|
|
121
|
+
Object.keys(workers.current).forEach(function (actionId) {
|
|
122
|
+
workers.current[actionId].terminate();
|
|
123
|
+
});
|
|
124
|
+
};
|
|
115
125
|
}
|
|
116
|
-
workers.current = customScripts.reduce(function (acc, customScript) {
|
|
117
|
-
var _a;
|
|
118
|
-
var customViewConfig = getCustomViewConfig(customScript);
|
|
119
|
-
return __assign(__assign({}, acc), (_a = {}, _a[customScript.actionId] = (0, mdm_sdk_1.initializeWebWorker)(workerUrl, processMessageFromWorker, customViewConfig), _a));
|
|
120
|
-
}, workers.current);
|
|
121
|
-
return function () {
|
|
122
|
-
Object.keys(workers.current).forEach(function (actionId) {
|
|
123
|
-
workers.current[actionId].terminate();
|
|
124
|
-
});
|
|
125
|
-
};
|
|
126
126
|
}, [config, metadata]);
|
|
127
127
|
var customScriptRequestInterceptor = function (_a) {
|
|
128
128
|
var _b;
|
|
@@ -18,16 +18,18 @@ import { InterceptHandlersContext, SandboxAPIContext, SnackbarContext, useMdmAct
|
|
|
18
18
|
import { processRequest } from './API';
|
|
19
19
|
import { getWorkerURL, isValidCustomScript, resetHtml, getProcessedTask, setUpRequestInterceptor, setUpResponseInterceptor } from './helpers';
|
|
20
20
|
export var useAPI = function (config) {
|
|
21
|
+
var _a;
|
|
21
22
|
if (config === void 0) { config = {}; }
|
|
22
|
-
var
|
|
23
|
-
var
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
var
|
|
23
|
+
var _b = config.action || {}, processApiRequest = _b.processApiRequest, processApiResponse = _b.processApiResponse, platform = _b.platform;
|
|
24
|
+
var _c = useState(), html = _c[0], setHtml = _c[1];
|
|
25
|
+
var _d = useState([]), listenersToReset = _d[0], setListenersToReset = _d[1];
|
|
26
|
+
var _e = useState([]), popupListenersToReset = _e[0], setPopupListenersToReset = _e[1];
|
|
27
|
+
var _f = useState(true), visible = _f[0], setVisible = _f[1];
|
|
28
|
+
var _g = useState(), popup = _g[0], setPopup = _g[1];
|
|
29
|
+
var _h = useState(null), tooltip = _h[0], setTooltip = _h[1];
|
|
30
|
+
var _j = useState({}), customStyles = _j[0], setCustomStyles = _j[1];
|
|
30
31
|
var workerRef = useRef();
|
|
32
|
+
var entityRef = useRef();
|
|
31
33
|
var requestListeners = useRef({});
|
|
32
34
|
var responseListeners = useRef({});
|
|
33
35
|
var sanitizeHtml = useHtmlSanitizer();
|
|
@@ -39,8 +41,8 @@ export var useAPI = function (config) {
|
|
|
39
41
|
var qxApi = useContext(SandboxAPIContext);
|
|
40
42
|
var interceptHandlers = useContext(InterceptHandlersContext);
|
|
41
43
|
var workflowCheckPermission = useWorkflowCheckPermission();
|
|
42
|
-
var metadata = useMdmMetadata()
|
|
43
|
-
var entity = useMdmEntity()
|
|
44
|
+
var metadata = useMdmMetadata();
|
|
45
|
+
var entity = useMdmEntity();
|
|
44
46
|
var apiPath = useMdmApiPath();
|
|
45
47
|
var servicesPath = useMdmServicesPath();
|
|
46
48
|
var reltioPath = useMdmReltioPath();
|
|
@@ -49,8 +51,8 @@ export var useAPI = function (config) {
|
|
|
49
51
|
var entityUri = useMdmEntityUri();
|
|
50
52
|
var isEditableMode = useMdmIsEditableMode();
|
|
51
53
|
var environment = useMdmWorkflowEnvironmentUrl();
|
|
52
|
-
var
|
|
53
|
-
var searchQuery =
|
|
54
|
+
var searchProviderData = useMdmSearchProviderData();
|
|
55
|
+
var searchQuery = (searchProviderData === null || searchProviderData === void 0 ? void 0 : searchProviderData.type) === 'search' ? (_a = searchProviderData === null || searchProviderData === void 0 ? void 0 : searchProviderData.data) === null || _a === void 0 ? void 0 : _a.query : null;
|
|
54
56
|
var innerText = '';
|
|
55
57
|
var popupText = '';
|
|
56
58
|
var process = function (_a) {
|
|
@@ -139,7 +141,7 @@ export var useAPI = function (config) {
|
|
|
139
141
|
}
|
|
140
142
|
case CustomAction.REQUEST: {
|
|
141
143
|
var processedTask = getProcessedTask(task, apiPath, reltioPath, tenant);
|
|
142
|
-
processRequest(__assign({ params: processedTask.params, permissions: config.action.permissions, worker: worker, metadata: metadata, config: config, user: user, servicesPath: servicesPath, apiPath: reltioPath, tenant: tenant, workflowPath: workflowPath, entity:
|
|
144
|
+
processRequest(__assign({ params: processedTask.params, permissions: config.action.permissions, worker: worker, metadata: metadata, config: config, user: user, servicesPath: servicesPath, apiPath: reltioPath, tenant: tenant, workflowPath: workflowPath, entity: entityRef.current, entityUri: entityUri, environment: environment, query: searchQuery, openSearch: openSearch, workflowCheckPermission: workflowCheckPermission }, qxApi));
|
|
143
145
|
break;
|
|
144
146
|
}
|
|
145
147
|
case CustomAction.RETURN_PROCESSED_API_RESPONSE: {
|
|
@@ -206,9 +208,12 @@ export var useAPI = function (config) {
|
|
|
206
208
|
interceptHandlers.finishInterceptorInit();
|
|
207
209
|
pendingInterceptors.current = false;
|
|
208
210
|
}
|
|
209
|
-
postEventMessage('updateEntity', entity);
|
|
210
211
|
}
|
|
211
|
-
}, [
|
|
212
|
+
}, [config]);
|
|
213
|
+
useEffect(function () {
|
|
214
|
+
postEventMessage('updateEntity', entity);
|
|
215
|
+
entityRef.current = entity;
|
|
216
|
+
}, [entity]);
|
|
212
217
|
useEffect(function () {
|
|
213
218
|
postEventMessage('editMode', isEditableMode);
|
|
214
219
|
}, [isEditableMode]);
|
|
@@ -53,8 +53,8 @@ export var useCustomScripts = function (config) {
|
|
|
53
53
|
var _b = useContext(InterceptHandlersContext), addInternalRequestInterceptor = _b.addInternalRequestInterceptor, addInternalResponseInterceptor = _b.addInternalResponseInterceptor, removeInternalRequestInterceptor = _b.removeInternalRequestInterceptor, removeInternalResponseInterceptor = _b.removeInternalResponseInterceptor;
|
|
54
54
|
var qxApi = useContext(SandboxAPIContext);
|
|
55
55
|
var openSearch = useMdmAction('openSearch');
|
|
56
|
-
var metadata =
|
|
57
|
-
var entity = useMdmEntity()
|
|
56
|
+
var metadata = useMdmMetadata();
|
|
57
|
+
var entity = useMdmEntity();
|
|
58
58
|
var uiPath = useMdmUiPath();
|
|
59
59
|
var servicesPath = useMdmServicesPath();
|
|
60
60
|
var reltioPath = useMdmReltioPath();
|
|
@@ -66,7 +66,8 @@ export var useCustomScripts = function (config) {
|
|
|
66
66
|
var entityUri = useMdmEntityUri();
|
|
67
67
|
var environment = useMdmWorkflowEnvironmentUrl();
|
|
68
68
|
var workflowCheckPermission = useWorkflowCheckPermission();
|
|
69
|
-
var
|
|
69
|
+
var searchProviderData = useMdmSearchProviderData();
|
|
70
|
+
var searchQuery = (searchProviderData === null || searchProviderData === void 0 ? void 0 : searchProviderData.type) === 'search' ? (_a = searchProviderData === null || searchProviderData === void 0 ? void 0 : searchProviderData.data) === null || _a === void 0 ? void 0 : _a.query : null;
|
|
70
71
|
var requestListeners = useRef({});
|
|
71
72
|
var responseListeners = useRef({});
|
|
72
73
|
var workers = useRef({});
|
|
@@ -84,7 +85,7 @@ export var useCustomScripts = function (config) {
|
|
|
84
85
|
}
|
|
85
86
|
case CustomAction.REQUEST: {
|
|
86
87
|
var processedTask = getProcessedTask(task, apiPath, reltioPath, tenant);
|
|
87
|
-
processRequest(__assign({ params: processedTask.params, permissions: config.action.permissions, worker: worker, metadata: metadata, config: config, user: user, apiPath: reltioPath, servicesPath: servicesPath, tenant: tenant, workflowPath: workflowPath, entity: entity, entityUri: entityUri, environment: environment, query:
|
|
88
|
+
processRequest(__assign({ params: processedTask.params, permissions: config.action.permissions, worker: worker, metadata: metadata, config: config, user: user, apiPath: reltioPath, servicesPath: servicesPath, tenant: tenant, workflowPath: workflowPath, entity: entity, entityUri: entityUri, environment: environment, query: searchQuery, openSearch: openSearch, workflowCheckPermission: workflowCheckPermission }, qxApi));
|
|
88
89
|
break;
|
|
89
90
|
}
|
|
90
91
|
case CustomAction.RETURN_PROCESSED_API_RESPONSE: {
|
|
@@ -107,19 +108,18 @@ export var useCustomScripts = function (config) {
|
|
|
107
108
|
}
|
|
108
109
|
};
|
|
109
110
|
useEffect(function () {
|
|
110
|
-
if (metadata
|
|
111
|
-
|
|
111
|
+
if (metadata) {
|
|
112
|
+
workers.current = customScripts.reduce(function (acc, customScript) {
|
|
113
|
+
var _a;
|
|
114
|
+
var customViewConfig = getCustomViewConfig(customScript);
|
|
115
|
+
return __assign(__assign({}, acc), (_a = {}, _a[customScript.actionId] = initializeWebWorker(workerUrl, processMessageFromWorker, customViewConfig), _a));
|
|
116
|
+
}, workers.current);
|
|
117
|
+
return function () {
|
|
118
|
+
Object.keys(workers.current).forEach(function (actionId) {
|
|
119
|
+
workers.current[actionId].terminate();
|
|
120
|
+
});
|
|
121
|
+
};
|
|
112
122
|
}
|
|
113
|
-
workers.current = customScripts.reduce(function (acc, customScript) {
|
|
114
|
-
var _a;
|
|
115
|
-
var customViewConfig = getCustomViewConfig(customScript);
|
|
116
|
-
return __assign(__assign({}, acc), (_a = {}, _a[customScript.actionId] = initializeWebWorker(workerUrl, processMessageFromWorker, customViewConfig), _a));
|
|
117
|
-
}, workers.current);
|
|
118
|
-
return function () {
|
|
119
|
-
Object.keys(workers.current).forEach(function (actionId) {
|
|
120
|
-
workers.current[actionId].terminate();
|
|
121
|
-
});
|
|
122
|
-
};
|
|
123
123
|
}, [config, metadata]);
|
|
124
124
|
var customScriptRequestInterceptor = function (_a) {
|
|
125
125
|
var _b;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reltio/components",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1831",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE FILE",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@fluentui/react-context-selector": "^9.1.26",
|
|
9
9
|
"@react-google-maps/api": "2.7.0",
|
|
10
|
-
"@reltio/mdm-sdk": "^1.4.
|
|
10
|
+
"@reltio/mdm-sdk": "^1.4.1790",
|
|
11
11
|
"classnames": "^2.2.5",
|
|
12
12
|
"d3-cloud": "^1.2.5",
|
|
13
13
|
"d3-geo": "^2.0.1",
|