@reltio/components 1.4.2243 → 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.
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 +25 -6
  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 +113 -18
  99. package/cjs/features/workflow/helpers/dcr.test.js +122 -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 +26 -7
  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 +112 -18
  187. package/features/workflow/helpers/dcr.test.js +123 -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
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.prepareChangesList = void 0;
15
+ var mdm_sdk_1 = require("@reltio/mdm-sdk");
16
+ var common_1 = require("../../helpers/common");
17
+ var helpers_1 = require("./helpers");
18
+ var getImageOperation = function (diff) {
19
+ var _a;
20
+ var innerChange = (_a = diff.attributeValue) === null || _a === void 0 ? void 0 : _a.value;
21
+ return (innerChange === null || innerChange === void 0 ? void 0 : innerChange.type) ? (0, common_1.getOperationType)(innerChange.type) : undefined;
22
+ };
23
+ var filterImageSubAttributes = function (rawChangesList) {
24
+ var filtered = [];
25
+ var skipBelowLevel = null;
26
+ for (var _i = 0, rawChangesList_1 = rawChangesList; _i < rawChangesList_1.length; _i++) {
27
+ var item = rawChangesList_1[_i];
28
+ if (!(0, helpers_1.isDiffChange)(item)) {
29
+ skipBelowLevel = null;
30
+ filtered.push(item);
31
+ continue;
32
+ }
33
+ var diff = item;
34
+ if (skipBelowLevel !== null && diff.level > skipBelowLevel) {
35
+ continue;
36
+ }
37
+ skipBelowLevel = null;
38
+ if ((0, mdm_sdk_1.isImage)(diff.attributeType)) {
39
+ skipBelowLevel = diff.level;
40
+ }
41
+ filtered.push(item);
42
+ }
43
+ return filtered;
44
+ };
45
+ var withImageOperation = function (items) {
46
+ return items.map(function (item) {
47
+ if (!(0, helpers_1.isDiffChange)(item) || !(0, mdm_sdk_1.isImage)(item.attributeType))
48
+ return item;
49
+ var operation = getImageOperation(item);
50
+ return operation ? __assign(__assign({}, item), { operation: operation }) : item;
51
+ });
52
+ };
53
+ var isSameGroup = function (a, b) {
54
+ var _a, _b;
55
+ return a.operation === mdm_sdk_1.DCROperationTypes.ADDED &&
56
+ b.operation === mdm_sdk_1.DCROperationTypes.ADDED &&
57
+ ((_a = a.attributeType) === null || _a === void 0 ? void 0 : _a.uri) === ((_b = b.attributeType) === null || _b === void 0 ? void 0 : _b.uri) &&
58
+ a.level === b.level;
59
+ };
60
+ var canAddSameAttribute = function (attributeType) {
61
+ var _a;
62
+ if (!attributeType)
63
+ return false;
64
+ if (attributeType.singleValue)
65
+ return false;
66
+ if (((_a = attributeType.cardinality) === null || _a === void 0 ? void 0 : _a.maxValue) === 1)
67
+ return false;
68
+ if ((0, mdm_sdk_1.isRoleAttrType)(attributeType) || (0, mdm_sdk_1.isTagAttrType)(attributeType))
69
+ return false;
70
+ return true;
71
+ };
72
+ var withDisplayOptions = function (items) {
73
+ return items.map(function (item, i) {
74
+ if (!(0, helpers_1.isDiffChange)(item))
75
+ return item;
76
+ if (item.operation !== mdm_sdk_1.DCROperationTypes.ADDED) {
77
+ return __assign(__assign({}, item), { displayOptions: {
78
+ showLabel: item.operation !== mdm_sdk_1.DCROperationTypes.EDITED,
79
+ showAddButton: false,
80
+ hasSameAttributeSiblings: false
81
+ } });
82
+ }
83
+ var prev = items[i - 1];
84
+ var next = items[i + 1];
85
+ var hasPrevSibling = !!prev && (0, helpers_1.isDiffChange)(prev) && isSameGroup(prev, item);
86
+ var hasNextSibling = !!next && (0, helpers_1.isDiffChange)(next) && isSameGroup(item, next);
87
+ return __assign(__assign({}, item), { displayOptions: {
88
+ showLabel: !hasPrevSibling,
89
+ showAddButton: canAddSameAttribute(item.attributeType) && !hasNextSibling,
90
+ hasSameAttributeSiblings: hasPrevSibling || hasNextSibling
91
+ } });
92
+ });
93
+ };
94
+ var truncateAtSegment = function (source, segment) {
95
+ var index = source.indexOf(segment);
96
+ return index >= 0 ? source.substring(0, index + segment.length) : undefined;
97
+ };
98
+ var findDescendantWithPath = function (items, fromIndex, parentLevel) {
99
+ for (var j = fromIndex + 1; j < items.length; j++) {
100
+ var next = items[j];
101
+ if (!(0, helpers_1.isDiffChange)(next) || next.level <= parentLevel)
102
+ break;
103
+ if (next.attributePath)
104
+ return next;
105
+ }
106
+ return undefined;
107
+ };
108
+ var deriveParentPath = function (descendant, name, instanceId) {
109
+ var segment = "".concat(name, "/").concat(instanceId);
110
+ var result = {};
111
+ var attributePath = truncateAtSegment(descendant.attributePath, segment);
112
+ if (attributePath) {
113
+ result.attributePath = attributePath;
114
+ }
115
+ if (descendant.refAttributeType) {
116
+ var refAttributeType = truncateAtSegment(descendant.refAttributeType, "/attributes/".concat(name));
117
+ if (refAttributeType) {
118
+ result.refAttributeType = refAttributeType;
119
+ }
120
+ }
121
+ if (descendant.refObjectURI) {
122
+ result.refObjectURI = descendant.refObjectURI;
123
+ }
124
+ return Object.keys(result).length > 0 ? result : null;
125
+ };
126
+ var extractPathFromInnerChange = function (attributeValue) {
127
+ var inner = attributeValue === null || attributeValue === void 0 ? void 0 : attributeValue.value;
128
+ if (!(inner === null || inner === void 0 ? void 0 : inner.attributePath))
129
+ return null;
130
+ return __assign(__assign({ attributePath: inner.attributePath }, (inner.refAttributeType && { refAttributeType: inner.refAttributeType })), (inner.refObjectURI && { refObjectURI: inner.refObjectURI }));
131
+ };
132
+ var fillParentPaths = function (items) {
133
+ return items.map(function (item, index) {
134
+ var _a, _b;
135
+ if (!(0, helpers_1.isDiffChange)(item) || !(0, mdm_sdk_1.isComplexAttribute)(item.attributeType) || item.attributePath)
136
+ return item;
137
+ var innerPath = extractPathFromInnerChange(item.attributeValue);
138
+ if (innerPath)
139
+ return __assign(__assign({}, item), innerPath);
140
+ var name = (_a = item.attributeType) === null || _a === void 0 ? void 0 : _a.name;
141
+ var instanceId = (_b = item.attributeValue) === null || _b === void 0 ? void 0 : _b.id;
142
+ if (!name || !instanceId)
143
+ return item;
144
+ var descendant = findDescendantWithPath(items, index, item.level);
145
+ if (!descendant)
146
+ return item;
147
+ var parentPath = deriveParentPath(descendant, name, instanceId);
148
+ return parentPath ? __assign(__assign({}, item), parentPath) : item;
149
+ });
150
+ };
151
+ var prepareChangesList = function (rawChangesList) {
152
+ var withPaths = fillParentPaths(rawChangesList);
153
+ var filtered = filterImageSubAttributes(withPaths);
154
+ var withOperations = withImageOperation(filtered);
155
+ return withDisplayOptions(withOperations);
156
+ };
157
+ exports.prepareChangesList = prepareChangesList;
@@ -0,0 +1,203 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ var mdm_sdk_1 = require("@reltio/mdm-sdk");
15
+ var changesList_1 = require("./changesList");
16
+ var createDiff = function (overrides) {
17
+ if (overrides === void 0) { overrides = {}; }
18
+ return (__assign({ level: 0, label: 'Test', attributeType: {
19
+ uri: 'configuration/entityTypes/HCP/attributes/Name',
20
+ name: 'Name',
21
+ label: 'Name',
22
+ type: 'String'
23
+ } }, overrides));
24
+ };
25
+ var createTitle = function (label) { return ({ label: label }); };
26
+ describe('prepareChangesList', function () {
27
+ describe('filterImageSubAttributes', function () {
28
+ it('should filter sub-attributes of image type attributes', function () {
29
+ var imageAttr = createDiff({
30
+ level: 0,
31
+ label: 'Photo',
32
+ attributeType: {
33
+ uri: 'attr/Photo',
34
+ name: 'Photo',
35
+ label: 'Photo',
36
+ type: mdm_sdk_1.DataTypes.TYPE_IMAGE
37
+ }
38
+ });
39
+ var imageSub1 = createDiff({ level: 1, label: 'FileName' });
40
+ var imageSub2 = createDiff({ level: 1, label: 'FileSize' });
41
+ var normalAttr = createDiff({ level: 0, label: 'Name' });
42
+ var result = (0, changesList_1.prepareChangesList)([imageAttr, imageSub1, imageSub2, normalAttr]);
43
+ var labels = result.map(function (item) { return item.label; });
44
+ expect(labels).toContain('Photo');
45
+ expect(labels).toContain('Name');
46
+ expect(labels).not.toContain('FileName');
47
+ expect(labels).not.toContain('FileSize');
48
+ });
49
+ it('should keep non-image nested attributes and their children unchanged', function () {
50
+ var nested = createDiff({
51
+ level: 0,
52
+ label: 'Details',
53
+ attributeType: { uri: 'attr/Details', name: 'Details', label: 'Details', type: 'Nested' }
54
+ });
55
+ var child = createDiff({ level: 1, label: 'Notes' });
56
+ var result = (0, changesList_1.prepareChangesList)([nested, child]);
57
+ expect(result).toHaveLength(2);
58
+ });
59
+ it('should reset image skip when a Title item is encountered', function () {
60
+ var imageAttr = createDiff({
61
+ level: 0,
62
+ label: 'Photo',
63
+ attributeType: {
64
+ uri: 'attr/Photo',
65
+ name: 'Photo',
66
+ label: 'Photo',
67
+ type: mdm_sdk_1.DataTypes.TYPE_IMAGE
68
+ }
69
+ });
70
+ var imageSub = createDiff({ level: 1, label: 'FileName' });
71
+ var title = createTitle('Section');
72
+ var normalAttr = createDiff({ level: 1, label: 'Name' });
73
+ var result = (0, changesList_1.prepareChangesList)([imageAttr, imageSub, title, normalAttr]);
74
+ var labels = result.map(function (item) { return item.label; });
75
+ expect(labels).toEqual(['Photo', 'Section', 'Name']);
76
+ });
77
+ });
78
+ describe('displayOptions', function () {
79
+ it('should set showLabel=true for first ADDED item in a group', function () {
80
+ var _a, _b;
81
+ var attrType = {
82
+ uri: 'configuration/entityTypes/HCP/attributes/Name',
83
+ name: 'Name',
84
+ label: 'Name',
85
+ type: 'String'
86
+ };
87
+ var diff1 = createDiff({ operation: mdm_sdk_1.DCROperationTypes.ADDED, attributeType: attrType, level: 0 });
88
+ var diff2 = createDiff({ operation: mdm_sdk_1.DCROperationTypes.ADDED, attributeType: attrType, level: 0 });
89
+ var result = (0, changesList_1.prepareChangesList)([diff1, diff2]);
90
+ expect((_a = result[0].displayOptions) === null || _a === void 0 ? void 0 : _a.showLabel).toBe(true);
91
+ expect((_b = result[1].displayOptions) === null || _b === void 0 ? void 0 : _b.showLabel).toBe(false);
92
+ });
93
+ it('should set showAddButton=true only for last ADDED item in group of multi-value attr', function () {
94
+ var _a, _b;
95
+ var attrType = {
96
+ uri: 'configuration/entityTypes/HCP/attributes/Name',
97
+ name: 'Name',
98
+ label: 'Name',
99
+ type: 'String'
100
+ };
101
+ var diff1 = createDiff({ operation: mdm_sdk_1.DCROperationTypes.ADDED, attributeType: attrType, level: 0 });
102
+ var diff2 = createDiff({ operation: mdm_sdk_1.DCROperationTypes.ADDED, attributeType: attrType, level: 0 });
103
+ var result = (0, changesList_1.prepareChangesList)([diff1, diff2]);
104
+ expect((_a = result[0].displayOptions) === null || _a === void 0 ? void 0 : _a.showAddButton).toBe(false);
105
+ expect((_b = result[1].displayOptions) === null || _b === void 0 ? void 0 : _b.showAddButton).toBe(true);
106
+ });
107
+ it('should set showAddButton=false for single-value attributes', function () {
108
+ var _a;
109
+ var attrType = {
110
+ uri: 'configuration/entityTypes/HCP/attributes/Id',
111
+ name: 'Id',
112
+ label: 'Id',
113
+ type: 'String',
114
+ singleValue: true
115
+ };
116
+ var diff = createDiff({ operation: mdm_sdk_1.DCROperationTypes.ADDED, attributeType: attrType, level: 0 });
117
+ var result = (0, changesList_1.prepareChangesList)([diff]);
118
+ expect((_a = result[0].displayOptions) === null || _a === void 0 ? void 0 : _a.showAddButton).toBe(false);
119
+ });
120
+ it('should set showAddButton=false for role and tag attributes', function () {
121
+ var _a, _b;
122
+ var roleType = { uri: 'roles', name: 'roles', label: 'Roles', type: 'String' };
123
+ var tagType = { uri: 'tags', name: 'tags', label: 'Tags', type: 'String' };
124
+ var diff1 = createDiff({ operation: mdm_sdk_1.DCROperationTypes.ADDED, attributeType: roleType, level: 0 });
125
+ var diff2 = createDiff({ operation: mdm_sdk_1.DCROperationTypes.ADDED, attributeType: tagType, level: 0 });
126
+ var result = (0, changesList_1.prepareChangesList)([diff1, diff2]);
127
+ expect((_a = result[0].displayOptions) === null || _a === void 0 ? void 0 : _a.showAddButton).toBe(false);
128
+ expect((_b = result[1].displayOptions) === null || _b === void 0 ? void 0 : _b.showAddButton).toBe(false);
129
+ });
130
+ it('should set showLabel=true and showAddButton=false for non-ADDED non-EDITED operations', function () {
131
+ var _a, _b;
132
+ var diff = createDiff({ operation: mdm_sdk_1.DCROperationTypes.DELETED, level: 0 });
133
+ var result = (0, changesList_1.prepareChangesList)([diff]);
134
+ expect((_a = result[0].displayOptions) === null || _a === void 0 ? void 0 : _a.showLabel).toBe(true);
135
+ expect((_b = result[0].displayOptions) === null || _b === void 0 ? void 0 : _b.showAddButton).toBe(false);
136
+ });
137
+ it('should set showLabel=false for EDITED operations', function () {
138
+ var _a;
139
+ var diff = createDiff({ operation: mdm_sdk_1.DCROperationTypes.EDITED, level: 0 });
140
+ var result = (0, changesList_1.prepareChangesList)([diff]);
141
+ expect((_a = result[0].displayOptions) === null || _a === void 0 ? void 0 : _a.showLabel).toBe(false);
142
+ });
143
+ it('should set showAddButton=false for cardinality maxValue=1 attributes', function () {
144
+ var _a;
145
+ var attrType = {
146
+ uri: 'configuration/entityTypes/HCP/attributes/Single',
147
+ name: 'Single',
148
+ label: 'Single',
149
+ type: 'String',
150
+ cardinality: { maxValue: 1 }
151
+ };
152
+ var diff = createDiff({ operation: mdm_sdk_1.DCROperationTypes.ADDED, attributeType: attrType, level: 0 });
153
+ var result = (0, changesList_1.prepareChangesList)([diff]);
154
+ expect((_a = result[0].displayOptions) === null || _a === void 0 ? void 0 : _a.showAddButton).toBe(false);
155
+ });
156
+ it('should set hasSameAttributeSiblings=true for all items in a multi-value ADDED group', function () {
157
+ var _a, _b;
158
+ var attrType = {
159
+ uri: 'configuration/entityTypes/HCP/attributes/Name',
160
+ name: 'Name',
161
+ label: 'Name',
162
+ type: 'String'
163
+ };
164
+ var diff1 = createDiff({ operation: mdm_sdk_1.DCROperationTypes.ADDED, attributeType: attrType, level: 0 });
165
+ var diff2 = createDiff({ operation: mdm_sdk_1.DCROperationTypes.ADDED, attributeType: attrType, level: 0 });
166
+ var result = (0, changesList_1.prepareChangesList)([diff1, diff2]);
167
+ expect((_a = result[0].displayOptions) === null || _a === void 0 ? void 0 : _a.hasSameAttributeSiblings).toBe(true);
168
+ expect((_b = result[1].displayOptions) === null || _b === void 0 ? void 0 : _b.hasSameAttributeSiblings).toBe(true);
169
+ });
170
+ it('should set hasSameAttributeSiblings=false for a single ADDED item', function () {
171
+ var _a;
172
+ var attrType = {
173
+ uri: 'configuration/entityTypes/HCP/attributes/Name',
174
+ name: 'Name',
175
+ label: 'Name',
176
+ type: 'String'
177
+ };
178
+ var diff = createDiff({ operation: mdm_sdk_1.DCROperationTypes.ADDED, attributeType: attrType, level: 0 });
179
+ var result = (0, changesList_1.prepareChangesList)([diff]);
180
+ expect((_a = result[0].displayOptions) === null || _a === void 0 ? void 0 : _a.hasSameAttributeSiblings).toBe(false);
181
+ });
182
+ it('should set hasSameAttributeSiblings=false for ADDED items with different attribute URIs', function () {
183
+ var _a, _b;
184
+ var attrType1 = {
185
+ uri: 'configuration/entityTypes/HCP/attributes/Name',
186
+ name: 'Name',
187
+ label: 'Name',
188
+ type: 'String'
189
+ };
190
+ var attrType2 = {
191
+ uri: 'configuration/entityTypes/HCP/attributes/Email',
192
+ name: 'Email',
193
+ label: 'Email',
194
+ type: 'String'
195
+ };
196
+ var diff1 = createDiff({ operation: mdm_sdk_1.DCROperationTypes.ADDED, attributeType: attrType1, level: 0 });
197
+ var diff2 = createDiff({ operation: mdm_sdk_1.DCROperationTypes.ADDED, attributeType: attrType2, level: 0 });
198
+ var result = (0, changesList_1.prepareChangesList)([diff1, diff2]);
199
+ expect((_a = result[0].displayOptions) === null || _a === void 0 ? void 0 : _a.hasSameAttributeSiblings).toBe(false);
200
+ expect((_b = result[1].displayOptions) === null || _b === void 0 ? void 0 : _b.hasSameAttributeSiblings).toBe(false);
201
+ });
202
+ });
203
+ });
@@ -1,6 +1,9 @@
1
- import { DCRChanges, GroupedObjectsInfo, EnrichedDCRChanges, TEntityType, Metadata } from '@reltio/mdm-sdk';
2
- import { Diff, Title } from '../../types';
1
+ import { type DCRChanges, type EnrichedDCRChanges, type GroupedObjectsInfo, type Metadata, type SimpleAttributeValue, type TEntityType } from '@reltio/mdm-sdk';
2
+ export declare const isSimpleAttributeValue: (value: unknown) => value is SimpleAttributeValue;
3
+ import type { Diff, Title } from '../../types';
3
4
  export declare const isEditableChange: (change: Diff, entityInfo: GroupedObjectsInfo["entity"]) => boolean;
4
- export declare const addLineIdToValue: (data: DCRChanges) => EnrichedDCRChanges;
5
+ export declare const addLineIdToValue: (data: DCRChanges | EnrichedDCRChanges) => EnrichedDCRChanges;
5
6
  export declare const isDiffChange: (change: Diff | Title) => change is Diff;
7
+ export declare const isRelationRow: (change: Diff) => boolean;
8
+ export declare const isNestedOrReferenceParent: (change: Diff) => boolean;
6
9
  export declare const checkCanInitiateChangeRequest: (metadata: Metadata, entityType: TEntityType, change: Diff) => any;
@@ -11,9 +11,13 @@ var __assign = (this && this.__assign) || function () {
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.checkCanInitiateChangeRequest = exports.isDiffChange = exports.addLineIdToValue = exports.isEditableChange = void 0;
14
+ exports.checkCanInitiateChangeRequest = exports.isNestedOrReferenceParent = exports.isRelationRow = exports.isDiffChange = exports.addLineIdToValue = exports.isEditableChange = exports.isSimpleAttributeValue = void 0;
15
15
  var ramda_1 = require("ramda");
16
16
  var mdm_sdk_1 = require("@reltio/mdm-sdk");
17
+ var isSimpleAttributeValue = function (value) {
18
+ return value !== null && typeof value === 'object' && 'value' in value;
19
+ };
20
+ exports.isSimpleAttributeValue = isSimpleAttributeValue;
17
21
  var isEditableChange = function (change, entityInfo) {
18
22
  var _a;
19
23
  var currentAttributeTypeUri = (_a = change.attributeType) === null || _a === void 0 ? void 0 : _a.uri;
@@ -70,7 +74,7 @@ var addLineIdToChangeValue = function (container, basePath, type) {
70
74
  if (Array.isArray(container)) {
71
75
  return { value: container, lineIds: [basePath] };
72
76
  }
73
- if (typeof container === 'object' && 'value' in container) {
77
+ if ((0, exports.isSimpleAttributeValue)(container)) {
74
78
  var containerValue = container.value;
75
79
  return __assign(__assign({}, container), { lineIds: [basePath], value: isPrimitiveValue(containerValue)
76
80
  ? containerValue
@@ -79,7 +83,7 @@ var addLineIdToChangeValue = function (container, basePath, type) {
79
83
  return container;
80
84
  };
81
85
  var addLineIdToValue = function (data) {
82
- var enrichedData = (0, ramda_1.clone)(data);
86
+ var enrichedData = data;
83
87
  for (var entityOrRelationKey in enrichedData) {
84
88
  var entityOrRelationId = entityOrRelationKey.split('/')[1];
85
89
  var changeList = enrichedData[entityOrRelationKey];
@@ -107,6 +111,21 @@ var isDiffChange = function (change) {
107
111
  return (0, ramda_1.has)('level', change);
108
112
  };
109
113
  exports.isDiffChange = isDiffChange;
114
+ var isRelationRow = function (change) { return Boolean(change.relationType); };
115
+ exports.isRelationRow = isRelationRow;
116
+ var isNestedOrReferenceParent = function (change) {
117
+ var _a;
118
+ if (!change.attributeType)
119
+ return false;
120
+ if ((0, mdm_sdk_1.isImage)(change.attributeType))
121
+ return false;
122
+ if (!(0, mdm_sdk_1.isComplexAttribute)(change.attributeType))
123
+ return false;
124
+ var value = (_a = change.attributeValue) === null || _a === void 0 ? void 0 : _a.value;
125
+ var isDeleted = (value === null || value === void 0 ? void 0 : value.type) === mdm_sdk_1.DCRTypes.DELETE_ATTRIBUTE;
126
+ return !isDeleted;
127
+ };
128
+ exports.isNestedOrReferenceParent = isNestedOrReferenceParent;
110
129
  var checkCanInitiateChangeRequest = function (metadata, entityType, change) {
111
130
  if (change.relationType) {
112
131
  return checkCanInitChangeRequestForRelation(metadata, change.attributeValue, change.relationType);
@@ -0,0 +1,3 @@
1
+ import { type DCRChanges, type EnrichedDCRChanges } from '@reltio/mdm-sdk';
2
+ import type { AddedAttribute } from '../../contexts/AddedAttributesContext';
3
+ export declare const mergeAddedAttributesWithDCRChanges: (changes: DCRChanges, addedAttributes: AddedAttribute[], enrich?: boolean) => EnrichedDCRChanges | DCRChanges;
@@ -0,0 +1,190 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.mergeAddedAttributesWithDCRChanges = void 0;
15
+ var ramda_1 = require("ramda");
16
+ var mdm_sdk_1 = require("@reltio/mdm-sdk");
17
+ var helpers_1 = require("./helpers");
18
+ var findNodeByLineId = function (changes, objectUri, lineId) {
19
+ var _a;
20
+ var changeList = changes[objectUri];
21
+ if (!Array.isArray(changeList))
22
+ return null;
23
+ var lineIdParts = lineId.split('/');
24
+ if (lineIdParts.length < 3)
25
+ return null;
26
+ var changeId = lineIdParts[1];
27
+ var change = changeList.find(function (c) { return c.id === changeId; });
28
+ if (!(change === null || change === void 0 ? void 0 : change.newValue))
29
+ return null;
30
+ return (_a = (0, ramda_1.path)(lineIdParts.slice(2), change)) !== null && _a !== void 0 ? _a : null;
31
+ };
32
+ var addChildToNode = function (parentNode, attrName, addedId, attributeType, initialValue) {
33
+ var containerKey = 'attributes' in parentNode && typeof parentNode.attributes === 'object' ? 'attributes' : 'value';
34
+ if (!parentNode[containerKey] ||
35
+ typeof parentNode[containerKey] !== 'object' ||
36
+ Array.isArray(parentNode[containerKey])) {
37
+ parentNode[containerKey] = {};
38
+ }
39
+ var container = parentNode[containerKey];
40
+ if (!Array.isArray(container[attrName])) {
41
+ container[attrName] = [];
42
+ }
43
+ var isComplex = attributeType && ((0, mdm_sdk_1.isComplexAttribute)(attributeType) || (0, mdm_sdk_1.isImage)(attributeType));
44
+ var value = isComplex ? {} : initialValue === null || initialValue === void 0 ? void 0 : initialValue.value;
45
+ var childNode = __assign(__assign({ value: value }, ((initialValue === null || initialValue === void 0 ? void 0 : initialValue.lookupCode) && { lookupCode: initialValue.lookupCode })), (addedId && { addedId: addedId }));
46
+ container[attrName].push(childNode);
47
+ return childNode;
48
+ };
49
+ var createNewValue = function (attributeType, enrich, id, refEntityUri, initialValue) {
50
+ var isComplex = (0, mdm_sdk_1.isComplexAttribute)(attributeType) || (0, mdm_sdk_1.isImage)(attributeType);
51
+ var value = isComplex ? {} : initialValue === null || initialValue === void 0 ? void 0 : initialValue.value;
52
+ var base = __assign(__assign({ value: value }, ((initialValue === null || initialValue === void 0 ? void 0 : initialValue.lookupCode) && { lookupCode: initialValue.lookupCode })), (enrich && id && { addedId: id }));
53
+ if ((0, mdm_sdk_1.isReference)(attributeType)) {
54
+ base.refEntity = { objectURI: refEntityUri || '' };
55
+ }
56
+ return base;
57
+ };
58
+ var createFakeInsertAttributeChange = function (id, attributeType, newValue, changeOverrides) {
59
+ return __assign({ id: id, type: mdm_sdk_1.DCRTypes.INSERT_ATTRIBUTE, attributePath: attributeType.name, attributeType: attributeType.uri, newValue: newValue }, changeOverrides);
60
+ };
61
+ var createFakeRolesOrTagsChange = function (id, attributeType, enrich) { return ({
62
+ id: id,
63
+ type: (0, mdm_sdk_1.isTagAttrType)(attributeType) ? mdm_sdk_1.DCRTypes.UPDATE_TAGS : mdm_sdk_1.DCRTypes.UPDATE_ROLES,
64
+ newValue: (enrich ? { value: [], addedId: id } : [])
65
+ }); };
66
+ var createFakeActivenessDateChange = function (id, attributeType, enrich) { return ({
67
+ id: id,
68
+ type: attributeType.uri === mdm_sdk_1.EntityAttrTypes.startDate.uri ? mdm_sdk_1.DCRTypes.UPDATE_START_DATE : mdm_sdk_1.DCRTypes.UPDATE_END_DATE,
69
+ objectType: (0, mdm_sdk_1.getBaseUri)(attributeType.uri),
70
+ newValue: (enrich ? { value: undefined, addedId: id } : [])
71
+ }); };
72
+ var createEmptyChangeValue = function (enrich, id) {
73
+ return (enrich ? { value: undefined, addedId: id } : []);
74
+ };
75
+ var upsertSpecialAttributeChange = function (_a) {
76
+ var changesList = _a.changesList, changeType = _a.changeType, change = _a.change, enrich = _a.enrich, id = _a.id;
77
+ var existingChange = changesList.find(function (c) { return c.type === changeType; });
78
+ if (existingChange && !existingChange.newValue) {
79
+ existingChange.newValue = createEmptyChangeValue(enrich, id);
80
+ }
81
+ else if (!existingChange) {
82
+ changesList.push(change);
83
+ }
84
+ };
85
+ var resolveObjectUri = function (objectUriOrId, changes) {
86
+ if (!objectUriOrId)
87
+ return undefined;
88
+ if (changes[objectUriOrId])
89
+ return objectUriOrId;
90
+ return Object.keys(changes).find(function (uri) { return uri.endsWith("/".concat(objectUriOrId)); }) || objectUriOrId;
91
+ };
92
+ var getObjectUriFromLineId = function (lineId, changes) {
93
+ var objectId = lineId.split('/')[0];
94
+ return resolveObjectUri(objectId, changes);
95
+ };
96
+ var mergeAddedAttributesWithDCRChanges = function (changes, addedAttributes, enrich) {
97
+ var _a, _b, _c, _d;
98
+ if (enrich === void 0) { enrich = true; }
99
+ var merged = (0, ramda_1.clone)(changes);
100
+ if (addedAttributes.length === 0) {
101
+ return enrich ? (0, helpers_1.addLineIdToValue)(merged) : merged;
102
+ }
103
+ var nodeById = new Map();
104
+ for (var _i = 0, addedAttributes_1 = addedAttributes; _i < addedAttributes_1.length; _i++) {
105
+ var addedAttribute = addedAttributes_1[_i];
106
+ var id = addedAttribute.id, objectUriFromAddedAttribute = addedAttribute.objectUri, parentLineId = addedAttribute.parentLineId, parentId = addedAttribute.parentId, changeOverrides = addedAttribute.changeOverrides, attributeType = addedAttribute.attributeType;
107
+ var objectUri = resolveObjectUri(objectUriFromAddedAttribute, merged) ||
108
+ (parentLineId ? getObjectUriFromLineId(parentLineId, merged) : undefined);
109
+ var attrName = (_a = attributeType === null || attributeType === void 0 ? void 0 : attributeType.name) !== null && _a !== void 0 ? _a : '';
110
+ if (parentId && !objectUri) {
111
+ var parentNode = (_b = nodeById.get(parentId)) !== null && _b !== void 0 ? _b : null;
112
+ if (!parentNode)
113
+ continue;
114
+ var childNode = addChildToNode(parentNode, attrName, enrich ? id : undefined, attributeType, addedAttribute.initialValue);
115
+ nodeById.set(id, childNode);
116
+ continue;
117
+ }
118
+ if (!objectUri)
119
+ continue;
120
+ if (!merged[objectUri]) {
121
+ merged[objectUri] = [];
122
+ }
123
+ var createChange = !parentLineId && !parentId
124
+ ? merged[objectUri].find(function (c) { return c.type === mdm_sdk_1.DCRTypes.CREATE_ENTITY || c.type === mdm_sdk_1.DCRTypes.CREATE_RELATIONSHIP; })
125
+ : undefined;
126
+ if ((createChange === null || createChange === void 0 ? void 0 : createChange.newValue) && ((0, mdm_sdk_1.isRoleAttrType)(attributeType) || (0, mdm_sdk_1.isTagAttrType)(attributeType))) {
127
+ var parentNode = createChange.newValue;
128
+ parentNode[attrName] = enrich ? { value: [], addedId: id } : [];
129
+ }
130
+ else if ((createChange === null || createChange === void 0 ? void 0 : createChange.newValue) && (0, mdm_sdk_1.isActivenessAttrType)(attributeType)) {
131
+ var parentNode = createChange.newValue;
132
+ parentNode[attributeType.uri] = enrich ? { addedId: id } : null;
133
+ }
134
+ else if (createChange === null || createChange === void 0 ? void 0 : createChange.newValue) {
135
+ var parentNode = createChange.newValue;
136
+ var childNode = addChildToNode(parentNode, attrName, enrich ? id : undefined, attributeType, addedAttribute.initialValue);
137
+ nodeById.set(id, childNode);
138
+ }
139
+ else if ((0, mdm_sdk_1.isActivenessAttrType)(attributeType)) {
140
+ var createRelOrEntityChange = merged[objectUri].find(function (c) { return c.type === mdm_sdk_1.DCRTypes.CREATE_RELATIONSHIP || c.type === mdm_sdk_1.DCRTypes.CREATE_ENTITY; });
141
+ if (createRelOrEntityChange === null || createRelOrEntityChange === void 0 ? void 0 : createRelOrEntityChange.newValue) {
142
+ var parentNode = createRelOrEntityChange.newValue;
143
+ parentNode[attributeType.uri] = enrich ? { addedId: id } : null;
144
+ }
145
+ else {
146
+ var changeType = attributeType.uri === mdm_sdk_1.EntityAttrTypes.startDate.uri
147
+ ? mdm_sdk_1.DCRTypes.UPDATE_START_DATE
148
+ : mdm_sdk_1.DCRTypes.UPDATE_END_DATE;
149
+ upsertSpecialAttributeChange({
150
+ changesList: merged[objectUri],
151
+ changeType: changeType,
152
+ change: createFakeActivenessDateChange(id, attributeType, enrich),
153
+ enrich: enrich,
154
+ id: id
155
+ });
156
+ }
157
+ }
158
+ else if ((0, mdm_sdk_1.isTagAttrType)(attributeType) || (0, mdm_sdk_1.isRoleAttrType)(attributeType)) {
159
+ var changeType = (0, mdm_sdk_1.isTagAttrType)(attributeType) ? mdm_sdk_1.DCRTypes.UPDATE_TAGS : mdm_sdk_1.DCRTypes.UPDATE_ROLES;
160
+ upsertSpecialAttributeChange({
161
+ changesList: merged[objectUri],
162
+ changeType: changeType,
163
+ change: createFakeRolesOrTagsChange(id, attributeType, enrich),
164
+ enrich: enrich,
165
+ id: id
166
+ });
167
+ }
168
+ else if (!parentLineId && !parentId) {
169
+ var newValue = createNewValue(attributeType, enrich, id, (_c = addedAttribute.refEntity) === null || _c === void 0 ? void 0 : _c.entityUri, addedAttribute.initialValue);
170
+ nodeById.set(id, newValue);
171
+ var newChange = createFakeInsertAttributeChange(id, attributeType, newValue, changeOverrides);
172
+ merged[objectUri].push(newChange);
173
+ }
174
+ else {
175
+ var parentNode = null;
176
+ if (parentLineId) {
177
+ parentNode = findNodeByLineId(merged, objectUri, parentLineId);
178
+ }
179
+ else if (parentId) {
180
+ parentNode = (_d = nodeById.get(parentId)) !== null && _d !== void 0 ? _d : null;
181
+ }
182
+ if (!parentNode)
183
+ continue;
184
+ var childNode = addChildToNode(parentNode, attrName, enrich ? id : undefined, attributeType, addedAttribute.initialValue);
185
+ nodeById.set(id, childNode);
186
+ }
187
+ }
188
+ return enrich ? (0, helpers_1.addLineIdToValue)(merged) : merged;
189
+ };
190
+ exports.mergeAddedAttributesWithDCRChanges = mergeAddedAttributesWithDCRChanges;