@reltio/components 1.4.1102 → 1.4.1105

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 (93) hide show
  1. package/cjs/components/ActionButton/styles.d.ts +1 -1
  2. package/cjs/components/AttributesFiltersButton/ActionButtons/styles.d.ts +1 -1
  3. package/cjs/components/DropDownSelector/styles.d.ts +1 -1
  4. package/cjs/components/MatchRulesBlock/MatchRulesBadge/MatchRulesBadge.js +2 -1
  5. package/cjs/components/MatchRulesBlock/MatchRulesBadge/styles.d.ts +1 -1
  6. package/cjs/components/MatchRulesBlock/MatchRulesBadge/styles.js +5 -3
  7. package/cjs/components/MergeButton/MergeButton.d.ts +1 -0
  8. package/cjs/components/ModeSwitcherSelect/styles.d.ts +1 -1
  9. package/cjs/components/NotMatchButton/NotMatchButton.d.ts +1 -0
  10. package/cjs/components/Popper/styles.d.ts +1 -1
  11. package/cjs/components/ProfileBand/styles.d.ts +1 -1
  12. package/cjs/components/ProfileCard/styles.d.ts +1 -1
  13. package/cjs/components/ProfileMatchCard/styles.d.ts +1 -1
  14. package/cjs/components/ProfileMatchCard/styles.js +2 -1
  15. package/cjs/components/VerticalHeadingsTable/VerticalHeadingsTable.d.ts +5 -1
  16. package/cjs/components/VerticalHeadingsTable/VerticalHeadingsTable.js +5 -3
  17. package/cjs/components/attributes/editMode/ComplexAttribute/styles.d.ts +1 -1
  18. package/cjs/components/attributes/editMode/MoreAttributesButton/styles.d.ts +1 -1
  19. package/cjs/components/attributes/editMode/SimpleAttributeEditor/styles.d.ts +1 -1
  20. package/cjs/components/crosswalks/CrosswalkAttributes/styles.d.ts +1 -1
  21. package/cjs/components/editors/CustomDateRangeEditor/styles.d.ts +1 -1
  22. package/cjs/components/editors/DateEditor/styles.d.ts +1 -1
  23. package/cjs/components/editors/DateRangeEditor/styles.d.ts +1 -1
  24. package/cjs/components/editors/TimestampEditor/styles.d.ts +1 -1
  25. package/cjs/components/workflow/cards/GenericWorkflowTaskCard/styles.d.ts +1 -1
  26. package/cjs/components/workflow/components/AddWorkflowDialog/styles.d.ts +1 -1
  27. package/cjs/components/workflow/components/DueDateField/styles.d.ts +1 -1
  28. package/cjs/components/workflow/components/LineDecorator/styles.d.ts +1 -1
  29. package/cjs/contexts/SandboxAPIContext/index.d.ts +6 -0
  30. package/cjs/contexts/SandboxAPIContext/index.js +12 -0
  31. package/cjs/contexts/index.d.ts +1 -0
  32. package/cjs/contexts/index.js +3 -1
  33. package/cjs/hooks/index.d.ts +3 -0
  34. package/cjs/hooks/index.js +6 -1
  35. package/cjs/hooks/useAPI/API.d.ts +2 -0
  36. package/cjs/hooks/useAPI/API.js +201 -0
  37. package/cjs/hooks/useAPI/helpers.d.ts +1 -0
  38. package/cjs/hooks/useAPI/helpers.js +12 -0
  39. package/cjs/hooks/useAPI/index.d.ts +5 -0
  40. package/cjs/hooks/useAPI/index.js +11 -0
  41. package/cjs/hooks/useAPI/types.d.ts +90 -0
  42. package/cjs/hooks/useAPI/types.js +42 -0
  43. package/cjs/hooks/useAPI/useAPI.d.ts +13 -0
  44. package/cjs/hooks/useAPI/useAPI.js +192 -0
  45. package/cjs/hooks/useCustomScripts.d.ts +9 -0
  46. package/cjs/hooks/useCustomScripts.js +215 -0
  47. package/esm/components/ActionButton/styles.d.ts +1 -1
  48. package/esm/components/AttributesFiltersButton/ActionButtons/styles.d.ts +1 -1
  49. package/esm/components/DropDownSelector/styles.d.ts +1 -1
  50. package/esm/components/MatchRulesBlock/MatchRulesBadge/MatchRulesBadge.js +2 -1
  51. package/esm/components/MatchRulesBlock/MatchRulesBadge/styles.d.ts +1 -1
  52. package/esm/components/MatchRulesBlock/MatchRulesBadge/styles.js +5 -3
  53. package/esm/components/MergeButton/MergeButton.d.ts +1 -0
  54. package/esm/components/ModeSwitcherSelect/styles.d.ts +1 -1
  55. package/esm/components/NotMatchButton/NotMatchButton.d.ts +1 -0
  56. package/esm/components/Popper/styles.d.ts +1 -1
  57. package/esm/components/ProfileBand/styles.d.ts +1 -1
  58. package/esm/components/ProfileCard/styles.d.ts +1 -1
  59. package/esm/components/ProfileMatchCard/styles.d.ts +1 -1
  60. package/esm/components/ProfileMatchCard/styles.js +2 -1
  61. package/esm/components/VerticalHeadingsTable/VerticalHeadingsTable.d.ts +5 -1
  62. package/esm/components/VerticalHeadingsTable/VerticalHeadingsTable.js +5 -3
  63. package/esm/components/attributes/editMode/ComplexAttribute/styles.d.ts +1 -1
  64. package/esm/components/attributes/editMode/MoreAttributesButton/styles.d.ts +1 -1
  65. package/esm/components/attributes/editMode/SimpleAttributeEditor/styles.d.ts +1 -1
  66. package/esm/components/crosswalks/CrosswalkAttributes/styles.d.ts +1 -1
  67. package/esm/components/editors/CustomDateRangeEditor/styles.d.ts +1 -1
  68. package/esm/components/editors/DateEditor/styles.d.ts +1 -1
  69. package/esm/components/editors/DateRangeEditor/styles.d.ts +1 -1
  70. package/esm/components/editors/TimestampEditor/styles.d.ts +1 -1
  71. package/esm/components/workflow/cards/GenericWorkflowTaskCard/styles.d.ts +1 -1
  72. package/esm/components/workflow/components/AddWorkflowDialog/styles.d.ts +1 -1
  73. package/esm/components/workflow/components/DueDateField/styles.d.ts +1 -1
  74. package/esm/components/workflow/components/LineDecorator/styles.d.ts +1 -1
  75. package/esm/contexts/SandboxAPIContext/index.d.ts +6 -0
  76. package/esm/contexts/SandboxAPIContext/index.js +6 -0
  77. package/esm/contexts/index.d.ts +1 -0
  78. package/esm/contexts/index.js +1 -0
  79. package/esm/hooks/index.d.ts +3 -0
  80. package/esm/hooks/index.js +2 -0
  81. package/esm/hooks/useAPI/API.d.ts +2 -0
  82. package/esm/hooks/useAPI/API.js +197 -0
  83. package/esm/hooks/useAPI/helpers.d.ts +1 -0
  84. package/esm/hooks/useAPI/helpers.js +8 -0
  85. package/esm/hooks/useAPI/index.d.ts +5 -0
  86. package/esm/hooks/useAPI/index.js +4 -0
  87. package/esm/hooks/useAPI/types.d.ts +90 -0
  88. package/esm/hooks/useAPI/types.js +39 -0
  89. package/esm/hooks/useAPI/useAPI.d.ts +13 -0
  90. package/esm/hooks/useAPI/useAPI.js +169 -0
  91. package/esm/hooks/useCustomScripts.d.ts +9 -0
  92. package/esm/hooks/useCustomScripts.js +189 -0
  93. package/package.json +3 -3
@@ -1,2 +1,2 @@
1
- declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"label" | "image" | "secondaryLabel" | "link" | "container" | "info" | "thirdRow" | "entityId" | "entityIdLabel" | "entityIdValue">;
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" | "rulesContainer" | "profileCardWrapper" | "profileCardContainer">;
1
+ export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"root" | "profileCardWrapper" | "profileCardContainer" | "rulesContainer">;
@@ -22,6 +22,7 @@ export var useStyles = makeStyles({
22
22
  paddingTop: '8px'
23
23
  },
24
24
  rulesContainer: {
25
- paddingLeft: '52px'
25
+ paddingLeft: '52px',
26
+ marginBottom: '8px'
26
27
  }
27
28
  });
@@ -1,9 +1,11 @@
1
1
  declare var _default: React.MemoExoticComponent<{
2
- ({ className, rowsData, columnsData, theadRowsNumber }: {
2
+ ({ className, rowsData, columnsData, theadRowsNumber, setHoveredColumn, resetHoveredColumn }: {
3
3
  className: any;
4
4
  rowsData: any;
5
5
  columnsData: any;
6
6
  theadRowsNumber?: number;
7
+ setHoveredColumn: any;
8
+ resetHoveredColumn: any;
7
9
  }): JSX.Element;
8
10
  propTypes: {
9
11
  rowsData: PropTypes.Requireable<PropTypes.InferProps<{
@@ -15,6 +17,8 @@ declare var _default: React.MemoExoticComponent<{
15
17
  columnsData: PropTypes.Requireable<object[]>;
16
18
  theadRowsNumber: PropTypes.Requireable<number>;
17
19
  className: PropTypes.Requireable<string>;
20
+ setHoveredColumn: PropTypes.Requireable<(...args: any[]) => any>;
21
+ resetHoveredColumn: PropTypes.Requireable<(...args: any[]) => any>;
18
22
  };
19
23
  }>;
20
24
  export default _default;
@@ -20,14 +20,14 @@ var DefaultCellRenderer = function (_a) {
20
20
  return value || null;
21
21
  };
22
22
  var VerticalHeadingsTable = function (_a) {
23
- var className = _a.className, rowsData = _a.rowsData, columnsData = _a.columnsData, _b = _a.theadRowsNumber, theadRowsNumber = _b === void 0 ? 0 : _b;
23
+ var className = _a.className, rowsData = _a.rowsData, columnsData = _a.columnsData, _b = _a.theadRowsNumber, theadRowsNumber = _b === void 0 ? 0 : _b, setHoveredColumn = _a.setHoveredColumn, resetHoveredColumn = _a.resetHoveredColumn;
24
24
  var renderRow = function (rowData) {
25
25
  var CellRenderer = rowData.cellRenderer || DefaultCellRenderer;
26
26
  var HeadCellRenderer = rowData.headCellRenderer || DefaultHeadCellRenderer;
27
27
  return (React.createElement("tr", { key: rowData.id },
28
28
  React.createElement("th", { key: rowData.id },
29
29
  React.createElement(HeadCellRenderer, __assign({}, rowData))),
30
- columnsData.map(function (columnValue, index) { return (React.createElement("td", { key: index },
30
+ columnsData.map(function (columnValue, index) { return (React.createElement("td", { key: index, onMouseOver: function () { return setHoveredColumn(columnValue); }, onMouseLeave: resetHoveredColumn },
31
31
  React.createElement(CellRenderer, { value: columnValue[rowData.id], columnValue: columnValue, rowData: rowData }))); })));
32
32
  };
33
33
  return (React.createElement("table", { className: className },
@@ -43,6 +43,8 @@ VerticalHeadingsTable.propTypes = {
43
43
  })),
44
44
  columnsData: PropTypes.arrayOf(PropTypes.object),
45
45
  theadRowsNumber: PropTypes.number,
46
- className: PropTypes.string
46
+ className: PropTypes.string,
47
+ setHoveredColumn: PropTypes.func,
48
+ resetHoveredColumn: PropTypes.func
47
49
  };
48
50
  export default memo(VerticalHeadingsTable);
@@ -1 +1 @@
1
- export const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"deleted" | "label" | "actions" | "expandButton" | "editor" | "editedLabel" | "titleContainer" | "errorWrapperHelperText">;
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" | "moreButton" | "buttonLabel" | "moreAttributes" | "popupContainer" | "moreAttributesPopup">;
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" | "wrapper" | "addButton" | "editor" | "errorWrapper" | "editor-value" | "editor-read-only-value" | "editor-actions" | "editedLabel">;
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" | "moreButton" | "editor" | "sourceIcon" | "attributeTitle" | "attributeWrapper">;
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" | "dateOptionLabel" | "dropdownIndicator" | "inputRoot" | "paper">;
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" | "adornedEnd" | "iconButtonRoot" | "inputLabel" | "inputRoot" | "adornmentPositionEnd">;
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" | "dropdownIndicator" | "adornedEnd" | "inputLabel" | "inputRoot" | "paper" | "menuItem" | "menuText">;
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" | "adornedEnd" | "iconButtonRoot" | "inputLabel" | "inputRoot">;
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" | "comments" | "info" | "card" | "withBackground" | "lineWrapper" | "commentsInfo" | "commentsIcon" | "infoValue" | "infoBlock" | "flag" | "mainInfo" | "controlsBox" | "controlsInRow">;
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" | "cancelButton" | "popoverPaper" | "simpleDropDownSelector">;
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" | "inputLabel" | "dueDateInput">;
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" | "rowDivider" | "decorator" | "plain" | "lineBlock" | "withLinePadding" | "noLine">;
1
+ export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"content" | "last" | "line" | "decorator" | "lineBlock" | "withLinePadding" | "noLine" | "plain" | "rowDivider">;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ export declare const SandboxAPIContext: React.Context<{
3
+ getCurrentPerspectiveId: () => string;
4
+ showPerspective: (perspective: any) => void;
5
+ setEntityUri: (entityUri: string, listener: () => void) => void;
6
+ }>;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ export var SandboxAPIContext = React.createContext({
3
+ getCurrentPerspectiveId: function () { return ''; },
4
+ setEntityUri: function () { },
5
+ showPerspective: function () { }
6
+ });
@@ -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';
@@ -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';
@@ -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';
@@ -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;
@@ -0,0 +1,197 @@
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 { sendRequestFromCustomSandbox, sendWorkflowRequest, startProcessFromQuery } from '@reltio/mdm-sdk';
13
+ import { RequestAction } from './types';
14
+ var processFromQuery = function (params, permissions, workflowPath, tenant, environment) {
15
+ if (!params.processDefinitionId) {
16
+ return new Promise(function (resolve) { return resolve({ errorMessage: 'processDefinitionId is empty' }); });
17
+ }
18
+ if (!params.searchString) {
19
+ return new Promise(function (resolve) { return resolve({ errorMessage: 'searchString is empty' }); });
20
+ }
21
+ if (!workflowPath) {
22
+ return new Promise(function (resolve) { return resolve({ errorMessage: 'Workflow path is not defined' }); });
23
+ }
24
+ var errors = validateParams(__assign({ url: '/processInstances/_generateFromQuery' }, params), permissions);
25
+ if (errors) {
26
+ return new Promise(function (resolve) { return resolve(errors); });
27
+ }
28
+ return startProcessFromQuery({
29
+ workflowPath: workflowPath,
30
+ processType: params.processDefinitionId,
31
+ searchString: params.searchString,
32
+ tenant: tenant,
33
+ environment: environment
34
+ });
35
+ };
36
+ var workflowRequest = function (params, permissions, workflowPath, tenant) {
37
+ var url = params.url;
38
+ var errors = validateParams(params, permissions);
39
+ if (errors) {
40
+ return new Promise(function (resolve) { return resolve(errors); });
41
+ }
42
+ var isExternalUrl = url.includes('http:') || url.includes('https:');
43
+ if (!workflowPath && !isExternalUrl) {
44
+ return new Promise(function (resolve) { return resolve({ errorMessage: 'Workflow path is not defined' }); });
45
+ }
46
+ return sendWorkflowRequest({
47
+ url: url,
48
+ method: params.method || 'GET',
49
+ data: params.data,
50
+ tenant: tenant,
51
+ headers: params.headers,
52
+ workflowPath: workflowPath
53
+ });
54
+ };
55
+ var sendApiRequest = function (params, permissions) {
56
+ var errors = validateParams(params, permissions);
57
+ if (errors) {
58
+ return new Promise(function (resolve) { return resolve(errors); });
59
+ }
60
+ return sendRequestFromCustomSandbox({
61
+ url: params.url,
62
+ method: params.method,
63
+ data: params.data,
64
+ headers: params.headers
65
+ });
66
+ };
67
+ var validateParams = function (params, permissions) {
68
+ var url = params.url;
69
+ if (!url)
70
+ return { errorMessage: 'URL is empty' };
71
+ var allowed = permissions === null || permissions === void 0 ? void 0 : permissions.some(function (perm) {
72
+ var parsed = perm.match(/^(?:([^:?#]+):)?(?:\/\/((?:(([^:@?]*)(?::([^:@?]*))?)?@)?((?:\[[0-9A-Fa-f:]+)|(?:[^:?#]*))(?::(\d*))?))?((((?:[^?#]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/);
73
+ var protocol = parsed[1];
74
+ var host = parsed[6];
75
+ var protocolAndHost = protocol + "://" + host;
76
+ var re = new RegExp('^' + perm + '$');
77
+ var formattedPerm = perm.replace(/\/*$/, '');
78
+ return (formattedPerm === url ||
79
+ (host && host === formattedPerm) ||
80
+ (host && protocolAndHost === formattedPerm) ||
81
+ (formattedPerm && formattedPerm.indexOf('/') === 0 && url && url.indexOf(formattedPerm) === 0) ||
82
+ (formattedPerm && re.test(url)));
83
+ });
84
+ if (!allowed || ((permissions === null || permissions === void 0 ? void 0 : permissions.length) || 0) === 0) {
85
+ return { errorMessage: 'Not enough permissions' };
86
+ }
87
+ return false;
88
+ };
89
+ export var processRequest = function (_a) {
90
+ var name = _a.name, paramObject = _a.paramObject, permissions = _a.permissions, worker = _a.worker, metadata = _a.metadata, config = _a.config, apiPath = _a.apiPath, 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;
91
+ var handleRequest = function (request) {
92
+ request
93
+ .then(function (data) {
94
+ worker.postMessage(__assign({ action: 'response', result: { data: data } }, paramObject.params));
95
+ })
96
+ .catch(function () {
97
+ worker.postMessage(__assign({ action: 'response', result: { data: {}, headers: '', status: 0 } }, paramObject.params));
98
+ });
99
+ };
100
+ switch (name) {
101
+ case RequestAction.API: {
102
+ var request = sendApiRequest(paramObject.params, permissions);
103
+ handleRequest(request);
104
+ break;
105
+ }
106
+ case RequestAction.WORKFLOW: {
107
+ var request = workflowRequest(paramObject.params, permissions, workflowPath, tenant);
108
+ handleRequest(request);
109
+ break;
110
+ }
111
+ case RequestAction.WORKFLOW_START_PROCESS_FROM_QUERY: {
112
+ var request = processFromQuery(paramObject.params, permissions, workflowPath, tenant, environment);
113
+ handleRequest(request);
114
+ break;
115
+ }
116
+ case RequestAction.GET_CONFIGURATION: {
117
+ worker.postMessage(__assign({ action: 'response', result: metadata }, paramObject.params));
118
+ break;
119
+ }
120
+ case RequestAction.GET_UI_CONFIGURATION: {
121
+ var response = __assign(__assign({}, config), { action: __assign({}, config.action) });
122
+ if (response.action.permissions) {
123
+ delete response.action.permissions;
124
+ }
125
+ worker.postMessage(__assign({ action: 'response', result: response }, paramObject.params));
126
+ break;
127
+ }
128
+ case RequestAction.SET_ENTITY_URI: {
129
+ var listener = function () { return worker.postMessage(__assign({ action: 'response', result: entity }, paramObject.params)); };
130
+ setEntityUri(entityUri, listener);
131
+ break;
132
+ }
133
+ case RequestAction.SET_PERSPECTIVE: {
134
+ showPerspective(paramObject.params.perspective);
135
+ worker.postMessage(__assign({ action: 'response', result: getCurrentPerspectiveId() }, paramObject.params));
136
+ break;
137
+ }
138
+ case RequestAction.GET_PERSPECTIVE: {
139
+ if (getCurrentPerspectiveId) {
140
+ worker.postMessage(__assign({ action: 'response', result: getCurrentPerspectiveId() }, paramObject.params));
141
+ }
142
+ break;
143
+ }
144
+ case RequestAction.WORKFLOW_CHECK_PERMISSION: {
145
+ worker.postMessage(__assign({ action: 'response', result: workflowCheckPermission(paramObject.params.permission) }, paramObject.params));
146
+ break;
147
+ }
148
+ case RequestAction.GET_SEARCH_QUERY: {
149
+ worker.postMessage(__assign({ action: 'response', result: query }, paramObject.params));
150
+ break;
151
+ }
152
+ case RequestAction.OPEN_SEARCH: {
153
+ openSearch({ viewId: config.id, searchState: paramObject.params.searchState });
154
+ break;
155
+ }
156
+ case RequestAction.GET_ENTITY_URI: {
157
+ worker.postMessage(__assign({ action: 'response', result: entityUri }, paramObject.params));
158
+ break;
159
+ }
160
+ case RequestAction.GET_ENTITY: {
161
+ worker.postMessage(__assign({ action: 'response', result: entity }, paramObject.params));
162
+ break;
163
+ }
164
+ case RequestAction.GET_API_PATH: {
165
+ worker.postMessage(__assign({ action: 'response', result: apiPath }, paramObject.params));
166
+ break;
167
+ }
168
+ case RequestAction.WORKFLOW_GET_WORKFLOW_PATH: {
169
+ worker.postMessage(__assign({ action: 'response', result: workflowPath }, paramObject.params));
170
+ break;
171
+ }
172
+ case RequestAction.GET_TENANT: {
173
+ worker.postMessage(__assign({ action: 'response', result: tenant }, paramObject.params));
174
+ break;
175
+ }
176
+ case RequestAction.GET_USER: {
177
+ worker.postMessage(__assign({ action: 'response', result: user }, paramObject.params));
178
+ break;
179
+ }
180
+ case RequestAction.ALERT: {
181
+ window.alert(paramObject.params.text);
182
+ break;
183
+ }
184
+ case RequestAction.CONFIRM: {
185
+ window.confirm(paramObject.params.text);
186
+ break;
187
+ }
188
+ case RequestAction.PROMPT: {
189
+ window.prompt(paramObject.params.text, paramObject.params.defaultText || '');
190
+ break;
191
+ }
192
+ case RequestAction.OPEN_WINDOW: {
193
+ window.open(paramObject.params.url, '_blank');
194
+ break;
195
+ }
196
+ }
197
+ };
@@ -0,0 +1 @@
1
+ export declare const getWorkerURL: (uiPath: string, tenant: string) => string;
@@ -0,0 +1,8 @@
1
+ export var getWorkerURL = function (uiPath, tenant) {
2
+ if (uiPath === null || uiPath === void 0 ? void 0 : uiPath.includes('nui')) {
3
+ return uiPath.replace(tenant + "/", '') + "worker_api.js";
4
+ }
5
+ else {
6
+ return uiPath + "worker_api.js";
7
+ }
8
+ };
@@ -0,0 +1,5 @@
1
+ export { useAPI } from './useAPI';
2
+ export { CustomAction } from './types';
3
+ export { processRequest } from './API';
4
+ export { getWorkerURL } from './helpers';
5
+ export type { CustomActionTask, Params, Request } from './types';
@@ -0,0 +1,4 @@
1
+ export { useAPI } from './useAPI';
2
+ export { CustomAction } from './types';
3
+ export { processRequest } from './API';
4
+ export { getWorkerURL } from './helpers';
@@ -0,0 +1,90 @@
1
+ import { CustomScript, CustomViewConfig, PrimitiveValue } from '@reltio/mdm-sdk';
2
+ export declare enum RequestAction {
3
+ WORKFLOW = "workflow",
4
+ WORKFLOW_START_PROCESS_FROM_QUERY = "workflow/startProcessFromQuery",
5
+ API = "api",
6
+ GET_ENTITY_URI = "getEntityUri",
7
+ GET_ENTITY = "getEntity",
8
+ GET_API_PATH = "getApiPath",
9
+ WORKFLOW_GET_WORKFLOW_PATH = "workflow/getWorkflowPath",
10
+ GET_SEARCH_QUERY = "getSearchQuery",
11
+ GET_TENANT = "getTenant",
12
+ GET_USER = "getUser",
13
+ GET_PERSPECTIVE = "getPerspective",
14
+ SET_PERSPECTIVE = "setPerspective",
15
+ SET_ENTITY_URI = "setEntityUri",
16
+ ALERT = "alert",
17
+ CONFIRM = "confirm",
18
+ PROMPT = "prompt",
19
+ OPEN_WINDOW = "openWindow",
20
+ GET_CONFIGURATION = "getConfiguration",
21
+ GET_UI_CONFIGURATION = "getUiConfiguration",
22
+ OPEN_SEARCH = "openSearch",
23
+ WORKFLOW_CHECK_PERMISSION = "workflow/checkPermission"
24
+ }
25
+ export declare type Params = {
26
+ url?: string;
27
+ name?: RequestAction;
28
+ id?: string | number;
29
+ method?: 'PUT' | 'DELETE' | 'GET' | 'POST';
30
+ data?: {
31
+ [key: string]: unknown;
32
+ };
33
+ headers?: {
34
+ [key: string]: string;
35
+ };
36
+ processDefinitionId?: string;
37
+ searchString?: string;
38
+ perspective?: string;
39
+ permission?: string;
40
+ searchState?: unknown;
41
+ defaultText?: string;
42
+ text?: string;
43
+ html?: string;
44
+ };
45
+ export declare type ProcessRequestParams = {
46
+ name: RequestAction;
47
+ paramObject: {
48
+ params: Params;
49
+ };
50
+ permissions?: string[];
51
+ worker: Worker;
52
+ metadata: any;
53
+ config: CustomViewConfig | {
54
+ action: CustomScript;
55
+ };
56
+ user: any;
57
+ apiPath: string;
58
+ workflowPath: string;
59
+ environment: string;
60
+ entity: any;
61
+ tenant: any;
62
+ entityUri: string;
63
+ query: any;
64
+ openSearch: (search: any) => void;
65
+ workflowCheckPermission: (permission?: string) => boolean;
66
+ getCurrentPerspectiveId: () => string;
67
+ showPerspective: (perspective: any) => void;
68
+ setEntityUri: (entityUri: string, listener: () => void) => void;
69
+ };
70
+ export declare enum CustomAction {
71
+ SET_HTML = "setHtml",
72
+ LOG = "log",
73
+ SET_VISIBILITY = "setVisibility",
74
+ MESSAGE = "message",
75
+ SET_ENABLED = "setEnabled",
76
+ SET_TOOLTIP = "setToolTip",
77
+ SET_LABEL = "setLabel",
78
+ SET_HEIGHT = "setHeight",
79
+ SET_WIDTH = "setWidth",
80
+ RETURN_PROCESSED_API_RESPONSE = "returnProcessedApiResponse",
81
+ RETURN_PROCESSED_API_REQUEST = "returnProcessedApiRequest",
82
+ REQUEST = "request"
83
+ }
84
+ export declare type CustomActionTask = {
85
+ action: CustomAction;
86
+ params: Params | PrimitiveValue;
87
+ };
88
+ export declare type Request = Omit<CustomActionTask, 'params'> & {
89
+ params: Params;
90
+ };
@@ -0,0 +1,39 @@
1
+ export var RequestAction;
2
+ (function (RequestAction) {
3
+ RequestAction["WORKFLOW"] = "workflow";
4
+ RequestAction["WORKFLOW_START_PROCESS_FROM_QUERY"] = "workflow/startProcessFromQuery";
5
+ RequestAction["API"] = "api";
6
+ RequestAction["GET_ENTITY_URI"] = "getEntityUri";
7
+ RequestAction["GET_ENTITY"] = "getEntity";
8
+ RequestAction["GET_API_PATH"] = "getApiPath";
9
+ RequestAction["WORKFLOW_GET_WORKFLOW_PATH"] = "workflow/getWorkflowPath";
10
+ RequestAction["GET_SEARCH_QUERY"] = "getSearchQuery";
11
+ RequestAction["GET_TENANT"] = "getTenant";
12
+ RequestAction["GET_USER"] = "getUser";
13
+ RequestAction["GET_PERSPECTIVE"] = "getPerspective";
14
+ RequestAction["SET_PERSPECTIVE"] = "setPerspective";
15
+ RequestAction["SET_ENTITY_URI"] = "setEntityUri";
16
+ RequestAction["ALERT"] = "alert";
17
+ RequestAction["CONFIRM"] = "confirm";
18
+ RequestAction["PROMPT"] = "prompt";
19
+ RequestAction["OPEN_WINDOW"] = "openWindow";
20
+ RequestAction["GET_CONFIGURATION"] = "getConfiguration";
21
+ RequestAction["GET_UI_CONFIGURATION"] = "getUiConfiguration";
22
+ RequestAction["OPEN_SEARCH"] = "openSearch";
23
+ RequestAction["WORKFLOW_CHECK_PERMISSION"] = "workflow/checkPermission";
24
+ })(RequestAction || (RequestAction = {}));
25
+ export var CustomAction;
26
+ (function (CustomAction) {
27
+ CustomAction["SET_HTML"] = "setHtml";
28
+ CustomAction["LOG"] = "log";
29
+ CustomAction["SET_VISIBILITY"] = "setVisibility";
30
+ CustomAction["MESSAGE"] = "message";
31
+ CustomAction["SET_ENABLED"] = "setEnabled";
32
+ CustomAction["SET_TOOLTIP"] = "setToolTip";
33
+ CustomAction["SET_LABEL"] = "setLabel";
34
+ CustomAction["SET_HEIGHT"] = "setHeight";
35
+ CustomAction["SET_WIDTH"] = "setWidth";
36
+ CustomAction["RETURN_PROCESSED_API_RESPONSE"] = "returnProcessedApiResponse";
37
+ CustomAction["RETURN_PROCESSED_API_REQUEST"] = "returnProcessedApiRequest";
38
+ CustomAction["REQUEST"] = "request";
39
+ })(CustomAction || (CustomAction = {}));
@@ -0,0 +1,13 @@
1
+ import { CustomViewConfig } from '@reltio/mdm-sdk';
2
+ export declare const useAPI: (config: CustomViewConfig) => {
3
+ html: HTMLElement;
4
+ visible: boolean;
5
+ tooltip: string;
6
+ customStyles: {
7
+ height?: number | string;
8
+ width?: number | string;
9
+ 'pointer-events'?: string;
10
+ };
11
+ message: string;
12
+ onClosePopup: () => void;
13
+ };