@reltio/components 1.4.1161 → 1.4.1162

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.
@@ -1,6 +1,5 @@
1
1
  export { useActions } from './useActions';
2
- export { useAPI, CustomAction } from './useAPI';
3
- export type { CustomActionTask } from './useAPI';
2
+ export { useAPI } from './useAPI';
4
3
  export { useAsyncMount } from './useAsyncMount';
5
4
  export { useCollaboration } from './useCollaboration';
6
5
  export { useCommentsEntitiesMap } from './useCommentsEntitiesMap';
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useSnackbar = exports.useSavedStateForEntityType = exports.useReadableSearchState = exports.useEditableConnection = exports.useCustomScripts = exports.useMarkAsNotMatchRequest = exports.useMergeAllRequest = exports.usePagingSimulator = exports.useMatchesLoader = exports.useConfigPermissions = exports.useWhyDidYouUpdate = exports.useUsers = exports.useSavedState = exports.useSafePromise = exports.useRunOnceAfterValueInitialization = exports.useRelationsLoader = exports.useRelationTypeSelector = exports.usePrevious = exports.useDidUpdateEffect = exports.useCommentsEntitiesMap = exports.useCollaboration = exports.useAsyncMount = exports.CustomAction = exports.useAPI = exports.useActions = void 0;
3
+ exports.useSnackbar = exports.useSavedStateForEntityType = exports.useReadableSearchState = exports.useEditableConnection = exports.useCustomScripts = exports.useMarkAsNotMatchRequest = exports.useMergeAllRequest = exports.usePagingSimulator = exports.useMatchesLoader = exports.useConfigPermissions = exports.useWhyDidYouUpdate = exports.useUsers = exports.useSavedState = exports.useSafePromise = exports.useRunOnceAfterValueInitialization = exports.useRelationsLoader = exports.useRelationTypeSelector = exports.usePrevious = exports.useDidUpdateEffect = exports.useCommentsEntitiesMap = exports.useCollaboration = exports.useAsyncMount = exports.useAPI = exports.useActions = void 0;
4
4
  var useActions_1 = require("./useActions");
5
5
  Object.defineProperty(exports, "useActions", { enumerable: true, get: function () { return useActions_1.useActions; } });
6
6
  var useAPI_1 = require("./useAPI");
7
7
  Object.defineProperty(exports, "useAPI", { enumerable: true, get: function () { return useAPI_1.useAPI; } });
8
- Object.defineProperty(exports, "CustomAction", { enumerable: true, get: function () { return useAPI_1.CustomAction; } });
9
8
  var useAsyncMount_1 = require("./useAsyncMount");
10
9
  Object.defineProperty(exports, "useAsyncMount", { enumerable: true, get: function () { return useAsyncMount_1.useAsyncMount; } });
11
10
  var useCollaboration_1 = require("./useCollaboration");
@@ -13,7 +13,6 @@ var __assign = (this && this.__assign) || function () {
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.processRequest = void 0;
15
15
  var mdm_sdk_1 = require("@reltio/mdm-sdk");
16
- var types_1 = require("./types");
17
16
  var processFromQuery = function (params, permissions, workflowPath, tenant, environment) {
18
17
  if (!params.processDefinitionId) {
19
18
  return new Promise(function (resolve) { return resolve({ errorMessage: 'processDefinitionId is empty' }); });
@@ -101,26 +100,26 @@ var processRequest = function (_a) {
101
100
  });
102
101
  };
103
102
  switch (name) {
104
- case types_1.RequestAction.API: {
103
+ case mdm_sdk_1.RequestAction.API: {
105
104
  var request = sendApiRequest(paramObject.params, permissions);
106
105
  handleRequest(request);
107
106
  break;
108
107
  }
109
- case types_1.RequestAction.WORKFLOW: {
108
+ case mdm_sdk_1.RequestAction.WORKFLOW: {
110
109
  var request = workflowRequest(paramObject.params, permissions, workflowPath, tenant);
111
110
  handleRequest(request);
112
111
  break;
113
112
  }
114
- case types_1.RequestAction.WORKFLOW_START_PROCESS_FROM_QUERY: {
113
+ case mdm_sdk_1.RequestAction.WORKFLOW_START_PROCESS_FROM_QUERY: {
115
114
  var request = processFromQuery(paramObject.params, permissions, workflowPath, tenant, environment);
116
115
  handleRequest(request);
117
116
  break;
118
117
  }
119
- case types_1.RequestAction.GET_CONFIGURATION: {
118
+ case mdm_sdk_1.RequestAction.GET_CONFIGURATION: {
120
119
  worker.postMessage(__assign({ action: 'response', result: metadata }, paramObject.params));
121
120
  break;
122
121
  }
123
- case types_1.RequestAction.GET_UI_CONFIGURATION: {
122
+ case mdm_sdk_1.RequestAction.GET_UI_CONFIGURATION: {
124
123
  var response = __assign(__assign({}, config), { action: __assign({}, config.action) });
125
124
  if (response.action.permissions) {
126
125
  delete response.action.permissions;
@@ -128,71 +127,71 @@ var processRequest = function (_a) {
128
127
  worker.postMessage(__assign({ action: 'response', result: response }, paramObject.params));
129
128
  break;
130
129
  }
131
- case types_1.RequestAction.SET_ENTITY_URI: {
130
+ case mdm_sdk_1.RequestAction.SET_ENTITY_URI: {
132
131
  var listener = function () { return worker.postMessage(__assign({ action: 'response', result: entity }, paramObject.params)); };
133
132
  setEntityUri(entityUri, listener);
134
133
  break;
135
134
  }
136
- case types_1.RequestAction.SET_PERSPECTIVE: {
135
+ case mdm_sdk_1.RequestAction.SET_PERSPECTIVE: {
137
136
  showPerspective(paramObject.params.perspective);
138
137
  worker.postMessage(__assign({ action: 'response', result: getCurrentPerspectiveId() }, paramObject.params));
139
138
  break;
140
139
  }
141
- case types_1.RequestAction.GET_PERSPECTIVE: {
140
+ case mdm_sdk_1.RequestAction.GET_PERSPECTIVE: {
142
141
  if (getCurrentPerspectiveId) {
143
142
  worker.postMessage(__assign({ action: 'response', result: getCurrentPerspectiveId() }, paramObject.params));
144
143
  }
145
144
  break;
146
145
  }
147
- case types_1.RequestAction.WORKFLOW_CHECK_PERMISSION: {
146
+ case mdm_sdk_1.RequestAction.WORKFLOW_CHECK_PERMISSION: {
148
147
  worker.postMessage(__assign({ action: 'response', result: workflowCheckPermission(paramObject.params.permission) }, paramObject.params));
149
148
  break;
150
149
  }
151
- case types_1.RequestAction.GET_SEARCH_QUERY: {
150
+ case mdm_sdk_1.RequestAction.GET_SEARCH_QUERY: {
152
151
  worker.postMessage(__assign({ action: 'response', result: query }, paramObject.params));
153
152
  break;
154
153
  }
155
- case types_1.RequestAction.OPEN_SEARCH: {
154
+ case mdm_sdk_1.RequestAction.OPEN_SEARCH: {
156
155
  openSearch({ viewId: config.id, searchState: paramObject.params.searchState });
157
156
  break;
158
157
  }
159
- case types_1.RequestAction.GET_ENTITY_URI: {
158
+ case mdm_sdk_1.RequestAction.GET_ENTITY_URI: {
160
159
  worker.postMessage(__assign({ action: 'response', result: entityUri }, paramObject.params));
161
160
  break;
162
161
  }
163
- case types_1.RequestAction.GET_ENTITY: {
162
+ case mdm_sdk_1.RequestAction.GET_ENTITY: {
164
163
  worker.postMessage(__assign({ action: 'response', result: entity }, paramObject.params));
165
164
  break;
166
165
  }
167
- case types_1.RequestAction.GET_API_PATH: {
166
+ case mdm_sdk_1.RequestAction.GET_API_PATH: {
168
167
  worker.postMessage(__assign({ action: 'response', result: apiPath }, paramObject.params));
169
168
  break;
170
169
  }
171
- case types_1.RequestAction.WORKFLOW_GET_WORKFLOW_PATH: {
170
+ case mdm_sdk_1.RequestAction.WORKFLOW_GET_WORKFLOW_PATH: {
172
171
  worker.postMessage(__assign({ action: 'response', result: workflowPath }, paramObject.params));
173
172
  break;
174
173
  }
175
- case types_1.RequestAction.GET_TENANT: {
174
+ case mdm_sdk_1.RequestAction.GET_TENANT: {
176
175
  worker.postMessage(__assign({ action: 'response', result: tenant }, paramObject.params));
177
176
  break;
178
177
  }
179
- case types_1.RequestAction.GET_USER: {
178
+ case mdm_sdk_1.RequestAction.GET_USER: {
180
179
  worker.postMessage(__assign({ action: 'response', result: user }, paramObject.params));
181
180
  break;
182
181
  }
183
- case types_1.RequestAction.ALERT: {
182
+ case mdm_sdk_1.RequestAction.ALERT: {
184
183
  worker.postMessage(__assign({ action: 'response', result: window.alert(paramObject.params.text) }, paramObject.params));
185
184
  break;
186
185
  }
187
- case types_1.RequestAction.CONFIRM: {
186
+ case mdm_sdk_1.RequestAction.CONFIRM: {
188
187
  worker.postMessage(__assign({ action: 'response', result: window.confirm(paramObject.params.text) }, paramObject.params));
189
188
  break;
190
189
  }
191
- case types_1.RequestAction.PROMPT: {
190
+ case mdm_sdk_1.RequestAction.PROMPT: {
192
191
  worker.postMessage(__assign({ action: 'response', result: window.prompt(paramObject.params.text, paramObject.params.defaultText || '') }, paramObject.params));
193
192
  break;
194
193
  }
195
- case types_1.RequestAction.OPEN_WINDOW: {
194
+ case mdm_sdk_1.RequestAction.OPEN_WINDOW: {
196
195
  window.open(paramObject.params.url, '_blank');
197
196
  break;
198
197
  }
@@ -1,5 +1,4 @@
1
1
  export { useAPI } from './useAPI';
2
- export { CustomAction } from './types';
3
2
  export { processRequest } from './API';
4
3
  export { getWorkerURL } from './helpers';
5
- export type { CustomActionTask, Params, Request } from './types';
4
+ export type { Request } from './types';
@@ -1,10 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getWorkerURL = exports.processRequest = exports.CustomAction = exports.useAPI = void 0;
3
+ exports.getWorkerURL = exports.processRequest = exports.useAPI = void 0;
4
4
  var useAPI_1 = require("./useAPI");
5
5
  Object.defineProperty(exports, "useAPI", { enumerable: true, get: function () { return useAPI_1.useAPI; } });
6
- var types_1 = require("./types");
7
- Object.defineProperty(exports, "CustomAction", { enumerable: true, get: function () { return types_1.CustomAction; } });
8
6
  var API_1 = require("./API");
9
7
  Object.defineProperty(exports, "processRequest", { enumerable: true, get: function () { return API_1.processRequest; } });
10
8
  var helpers_1 = require("./helpers");
@@ -1,52 +1,8 @@
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
- type?: string;
45
- };
1
+ import { CustomActionTask, CustomActionTaskParams, CustomScript, CustomViewConfig, RequestAction } from '@reltio/mdm-sdk';
46
2
  export declare type ProcessRequestParams = {
47
3
  name: RequestAction;
48
4
  paramObject: {
49
- params: Params;
5
+ params: CustomActionTaskParams;
50
6
  };
51
7
  permissions?: string[];
52
8
  worker: Worker;
@@ -68,25 +24,6 @@ export declare type ProcessRequestParams = {
68
24
  showPerspective: (perspective: any) => void;
69
25
  setEntityUri: (entityUri: string, listener: () => void) => void;
70
26
  };
71
- export declare enum CustomAction {
72
- SET_HTML = "setHtml",
73
- LOG = "log",
74
- SET_VISIBILITY = "setVisibility",
75
- MESSAGE = "message",
76
- SET_ENABLED = "setEnabled",
77
- SET_TOOLTIP = "setToolTip",
78
- SET_LABEL = "setLabel",
79
- SET_HEIGHT = "setHeight",
80
- SET_WIDTH = "setWidth",
81
- RETURN_PROCESSED_API_RESPONSE = "returnProcessedApiResponse",
82
- RETURN_PROCESSED_API_REQUEST = "returnProcessedApiRequest",
83
- REQUEST = "request",
84
- EVENT = "event"
85
- }
86
- export declare type CustomActionTask = {
87
- action: CustomAction;
88
- params: Params | PrimitiveValue;
89
- };
90
27
  export declare type Request = Omit<CustomActionTask, 'params'> & {
91
- params: Params;
28
+ params: CustomActionTaskParams;
92
29
  };
@@ -1,43 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CustomAction = exports.RequestAction = void 0;
4
- var RequestAction;
5
- (function (RequestAction) {
6
- RequestAction["WORKFLOW"] = "workflow";
7
- RequestAction["WORKFLOW_START_PROCESS_FROM_QUERY"] = "workflow/startProcessFromQuery";
8
- RequestAction["API"] = "api";
9
- RequestAction["GET_ENTITY_URI"] = "getEntityUri";
10
- RequestAction["GET_ENTITY"] = "getEntity";
11
- RequestAction["GET_API_PATH"] = "getApiPath";
12
- RequestAction["WORKFLOW_GET_WORKFLOW_PATH"] = "workflow/getWorkflowPath";
13
- RequestAction["GET_SEARCH_QUERY"] = "getSearchQuery";
14
- RequestAction["GET_TENANT"] = "getTenant";
15
- RequestAction["GET_USER"] = "getUser";
16
- RequestAction["GET_PERSPECTIVE"] = "getPerspective";
17
- RequestAction["SET_PERSPECTIVE"] = "setPerspective";
18
- RequestAction["SET_ENTITY_URI"] = "setEntityUri";
19
- RequestAction["ALERT"] = "alert";
20
- RequestAction["CONFIRM"] = "confirm";
21
- RequestAction["PROMPT"] = "prompt";
22
- RequestAction["OPEN_WINDOW"] = "openWindow";
23
- RequestAction["GET_CONFIGURATION"] = "getConfiguration";
24
- RequestAction["GET_UI_CONFIGURATION"] = "getUiConfiguration";
25
- RequestAction["OPEN_SEARCH"] = "openSearch";
26
- RequestAction["WORKFLOW_CHECK_PERMISSION"] = "workflow/checkPermission";
27
- })(RequestAction = exports.RequestAction || (exports.RequestAction = {}));
28
- var CustomAction;
29
- (function (CustomAction) {
30
- CustomAction["SET_HTML"] = "setHtml";
31
- CustomAction["LOG"] = "log";
32
- CustomAction["SET_VISIBILITY"] = "setVisibility";
33
- CustomAction["MESSAGE"] = "message";
34
- CustomAction["SET_ENABLED"] = "setEnabled";
35
- CustomAction["SET_TOOLTIP"] = "setToolTip";
36
- CustomAction["SET_LABEL"] = "setLabel";
37
- CustomAction["SET_HEIGHT"] = "setHeight";
38
- CustomAction["SET_WIDTH"] = "setWidth";
39
- CustomAction["RETURN_PROCESSED_API_RESPONSE"] = "returnProcessedApiResponse";
40
- CustomAction["RETURN_PROCESSED_API_REQUEST"] = "returnProcessedApiRequest";
41
- CustomAction["REQUEST"] = "request";
42
- CustomAction["EVENT"] = "event";
43
- })(CustomAction = exports.CustomAction || (exports.CustomAction = {}));
@@ -39,7 +39,6 @@ var workflow_1 = require("../../components/workflow");
39
39
  var contexts_1 = require("../../contexts");
40
40
  var API_1 = require("./API");
41
41
  var helpers_1 = require("./helpers");
42
- var types_1 = require("./types");
43
42
  var useAPI = function (config) {
44
43
  if (config === void 0) { config = {}; }
45
44
  var _a = react_1.useState(), html = _a[0], setHtml = _a[1];
@@ -64,7 +63,8 @@ var useAPI = function (config) {
64
63
  var _g = react_redux_1.useSelector(mdm_module_1.default.selectors.getSearchProviderData) || {}, typeSearch = _g.type, search = _g.data;
65
64
  var openSearch = function (search) { return dispatch(mdm_module_1.ui.actions.openSearch(search)); };
66
65
  var workerRef = react_1.useRef();
67
- var process = function (task, worker, innerText) {
66
+ var process = function (_a) {
67
+ var task = _a.task, worker = _a.worker, innerText = _a.innerText;
68
68
  if (task) {
69
69
  var handlersToReset_1 = [];
70
70
  var processInnerHtml_1 = function (parent) {
@@ -108,15 +108,15 @@ var useAPI = function (config) {
108
108
  setListenersToReset(handlersToReset_1);
109
109
  setHtml(docBlock);
110
110
  };
111
- if (task.action === types_1.CustomAction.SET_HTML && innerText !== task.params.html) {
111
+ if (task.action === mdm_sdk_1.CustomAction.SET_HTML && innerText !== task.params.html) {
112
112
  resetHtml(task.params.html);
113
113
  }
114
114
  switch (task.action) {
115
- case types_1.CustomAction.LOG: {
115
+ case mdm_sdk_1.CustomAction.LOG: {
116
116
  console.log(task.params); //eslint-disable-line no-console
117
117
  break;
118
118
  }
119
- case types_1.CustomAction.SET_VISIBILITY: {
119
+ case mdm_sdk_1.CustomAction.SET_VISIBILITY: {
120
120
  if (task.params === 'visible') {
121
121
  setVisible(true);
122
122
  resetHtml();
@@ -126,20 +126,20 @@ var useAPI = function (config) {
126
126
  }
127
127
  break;
128
128
  }
129
- case types_1.CustomAction.SET_TOOLTIP: {
129
+ case mdm_sdk_1.CustomAction.SET_TOOLTIP: {
130
130
  setTooltip(task.params);
131
131
  resetHtml();
132
132
  break;
133
133
  }
134
- case types_1.CustomAction.SET_HEIGHT: {
134
+ case mdm_sdk_1.CustomAction.SET_HEIGHT: {
135
135
  setCustomStyles(function (prev) { return (__assign(__assign({}, (prev || {})), { height: task.params })); });
136
136
  break;
137
137
  }
138
- case types_1.CustomAction.SET_WIDTH: {
138
+ case mdm_sdk_1.CustomAction.SET_WIDTH: {
139
139
  setCustomStyles(function (prev) { return (__assign(__assign({}, (prev || {})), { width: task.params })); });
140
140
  break;
141
141
  }
142
- case types_1.CustomAction.SET_ENABLED: {
142
+ case mdm_sdk_1.CustomAction.SET_ENABLED: {
143
143
  setCustomStyles(function (prev) {
144
144
  var newStyles = __assign({}, (prev || {}));
145
145
  if (!task.params) {
@@ -152,11 +152,11 @@ var useAPI = function (config) {
152
152
  });
153
153
  break;
154
154
  }
155
- case types_1.CustomAction.MESSAGE: {
155
+ case mdm_sdk_1.CustomAction.MESSAGE: {
156
156
  setMessage(task.params);
157
157
  break;
158
158
  }
159
- case types_1.CustomAction.REQUEST: {
159
+ case mdm_sdk_1.CustomAction.REQUEST: {
160
160
  API_1.processRequest(__assign({ name: task.params.name, paramObject: task, permissions: config.action.permissions, worker: worker,
161
161
  metadata: metadata, config: config, user: user,
162
162
  apiPath: apiPath,
@@ -29,6 +29,17 @@ var __importStar = (this && this.__importStar) || function (mod) {
29
29
  __setModuleDefault(result, mod);
30
30
  return result;
31
31
  };
32
+ var __rest = (this && this.__rest) || function (s, e) {
33
+ var t = {};
34
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
35
+ t[p] = s[p];
36
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
37
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
38
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
39
+ t[p[i]] = s[p[i]];
40
+ }
41
+ return t;
42
+ };
32
43
  var __spreadArray = (this && this.__spreadArray) || function (to, from) {
33
44
  for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
34
45
  to[j] = from[i];
@@ -54,6 +65,10 @@ var isURLtoProcess = function (processApi, url) {
54
65
  return request.replace(/\/*$/, '') === url || (request && regExp.test(url));
55
66
  });
56
67
  };
68
+ var getCustomViewConfig = function (config) {
69
+ var processApiResponse = config.processApiResponse, processApiRequest = config.processApiRequest, permissions = config.permissions, files = config.files, otherProps = __rest(config, ["processApiResponse", "processApiRequest", "permissions", "files"]);
70
+ return __assign({ action: { processApiResponse: processApiResponse, processApiRequest: processApiRequest, permissions: permissions, files: files } }, otherProps);
71
+ };
57
72
  var useCustomScripts = function (config, _a) {
58
73
  var addInternalRequestInterceptor = _a.addInternalRequestInterceptor, addInternalResponseInterceptor = _a.addInternalResponseInterceptor, removeInternalRequestInterceptor = _a.removeInternalRequestInterceptor, removeInternalResponseInterceptor = _a.removeInternalResponseInterceptor;
59
74
  var customScripts = config.reduce(function (acc, customScript) {
@@ -81,14 +96,17 @@ var useCustomScripts = function (config, _a) {
81
96
  var requestListeners = react_1.useRef({});
82
97
  var responseListeners = react_1.useRef({});
83
98
  var workers = react_1.useRef({});
84
- var process = function (task, worker) {
85
- var _a, _b;
99
+ var process = function (_a) {
100
+ var _b, _c;
101
+ var task = _a.task, worker = _a.worker, config = _a.config;
86
102
  if (task) {
87
103
  switch (task.action) {
88
- case useAPI_1.CustomAction.REQUEST: {
89
- if (((_b = (_a = task.params) === null || _a === void 0 ? void 0 : _a.headers) === null || _b === void 0 ? void 0 : _b.origin) !== 'ui') {
90
- useAPI_1.processRequest(__assign({ name: task.params.name, paramObject: task, permissions: customScripts[0].permissions, worker: worker,
91
- metadata: metadata, config: { action: customScripts[0] }, user: user,
104
+ case mdm_sdk_1.CustomAction.REQUEST: {
105
+ if (((_c = (_b = task.params) === null || _b === void 0 ? void 0 : _b.headers) === null || _c === void 0 ? void 0 : _c.origin) !== 'ui') {
106
+ useAPI_1.processRequest(__assign({ name: task.params.name, paramObject: task, permissions: config.action.permissions, worker: worker,
107
+ metadata: metadata,
108
+ config: config,
109
+ user: user,
92
110
  apiPath: apiPath,
93
111
  tenant: tenant,
94
112
  workflowPath: workflowPath,
@@ -98,7 +116,7 @@ var useCustomScripts = function (config, _a) {
98
116
  workflowCheckPermission: workflowCheckPermission }, qxApi));
99
117
  }
100
118
  else {
101
- var _c = task.params, headers = _c.headers, id = _c.id, fakeURL = _c.url, method = _c.method, data = _c.data;
119
+ var _d = task.params, headers = _d.headers, id = _d.id, fakeURL = _d.url, method = _d.method, data = _d.data;
102
120
  var url = fakeURL.replace(reltioPath, apiPath);
103
121
  if (requestListeners.current[headers.requestId]) {
104
122
  requestListeners.current[headers.requestId].next(url, __assign(__assign({}, data), { id: id,
@@ -110,9 +128,9 @@ var useCustomScripts = function (config, _a) {
110
128
  }
111
129
  break;
112
130
  }
113
- case useAPI_1.CustomAction.RETURN_PROCESSED_API_RESPONSE:
114
- case useAPI_1.CustomAction.RETURN_PROCESSED_API_REQUEST: {
115
- var _d = task.params, id = _d.id, data = _d.data;
131
+ case mdm_sdk_1.CustomAction.RETURN_PROCESSED_API_RESPONSE:
132
+ case mdm_sdk_1.CustomAction.RETURN_PROCESSED_API_REQUEST: {
133
+ var _e = task.params, id = _e.id, data = _e.data;
116
134
  if (responseListeners.current[id]) {
117
135
  responseListeners.current[id].next(data);
118
136
  responseListeners.current = ramda_1.omit([id], responseListeners.current);
@@ -125,7 +143,8 @@ var useCustomScripts = function (config, _a) {
125
143
  react_1.useEffect(function () {
126
144
  workers.current = customScripts.reduce(function (acc, customScript) {
127
145
  var _a;
128
- return __assign(__assign({}, acc), (_a = {}, _a[customScript.actionId] = mdm_sdk_1.initializeWebWorker(workerUrl, customScript.files, process), _a));
146
+ var customViewConfig = getCustomViewConfig(customScript);
147
+ return __assign(__assign({}, acc), (_a = {}, _a[customScript.actionId] = mdm_sdk_1.initializeWebWorker(workerUrl, customScript.files, process, customViewConfig), _a));
129
148
  }, workers.current);
130
149
  return function () {
131
150
  Object.keys(workers.current).forEach(function (actionId) {
@@ -26,14 +26,14 @@ var useSavedStateForEntityType = function (_a) {
26
26
  }
27
27
  };
28
28
  useDidUpdateEffect_1.useDidUpdateEffect(saveChangesLocallyForPrevEntityType, [entityTypeUri]);
29
- var updateSavedState = function (stateToSave) {
29
+ var updateSavedState = react_1.useCallback(function (stateToSave) {
30
30
  var _a;
31
31
  var changedState = (_a = {},
32
32
  _a[entityTypeUri] = stateToSave,
33
33
  _a);
34
34
  setChangedState(changedState);
35
35
  saveState(__assign(__assign({}, savedState), changedState));
36
- };
36
+ }, [entityTypeUri, saveState, savedState]);
37
37
  react_1.useEffect(function () {
38
38
  getSavedState()
39
39
  .then(function (savedState) {
@@ -1,6 +1,5 @@
1
1
  export { useActions } from './useActions';
2
- export { useAPI, CustomAction } from './useAPI';
3
- export type { CustomActionTask } from './useAPI';
2
+ export { useAPI } from './useAPI';
4
3
  export { useAsyncMount } from './useAsyncMount';
5
4
  export { useCollaboration } from './useCollaboration';
6
5
  export { useCommentsEntitiesMap } from './useCommentsEntitiesMap';
@@ -1,5 +1,5 @@
1
1
  export { useActions } from './useActions';
2
- export { useAPI, CustomAction } from './useAPI';
2
+ export { useAPI } from './useAPI';
3
3
  export { useAsyncMount } from './useAsyncMount';
4
4
  export { useCollaboration } from './useCollaboration';
5
5
  export { useCommentsEntitiesMap } from './useCommentsEntitiesMap';
@@ -9,8 +9,7 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- import { sendRequestFromCustomSandbox, sendWorkflowRequest, startProcessFromQuery } from '@reltio/mdm-sdk';
13
- import { RequestAction } from './types';
12
+ import { RequestAction, sendRequestFromCustomSandbox, sendWorkflowRequest, startProcessFromQuery } from '@reltio/mdm-sdk';
14
13
  var processFromQuery = function (params, permissions, workflowPath, tenant, environment) {
15
14
  if (!params.processDefinitionId) {
16
15
  return new Promise(function (resolve) { return resolve({ errorMessage: 'processDefinitionId is empty' }); });
@@ -1,5 +1,4 @@
1
1
  export { useAPI } from './useAPI';
2
- export { CustomAction } from './types';
3
2
  export { processRequest } from './API';
4
3
  export { getWorkerURL } from './helpers';
5
- export type { CustomActionTask, Params, Request } from './types';
4
+ export type { Request } from './types';
@@ -1,4 +1,3 @@
1
1
  export { useAPI } from './useAPI';
2
- export { CustomAction } from './types';
3
2
  export { processRequest } from './API';
4
3
  export { getWorkerURL } from './helpers';
@@ -1,52 +1,8 @@
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
- type?: string;
45
- };
1
+ import { CustomActionTask, CustomActionTaskParams, CustomScript, CustomViewConfig, RequestAction } from '@reltio/mdm-sdk';
46
2
  export declare type ProcessRequestParams = {
47
3
  name: RequestAction;
48
4
  paramObject: {
49
- params: Params;
5
+ params: CustomActionTaskParams;
50
6
  };
51
7
  permissions?: string[];
52
8
  worker: Worker;
@@ -68,25 +24,6 @@ export declare type ProcessRequestParams = {
68
24
  showPerspective: (perspective: any) => void;
69
25
  setEntityUri: (entityUri: string, listener: () => void) => void;
70
26
  };
71
- export declare enum CustomAction {
72
- SET_HTML = "setHtml",
73
- LOG = "log",
74
- SET_VISIBILITY = "setVisibility",
75
- MESSAGE = "message",
76
- SET_ENABLED = "setEnabled",
77
- SET_TOOLTIP = "setToolTip",
78
- SET_LABEL = "setLabel",
79
- SET_HEIGHT = "setHeight",
80
- SET_WIDTH = "setWidth",
81
- RETURN_PROCESSED_API_RESPONSE = "returnProcessedApiResponse",
82
- RETURN_PROCESSED_API_REQUEST = "returnProcessedApiRequest",
83
- REQUEST = "request",
84
- EVENT = "event"
85
- }
86
- export declare type CustomActionTask = {
87
- action: CustomAction;
88
- params: Params | PrimitiveValue;
89
- };
90
27
  export declare type Request = Omit<CustomActionTask, 'params'> & {
91
- params: Params;
28
+ params: CustomActionTaskParams;
92
29
  };
@@ -1,40 +1 @@
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["EVENT"] = "event";
40
- })(CustomAction || (CustomAction = {}));
1
+ export {};
@@ -12,12 +12,11 @@ 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 { CustomScriptPlatform, initializeWebWorker, isEmptyValue } from '@reltio/mdm-sdk';
15
+ import { CustomAction, CustomScriptPlatform, initializeWebWorker, isEmptyValue } from '@reltio/mdm-sdk';
16
16
  import { useWorkflowCheckPermission } from '../../components/workflow';
17
17
  import { SandboxAPIContext } from '../../contexts';
18
18
  import { processRequest } from './API';
19
19
  import { getWorkerURL } from './helpers';
20
- import { CustomAction } from './types';
21
20
  export var useAPI = function (config) {
22
21
  if (config === void 0) { config = {}; }
23
22
  var _a = useState(), html = _a[0], setHtml = _a[1];
@@ -42,7 +41,8 @@ export var useAPI = function (config) {
42
41
  var _g = useSelector(mdmModule.selectors.getSearchProviderData) || {}, typeSearch = _g.type, search = _g.data;
43
42
  var openSearch = function (search) { return dispatch(ui.actions.openSearch(search)); };
44
43
  var workerRef = useRef();
45
- var process = function (task, worker, innerText) {
44
+ var process = function (_a) {
45
+ var task = _a.task, worker = _a.worker, innerText = _a.innerText;
46
46
  if (task) {
47
47
  var handlersToReset_1 = [];
48
48
  var processInnerHtml_1 = function (parent) {
@@ -9,6 +9,17 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
12
23
  var __spreadArray = (this && this.__spreadArray) || function (to, from) {
13
24
  for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
14
25
  to[j] = from[i];
@@ -17,18 +28,22 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
17
28
  import { useContext, useEffect, useRef } from 'react';
18
29
  import { useDispatch, useSelector } from 'react-redux';
19
30
  import mdmModule, { ui } from '@reltio/mdm-module';
20
- import { CustomScriptPlatform, initializeWebWorker, isEmptyValue } from '@reltio/mdm-sdk';
31
+ import { CustomAction, CustomScriptPlatform, initializeWebWorker, isEmptyValue } from '@reltio/mdm-sdk';
21
32
  import nanoid from 'nanoid';
22
- import { find, map, pick, pipe, prop, omit } from 'ramda';
33
+ import { find, map, omit, pick, pipe, prop } from 'ramda';
23
34
  import { useWorkflowCheckPermission } from '../components/workflow';
24
35
  import { SandboxAPIContext } from '../contexts';
25
- import { CustomAction, getWorkerURL, processRequest } from './useAPI';
36
+ import { getWorkerURL, processRequest } from './useAPI';
26
37
  var isURLtoProcess = function (processApi, url) {
27
38
  return (processApi || []).some(function (request) {
28
39
  var regExp = new RegExp("^" + request + "$");
29
40
  return request.replace(/\/*$/, '') === url || (request && regExp.test(url));
30
41
  });
31
42
  };
43
+ var getCustomViewConfig = function (config) {
44
+ var processApiResponse = config.processApiResponse, processApiRequest = config.processApiRequest, permissions = config.permissions, files = config.files, otherProps = __rest(config, ["processApiResponse", "processApiRequest", "permissions", "files"]);
45
+ return __assign({ action: { processApiResponse: processApiResponse, processApiRequest: processApiRequest, permissions: permissions, files: files } }, otherProps);
46
+ };
32
47
  export var useCustomScripts = function (config, _a) {
33
48
  var addInternalRequestInterceptor = _a.addInternalRequestInterceptor, addInternalResponseInterceptor = _a.addInternalResponseInterceptor, removeInternalRequestInterceptor = _a.removeInternalRequestInterceptor, removeInternalResponseInterceptor = _a.removeInternalResponseInterceptor;
34
49
  var customScripts = config.reduce(function (acc, customScript) {
@@ -56,14 +71,17 @@ export var useCustomScripts = function (config, _a) {
56
71
  var requestListeners = useRef({});
57
72
  var responseListeners = useRef({});
58
73
  var workers = useRef({});
59
- var process = function (task, worker) {
60
- var _a, _b;
74
+ var process = function (_a) {
75
+ var _b, _c;
76
+ var task = _a.task, worker = _a.worker, config = _a.config;
61
77
  if (task) {
62
78
  switch (task.action) {
63
79
  case CustomAction.REQUEST: {
64
- if (((_b = (_a = task.params) === null || _a === void 0 ? void 0 : _a.headers) === null || _b === void 0 ? void 0 : _b.origin) !== 'ui') {
65
- processRequest(__assign({ name: task.params.name, paramObject: task, permissions: customScripts[0].permissions, worker: worker,
66
- metadata: metadata, config: { action: customScripts[0] }, user: user,
80
+ if (((_c = (_b = task.params) === null || _b === void 0 ? void 0 : _b.headers) === null || _c === void 0 ? void 0 : _c.origin) !== 'ui') {
81
+ processRequest(__assign({ name: task.params.name, paramObject: task, permissions: config.action.permissions, worker: worker,
82
+ metadata: metadata,
83
+ config: config,
84
+ user: user,
67
85
  apiPath: apiPath,
68
86
  tenant: tenant,
69
87
  workflowPath: workflowPath,
@@ -73,7 +91,7 @@ export var useCustomScripts = function (config, _a) {
73
91
  workflowCheckPermission: workflowCheckPermission }, qxApi));
74
92
  }
75
93
  else {
76
- var _c = task.params, headers = _c.headers, id = _c.id, fakeURL = _c.url, method = _c.method, data = _c.data;
94
+ var _d = task.params, headers = _d.headers, id = _d.id, fakeURL = _d.url, method = _d.method, data = _d.data;
77
95
  var url = fakeURL.replace(reltioPath, apiPath);
78
96
  if (requestListeners.current[headers.requestId]) {
79
97
  requestListeners.current[headers.requestId].next(url, __assign(__assign({}, data), { id: id,
@@ -87,7 +105,7 @@ export var useCustomScripts = function (config, _a) {
87
105
  }
88
106
  case CustomAction.RETURN_PROCESSED_API_RESPONSE:
89
107
  case CustomAction.RETURN_PROCESSED_API_REQUEST: {
90
- var _d = task.params, id = _d.id, data = _d.data;
108
+ var _e = task.params, id = _e.id, data = _e.data;
91
109
  if (responseListeners.current[id]) {
92
110
  responseListeners.current[id].next(data);
93
111
  responseListeners.current = omit([id], responseListeners.current);
@@ -100,7 +118,8 @@ export var useCustomScripts = function (config, _a) {
100
118
  useEffect(function () {
101
119
  workers.current = customScripts.reduce(function (acc, customScript) {
102
120
  var _a;
103
- return __assign(__assign({}, acc), (_a = {}, _a[customScript.actionId] = initializeWebWorker(workerUrl, customScript.files, process), _a));
121
+ var customViewConfig = getCustomViewConfig(customScript);
122
+ return __assign(__assign({}, acc), (_a = {}, _a[customScript.actionId] = initializeWebWorker(workerUrl, customScript.files, process, customViewConfig), _a));
104
123
  }, workers.current);
105
124
  return function () {
106
125
  Object.keys(workers.current).forEach(function (actionId) {
@@ -9,7 +9,7 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- import { useEffect, useState } from 'react';
12
+ import { useCallback, useEffect, useState } from 'react';
13
13
  import { useDidUpdateEffect } from './useDidUpdateEffect';
14
14
  export var useSavedStateForEntityType = function (_a) {
15
15
  var getSavedState = _a.getSavedState, saveState = _a.saveState, entityTypeUri = _a.entityTypeUri;
@@ -23,14 +23,14 @@ export var useSavedStateForEntityType = function (_a) {
23
23
  }
24
24
  };
25
25
  useDidUpdateEffect(saveChangesLocallyForPrevEntityType, [entityTypeUri]);
26
- var updateSavedState = function (stateToSave) {
26
+ var updateSavedState = useCallback(function (stateToSave) {
27
27
  var _a;
28
28
  var changedState = (_a = {},
29
29
  _a[entityTypeUri] = stateToSave,
30
30
  _a);
31
31
  setChangedState(changedState);
32
32
  saveState(__assign(__assign({}, savedState), changedState));
33
- };
33
+ }, [entityTypeUri, saveState, savedState]);
34
34
  useEffect(function () {
35
35
  getSavedState()
36
36
  .then(function (savedState) {
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.1161",
3
+ "version": "1.4.1162",
4
4
  "license": "SEE LICENSE IN LICENSE FILE",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
7
7
  "dependencies": {
8
8
  "@date-io/moment": "^1.3.5",
9
9
  "@react-google-maps/api": "2.7.0",
10
- "@reltio/mdm-module": "^1.4.1161",
11
- "@reltio/mdm-sdk": "^1.4.1161",
10
+ "@reltio/mdm-module": "^1.4.1162",
11
+ "@reltio/mdm-sdk": "^1.4.1162",
12
12
  "classnames": "^2.2.5",
13
13
  "d3-cloud": "^1.2.5",
14
14
  "d3-geo": "^2.0.1",