@reltio/components 1.4.2242 → 1.4.2244
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/ActivenessDateControl/ActivenessDateControl.d.ts +9 -0
- package/ActivenessDateControl/ActivenessDateControl.js +11 -0
- package/ActivenessDateControl/index.d.ts +1 -0
- package/ActivenessDateControl/index.js +1 -0
- package/EntitySelector/EntitySelector.d.ts +2 -1
- package/EntitySelector/EntitySelector.js +2 -2
- package/EntitySelector/index.d.ts +1 -0
- package/MoreAttributesButton/MoreAttributesButton.d.ts +3 -2
- package/MoreAttributesButton/MoreAttributesButton.js +8 -8
- package/MoreAttributesButton/useMoreAttributesItems.d.ts +4 -4
- package/cjs/ActivenessDateControl/ActivenessDateControl.d.ts +9 -0
- package/cjs/ActivenessDateControl/ActivenessDateControl.js +18 -0
- package/cjs/ActivenessDateControl/index.d.ts +1 -0
- package/cjs/ActivenessDateControl/index.js +5 -0
- package/cjs/EntitySelector/EntitySelector.d.ts +2 -1
- package/cjs/EntitySelector/EntitySelector.js +2 -2
- package/cjs/EntitySelector/index.d.ts +1 -0
- package/cjs/MoreAttributesButton/MoreAttributesButton.d.ts +3 -2
- package/cjs/MoreAttributesButton/MoreAttributesButton.js +8 -8
- package/cjs/MoreAttributesButton/useMoreAttributesItems.d.ts +4 -4
- package/cjs/features/activity-log/ActivityLog/ActivityLog.test.js +28 -0
- package/cjs/features/activity-log/ActivityLog/components/ActivityItem/ActivityItem.js +22 -11
- package/cjs/features/activity-log/ActivityLog/components/ActivityItem/ActivityItem.module.css.js +9 -0
- package/cjs/features/activity-log/ActivityLog/constants.d.ts +17 -0
- package/cjs/features/activity-log/ActivityLog/constants.js +20 -0
- package/cjs/features/workflow/ChangeRequestEditor/ChangeRequestEditor.d.ts +1 -1
- package/cjs/features/workflow/ChangeRequestEditor/ChangeRequestEditor.js +20 -9
- package/cjs/features/workflow/ChangeRequestEditor/components/AddSameAttributeButton/AddSameAttributeButton.d.ts +7 -0
- package/cjs/features/workflow/ChangeRequestEditor/components/AddSameAttributeButton/AddSameAttributeButton.js +67 -0
- package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemLabel/ChangeItemLabel.js +3 -1
- package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemLabel/ChangeItemLabel.module.css.js +2 -2
- package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.d.ts +2 -2
- package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.js +25 -6
- package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.module.css.js +2 -2
- package/cjs/features/workflow/ChangeRequestEditor/components/DCRImageEditor/DCRImageEditor.d.ts +9 -0
- package/cjs/features/workflow/ChangeRequestEditor/components/DCRImageEditor/DCRImageEditor.js +79 -0
- package/cjs/features/workflow/ChangeRequestEditor/components/DCRImageEditor/index.d.ts +1 -0
- package/cjs/features/workflow/ChangeRequestEditor/components/DCRImageEditor/index.js +5 -0
- package/cjs/features/workflow/ChangeRequestEditor/components/DCRValueEditorFactory/DCRValueEditorFactory.d.ts +2 -2
- package/cjs/features/workflow/ChangeRequestEditor/components/DCRValueEditorFactory/DCRValueEditorFactory.js +2 -2
- package/cjs/features/workflow/ChangeRequestEditor/components/EditorStatusChip/EditorStatusChip.d.ts +11 -0
- package/cjs/features/workflow/ChangeRequestEditor/components/EditorStatusChip/EditorStatusChip.js +41 -0
- package/cjs/features/workflow/ChangeRequestEditor/components/EditorStatusChip/EditorStatusChip.module.css.js +9 -0
- package/cjs/features/workflow/ChangeRequestEditor/components/EditorStatusChip/index.d.ts +1 -0
- package/cjs/features/workflow/ChangeRequestEditor/components/EditorStatusChip/index.js +6 -0
- package/cjs/features/workflow/ChangeRequestEditor/components/EntityChangesGroup/EntityChangesGroup.d.ts +1 -1
- package/cjs/features/workflow/ChangeRequestEditor/components/EntityChangesGroup/EntityChangesGroup.js +134 -5
- package/cjs/features/workflow/ChangeRequestEditor/components/EntityChangesGroup/SkeletonEntityChangesGroupLoader.js +2 -2
- package/cjs/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemEditor}/ChangeItemEditor.d.ts +1 -1
- package/cjs/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditor/ChangeItemEditor.js +110 -0
- package/cjs/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditor/ChangeItemEditor.module.css.js +9 -0
- package/cjs/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemEditor}/SkeletonChangeItemEditorLoader.js +6 -5
- package/cjs/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemEditor}/index.d.ts +0 -1
- package/cjs/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemEditor}/index.js +1 -3
- package/cjs/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditorRecentlyAdded/ChangeItemEditorRecentlyAdded.d.ts +8 -0
- package/cjs/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditorRecentlyAdded/ChangeItemEditorRecentlyAdded.js +89 -0
- package/cjs/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditorRecentlyAdded/index.d.ts +1 -0
- package/cjs/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditorRecentlyAdded/index.js +5 -0
- package/cjs/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemOldValue}/ChangeItemOldValue.d.ts +1 -1
- package/cjs/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemOldValue}/ChangeItemOldValue.js +12 -11
- package/cjs/features/workflow/ChangeRequestEditor/components/editors/ChangeItemOldValue/ChangeItemOldValue.module.css.js +9 -0
- package/cjs/features/workflow/ChangeRequestEditor/components/editors/ChangeItemOldValue/index.d.ts +1 -0
- package/cjs/features/workflow/ChangeRequestEditor/components/editors/ChangeItemOldValue/index.js +5 -0
- package/cjs/features/workflow/ChangeRequestEditor/components/editors/MoreAttributesEditor/MoreAttributesEditor.d.ts +11 -0
- package/cjs/features/workflow/ChangeRequestEditor/components/editors/MoreAttributesEditor/MoreAttributesEditor.js +34 -0
- package/cjs/features/workflow/ChangeRequestEditor/components/editors/MoreAttributesEditor/MoreAttributesEditor.module.css.js +9 -0
- package/cjs/features/workflow/ChangeRequestEditor/components/editors/MoreAttributesEditor/index.d.ts +1 -0
- package/cjs/features/workflow/ChangeRequestEditor/components/editors/MoreAttributesEditor/index.js +5 -0
- package/cjs/features/workflow/ChangeRequestEditor/components/editors/editors.module.css.js +9 -0
- package/cjs/features/workflow/ChangeRequestEditor/components/editors/index.d.ts +4 -0
- package/cjs/features/workflow/ChangeRequestEditor/components/editors/index.js +12 -0
- package/cjs/features/workflow/ChangeRequestEditor/helpers/addedAttributes.d.ts +11 -0
- package/cjs/features/workflow/ChangeRequestEditor/helpers/addedAttributes.js +74 -0
- package/cjs/features/workflow/ChangeRequestEditor/helpers/changesList.d.ts +2 -0
- package/cjs/features/workflow/ChangeRequestEditor/helpers/changesList.js +157 -0
- package/cjs/features/workflow/ChangeRequestEditor/helpers/changesList.test.d.ts +1 -0
- package/cjs/features/workflow/ChangeRequestEditor/helpers/changesList.test.js +203 -0
- package/cjs/features/workflow/ChangeRequestEditor/helpers/helpers.d.ts +6 -3
- package/cjs/features/workflow/ChangeRequestEditor/helpers/helpers.js +22 -3
- package/cjs/features/workflow/ChangeRequestEditor/helpers/mergeAddedAttributesWithDCRChanges.d.ts +3 -0
- package/cjs/features/workflow/ChangeRequestEditor/helpers/mergeAddedAttributesWithDCRChanges.js +190 -0
- package/cjs/features/workflow/ChangeRequestEditor/helpers/mergeAddedAttributesWithDCRChanges.test.d.ts +1 -0
- package/cjs/features/workflow/ChangeRequestEditor/helpers/mergeAddedAttributesWithDCRChanges.test.js +768 -0
- package/cjs/features/workflow/ChangeRequestEditor/hooks/useChangeRequestEditor.d.ts +4 -3
- package/cjs/features/workflow/ChangeRequestEditor/hooks/useChangeRequestEditor.js +9 -1
- package/cjs/features/workflow/ChangeRequestEditor/hooks/useNewAttributesEditor.d.ts +18 -0
- package/cjs/features/workflow/ChangeRequestEditor/hooks/useNewAttributesEditor.js +65 -0
- package/cjs/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.js +7 -3
- package/cjs/features/workflow/contexts/AddedAttributesContext/index.d.ts +39 -0
- package/cjs/features/workflow/contexts/AddedAttributesContext/index.js +152 -0
- package/cjs/features/workflow/contexts/ChangeRequestEditorContext/index.d.ts +3 -2
- package/cjs/features/workflow/contexts/ChangeRequestEditorContext/index.js +47 -7
- package/cjs/features/workflow/contexts/ScrollToAddedAttributeContext/index.d.ts +11 -0
- package/cjs/features/workflow/contexts/ScrollToAddedAttributeContext/index.js +78 -0
- package/cjs/features/workflow/helpers/attributes.js +16 -13
- package/cjs/features/workflow/helpers/attributes.test.js +6 -3
- package/cjs/features/workflow/helpers/dcr.d.ts +6 -1
- package/cjs/features/workflow/helpers/dcr.js +113 -18
- package/cjs/features/workflow/helpers/dcr.test.js +122 -0
- package/cjs/features/workflow/helpers/merge.d.ts +3 -0
- package/cjs/features/workflow/helpers/merge.js +32 -20
- package/cjs/features/workflow/helpers/merge.test.js +2 -1
- package/cjs/features/workflow/helpers/moreAttributesScope.d.ts +4 -0
- package/cjs/features/workflow/helpers/moreAttributesScope.js +20 -0
- package/cjs/features/workflow/helpers/validation.js +31 -6
- package/cjs/features/workflow/hooks/useApplyDcrChanges.d.ts +2 -2
- package/cjs/features/workflow/hooks/useApplyDcrChanges.js +80 -63
- package/cjs/features/workflow/types.d.ts +12 -2
- package/features/activity-log/ActivityLog/ActivityLog.test.js +28 -0
- package/features/activity-log/ActivityLog/components/ActivityItem/ActivityItem.js +15 -4
- package/features/activity-log/ActivityLog/components/ActivityItem/ActivityItem.module.css.js +9 -0
- package/features/activity-log/ActivityLog/constants.d.ts +17 -0
- package/features/activity-log/ActivityLog/constants.js +17 -0
- package/features/workflow/ChangeRequestEditor/ChangeRequestEditor.d.ts +1 -1
- package/features/workflow/ChangeRequestEditor/ChangeRequestEditor.js +20 -9
- package/features/workflow/ChangeRequestEditor/components/AddSameAttributeButton/AddSameAttributeButton.d.ts +7 -0
- package/features/workflow/ChangeRequestEditor/components/AddSameAttributeButton/AddSameAttributeButton.js +37 -0
- package/features/workflow/ChangeRequestEditor/components/ChangeItemLabel/ChangeItemLabel.js +3 -1
- package/features/workflow/ChangeRequestEditor/components/ChangeItemLabel/ChangeItemLabel.module.css.js +2 -2
- package/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.d.ts +2 -2
- package/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.js +26 -7
- package/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.module.css.js +2 -2
- package/features/workflow/ChangeRequestEditor/components/DCRImageEditor/DCRImageEditor.d.ts +9 -0
- package/features/workflow/ChangeRequestEditor/components/DCRImageEditor/DCRImageEditor.js +49 -0
- package/features/workflow/ChangeRequestEditor/components/DCRImageEditor/index.d.ts +1 -0
- package/features/workflow/ChangeRequestEditor/components/DCRImageEditor/index.js +1 -0
- package/features/workflow/ChangeRequestEditor/components/DCRValueEditorFactory/DCRValueEditorFactory.d.ts +2 -2
- package/features/workflow/ChangeRequestEditor/components/DCRValueEditorFactory/DCRValueEditorFactory.js +2 -2
- package/features/workflow/ChangeRequestEditor/components/EditorStatusChip/EditorStatusChip.d.ts +11 -0
- package/features/workflow/ChangeRequestEditor/components/EditorStatusChip/EditorStatusChip.js +34 -0
- package/features/workflow/ChangeRequestEditor/components/EditorStatusChip/EditorStatusChip.module.css.js +9 -0
- package/features/workflow/ChangeRequestEditor/components/EditorStatusChip/index.d.ts +1 -0
- package/features/workflow/ChangeRequestEditor/components/EditorStatusChip/index.js +1 -0
- package/features/workflow/ChangeRequestEditor/components/EntityChangesGroup/EntityChangesGroup.d.ts +1 -1
- package/features/workflow/ChangeRequestEditor/components/EntityChangesGroup/EntityChangesGroup.js +112 -6
- package/features/workflow/ChangeRequestEditor/components/EntityChangesGroup/SkeletonEntityChangesGroupLoader.js +1 -1
- package/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemEditor}/ChangeItemEditor.d.ts +1 -1
- package/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditor/ChangeItemEditor.js +80 -0
- package/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditor/ChangeItemEditor.module.css.js +9 -0
- package/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemEditor}/SkeletonChangeItemEditorLoader.js +6 -5
- package/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemEditor}/index.d.ts +0 -1
- package/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemEditor}/index.js +0 -1
- package/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditorRecentlyAdded/ChangeItemEditorRecentlyAdded.d.ts +8 -0
- package/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditorRecentlyAdded/ChangeItemEditorRecentlyAdded.js +59 -0
- package/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditorRecentlyAdded/index.d.ts +1 -0
- package/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditorRecentlyAdded/index.js +1 -0
- package/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemOldValue}/ChangeItemOldValue.d.ts +1 -1
- package/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemOldValue}/ChangeItemOldValue.js +10 -9
- package/features/workflow/ChangeRequestEditor/components/editors/ChangeItemOldValue/ChangeItemOldValue.module.css.js +9 -0
- package/features/workflow/ChangeRequestEditor/components/editors/ChangeItemOldValue/index.d.ts +1 -0
- package/features/workflow/ChangeRequestEditor/components/editors/ChangeItemOldValue/index.js +1 -0
- package/features/workflow/ChangeRequestEditor/components/editors/MoreAttributesEditor/MoreAttributesEditor.d.ts +11 -0
- package/features/workflow/ChangeRequestEditor/components/editors/MoreAttributesEditor/MoreAttributesEditor.js +27 -0
- package/features/workflow/ChangeRequestEditor/components/editors/MoreAttributesEditor/MoreAttributesEditor.module.css.js +9 -0
- package/features/workflow/ChangeRequestEditor/components/editors/MoreAttributesEditor/index.d.ts +1 -0
- package/features/workflow/ChangeRequestEditor/components/editors/MoreAttributesEditor/index.js +1 -0
- package/features/workflow/ChangeRequestEditor/components/editors/editors.module.css.js +9 -0
- package/features/workflow/ChangeRequestEditor/components/editors/index.d.ts +4 -0
- package/features/workflow/ChangeRequestEditor/components/editors/index.js +4 -0
- package/features/workflow/ChangeRequestEditor/helpers/addedAttributes.d.ts +11 -0
- package/features/workflow/ChangeRequestEditor/helpers/addedAttributes.js +62 -0
- package/features/workflow/ChangeRequestEditor/helpers/changesList.d.ts +2 -0
- package/features/workflow/ChangeRequestEditor/helpers/changesList.js +153 -0
- package/features/workflow/ChangeRequestEditor/helpers/changesList.test.d.ts +1 -0
- package/features/workflow/ChangeRequestEditor/helpers/changesList.test.js +201 -0
- package/features/workflow/ChangeRequestEditor/helpers/helpers.d.ts +6 -3
- package/features/workflow/ChangeRequestEditor/helpers/helpers.js +19 -3
- package/features/workflow/ChangeRequestEditor/helpers/mergeAddedAttributesWithDCRChanges.d.ts +3 -0
- package/features/workflow/ChangeRequestEditor/helpers/mergeAddedAttributesWithDCRChanges.js +186 -0
- package/features/workflow/ChangeRequestEditor/helpers/mergeAddedAttributesWithDCRChanges.test.d.ts +1 -0
- package/features/workflow/ChangeRequestEditor/helpers/mergeAddedAttributesWithDCRChanges.test.js +766 -0
- package/features/workflow/ChangeRequestEditor/hooks/useChangeRequestEditor.d.ts +4 -3
- package/features/workflow/ChangeRequestEditor/hooks/useChangeRequestEditor.js +9 -1
- package/features/workflow/ChangeRequestEditor/hooks/useNewAttributesEditor.d.ts +18 -0
- package/features/workflow/ChangeRequestEditor/hooks/useNewAttributesEditor.js +61 -0
- package/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.js +7 -3
- package/features/workflow/contexts/AddedAttributesContext/index.d.ts +39 -0
- package/features/workflow/contexts/AddedAttributesContext/index.js +125 -0
- package/features/workflow/contexts/ChangeRequestEditorContext/index.d.ts +3 -2
- package/features/workflow/contexts/ChangeRequestEditorContext/index.js +47 -7
- package/features/workflow/contexts/ScrollToAddedAttributeContext/index.d.ts +11 -0
- package/features/workflow/contexts/ScrollToAddedAttributeContext/index.js +51 -0
- package/features/workflow/helpers/attributes.js +16 -13
- package/features/workflow/helpers/attributes.test.js +6 -3
- package/features/workflow/helpers/dcr.d.ts +6 -1
- package/features/workflow/helpers/dcr.js +112 -18
- package/features/workflow/helpers/dcr.test.js +123 -1
- package/features/workflow/helpers/merge.d.ts +3 -0
- package/features/workflow/helpers/merge.js +30 -19
- package/features/workflow/helpers/merge.test.js +2 -1
- package/features/workflow/helpers/moreAttributesScope.d.ts +4 -0
- package/features/workflow/helpers/moreAttributesScope.js +14 -0
- package/features/workflow/helpers/validation.js +31 -6
- package/features/workflow/hooks/useApplyDcrChanges.d.ts +2 -2
- package/features/workflow/hooks/useApplyDcrChanges.js +83 -66
- package/features/workflow/types.d.ts +12 -2
- package/package.json +2 -2
- package/cjs/features/activity-log/ActivityLog/components/ActivityItem/styles.d.ts +0 -1
- package/cjs/features/activity-log/ActivityLog/components/ActivityItem/styles.js +0 -57
- package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemEditor/ChangeItemEditor.js +0 -95
- package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemEditor/ChangeItemEditor.module.css.js +0 -9
- package/cjs/features/workflow/ChangeRequestEditor/components/StatusChips/StatusChips.d.ts +0 -7
- package/cjs/features/workflow/ChangeRequestEditor/components/StatusChips/StatusChips.js +0 -21
- package/cjs/features/workflow/ChangeRequestEditor/components/StatusChips/StatusChips.module.css.js +0 -9
- package/cjs/features/workflow/ChangeRequestEditor/components/StatusChips/index.d.ts +0 -1
- package/cjs/features/workflow/ChangeRequestEditor/components/StatusChips/index.js +0 -5
- package/features/activity-log/ActivityLog/components/ActivityItem/styles.d.ts +0 -1
- package/features/activity-log/ActivityLog/components/ActivityItem/styles.js +0 -54
- package/features/workflow/ChangeRequestEditor/components/ChangeItemEditor/ChangeItemEditor.js +0 -65
- package/features/workflow/ChangeRequestEditor/components/ChangeItemEditor/ChangeItemEditor.module.css.js +0 -9
- package/features/workflow/ChangeRequestEditor/components/StatusChips/StatusChips.d.ts +0 -7
- package/features/workflow/ChangeRequestEditor/components/StatusChips/StatusChips.js +0 -14
- package/features/workflow/ChangeRequestEditor/components/StatusChips/StatusChips.module.css.js +0 -9
- package/features/workflow/ChangeRequestEditor/components/StatusChips/index.d.ts +0 -1
- package/features/workflow/ChangeRequestEditor/components/StatusChips/index.js +0 -1
- /package/cjs/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemEditor}/SkeletonChangeItemEditorLoader.d.ts +0 -0
- /package/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemEditor}/SkeletonChangeItemEditorLoader.d.ts +0 -0
|
@@ -18,8 +18,51 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
18
18
|
}
|
|
19
19
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
20
|
};
|
|
21
|
-
import { createEntryDeleteAttribute, DCRTypes, findAttributeTypeByUri, isEntityUri, isNested, isRelationTypeUri, isRelationUri } from '@reltio/mdm-sdk';
|
|
21
|
+
import { createEntryDeleteAttribute, DCRTypes, EventType, findAttributeTypeByUri, getReferencedEntityTypeUriFromAttrType, isEmptyValue, isEntityUri, isNested, isRelationTypeUri, isRelationUri } from '@reltio/mdm-sdk';
|
|
22
22
|
import { allPass, append, assocPath, concat, curry, dissocPath, equals, filter, flatten, fromPairs, groupBy, has, hasPath, isEmpty, isNil, keys, map, partition, path, pathOr, pipe, pluck, prop, propOr, toPairs, values, uniq, uniqBy, when } from 'ramda';
|
|
23
|
+
import { ADDED_CHANGE_ID_PREFIX } from '../contexts/AddedAttributesContext';
|
|
24
|
+
var isAddedChange = function (changeId) { return changeId === null || changeId === void 0 ? void 0 : changeId.startsWith(ADDED_CHANGE_ID_PREFIX); };
|
|
25
|
+
var normalizeReferenceValueForApi = function (val, change, metadata) {
|
|
26
|
+
var attrType = findAttributeTypeByUri(metadata, change.attributeType);
|
|
27
|
+
return __assign(__assign(__assign({}, val), { refEntity: {
|
|
28
|
+
objectURI: val.refEntity.objectURI,
|
|
29
|
+
type: getReferencedEntityTypeUriFromAttrType(attrType)
|
|
30
|
+
} }), (change.crosswalk && {
|
|
31
|
+
refRelation: {
|
|
32
|
+
type: change.crosswalk.type
|
|
33
|
+
}
|
|
34
|
+
}));
|
|
35
|
+
};
|
|
36
|
+
var dcrChangeToInsertDiffEntry = function (change, objectUri, metadata) {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
switch (change.type) {
|
|
39
|
+
case DCRTypes.INSERT_ATTRIBUTE: {
|
|
40
|
+
var newVal = change.newValue;
|
|
41
|
+
var normalized = newVal.refEntity !== undefined ? normalizeReferenceValueForApi(newVal, change, metadata) : newVal;
|
|
42
|
+
var attributePath = change.attributePath;
|
|
43
|
+
if (change.refObjectURI && change.refAttributeType) {
|
|
44
|
+
var refAttrName = change.refAttributeType.split('/attributes/')[1];
|
|
45
|
+
var refInstanceId = change.refObjectURI.split('/')[1];
|
|
46
|
+
attributePath = "".concat(refAttrName, "/").concat(refInstanceId, "/").concat(attributePath);
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
type: EventType.INSERT_ATTRIBUTE,
|
|
50
|
+
uri: "".concat(objectUri, "/attributes/").concat(attributePath),
|
|
51
|
+
newValue: [normalized]
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
case DCRTypes.UPDATE_TAGS:
|
|
55
|
+
return { type: EventType.UPDATE_TAGS, newValue: change.newValue };
|
|
56
|
+
case DCRTypes.UPDATE_ROLES:
|
|
57
|
+
return { type: EventType.UPDATE_ROLES, newValue: change.newValue };
|
|
58
|
+
case DCRTypes.UPDATE_START_DATE:
|
|
59
|
+
return { type: EventType.UPDATE_START_DATE, newValue: { value: (_a = change.newValue) === null || _a === void 0 ? void 0 : _a[0] } };
|
|
60
|
+
case DCRTypes.UPDATE_END_DATE:
|
|
61
|
+
return { type: EventType.UPDATE_END_DATE, newValue: { value: (_b = change.newValue) === null || _b === void 0 ? void 0 : _b[0] } };
|
|
62
|
+
default:
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
23
66
|
export var getEntitiesObjects = filter(pipe(prop('uri'), isEntityUri));
|
|
24
67
|
export var getRelationsObjects = filter(pipe(prop('uri'), isRelationUri));
|
|
25
68
|
var getRelations = function (objectsWithChanges, entityUri) {
|
|
@@ -57,7 +100,7 @@ export var isCreateEntityOperation = function (dcr) {
|
|
|
57
100
|
return dcr.type === DCRTypes.CREATE_ENTITY;
|
|
58
101
|
};
|
|
59
102
|
var cleanValueRecursively = function (value) {
|
|
60
|
-
if (typeof value === 'string' || isEmpty(value)) {
|
|
103
|
+
if (isNil(value) || typeof value === 'string' || isEmpty(value)) {
|
|
61
104
|
return value;
|
|
62
105
|
}
|
|
63
106
|
var cleanedProperties = map(function (propertyValues) {
|
|
@@ -69,7 +112,7 @@ var cleanValueRecursively = function (value) {
|
|
|
69
112
|
})
|
|
70
113
|
.filter(function (item) {
|
|
71
114
|
var itemValue = item.value;
|
|
72
|
-
return !isEmpty(itemValue) && !isNil(itemValue);
|
|
115
|
+
return (!isEmpty(itemValue) && !isNil(itemValue)) || 'lookupCode' in item;
|
|
73
116
|
});
|
|
74
117
|
}, value);
|
|
75
118
|
return filter(function (propertyValues) { return !isEmpty(propertyValues); }, cleanedProperties);
|
|
@@ -109,12 +152,16 @@ var calculateValuePath = function (key, change) {
|
|
|
109
152
|
case DCRTypes.UPDATE_END_DATE:
|
|
110
153
|
return __spreadArray(__spreadArray([], path, true), [0], false);
|
|
111
154
|
case DCRTypes.CREATE_RELATIONSHIP:
|
|
155
|
+
case DCRTypes.CREATE_ENTITY:
|
|
112
156
|
if (path.length === 2) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
157
|
+
switch (path[1]) {
|
|
158
|
+
case 'roles':
|
|
159
|
+
case 'tags':
|
|
160
|
+
return path;
|
|
161
|
+
case 'activeness.startDate':
|
|
162
|
+
return [path[0], 'startDate'];
|
|
163
|
+
case 'activeness.endDate':
|
|
164
|
+
return [path[0], 'endDate'];
|
|
118
165
|
}
|
|
119
166
|
}
|
|
120
167
|
return __spreadArray(__spreadArray([], path, true), ['value'], false);
|
|
@@ -123,6 +170,12 @@ var calculateValuePath = function (key, change) {
|
|
|
123
170
|
}
|
|
124
171
|
};
|
|
125
172
|
var valuesAreEqual = function (oldValue, newValue) {
|
|
173
|
+
if (typeof oldValue === 'object' &&
|
|
174
|
+
typeof newValue === 'object' &&
|
|
175
|
+
!Array.isArray(oldValue) &&
|
|
176
|
+
!Array.isArray(newValue)) {
|
|
177
|
+
return equals(oldValue, newValue);
|
|
178
|
+
}
|
|
126
179
|
var sortWithLocale = function (array) { return array.slice().sort(function (a, b) { return a.localeCompare(b); }); };
|
|
127
180
|
if (Array.isArray(oldValue) && Array.isArray(newValue)) {
|
|
128
181
|
return oldValue.length === newValue.length && equals(sortWithLocale(oldValue), sortWithLocale(newValue));
|
|
@@ -143,6 +196,7 @@ export var buildDCRSavePlan = function (changes, getLinesByChangeId, metadata) {
|
|
|
143
196
|
var rejectedChangeIds = [];
|
|
144
197
|
var updatedChanges = {};
|
|
145
198
|
var deleteAttributes = {};
|
|
199
|
+
var insertAttributes = {};
|
|
146
200
|
for (var _i = 0, _c = Object.entries(changes); _i < _c.length; _i++) {
|
|
147
201
|
var _d = _c[_i], objectUri = _d[0], objectChanges = _d[1];
|
|
148
202
|
var rawChanges = new Map();
|
|
@@ -152,18 +206,28 @@ export var buildDCRSavePlan = function (changes, getLinesByChangeId, metadata) {
|
|
|
152
206
|
var key = _a[0], lineData = _a[1];
|
|
153
207
|
return key.split('/').length === 3 &&
|
|
154
208
|
(lineData.isRejected ||
|
|
155
|
-
(
|
|
209
|
+
(isEmptyValue((_b = lineData.value) === null || _b === void 0 ? void 0 : _b.value) && change.type !== DCRTypes.UPDATE_ATTRIBUTE));
|
|
156
210
|
}))(change), rejectedRootLines = _h[0], otherLines = _h[1];
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
211
|
+
var isNew = isAddedChange(change.id);
|
|
212
|
+
if (!isNew) {
|
|
213
|
+
rejectedChangeIds.push.apply(rejectedChangeIds, rejectedRootLines.map(function (_a) {
|
|
214
|
+
var key = _a[0];
|
|
215
|
+
return key.split('/')[1];
|
|
216
|
+
}));
|
|
217
|
+
}
|
|
218
|
+
var newValueObj = change.newValue;
|
|
219
|
+
var hasNonEmptyNewValue = Array.isArray(change.newValue) ||
|
|
220
|
+
!isEmptyValue(newValueObj === null || newValueObj === void 0 ? void 0 : newValueObj.value) ||
|
|
221
|
+
'lookupCode' in (newValueObj !== null && newValueObj !== void 0 ? newValueObj : {});
|
|
222
|
+
if (isNew && otherLines.length === 0 && rejectedRootLines.length === 0 && hasNonEmptyNewValue) {
|
|
223
|
+
rawChanges.set(change.id, change);
|
|
224
|
+
}
|
|
161
225
|
var rejectedRootLinesMap = new Map(rejectedRootLines);
|
|
162
226
|
for (var _j = 0, otherLines_1 = otherLines; _j < otherLines_1.length; _j++) {
|
|
163
227
|
var _k = otherLines_1[_j], key = _k[0], lineData = _k[1];
|
|
164
228
|
var rootId = key.split('/').slice(0, 3).join('/');
|
|
165
229
|
var newValue = (_a = lineData.value) === null || _a === void 0 ? void 0 : _a.value;
|
|
166
|
-
if (rootId === key && change.type === DCRTypes.UPDATE_ATTRIBUTE &&
|
|
230
|
+
if (!isNew && rootId === key && change.type === DCRTypes.UPDATE_ATTRIBUTE && isEmptyValue(newValue)) {
|
|
167
231
|
var attributeUri = [objectUri, 'attributes', change.attributePath].join('/');
|
|
168
232
|
var entry = __assign(__assign({}, createEntryDeleteAttribute({ uri: attributeUri })[0]), (change.crosswalk && { crosswalk: change.crosswalk }));
|
|
169
233
|
deleteAttributes[objectUri] = uniqBy(prop('uri'), append(entry, propOr([], objectUri, deleteAttributes)));
|
|
@@ -175,12 +239,14 @@ export var buildDCRSavePlan = function (changes, getLinesByChangeId, metadata) {
|
|
|
175
239
|
var oldValue = getOldValueByNewValuePath(valuePath, change);
|
|
176
240
|
var initialChange = rawChanges.has(change.id) ? rawChanges.get(change.id) : change;
|
|
177
241
|
var updatedChange = void 0;
|
|
178
|
-
if (lineData.isRejected ||
|
|
242
|
+
if (lineData.isRejected || isEmptyValue(newValue)) {
|
|
179
243
|
updatedChange = assocPath(valuePath, null, initialChange);
|
|
180
244
|
}
|
|
181
245
|
else if (!valuesAreEqual(oldDCRValue, newValue)) {
|
|
182
246
|
if (oldValue && valuesAreEqual(oldValue, newValue)) {
|
|
183
|
-
|
|
247
|
+
if (!isNew) {
|
|
248
|
+
rejectedChangeIds.push(change.id);
|
|
249
|
+
}
|
|
184
250
|
}
|
|
185
251
|
else {
|
|
186
252
|
var processedNewValue = typeof oldDCRValue === 'string' && typeof newValue === 'number'
|
|
@@ -205,7 +271,15 @@ export var buildDCRSavePlan = function (changes, getLinesByChangeId, metadata) {
|
|
|
205
271
|
var isNestedChange = has('attributeType', cleanedChange) &&
|
|
206
272
|
isNested(findAttributeTypeByUri(metadata, cleanedChange.attributeType));
|
|
207
273
|
if (isNestedChange && isEmpty((_b = cleanedChange.newValue) === null || _b === void 0 ? void 0 : _b.value)) {
|
|
208
|
-
|
|
274
|
+
if (!isAddedChange(cleanedChange.id)) {
|
|
275
|
+
rejectedChangeIds.push(cleanedChange.id);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
else if (isAddedChange(cleanedChange.id)) {
|
|
279
|
+
var diffEntry = dcrChangeToInsertDiffEntry(cleanedChange, objectUri, metadata);
|
|
280
|
+
if (diffEntry) {
|
|
281
|
+
insertAttributes[objectUri] = append(diffEntry, propOr([], objectUri, insertAttributes));
|
|
282
|
+
}
|
|
209
283
|
}
|
|
210
284
|
else {
|
|
211
285
|
updatedChanges[objectUri] = append(cleanedChange, propOr([], objectUri, updatedChanges));
|
|
@@ -220,10 +294,30 @@ export var buildDCRSavePlan = function (changes, getLinesByChangeId, metadata) {
|
|
|
220
294
|
}, toPairs(deleteAttributes));
|
|
221
295
|
var deleteRelationAttributes = fromPairs(deleteAttributesGroups.relation || []);
|
|
222
296
|
var deleteEntityAttributes = fromPairs(deleteAttributesGroups.entity || []);
|
|
297
|
+
var insertAttributesGroups = groupBy(function (_a) {
|
|
298
|
+
var uri = _a[0];
|
|
299
|
+
return (isRelationUri(uri) ? 'relation' : 'entity');
|
|
300
|
+
}, toPairs(insertAttributes));
|
|
301
|
+
var insertRelationAttributes = fromPairs(insertAttributesGroups.relation || []);
|
|
302
|
+
var insertEntityAttributes = fromPairs(insertAttributesGroups.entity || []);
|
|
223
303
|
return {
|
|
224
304
|
rejectedChangeIds: rejectedChangeIds,
|
|
225
305
|
updatedChanges: updatedChanges,
|
|
226
306
|
deleteEntityAttributes: deleteEntityAttributes,
|
|
227
|
-
deleteRelationAttributes: deleteRelationAttributes
|
|
307
|
+
deleteRelationAttributes: deleteRelationAttributes,
|
|
308
|
+
insertEntityAttributes: insertEntityAttributes,
|
|
309
|
+
insertRelationAttributes: insertRelationAttributes
|
|
228
310
|
};
|
|
229
311
|
};
|
|
312
|
+
export var mergeExistingRolesAndTags = function (diff, entity) {
|
|
313
|
+
return diff.map(function (entry) {
|
|
314
|
+
var _a, _b;
|
|
315
|
+
if (entry.type === EventType.UPDATE_TAGS && ((_a = entity.tags) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
316
|
+
return __assign(__assign({}, entry), { newValue: uniq(__spreadArray(__spreadArray([], entity.tags, true), entry.newValue, true)) });
|
|
317
|
+
}
|
|
318
|
+
if (entry.type === EventType.UPDATE_ROLES && ((_b = entity.roles) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
319
|
+
return __assign(__assign({}, entry), { newValue: uniq(__spreadArray(__spreadArray([], entity.roles, true), entry.newValue, true)) });
|
|
320
|
+
}
|
|
321
|
+
return entry;
|
|
322
|
+
});
|
|
323
|
+
};
|
|
@@ -10,7 +10,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import { DCRChangeRequestState, DCRTypes } from '@reltio/mdm-sdk';
|
|
13
|
-
import { concatEntityRelationsObjects, createEntityRelationsObjectByEntity, createEntityRelationsObjectByRelation, extractObjectsFromChangeRequest, getEntityUriForChangeRequest, isCreateEntityOperation } from './dcr';
|
|
13
|
+
import { buildDCRSavePlan, concatEntityRelationsObjects, createEntityRelationsObjectByEntity, createEntityRelationsObjectByRelation, extractObjectsFromChangeRequest, getEntityUriForChangeRequest, isCreateEntityOperation } from './dcr';
|
|
14
14
|
describe('dcr helpers tests', function () {
|
|
15
15
|
it('extractObjectsFromChangeRequest behaviour', function () {
|
|
16
16
|
var objectsInfo = { id1: {}, id2: {}, id3: {} };
|
|
@@ -144,4 +144,126 @@ describe('dcr helpers tests', function () {
|
|
|
144
144
|
expect(isCreateEntityOperation(change)).toBe(true);
|
|
145
145
|
expect(isCreateEntityOperation(__assign(__assign({}, change), { type: DCRTypes.CREATE_RELATIONSHIP }))).toBe(false);
|
|
146
146
|
});
|
|
147
|
+
describe('buildDCRSavePlan', function () {
|
|
148
|
+
var emptyMetadata = { entityTypes: [], relationTypes: [] };
|
|
149
|
+
var noLineData = function () { return []; };
|
|
150
|
+
var emptyPlan = {
|
|
151
|
+
rejectedChangeIds: [],
|
|
152
|
+
updatedChanges: {},
|
|
153
|
+
deleteEntityAttributes: {},
|
|
154
|
+
deleteRelationAttributes: {},
|
|
155
|
+
insertEntityAttributes: {},
|
|
156
|
+
insertRelationAttributes: {}
|
|
157
|
+
};
|
|
158
|
+
it('should include added attribute with defaultValue when no lineData exists', function () {
|
|
159
|
+
var changes = {
|
|
160
|
+
'entities/456': [
|
|
161
|
+
{
|
|
162
|
+
id: 'added|simple1',
|
|
163
|
+
type: DCRTypes.INSERT_ATTRIBUTE,
|
|
164
|
+
attributePath: 'Surname',
|
|
165
|
+
attributeType: 'configuration/entityTypes/HCP/attributes/Surname',
|
|
166
|
+
newValue: { value: 'DefaultSurname' }
|
|
167
|
+
}
|
|
168
|
+
]
|
|
169
|
+
};
|
|
170
|
+
var result = buildDCRSavePlan(changes, noLineData, emptyMetadata);
|
|
171
|
+
expect(result).toEqual(__assign(__assign({}, emptyPlan), { insertEntityAttributes: {
|
|
172
|
+
'entities/456': [
|
|
173
|
+
{
|
|
174
|
+
type: 'INSERT_ATTRIBUTE',
|
|
175
|
+
uri: 'entities/456/attributes/Surname',
|
|
176
|
+
newValue: [{ value: 'DefaultSurname' }]
|
|
177
|
+
}
|
|
178
|
+
]
|
|
179
|
+
} }));
|
|
180
|
+
});
|
|
181
|
+
it('should include added lookup attribute with lookupCode when no lineData exists', function () {
|
|
182
|
+
var changes = {
|
|
183
|
+
'entities/456': [
|
|
184
|
+
{
|
|
185
|
+
id: 'added|lookup1',
|
|
186
|
+
type: DCRTypes.INSERT_ATTRIBUTE,
|
|
187
|
+
attributePath: 'Country',
|
|
188
|
+
attributeType: 'configuration/entityTypes/HCP/attributes/Country',
|
|
189
|
+
newValue: { value: '', lookupCode: 'ALBY' }
|
|
190
|
+
}
|
|
191
|
+
]
|
|
192
|
+
};
|
|
193
|
+
var result = buildDCRSavePlan(changes, noLineData, emptyMetadata);
|
|
194
|
+
expect(result).toEqual(__assign(__assign({}, emptyPlan), { insertEntityAttributes: {
|
|
195
|
+
'entities/456': [
|
|
196
|
+
{
|
|
197
|
+
type: 'INSERT_ATTRIBUTE',
|
|
198
|
+
uri: 'entities/456/attributes/Country',
|
|
199
|
+
newValue: [{ value: '', lookupCode: 'ALBY' }]
|
|
200
|
+
}
|
|
201
|
+
]
|
|
202
|
+
} }));
|
|
203
|
+
});
|
|
204
|
+
it('should preserve lookup sub-attribute with lookupCode inside nested parent', function () {
|
|
205
|
+
var metadata = {
|
|
206
|
+
entityTypes: [
|
|
207
|
+
{
|
|
208
|
+
uri: 'configuration/entityTypes/HCP',
|
|
209
|
+
attributes: [
|
|
210
|
+
{
|
|
211
|
+
uri: 'configuration/entityTypes/HCP/attributes/Details',
|
|
212
|
+
name: 'Details',
|
|
213
|
+
type: 'Nested',
|
|
214
|
+
attributes: [
|
|
215
|
+
{
|
|
216
|
+
uri: 'configuration/entityTypes/HCP/attributes/Details/attributes/Country',
|
|
217
|
+
name: 'Country',
|
|
218
|
+
type: 'String'
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
uri: 'configuration/entityTypes/HCP/attributes/Details/attributes/Notes',
|
|
222
|
+
name: 'Notes',
|
|
223
|
+
type: 'String'
|
|
224
|
+
}
|
|
225
|
+
]
|
|
226
|
+
}
|
|
227
|
+
]
|
|
228
|
+
}
|
|
229
|
+
]
|
|
230
|
+
};
|
|
231
|
+
var changes = {
|
|
232
|
+
'entities/456': [
|
|
233
|
+
{
|
|
234
|
+
id: 'added|nested1',
|
|
235
|
+
type: DCRTypes.INSERT_ATTRIBUTE,
|
|
236
|
+
attributePath: 'Details',
|
|
237
|
+
attributeType: 'configuration/entityTypes/HCP/attributes/Details',
|
|
238
|
+
newValue: {
|
|
239
|
+
value: {
|
|
240
|
+
Country: [{ value: '', lookupCode: 'ALBY' }],
|
|
241
|
+
Notes: [{ value: '' }]
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
]
|
|
246
|
+
};
|
|
247
|
+
var notesLineData = [
|
|
248
|
+
['456/added|nested1/newValue/value/Notes/0', { value: { value: 'User typed note' } }]
|
|
249
|
+
];
|
|
250
|
+
var result = buildDCRSavePlan(changes, function (changeId) { return (changeId === 'added|nested1' ? notesLineData : []); }, metadata);
|
|
251
|
+
expect(result).toEqual(__assign(__assign({}, emptyPlan), { insertEntityAttributes: {
|
|
252
|
+
'entities/456': [
|
|
253
|
+
{
|
|
254
|
+
type: 'INSERT_ATTRIBUTE',
|
|
255
|
+
uri: 'entities/456/attributes/Details',
|
|
256
|
+
newValue: [
|
|
257
|
+
{
|
|
258
|
+
value: {
|
|
259
|
+
Country: [{ value: '', lookupCode: 'ALBY' }],
|
|
260
|
+
Notes: [{ value: 'User typed note' }]
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
]
|
|
264
|
+
}
|
|
265
|
+
]
|
|
266
|
+
} }));
|
|
267
|
+
});
|
|
268
|
+
});
|
|
147
269
|
});
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { GroupedObjectsInfo, Metadata, EnrichedDCRChanges, EnrichedChangeValue, ChangeValue, DCRChanges } from '@reltio/mdm-sdk';
|
|
2
2
|
import { Diff } from '../types';
|
|
3
3
|
export declare const extractLineIds: (value: ChangeValue | EnrichedChangeValue) => string[] | undefined;
|
|
4
|
+
export declare const extractAddedId: (value: {
|
|
5
|
+
addedId?: string;
|
|
6
|
+
}) => string | undefined;
|
|
4
7
|
export declare const mergeChanges: (metadata: Metadata, changes: EnrichedDCRChanges | DCRChanges, entityInfo: GroupedObjectsInfo["entity"], relationsInfo: GroupedObjectsInfo["relations"]) => [Diff[], Diff[]];
|
|
@@ -23,6 +23,9 @@ var SPECIAL_ATTRIBUTES_NAMES = [
|
|
|
23
23
|
export var extractLineIds = function (value) {
|
|
24
24
|
return typeof value === 'object' && 'lineIds' in value ? value.lineIds : undefined;
|
|
25
25
|
};
|
|
26
|
+
export var extractAddedId = function (value) {
|
|
27
|
+
return typeof value === 'object' && value !== null && 'addedId' in value ? value.addedId : undefined;
|
|
28
|
+
};
|
|
26
29
|
var prepareStartOrEndDate = function (_a) {
|
|
27
30
|
var newValue = _a.newValue, oldValue = _a.oldValue;
|
|
28
31
|
var actualNewValue = newValue && 'value' in newValue ? newValue.value : newValue;
|
|
@@ -68,6 +71,15 @@ var prepareStartOrEndDate = function (_a) {
|
|
|
68
71
|
}
|
|
69
72
|
];
|
|
70
73
|
}
|
|
74
|
+
var addedId = newValue === null || newValue === void 0 ? void 0 : newValue.addedId;
|
|
75
|
+
if (addedId) {
|
|
76
|
+
return [
|
|
77
|
+
{
|
|
78
|
+
type: DCRTypes.INSERT_ATTRIBUTE,
|
|
79
|
+
newValue: __assign({ value: undefined, lineIds: extractLineIds(newValue) }, (addedId && { addedId: addedId }))
|
|
80
|
+
}
|
|
81
|
+
];
|
|
82
|
+
}
|
|
71
83
|
};
|
|
72
84
|
var prepareRolesOrTags = function (change) {
|
|
73
85
|
var _a = change.newValue, newValue = _a === void 0 ? [] : _a, _b = change.oldValue, oldValue = _b === void 0 ? [] : _b;
|
|
@@ -75,11 +87,12 @@ var prepareRolesOrTags = function (change) {
|
|
|
75
87
|
var preparedOldValue = 'value' in oldValue ? oldValue.value : oldValue;
|
|
76
88
|
var diffNewValue = difference(preparedNewValue, preparedOldValue);
|
|
77
89
|
var diffOldValue = difference(preparedOldValue, preparedNewValue);
|
|
90
|
+
var addedId = extractAddedId(newValue);
|
|
78
91
|
var items = [];
|
|
79
92
|
if (diffNewValue.length) {
|
|
80
93
|
items.push({
|
|
81
94
|
type: DCRTypes.INSERT_ATTRIBUTE,
|
|
82
|
-
newValue: { value: diffNewValue, lineIds: extractLineIds(newValue) }
|
|
95
|
+
newValue: __assign({ value: diffNewValue, lineIds: extractLineIds(newValue) }, (addedId && { addedId: addedId }))
|
|
83
96
|
});
|
|
84
97
|
}
|
|
85
98
|
if (diffOldValue.length) {
|
|
@@ -88,6 +101,12 @@ var prepareRolesOrTags = function (change) {
|
|
|
88
101
|
oldValue: { value: diffOldValue, lineIds: extractLineIds(oldValue) }
|
|
89
102
|
});
|
|
90
103
|
}
|
|
104
|
+
if (items.length === 0 && addedId) {
|
|
105
|
+
items.push({
|
|
106
|
+
type: DCRTypes.INSERT_ATTRIBUTE,
|
|
107
|
+
newValue: { value: [], lineIds: extractLineIds(newValue), addedId: addedId }
|
|
108
|
+
});
|
|
109
|
+
}
|
|
91
110
|
return items;
|
|
92
111
|
};
|
|
93
112
|
var getPath = function (change) {
|
|
@@ -143,46 +162,38 @@ var createEntityOrRelation = function (metadata, value) {
|
|
|
143
162
|
newObject['defaultProfilePicValue'] = [defaultProfilePicValue];
|
|
144
163
|
}
|
|
145
164
|
if (roles) {
|
|
165
|
+
var addedId = extractAddedId(roles);
|
|
146
166
|
newObject[EntityAttrTypes.roles.name] = [
|
|
147
167
|
{
|
|
148
168
|
type: DCRTypes.INSERT_ATTRIBUTE,
|
|
149
|
-
newValue: {
|
|
150
|
-
value: roles.map(getRoleLabel(metadata)).join(', '),
|
|
151
|
-
lineIds: lineIds && ["".concat(lineIds[0], "/").concat(EntityAttrTypes.roles.name)]
|
|
152
|
-
}
|
|
169
|
+
newValue: __assign({ value: addedId ? [] : roles.map(getRoleLabel(metadata)), lineIds: lineIds && ["".concat(lineIds[0], "/").concat(EntityAttrTypes.roles.name)] }, (addedId && { addedId: addedId }))
|
|
153
170
|
}
|
|
154
171
|
];
|
|
155
172
|
}
|
|
156
173
|
if (tags) {
|
|
174
|
+
var addedId = extractAddedId(tags);
|
|
157
175
|
newObject[EntityAttrTypes.tags.name] = [
|
|
158
176
|
{
|
|
159
177
|
type: DCRTypes.INSERT_ATTRIBUTE,
|
|
160
|
-
newValue: {
|
|
161
|
-
value: tags.join(', '),
|
|
162
|
-
lineIds: lineIds && ["".concat(lineIds[0], "/").concat(EntityAttrTypes.tags.name)]
|
|
163
|
-
}
|
|
178
|
+
newValue: __assign({ value: addedId ? [] : tags, lineIds: lineIds && ["".concat(lineIds[0], "/").concat(EntityAttrTypes.tags.name)] }, (addedId && { addedId: addedId }))
|
|
164
179
|
}
|
|
165
180
|
];
|
|
166
181
|
}
|
|
167
|
-
if (startDate) {
|
|
182
|
+
if (startDate !== undefined) {
|
|
183
|
+
var addedId = extractAddedId(startDate);
|
|
168
184
|
newObject[EntityAttrTypes.startDate.name] = [
|
|
169
185
|
{
|
|
170
186
|
type: DCRTypes.INSERT_ATTRIBUTE,
|
|
171
|
-
newValue: {
|
|
172
|
-
value: startDate,
|
|
173
|
-
lineIds: lineIds && ["".concat(lineIds[0], "/").concat(EntityAttrTypes.startDate.name)]
|
|
174
|
-
}
|
|
187
|
+
newValue: __assign({ value: addedId ? undefined : startDate, lineIds: lineIds && ["".concat(lineIds[0], "/").concat(EntityAttrTypes.startDate.name)] }, (addedId && { addedId: addedId }))
|
|
175
188
|
}
|
|
176
189
|
];
|
|
177
190
|
}
|
|
178
|
-
if (endDate) {
|
|
191
|
+
if (endDate !== undefined) {
|
|
192
|
+
var addedId = extractAddedId(endDate);
|
|
179
193
|
newObject[EntityAttrTypes.endDate.name] = [
|
|
180
194
|
{
|
|
181
195
|
type: DCRTypes.INSERT_ATTRIBUTE,
|
|
182
|
-
newValue: {
|
|
183
|
-
value: endDate,
|
|
184
|
-
lineIds: lineIds && ["".concat(lineIds[0], "/").concat(EntityAttrTypes.endDate.name)]
|
|
185
|
-
}
|
|
196
|
+
newValue: __assign({ value: addedId ? undefined : endDate, lineIds: lineIds && ["".concat(lineIds[0], "/").concat(EntityAttrTypes.endDate.name)] }, (addedId && { addedId: addedId }))
|
|
186
197
|
}
|
|
187
198
|
];
|
|
188
199
|
}
|
|
@@ -61,7 +61,8 @@ describe('mergeChanges tests', function () {
|
|
|
61
61
|
level: 1,
|
|
62
62
|
newValue: changes[entityUri][0].newValue,
|
|
63
63
|
operation: 'ignored',
|
|
64
|
-
isReferenceSubAttribute: false
|
|
64
|
+
isReferenceSubAttribute: false,
|
|
65
|
+
attributePath: 'Identifiers/45uypcuAz/Type/45uypcyRF'
|
|
65
66
|
}
|
|
66
67
|
],
|
|
67
68
|
[]
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type AttributeType, type Metadata } from '@reltio/mdm-sdk';
|
|
2
|
+
export declare const getAvailableAttributeTypesForEntity: (metadata: Metadata, entityTypeUri: string) => AttributeType[];
|
|
3
|
+
export declare const getAvailableAttributeTypesForRelation: (metadata: Metadata, relationTypeUri: string) => AttributeType[];
|
|
4
|
+
export declare const getAvailableSubAttributesForNestedOrReference: (metadata: Metadata, attributeType: AttributeType) => AttributeType[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getAttributeTypeSubAttributes, getCreatableAttributeTypes, getEditableAttributeTypeSubAttributes, getRelationAttributesList, isReference, Mode } from '@reltio/mdm-sdk';
|
|
2
|
+
import { getFilteredAttrTypes } from '../../../helpers/attributesView';
|
|
3
|
+
export var getAvailableAttributeTypesForEntity = function (metadata, entityTypeUri) {
|
|
4
|
+
return getCreatableAttributeTypes(Mode.Suggesting, getFilteredAttrTypes(metadata, entityTypeUri, [], []));
|
|
5
|
+
};
|
|
6
|
+
export var getAvailableAttributeTypesForRelation = function (metadata, relationTypeUri) {
|
|
7
|
+
return getCreatableAttributeTypes(Mode.Suggesting, getRelationAttributesList(metadata, relationTypeUri));
|
|
8
|
+
};
|
|
9
|
+
export var getAvailableSubAttributesForNestedOrReference = function (metadata, attributeType) {
|
|
10
|
+
var subAttributes = isReference(attributeType)
|
|
11
|
+
? getEditableAttributeTypeSubAttributes(metadata, attributeType) || []
|
|
12
|
+
: getAttributeTypeSubAttributes(metadata, attributeType) || [];
|
|
13
|
+
return getCreatableAttributeTypes(Mode.Suggesting, subAttributes);
|
|
14
|
+
};
|
|
@@ -226,13 +226,13 @@ var getRequiredAttributeUris = function (metadata, typeUri) {
|
|
|
226
226
|
return requiredAttrTypes.map(function (attr) { return attr.uri; });
|
|
227
227
|
};
|
|
228
228
|
var createRequiredError = function (_a) {
|
|
229
|
-
var attributeType = _a.attributeType, attributeTypeUri = _a.attributeTypeUri, parentUri = _a.parentUri, lineIds = _a.lineIds, metadata = _a.metadata, entityUri = _a.entityUri, entitiesMap = _a.entitiesMap, valueUri = _a.valueUri;
|
|
229
|
+
var attributeType = _a.attributeType, attributeTypeUri = _a.attributeTypeUri, parentUri = _a.parentUri, lineIds = _a.lineIds, metadata = _a.metadata, entityUri = _a.entityUri, entitiesMap = _a.entitiesMap, valueUri = _a.valueUri, _b = _a.errorType, errorType = _b === void 0 ? ErrorType.missed : _b, _c = _a.message, message = _c === void 0 ? i18n.text('Attribute is required') : _c;
|
|
230
230
|
var error = buildError({
|
|
231
|
-
type:
|
|
231
|
+
type: errorType,
|
|
232
232
|
attributeType: attributeType,
|
|
233
233
|
attributeTypeUri: attributeTypeUri,
|
|
234
234
|
parentUri: parentUri,
|
|
235
|
-
message:
|
|
235
|
+
message: message,
|
|
236
236
|
source: ErrorSource.local,
|
|
237
237
|
uri: lineIds[0]
|
|
238
238
|
});
|
|
@@ -252,27 +252,37 @@ var createRequiredError = function (_a) {
|
|
|
252
252
|
var validateRequiredComplexAttributes = function (_a) {
|
|
253
253
|
var _b;
|
|
254
254
|
var metadata = _a.metadata, change = _a.change, userChanges = _a.userChanges, entityUri = _a.entityUri;
|
|
255
|
-
if (
|
|
255
|
+
if (change.type === DCRTypes.DELETE_ATTRIBUTE) {
|
|
256
256
|
return [];
|
|
257
257
|
}
|
|
258
258
|
var valueHolder = change.type === DCRTypes.CREATE_ENTITY || change.type === DCRTypes.CREATE_RELATIONSHIP ? 'attributes' : 'value';
|
|
259
259
|
var rootAttributeTypeUri = change.refAttributeType || change.attributeType || change.objectType;
|
|
260
|
+
if (!rootAttributeTypeUri) {
|
|
261
|
+
return [];
|
|
262
|
+
}
|
|
260
263
|
var attributeType = findAttributeTypeByUri(metadata, rootAttributeTypeUri);
|
|
261
264
|
var isReferenceType = isReference(attributeType);
|
|
262
|
-
var entityTypeUri = isReferenceType ? attributeType.relationshipTypeURI : getEntityTypeUriFromChange(change);
|
|
263
|
-
var requiredAttributeUris = getRequiredAttributeUris(metadata, entityTypeUri);
|
|
264
265
|
var calculateLineIdFromPath = function (path) {
|
|
265
266
|
if (path === void 0) { path = ''; }
|
|
266
267
|
var entityId = entityUri.split('/').pop() || '';
|
|
267
268
|
return "".concat(entityId, "/").concat(change.id, "/newValue").concat(path ? "/".concat(path) : '');
|
|
268
269
|
};
|
|
270
|
+
var entityTypeUri = isReferenceType ? attributeType.relationshipTypeURI : getEntityTypeUriFromChange(change);
|
|
271
|
+
var requiredAttributeUris = getRequiredAttributeUris(metadata, entityTypeUri);
|
|
269
272
|
var checkIsChangeRejected = function (path) {
|
|
270
273
|
var _a, _b, _c;
|
|
271
274
|
var searchLineId = calculateLineIdFromPath(path);
|
|
272
275
|
var lineUserChanges = userChanges.find(function (userChange) { return userChange.lineId === searchLineId; });
|
|
273
276
|
return (((_a = lineUserChanges === null || lineUserChanges === void 0 ? void 0 : lineUserChanges.data) === null || _a === void 0 ? void 0 : _a.isRejected) || (lineUserChanges && isEmptyValue((_c = (_b = lineUserChanges === null || lineUserChanges === void 0 ? void 0 : lineUserChanges.data) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.value)));
|
|
274
277
|
};
|
|
278
|
+
var checkHasUserValue = function (path) {
|
|
279
|
+
var _a, _b;
|
|
280
|
+
var searchLineId = calculateLineIdFromPath(path);
|
|
281
|
+
var lineUserChange = userChanges.find(function (userChange) { return userChange.lineId === searchLineId; });
|
|
282
|
+
return Boolean(lineUserChange && !isEmptyValue((_b = (_a = lineUserChange.data) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.value));
|
|
283
|
+
};
|
|
275
284
|
var collectErrors = function (attributes) {
|
|
285
|
+
var _a;
|
|
276
286
|
var errors = [];
|
|
277
287
|
var visitValue = function (value, path) {
|
|
278
288
|
var isRejected = checkIsChangeRejected(path.slice(0, -1).join('/'));
|
|
@@ -282,6 +292,9 @@ var validateRequiredComplexAttributes = function (_a) {
|
|
|
282
292
|
if (isRejected) {
|
|
283
293
|
return false;
|
|
284
294
|
}
|
|
295
|
+
if (value === undefined) {
|
|
296
|
+
return checkHasUserValue(path.slice(0, -1).join('/'));
|
|
297
|
+
}
|
|
285
298
|
var anyFieldHasValue = false;
|
|
286
299
|
Object.entries(value).forEach(function (_a) {
|
|
287
300
|
var fieldName = _a[0], subAttributes = _a[1];
|
|
@@ -319,6 +332,18 @@ var validateRequiredComplexAttributes = function (_a) {
|
|
|
319
332
|
lineIds: [calculateLineIdFromPath()]
|
|
320
333
|
}));
|
|
321
334
|
}
|
|
335
|
+
if (isReferenceType && change.type === DCRTypes.INSERT_ATTRIBUTE) {
|
|
336
|
+
var refEntity = (_a = change.newValue) === null || _a === void 0 ? void 0 : _a.refEntity;
|
|
337
|
+
if (!(refEntity === null || refEntity === void 0 ? void 0 : refEntity.objectURI)) {
|
|
338
|
+
errors.push(createRequiredError({
|
|
339
|
+
attributeType: attributeType,
|
|
340
|
+
attributeTypeUri: attributeType.uri,
|
|
341
|
+
lineIds: [calculateLineIdFromPath()],
|
|
342
|
+
errorType: ErrorType.missedRefEntity,
|
|
343
|
+
message: i18n.text('Entity is required')
|
|
344
|
+
}));
|
|
345
|
+
}
|
|
346
|
+
}
|
|
322
347
|
return errors;
|
|
323
348
|
};
|
|
324
349
|
return collectErrors((_b = change.newValue) === null || _b === void 0 ? void 0 : _b[valueHolder]);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ChangeRequest } from '@reltio/mdm-sdk';
|
|
2
|
-
import { BeforeActionOutcome } from '../types';
|
|
1
|
+
import { type ChangeRequest } from '@reltio/mdm-sdk';
|
|
2
|
+
import type { BeforeActionOutcome } from '../types';
|
|
3
3
|
export declare const useApplyDcrChanges: (dcr: ChangeRequest) => () => Promise<BeforeActionOutcome>;
|