@reltio/components 1.4.1434 → 1.4.1436

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.
Files changed (65) hide show
  1. package/cjs/components/BasicTableView/BasicTable/helpers/dataHelpers.js +2 -1
  2. package/cjs/components/attributes/DescriptionIcon/DescriptionIcon.d.ts +31 -0
  3. package/cjs/components/attributes/DescriptionIcon/DescriptionIcon.js +51 -0
  4. package/cjs/components/attributes/DescriptionIcon/index.d.ts +1 -0
  5. package/cjs/components/attributes/DescriptionIcon/index.js +8 -0
  6. package/cjs/components/attributes/DescriptionIcon/styles.d.ts +1 -0
  7. package/cjs/components/attributes/DescriptionIcon/styles.js +24 -0
  8. package/cjs/components/attributes/OvIcon/OvIcon.js +1 -1
  9. package/cjs/components/attributes/editMode/AttributesPager/AttributeRenderer.js +3 -1
  10. package/cjs/components/attributes/editMode/AttributesPager/styles.d.ts +1 -1
  11. package/cjs/components/attributes/editMode/AttributesPager/styles.js +3 -0
  12. package/cjs/components/attributes/readMode/AttributesPager/MultiLineRenderer.js +3 -1
  13. package/cjs/components/attributes/readMode/AttributesPager/OneLineRenderer.js +3 -1
  14. package/cjs/components/attributes/readMode/AttributesPager/styles.d.ts +2 -2
  15. package/cjs/components/attributes/readMode/AttributesPager/styles.js +5 -0
  16. package/cjs/components/index.d.ts +1 -0
  17. package/cjs/components/index.js +5 -3
  18. package/cjs/components/workflow/hooks/useWorkflowTasks.js +13 -1
  19. package/cjs/contexts/FeaturesContext/index.d.ts +6 -0
  20. package/cjs/contexts/FeaturesContext/index.js +9 -0
  21. package/cjs/contexts/index.d.ts +1 -0
  22. package/cjs/contexts/index.js +3 -1
  23. package/cjs/hooks/useAPI/API.js +14 -9
  24. package/cjs/hooks/useAPI/helpers.d.ts +2 -1
  25. package/cjs/hooks/useAPI/helpers.js +2 -2
  26. package/cjs/hooks/useAPI/useAPI.d.ts +1 -1
  27. package/cjs/hooks/useAPI/useAPI.js +49 -32
  28. package/cjs/hooks/useCustomScripts.js +37 -38
  29. package/cjs/icons/Description.d.ts +3 -0
  30. package/cjs/icons/Description.js +22 -0
  31. package/cjs/icons/index.d.ts +6 -3
  32. package/cjs/icons/index.js +14 -8
  33. package/esm/components/BasicTableView/BasicTable/helpers/dataHelpers.js +2 -1
  34. package/esm/components/attributes/DescriptionIcon/DescriptionIcon.d.ts +31 -0
  35. package/esm/components/attributes/DescriptionIcon/DescriptionIcon.js +22 -0
  36. package/esm/components/attributes/DescriptionIcon/index.d.ts +1 -0
  37. package/esm/components/attributes/DescriptionIcon/index.js +1 -0
  38. package/esm/components/attributes/DescriptionIcon/styles.d.ts +1 -0
  39. package/esm/components/attributes/DescriptionIcon/styles.js +21 -0
  40. package/esm/components/attributes/OvIcon/OvIcon.js +1 -1
  41. package/esm/components/attributes/editMode/AttributesPager/AttributeRenderer.js +3 -1
  42. package/esm/components/attributes/editMode/AttributesPager/styles.d.ts +1 -1
  43. package/esm/components/attributes/editMode/AttributesPager/styles.js +3 -0
  44. package/esm/components/attributes/readMode/AttributesPager/MultiLineRenderer.js +3 -1
  45. package/esm/components/attributes/readMode/AttributesPager/OneLineRenderer.js +3 -1
  46. package/esm/components/attributes/readMode/AttributesPager/styles.d.ts +2 -2
  47. package/esm/components/attributes/readMode/AttributesPager/styles.js +5 -0
  48. package/esm/components/index.d.ts +1 -0
  49. package/esm/components/index.js +1 -0
  50. package/esm/components/workflow/hooks/useWorkflowTasks.js +13 -1
  51. package/esm/contexts/FeaturesContext/index.d.ts +6 -0
  52. package/esm/contexts/FeaturesContext/index.js +3 -0
  53. package/esm/contexts/index.d.ts +1 -0
  54. package/esm/contexts/index.js +1 -0
  55. package/esm/hooks/useAPI/API.js +14 -9
  56. package/esm/hooks/useAPI/helpers.d.ts +2 -1
  57. package/esm/hooks/useAPI/helpers.js +2 -2
  58. package/esm/hooks/useAPI/useAPI.d.ts +1 -1
  59. package/esm/hooks/useAPI/useAPI.js +52 -35
  60. package/esm/hooks/useCustomScripts.js +38 -39
  61. package/esm/icons/Description.d.ts +3 -0
  62. package/esm/icons/Description.js +17 -0
  63. package/esm/icons/index.d.ts +6 -3
  64. package/esm/icons/index.js +6 -3
  65. package/package.json +3 -3
@@ -7,6 +7,7 @@ import Title from '../../../Title/Title';
7
7
  import ShowMore from '../../pagersCommon/ShowMore';
8
8
  import ShowLess from '../../pagersCommon/ShowLess';
9
9
  import OvIcon from '../../OvIcon';
10
+ import DescriptionIcon from '../../DescriptionIcon';
10
11
  var MultiLineRenderer = function (_a) {
11
12
  var max = _a.max, values = _a.values, nonVisibleValues = _a.nonVisibleValues, totalVisibleValues = _a.totalVisibleValues, attributeType = _a.attributeType, parentUri = _a.parentUri, requestNextPageOfAttributeValues = _a.requestNextPageOfAttributeValues, titleClassName = _a.titleClassName, contentClassName = _a.contentClassName, showNonOv = _a.showNonOv, totalNonVisibleValues = _a.totalNonVisibleValues;
12
13
  var styles = useMultiLineStyles();
@@ -14,7 +15,7 @@ var MultiLineRenderer = function (_a) {
14
15
  var hasPaging = max < totalVisibleValues;
15
16
  var showMore = hasPaging && visibleValuesCount < totalVisibleValues;
16
17
  var showLess = hasPaging && visibleValuesCount >= totalVisibleValues;
17
- var label = attributeType.label;
18
+ var label = attributeType.label, description = attributeType.description;
18
19
  var onShowMore = function () {
19
20
  if (values.length < totalVisibleValues) {
20
21
  requestNextPageOfAttributeValues({
@@ -35,6 +36,7 @@ var MultiLineRenderer = function (_a) {
35
36
  return (React.createElement("div", { className: styles.wrapper },
36
37
  React.createElement("div", { className: styles.titleRow },
37
38
  React.createElement(Title, { label: label, className: classnames(styles.title, titleClassName), "data-reltio-id": "reltio-attribute-label" }),
39
+ React.createElement(DescriptionIcon, { description: description }),
38
40
  React.createElement(OvIcon, { nonOvValues: nonVisibleValues, attributeType: attributeType, className: styles.ovIcon, nonOvTotal: totalNonVisibleValues })),
39
41
  React.createElement("div", { className: styles.attributes }, shownValues.map(function (value) { return (React.createElement(Attribute, { key: value.uri, className: classnames(styles.attribute, contentClassName), attributeValue: value, attributeType: attributeType, showNonOv: showNonOv })); })),
40
42
  showMore && (React.createElement(ShowMore, { moreNumber: min(max, hiddenValuesCount), valueNumber: hiddenValuesCount, onClick: onShowMore })),
@@ -5,18 +5,20 @@ import { COMMENTS_CONTAINER_VISIBILITY_AREA } from '../../../../constants';
5
5
  import CommentsContainer from '../../../CommentsContainer/CommentsContainer';
6
6
  import Title from '../../../Title/Title';
7
7
  import OvIcon from '../../OvIcon';
8
+ import DescriptionIcon from '../../DescriptionIcon/DescriptionIcon';
8
9
  import Attribute from '../AttributesFactory/Attribute';
9
10
  import { useOneLineStyles } from './styles';
10
11
  var OneLineRenderer = function (_a) {
11
12
  var value = _a.value, nonVisibleValues = _a.nonVisibleValues, attributeType = _a.attributeType, titleClassName = _a.titleClassName, contentClassName = _a.contentClassName, showNonOv = _a.showNonOv, totalNonVisibleValues = _a.totalNonVisibleValues;
12
13
  var styles = useOneLineStyles();
13
- var label = attributeType.label;
14
+ var label = attributeType.label, description = attributeType.description;
14
15
  var objectType = isRelationAttrType(attributeType)
15
16
  ? CollaborationObjectTypes.RELATION_ATTRIBUTE
16
17
  : CollaborationObjectTypes.ENTITY_ATTRIBUTE;
17
18
  return (React.createElement("div", { className: classnames(styles.collaborationWrapper, COMMENTS_CONTAINER_VISIBILITY_AREA) },
18
19
  React.createElement("div", { className: classnames(styles.titleRow, styles.wrapper) },
19
20
  React.createElement(Title, { label: label, className: classnames(styles.title, titleClassName), "data-reltio-id": "reltio-attribute-label" }),
21
+ React.createElement(DescriptionIcon, { description: description, className: styles.descriptionIcon }),
20
22
  React.createElement(OvIcon, { nonOvValues: nonVisibleValues, attributeType: attributeType, className: styles.ovIcon, nonOvTotal: totalNonVisibleValues }),
21
23
  React.createElement(Attribute, { className: classnames(styles.attribute, contentClassName), attributeValue: value, attributeType: attributeType, showNonOv: showNonOv, inlined: true })),
22
24
  React.createElement(CommentsContainer, { uri: value.uri, relatedObjectUris: createRelatedObjectUris(objectType, {
@@ -1,3 +1,3 @@
1
1
  export const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"paddingWrapper" | "paddingWrapperWithLines">;
2
- export const useOneLineStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"title" | "attribute" | "wrapper" | "collaborationWrapper" | "titleIcon" | "titleRow" | "ovIcon">;
3
- export const useMultiLineStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"title" | "attributes" | "attribute" | "wrapper" | "titleRow" | "ovIcon">;
2
+ export const useOneLineStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"title" | "attribute" | "wrapper" | "collaborationWrapper" | "titleIcon" | "titleRow" | "ovIcon" | "descriptionIcon">;
3
+ export const useMultiLineStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"title" | "attributes" | "attribute" | "wrapper" | "titleRow" | "ovIcon" | "descriptionIcon">;
@@ -27,6 +27,11 @@ var commonStyles = {
27
27
  marginRight: '-3px',
28
28
  marginTop: '-1px',
29
29
  textIndent: 0
30
+ },
31
+ descriptionIcon: {
32
+ marginTop: '-1px',
33
+ textIndent: 0,
34
+ marginRight: '-10px'
30
35
  }
31
36
  };
32
37
  export var useStyles = makeStyles({
@@ -1,6 +1,7 @@
1
1
  export * from './activityLog';
2
2
  export { default as AttributeListItem } from './AttributeListItem/AttributeListItem';
3
3
  export { default as AttributesView } from './attributes/AttributesView';
4
+ export { default as DescriptionIcon } from './attributes/DescriptionIcon';
4
5
  export { default as BranchDecorator } from './attributes/BranchDecorator/BranchDecorator';
5
6
  export { default as AttributesList } from './attributes/editMode/AttributesList';
6
7
  export { default as EntityCreator } from './attributes/editMode/EntityCreator';
@@ -1,6 +1,7 @@
1
1
  export * from './activityLog';
2
2
  export { default as AttributeListItem } from './AttributeListItem/AttributeListItem';
3
3
  export { default as AttributesView } from './attributes/AttributesView';
4
+ export { default as DescriptionIcon } from './attributes/DescriptionIcon';
4
5
  export { default as BranchDecorator } from './attributes/BranchDecorator/BranchDecorator';
5
6
  export { default as AttributesList } from './attributes/editMode/AttributesList';
6
7
  export { default as EntityCreator } from './attributes/editMode/EntityCreator';
@@ -14,6 +14,7 @@ export var useWorkflowTasks = function (config) {
14
14
  var tenant = useSelector(mdmModule.selectors.getTenant);
15
15
  var entityUri = useSelector(mdmModule.selectors.getEntityUri);
16
16
  var isEditableMode = useSelector(mdmModule.selectors.getIsEditableMode);
17
+ var entityLastLoadedTime = useSelector(mdmModule.selectors.getProfileLastLoadedTime);
17
18
  var checkWorkflowPermission = useWorkflowCheckPermission();
18
19
  var canViewTasks = checkWorkflowPermission('VIEW_TASKS');
19
20
  var enabled = !!(workflowPath && environment) && isWorkflowEnabled && canViewTasks;
@@ -45,7 +46,18 @@ export var useWorkflowTasks = function (config) {
45
46
  .finally(function () {
46
47
  setLoading(false);
47
48
  });
48
- }, [entityUri, environment, safePromise, tenant, workflowPath, assignee, showClosedTasks, processTypes]);
49
+ // eslint-disable-next-line react-hooks/exhaustive-deps
50
+ }, [
51
+ entityUri,
52
+ environment,
53
+ safePromise,
54
+ tenant,
55
+ workflowPath,
56
+ assignee,
57
+ showClosedTasks,
58
+ processTypes,
59
+ entityLastLoadedTime
60
+ ]);
49
61
  useEffect(function () {
50
62
  if (entityUri && enabled && !isTempUri(entityUri)) {
51
63
  loadTasks();
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ declare type Features = {
3
+ showDescription?: boolean;
4
+ };
5
+ export declare const FeaturesContext: React.Context<Features>;
6
+ export {};
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ export var FeaturesContext = React.createContext({});
3
+ FeaturesContext.displayName = 'FeaturesContext';
@@ -25,3 +25,4 @@ export { SearchValueContext } from './SearchValueContext';
25
25
  export { ScrollToErrorContext, ScrollToErrorProvider } from './ScrollToErrorContext';
26
26
  export { UrlGeneratorsContext } from './UrlGeneratorsContext';
27
27
  export { LabelsContext } from './LabelsContext';
28
+ export { FeaturesContext } from './FeaturesContext';
@@ -25,3 +25,4 @@ export { SearchValueContext } from './SearchValueContext';
25
25
  export { ScrollToErrorContext, ScrollToErrorProvider } from './ScrollToErrorContext';
26
26
  export { UrlGeneratorsContext } from './UrlGeneratorsContext';
27
27
  export { LabelsContext } from './LabelsContext';
28
+ export { FeaturesContext } from './FeaturesContext';
@@ -57,7 +57,7 @@ var processFromQuery = function (params, permissions, workflowPath, tenant, envi
57
57
  if (!workflowPath) {
58
58
  return new Promise(function (resolve) { return resolve({ errorMessage: 'Workflow path is not defined' }); });
59
59
  }
60
- var errors = validateParams(__assign({ url: '/processInstances/_generateFromQuery' }, params), permissions);
60
+ var errors = validateParams(__assign({ validationUrl: '/processInstances/_generateFromQuery' }, params), permissions);
61
61
  if (errors) {
62
62
  return new Promise(function (resolve) { return resolve(errors); });
63
63
  }
@@ -117,7 +117,7 @@ var sendApiRequest = function (params, permissions, signHandler) { return __awai
117
117
  case 0:
118
118
  errors = validateParams(params, permissions);
119
119
  if (errors) {
120
- return [2 /*return*/, errors];
120
+ return [2 /*return*/, Promise.reject(errors)];
121
121
  }
122
122
  return [4 /*yield*/, getHeaders(params, signHandler)];
123
123
  case 1:
@@ -134,18 +134,18 @@ var sendApiRequest = function (params, permissions, signHandler) { return __awai
134
134
  });
135
135
  }); };
136
136
  var validateParams = function (params, permissions) {
137
- var url = params.url;
138
- if (!url)
137
+ var validationUrl = params.validationUrl;
138
+ if (!validationUrl)
139
139
  return { errorMessage: 'URL is empty' };
140
140
  var allowed = permissions === null || permissions === void 0 ? void 0 : permissions.some(function (permission) {
141
141
  var _a;
142
- var urlOrigin = (_a = url.match(/^(https?:\/\/[^:/?#]*).*$/)) === null || _a === void 0 ? void 0 : _a[1];
142
+ var urlOrigin = (_a = validationUrl.match(/^(https?:\/\/[^:/?#]*).*$/)) === null || _a === void 0 ? void 0 : _a[1];
143
143
  var permRegex = new RegExp('^' + permission + '$');
144
144
  var decodedPerm = permission.replace(/\/*$/, '');
145
- return (decodedPerm === url ||
145
+ return (decodedPerm === validationUrl ||
146
146
  (urlOrigin && urlOrigin === decodedPerm) ||
147
- ((decodedPerm === null || decodedPerm === void 0 ? void 0 : decodedPerm.startsWith('/')) && (url === null || url === void 0 ? void 0 : url.startsWith(decodedPerm))) ||
148
- (permission && permRegex.test(url)));
147
+ ((decodedPerm === null || decodedPerm === void 0 ? void 0 : decodedPerm.startsWith('/')) && (validationUrl === null || validationUrl === void 0 ? void 0 : validationUrl.startsWith(decodedPerm))) ||
148
+ (permission && permRegex.test(validationUrl)));
149
149
  });
150
150
  if (!allowed || ((permissions === null || permissions === void 0 ? void 0 : permissions.length) || 0) === 0) {
151
151
  return { errorMessage: 'Not enough permissions' };
@@ -156,8 +156,13 @@ export var processRequest = function (_a) {
156
156
  var name = _a.name, paramObject = _a.paramObject, permissions = _a.permissions, worker = _a.worker, metadata = _a.metadata, config = _a.config, apiPath = _a.apiPath, servicesPath = _a.servicesPath, user = _a.user, workflowPath = _a.workflowPath, entity = _a.entity, tenant = _a.tenant, entityUri = _a.entityUri, query = _a.query, openSearch = _a.openSearch, environment = _a.environment, getCurrentPerspectiveId = _a.getCurrentPerspectiveId, showPerspective = _a.showPerspective, workflowCheckPermission = _a.workflowCheckPermission, setEntityUri = _a.setEntityUri;
157
157
  var handleRequest = function (request) {
158
158
  request
159
+ .then(function (response) { return (response.json ? response.json() : response); })
159
160
  .then(function (data) {
160
- worker.postMessage(__assign({ action: 'response', result: { data: data, headers: paramObject.params.headers, status: 200 } }, paramObject.params));
161
+ worker.postMessage(__assign({ action: 'response', result: {
162
+ data: JSON.parse(JSON.stringify(data)),
163
+ headers: paramObject.params.headers,
164
+ status: 200
165
+ } }, paramObject.params));
161
166
  })
162
167
  .catch(function (error) {
163
168
  worker.postMessage(__assign({ action: 'response', result: { data: error, headers: paramObject.params.headers, status: 0 } }, paramObject.params));
@@ -29,9 +29,10 @@ export declare const setUpRequestInterceptor: ({ apiPath, reltioPath, tenant, pr
29
29
  processApiRequest: any;
30
30
  workerRef: any;
31
31
  setRequestListeners: any;
32
- }) => ({ options, url, next }: {
32
+ }) => ({ options, url, next, resolve }: {
33
33
  next: (url: string, options: RequestInit) => void;
34
34
  abort?: (error: Error) => void;
35
+ resolve: (data: unknown) => void;
35
36
  url: string;
36
37
  options: RequestInit;
37
38
  }) => void;
@@ -131,14 +131,14 @@ export var setUpQooxdooResponseInterceptor = function (_a) {
131
131
  export var setUpRequestInterceptor = function (_a) {
132
132
  var apiPath = _a.apiPath, reltioPath = _a.reltioPath, tenant = _a.tenant, processApiRequest = _a.processApiRequest, workerRef = _a.workerRef, setRequestListeners = _a.setRequestListeners;
133
133
  return function (_a) {
134
- var _b = _a.options, options = _b === void 0 ? {} : _b, url = _a.url, next = _a.next;
134
+ var _b = _a.options, options = _b === void 0 ? {} : _b, url = _a.url, next = _a.next, resolve = _a.resolve;
135
135
  var fakeURL = url.startsWith('/') && !url.startsWith(apiPath)
136
136
  ? "".concat(reltioPath, "/api/").concat(tenant).concat(url)
137
137
  : "".concat(reltioPath).concat(url.replace(apiPath, ''));
138
138
  var isProcessableUrl = isURLtoProcess(processApiRequest, fakeURL);
139
139
  if (isProcessableUrl) {
140
140
  var requestId = nanoid();
141
- setRequestListeners(options, next, requestId);
141
+ setRequestListeners(options, next, requestId, resolve);
142
142
  workerRef.current.postMessage({
143
143
  action: 'apiRequest',
144
144
  id: requestId,
@@ -1,5 +1,5 @@
1
1
  import { CSSProperties } from 'react';
2
- import { CustomActionViewConfig, CustomActionExtension } from '@reltio/mdm-sdk';
2
+ import { CustomActionExtension, CustomActionViewConfig } from '@reltio/mdm-sdk';
3
3
  declare type Config = CustomActionViewConfig | CustomActionExtension;
4
4
  export declare const useAPI: (config?: Config) => {
5
5
  html: HTMLElement;
@@ -12,23 +12,23 @@ var __assign = (this && this.__assign) || function () {
12
12
  import { useCallback, useContext, useEffect, useRef, useState } from 'react';
13
13
  import { useDispatch, useSelector } from 'react-redux';
14
14
  import mdmModule, { ui } from '@reltio/mdm-module';
15
- import { CustomAction, CustomScriptPlatform, initializeWebWorker, isEmptyValue } from '@reltio/mdm-sdk';
16
- import { omit } from 'ramda';
15
+ import { CustomAction, CustomScriptPlatform, initializeWebWorker, isEmptyValue, RequestAction } from '@reltio/mdm-sdk';
16
+ import { always, assocPath, both, concat, evolve, has, ifElse, omit, pathEq, pathOr, pipe, replace, startsWith, when } from 'ramda';
17
17
  import { useWorkflowCheckPermission } from '../../components/workflow';
18
18
  import { useHtmlSanitizer } from '../useHtmlSanitizer';
19
19
  import { InterceptHandlersContext, SandboxAPIContext, SnackbarContext } from '../../contexts';
20
20
  import { processRequest } from './API';
21
- import { getWorkerURL, resetHtml, isNewUI, setUpResponseInterceptor, setUpRequestInterceptor, setUpQooxdooRequestInterceptor, setUpQooxdooResponseInterceptor } from './helpers';
21
+ import { getWorkerURL, isNewUI, resetHtml, setUpQooxdooRequestInterceptor, setUpQooxdooResponseInterceptor, setUpRequestInterceptor, setUpResponseInterceptor } from './helpers';
22
22
  export var useAPI = function (config) {
23
- var _a, _b;
23
+ var _a, _b, _c, _d;
24
24
  if (config === void 0) { config = {}; }
25
- var _c = useState(), html = _c[0], setHtml = _c[1];
26
- var _d = useState([]), listenersToReset = _d[0], setListenersToReset = _d[1];
27
- var _e = useState([]), popupListenersToReset = _e[0], setPopupListenersToReset = _e[1];
28
- var _f = useState(true), visible = _f[0], setVisible = _f[1];
29
- var _g = useState(), popup = _g[0], setPopup = _g[1];
30
- var _h = useState(null), tooltip = _h[0], setTooltip = _h[1];
31
- var _j = useState({}), customStyles = _j[0], setCustomStyles = _j[1];
25
+ var _e = useState(), html = _e[0], setHtml = _e[1];
26
+ var _f = useState([]), listenersToReset = _f[0], setListenersToReset = _f[1];
27
+ var _g = useState([]), popupListenersToReset = _g[0], setPopupListenersToReset = _g[1];
28
+ var _h = useState(true), visible = _h[0], setVisible = _h[1];
29
+ var _j = useState(), popup = _j[0], setPopup = _j[1];
30
+ var _k = useState(null), tooltip = _k[0], setTooltip = _k[1];
31
+ var _l = useState({}), customStyles = _l[0], setCustomStyles = _l[1];
32
32
  var workerRef = useRef();
33
33
  var requestListeners = useRef({});
34
34
  var responseListeners = useRef({});
@@ -51,7 +51,7 @@ export var useAPI = function (config) {
51
51
  var entityUri = useSelector(mdmModule.selectors.getEntityUri);
52
52
  var isEditableMode = useSelector(mdmModule.selectors.getIsEditableMode);
53
53
  var environment = useSelector(mdmModule.selectors.getWorkflowEnvironmentUrl);
54
- var _k = useSelector(mdmModule.selectors.getSearchProviderData) || {}, typeSearch = _k.type, search = _k.data;
54
+ var _m = useSelector(mdmModule.selectors.getSearchProviderData) || {}, typeSearch = _m.type, search = _m.data;
55
55
  var searchQuery = typeSearch === 'search' ? search === null || search === void 0 ? void 0 : search.query : null;
56
56
  var isOldUI = !isNewUI(servicesPath);
57
57
  var supportedInterceptHandlers = isOldUI ? qxApi.interceptors : interceptHandlers;
@@ -59,7 +59,6 @@ export var useAPI = function (config) {
59
59
  var innerText = '';
60
60
  var popupText = '';
61
61
  var process = function (_a) {
62
- var _b, _c;
63
62
  var task = _a.task, worker = _a.worker;
64
63
  if (task) {
65
64
  switch (task.action) {
@@ -143,40 +142,38 @@ export var useAPI = function (config) {
143
142
  break;
144
143
  }
145
144
  case CustomAction.REQUEST: {
146
- if (((_c = (_b = task.params) === null || _b === void 0 ? void 0 : _b.headers) === null || _c === void 0 ? void 0 : _c.origin) !== 'ui') {
147
- processRequest(__assign({ name: task.params.name, paramObject: task, permissions: config.action.permissions, worker: worker, metadata: metadata, config: config, user: user, servicesPath: servicesPath, apiPath: isOldUI ? apiPath : reltioPath, tenant: tenant, workflowPath: workflowPath, entity: entity, entityUri: entityUri, environment: environment, query: searchQuery, openSearch: openSearch, workflowCheckPermission: workflowCheckPermission }, qxApi));
148
- }
149
- else {
150
- var _d = task.params, headers = _d.headers, id = _d.id, fakeURL = _d.url, method = _d.method, data = _d.data;
151
- var url = fakeURL.replace(reltioPath, apiPath);
152
- if (requestListeners.current[headers.requestId]) {
153
- requestListeners.current[headers.requestId].next(url, {
154
- body: data,
155
- id: id,
156
- task: task,
157
- headers: headers,
158
- method: method
159
- });
160
- requestListeners.current = omit([headers.requestId], requestListeners.current);
161
- }
162
- }
145
+ var processedApiPath = isOldUI ? reltioPath : apiPath;
146
+ var isGlobalUrl = startsWith('/', pathOr('', ['params', 'url'], task)) &&
147
+ !startsWith(apiPath, pathOr('', ['params', 'url'], task));
148
+ var processedParams = pipe(evolve({
149
+ url: ifElse(both(always(isGlobalUrl), always(pathEq(['params', 'name'], RequestAction.API, task))), concat("".concat(processedApiPath, "/api/").concat(tenant)), replace(reltioPath, apiPath))
150
+ }), when(has('url'), assocPath(['validationUrl'], task.params.url)))(task.params);
151
+ var processedTask = __assign(__assign({}, task), { params: processedParams });
152
+ processRequest(__assign({ name: processedTask.params.name, paramObject: processedTask, permissions: config.action.permissions, worker: worker, metadata: metadata, config: config, user: user, servicesPath: servicesPath, apiPath: processedApiPath, tenant: tenant, workflowPath: workflowPath, entity: entity, entityUri: entityUri, environment: environment, query: searchQuery, openSearch: openSearch, workflowCheckPermission: workflowCheckPermission }, qxApi));
163
153
  break;
164
154
  }
165
- case CustomAction.RETURN_PROCESSED_API_RESPONSE:
166
- case CustomAction.RETURN_PROCESSED_API_REQUEST: {
167
- var _e = task.params, id = _e.id, data = _e.data;
155
+ case CustomAction.RETURN_PROCESSED_API_RESPONSE: {
156
+ var _b = task.params, id = _b.id, data = _b.data;
168
157
  if (responseListeners.current[id]) {
169
158
  responseListeners.current[id].next(data);
170
159
  responseListeners.current = omit([id], responseListeners.current);
171
160
  }
172
161
  break;
173
162
  }
163
+ case CustomAction.RETURN_PROCESSED_API_REQUEST: {
164
+ var _c = task.params, id = _c.id, data = _c.data;
165
+ if (requestListeners.current[id]) {
166
+ requestListeners.current[id].resolve(data);
167
+ requestListeners.current = omit([id], requestListeners.current);
168
+ }
169
+ break;
170
+ }
174
171
  }
175
172
  }
176
173
  };
177
- var setRequestListeners = function (options, next, requestId) {
174
+ var setRequestListeners = function (options, next, requestId, resolve) {
178
175
  var _a;
179
- requestListeners.current = __assign(__assign({}, requestListeners.current), (_a = {}, _a[requestId] = { options: options, next: next, id: requestId }, _a));
176
+ requestListeners.current = __assign(__assign({}, requestListeners.current), (_a = {}, _a[requestId] = { options: options, next: next, id: requestId, resolve: resolve }, _a));
180
177
  };
181
178
  var setResponseListeners = function (next, responseId) {
182
179
  var _a;
@@ -203,9 +200,25 @@ export var useAPI = function (config) {
203
200
  var _a;
204
201
  (_a = workerRef.current) === null || _a === void 0 ? void 0 : _a.postMessage({ action: 'event', type: type, data: data });
205
202
  };
203
+ var pendingInterceptors = useRef(false);
204
+ var needDelayedRequestForInterceptors = !isOldUI &&
205
+ interceptHandlers &&
206
+ !isEmptyValue(config.action) &&
207
+ config.action.platform !== CustomScriptPlatform.CLASSIC &&
208
+ (((_c = config === null || config === void 0 ? void 0 : config.action) === null || _c === void 0 ? void 0 : _c.processApiRequest) || ((_d = config === null || config === void 0 ? void 0 : config.action) === null || _d === void 0 ? void 0 : _d.processApiResponse));
209
+ if (needDelayedRequestForInterceptors) {
210
+ if (!pendingInterceptors.current && !workerRef.current) {
211
+ interceptHandlers.startInterceptorInit();
212
+ pendingInterceptors.current = true;
213
+ }
214
+ }
206
215
  useEffect(function () {
207
216
  if (!isEmptyValue(config.action) && config.action.platform !== CustomScriptPlatform.CLASSIC) {
208
217
  workerRef.current = initializeWebWorker(workerUrl, process, config);
218
+ if (pendingInterceptors.current) {
219
+ interceptHandlers.finishInterceptorInit();
220
+ pendingInterceptors.current = false;
221
+ }
209
222
  postEventMessage('updateEntity', entity);
210
223
  }
211
224
  }, [entity, config]);
@@ -244,6 +257,10 @@ export var useAPI = function (config) {
244
257
  else {
245
258
  addInternalRequestInterceptor(requestInterceptor);
246
259
  addInternalResponseInterceptor(responseInterceptor);
260
+ workerRef.current.onerror = function () {
261
+ removeInternalRequestInterceptor_1(requestInterceptor);
262
+ removeInternalResponseInterceptor_1(responseInterceptor);
263
+ };
247
264
  return function () {
248
265
  removeInternalRequestInterceptor_1(requestInterceptor);
249
266
  removeInternalResponseInterceptor_1(responseInterceptor);
@@ -34,7 +34,7 @@ import { useDispatch, useSelector } from 'react-redux';
34
34
  import mdmModule, { ui } from '@reltio/mdm-module';
35
35
  import { CustomAction, CustomScriptPlatform, initializeWebWorker, isEmptyValue } from '@reltio/mdm-sdk';
36
36
  import nanoid from 'nanoid';
37
- import { find, map, omit, pick, pipe, prop } from 'ramda';
37
+ import { assocPath, evolve, find, has, map, omit, pick, pipe, prop, replace, when } from 'ramda';
38
38
  import { useWorkflowCheckPermission } from '../components/workflow';
39
39
  import { InterceptHandlersContext, SandboxAPIContext, SnackbarContext } from '../contexts';
40
40
  import { getWorkerURL, processRequest } from './useAPI';
@@ -49,6 +49,7 @@ var getCustomViewConfig = function (config) {
49
49
  return __assign({ action: { processApiResponse: processApiResponse, processApiRequest: processApiRequest, permissions: permissions, files: files } }, otherProps);
50
50
  };
51
51
  export var useCustomScripts = function (config) {
52
+ var _a;
52
53
  var customScripts = config.reduce(function (acc, customScript) {
53
54
  if (customScript.platform !== CustomScriptPlatform.CLASSIC) {
54
55
  return __spreadArray(__spreadArray([], acc, true), [__assign(__assign({}, customScript), { actionId: nanoid() })], false);
@@ -56,10 +57,10 @@ export var useCustomScripts = function (config) {
56
57
  return acc;
57
58
  }, []);
58
59
  var showSnackbarMessage = useContext(SnackbarContext);
59
- var _a = useContext(InterceptHandlersContext), addInternalRequestInterceptor = _a.addInternalRequestInterceptor, addInternalResponseInterceptor = _a.addInternalResponseInterceptor, removeInternalRequestInterceptor = _a.removeInternalRequestInterceptor, removeInternalResponseInterceptor = _a.removeInternalResponseInterceptor;
60
+ var _b = useContext(InterceptHandlersContext), addInternalRequestInterceptor = _b.addInternalRequestInterceptor, addInternalResponseInterceptor = _b.addInternalResponseInterceptor, removeInternalRequestInterceptor = _b.removeInternalRequestInterceptor, removeInternalResponseInterceptor = _b.removeInternalResponseInterceptor;
60
61
  var qxApi = useContext(SandboxAPIContext);
61
62
  var dispatch = useDispatch();
62
- var metadata = useSelector(mdmModule.selectors.getMetadata) || {};
63
+ var metadata = (_a = useSelector(mdmModule.selectors.getMetadata)) !== null && _a !== void 0 ? _a : null;
63
64
  var entity = useSelector(mdmModule.selectors.getEntity) || {};
64
65
  var uiPath = useSelector(mdmModule.selectors.getUIPath);
65
66
  var servicesPath = useSelector(mdmModule.selectors.getServicesPath);
@@ -72,13 +73,12 @@ export var useCustomScripts = function (config) {
72
73
  var entityUri = useSelector(mdmModule.selectors.getEntityUri);
73
74
  var environment = useSelector(mdmModule.selectors.getWorkflowEnvironmentUrl);
74
75
  var workflowCheckPermission = useWorkflowCheckPermission();
75
- var _b = useSelector(mdmModule.selectors.getSearchProviderData) || {}, typeSearch = _b.type, search = _b.data;
76
+ var _c = useSelector(mdmModule.selectors.getSearchProviderData) || {}, typeSearch = _c.type, search = _c.data;
76
77
  var openSearch = function (search) { return dispatch(ui.actions.openSearch(search)); };
77
78
  var requestListeners = useRef({});
78
79
  var responseListeners = useRef({});
79
80
  var workers = useRef({});
80
- var process = function (_a) {
81
- var _b, _c;
81
+ var processMessageFromWorker = function (_a) {
82
82
  var task = _a.task, worker = _a.worker, config = _a.config;
83
83
  if (task) {
84
84
  switch (task.action) {
@@ -91,52 +91,50 @@ export var useCustomScripts = function (config) {
91
91
  break;
92
92
  }
93
93
  case CustomAction.REQUEST: {
94
- if (((_c = (_b = task.params) === null || _b === void 0 ? void 0 : _b.headers) === null || _c === void 0 ? void 0 : _c.origin) !== 'ui') {
95
- processRequest(__assign({ name: task.params.name, paramObject: task, permissions: config.action.permissions, worker: worker, metadata: metadata, config: config, user: user, apiPath: apiPath, servicesPath: servicesPath, tenant: tenant, workflowPath: workflowPath, entity: entity, entityUri: entityUri, environment: environment, query: typeSearch === 'search' ? search === null || search === void 0 ? void 0 : search.query : null, openSearch: openSearch, workflowCheckPermission: workflowCheckPermission }, qxApi));
96
- }
97
- else {
98
- var _d = task.params, headers = _d.headers, id = _d.id, fakeURL = _d.url, method = _d.method, data = _d.data;
99
- var url = fakeURL.replace(reltioPath, apiPath);
100
- if (requestListeners.current[headers.requestId]) {
101
- requestListeners.current[headers.requestId].next(url, {
102
- body: data,
103
- id: id,
104
- task: task,
105
- headers: headers,
106
- method: method
107
- });
108
- requestListeners.current = omit([headers.requestId], requestListeners.current);
109
- }
110
- }
94
+ var processedParams = pipe(evolve({
95
+ url: replace(reltioPath, apiPath)
96
+ }), when(has('url'), assocPath(['validationUrl'], task.params.url)))(task.params);
97
+ var processedTask = __assign(__assign({}, task), { params: processedParams });
98
+ processRequest(__assign({ name: processedTask.params.name, paramObject: processedTask, permissions: config.action.permissions, worker: worker, metadata: metadata, config: config, user: user, apiPath: apiPath, servicesPath: servicesPath, tenant: tenant, workflowPath: workflowPath, entity: entity, entityUri: entityUri, environment: environment, query: typeSearch === 'search' ? search === null || search === void 0 ? void 0 : search.query : null, openSearch: openSearch, workflowCheckPermission: workflowCheckPermission }, qxApi));
111
99
  break;
112
100
  }
113
- case CustomAction.RETURN_PROCESSED_API_RESPONSE:
114
- case CustomAction.RETURN_PROCESSED_API_REQUEST: {
115
- var _e = task.params, id = _e.id, data = _e.data;
101
+ case CustomAction.RETURN_PROCESSED_API_RESPONSE: {
102
+ var _b = task.params, id = _b.id, data = _b.data;
116
103
  if (responseListeners.current[id]) {
117
104
  responseListeners.current[id].next(data);
118
105
  responseListeners.current = omit([id], responseListeners.current);
119
106
  }
120
107
  break;
121
108
  }
109
+ case CustomAction.RETURN_PROCESSED_API_REQUEST: {
110
+ var _c = task.params, id = _c.id, data = _c.data;
111
+ if (requestListeners.current[id]) {
112
+ requestListeners.current[id].resolve(data);
113
+ requestListeners.current = omit([id], requestListeners.current);
114
+ }
115
+ break;
116
+ }
122
117
  }
123
118
  }
124
119
  };
125
120
  useEffect(function () {
121
+ if (metadata === null) {
122
+ return;
123
+ }
126
124
  workers.current = customScripts.reduce(function (acc, customScript) {
127
125
  var _a;
128
126
  var customViewConfig = getCustomViewConfig(customScript);
129
- return __assign(__assign({}, acc), (_a = {}, _a[customScript.actionId] = initializeWebWorker(workerUrl, process, customViewConfig), _a));
127
+ return __assign(__assign({}, acc), (_a = {}, _a[customScript.actionId] = initializeWebWorker(workerUrl, processMessageFromWorker, customViewConfig), _a));
130
128
  }, workers.current);
131
129
  return function () {
132
130
  Object.keys(workers.current).forEach(function (actionId) {
133
131
  workers.current[actionId].terminate();
134
132
  });
135
133
  };
136
- }, [config]);
134
+ }, [config, metadata]);
137
135
  var customScriptRequestInterceptor = function (_a) {
138
136
  var _b;
139
- var _c = _a.options, options = _c === void 0 ? {} : _c, url = _a.url, next = _a.next;
137
+ var _c = _a.options, options = _c === void 0 ? {} : _c, url = _a.url, next = _a.next, resolve = _a.resolve;
140
138
  var fakeURL = url.startsWith('/') && !url.startsWith(apiPath)
141
139
  ? "".concat(reltioPath, "/api/").concat(tenant).concat(url)
142
140
  : "".concat(reltioPath).concat(url.replace(apiPath, ''));
@@ -146,7 +144,7 @@ export var useCustomScripts = function (config) {
146
144
  }), prop('actionId'))(customScripts);
147
145
  if (actionId) {
148
146
  var requestId = nanoid();
149
- requestListeners.current = __assign(__assign({}, requestListeners.current), (_b = {}, _b[requestId] = { options: options, next: next, id: requestId }, _b));
147
+ requestListeners.current = __assign(__assign({}, requestListeners.current), (_b = {}, _b[requestId] = { options: options, next: next, id: requestId, resolve: resolve }, _b));
150
148
  workers.current[actionId].postMessage({
151
149
  action: 'apiRequest',
152
150
  id: requestId,
@@ -172,7 +170,7 @@ export var useCustomScripts = function (config) {
172
170
  responseListeners.current = __assign(__assign({}, responseListeners.current), (_a = {}, _a[options.headers.requestId] = { next: next }, _a));
173
171
  workers.current[(_b = options.headers) === null || _b === void 0 ? void 0 : _b.actionId].postMessage({
174
172
  action: 'response',
175
- result: { data: data },
173
+ result: { data: data, status: response.status },
176
174
  id: options === null || options === void 0 ? void 0 : options.id,
177
175
  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
178
176
  });
@@ -212,13 +210,14 @@ export var useCustomScripts = function (config) {
212
210
  }
213
211
  };
214
212
  useEffect(function () {
215
- if (!isEmptyValue(customScripts)) {
216
- addInternalRequestInterceptor(customScriptRequestInterceptor);
217
- addInternalResponseInterceptor(customScriptResponseInterceptor);
218
- return function () {
219
- removeInternalRequestInterceptor(customScriptRequestInterceptor);
220
- removeInternalResponseInterceptor(customScriptResponseInterceptor);
221
- };
213
+ if (isEmptyValue(customScripts) || !metadata) {
214
+ return;
222
215
  }
223
- }, [config]);
216
+ addInternalRequestInterceptor(customScriptRequestInterceptor);
217
+ addInternalResponseInterceptor(customScriptResponseInterceptor);
218
+ return function () {
219
+ removeInternalRequestInterceptor(customScriptRequestInterceptor);
220
+ removeInternalResponseInterceptor(customScriptResponseInterceptor);
221
+ };
222
+ }, [config, metadata]);
224
223
  };
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const SvgDescription: React.FC<React.SVGProps<SVGSVGElement>>;
3
+ export default SvgDescription;
@@ -0,0 +1,17 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import React from 'react';
13
+ var SvgDescription = function (props) {
14
+ return (React.createElement("svg", __assign({ width: 12, height: 12, viewBox: "0 0 12 12", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, props),
15
+ React.createElement("path", { d: "M5.417 9.5h1.166V8.333H5.417V9.5zM6 .167A5.835 5.835 0 00.167 6 5.835 5.835 0 006 11.833 5.835 5.835 0 0011.833 6 5.835 5.835 0 006 .167zm0 10.5A4.673 4.673 0 011.333 6 4.673 4.673 0 016 1.333 4.673 4.673 0 0110.667 6 4.673 4.673 0 016 10.667zM6 2.5a2.333 2.333 0 00-2.333 2.333h1.166A1.17 1.17 0 016 3.667a1.17 1.17 0 011.167 1.166c0 1.167-1.75 1.021-1.75 2.917h1.166c0-1.313 1.75-1.458 1.75-2.917A2.333 2.333 0 006 2.5z", fill: "#000", fillOpacity: 0.54 })));
16
+ };
17
+ export default SvgDescription;
@@ -11,6 +11,7 @@ export { default as DcrTaskIcon } from './DcrTaskIcon';
11
11
  export { default as DefaultImage } from './DefaultImage';
12
12
  export { default as DefaultTaskIcon } from './DefaultTaskIcon';
13
13
  export { default as DeleteRequestTaskIcon } from './DeleteRequestTaskIcon';
14
+ export { default as Description } from './Description';
14
15
  export { default as Details } from './Details';
15
16
  export { default as Download } from './Download';
16
17
  export { default as Draw } from './Draw';
@@ -22,20 +23,22 @@ export { default as Ignored } from './Ignored';
22
23
  export { default as IgnoredOutlined } from './IgnoredOutlined';
23
24
  export { default as LogIn } from './LogIn';
24
25
  export { default as LogOut } from './LogOut';
25
- export { default as MlMatch } from './MlMatch';
26
26
  export { default as Merge } from './Merge';
27
27
  export { default as MergeDark } from './MergeDark';
28
+ export { default as MlMatch } from './MlMatch';
29
+ export { default as NegativeRuleIcon } from './NegativeRuleIcon';
30
+ export { default as NegativeRuleTooltipIcon } from './NegativeRuleTooltipIcon';
28
31
  export { default as NestedAttribute } from './NestedAttribute';
29
32
  export { default as NoData } from './NoData';
30
33
  export { default as NoDataSearch } from './NoDataSearch';
31
34
  export { default as NoMatches } from './NoMatches';
32
35
  export { default as NotMatchDark } from './NotMatchDark';
33
36
  export { default as NotMatchRule } from './NotMatchRule';
34
- export { default as PmIcon } from './PmIcon';
35
- export { default as PmTaskIcon } from './PmTaskIcon';
36
37
  export { default as Pin } from './Pin';
37
38
  export { default as PinOutlined } from './PinOutlined';
38
39
  export { default as PivotingIcon } from './PivotingIcon';
40
+ export { default as PmIcon } from './PmIcon';
41
+ export { default as PmTaskIcon } from './PmTaskIcon';
39
42
  export { default as Polygon } from './Polygon';
40
43
  export { default as PotentialMatch } from './PotentialMatch';
41
44
  export { default as Profile } from './Profile';