@reltio/components 1.4.1102 → 1.4.1103
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/components/ActionButton/styles.d.ts +1 -1
- package/cjs/components/AttributesFiltersButton/ActionButtons/styles.d.ts +1 -1
- package/cjs/components/DropDownSelector/styles.d.ts +1 -1
- package/cjs/components/ModeSwitcherSelect/styles.d.ts +1 -1
- package/cjs/components/Popper/styles.d.ts +1 -1
- package/cjs/components/ProfileBand/styles.d.ts +1 -1
- package/cjs/components/ProfileCard/styles.d.ts +1 -1
- package/cjs/components/ProfileMatchCard/styles.d.ts +1 -1
- package/cjs/components/attributes/editMode/ComplexAttribute/styles.d.ts +1 -1
- package/cjs/components/attributes/editMode/MoreAttributesButton/styles.d.ts +1 -1
- package/cjs/components/attributes/editMode/SimpleAttributeEditor/styles.d.ts +1 -1
- package/cjs/components/crosswalks/CrosswalkAttributes/styles.d.ts +1 -1
- package/cjs/components/editors/CustomDateRangeEditor/styles.d.ts +1 -1
- package/cjs/components/editors/DateEditor/styles.d.ts +1 -1
- package/cjs/components/editors/DateRangeEditor/styles.d.ts +1 -1
- package/cjs/components/editors/TimestampEditor/styles.d.ts +1 -1
- package/cjs/components/workflow/cards/GenericWorkflowTaskCard/styles.d.ts +1 -1
- package/cjs/components/workflow/components/AddWorkflowDialog/styles.d.ts +1 -1
- package/cjs/components/workflow/components/DueDateField/styles.d.ts +1 -1
- package/cjs/components/workflow/components/LineDecorator/styles.d.ts +1 -1
- package/cjs/contexts/SandboxAPIContext/index.d.ts +6 -0
- package/cjs/contexts/SandboxAPIContext/index.js +12 -0
- package/cjs/contexts/index.d.ts +1 -0
- package/cjs/contexts/index.js +3 -1
- package/cjs/hooks/index.d.ts +3 -0
- package/cjs/hooks/index.js +6 -1
- package/cjs/hooks/useAPI/API.d.ts +2 -0
- package/cjs/hooks/useAPI/API.js +201 -0
- package/cjs/hooks/useAPI/helpers.d.ts +1 -0
- package/cjs/hooks/useAPI/helpers.js +12 -0
- package/cjs/hooks/useAPI/index.d.ts +5 -0
- package/cjs/hooks/useAPI/index.js +11 -0
- package/cjs/hooks/useAPI/types.d.ts +90 -0
- package/cjs/hooks/useAPI/types.js +42 -0
- package/cjs/hooks/useAPI/useAPI.d.ts +13 -0
- package/cjs/hooks/useAPI/useAPI.js +192 -0
- package/cjs/hooks/useCustomScripts.d.ts +9 -0
- package/cjs/hooks/useCustomScripts.js +215 -0
- package/esm/components/ActionButton/styles.d.ts +1 -1
- package/esm/components/AttributesFiltersButton/ActionButtons/styles.d.ts +1 -1
- package/esm/components/DropDownSelector/styles.d.ts +1 -1
- package/esm/components/ModeSwitcherSelect/styles.d.ts +1 -1
- package/esm/components/Popper/styles.d.ts +1 -1
- package/esm/components/ProfileBand/styles.d.ts +1 -1
- package/esm/components/ProfileCard/styles.d.ts +1 -1
- package/esm/components/ProfileMatchCard/styles.d.ts +1 -1
- package/esm/components/attributes/editMode/ComplexAttribute/styles.d.ts +1 -1
- package/esm/components/attributes/editMode/MoreAttributesButton/styles.d.ts +1 -1
- package/esm/components/attributes/editMode/SimpleAttributeEditor/styles.d.ts +1 -1
- package/esm/components/crosswalks/CrosswalkAttributes/styles.d.ts +1 -1
- package/esm/components/editors/CustomDateRangeEditor/styles.d.ts +1 -1
- package/esm/components/editors/DateEditor/styles.d.ts +1 -1
- package/esm/components/editors/DateRangeEditor/styles.d.ts +1 -1
- package/esm/components/editors/TimestampEditor/styles.d.ts +1 -1
- package/esm/components/workflow/cards/GenericWorkflowTaskCard/styles.d.ts +1 -1
- package/esm/components/workflow/components/AddWorkflowDialog/styles.d.ts +1 -1
- package/esm/components/workflow/components/DueDateField/styles.d.ts +1 -1
- package/esm/components/workflow/components/LineDecorator/styles.d.ts +1 -1
- package/esm/contexts/SandboxAPIContext/index.d.ts +6 -0
- package/esm/contexts/SandboxAPIContext/index.js +6 -0
- package/esm/contexts/index.d.ts +1 -0
- package/esm/contexts/index.js +1 -0
- package/esm/hooks/index.d.ts +3 -0
- package/esm/hooks/index.js +2 -0
- package/esm/hooks/useAPI/API.d.ts +2 -0
- package/esm/hooks/useAPI/API.js +197 -0
- package/esm/hooks/useAPI/helpers.d.ts +1 -0
- package/esm/hooks/useAPI/helpers.js +8 -0
- package/esm/hooks/useAPI/index.d.ts +5 -0
- package/esm/hooks/useAPI/index.js +4 -0
- package/esm/hooks/useAPI/types.d.ts +90 -0
- package/esm/hooks/useAPI/types.js +39 -0
- package/esm/hooks/useAPI/useAPI.d.ts +13 -0
- package/esm/hooks/useAPI/useAPI.js +169 -0
- package/esm/hooks/useCustomScripts.d.ts +9 -0
- package/esm/hooks/useCustomScripts.js +189 -0
- package/package.json +3 -3
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
+
if (mod && mod.__esModule) return mod;
|
|
27
|
+
var result = {};
|
|
28
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
+
__setModuleDefault(result, mod);
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.useAPI = void 0;
|
|
34
|
+
var react_1 = require("react");
|
|
35
|
+
var react_redux_1 = require("react-redux");
|
|
36
|
+
var mdm_module_1 = __importStar(require("@reltio/mdm-module"));
|
|
37
|
+
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
38
|
+
var workflow_1 = require("../../components/workflow");
|
|
39
|
+
var contexts_1 = require("../../contexts");
|
|
40
|
+
var API_1 = require("./API");
|
|
41
|
+
var helpers_1 = require("./helpers");
|
|
42
|
+
var types_1 = require("./types");
|
|
43
|
+
var useAPI = function (config) {
|
|
44
|
+
var _a = config.action, files = _a.files, permissions = _a.permissions;
|
|
45
|
+
var _b = react_1.useState(), html = _b[0], setHtml = _b[1];
|
|
46
|
+
var _c = react_1.useState([]), listenersToReset = _c[0], setListenersToReset = _c[1];
|
|
47
|
+
var _d = react_1.useState(true), visible = _d[0], setVisible = _d[1];
|
|
48
|
+
var _e = react_1.useState(null), tooltip = _e[0], setTooltip = _e[1];
|
|
49
|
+
var _f = react_1.useState(null), customStyles = _f[0], setCustomStyles = _f[1];
|
|
50
|
+
var _g = react_1.useState(''), message = _g[0], setMessage = _g[1];
|
|
51
|
+
var dispatch = react_redux_1.useDispatch();
|
|
52
|
+
var metadata = react_redux_1.useSelector(mdm_module_1.default.selectors.getMetadata) || {};
|
|
53
|
+
var entity = react_redux_1.useSelector(mdm_module_1.default.selectors.getEntity) || {};
|
|
54
|
+
var uiPath = react_redux_1.useSelector(mdm_module_1.default.selectors.getUIPath);
|
|
55
|
+
var tenant = react_redux_1.useSelector(mdm_module_1.default.selectors.getTenant);
|
|
56
|
+
var workerUrl = helpers_1.getWorkerURL(uiPath, tenant);
|
|
57
|
+
var apiPath = react_redux_1.useSelector(mdm_module_1.default.selectors.getApiPath);
|
|
58
|
+
var workflowPath = react_redux_1.useSelector(mdm_module_1.default.selectors.getWorkflowPath);
|
|
59
|
+
var user = react_redux_1.useSelector(mdm_module_1.default.selectors.getUser);
|
|
60
|
+
var entityUri = react_redux_1.useSelector(mdm_module_1.default.selectors.getEntityUri);
|
|
61
|
+
var environment = react_redux_1.useSelector(mdm_module_1.default.selectors.getWorkflowEnvironmentUrl);
|
|
62
|
+
var qxApi = react_1.useContext(contexts_1.SandboxAPIContext);
|
|
63
|
+
var workflowCheckPermission = workflow_1.useWorkflowCheckPermission();
|
|
64
|
+
var _h = react_redux_1.useSelector(mdm_module_1.default.selectors.getSearchProviderData) || {}, typeSearch = _h.type, search = _h.data;
|
|
65
|
+
var openSearch = function (search) { return dispatch(mdm_module_1.ui.actions.openSearch(search)); };
|
|
66
|
+
var process = function (task, worker, innerText) {
|
|
67
|
+
if (task) {
|
|
68
|
+
var handlersToReset_1 = [];
|
|
69
|
+
var processInnerHtml_1 = function (parent) {
|
|
70
|
+
var uiActions = parent.getAttribute('ui-actions');
|
|
71
|
+
var uiTooltip = parent.getAttribute('ui-tooltip');
|
|
72
|
+
var id = parent.getAttribute('id') || parent.getAttribute('name');
|
|
73
|
+
if (uiActions) {
|
|
74
|
+
uiActions.split(',').forEach(function (uiAction) {
|
|
75
|
+
var handler = function () {
|
|
76
|
+
var data = {
|
|
77
|
+
action: 'event',
|
|
78
|
+
type: 'uiAction',
|
|
79
|
+
data: {
|
|
80
|
+
type: uiAction,
|
|
81
|
+
id: id
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
worker.postMessage(data);
|
|
85
|
+
};
|
|
86
|
+
parent.addEventListener(uiAction, handler);
|
|
87
|
+
handlersToReset_1.push(function () {
|
|
88
|
+
parent.removeEventListener(uiAction, handler);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
parent.removeAttribute('ui-actions');
|
|
92
|
+
}
|
|
93
|
+
if (uiTooltip) {
|
|
94
|
+
setTooltip(uiTooltip);
|
|
95
|
+
}
|
|
96
|
+
parent.childNodes.forEach(function (child) {
|
|
97
|
+
if (child.nodeType === 1) {
|
|
98
|
+
//Node.ELEMENT_NODE
|
|
99
|
+
processInnerHtml_1(child);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
var resetHtml = function (html) {
|
|
104
|
+
var docBlock = document.createElement('div');
|
|
105
|
+
docBlock.innerHTML = html || innerText;
|
|
106
|
+
processInnerHtml_1(docBlock);
|
|
107
|
+
setListenersToReset(handlersToReset_1);
|
|
108
|
+
setHtml(docBlock);
|
|
109
|
+
};
|
|
110
|
+
if (task.action === types_1.CustomAction.SET_HTML && innerText !== task.params.html) {
|
|
111
|
+
resetHtml(task.params.html);
|
|
112
|
+
}
|
|
113
|
+
switch (task.action) {
|
|
114
|
+
case types_1.CustomAction.LOG: {
|
|
115
|
+
console.log(task.params); //eslint-disable-line no-console
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
case types_1.CustomAction.SET_VISIBILITY: {
|
|
119
|
+
if (task.params === 'visible') {
|
|
120
|
+
setVisible(true);
|
|
121
|
+
resetHtml();
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
setVisible(false);
|
|
125
|
+
}
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
case types_1.CustomAction.SET_TOOLTIP: {
|
|
129
|
+
setTooltip(task.params);
|
|
130
|
+
resetHtml();
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
case types_1.CustomAction.SET_HEIGHT: {
|
|
134
|
+
setCustomStyles(function (prev) { return (__assign(__assign({}, (prev || {})), { height: task.params })); });
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
case types_1.CustomAction.SET_WIDTH: {
|
|
138
|
+
setCustomStyles(function (prev) { return (__assign(__assign({}, (prev || {})), { width: task.params })); });
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
case types_1.CustomAction.SET_ENABLED: {
|
|
142
|
+
setCustomStyles(function (prev) {
|
|
143
|
+
var newStyles = __assign({}, (prev || {}));
|
|
144
|
+
if (!task.params) {
|
|
145
|
+
newStyles['pointer-events'] = 'none';
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
delete newStyles['pointer-events'];
|
|
149
|
+
}
|
|
150
|
+
return newStyles;
|
|
151
|
+
});
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
case types_1.CustomAction.MESSAGE: {
|
|
155
|
+
setMessage(task.params);
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
case types_1.CustomAction.REQUEST: {
|
|
159
|
+
API_1.processRequest(__assign({ name: task.params.name, paramObject: task, permissions: permissions,
|
|
160
|
+
worker: worker,
|
|
161
|
+
metadata: metadata, config: config, user: user,
|
|
162
|
+
apiPath: apiPath,
|
|
163
|
+
tenant: tenant,
|
|
164
|
+
workflowPath: workflowPath,
|
|
165
|
+
entity: entity,
|
|
166
|
+
entityUri: entityUri,
|
|
167
|
+
environment: environment, query: typeSearch === 'search' ? search === null || search === void 0 ? void 0 : search.query : null, openSearch: openSearch,
|
|
168
|
+
workflowCheckPermission: workflowCheckPermission }, qxApi));
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
react_1.useEffect(function () {
|
|
175
|
+
var worker = mdm_sdk_1.initializeWebWorker(workerUrl, files, process);
|
|
176
|
+
return function () {
|
|
177
|
+
worker.terminate();
|
|
178
|
+
};
|
|
179
|
+
}, []);
|
|
180
|
+
react_1.useEffect(function () { return function () {
|
|
181
|
+
listenersToReset.forEach(function (listener) { return listener(); });
|
|
182
|
+
}; }, [listenersToReset]);
|
|
183
|
+
return {
|
|
184
|
+
html: html,
|
|
185
|
+
visible: visible,
|
|
186
|
+
tooltip: tooltip,
|
|
187
|
+
customStyles: customStyles,
|
|
188
|
+
message: message,
|
|
189
|
+
onClosePopup: function () { return setMessage(''); }
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
exports.useAPI = useAPI;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createRequestProvider, CustomScript } from '@reltio/mdm-sdk';
|
|
2
|
+
declare type InterceptHandlers = {
|
|
3
|
+
addInternalRequestInterceptor: ReturnType<typeof createRequestProvider>['addRequestInterceptor'];
|
|
4
|
+
addInternalResponseInterceptor: ReturnType<typeof createRequestProvider>['addResponseInterceptor'];
|
|
5
|
+
removeInternalRequestInterceptor: ReturnType<typeof createRequestProvider>['removeRequestInterceptor'];
|
|
6
|
+
removeInternalResponseInterceptor: ReturnType<typeof createRequestProvider>['removeResponseInterceptor'];
|
|
7
|
+
};
|
|
8
|
+
export declare const useCustomScripts: (config: CustomScript[], { addInternalRequestInterceptor, addInternalResponseInterceptor, removeInternalRequestInterceptor, removeInternalResponseInterceptor }: InterceptHandlers) => void;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
+
if (mod && mod.__esModule) return mod;
|
|
27
|
+
var result = {};
|
|
28
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
+
__setModuleDefault(result, mod);
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
|
+
};
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.useCustomScripts = void 0;
|
|
37
|
+
var react_1 = require("react");
|
|
38
|
+
var react_redux_1 = require("react-redux");
|
|
39
|
+
var mdm_module_1 = __importStar(require("@reltio/mdm-module"));
|
|
40
|
+
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
41
|
+
var nanoid_1 = __importDefault(require("nanoid"));
|
|
42
|
+
var ramda_1 = require("ramda");
|
|
43
|
+
var workflow_1 = require("../components/workflow");
|
|
44
|
+
var contexts_1 = require("../contexts");
|
|
45
|
+
var useAPI_1 = require("./useAPI");
|
|
46
|
+
var isURLtoProcess = function (processApi, url) {
|
|
47
|
+
return (processApi || []).some(function (request) {
|
|
48
|
+
var regExp = new RegExp("^" + request + "$");
|
|
49
|
+
return request.replace(/\/*$/, '') === url || (request && regExp.test(url));
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
var useCustomScripts = function (config, _a) {
|
|
53
|
+
var addInternalRequestInterceptor = _a.addInternalRequestInterceptor, addInternalResponseInterceptor = _a.addInternalResponseInterceptor, removeInternalRequestInterceptor = _a.removeInternalRequestInterceptor, removeInternalResponseInterceptor = _a.removeInternalResponseInterceptor;
|
|
54
|
+
var customScripts = config.map(function (customScript) { return (__assign(__assign({}, customScript), { actionId: nanoid_1.default() })); });
|
|
55
|
+
var dispatch = react_redux_1.useDispatch();
|
|
56
|
+
var metadata = react_redux_1.useSelector(mdm_module_1.default.selectors.getMetadata) || {};
|
|
57
|
+
var entity = react_redux_1.useSelector(mdm_module_1.default.selectors.getEntity) || {};
|
|
58
|
+
var uiPath = react_redux_1.useSelector(mdm_module_1.default.selectors.getUIPath);
|
|
59
|
+
var reltioPath = react_redux_1.useSelector(mdm_module_1.default.selectors.getReltioPath);
|
|
60
|
+
var tenant = react_redux_1.useSelector(mdm_module_1.default.selectors.getTenant);
|
|
61
|
+
var workerUrl = useAPI_1.getWorkerURL(uiPath, tenant);
|
|
62
|
+
var apiPath = react_redux_1.useSelector(mdm_module_1.default.selectors.getApiPath);
|
|
63
|
+
var workflowPath = react_redux_1.useSelector(mdm_module_1.default.selectors.getWorkflowPath);
|
|
64
|
+
var user = react_redux_1.useSelector(mdm_module_1.default.selectors.getUser);
|
|
65
|
+
var entityUri = react_redux_1.useSelector(mdm_module_1.default.selectors.getEntityUri);
|
|
66
|
+
var environment = react_redux_1.useSelector(mdm_module_1.default.selectors.getWorkflowEnvironmentUrl);
|
|
67
|
+
var qxApi = react_1.useContext(contexts_1.SandboxAPIContext);
|
|
68
|
+
var workflowCheckPermission = workflow_1.useWorkflowCheckPermission();
|
|
69
|
+
var _b = react_redux_1.useSelector(mdm_module_1.default.selectors.getSearchProviderData) || {}, typeSearch = _b.type, search = _b.data;
|
|
70
|
+
var openSearch = function (search) { return dispatch(mdm_module_1.ui.actions.openSearch(search)); };
|
|
71
|
+
var requestListeners = react_1.useRef({});
|
|
72
|
+
var responseListeners = react_1.useRef({});
|
|
73
|
+
var workers = react_1.useRef({});
|
|
74
|
+
var process = function (task, worker) {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
if (task) {
|
|
77
|
+
switch (task.action) {
|
|
78
|
+
case useAPI_1.CustomAction.REQUEST: {
|
|
79
|
+
if (((_b = (_a = task.params) === null || _a === void 0 ? void 0 : _a.headers) === null || _b === void 0 ? void 0 : _b.origin) !== 'ui') {
|
|
80
|
+
useAPI_1.processRequest(__assign({ name: task.params.name, paramObject: task, permissions: customScripts[0].permissions, worker: worker,
|
|
81
|
+
metadata: metadata, config: { action: customScripts[0] }, user: user,
|
|
82
|
+
apiPath: apiPath,
|
|
83
|
+
tenant: tenant,
|
|
84
|
+
workflowPath: workflowPath,
|
|
85
|
+
entity: entity,
|
|
86
|
+
entityUri: entityUri,
|
|
87
|
+
environment: environment, query: typeSearch === 'search' ? search === null || search === void 0 ? void 0 : search.query : null, openSearch: openSearch,
|
|
88
|
+
workflowCheckPermission: workflowCheckPermission }, qxApi));
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
var _c = task.params, headers = _c.headers, id = _c.id, fakeURL = _c.url, method = _c.method, data = _c.data;
|
|
92
|
+
var url = fakeURL.replace(reltioPath, apiPath);
|
|
93
|
+
if (requestListeners.current[headers.requestId]) {
|
|
94
|
+
requestListeners.current[headers.requestId].next(url, __assign(__assign({}, data), { id: id,
|
|
95
|
+
task: task,
|
|
96
|
+
headers: headers,
|
|
97
|
+
method: method }));
|
|
98
|
+
requestListeners.current = ramda_1.omit([headers.requestId], requestListeners.current);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
case useAPI_1.CustomAction.RETURN_PROCESSED_API_RESPONSE:
|
|
104
|
+
case useAPI_1.CustomAction.RETURN_PROCESSED_API_REQUEST: {
|
|
105
|
+
var _d = task.params, id = _d.id, data = _d.data;
|
|
106
|
+
if (responseListeners.current[id]) {
|
|
107
|
+
responseListeners.current[id].next(data);
|
|
108
|
+
responseListeners.current = ramda_1.omit([id], responseListeners.current);
|
|
109
|
+
}
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
react_1.useEffect(function () {
|
|
116
|
+
workers.current = customScripts.reduce(function (acc, customScript) {
|
|
117
|
+
var _a;
|
|
118
|
+
acc = __assign(__assign({}, acc), (_a = {}, _a[customScript.actionId] = mdm_sdk_1.initializeWebWorker(workerUrl, customScript.files, process), _a));
|
|
119
|
+
return acc;
|
|
120
|
+
}, workers.current);
|
|
121
|
+
return function () {
|
|
122
|
+
Object.keys(workers.current).forEach(function (actionId) {
|
|
123
|
+
workers.current[actionId].terminate();
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
}, [config]);
|
|
127
|
+
var customScriptRequestInterceptor = function (_a) {
|
|
128
|
+
var _b;
|
|
129
|
+
var _c = _a.options, options = _c === void 0 ? {} : _c, url = _a.url, next = _a.next;
|
|
130
|
+
var fakeURL = url.startsWith('/') && !url.startsWith(apiPath)
|
|
131
|
+
? reltioPath + "/api/" + tenant + url
|
|
132
|
+
: "" + reltioPath + url.replace(apiPath, '');
|
|
133
|
+
var actionId = ramda_1.pipe(ramda_1.map(ramda_1.pick(['actionId', 'processApiRequest'])), ramda_1.find(function (_a) {
|
|
134
|
+
var processApiRequest = _a.processApiRequest;
|
|
135
|
+
return isURLtoProcess(processApiRequest, fakeURL);
|
|
136
|
+
}), ramda_1.prop('actionId'))(customScripts);
|
|
137
|
+
if (actionId) {
|
|
138
|
+
var requestId = nanoid_1.default();
|
|
139
|
+
requestListeners.current = __assign(__assign({}, requestListeners.current), (_b = {}, _b[requestId] = { options: options, next: next, id: requestId }, _b));
|
|
140
|
+
workers.current[actionId].postMessage({
|
|
141
|
+
action: 'apiRequest',
|
|
142
|
+
id: requestId,
|
|
143
|
+
url: fakeURL,
|
|
144
|
+
method: options.method,
|
|
145
|
+
headers: __assign(__assign({}, options.headers), { origin: 'ui', requestId: requestId, actionId: actionId }),
|
|
146
|
+
data: options
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
next(url, options);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
var customScriptResponseInterceptor = function (_a) {
|
|
154
|
+
var _b;
|
|
155
|
+
var url = _a.url, response = _a.response, next = _a.next, options = _a.options, abort = _a.abort;
|
|
156
|
+
if (((_b = options === null || options === void 0 ? void 0 : options.headers) === null || _b === void 0 ? void 0 : _b.origin) === 'ui') {
|
|
157
|
+
response
|
|
158
|
+
.json()
|
|
159
|
+
.then(function (data) {
|
|
160
|
+
var _a;
|
|
161
|
+
var _b, _c, _d;
|
|
162
|
+
responseListeners.current = __assign(__assign({}, responseListeners.current), (_a = {}, _a[options.headers.requestId] = { next: next }, _a));
|
|
163
|
+
workers.current[(_b = options.headers) === null || _b === void 0 ? void 0 : _b.actionId].postMessage({
|
|
164
|
+
action: 'response',
|
|
165
|
+
result: { data: data },
|
|
166
|
+
id: options === null || options === void 0 ? void 0 : options.id,
|
|
167
|
+
name: (_d = (_c = options === null || options === void 0 ? void 0 : options.task) === null || _c === void 0 ? void 0 : _c.params) === null || _d === void 0 ? void 0 : _d.name
|
|
168
|
+
});
|
|
169
|
+
})
|
|
170
|
+
.catch(function (error) {
|
|
171
|
+
abort(error);
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
var fakeURL_1 = "" + reltioPath + url.replace(apiPath, '');
|
|
176
|
+
var actionId_1 = ramda_1.pipe(ramda_1.map(ramda_1.pick(['actionId', 'processApiResponse'])), ramda_1.find(function (_a) {
|
|
177
|
+
var processApiResponse = _a.processApiResponse;
|
|
178
|
+
return isURLtoProcess(processApiResponse, fakeURL_1);
|
|
179
|
+
}), ramda_1.prop('actionId'))(customScripts);
|
|
180
|
+
if (actionId_1) {
|
|
181
|
+
var responseId_1 = nanoid_1.default();
|
|
182
|
+
response
|
|
183
|
+
.json()
|
|
184
|
+
.then(function (data) {
|
|
185
|
+
var _a;
|
|
186
|
+
responseListeners.current = __assign(__assign({}, responseListeners.current), (_a = {}, _a[responseId_1] = { next: next }, _a));
|
|
187
|
+
workers.current[actionId_1].postMessage({
|
|
188
|
+
action: 'apiResponse',
|
|
189
|
+
id: responseId_1,
|
|
190
|
+
url: fakeURL_1,
|
|
191
|
+
method: options.method,
|
|
192
|
+
data: data
|
|
193
|
+
});
|
|
194
|
+
})
|
|
195
|
+
.catch(function (error) {
|
|
196
|
+
abort(error);
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
next(response);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
react_1.useEffect(function () {
|
|
205
|
+
if (!mdm_sdk_1.isEmptyValue(config)) {
|
|
206
|
+
addInternalRequestInterceptor(customScriptRequestInterceptor);
|
|
207
|
+
addInternalResponseInterceptor(customScriptResponseInterceptor);
|
|
208
|
+
return function () {
|
|
209
|
+
removeInternalRequestInterceptor(customScriptRequestInterceptor);
|
|
210
|
+
removeInternalResponseInterceptor(customScriptResponseInterceptor);
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
}, [config]);
|
|
214
|
+
};
|
|
215
|
+
exports.useCustomScripts = useCustomScripts;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"label" | "button" | "
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"label" | "button" | "menuItem" | "menuText" | "startIcon" | "iconButton" | "overflowStyle" | "menuIcon">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"cancelButton" | "buttonsWrapper" | "applyButton" | "clearButon">;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"
|
|
1
|
+
export const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"inputLabel" | "formControl" | "control" | "valueContainer" | "dropdownIndicator" | "filledInputUnderline" | "filledInputRoot">;
|
|
2
2
|
export namespace customStyles {
|
|
3
3
|
function menu(baseStyles: any): any;
|
|
4
4
|
function menuList(baseStyles: any): any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"root" | "outlined" | "
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"root" | "outlined" | "menuItem" | "currentValue" | "arrowIcon" | "currentValueIcon" | "currentValueText" | "firstMenuItemButton" | "menuItemInner" | "menuItemIcon" | "menuItemLabel" | "menuItemDescription">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"backdrop" | "popper">;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export default useStyles;
|
|
2
|
-
declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"label" | "entityType" | "secondaryLabel" | "inactive" | "
|
|
2
|
+
declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"label" | "entityType" | "secondaryLabel" | "inactive" | "entityId" | "badge" | "profileIcon" | "businessCard" | "profileBandWrapper" | "profileBand" | "imageProfileIcon" | "profileInfo" | "specialInfo">;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"label" | "image" | "secondaryLabel" | "link" | "
|
|
1
|
+
declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"label" | "image" | "secondaryLabel" | "link" | "info" | "container" | "thirdRow" | "entityId" | "entityIdLabel" | "entityIdValue">;
|
|
2
2
|
export default useStyles;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"root" | "
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"root" | "profileCardWrapper" | "profileCardContainer" | "rulesContainer">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"deleted" | "label" | "actions" | "
|
|
1
|
+
export const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"deleted" | "label" | "actions" | "editor" | "expandButton" | "editedLabel" | "titleContainer" | "errorWrapperHelperText">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"dense" | "icon" | "
|
|
1
|
+
export const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"dense" | "icon" | "buttonLabel" | "moreButton" | "moreAttributes" | "popupContainer" | "moreAttributesPopup">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"deleted" | "button" | "placeholder" | "
|
|
1
|
+
export const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"deleted" | "button" | "placeholder" | "editor" | "wrapper" | "addButton" | "errorWrapper" | "editor-value" | "editor-read-only-value" | "editor-actions" | "editedLabel">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"attributeValue" | "text" | "input" | "
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"attributeValue" | "text" | "input" | "editor" | "moreButton" | "sourceIcon" | "attributeTitle" | "attributeWrapper">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"input" | "root" | "
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"input" | "root" | "inputRoot" | "paper" | "dateOptionLabel" | "dropdownIndicator">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"underline" | "icon" | "
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"underline" | "icon" | "inputLabel" | "iconButtonRoot" | "adornedEnd" | "adornmentPositionEnd" | "inputRoot">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"underline" | "
|
|
1
|
+
export const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"underline" | "inputLabel" | "adornedEnd" | "inputRoot" | "paper" | "menuItem" | "menuText" | "dropdownIndicator">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"underline" | "
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"underline" | "inputLabel" | "iconButtonRoot" | "adornedEnd" | "inputRoot">;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare const useStyles: (props: {
|
|
2
2
|
color: string;
|
|
3
|
-
}) => import("@material-ui/core/styles/withStyles").ClassNameMap<"title" | "priority" | "flex" | "caption" | "icon" | "header" | "line" | "date" | "
|
|
3
|
+
}) => import("@material-ui/core/styles/withStyles").ClassNameMap<"title" | "priority" | "flex" | "caption" | "icon" | "header" | "line" | "date" | "card" | "withBackground" | "lineWrapper" | "info" | "commentsInfo" | "commentsIcon" | "infoValue" | "infoBlock" | "flag" | "mainInfo" | "controlsBox" | "controlsInRow" | "comments">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"content" | "title" | "footer" | "input" | "select" | "inputRoot" | "
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"content" | "title" | "footer" | "input" | "select" | "inputRoot" | "popoverPaper" | "simpleDropDownSelector" | "cancelButton">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"dueDate" | "
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"dueDate" | "dueDateInput" | "inputLabel">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"content" | "last" | "line" | "
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"content" | "last" | "line" | "decorator" | "lineBlock" | "withLinePadding" | "noLine" | "plain" | "rowDivider">;
|
package/esm/contexts/index.d.ts
CHANGED
|
@@ -15,5 +15,6 @@ export { EntityMarkerContext } from './EntityMarkerContext';
|
|
|
15
15
|
export { WorkflowTasksContext } from './WorkflowTasksContext';
|
|
16
16
|
export { RelatedObjectUrisContext } from './RelatedObjectUrisContext';
|
|
17
17
|
export { EntityContext } from './EntityContext';
|
|
18
|
+
export { SandboxAPIContext } from './SandboxAPIContext';
|
|
18
19
|
export { useReloadAllFacets, ReloadFacetProvider, useReloadFacet } from './ReloadFacetContext';
|
|
19
20
|
export { SearchFiltersContext } from './SearchFiltersContext';
|
package/esm/contexts/index.js
CHANGED
|
@@ -15,5 +15,6 @@ export { EntityMarkerContext } from './EntityMarkerContext';
|
|
|
15
15
|
export { WorkflowTasksContext } from './WorkflowTasksContext';
|
|
16
16
|
export { RelatedObjectUrisContext } from './RelatedObjectUrisContext';
|
|
17
17
|
export { EntityContext } from './EntityContext';
|
|
18
|
+
export { SandboxAPIContext } from './SandboxAPIContext';
|
|
18
19
|
export { useReloadAllFacets, ReloadFacetProvider, useReloadFacet } from './ReloadFacetContext';
|
|
19
20
|
export { SearchFiltersContext } from './SearchFiltersContext';
|
package/esm/hooks/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { useActions } from './useActions';
|
|
2
|
+
export { useAPI, CustomAction } from './useAPI';
|
|
3
|
+
export type { CustomActionTask } from './useAPI';
|
|
2
4
|
export { useAsyncMount } from './useAsyncMount';
|
|
3
5
|
export { useCollaboration } from './useCollaboration';
|
|
4
6
|
export { useDidUpdateEffect } from './useDidUpdateEffect';
|
|
@@ -15,5 +17,6 @@ export { useMatchesLoader } from './useMatchesLoader';
|
|
|
15
17
|
export { usePagingSimulator } from './usePagingSimulator';
|
|
16
18
|
export { useMergeAllRequest } from './useMergeAllRequest';
|
|
17
19
|
export { useMarkAsNotMatchRequest } from './useMarkAsNotMatchRequest';
|
|
20
|
+
export { useCustomScripts } from './useCustomScripts';
|
|
18
21
|
export { useEditableConnection } from './useEditableConnection';
|
|
19
22
|
export { useReadableSearchState } from './useReadableSearchState';
|
package/esm/hooks/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { useActions } from './useActions';
|
|
2
|
+
export { useAPI, CustomAction } from './useAPI';
|
|
2
3
|
export { useAsyncMount } from './useAsyncMount';
|
|
3
4
|
export { useCollaboration } from './useCollaboration';
|
|
4
5
|
export { useDidUpdateEffect } from './useDidUpdateEffect';
|
|
@@ -15,5 +16,6 @@ export { useMatchesLoader } from './useMatchesLoader';
|
|
|
15
16
|
export { usePagingSimulator } from './usePagingSimulator';
|
|
16
17
|
export { useMergeAllRequest } from './useMergeAllRequest';
|
|
17
18
|
export { useMarkAsNotMatchRequest } from './useMarkAsNotMatchRequest';
|
|
19
|
+
export { useCustomScripts } from './useCustomScripts';
|
|
18
20
|
export { useEditableConnection } from './useEditableConnection';
|
|
19
21
|
export { useReadableSearchState } from './useReadableSearchState';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { ProcessRequestParams } from './types';
|
|
2
|
+
export declare const processRequest: ({ name, paramObject, permissions, worker, metadata, config, apiPath, user, workflowPath, entity, tenant, entityUri, query, openSearch, environment, getCurrentPerspectiveId, showPerspective, workflowCheckPermission, setEntityUri }: ProcessRequestParams) => void;
|