@reltio/components 1.4.1985 → 1.4.1986

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,5 +1,5 @@
1
1
  import React from 'react';
2
- import { TEntityType, MatchRulesAttrNames } from '@reltio/mdm-sdk';
2
+ import { MatchRulesAttrNames } from '@reltio/mdm-sdk';
3
3
  import { TextFieldProps as TextFieldPropsType } from '@mui/material/TextField';
4
4
  type Props = {
5
5
  name: MatchRulesAttrNames;
@@ -7,7 +7,7 @@ type Props = {
7
7
  onChange: (values: string[]) => void;
8
8
  TextFieldProps?: Partial<TextFieldPropsType>;
9
9
  fullWidth?: boolean;
10
- entityType: TEntityType;
10
+ entityTypeUris?: string[];
11
11
  };
12
- export declare const MatchRulesSelector: ({ name, values, onChange, entityType, TextFieldProps, fullWidth }: Props) => React.JSX.Element;
12
+ export declare const MatchRulesSelector: ({ name, values, onChange, entityTypeUris, TextFieldProps, fullWidth }: Props) => React.JSX.Element;
13
13
  export {};
@@ -36,9 +36,16 @@ var prepareOptions = function (options) {
36
36
  });
37
37
  };
38
38
  var MatchRulesSelector = function (_a) {
39
- var name = _a.name, values = _a.values, onChange = _a.onChange, entityType = _a.entityType, TextFieldProps = _a.TextFieldProps, fullWidth = _a.fullWidth;
39
+ var name = _a.name, values = _a.values, onChange = _a.onChange, entityTypeUris = _a.entityTypeUris, TextFieldProps = _a.TextFieldProps, fullWidth = _a.fullWidth;
40
40
  var metadata = (0, MdmModuleContext_1.useMdmMetadata)();
41
- var _b = (0, react_1.useMemo)(function () { return (0, mdm_sdk_1.partitionByMlMatch)((0, mdm_sdk_1.getMatchGroups)(metadata, entityType === null || entityType === void 0 ? void 0 : entityType.uri)); }, [entityType === null || entityType === void 0 ? void 0 : entityType.uri, metadata]), mlMatchRules = _b[0], matchRules = _b[1];
41
+ var _b = (0, react_1.useMemo)(function () {
42
+ var allEntityTypeUris = metadata.entityTypes.filter(mdm_sdk_1.isAvailableEntityType).map(function (_a) {
43
+ var uri = _a.uri;
44
+ return uri;
45
+ });
46
+ var displayedEntityTypeUris = entityTypeUris.length ? entityTypeUris : allEntityTypeUris;
47
+ return (0, mdm_sdk_1.partitionByMlMatch)(displayedEntityTypeUris.flatMap(function (entityTypeUri) { return (0, mdm_sdk_1.getMatchGroups)(metadata, entityTypeUri); }));
48
+ }, [entityTypeUris, metadata]), mlMatchRules = _b[0], matchRules = _b[1];
42
49
  var options = (0, react_1.useMemo)(function () { return prepareOptions(name === mdm_sdk_1.MatchRulesAttrNames.matchRules ? matchRules : mlMatchRules); }, [name, matchRules, mlMatchRules]);
43
50
  return (react_1.default.createElement(MultiValueSelector_1.MultiValueSelector, { values: values, onChange: onChange, options: options, TextFieldProps: TextFieldProps, fullWidth: fullWidth }));
44
51
  };
@@ -56,39 +56,66 @@ var user_event_1 = __importDefault(require("@testing-library/user-event"));
56
56
  var mdm_sdk_1 = require("@reltio/mdm-sdk");
57
57
  var MatchRulesSelector_1 = require("./MatchRulesSelector");
58
58
  var MdmModuleContext_1 = require("../contexts/MdmModuleContext");
59
- var matchGroups = [
60
- {
61
- label: 'matchRule1',
62
- uri: 'configuration/entityTypes/HCA/matchGroups/HCAByUWI'
63
- },
64
- {
65
- label: 'MLmatchRule1',
66
- uri: 'configuration/entityTypes/HCA/matchGroups/HCAMLMatchGroup',
67
- scope: 'INTERNAL',
68
- matchMethod: 'match_iq'
69
- },
70
- {
71
- label: 'matchRule2',
72
- uri: 'configuration/entityTypes/HCA/matchGroups/HCABytsv'
73
- },
74
- {
75
- label: 'MLmatchRule2',
76
- uri: 'configuration/entityTypes/HCА/matchGroups/HCPSameName',
77
- scope: 'ALL',
78
- matchMethod: 'match_iq'
79
- }
80
- ];
81
59
  var metadata = {
82
- entityTypes: [{ uri: 'configuration/entityTypes/HCA', label: 'HCA', matchGroups: matchGroups }]
60
+ entityTypes: [
61
+ {
62
+ uri: 'configuration/entityTypes/HCA',
63
+ label: 'HCA',
64
+ matchGroups: [
65
+ {
66
+ label: 'HCA Match Rule 1',
67
+ uri: 'configuration/entityTypes/HCA/matchGroups/HCAByUWI'
68
+ },
69
+ {
70
+ label: 'HCA ML Match Rule 1',
71
+ uri: 'configuration/entityTypes/HCA/matchGroups/HCAMLMatchGroup',
72
+ scope: 'INTERNAL',
73
+ matchMethod: 'match_iq'
74
+ },
75
+ {
76
+ label: 'HCA Match Rule 2',
77
+ uri: 'configuration/entityTypes/HCA/matchGroups/HCABytsv'
78
+ },
79
+ {
80
+ label: 'HCA ML Match Rule 2',
81
+ uri: 'configuration/entityTypes/HCА/matchGroups/HCPSameName',
82
+ scope: 'ALL',
83
+ matchMethod: 'match_iq'
84
+ }
85
+ ]
86
+ },
87
+ {
88
+ uri: 'configuration/entityTypes/HCP',
89
+ label: 'HCP',
90
+ matchGroups: [
91
+ {
92
+ label: 'HCP Match Rule 1',
93
+ uri: 'configuration/entityTypes/HCP/matchGroups/HCPMatchRule'
94
+ }
95
+ ]
96
+ },
97
+ {
98
+ uri: 'configuration/entityTypes/Individual',
99
+ label: 'Individual',
100
+ matchGroups: [
101
+ {
102
+ label: 'Individual Match Rule 1',
103
+ uri: 'configuration/entityTypes/Individual/matchGroups/IndividualMatchRule'
104
+ },
105
+ {
106
+ label: 'Individual ML Match Rule 1',
107
+ uri: 'configuration/entityTypes/Individual/matchGroups/IndividualMLMatchRule',
108
+ scope: 'INTERNAL',
109
+ matchMethod: 'match_iq'
110
+ }
111
+ ]
112
+ }
113
+ ]
83
114
  };
84
115
  var defaultProps = {
85
116
  onChange: jest.fn(),
86
117
  name: mdm_sdk_1.MatchRulesAttrNames.matchRules,
87
- entityType: {
88
- uri: 'configuration/entityTypes/HCA',
89
- label: 'HCA',
90
- attributes: []
91
- }
118
+ entityTypeUris: ['configuration/entityTypes/HCA']
92
119
  };
93
120
  var setUp = function (props) {
94
121
  if (props === void 0) { props = defaultProps; }
@@ -100,6 +127,23 @@ var setUp = function (props) {
100
127
  return __assign(__assign({}, (0, react_2.render)(react_1.default.createElement(MatchRulesSelector_1.MatchRulesSelector, __assign({}, props)), { wrapper: Providers })), { user: user });
101
128
  };
102
129
  describe('MatchRulesSelector tests', function () {
130
+ it('should show rules for several entity types correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
131
+ var props, user;
132
+ return __generator(this, function (_a) {
133
+ switch (_a.label) {
134
+ case 0:
135
+ props = __assign(__assign({}, defaultProps), { entityTypeUris: ['configuration/entityTypes/HCP', 'configuration/entityTypes/Individual'] });
136
+ user = setUp(props).user;
137
+ return [4 /*yield*/, user.click(react_2.screen.getByRole('combobox'))];
138
+ case 1:
139
+ _a.sent();
140
+ expect(react_2.screen.getAllByRole('option')).toHaveLength(2);
141
+ react_2.screen.getByText('HCP Match Rule 1');
142
+ react_2.screen.getByText('Individual Match Rule 1');
143
+ return [2 /*return*/];
144
+ }
145
+ });
146
+ }); });
103
147
  it('should show match rules as options correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
104
148
  var user;
105
149
  return __generator(this, function (_a) {
@@ -110,8 +154,27 @@ describe('MatchRulesSelector tests', function () {
110
154
  case 1:
111
155
  _a.sent();
112
156
  expect(react_2.screen.getAllByRole('option')).toHaveLength(2);
113
- react_2.screen.getByText('matchRule1');
114
- react_2.screen.getByText('matchRule2');
157
+ react_2.screen.getByText('HCA Match Rule 1');
158
+ react_2.screen.getByText('HCA Match Rule 2');
159
+ return [2 /*return*/];
160
+ }
161
+ });
162
+ }); });
163
+ it('should show match rules as options correctly if entityTypeUris prop is empty array', function () { return __awaiter(void 0, void 0, void 0, function () {
164
+ var props, user;
165
+ return __generator(this, function (_a) {
166
+ switch (_a.label) {
167
+ case 0:
168
+ props = __assign(__assign({}, defaultProps), { entityTypeUris: [] });
169
+ user = setUp(props).user;
170
+ return [4 /*yield*/, user.click(react_2.screen.getByRole('combobox'))];
171
+ case 1:
172
+ _a.sent();
173
+ expect(react_2.screen.getAllByRole('option')).toHaveLength(4);
174
+ react_2.screen.getByText('HCA Match Rule 1');
175
+ react_2.screen.getByText('HCA Match Rule 2');
176
+ react_2.screen.getByText('HCP Match Rule 1');
177
+ react_2.screen.getByText('Individual Match Rule 1');
115
178
  return [2 /*return*/];
116
179
  }
117
180
  });
@@ -127,8 +190,26 @@ describe('MatchRulesSelector tests', function () {
127
190
  case 1:
128
191
  _a.sent();
129
192
  expect(react_2.screen.getAllByRole('option')).toHaveLength(2);
130
- react_2.screen.getByText('MLmatchRule1');
131
- react_2.screen.getByText('MLmatchRule2');
193
+ react_2.screen.getByText('HCA ML Match Rule 1');
194
+ react_2.screen.getByText('HCA ML Match Rule 2');
195
+ return [2 /*return*/];
196
+ }
197
+ });
198
+ }); });
199
+ it('should show ml match rules as options correctly if entityTypeUris prop is empty array', function () { return __awaiter(void 0, void 0, void 0, function () {
200
+ var props, user;
201
+ return __generator(this, function (_a) {
202
+ switch (_a.label) {
203
+ case 0:
204
+ props = __assign(__assign({}, defaultProps), { name: mdm_sdk_1.MatchRulesAttrNames.MLRecommendedMatch, entityTypeUris: [] });
205
+ user = setUp(props).user;
206
+ return [4 /*yield*/, user.click(react_2.screen.getByRole('combobox'))];
207
+ case 1:
208
+ _a.sent();
209
+ expect(react_2.screen.getAllByRole('option')).toHaveLength(3);
210
+ react_2.screen.getByText('HCA ML Match Rule 1');
211
+ react_2.screen.getByText('HCA ML Match Rule 2');
212
+ react_2.screen.getByText('Individual ML Match Rule 1');
132
213
  return [2 /*return*/];
133
214
  }
134
215
  });
@@ -138,7 +219,7 @@ describe('MatchRulesSelector tests', function () {
138
219
  return __generator(this, function (_a) {
139
220
  props = __assign(__assign({}, defaultProps), { values: ['configuration/entityTypes/HCA/matchGroups/HCABytsv'] });
140
221
  setUp(props);
141
- react_2.screen.getByText('matchRule2');
222
+ react_2.screen.getByText('HCA Match Rule 2');
142
223
  return [2 /*return*/];
143
224
  });
144
225
  }); });
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { TEntityType, MatchRulesAttrNames } from '@reltio/mdm-sdk';
2
+ import { MatchRulesAttrNames } from '@reltio/mdm-sdk';
3
3
  import { TextFieldProps as TextFieldPropsType } from '@mui/material/TextField';
4
4
  type Props = {
5
5
  name: MatchRulesAttrNames;
@@ -7,7 +7,7 @@ type Props = {
7
7
  onChange: (values: string[]) => void;
8
8
  TextFieldProps?: Partial<TextFieldPropsType>;
9
9
  fullWidth?: boolean;
10
- entityType: TEntityType;
10
+ entityTypeUris?: string[];
11
11
  };
12
- export declare const MatchRulesSelector: ({ name, values, onChange, entityType, TextFieldProps, fullWidth }: Props) => React.JSX.Element;
12
+ export declare const MatchRulesSelector: ({ name, values, onChange, entityTypeUris, TextFieldProps, fullWidth }: Props) => React.JSX.Element;
13
13
  export {};
@@ -1,5 +1,5 @@
1
1
  import React, { useMemo } from 'react';
2
- import { getMatchGroups, partitionByMlMatch, MatchRulesAttrNames } from '@reltio/mdm-sdk';
2
+ import { getMatchGroups, partitionByMlMatch, MatchRulesAttrNames, isAvailableEntityType } from '@reltio/mdm-sdk';
3
3
  import { MultiValueSelector } from '../MultiValueSelector';
4
4
  import { useMdmMetadata } from '../contexts/MdmModuleContext';
5
5
  var prepareOptions = function (options) {
@@ -10,9 +10,16 @@ var prepareOptions = function (options) {
10
10
  });
11
11
  };
12
12
  export var MatchRulesSelector = function (_a) {
13
- var name = _a.name, values = _a.values, onChange = _a.onChange, entityType = _a.entityType, TextFieldProps = _a.TextFieldProps, fullWidth = _a.fullWidth;
13
+ var name = _a.name, values = _a.values, onChange = _a.onChange, entityTypeUris = _a.entityTypeUris, TextFieldProps = _a.TextFieldProps, fullWidth = _a.fullWidth;
14
14
  var metadata = useMdmMetadata();
15
- var _b = useMemo(function () { return partitionByMlMatch(getMatchGroups(metadata, entityType === null || entityType === void 0 ? void 0 : entityType.uri)); }, [entityType === null || entityType === void 0 ? void 0 : entityType.uri, metadata]), mlMatchRules = _b[0], matchRules = _b[1];
15
+ var _b = useMemo(function () {
16
+ var allEntityTypeUris = metadata.entityTypes.filter(isAvailableEntityType).map(function (_a) {
17
+ var uri = _a.uri;
18
+ return uri;
19
+ });
20
+ var displayedEntityTypeUris = entityTypeUris.length ? entityTypeUris : allEntityTypeUris;
21
+ return partitionByMlMatch(displayedEntityTypeUris.flatMap(function (entityTypeUri) { return getMatchGroups(metadata, entityTypeUri); }));
22
+ }, [entityTypeUris, metadata]), mlMatchRules = _b[0], matchRules = _b[1];
16
23
  var options = useMemo(function () { return prepareOptions(name === MatchRulesAttrNames.matchRules ? matchRules : mlMatchRules); }, [name, matchRules, mlMatchRules]);
17
24
  return (React.createElement(MultiValueSelector, { values: values, onChange: onChange, options: options, TextFieldProps: TextFieldProps, fullWidth: fullWidth }));
18
25
  };
@@ -51,39 +51,66 @@ import userEvent from '@testing-library/user-event';
51
51
  import { MatchRulesAttrNames } from '@reltio/mdm-sdk';
52
52
  import { MatchRulesSelector } from './MatchRulesSelector';
53
53
  import { MdmModuleProvider } from '../contexts/MdmModuleContext';
54
- var matchGroups = [
55
- {
56
- label: 'matchRule1',
57
- uri: 'configuration/entityTypes/HCA/matchGroups/HCAByUWI'
58
- },
59
- {
60
- label: 'MLmatchRule1',
61
- uri: 'configuration/entityTypes/HCA/matchGroups/HCAMLMatchGroup',
62
- scope: 'INTERNAL',
63
- matchMethod: 'match_iq'
64
- },
65
- {
66
- label: 'matchRule2',
67
- uri: 'configuration/entityTypes/HCA/matchGroups/HCABytsv'
68
- },
69
- {
70
- label: 'MLmatchRule2',
71
- uri: 'configuration/entityTypes/HCА/matchGroups/HCPSameName',
72
- scope: 'ALL',
73
- matchMethod: 'match_iq'
74
- }
75
- ];
76
54
  var metadata = {
77
- entityTypes: [{ uri: 'configuration/entityTypes/HCA', label: 'HCA', matchGroups: matchGroups }]
55
+ entityTypes: [
56
+ {
57
+ uri: 'configuration/entityTypes/HCA',
58
+ label: 'HCA',
59
+ matchGroups: [
60
+ {
61
+ label: 'HCA Match Rule 1',
62
+ uri: 'configuration/entityTypes/HCA/matchGroups/HCAByUWI'
63
+ },
64
+ {
65
+ label: 'HCA ML Match Rule 1',
66
+ uri: 'configuration/entityTypes/HCA/matchGroups/HCAMLMatchGroup',
67
+ scope: 'INTERNAL',
68
+ matchMethod: 'match_iq'
69
+ },
70
+ {
71
+ label: 'HCA Match Rule 2',
72
+ uri: 'configuration/entityTypes/HCA/matchGroups/HCABytsv'
73
+ },
74
+ {
75
+ label: 'HCA ML Match Rule 2',
76
+ uri: 'configuration/entityTypes/HCА/matchGroups/HCPSameName',
77
+ scope: 'ALL',
78
+ matchMethod: 'match_iq'
79
+ }
80
+ ]
81
+ },
82
+ {
83
+ uri: 'configuration/entityTypes/HCP',
84
+ label: 'HCP',
85
+ matchGroups: [
86
+ {
87
+ label: 'HCP Match Rule 1',
88
+ uri: 'configuration/entityTypes/HCP/matchGroups/HCPMatchRule'
89
+ }
90
+ ]
91
+ },
92
+ {
93
+ uri: 'configuration/entityTypes/Individual',
94
+ label: 'Individual',
95
+ matchGroups: [
96
+ {
97
+ label: 'Individual Match Rule 1',
98
+ uri: 'configuration/entityTypes/Individual/matchGroups/IndividualMatchRule'
99
+ },
100
+ {
101
+ label: 'Individual ML Match Rule 1',
102
+ uri: 'configuration/entityTypes/Individual/matchGroups/IndividualMLMatchRule',
103
+ scope: 'INTERNAL',
104
+ matchMethod: 'match_iq'
105
+ }
106
+ ]
107
+ }
108
+ ]
78
109
  };
79
110
  var defaultProps = {
80
111
  onChange: jest.fn(),
81
112
  name: MatchRulesAttrNames.matchRules,
82
- entityType: {
83
- uri: 'configuration/entityTypes/HCA',
84
- label: 'HCA',
85
- attributes: []
86
- }
113
+ entityTypeUris: ['configuration/entityTypes/HCA']
87
114
  };
88
115
  var setUp = function (props) {
89
116
  if (props === void 0) { props = defaultProps; }
@@ -95,6 +122,23 @@ var setUp = function (props) {
95
122
  return __assign(__assign({}, render(React.createElement(MatchRulesSelector, __assign({}, props)), { wrapper: Providers })), { user: user });
96
123
  };
97
124
  describe('MatchRulesSelector tests', function () {
125
+ it('should show rules for several entity types correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
126
+ var props, user;
127
+ return __generator(this, function (_a) {
128
+ switch (_a.label) {
129
+ case 0:
130
+ props = __assign(__assign({}, defaultProps), { entityTypeUris: ['configuration/entityTypes/HCP', 'configuration/entityTypes/Individual'] });
131
+ user = setUp(props).user;
132
+ return [4 /*yield*/, user.click(screen.getByRole('combobox'))];
133
+ case 1:
134
+ _a.sent();
135
+ expect(screen.getAllByRole('option')).toHaveLength(2);
136
+ screen.getByText('HCP Match Rule 1');
137
+ screen.getByText('Individual Match Rule 1');
138
+ return [2 /*return*/];
139
+ }
140
+ });
141
+ }); });
98
142
  it('should show match rules as options correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
99
143
  var user;
100
144
  return __generator(this, function (_a) {
@@ -105,8 +149,27 @@ describe('MatchRulesSelector tests', function () {
105
149
  case 1:
106
150
  _a.sent();
107
151
  expect(screen.getAllByRole('option')).toHaveLength(2);
108
- screen.getByText('matchRule1');
109
- screen.getByText('matchRule2');
152
+ screen.getByText('HCA Match Rule 1');
153
+ screen.getByText('HCA Match Rule 2');
154
+ return [2 /*return*/];
155
+ }
156
+ });
157
+ }); });
158
+ it('should show match rules as options correctly if entityTypeUris prop is empty array', function () { return __awaiter(void 0, void 0, void 0, function () {
159
+ var props, user;
160
+ return __generator(this, function (_a) {
161
+ switch (_a.label) {
162
+ case 0:
163
+ props = __assign(__assign({}, defaultProps), { entityTypeUris: [] });
164
+ user = setUp(props).user;
165
+ return [4 /*yield*/, user.click(screen.getByRole('combobox'))];
166
+ case 1:
167
+ _a.sent();
168
+ expect(screen.getAllByRole('option')).toHaveLength(4);
169
+ screen.getByText('HCA Match Rule 1');
170
+ screen.getByText('HCA Match Rule 2');
171
+ screen.getByText('HCP Match Rule 1');
172
+ screen.getByText('Individual Match Rule 1');
110
173
  return [2 /*return*/];
111
174
  }
112
175
  });
@@ -122,8 +185,26 @@ describe('MatchRulesSelector tests', function () {
122
185
  case 1:
123
186
  _a.sent();
124
187
  expect(screen.getAllByRole('option')).toHaveLength(2);
125
- screen.getByText('MLmatchRule1');
126
- screen.getByText('MLmatchRule2');
188
+ screen.getByText('HCA ML Match Rule 1');
189
+ screen.getByText('HCA ML Match Rule 2');
190
+ return [2 /*return*/];
191
+ }
192
+ });
193
+ }); });
194
+ it('should show ml match rules as options correctly if entityTypeUris prop is empty array', function () { return __awaiter(void 0, void 0, void 0, function () {
195
+ var props, user;
196
+ return __generator(this, function (_a) {
197
+ switch (_a.label) {
198
+ case 0:
199
+ props = __assign(__assign({}, defaultProps), { name: MatchRulesAttrNames.MLRecommendedMatch, entityTypeUris: [] });
200
+ user = setUp(props).user;
201
+ return [4 /*yield*/, user.click(screen.getByRole('combobox'))];
202
+ case 1:
203
+ _a.sent();
204
+ expect(screen.getAllByRole('option')).toHaveLength(3);
205
+ screen.getByText('HCA ML Match Rule 1');
206
+ screen.getByText('HCA ML Match Rule 2');
207
+ screen.getByText('Individual ML Match Rule 1');
127
208
  return [2 /*return*/];
128
209
  }
129
210
  });
@@ -133,7 +214,7 @@ describe('MatchRulesSelector tests', function () {
133
214
  return __generator(this, function (_a) {
134
215
  props = __assign(__assign({}, defaultProps), { values: ['configuration/entityTypes/HCA/matchGroups/HCABytsv'] });
135
216
  setUp(props);
136
- screen.getByText('matchRule2');
217
+ screen.getByText('HCA Match Rule 2');
137
218
  return [2 /*return*/];
138
219
  });
139
220
  }); });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.1985",
3
+ "version": "1.4.1986",
4
4
  "license": "SEE LICENSE IN LICENSE FILE",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",