@reltio/components 1.4.1173 → 1.4.1176

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 (45) hide show
  1. package/cjs/components/ModeSwitcherSelect/styles.d.ts +1 -1
  2. package/cjs/components/activityLog/ActivityFilterEditor/ActivityFilterEditor.js +16 -32
  3. package/cjs/components/activityLog/ActivityFilterEditor/ActivitySelector.js +5 -2
  4. package/cjs/components/activityLog/ActivityFilterEditor/DateRangeSelector.js +1 -1
  5. package/cjs/components/activityLog/ActivityFilterEditor/EntityChangedSelectors.d.ts +10 -0
  6. package/cjs/components/activityLog/ActivityFilterEditor/EntityChangedSelectors.js +27 -0
  7. package/cjs/components/activityLog/ActivityFilterEditor/EntityTypesSelector.d.ts +9 -0
  8. package/cjs/components/activityLog/ActivityFilterEditor/EntityTypesSelector.js +29 -0
  9. package/cjs/components/activityLog/ActivityFilterEditor/SourceSelector.js +1 -1
  10. package/cjs/components/activityLog/ActivityFilterEditor/styles.d.ts +1 -1
  11. package/cjs/components/activityLog/ActivityFilterEditor/styles.js +18 -7
  12. package/cjs/components/activityLog/ActivityLogFilter/helpers.js +4 -3
  13. package/cjs/components/activityLog/ActivityLogFilter/styles.js +2 -1
  14. package/cjs/components/activityLog/types/ActivitiesFilter.d.ts +2 -1
  15. package/cjs/components/activityLog/utils/filters.js +4 -0
  16. package/cjs/hooks/useAPI/API.d.ts +1 -1
  17. package/cjs/hooks/useAPI/API.js +105 -32
  18. package/cjs/hooks/useAPI/helpers.d.ts +1 -0
  19. package/cjs/hooks/useAPI/helpers.js +7 -3
  20. package/cjs/hooks/useAPI/types.d.ts +1 -0
  21. package/cjs/hooks/useAPI/useAPI.js +3 -1
  22. package/cjs/hooks/useCustomScripts.js +2 -0
  23. package/esm/components/ModeSwitcherSelect/styles.d.ts +1 -1
  24. package/esm/components/activityLog/ActivityFilterEditor/ActivityFilterEditor.js +16 -32
  25. package/esm/components/activityLog/ActivityFilterEditor/ActivitySelector.js +5 -2
  26. package/esm/components/activityLog/ActivityFilterEditor/DateRangeSelector.js +1 -1
  27. package/esm/components/activityLog/ActivityFilterEditor/EntityChangedSelectors.d.ts +10 -0
  28. package/esm/components/activityLog/ActivityFilterEditor/EntityChangedSelectors.js +22 -0
  29. package/esm/components/activityLog/ActivityFilterEditor/EntityTypesSelector.d.ts +9 -0
  30. package/esm/components/activityLog/ActivityFilterEditor/EntityTypesSelector.js +24 -0
  31. package/esm/components/activityLog/ActivityFilterEditor/SourceSelector.js +1 -1
  32. package/esm/components/activityLog/ActivityFilterEditor/styles.d.ts +1 -1
  33. package/esm/components/activityLog/ActivityFilterEditor/styles.js +18 -7
  34. package/esm/components/activityLog/ActivityLogFilter/helpers.js +5 -4
  35. package/esm/components/activityLog/ActivityLogFilter/styles.js +2 -1
  36. package/esm/components/activityLog/types/ActivitiesFilter.d.ts +2 -1
  37. package/esm/components/activityLog/utils/filters.js +4 -0
  38. package/esm/hooks/useAPI/API.d.ts +1 -1
  39. package/esm/hooks/useAPI/API.js +106 -33
  40. package/esm/hooks/useAPI/helpers.d.ts +1 -0
  41. package/esm/hooks/useAPI/helpers.js +5 -2
  42. package/esm/hooks/useAPI/types.d.ts +1 -0
  43. package/esm/hooks/useAPI/useAPI.js +3 -1
  44. package/esm/hooks/useCustomScripts.js +2 -0
  45. package/package.json +3 -3
@@ -1,58 +1,42 @@
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
1
  import React, { useState } from 'react';
2
+ import { curry, pipe, assoc, when, mergeLeft, always } from 'ramda';
13
3
  import { useSelector } from 'react-redux';
14
4
  import mdmModule from '@reltio/mdm-module';
15
5
  import i18n from 'ui-i18n';
16
- import classnames from 'classnames';
17
6
  import Button from '@material-ui/core/Button';
7
+ import Divider from '@material-ui/core/Divider';
18
8
  import { ActivityTypes } from '../types';
19
9
  import { getSelectorActivityTypes } from './utils/getSelectorActivityTypes';
20
10
  import ActivitySelector from './ActivitySelector';
21
- import AttributeSelector from '../../AttributeSelector/AttributeSelector';
22
- import SourceSelector from './SourceSelector';
23
11
  import UserSelector from '../../UserSelector/UserSelector';
24
12
  import DateRangeSelector from './DateRangeSelector';
13
+ import EntityChangedSelectors from './EntityChangedSelectors';
25
14
  import { useDidUpdateEffect } from '../../../hooks';
26
- import { curry, pipe } from 'ramda';
27
15
  import { useStyles } from './styles';
28
16
  var ActivityFilterEditor = function (_a) {
29
17
  var value = _a.value, open = _a.open, entityType = _a.entityType, onApply = _a.onApply, onCancel = _a.onCancel, onClear = _a.onClear;
30
18
  var styles = useStyles();
31
19
  var metadata = useSelector(mdmModule.selectors.getMetadata);
32
- var _b = useState(value), currentValue = _b[0], setCurrentValue = _b[1];
33
- var clearCurrentValue = function () { return setCurrentValue(null); };
20
+ var _b = useState(value), currentFilter = _b[0], setCurrentFilter = _b[1];
21
+ var clearCurrentFilter = function () { return setCurrentFilter(null); };
34
22
  var handlePropChange = curry(function (propName, value) {
35
- setCurrentValue(function (filterValue) {
36
- var _a;
37
- return (__assign(__assign({}, filterValue), (_a = {}, _a[propName] = value, _a)));
38
- });
23
+ setCurrentFilter(pipe(when(always(propName === 'entityTypes'), assoc('attributes', [])), when(always(propName === 'activities'), mergeLeft({ attributes: [], entityTypes: [], sources: [] })), assoc(propName, value)));
39
24
  });
40
25
  useDidUpdateEffect(function () {
41
- setCurrentValue(value);
26
+ setCurrentFilter(value);
42
27
  }, [value]);
43
- var _c = currentValue || {}, _d = _c.activities, activities = _d === void 0 ? [] : _d, _e = _c.attributes, attributes = _e === void 0 ? [] : _e, _f = _c.sources, sources = _f === void 0 ? [] : _f, _g = _c.dateRange, dateRange = _g === void 0 ? null : _g, _h = _c.users, users = _h === void 0 ? [] : _h;
44
- var hasEntityChanged = activities.includes(ActivityTypes.ENTITY_CHANGED);
45
- var ActivityFilterRenderer = (React.createElement(React.Fragment, null,
28
+ var _c = currentFilter || {}, _d = _c.activities, activities = _d === void 0 ? [] : _d, _e = _c.dateRange, dateRange = _e === void 0 ? null : _e, _f = _c.users, users = _f === void 0 ? [] : _f;
29
+ var isEntityChangedActivity = activities.length === 1 && activities.includes(ActivityTypes.ENTITY_CHANGED);
30
+ return open ? (React.createElement("div", { className: styles.container },
46
31
  React.createElement(ActivitySelector, { activityTypes: getSelectorActivityTypes(metadata, entityType), selectedActivityTypes: activities, onChange: handlePropChange('activities') }),
47
- hasEntityChanged && entityType && (React.createElement(React.Fragment, null,
48
- React.createElement(AttributeSelector, { selectedAttributes: attributes, entityType: entityType, onChange: handlePropChange('attributes'), className: styles.borderBottom, disableUnderline: true }),
49
- React.createElement(SourceSelector, { selectedSources: sources, onChange: handlePropChange('sources') }))),
32
+ isEntityChangedActivity && (React.createElement(EntityChangedSelectors, { filter: currentFilter, entityType: entityType, onPropChange: handlePropChange })),
33
+ React.createElement(Divider, { light: true, className: styles.divider }),
50
34
  React.createElement(DateRangeSelector, { value: dateRange, onChange: handlePropChange('dateRange') }),
35
+ React.createElement(Divider, { light: true, className: styles.divider }),
51
36
  React.createElement(UserSelector, { selectedUsers: users, onChange: handlePropChange('users'), disableUnderline: true }),
52
- React.createElement("div", { className: classnames(styles.borderBottom, styles.filterControls) },
53
- React.createElement(Button, { onClick: pipe(clearCurrentValue, onClear), className: styles.clearButton }, i18n.text('Clear all')),
37
+ React.createElement("div", { className: styles.filterControls },
38
+ React.createElement(Button, { onClick: pipe(clearCurrentFilter, onClear), className: styles.clearButton }, i18n.text('Clear all')),
54
39
  React.createElement(Button, { onClick: onCancel }, i18n.text('Cancel')),
55
- React.createElement(Button, { color: "primary", onClick: function () { return onApply(currentValue); } }, i18n.text('Apply')))));
56
- return open && React.createElement("div", { className: styles.container }, ActivityFilterRenderer);
40
+ React.createElement(Button, { color: "primary", onClick: function () { return onApply(currentFilter); } }, i18n.text('Apply'))))) : null;
57
41
  };
58
42
  export default ActivityFilterEditor;
@@ -3,6 +3,7 @@ import i18n from 'ui-i18n';
3
3
  import { defaultTo, pipe, pluck, sortBy } from 'ramda';
4
4
  import classnames from 'classnames';
5
5
  import Typography from '@material-ui/core/Typography';
6
+ import { ActivityTypes } from '../types/ActivityTypes';
6
7
  import MultiSelect from '../../ReactSelect/MultiSelect';
7
8
  import DropdownIndicatorWithIconButton from '../../commonReactSelectComponents/DropdownIndicatorWithIconButton';
8
9
  import { getActivityLabel } from '../utils/activities';
@@ -12,14 +13,16 @@ var ActivitySelector = function (_a) {
12
13
  var styles = useStyles();
13
14
  var valueToOption = function (value) { return ({ value: value, label: getActivityLabel(value) }); };
14
15
  var prepareValues = function (values) { return values.map(valueToOption); };
16
+ var showHint = selectedActivityTypes.length > 1 && selectedActivityTypes.includes(ActivityTypes.ENTITY_CHANGED);
15
17
  var options = pipe(sortBy(function (option) { return getActivityLabel(option); }), prepareValues)(activityTypes);
16
- return (React.createElement("div", { className: styles.borderBottom },
18
+ return (React.createElement("div", { className: styles.selectorWrapper },
17
19
  React.createElement(Typography, { className: classnames(styles.filterSubtitle, styles.labels), variant: 'subtitle1' }, i18n.text('Activity')),
18
20
  React.createElement(MultiSelect, { value: prepareValues(selectedActivityTypes), onChange: pipe(defaultTo([]), pluck('value'), onChange), options: options, TextFieldProps: {
19
21
  InputProps: { disableUnderline: true },
20
22
  classes: { root: styles.dropDownInput }
21
23
  }, components: {
22
24
  DropdownIndicator: DropdownIndicatorWithIconButton
23
- }, styles: customStyles, classes: styles, menuPlacement: "bottom" })));
25
+ }, styles: customStyles, classes: styles, menuPlacement: "bottom" }),
26
+ showHint && (React.createElement("span", { className: styles.selectorHint }, i18n.text('One at a time! Select a single Activity and any of its filters -OR- multiple Activities with no filters.')))));
24
27
  };
25
28
  export default ActivitySelector;
@@ -79,7 +79,7 @@ var DateRangeSelector = function (_a) {
79
79
  setAgoInterval(emptyInterval);
80
80
  }
81
81
  }, [value]);
82
- return (React.createElement("div", { className: styles.borderBottom },
82
+ return (React.createElement("div", { className: styles.selectorWrapper },
83
83
  React.createElement(Typography, { className: classnames(styles.filterSubtitle, styles.labels), variant: 'subtitle1' }, i18n.text('Date')),
84
84
  React.createElement(RadioGroup, { value: (value === null || value === void 0 ? void 0 : value.type) || null, onChange: pipe(getValue, changeType) },
85
85
  React.createElement("div", { className: styles.dateOptionWithin },
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { TEntityType } from '@reltio/mdm-sdk';
3
+ import { ActivitiesFilter } from '../types';
4
+ declare type Props = {
5
+ filter: ActivitiesFilter;
6
+ entityType?: TEntityType;
7
+ onPropChange: (propName: string) => (value: unknown) => void;
8
+ };
9
+ declare const EntityChangedSelectors: ({ filter, entityType, onPropChange }: Props) => JSX.Element;
10
+ export default EntityChangedSelectors;
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import { map, prop } from 'ramda';
3
+ import { useSelector } from 'react-redux';
4
+ import mdmModule from '@reltio/mdm-module';
5
+ import { findClosestCommonAncestor, getEntityType } from '@reltio/mdm-sdk';
6
+ import AttributeSelector from '../../AttributeSelector/AttributeSelector';
7
+ import EntityTypesSelector from './EntityTypesSelector';
8
+ import SourceSelector from './SourceSelector';
9
+ import { useStyles } from './styles';
10
+ var EntityChangedSelectors = function (_a) {
11
+ var filter = _a.filter, entityType = _a.entityType, onPropChange = _a.onPropChange;
12
+ var styles = useStyles();
13
+ var metadata = useSelector(mdmModule.selectors.getMetadata);
14
+ var _b = filter || {}, _c = _b.attributes, attributes = _c === void 0 ? [] : _c, _d = _b.sources, sources = _d === void 0 ? [] : _d, _e = _b.entityTypes, entityTypes = _e === void 0 ? [] : _e;
15
+ var closestEntityTypeAncestor = findClosestCommonAncestor(metadata, map(prop('uri'), entityTypes));
16
+ var attributesEntityType = entityType || getEntityType(metadata, closestEntityTypeAncestor);
17
+ return (React.createElement("div", { className: styles.selectorsGroup },
18
+ !entityType && (React.createElement(EntityTypesSelector, { entityTypes: metadata.entityTypes, selectedEntityTypes: entityTypes, onChange: onPropChange('entityTypes') })),
19
+ React.createElement(AttributeSelector, { selectedAttributes: attributes, entityType: attributesEntityType, onChange: onPropChange('attributes'), className: styles.selectorWrapper, disableUnderline: true }),
20
+ React.createElement(SourceSelector, { selectedSources: sources, onChange: onPropChange('sources') })));
21
+ };
22
+ export default EntityChangedSelectors;
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { TEntityType } from '@reltio/mdm-sdk';
3
+ declare type Props = {
4
+ entityTypes: TEntityType[];
5
+ selectedEntityTypes: TEntityType[];
6
+ onChange: (entityTypes: TEntityType[]) => void;
7
+ };
8
+ declare const EntityTypesSelector: ({ entityTypes, selectedEntityTypes, onChange }: Props) => JSX.Element;
9
+ export default EntityTypesSelector;
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import i18n from 'ui-i18n';
3
+ import { defaultTo, pipe, pluck, sortBy } from 'ramda';
4
+ import classnames from 'classnames';
5
+ import Typography from '@material-ui/core/Typography';
6
+ import MultiSelect from '../../ReactSelect/MultiSelect';
7
+ import DropdownIndicatorWithIconButton from '../../commonReactSelectComponents/DropdownIndicatorWithIconButton';
8
+ import { customStyles, useStyles } from './styles';
9
+ var EntityTypesSelector = function (_a) {
10
+ var entityTypes = _a.entityTypes, selectedEntityTypes = _a.selectedEntityTypes, onChange = _a.onChange;
11
+ var styles = useStyles();
12
+ var valueToOption = function (entityType) { return ({ value: entityType.uri, label: entityType.label, entityType: entityType }); };
13
+ var prepareValues = function (values) { return values.map(valueToOption); };
14
+ var options = pipe(sortBy(function (option) { return option.label; }), prepareValues)(entityTypes);
15
+ return (React.createElement("div", { className: styles.selectorWrapper },
16
+ React.createElement(Typography, { className: classnames(styles.filterSubtitle, styles.labels), variant: 'subtitle1' }, i18n.text('Type')),
17
+ React.createElement(MultiSelect, { value: prepareValues(selectedEntityTypes), onChange: pipe(defaultTo([]), pluck('entityType'), onChange), options: options, TextFieldProps: {
18
+ InputProps: { disableUnderline: true },
19
+ classes: { root: styles.dropDownInput }
20
+ }, components: {
21
+ DropdownIndicator: DropdownIndicatorWithIconButton
22
+ }, styles: customStyles, classes: styles, menuPlacement: "bottom" })));
23
+ };
24
+ export default EntityTypesSelector;
@@ -13,7 +13,7 @@ var SourceSelector = function (_a) {
13
13
  var styles = useStyles();
14
14
  var metadata = useSelector(mdmModule.selectors.getMetadata);
15
15
  var options = sortBy(function (option) { return option.label; })(metadata.sources);
16
- return (React.createElement("div", { className: styles.borderBottom },
16
+ return (React.createElement("div", { className: styles.selectorWrapper },
17
17
  React.createElement(Typography, { className: classnames(styles.filterSubtitle, styles.labels), variant: 'subtitle1' }, i18n.text('Source')),
18
18
  React.createElement(MultiSelect, { value: selectedSources, onChange: pipe(defaultTo([]), onChange), options: options, TextFieldProps: {
19
19
  InputProps: { disableUnderline: true },
@@ -1,4 +1,4 @@
1
1
  export declare const customStyles: {
2
2
  input: (currentStyles: any) => any;
3
3
  };
4
- export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"option" | "labels" | "borderBottom" | "container" | "filterSubtitle" | "agoLabel" | "dateOption" | "dateOptionAgo" | "dateOptionWithin" | "dateOptionLabel" | "dropDownInput" | "filterControls" | "clearButton">;
4
+ export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"option" | "labels" | "container" | "divider" | "filterSubtitle" | "agoLabel" | "dateOption" | "dateOptionAgo" | "dateOptionWithin" | "dateOptionLabel" | "dropDownInput" | "filterControls" | "clearButton" | "selectorWrapper" | "selectorsGroup" | "selectorHint">;
@@ -15,8 +15,8 @@ export var customStyles = {
15
15
  };
16
16
  export var useStyles = makeStyles({
17
17
  container: {
18
- padding: '24px 10px 0px',
19
- margin: '0 6px'
18
+ padding: '12px 7px 0px',
19
+ borderBottom: 'solid 1px rgba(0, 0, 0, 0.12)'
20
20
  },
21
21
  labels: {
22
22
  fontSize: '14px'
@@ -54,18 +54,29 @@ export var useStyles = makeStyles({
54
54
  },
55
55
  filterControls: {
56
56
  display: 'flex',
57
- paddingTop: '30px'
57
+ paddingTop: '30px',
58
+ marginBottom: 8
58
59
  },
59
60
  clearButton: {
60
61
  marginRight: 'auto'
61
62
  },
62
- borderBottom: {
63
- borderBottom: 'solid 1px rgba(0, 0, 0, 0.12)',
64
- paddingBottom: '10px',
65
- marginBottom: '15px'
63
+ selectorWrapper: {
64
+ marginBottom: '12px'
66
65
  },
67
66
  option: {
68
67
  fontSize: '14px',
69
68
  height: '32px'
69
+ },
70
+ selectorsGroup: {
71
+ display: 'flex',
72
+ flexDirection: 'column'
73
+ },
74
+ selectorHint: {
75
+ fontSize: 12,
76
+ lineHeight: '16px',
77
+ color: 'rgba(0,0,0,0.54)'
78
+ },
79
+ divider: {
80
+ marginBottom: 12
70
81
  }
71
82
  });
@@ -1,5 +1,5 @@
1
1
  import i18n from 'ui-i18n';
2
- import { curry, join, identity, isNil, map, pipe, reject, sortBy, defaultTo } from 'ramda';
2
+ import { curry, join, identity, isNil, map, pipe, reject, sortBy, defaultTo, pluck } from 'ramda';
3
3
  import { DataTypes, formatDataTypeValue } from '@reltio/mdm-sdk';
4
4
  import { DateRangeTypes } from '../../../types';
5
5
  import { getActivityLabel } from '../utils/activities';
@@ -11,8 +11,9 @@ export var getFilterLabel = function (filters) {
11
11
  });
12
12
  var activityLabel = pipe(map(getActivityLabel), getLabel(i18n.text('activity'), i18n.text('activities')))(filters.activities);
13
13
  var userLabel = getLabel(i18n.text('user'), i18n.text('users'), filters.users);
14
- var attributesLabel = pipe(defaultTo([]), map(function (attribute) { return attribute.label; }), sortBy(identity), getLabel(i18n.text('attribute'), i18n.text('attributes')))(filters.attributes);
15
- var sourcesLabel = pipe(defaultTo([]), map(function (source) { return source.label; }), getLabel(i18n.text('source'), i18n.text('sources')))(filters.sources);
14
+ var entityTypesLabel = pipe(defaultTo([]), pluck('label'), sortBy(identity), getLabel(i18n.text('type'), i18n.text('types')))(filters.entityTypes);
15
+ var attributesLabel = pipe(defaultTo([]), pluck('label'), sortBy(identity), getLabel(i18n.text('attribute'), i18n.text('attributes')))(filters.attributes);
16
+ var sourcesLabel = pipe(defaultTo([]), pluck('label'), getLabel(i18n.text('source'), i18n.text('sources')))(filters.sources);
16
17
  var getDateLabel = function (date) {
17
18
  var formatDateValue = function (value) {
18
19
  return "" + formatDataTypeValue({ dataTypeDefinition: { type: DataTypes.TYPE_ACTIVENESS_DATE } }, value);
@@ -31,5 +32,5 @@ export var getFilterLabel = function (filters) {
31
32
  return null;
32
33
  }
33
34
  };
34
- return pipe(reject(isNil), join(' | '))([activityLabel, attributesLabel, sourcesLabel, getDateLabel(filters.dateRange), userLabel]);
35
+ return pipe(reject(isNil), join(' | '))([activityLabel, entityTypesLabel, attributesLabel, sourcesLabel, getDateLabel(filters.dateRange), userLabel]);
35
36
  };
@@ -13,6 +13,7 @@ export var useStyles = makeStyles(function () { return ({
13
13
  margin: '4px'
14
14
  },
15
15
  buttonsWrapper: {
16
- marginLeft: 'auto'
16
+ marginLeft: 'auto',
17
+ display: 'flex'
17
18
  }
18
19
  }); });
@@ -1,4 +1,4 @@
1
- import { Source } from '@reltio/mdm-sdk';
1
+ import { Source, TEntityType } from '@reltio/mdm-sdk';
2
2
  import { ActivityTypes } from './ActivityTypes';
3
3
  import { AttributeOption, DateRangeFilter } from '../../../types';
4
4
  export declare type ActivitiesFilter = {
@@ -7,5 +7,6 @@ export declare type ActivitiesFilter = {
7
7
  dateRange: DateRangeFilter;
8
8
  attributes?: AttributeOption[];
9
9
  sources?: Source[];
10
+ entityTypes?: TEntityType[];
10
11
  entityUri?: string;
11
12
  };
@@ -16,6 +16,9 @@ var buildActivityFilterClause = function (activityType) {
16
16
  var buildSourceFilterClause = function (source) {
17
17
  return "equals(items.delta.sources, '" + source.abbreviation + "')";
18
18
  };
19
+ var buildEntityTypeFilterClause = function (entityType) {
20
+ return "equals(items.objectType, '" + entityType.uri + "')";
21
+ };
19
22
  var buildAttributeFilterClause = function (attribute) {
20
23
  return "equals(items.delta.attributeType, '" + attribute.value + "')";
21
24
  };
@@ -54,6 +57,7 @@ var getFilterClauseBuilder = cond([
54
57
  [equals('activities'), function () { return multiValueFilter(buildActivityFilterClause); }],
55
58
  [equals('sources'), function () { return multiValueFilter(buildSourceFilterClause); }],
56
59
  [equals('attributes'), function () { return multiValueFilter(buildAttributeFilterClause); }],
60
+ [equals('entityTypes'), function () { return multiValueFilter(buildEntityTypeFilterClause); }],
57
61
  [equals('dateRange'), function () { return buildDateRangeFilterClause; }],
58
62
  [equals('entityUri'), function () { return buildEntityUriFilterClause; }]
59
63
  ]);
@@ -1,2 +1,2 @@
1
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;
2
+ export declare const processRequest: ({ name, paramObject, permissions, worker, metadata, config, apiPath, servicesPath, user, workflowPath, entity, tenant, entityUri, query, openSearch, environment, getCurrentPerspectiveId, showPerspective, workflowCheckPermission, setEntityUri }: ProcessRequestParams) => void;
@@ -9,7 +9,44 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- import { RequestAction, sendRequestFromCustomSandbox, sendWorkflowRequest, startProcessFromQuery } from '@reltio/mdm-sdk';
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (_) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ import { getAccessToken, RequestAction, sendRequestFromCustomSandbox, sendWorkflowRequest, startProcessFromQuery } from '@reltio/mdm-sdk';
49
+ import { isNewUI } from './helpers';
13
50
  var processFromQuery = function (params, permissions, workflowPath, tenant, environment) {
14
51
  if (!params.processDefinitionId) {
15
52
  return new Promise(function (resolve) { return resolve({ errorMessage: 'processDefinitionId is empty' }); });
@@ -32,37 +69,69 @@ var processFromQuery = function (params, permissions, workflowPath, tenant, envi
32
69
  environment: environment
33
70
  });
34
71
  };
35
- var workflowRequest = function (params, permissions, workflowPath, tenant) {
36
- var url = params.url;
37
- var errors = validateParams(params, permissions);
38
- if (errors) {
39
- return new Promise(function (resolve) { return resolve(errors); });
40
- }
41
- var isExternalUrl = url.includes('http:') || url.includes('https:');
42
- if (!workflowPath && !isExternalUrl) {
43
- return new Promise(function (resolve) { return resolve({ errorMessage: 'Workflow path is not defined' }); });
44
- }
45
- return sendWorkflowRequest({
46
- url: url,
47
- method: params.method || 'GET',
48
- data: params.data,
49
- tenant: tenant,
50
- headers: params.headers,
51
- workflowPath: workflowPath
72
+ var getHeaders = function (params, signHandler) { return __awaiter(void 0, void 0, void 0, function () {
73
+ var accessToken;
74
+ return __generator(this, function (_a) {
75
+ switch (_a.label) {
76
+ case 0: return [4 /*yield*/, (signHandler === null || signHandler === void 0 ? void 0 : signHandler())];
77
+ case 1:
78
+ accessToken = (_a.sent()).accessToken;
79
+ return [2 /*return*/, accessToken
80
+ ? __assign(__assign({}, params.headers), { Authorization: "Bearer " + accessToken }) : params.headers];
81
+ }
52
82
  });
53
- };
54
- var sendApiRequest = function (params, permissions) {
55
- var errors = validateParams(params, permissions);
56
- if (errors) {
57
- return new Promise(function (resolve) { return resolve(errors); });
58
- }
59
- return sendRequestFromCustomSandbox({
60
- url: params.url,
61
- method: params.method,
62
- data: params.data,
63
- headers: params.headers
83
+ }); };
84
+ var workflowRequest = function (params, permissions, workflowPath, tenant, signHandler) { return __awaiter(void 0, void 0, void 0, function () {
85
+ var url, errors, isExternalUrl, headers;
86
+ return __generator(this, function (_a) {
87
+ switch (_a.label) {
88
+ case 0:
89
+ url = params.url;
90
+ errors = validateParams(params, permissions);
91
+ if (errors) {
92
+ return [2 /*return*/, errors];
93
+ }
94
+ isExternalUrl = url.includes('http:') || url.includes('https:');
95
+ if (!workflowPath && !isExternalUrl) {
96
+ return [2 /*return*/, { errorMessage: 'Workflow path is not defined' }];
97
+ }
98
+ return [4 /*yield*/, getHeaders(params, signHandler)];
99
+ case 1:
100
+ headers = _a.sent();
101
+ return [4 /*yield*/, sendWorkflowRequest({
102
+ url: url,
103
+ method: params.method || 'GET',
104
+ data: params.data,
105
+ tenant: tenant,
106
+ headers: headers,
107
+ workflowPath: workflowPath
108
+ })];
109
+ case 2: return [2 /*return*/, _a.sent()];
110
+ }
64
111
  });
65
- };
112
+ }); };
113
+ var sendApiRequest = function (params, permissions, signHandler) { return __awaiter(void 0, void 0, void 0, function () {
114
+ var errors, headers;
115
+ return __generator(this, function (_a) {
116
+ switch (_a.label) {
117
+ case 0:
118
+ errors = validateParams(params, permissions);
119
+ if (errors) {
120
+ return [2 /*return*/, errors];
121
+ }
122
+ return [4 /*yield*/, getHeaders(params, signHandler)];
123
+ case 1:
124
+ headers = _a.sent();
125
+ return [4 /*yield*/, sendRequestFromCustomSandbox({
126
+ url: params.url,
127
+ method: params.method,
128
+ data: params.data,
129
+ headers: headers
130
+ })];
131
+ case 2: return [2 /*return*/, _a.sent()];
132
+ }
133
+ });
134
+ }); };
66
135
  var validateParams = function (params, permissions) {
67
136
  var url = params.url;
68
137
  if (!url)
@@ -86,7 +155,7 @@ var validateParams = function (params, permissions) {
86
155
  return false;
87
156
  };
88
157
  export var processRequest = function (_a) {
89
- 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;
158
+ var name = _a.name, paramObject = _a.paramObject, permissions = _a.permissions, worker = _a.worker, metadata = _a.metadata, config = _a.config, apiPath = _a.apiPath, servicesPath = _a.servicesPath, user = _a.user, workflowPath = _a.workflowPath, entity = _a.entity, tenant = _a.tenant, entityUri = _a.entityUri, query = _a.query, openSearch = _a.openSearch, environment = _a.environment, getCurrentPerspectiveId = _a.getCurrentPerspectiveId, showPerspective = _a.showPerspective, workflowCheckPermission = _a.workflowCheckPermission, setEntityUri = _a.setEntityUri;
90
159
  var handleRequest = function (request) {
91
160
  request
92
161
  .then(function (data) {
@@ -96,14 +165,18 @@ export var processRequest = function (_a) {
96
165
  worker.postMessage(__assign({ action: 'response', result: { data: {}, headers: '', status: 0 } }, paramObject.params));
97
166
  });
98
167
  };
168
+ var shouldSignRequest = isNewUI(servicesPath);
169
+ var signHandler = shouldSignRequest
170
+ ? function () { return getAccessToken({ servicesPath: servicesPath }); }
171
+ : function () { return Promise.resolve({ accessToken: '' }); };
99
172
  switch (name) {
100
173
  case RequestAction.API: {
101
- var request = sendApiRequest(paramObject.params, permissions);
174
+ var request = sendApiRequest(paramObject.params, permissions, signHandler);
102
175
  handleRequest(request);
103
176
  break;
104
177
  }
105
178
  case RequestAction.WORKFLOW: {
106
- var request = workflowRequest(paramObject.params, permissions, workflowPath, tenant);
179
+ var request = workflowRequest(paramObject.params, permissions, workflowPath, tenant, signHandler);
107
180
  handleRequest(request);
108
181
  break;
109
182
  }
@@ -1,2 +1,3 @@
1
+ export declare const isNewUI: (path?: string) => boolean;
1
2
  export declare const getWorkerURL: (uiPath: string, tenant: string) => string;
2
3
  export declare const getFullApiPath: (apiPath: string) => string;
@@ -1,5 +1,8 @@
1
+ export var isNewUI = function (path) {
2
+ return path === null || path === void 0 ? void 0 : path.includes('/nui');
3
+ };
1
4
  export var getWorkerURL = function (uiPath, tenant) {
2
- if (uiPath === null || uiPath === void 0 ? void 0 : uiPath.includes('nui')) {
5
+ if (isNewUI(uiPath)) {
3
6
  return uiPath.replace(tenant + "/", '') + "worker_api.js";
4
7
  }
5
8
  else {
@@ -7,7 +10,7 @@ export var getWorkerURL = function (uiPath, tenant) {
7
10
  }
8
11
  };
9
12
  export var getFullApiPath = function (apiPath) {
10
- if (apiPath === null || apiPath === void 0 ? void 0 : apiPath.includes('nui')) {
13
+ if (isNewUI(apiPath)) {
11
14
  return "" + window.location.origin + apiPath;
12
15
  }
13
16
  else {
@@ -16,6 +16,7 @@ export declare type ProcessRequestParams = {
16
16
  environment: string;
17
17
  entity: any;
18
18
  tenant: any;
19
+ servicesPath: string;
19
20
  entityUri: string;
20
21
  query: any;
21
22
  openSearch: (search: any) => void;
@@ -34,6 +34,7 @@ export var useAPI = function (config) {
34
34
  var apiPath = useSelector(mdmModule.selectors.getApiPath);
35
35
  var workflowPath = useSelector(mdmModule.selectors.getWorkflowPath);
36
36
  var user = useSelector(mdmModule.selectors.getUser);
37
+ var servicesPath = useSelector(mdmModule.selectors.getServicesPath);
37
38
  var entityUri = useSelector(mdmModule.selectors.getEntityUri);
38
39
  var environment = useSelector(mdmModule.selectors.getWorkflowEnvironmentUrl);
39
40
  var qxApi = useContext(SandboxAPIContext);
@@ -143,7 +144,8 @@ export var useAPI = function (config) {
143
144
  }
144
145
  case CustomAction.REQUEST: {
145
146
  processRequest(__assign({ name: task.params.name, paramObject: task, permissions: config.action.permissions, worker: worker,
146
- metadata: metadata, config: config, user: user, apiPath: getFullApiPath(apiPath), tenant: tenant,
147
+ metadata: metadata, config: config, user: user,
148
+ servicesPath: servicesPath, apiPath: getFullApiPath(apiPath), tenant: tenant,
147
149
  workflowPath: workflowPath,
148
150
  entity: entity,
149
151
  entityUri: entityUri,
@@ -57,6 +57,7 @@ export var useCustomScripts = function (config, _a) {
57
57
  var metadata = useSelector(mdmModule.selectors.getMetadata) || {};
58
58
  var entity = useSelector(mdmModule.selectors.getEntity) || {};
59
59
  var uiPath = useSelector(mdmModule.selectors.getUIPath);
60
+ var servicesPath = useSelector(mdmModule.selectors.getServicesPath);
60
61
  var reltioPath = useSelector(mdmModule.selectors.getReltioPath);
61
62
  var tenant = useSelector(mdmModule.selectors.getTenant);
62
63
  var workerUrl = getWorkerURL(uiPath, tenant);
@@ -92,6 +93,7 @@ export var useCustomScripts = function (config, _a) {
92
93
  config: config,
93
94
  user: user,
94
95
  apiPath: apiPath,
96
+ servicesPath: servicesPath,
95
97
  tenant: tenant,
96
98
  workflowPath: workflowPath,
97
99
  entity: entity,
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.1173",
3
+ "version": "1.4.1176",
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.1173",
11
- "@reltio/mdm-sdk": "^1.4.1173",
10
+ "@reltio/mdm-module": "^1.4.1176",
11
+ "@reltio/mdm-sdk": "^1.4.1176",
12
12
  "classnames": "^2.2.5",
13
13
  "d3-cloud": "^1.2.5",
14
14
  "d3-geo": "^2.0.1",