@reltio/components 1.4.1102 → 1.4.1103
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/components/ActionButton/styles.d.ts +1 -1
- package/cjs/components/AttributesFiltersButton/ActionButtons/styles.d.ts +1 -1
- package/cjs/components/DropDownSelector/styles.d.ts +1 -1
- package/cjs/components/ModeSwitcherSelect/styles.d.ts +1 -1
- package/cjs/components/Popper/styles.d.ts +1 -1
- package/cjs/components/ProfileBand/styles.d.ts +1 -1
- package/cjs/components/ProfileCard/styles.d.ts +1 -1
- package/cjs/components/ProfileMatchCard/styles.d.ts +1 -1
- package/cjs/components/attributes/editMode/ComplexAttribute/styles.d.ts +1 -1
- package/cjs/components/attributes/editMode/MoreAttributesButton/styles.d.ts +1 -1
- package/cjs/components/attributes/editMode/SimpleAttributeEditor/styles.d.ts +1 -1
- package/cjs/components/crosswalks/CrosswalkAttributes/styles.d.ts +1 -1
- package/cjs/components/editors/CustomDateRangeEditor/styles.d.ts +1 -1
- package/cjs/components/editors/DateEditor/styles.d.ts +1 -1
- package/cjs/components/editors/DateRangeEditor/styles.d.ts +1 -1
- package/cjs/components/editors/TimestampEditor/styles.d.ts +1 -1
- package/cjs/components/workflow/cards/GenericWorkflowTaskCard/styles.d.ts +1 -1
- package/cjs/components/workflow/components/AddWorkflowDialog/styles.d.ts +1 -1
- package/cjs/components/workflow/components/DueDateField/styles.d.ts +1 -1
- package/cjs/components/workflow/components/LineDecorator/styles.d.ts +1 -1
- package/cjs/contexts/SandboxAPIContext/index.d.ts +6 -0
- package/cjs/contexts/SandboxAPIContext/index.js +12 -0
- package/cjs/contexts/index.d.ts +1 -0
- package/cjs/contexts/index.js +3 -1
- package/cjs/hooks/index.d.ts +3 -0
- package/cjs/hooks/index.js +6 -1
- package/cjs/hooks/useAPI/API.d.ts +2 -0
- package/cjs/hooks/useAPI/API.js +201 -0
- package/cjs/hooks/useAPI/helpers.d.ts +1 -0
- package/cjs/hooks/useAPI/helpers.js +12 -0
- package/cjs/hooks/useAPI/index.d.ts +5 -0
- package/cjs/hooks/useAPI/index.js +11 -0
- package/cjs/hooks/useAPI/types.d.ts +90 -0
- package/cjs/hooks/useAPI/types.js +42 -0
- package/cjs/hooks/useAPI/useAPI.d.ts +13 -0
- package/cjs/hooks/useAPI/useAPI.js +192 -0
- package/cjs/hooks/useCustomScripts.d.ts +9 -0
- package/cjs/hooks/useCustomScripts.js +215 -0
- package/esm/components/ActionButton/styles.d.ts +1 -1
- package/esm/components/AttributesFiltersButton/ActionButtons/styles.d.ts +1 -1
- package/esm/components/DropDownSelector/styles.d.ts +1 -1
- package/esm/components/ModeSwitcherSelect/styles.d.ts +1 -1
- package/esm/components/Popper/styles.d.ts +1 -1
- package/esm/components/ProfileBand/styles.d.ts +1 -1
- package/esm/components/ProfileCard/styles.d.ts +1 -1
- package/esm/components/ProfileMatchCard/styles.d.ts +1 -1
- package/esm/components/attributes/editMode/ComplexAttribute/styles.d.ts +1 -1
- package/esm/components/attributes/editMode/MoreAttributesButton/styles.d.ts +1 -1
- package/esm/components/attributes/editMode/SimpleAttributeEditor/styles.d.ts +1 -1
- package/esm/components/crosswalks/CrosswalkAttributes/styles.d.ts +1 -1
- package/esm/components/editors/CustomDateRangeEditor/styles.d.ts +1 -1
- package/esm/components/editors/DateEditor/styles.d.ts +1 -1
- package/esm/components/editors/DateRangeEditor/styles.d.ts +1 -1
- package/esm/components/editors/TimestampEditor/styles.d.ts +1 -1
- package/esm/components/workflow/cards/GenericWorkflowTaskCard/styles.d.ts +1 -1
- package/esm/components/workflow/components/AddWorkflowDialog/styles.d.ts +1 -1
- package/esm/components/workflow/components/DueDateField/styles.d.ts +1 -1
- package/esm/components/workflow/components/LineDecorator/styles.d.ts +1 -1
- package/esm/contexts/SandboxAPIContext/index.d.ts +6 -0
- package/esm/contexts/SandboxAPIContext/index.js +6 -0
- package/esm/contexts/index.d.ts +1 -0
- package/esm/contexts/index.js +1 -0
- package/esm/hooks/index.d.ts +3 -0
- package/esm/hooks/index.js +2 -0
- package/esm/hooks/useAPI/API.d.ts +2 -0
- package/esm/hooks/useAPI/API.js +197 -0
- package/esm/hooks/useAPI/helpers.d.ts +1 -0
- package/esm/hooks/useAPI/helpers.js +8 -0
- package/esm/hooks/useAPI/index.d.ts +5 -0
- package/esm/hooks/useAPI/index.js +4 -0
- package/esm/hooks/useAPI/types.d.ts +90 -0
- package/esm/hooks/useAPI/types.js +39 -0
- package/esm/hooks/useAPI/useAPI.d.ts +13 -0
- package/esm/hooks/useAPI/useAPI.js +169 -0
- package/esm/hooks/useCustomScripts.d.ts +9 -0
- package/esm/hooks/useCustomScripts.js +189 -0
- package/package.json +3 -3
|
@@ -0,0 +1,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,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
|
+
};
|
|
@@ -0,0 +1,169 @@
|
|
|
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 { useContext, useEffect, useState } from 'react';
|
|
13
|
+
import { useDispatch, useSelector } from 'react-redux';
|
|
14
|
+
import mdmModule, { ui } from '@reltio/mdm-module';
|
|
15
|
+
import { initializeWebWorker } from '@reltio/mdm-sdk';
|
|
16
|
+
import { useWorkflowCheckPermission } from '../../components/workflow';
|
|
17
|
+
import { SandboxAPIContext } from '../../contexts';
|
|
18
|
+
import { processRequest } from './API';
|
|
19
|
+
import { getWorkerURL } from './helpers';
|
|
20
|
+
import { CustomAction } from './types';
|
|
21
|
+
export var useAPI = function (config) {
|
|
22
|
+
var _a = config.action, files = _a.files, permissions = _a.permissions;
|
|
23
|
+
var _b = useState(), html = _b[0], setHtml = _b[1];
|
|
24
|
+
var _c = useState([]), listenersToReset = _c[0], setListenersToReset = _c[1];
|
|
25
|
+
var _d = useState(true), visible = _d[0], setVisible = _d[1];
|
|
26
|
+
var _e = useState(null), tooltip = _e[0], setTooltip = _e[1];
|
|
27
|
+
var _f = useState(null), customStyles = _f[0], setCustomStyles = _f[1];
|
|
28
|
+
var _g = useState(''), message = _g[0], setMessage = _g[1];
|
|
29
|
+
var dispatch = useDispatch();
|
|
30
|
+
var metadata = useSelector(mdmModule.selectors.getMetadata) || {};
|
|
31
|
+
var entity = useSelector(mdmModule.selectors.getEntity) || {};
|
|
32
|
+
var uiPath = useSelector(mdmModule.selectors.getUIPath);
|
|
33
|
+
var tenant = useSelector(mdmModule.selectors.getTenant);
|
|
34
|
+
var workerUrl = getWorkerURL(uiPath, tenant);
|
|
35
|
+
var apiPath = useSelector(mdmModule.selectors.getApiPath);
|
|
36
|
+
var workflowPath = useSelector(mdmModule.selectors.getWorkflowPath);
|
|
37
|
+
var user = useSelector(mdmModule.selectors.getUser);
|
|
38
|
+
var entityUri = useSelector(mdmModule.selectors.getEntityUri);
|
|
39
|
+
var environment = useSelector(mdmModule.selectors.getWorkflowEnvironmentUrl);
|
|
40
|
+
var qxApi = useContext(SandboxAPIContext);
|
|
41
|
+
var workflowCheckPermission = useWorkflowCheckPermission();
|
|
42
|
+
var _h = useSelector(mdmModule.selectors.getSearchProviderData) || {}, typeSearch = _h.type, search = _h.data;
|
|
43
|
+
var openSearch = function (search) { return dispatch(ui.actions.openSearch(search)); };
|
|
44
|
+
var process = function (task, worker, innerText) {
|
|
45
|
+
if (task) {
|
|
46
|
+
var handlersToReset_1 = [];
|
|
47
|
+
var processInnerHtml_1 = function (parent) {
|
|
48
|
+
var uiActions = parent.getAttribute('ui-actions');
|
|
49
|
+
var uiTooltip = parent.getAttribute('ui-tooltip');
|
|
50
|
+
var id = parent.getAttribute('id') || parent.getAttribute('name');
|
|
51
|
+
if (uiActions) {
|
|
52
|
+
uiActions.split(',').forEach(function (uiAction) {
|
|
53
|
+
var handler = function () {
|
|
54
|
+
var data = {
|
|
55
|
+
action: 'event',
|
|
56
|
+
type: 'uiAction',
|
|
57
|
+
data: {
|
|
58
|
+
type: uiAction,
|
|
59
|
+
id: id
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
worker.postMessage(data);
|
|
63
|
+
};
|
|
64
|
+
parent.addEventListener(uiAction, handler);
|
|
65
|
+
handlersToReset_1.push(function () {
|
|
66
|
+
parent.removeEventListener(uiAction, handler);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
parent.removeAttribute('ui-actions');
|
|
70
|
+
}
|
|
71
|
+
if (uiTooltip) {
|
|
72
|
+
setTooltip(uiTooltip);
|
|
73
|
+
}
|
|
74
|
+
parent.childNodes.forEach(function (child) {
|
|
75
|
+
if (child.nodeType === 1) {
|
|
76
|
+
//Node.ELEMENT_NODE
|
|
77
|
+
processInnerHtml_1(child);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
var resetHtml = function (html) {
|
|
82
|
+
var docBlock = document.createElement('div');
|
|
83
|
+
docBlock.innerHTML = html || innerText;
|
|
84
|
+
processInnerHtml_1(docBlock);
|
|
85
|
+
setListenersToReset(handlersToReset_1);
|
|
86
|
+
setHtml(docBlock);
|
|
87
|
+
};
|
|
88
|
+
if (task.action === CustomAction.SET_HTML && innerText !== task.params.html) {
|
|
89
|
+
resetHtml(task.params.html);
|
|
90
|
+
}
|
|
91
|
+
switch (task.action) {
|
|
92
|
+
case CustomAction.LOG: {
|
|
93
|
+
console.log(task.params); //eslint-disable-line no-console
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
case CustomAction.SET_VISIBILITY: {
|
|
97
|
+
if (task.params === 'visible') {
|
|
98
|
+
setVisible(true);
|
|
99
|
+
resetHtml();
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
setVisible(false);
|
|
103
|
+
}
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
case CustomAction.SET_TOOLTIP: {
|
|
107
|
+
setTooltip(task.params);
|
|
108
|
+
resetHtml();
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
case CustomAction.SET_HEIGHT: {
|
|
112
|
+
setCustomStyles(function (prev) { return (__assign(__assign({}, (prev || {})), { height: task.params })); });
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
case CustomAction.SET_WIDTH: {
|
|
116
|
+
setCustomStyles(function (prev) { return (__assign(__assign({}, (prev || {})), { width: task.params })); });
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
case CustomAction.SET_ENABLED: {
|
|
120
|
+
setCustomStyles(function (prev) {
|
|
121
|
+
var newStyles = __assign({}, (prev || {}));
|
|
122
|
+
if (!task.params) {
|
|
123
|
+
newStyles['pointer-events'] = 'none';
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
delete newStyles['pointer-events'];
|
|
127
|
+
}
|
|
128
|
+
return newStyles;
|
|
129
|
+
});
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
case CustomAction.MESSAGE: {
|
|
133
|
+
setMessage(task.params);
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
case CustomAction.REQUEST: {
|
|
137
|
+
processRequest(__assign({ name: task.params.name, paramObject: task, permissions: permissions,
|
|
138
|
+
worker: worker,
|
|
139
|
+
metadata: metadata, config: config, user: user,
|
|
140
|
+
apiPath: apiPath,
|
|
141
|
+
tenant: tenant,
|
|
142
|
+
workflowPath: workflowPath,
|
|
143
|
+
entity: entity,
|
|
144
|
+
entityUri: entityUri,
|
|
145
|
+
environment: environment, query: typeSearch === 'search' ? search === null || search === void 0 ? void 0 : search.query : null, openSearch: openSearch,
|
|
146
|
+
workflowCheckPermission: workflowCheckPermission }, qxApi));
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
useEffect(function () {
|
|
153
|
+
var worker = initializeWebWorker(workerUrl, files, process);
|
|
154
|
+
return function () {
|
|
155
|
+
worker.terminate();
|
|
156
|
+
};
|
|
157
|
+
}, []);
|
|
158
|
+
useEffect(function () { return function () {
|
|
159
|
+
listenersToReset.forEach(function (listener) { return listener(); });
|
|
160
|
+
}; }, [listenersToReset]);
|
|
161
|
+
return {
|
|
162
|
+
html: html,
|
|
163
|
+
visible: visible,
|
|
164
|
+
tooltip: tooltip,
|
|
165
|
+
customStyles: customStyles,
|
|
166
|
+
message: message,
|
|
167
|
+
onClosePopup: function () { return setMessage(''); }
|
|
168
|
+
};
|
|
169
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createRequestProvider, CustomScript } from '@reltio/mdm-sdk';
|
|
2
|
+
declare type InterceptHandlers = {
|
|
3
|
+
addInternalRequestInterceptor: ReturnType<typeof createRequestProvider>['addRequestInterceptor'];
|
|
4
|
+
addInternalResponseInterceptor: ReturnType<typeof createRequestProvider>['addResponseInterceptor'];
|
|
5
|
+
removeInternalRequestInterceptor: ReturnType<typeof createRequestProvider>['removeRequestInterceptor'];
|
|
6
|
+
removeInternalResponseInterceptor: ReturnType<typeof createRequestProvider>['removeResponseInterceptor'];
|
|
7
|
+
};
|
|
8
|
+
export declare const useCustomScripts: (config: CustomScript[], { addInternalRequestInterceptor, addInternalResponseInterceptor, removeInternalRequestInterceptor, removeInternalResponseInterceptor }: InterceptHandlers) => void;
|
|
9
|
+
export {};
|