@reltio/components 1.4.2243 → 1.4.2245

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 (217) hide show
  1. package/ActivenessDateControl/ActivenessDateControl.d.ts +9 -0
  2. package/ActivenessDateControl/ActivenessDateControl.js +11 -0
  3. package/ActivenessDateControl/index.d.ts +1 -0
  4. package/ActivenessDateControl/index.js +1 -0
  5. package/EntitySelector/EntitySelector.d.ts +2 -1
  6. package/EntitySelector/EntitySelector.js +2 -2
  7. package/EntitySelector/index.d.ts +1 -0
  8. package/MoreAttributesButton/MoreAttributesButton.d.ts +3 -2
  9. package/MoreAttributesButton/MoreAttributesButton.js +8 -8
  10. package/MoreAttributesButton/useMoreAttributesItems.d.ts +4 -4
  11. package/cjs/ActivenessDateControl/ActivenessDateControl.d.ts +9 -0
  12. package/cjs/ActivenessDateControl/ActivenessDateControl.js +18 -0
  13. package/cjs/ActivenessDateControl/index.d.ts +1 -0
  14. package/cjs/ActivenessDateControl/index.js +5 -0
  15. package/cjs/EntitySelector/EntitySelector.d.ts +2 -1
  16. package/cjs/EntitySelector/EntitySelector.js +2 -2
  17. package/cjs/EntitySelector/index.d.ts +1 -0
  18. package/cjs/MoreAttributesButton/MoreAttributesButton.d.ts +3 -2
  19. package/cjs/MoreAttributesButton/MoreAttributesButton.js +8 -8
  20. package/cjs/MoreAttributesButton/useMoreAttributesItems.d.ts +4 -4
  21. package/cjs/features/activity-log/ActivityLog/ActivityLog.test.js +28 -0
  22. package/cjs/features/activity-log/ActivityLog/components/ActivityItem/ActivityItem.js +22 -11
  23. package/cjs/features/activity-log/ActivityLog/components/ActivityItem/ActivityItem.module.css.js +9 -0
  24. package/cjs/features/activity-log/ActivityLog/constants.d.ts +17 -0
  25. package/cjs/features/activity-log/ActivityLog/constants.js +20 -0
  26. package/cjs/features/workflow/ChangeRequestEditor/ChangeRequestEditor.d.ts +1 -1
  27. package/cjs/features/workflow/ChangeRequestEditor/ChangeRequestEditor.js +20 -9
  28. package/cjs/features/workflow/ChangeRequestEditor/components/AddSameAttributeButton/AddSameAttributeButton.d.ts +7 -0
  29. package/cjs/features/workflow/ChangeRequestEditor/components/AddSameAttributeButton/AddSameAttributeButton.js +67 -0
  30. package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemLabel/ChangeItemLabel.js +3 -1
  31. package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemLabel/ChangeItemLabel.module.css.js +2 -2
  32. package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.d.ts +2 -2
  33. package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.js +31 -9
  34. package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.module.css.js +2 -2
  35. package/cjs/features/workflow/ChangeRequestEditor/components/DCRImageEditor/DCRImageEditor.d.ts +9 -0
  36. package/cjs/features/workflow/ChangeRequestEditor/components/DCRImageEditor/DCRImageEditor.js +79 -0
  37. package/cjs/features/workflow/ChangeRequestEditor/components/DCRImageEditor/index.d.ts +1 -0
  38. package/cjs/features/workflow/ChangeRequestEditor/components/DCRImageEditor/index.js +5 -0
  39. package/cjs/features/workflow/ChangeRequestEditor/components/DCRValueEditorFactory/DCRValueEditorFactory.d.ts +2 -2
  40. package/cjs/features/workflow/ChangeRequestEditor/components/DCRValueEditorFactory/DCRValueEditorFactory.js +2 -2
  41. package/cjs/features/workflow/ChangeRequestEditor/components/EditorStatusChip/EditorStatusChip.d.ts +11 -0
  42. package/cjs/features/workflow/ChangeRequestEditor/components/EditorStatusChip/EditorStatusChip.js +41 -0
  43. package/cjs/features/workflow/ChangeRequestEditor/components/EditorStatusChip/EditorStatusChip.module.css.js +9 -0
  44. package/cjs/features/workflow/ChangeRequestEditor/components/EditorStatusChip/index.d.ts +1 -0
  45. package/cjs/features/workflow/ChangeRequestEditor/components/EditorStatusChip/index.js +6 -0
  46. package/cjs/features/workflow/ChangeRequestEditor/components/EntityChangesGroup/EntityChangesGroup.d.ts +1 -1
  47. package/cjs/features/workflow/ChangeRequestEditor/components/EntityChangesGroup/EntityChangesGroup.js +134 -5
  48. package/cjs/features/workflow/ChangeRequestEditor/components/EntityChangesGroup/SkeletonEntityChangesGroupLoader.js +2 -2
  49. package/cjs/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemEditor}/ChangeItemEditor.d.ts +1 -1
  50. package/cjs/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditor/ChangeItemEditor.js +110 -0
  51. package/cjs/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditor/ChangeItemEditor.module.css.js +9 -0
  52. package/cjs/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemEditor}/SkeletonChangeItemEditorLoader.js +6 -5
  53. package/cjs/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemEditor}/index.d.ts +0 -1
  54. package/cjs/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemEditor}/index.js +1 -3
  55. package/cjs/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditorRecentlyAdded/ChangeItemEditorRecentlyAdded.d.ts +8 -0
  56. package/cjs/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditorRecentlyAdded/ChangeItemEditorRecentlyAdded.js +89 -0
  57. package/cjs/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditorRecentlyAdded/index.d.ts +1 -0
  58. package/cjs/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditorRecentlyAdded/index.js +5 -0
  59. package/cjs/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemOldValue}/ChangeItemOldValue.d.ts +1 -1
  60. package/cjs/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemOldValue}/ChangeItemOldValue.js +12 -11
  61. package/cjs/features/workflow/ChangeRequestEditor/components/editors/ChangeItemOldValue/ChangeItemOldValue.module.css.js +9 -0
  62. package/cjs/features/workflow/ChangeRequestEditor/components/editors/ChangeItemOldValue/index.d.ts +1 -0
  63. package/cjs/features/workflow/ChangeRequestEditor/components/editors/ChangeItemOldValue/index.js +5 -0
  64. package/cjs/features/workflow/ChangeRequestEditor/components/editors/MoreAttributesEditor/MoreAttributesEditor.d.ts +11 -0
  65. package/cjs/features/workflow/ChangeRequestEditor/components/editors/MoreAttributesEditor/MoreAttributesEditor.js +34 -0
  66. package/cjs/features/workflow/ChangeRequestEditor/components/editors/MoreAttributesEditor/MoreAttributesEditor.module.css.js +9 -0
  67. package/cjs/features/workflow/ChangeRequestEditor/components/editors/MoreAttributesEditor/index.d.ts +1 -0
  68. package/cjs/features/workflow/ChangeRequestEditor/components/editors/MoreAttributesEditor/index.js +5 -0
  69. package/cjs/features/workflow/ChangeRequestEditor/components/editors/editors.module.css.js +9 -0
  70. package/cjs/features/workflow/ChangeRequestEditor/components/editors/index.d.ts +4 -0
  71. package/cjs/features/workflow/ChangeRequestEditor/components/editors/index.js +12 -0
  72. package/cjs/features/workflow/ChangeRequestEditor/helpers/addedAttributes.d.ts +11 -0
  73. package/cjs/features/workflow/ChangeRequestEditor/helpers/addedAttributes.js +74 -0
  74. package/cjs/features/workflow/ChangeRequestEditor/helpers/changesList.d.ts +2 -0
  75. package/cjs/features/workflow/ChangeRequestEditor/helpers/changesList.js +157 -0
  76. package/cjs/features/workflow/ChangeRequestEditor/helpers/changesList.test.d.ts +1 -0
  77. package/cjs/features/workflow/ChangeRequestEditor/helpers/changesList.test.js +203 -0
  78. package/cjs/features/workflow/ChangeRequestEditor/helpers/helpers.d.ts +6 -3
  79. package/cjs/features/workflow/ChangeRequestEditor/helpers/helpers.js +22 -3
  80. package/cjs/features/workflow/ChangeRequestEditor/helpers/mergeAddedAttributesWithDCRChanges.d.ts +3 -0
  81. package/cjs/features/workflow/ChangeRequestEditor/helpers/mergeAddedAttributesWithDCRChanges.js +190 -0
  82. package/cjs/features/workflow/ChangeRequestEditor/helpers/mergeAddedAttributesWithDCRChanges.test.d.ts +1 -0
  83. package/cjs/features/workflow/ChangeRequestEditor/helpers/mergeAddedAttributesWithDCRChanges.test.js +768 -0
  84. package/cjs/features/workflow/ChangeRequestEditor/hooks/useChangeRequestEditor.d.ts +4 -3
  85. package/cjs/features/workflow/ChangeRequestEditor/hooks/useChangeRequestEditor.js +9 -1
  86. package/cjs/features/workflow/ChangeRequestEditor/hooks/useNewAttributesEditor.d.ts +18 -0
  87. package/cjs/features/workflow/ChangeRequestEditor/hooks/useNewAttributesEditor.js +65 -0
  88. package/cjs/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.js +7 -3
  89. package/cjs/features/workflow/contexts/AddedAttributesContext/index.d.ts +39 -0
  90. package/cjs/features/workflow/contexts/AddedAttributesContext/index.js +152 -0
  91. package/cjs/features/workflow/contexts/ChangeRequestEditorContext/index.d.ts +3 -2
  92. package/cjs/features/workflow/contexts/ChangeRequestEditorContext/index.js +47 -7
  93. package/cjs/features/workflow/contexts/ScrollToAddedAttributeContext/index.d.ts +11 -0
  94. package/cjs/features/workflow/contexts/ScrollToAddedAttributeContext/index.js +78 -0
  95. package/cjs/features/workflow/helpers/attributes.js +16 -13
  96. package/cjs/features/workflow/helpers/attributes.test.js +6 -3
  97. package/cjs/features/workflow/helpers/dcr.d.ts +6 -1
  98. package/cjs/features/workflow/helpers/dcr.js +123 -19
  99. package/cjs/features/workflow/helpers/dcr.test.js +171 -0
  100. package/cjs/features/workflow/helpers/merge.d.ts +3 -0
  101. package/cjs/features/workflow/helpers/merge.js +32 -20
  102. package/cjs/features/workflow/helpers/merge.test.js +2 -1
  103. package/cjs/features/workflow/helpers/moreAttributesScope.d.ts +4 -0
  104. package/cjs/features/workflow/helpers/moreAttributesScope.js +20 -0
  105. package/cjs/features/workflow/helpers/validation.js +31 -6
  106. package/cjs/features/workflow/hooks/useApplyDcrChanges.d.ts +2 -2
  107. package/cjs/features/workflow/hooks/useApplyDcrChanges.js +80 -63
  108. package/cjs/features/workflow/types.d.ts +12 -2
  109. package/features/activity-log/ActivityLog/ActivityLog.test.js +28 -0
  110. package/features/activity-log/ActivityLog/components/ActivityItem/ActivityItem.js +15 -4
  111. package/features/activity-log/ActivityLog/components/ActivityItem/ActivityItem.module.css.js +9 -0
  112. package/features/activity-log/ActivityLog/constants.d.ts +17 -0
  113. package/features/activity-log/ActivityLog/constants.js +17 -0
  114. package/features/workflow/ChangeRequestEditor/ChangeRequestEditor.d.ts +1 -1
  115. package/features/workflow/ChangeRequestEditor/ChangeRequestEditor.js +20 -9
  116. package/features/workflow/ChangeRequestEditor/components/AddSameAttributeButton/AddSameAttributeButton.d.ts +7 -0
  117. package/features/workflow/ChangeRequestEditor/components/AddSameAttributeButton/AddSameAttributeButton.js +37 -0
  118. package/features/workflow/ChangeRequestEditor/components/ChangeItemLabel/ChangeItemLabel.js +3 -1
  119. package/features/workflow/ChangeRequestEditor/components/ChangeItemLabel/ChangeItemLabel.module.css.js +2 -2
  120. package/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.d.ts +2 -2
  121. package/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.js +32 -10
  122. package/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.module.css.js +2 -2
  123. package/features/workflow/ChangeRequestEditor/components/DCRImageEditor/DCRImageEditor.d.ts +9 -0
  124. package/features/workflow/ChangeRequestEditor/components/DCRImageEditor/DCRImageEditor.js +49 -0
  125. package/features/workflow/ChangeRequestEditor/components/DCRImageEditor/index.d.ts +1 -0
  126. package/features/workflow/ChangeRequestEditor/components/DCRImageEditor/index.js +1 -0
  127. package/features/workflow/ChangeRequestEditor/components/DCRValueEditorFactory/DCRValueEditorFactory.d.ts +2 -2
  128. package/features/workflow/ChangeRequestEditor/components/DCRValueEditorFactory/DCRValueEditorFactory.js +2 -2
  129. package/features/workflow/ChangeRequestEditor/components/EditorStatusChip/EditorStatusChip.d.ts +11 -0
  130. package/features/workflow/ChangeRequestEditor/components/EditorStatusChip/EditorStatusChip.js +34 -0
  131. package/features/workflow/ChangeRequestEditor/components/EditorStatusChip/EditorStatusChip.module.css.js +9 -0
  132. package/features/workflow/ChangeRequestEditor/components/EditorStatusChip/index.d.ts +1 -0
  133. package/features/workflow/ChangeRequestEditor/components/EditorStatusChip/index.js +1 -0
  134. package/features/workflow/ChangeRequestEditor/components/EntityChangesGroup/EntityChangesGroup.d.ts +1 -1
  135. package/features/workflow/ChangeRequestEditor/components/EntityChangesGroup/EntityChangesGroup.js +112 -6
  136. package/features/workflow/ChangeRequestEditor/components/EntityChangesGroup/SkeletonEntityChangesGroupLoader.js +1 -1
  137. package/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemEditor}/ChangeItemEditor.d.ts +1 -1
  138. package/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditor/ChangeItemEditor.js +80 -0
  139. package/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditor/ChangeItemEditor.module.css.js +9 -0
  140. package/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemEditor}/SkeletonChangeItemEditorLoader.js +6 -5
  141. package/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemEditor}/index.d.ts +0 -1
  142. package/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemEditor}/index.js +0 -1
  143. package/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditorRecentlyAdded/ChangeItemEditorRecentlyAdded.d.ts +8 -0
  144. package/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditorRecentlyAdded/ChangeItemEditorRecentlyAdded.js +59 -0
  145. package/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditorRecentlyAdded/index.d.ts +1 -0
  146. package/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditorRecentlyAdded/index.js +1 -0
  147. package/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemOldValue}/ChangeItemOldValue.d.ts +1 -1
  148. package/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemOldValue}/ChangeItemOldValue.js +10 -9
  149. package/features/workflow/ChangeRequestEditor/components/editors/ChangeItemOldValue/ChangeItemOldValue.module.css.js +9 -0
  150. package/features/workflow/ChangeRequestEditor/components/editors/ChangeItemOldValue/index.d.ts +1 -0
  151. package/features/workflow/ChangeRequestEditor/components/editors/ChangeItemOldValue/index.js +1 -0
  152. package/features/workflow/ChangeRequestEditor/components/editors/MoreAttributesEditor/MoreAttributesEditor.d.ts +11 -0
  153. package/features/workflow/ChangeRequestEditor/components/editors/MoreAttributesEditor/MoreAttributesEditor.js +27 -0
  154. package/features/workflow/ChangeRequestEditor/components/editors/MoreAttributesEditor/MoreAttributesEditor.module.css.js +9 -0
  155. package/features/workflow/ChangeRequestEditor/components/editors/MoreAttributesEditor/index.d.ts +1 -0
  156. package/features/workflow/ChangeRequestEditor/components/editors/MoreAttributesEditor/index.js +1 -0
  157. package/features/workflow/ChangeRequestEditor/components/editors/editors.module.css.js +9 -0
  158. package/features/workflow/ChangeRequestEditor/components/editors/index.d.ts +4 -0
  159. package/features/workflow/ChangeRequestEditor/components/editors/index.js +4 -0
  160. package/features/workflow/ChangeRequestEditor/helpers/addedAttributes.d.ts +11 -0
  161. package/features/workflow/ChangeRequestEditor/helpers/addedAttributes.js +62 -0
  162. package/features/workflow/ChangeRequestEditor/helpers/changesList.d.ts +2 -0
  163. package/features/workflow/ChangeRequestEditor/helpers/changesList.js +153 -0
  164. package/features/workflow/ChangeRequestEditor/helpers/changesList.test.d.ts +1 -0
  165. package/features/workflow/ChangeRequestEditor/helpers/changesList.test.js +201 -0
  166. package/features/workflow/ChangeRequestEditor/helpers/helpers.d.ts +6 -3
  167. package/features/workflow/ChangeRequestEditor/helpers/helpers.js +19 -3
  168. package/features/workflow/ChangeRequestEditor/helpers/mergeAddedAttributesWithDCRChanges.d.ts +3 -0
  169. package/features/workflow/ChangeRequestEditor/helpers/mergeAddedAttributesWithDCRChanges.js +186 -0
  170. package/features/workflow/ChangeRequestEditor/helpers/mergeAddedAttributesWithDCRChanges.test.d.ts +1 -0
  171. package/features/workflow/ChangeRequestEditor/helpers/mergeAddedAttributesWithDCRChanges.test.js +766 -0
  172. package/features/workflow/ChangeRequestEditor/hooks/useChangeRequestEditor.d.ts +4 -3
  173. package/features/workflow/ChangeRequestEditor/hooks/useChangeRequestEditor.js +9 -1
  174. package/features/workflow/ChangeRequestEditor/hooks/useNewAttributesEditor.d.ts +18 -0
  175. package/features/workflow/ChangeRequestEditor/hooks/useNewAttributesEditor.js +61 -0
  176. package/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.js +7 -3
  177. package/features/workflow/contexts/AddedAttributesContext/index.d.ts +39 -0
  178. package/features/workflow/contexts/AddedAttributesContext/index.js +125 -0
  179. package/features/workflow/contexts/ChangeRequestEditorContext/index.d.ts +3 -2
  180. package/features/workflow/contexts/ChangeRequestEditorContext/index.js +47 -7
  181. package/features/workflow/contexts/ScrollToAddedAttributeContext/index.d.ts +11 -0
  182. package/features/workflow/contexts/ScrollToAddedAttributeContext/index.js +51 -0
  183. package/features/workflow/helpers/attributes.js +16 -13
  184. package/features/workflow/helpers/attributes.test.js +6 -3
  185. package/features/workflow/helpers/dcr.d.ts +6 -1
  186. package/features/workflow/helpers/dcr.js +122 -19
  187. package/features/workflow/helpers/dcr.test.js +172 -1
  188. package/features/workflow/helpers/merge.d.ts +3 -0
  189. package/features/workflow/helpers/merge.js +30 -19
  190. package/features/workflow/helpers/merge.test.js +2 -1
  191. package/features/workflow/helpers/moreAttributesScope.d.ts +4 -0
  192. package/features/workflow/helpers/moreAttributesScope.js +14 -0
  193. package/features/workflow/helpers/validation.js +31 -6
  194. package/features/workflow/hooks/useApplyDcrChanges.d.ts +2 -2
  195. package/features/workflow/hooks/useApplyDcrChanges.js +83 -66
  196. package/features/workflow/types.d.ts +12 -2
  197. package/package.json +2 -2
  198. package/cjs/features/activity-log/ActivityLog/components/ActivityItem/styles.d.ts +0 -1
  199. package/cjs/features/activity-log/ActivityLog/components/ActivityItem/styles.js +0 -57
  200. package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemEditor/ChangeItemEditor.js +0 -95
  201. package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemEditor/ChangeItemEditor.module.css.js +0 -9
  202. package/cjs/features/workflow/ChangeRequestEditor/components/StatusChips/StatusChips.d.ts +0 -7
  203. package/cjs/features/workflow/ChangeRequestEditor/components/StatusChips/StatusChips.js +0 -21
  204. package/cjs/features/workflow/ChangeRequestEditor/components/StatusChips/StatusChips.module.css.js +0 -9
  205. package/cjs/features/workflow/ChangeRequestEditor/components/StatusChips/index.d.ts +0 -1
  206. package/cjs/features/workflow/ChangeRequestEditor/components/StatusChips/index.js +0 -5
  207. package/features/activity-log/ActivityLog/components/ActivityItem/styles.d.ts +0 -1
  208. package/features/activity-log/ActivityLog/components/ActivityItem/styles.js +0 -54
  209. package/features/workflow/ChangeRequestEditor/components/ChangeItemEditor/ChangeItemEditor.js +0 -65
  210. package/features/workflow/ChangeRequestEditor/components/ChangeItemEditor/ChangeItemEditor.module.css.js +0 -9
  211. package/features/workflow/ChangeRequestEditor/components/StatusChips/StatusChips.d.ts +0 -7
  212. package/features/workflow/ChangeRequestEditor/components/StatusChips/StatusChips.js +0 -14
  213. package/features/workflow/ChangeRequestEditor/components/StatusChips/StatusChips.module.css.js +0 -9
  214. package/features/workflow/ChangeRequestEditor/components/StatusChips/index.d.ts +0 -1
  215. package/features/workflow/ChangeRequestEditor/components/StatusChips/index.js +0 -1
  216. /package/cjs/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemEditor}/SkeletonChangeItemEditorLoader.d.ts +0 -0
  217. /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) {
@@ -41,11 +84,12 @@ export var createEntityRelationsObjectByRelation = curry(function (objectsInfo,
41
84
  return entity ? { entity: __assign(__assign({}, entity), { uri: relation.startObjectUri }), relations: relations } : { relations: relations };
42
85
  });
43
86
  export var concatEntityRelationsObjects = function (acc, object) {
87
+ var _a, _b;
44
88
  var entity = object.entity, relations = object.relations;
45
89
  var entityUri = entity.uri;
46
90
  var mergedRelations = pipe(pathOr([], [entityUri, 'relations']), concat(relations), uniq)(acc);
47
91
  acc[entityUri] = {
48
- entity: entity,
92
+ entity: (_b = (_a = acc[entityUri]) === null || _a === void 0 ? void 0 : _a.entity) !== null && _b !== void 0 ? _b : entity,
49
93
  relations: mergedRelations
50
94
  };
51
95
  return acc;
@@ -57,7 +101,7 @@ export var isCreateEntityOperation = function (dcr) {
57
101
  return dcr.type === DCRTypes.CREATE_ENTITY;
58
102
  };
59
103
  var cleanValueRecursively = function (value) {
60
- if (typeof value === 'string' || isEmpty(value)) {
104
+ if (isNil(value) || typeof value === 'string' || isEmpty(value)) {
61
105
  return value;
62
106
  }
63
107
  var cleanedProperties = map(function (propertyValues) {
@@ -69,7 +113,7 @@ var cleanValueRecursively = function (value) {
69
113
  })
70
114
  .filter(function (item) {
71
115
  var itemValue = item.value;
72
- return !isEmpty(itemValue) && !isNil(itemValue);
116
+ return (!isEmpty(itemValue) && !isNil(itemValue)) || 'lookupCode' in item;
73
117
  });
74
118
  }, value);
75
119
  return filter(function (propertyValues) { return !isEmpty(propertyValues); }, cleanedProperties);
@@ -109,12 +153,16 @@ var calculateValuePath = function (key, change) {
109
153
  case DCRTypes.UPDATE_END_DATE:
110
154
  return __spreadArray(__spreadArray([], path, true), [0], false);
111
155
  case DCRTypes.CREATE_RELATIONSHIP:
156
+ case DCRTypes.CREATE_ENTITY:
112
157
  if (path.length === 2) {
113
- if (path[1] === 'activeness.startDate') {
114
- return [path[0], 'startDate'];
115
- }
116
- if (path[1] === 'activeness.endDate') {
117
- return [path[0], 'endDate'];
158
+ switch (path[1]) {
159
+ case 'roles':
160
+ case 'tags':
161
+ return path;
162
+ case 'activeness.startDate':
163
+ return [path[0], 'startDate'];
164
+ case 'activeness.endDate':
165
+ return [path[0], 'endDate'];
118
166
  }
119
167
  }
120
168
  return __spreadArray(__spreadArray([], path, true), ['value'], false);
@@ -123,6 +171,12 @@ var calculateValuePath = function (key, change) {
123
171
  }
124
172
  };
125
173
  var valuesAreEqual = function (oldValue, newValue) {
174
+ if (typeof oldValue === 'object' &&
175
+ typeof newValue === 'object' &&
176
+ !Array.isArray(oldValue) &&
177
+ !Array.isArray(newValue)) {
178
+ return equals(oldValue, newValue);
179
+ }
126
180
  var sortWithLocale = function (array) { return array.slice().sort(function (a, b) { return a.localeCompare(b); }); };
127
181
  if (Array.isArray(oldValue) && Array.isArray(newValue)) {
128
182
  return oldValue.length === newValue.length && equals(sortWithLocale(oldValue), sortWithLocale(newValue));
@@ -143,6 +197,7 @@ export var buildDCRSavePlan = function (changes, getLinesByChangeId, metadata) {
143
197
  var rejectedChangeIds = [];
144
198
  var updatedChanges = {};
145
199
  var deleteAttributes = {};
200
+ var insertAttributes = {};
146
201
  for (var _i = 0, _c = Object.entries(changes); _i < _c.length; _i++) {
147
202
  var _d = _c[_i], objectUri = _d[0], objectChanges = _d[1];
148
203
  var rawChanges = new Map();
@@ -152,18 +207,28 @@ export var buildDCRSavePlan = function (changes, getLinesByChangeId, metadata) {
152
207
  var key = _a[0], lineData = _a[1];
153
208
  return key.split('/').length === 3 &&
154
209
  (lineData.isRejected ||
155
- (isEmpty((_b = lineData.value) === null || _b === void 0 ? void 0 : _b.value) && change.type !== DCRTypes.UPDATE_ATTRIBUTE));
210
+ (isEmptyValue((_b = lineData.value) === null || _b === void 0 ? void 0 : _b.value) && change.type !== DCRTypes.UPDATE_ATTRIBUTE));
156
211
  }))(change), rejectedRootLines = _h[0], otherLines = _h[1];
157
- rejectedChangeIds.push.apply(rejectedChangeIds, rejectedRootLines.map(function (_a) {
158
- var key = _a[0];
159
- return key.split('/')[1];
160
- }));
212
+ var isNew = isAddedChange(change.id);
213
+ if (!isNew) {
214
+ rejectedChangeIds.push.apply(rejectedChangeIds, rejectedRootLines.map(function (_a) {
215
+ var key = _a[0];
216
+ return key.split('/')[1];
217
+ }));
218
+ }
219
+ var newValueObj = change.newValue;
220
+ var hasNonEmptyNewValue = Array.isArray(change.newValue) ||
221
+ !isEmptyValue(newValueObj === null || newValueObj === void 0 ? void 0 : newValueObj.value) ||
222
+ 'lookupCode' in (newValueObj !== null && newValueObj !== void 0 ? newValueObj : {});
223
+ if (isNew && otherLines.length === 0 && rejectedRootLines.length === 0 && hasNonEmptyNewValue) {
224
+ rawChanges.set(change.id, change);
225
+ }
161
226
  var rejectedRootLinesMap = new Map(rejectedRootLines);
162
227
  for (var _j = 0, otherLines_1 = otherLines; _j < otherLines_1.length; _j++) {
163
228
  var _k = otherLines_1[_j], key = _k[0], lineData = _k[1];
164
229
  var rootId = key.split('/').slice(0, 3).join('/');
165
230
  var newValue = (_a = lineData.value) === null || _a === void 0 ? void 0 : _a.value;
166
- if (rootId === key && change.type === DCRTypes.UPDATE_ATTRIBUTE && isEmpty(newValue)) {
231
+ if (!isNew && rootId === key && change.type === DCRTypes.UPDATE_ATTRIBUTE && isEmptyValue(newValue)) {
167
232
  var attributeUri = [objectUri, 'attributes', change.attributePath].join('/');
168
233
  var entry = __assign(__assign({}, createEntryDeleteAttribute({ uri: attributeUri })[0]), (change.crosswalk && { crosswalk: change.crosswalk }));
169
234
  deleteAttributes[objectUri] = uniqBy(prop('uri'), append(entry, propOr([], objectUri, deleteAttributes)));
@@ -175,18 +240,28 @@ export var buildDCRSavePlan = function (changes, getLinesByChangeId, metadata) {
175
240
  var oldValue = getOldValueByNewValuePath(valuePath, change);
176
241
  var initialChange = rawChanges.has(change.id) ? rawChanges.get(change.id) : change;
177
242
  var updatedChange = void 0;
178
- if (lineData.isRejected || isEmpty(newValue)) {
243
+ if (lineData.isRejected || isEmptyValue(newValue)) {
179
244
  updatedChange = assocPath(valuePath, null, initialChange);
180
245
  }
181
246
  else if (!valuesAreEqual(oldDCRValue, newValue)) {
182
247
  if (oldValue && valuesAreEqual(oldValue, newValue)) {
183
- rejectedChangeIds.push(change.id);
248
+ if (!isNew) {
249
+ rejectedChangeIds.push(change.id);
250
+ }
184
251
  }
185
252
  else {
186
253
  var processedNewValue = typeof oldDCRValue === 'string' && typeof newValue === 'number'
187
254
  ? newValue.toString()
188
255
  : newValue;
189
256
  updatedChange = assocPath(valuePath, processedNewValue, initialChange);
257
+ var lineValue = lineData.value;
258
+ if (lineValue && typeof lineValue === 'object' && 'lookupCode' in lineValue) {
259
+ var parentPath = valuePath.slice(0, -1);
260
+ updatedChange = assocPath(__spreadArray(__spreadArray([], parentPath, true), ['lookupCode'], false), lineValue.lookupCode, updatedChange);
261
+ if ('lookupRawValue' in lineValue) {
262
+ updatedChange = assocPath(__spreadArray(__spreadArray([], parentPath, true), ['lookupRawValue'], false), lineValue.lookupRawValue, updatedChange);
263
+ }
264
+ }
190
265
  }
191
266
  }
192
267
  if (updatedChange) {
@@ -205,7 +280,15 @@ export var buildDCRSavePlan = function (changes, getLinesByChangeId, metadata) {
205
280
  var isNestedChange = has('attributeType', cleanedChange) &&
206
281
  isNested(findAttributeTypeByUri(metadata, cleanedChange.attributeType));
207
282
  if (isNestedChange && isEmpty((_b = cleanedChange.newValue) === null || _b === void 0 ? void 0 : _b.value)) {
208
- rejectedChangeIds.push(cleanedChange.id);
283
+ if (!isAddedChange(cleanedChange.id)) {
284
+ rejectedChangeIds.push(cleanedChange.id);
285
+ }
286
+ }
287
+ else if (isAddedChange(cleanedChange.id)) {
288
+ var diffEntry = dcrChangeToInsertDiffEntry(cleanedChange, objectUri, metadata);
289
+ if (diffEntry) {
290
+ insertAttributes[objectUri] = append(diffEntry, propOr([], objectUri, insertAttributes));
291
+ }
209
292
  }
210
293
  else {
211
294
  updatedChanges[objectUri] = append(cleanedChange, propOr([], objectUri, updatedChanges));
@@ -220,10 +303,30 @@ export var buildDCRSavePlan = function (changes, getLinesByChangeId, metadata) {
220
303
  }, toPairs(deleteAttributes));
221
304
  var deleteRelationAttributes = fromPairs(deleteAttributesGroups.relation || []);
222
305
  var deleteEntityAttributes = fromPairs(deleteAttributesGroups.entity || []);
306
+ var insertAttributesGroups = groupBy(function (_a) {
307
+ var uri = _a[0];
308
+ return (isRelationUri(uri) ? 'relation' : 'entity');
309
+ }, toPairs(insertAttributes));
310
+ var insertRelationAttributes = fromPairs(insertAttributesGroups.relation || []);
311
+ var insertEntityAttributes = fromPairs(insertAttributesGroups.entity || []);
223
312
  return {
224
313
  rejectedChangeIds: rejectedChangeIds,
225
314
  updatedChanges: updatedChanges,
226
315
  deleteEntityAttributes: deleteEntityAttributes,
227
- deleteRelationAttributes: deleteRelationAttributes
316
+ deleteRelationAttributes: deleteRelationAttributes,
317
+ insertEntityAttributes: insertEntityAttributes,
318
+ insertRelationAttributes: insertRelationAttributes
228
319
  };
229
320
  };
321
+ export var mergeExistingRolesAndTags = function (diff, entity) {
322
+ return diff.map(function (entry) {
323
+ var _a, _b;
324
+ if (entry.type === EventType.UPDATE_TAGS && ((_a = entity.tags) === null || _a === void 0 ? void 0 : _a.length)) {
325
+ return __assign(__assign({}, entry), { newValue: uniq(__spreadArray(__spreadArray([], entity.tags, true), entry.newValue, true)) });
326
+ }
327
+ if (entry.type === EventType.UPDATE_ROLES && ((_b = entity.roles) === null || _b === void 0 ? void 0 : _b.length)) {
328
+ return __assign(__assign({}, entry), { newValue: uniq(__spreadArray(__spreadArray([], entity.roles, true), entry.newValue, true)) });
329
+ }
330
+ return entry;
331
+ });
332
+ };
@@ -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: {} };
@@ -126,6 +126,55 @@ describe('dcr helpers tests', function () {
126
126
  'entities/10f6Jabc': objects[3]
127
127
  });
128
128
  });
129
+ it('concatEntityRelationsObjects preserves existing entity when duplicate uri appears', function () {
130
+ var originalEntity = {
131
+ uri: 'entities/10f6JMNk',
132
+ isExist: true,
133
+ label: 'Test Label',
134
+ secondaryLabel: '',
135
+ type: 'configuration/entityTypes/Type'
136
+ };
137
+ var fetchedEntity = {
138
+ uri: 'entities/10f6JMNk',
139
+ type: 'configuration/entityTypes/Type',
140
+ label: 'Test Label',
141
+ secondaryLabel: '',
142
+ roles: ['configuration/roles/Admin']
143
+ };
144
+ var objects = [
145
+ {
146
+ entity: originalEntity,
147
+ relations: [
148
+ {
149
+ uri: 'relations/rel1',
150
+ type: 'configuration/relationTypes/HasAddress',
151
+ startObjectUri: 'entities/10f6JMNk',
152
+ startObjectLabel: 'label 1',
153
+ endObjectUri: 'entities/abc',
154
+ endObjectLabel: 'label 2',
155
+ isExist: true
156
+ }
157
+ ]
158
+ },
159
+ {
160
+ entity: fetchedEntity,
161
+ relations: [
162
+ {
163
+ uri: 'relations/rel2',
164
+ type: 'configuration/relationTypes/HasAddress',
165
+ startObjectUri: 'entities/10f6JMNk',
166
+ startObjectLabel: 'label 1',
167
+ endObjectUri: 'entities/def',
168
+ endObjectLabel: 'label 3',
169
+ isExist: true
170
+ }
171
+ ]
172
+ }
173
+ ];
174
+ var result = objects.reduce(function (acc, object) { return concatEntityRelationsObjects(acc, object); }, {});
175
+ expect(result['entities/10f6JMNk'].entity).toBe(originalEntity);
176
+ expect(result['entities/10f6JMNk'].relations).toEqual([objects[1].relations[0], objects[0].relations[0]]);
177
+ });
129
178
  it('getEntityUriForChangeRequest behaviour', function () {
130
179
  expect(getEntityUriForChangeRequest('dcrUri', 'entityUri')).toBe('dcrUri/changes/entityUri');
131
180
  });
@@ -144,4 +193,126 @@ describe('dcr helpers tests', function () {
144
193
  expect(isCreateEntityOperation(change)).toBe(true);
145
194
  expect(isCreateEntityOperation(__assign(__assign({}, change), { type: DCRTypes.CREATE_RELATIONSHIP }))).toBe(false);
146
195
  });
196
+ describe('buildDCRSavePlan', function () {
197
+ var emptyMetadata = { entityTypes: [], relationTypes: [] };
198
+ var noLineData = function () { return []; };
199
+ var emptyPlan = {
200
+ rejectedChangeIds: [],
201
+ updatedChanges: {},
202
+ deleteEntityAttributes: {},
203
+ deleteRelationAttributes: {},
204
+ insertEntityAttributes: {},
205
+ insertRelationAttributes: {}
206
+ };
207
+ it('should include added attribute with defaultValue when no lineData exists', function () {
208
+ var changes = {
209
+ 'entities/456': [
210
+ {
211
+ id: 'added|simple1',
212
+ type: DCRTypes.INSERT_ATTRIBUTE,
213
+ attributePath: 'Surname',
214
+ attributeType: 'configuration/entityTypes/HCP/attributes/Surname',
215
+ newValue: { value: 'DefaultSurname' }
216
+ }
217
+ ]
218
+ };
219
+ var result = buildDCRSavePlan(changes, noLineData, emptyMetadata);
220
+ expect(result).toEqual(__assign(__assign({}, emptyPlan), { insertEntityAttributes: {
221
+ 'entities/456': [
222
+ {
223
+ type: 'INSERT_ATTRIBUTE',
224
+ uri: 'entities/456/attributes/Surname',
225
+ newValue: [{ value: 'DefaultSurname' }]
226
+ }
227
+ ]
228
+ } }));
229
+ });
230
+ it('should include added lookup attribute with lookupCode when no lineData exists', function () {
231
+ var changes = {
232
+ 'entities/456': [
233
+ {
234
+ id: 'added|lookup1',
235
+ type: DCRTypes.INSERT_ATTRIBUTE,
236
+ attributePath: 'Country',
237
+ attributeType: 'configuration/entityTypes/HCP/attributes/Country',
238
+ newValue: { value: '', lookupCode: 'ALBY' }
239
+ }
240
+ ]
241
+ };
242
+ var result = buildDCRSavePlan(changes, noLineData, emptyMetadata);
243
+ expect(result).toEqual(__assign(__assign({}, emptyPlan), { insertEntityAttributes: {
244
+ 'entities/456': [
245
+ {
246
+ type: 'INSERT_ATTRIBUTE',
247
+ uri: 'entities/456/attributes/Country',
248
+ newValue: [{ value: '', lookupCode: 'ALBY' }]
249
+ }
250
+ ]
251
+ } }));
252
+ });
253
+ it('should preserve lookup sub-attribute with lookupCode inside nested parent', function () {
254
+ var metadata = {
255
+ entityTypes: [
256
+ {
257
+ uri: 'configuration/entityTypes/HCP',
258
+ attributes: [
259
+ {
260
+ uri: 'configuration/entityTypes/HCP/attributes/Details',
261
+ name: 'Details',
262
+ type: 'Nested',
263
+ attributes: [
264
+ {
265
+ uri: 'configuration/entityTypes/HCP/attributes/Details/attributes/Country',
266
+ name: 'Country',
267
+ type: 'String'
268
+ },
269
+ {
270
+ uri: 'configuration/entityTypes/HCP/attributes/Details/attributes/Notes',
271
+ name: 'Notes',
272
+ type: 'String'
273
+ }
274
+ ]
275
+ }
276
+ ]
277
+ }
278
+ ]
279
+ };
280
+ var changes = {
281
+ 'entities/456': [
282
+ {
283
+ id: 'added|nested1',
284
+ type: DCRTypes.INSERT_ATTRIBUTE,
285
+ attributePath: 'Details',
286
+ attributeType: 'configuration/entityTypes/HCP/attributes/Details',
287
+ newValue: {
288
+ value: {
289
+ Country: [{ value: '', lookupCode: 'ALBY' }],
290
+ Notes: [{ value: '' }]
291
+ }
292
+ }
293
+ }
294
+ ]
295
+ };
296
+ var notesLineData = [
297
+ ['456/added|nested1/newValue/value/Notes/0', { value: { value: 'User typed note' } }]
298
+ ];
299
+ var result = buildDCRSavePlan(changes, function (changeId) { return (changeId === 'added|nested1' ? notesLineData : []); }, metadata);
300
+ expect(result).toEqual(__assign(__assign({}, emptyPlan), { insertEntityAttributes: {
301
+ 'entities/456': [
302
+ {
303
+ type: 'INSERT_ATTRIBUTE',
304
+ uri: 'entities/456/attributes/Details',
305
+ newValue: [
306
+ {
307
+ value: {
308
+ Country: [{ value: '', lookupCode: 'ALBY' }],
309
+ Notes: [{ value: 'User typed note' }]
310
+ }
311
+ }
312
+ ]
313
+ }
314
+ ]
315
+ } }));
316
+ });
317
+ });
147
318
  });
@@ -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
+ };