@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
@@ -0,0 +1,766 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { DCRTypes, EntityAttrTypes } from '@reltio/mdm-sdk';
13
+ import { mergeAddedAttributesWithDCRChanges } from './mergeAddedAttributesWithDCRChanges';
14
+ var createSimpleAttrType = function (overrides) {
15
+ if (overrides === void 0) { overrides = {}; }
16
+ return (__assign({ name: 'FirstName', uri: 'configuration/entityTypes/HCP/attributes/FirstName', label: 'First Name', type: 'String' }, overrides));
17
+ };
18
+ var createReferenceAttrType = function (overrides) {
19
+ if (overrides === void 0) { overrides = {}; }
20
+ return (__assign({ name: 'Address', uri: 'configuration/entityTypes/HCP/attributes/Address', label: 'Address', type: 'Reference', referencedEntityTypeURI: 'configuration/entityTypes/Location', relationshipTypeURI: 'configuration/relationTypes/HasAddress' }, overrides));
21
+ };
22
+ describe('mergeAddedAttributesWithDCRChanges', function () {
23
+ var _a;
24
+ var entityUri = 'entities/456';
25
+ var baseChanges = (_a = {},
26
+ _a[entityUri] = [
27
+ {
28
+ id: 'existingChange1',
29
+ type: DCRTypes.UPDATE_ATTRIBUTE,
30
+ attributePath: 'Name/456',
31
+ newValue: { value: 'New Name' },
32
+ oldValue: { value: 'Old Name' }
33
+ }
34
+ ],
35
+ _a);
36
+ var enrichedBaseChange = {
37
+ id: 'existingChange1',
38
+ type: DCRTypes.UPDATE_ATTRIBUTE,
39
+ attributePath: 'Name/456',
40
+ newValue: { value: 'New Name', lineIds: ['456/existingChange1/newValue'] },
41
+ oldValue: { value: 'Old Name', lineIds: ['456/existingChange1/oldValue'] },
42
+ lineIds: ['456/existingChange1']
43
+ };
44
+ it('should return enriched changes with lineIds when addedAttributes is empty', function () {
45
+ var _a;
46
+ var result = mergeAddedAttributesWithDCRChanges(baseChanges, []);
47
+ expect(result).toEqual((_a = {},
48
+ _a[entityUri] = [enrichedBaseChange],
49
+ _a));
50
+ });
51
+ it('should return original changes without enrichment when enrich is false and addedAttributes is empty', function () {
52
+ var result = mergeAddedAttributesWithDCRChanges(baseChanges, [], false);
53
+ expect(result).toEqual(baseChanges);
54
+ });
55
+ it('should add INSERT_ATTRIBUTE change for simple root attribute', function () {
56
+ var _a;
57
+ var attrType = createSimpleAttrType();
58
+ var added = [
59
+ {
60
+ id: 'added|abc',
61
+ objectUri: entityUri,
62
+ attributeType: attrType
63
+ }
64
+ ];
65
+ var result = mergeAddedAttributesWithDCRChanges(baseChanges, added);
66
+ expect(result).toEqual((_a = {},
67
+ _a[entityUri] = [
68
+ enrichedBaseChange,
69
+ {
70
+ id: 'added|abc',
71
+ type: DCRTypes.INSERT_ATTRIBUTE,
72
+ attributePath: 'FirstName',
73
+ attributeType: 'configuration/entityTypes/HCP/attributes/FirstName',
74
+ newValue: { value: undefined, addedId: 'added|abc', lineIds: ['456/added|abc/newValue'] },
75
+ lineIds: ['456/added|abc']
76
+ }
77
+ ],
78
+ _a));
79
+ });
80
+ it('should add INSERT_ATTRIBUTE with refEntity for reference attribute', function () {
81
+ var _a;
82
+ var attrType = createReferenceAttrType();
83
+ var added = [
84
+ {
85
+ id: 'added|ref1',
86
+ objectUri: entityUri,
87
+ attributeType: attrType,
88
+ refEntity: { entityUri: 'entities/789' }
89
+ }
90
+ ];
91
+ var result = mergeAddedAttributesWithDCRChanges(baseChanges, added);
92
+ expect(result).toEqual((_a = {},
93
+ _a[entityUri] = [
94
+ enrichedBaseChange,
95
+ {
96
+ id: 'added|ref1',
97
+ type: DCRTypes.INSERT_ATTRIBUTE,
98
+ attributePath: 'Address',
99
+ attributeType: 'configuration/entityTypes/HCP/attributes/Address',
100
+ newValue: {
101
+ value: {},
102
+ addedId: 'added|ref1',
103
+ refEntity: { objectURI: 'entities/789' },
104
+ lineIds: ['456/added|ref1/newValue']
105
+ },
106
+ lineIds: ['456/added|ref1']
107
+ }
108
+ ],
109
+ _a));
110
+ });
111
+ it('should add UPDATE_ROLES change for role attribute', function () {
112
+ var _a;
113
+ var added = [
114
+ {
115
+ id: 'added|role1',
116
+ objectUri: entityUri,
117
+ attributeType: EntityAttrTypes.roles
118
+ }
119
+ ];
120
+ var result = mergeAddedAttributesWithDCRChanges(baseChanges, added);
121
+ expect(result).toEqual((_a = {},
122
+ _a[entityUri] = [
123
+ enrichedBaseChange,
124
+ {
125
+ id: 'added|role1',
126
+ type: DCRTypes.UPDATE_ROLES,
127
+ newValue: { value: [], addedId: 'added|role1', lineIds: ['456/added|role1/newValue'] },
128
+ lineIds: ['456/added|role1']
129
+ }
130
+ ],
131
+ _a));
132
+ });
133
+ it('should add UPDATE_TAGS change for tag attribute', function () {
134
+ var _a;
135
+ var added = [
136
+ {
137
+ id: 'added|tag1',
138
+ objectUri: entityUri,
139
+ attributeType: EntityAttrTypes.tags
140
+ }
141
+ ];
142
+ var result = mergeAddedAttributesWithDCRChanges(baseChanges, added);
143
+ expect(result).toEqual((_a = {},
144
+ _a[entityUri] = [
145
+ enrichedBaseChange,
146
+ {
147
+ id: 'added|tag1',
148
+ type: DCRTypes.UPDATE_TAGS,
149
+ newValue: { value: [], addedId: 'added|tag1', lineIds: ['456/added|tag1/newValue'] },
150
+ lineIds: ['456/added|tag1']
151
+ }
152
+ ],
153
+ _a));
154
+ });
155
+ it('should add UPDATE_START_DATE change for start date attribute', function () {
156
+ var _a;
157
+ var added = [
158
+ {
159
+ id: 'added|sd1',
160
+ objectUri: entityUri,
161
+ attributeType: EntityAttrTypes.startDate
162
+ }
163
+ ];
164
+ var result = mergeAddedAttributesWithDCRChanges(baseChanges, added);
165
+ expect(result).toEqual((_a = {},
166
+ _a[entityUri] = [
167
+ enrichedBaseChange,
168
+ {
169
+ id: 'added|sd1',
170
+ type: DCRTypes.UPDATE_START_DATE,
171
+ objectType: 'startDate',
172
+ newValue: { value: undefined, addedId: 'added|sd1', lineIds: ['456/added|sd1/newValue'] },
173
+ lineIds: ['456/added|sd1']
174
+ }
175
+ ],
176
+ _a));
177
+ });
178
+ it('should add UPDATE_END_DATE change for end date attribute', function () {
179
+ var _a;
180
+ var added = [
181
+ {
182
+ id: 'added|ed1',
183
+ objectUri: entityUri,
184
+ attributeType: EntityAttrTypes.endDate
185
+ }
186
+ ];
187
+ var result = mergeAddedAttributesWithDCRChanges(baseChanges, added);
188
+ expect(result).toEqual((_a = {},
189
+ _a[entityUri] = [
190
+ enrichedBaseChange,
191
+ {
192
+ id: 'added|ed1',
193
+ type: DCRTypes.UPDATE_END_DATE,
194
+ objectType: 'endDate',
195
+ newValue: { value: undefined, addedId: 'added|ed1', lineIds: ['456/added|ed1/newValue'] },
196
+ lineIds: ['456/added|ed1']
197
+ }
198
+ ],
199
+ _a));
200
+ });
201
+ it('should attach child to existing parent node by parentId', function () {
202
+ var _a;
203
+ var parentAttrType = createSimpleAttrType({
204
+ name: 'Parent',
205
+ uri: 'configuration/entityTypes/HCP/attributes/Parent',
206
+ type: 'Nested'
207
+ });
208
+ var childAttrType = createSimpleAttrType({
209
+ name: 'Child',
210
+ uri: 'configuration/entityTypes/HCP/attributes/Parent/attributes/Child'
211
+ });
212
+ var added = [
213
+ {
214
+ id: 'added|parent1',
215
+ objectUri: entityUri,
216
+ attributeType: parentAttrType
217
+ },
218
+ {
219
+ id: 'added|parent1|child1',
220
+ objectUri: entityUri,
221
+ attributeType: childAttrType,
222
+ parentId: 'added|parent1'
223
+ }
224
+ ];
225
+ var result = mergeAddedAttributesWithDCRChanges(baseChanges, added);
226
+ expect(result).toEqual((_a = {},
227
+ _a[entityUri] = [
228
+ enrichedBaseChange,
229
+ {
230
+ id: 'added|parent1',
231
+ type: DCRTypes.INSERT_ATTRIBUTE,
232
+ attributePath: 'Parent',
233
+ attributeType: 'configuration/entityTypes/HCP/attributes/Parent',
234
+ newValue: {
235
+ value: {
236
+ Child: [
237
+ {
238
+ value: undefined,
239
+ addedId: 'added|parent1|child1',
240
+ lineIds: ['456/added|parent1/newValue/value/Child/0']
241
+ }
242
+ ]
243
+ },
244
+ addedId: 'added|parent1',
245
+ lineIds: ['456/added|parent1/newValue']
246
+ },
247
+ lineIds: ['456/added|parent1']
248
+ }
249
+ ],
250
+ _a));
251
+ });
252
+ it('should attach child to existing DCR node by parentLineId', function () {
253
+ var _a, _b;
254
+ var changes = (_a = {},
255
+ _a[entityUri] = [
256
+ {
257
+ id: 'existingNested',
258
+ type: DCRTypes.INSERT_ATTRIBUTE,
259
+ newValue: { value: { SubAttr: [{ value: 'test' }] } }
260
+ }
261
+ ],
262
+ _a);
263
+ var childAttrType = createSimpleAttrType({
264
+ name: 'NewChild',
265
+ uri: 'configuration/entityTypes/HCP/attributes/NestedAttr/attributes/NewChild'
266
+ });
267
+ var added = [
268
+ {
269
+ id: 'added|child2',
270
+ objectUri: entityUri,
271
+ attributeType: childAttrType,
272
+ parentLineId: '456/existingNested/newValue'
273
+ }
274
+ ];
275
+ var result = mergeAddedAttributesWithDCRChanges(changes, added);
276
+ expect(result).toEqual((_b = {},
277
+ _b[entityUri] = [
278
+ {
279
+ id: 'existingNested',
280
+ type: DCRTypes.INSERT_ATTRIBUTE,
281
+ newValue: {
282
+ value: {
283
+ SubAttr: [{ value: 'test', lineIds: ['456/existingNested/newValue/value/SubAttr/0'] }],
284
+ NewChild: [
285
+ {
286
+ value: undefined,
287
+ addedId: 'added|child2',
288
+ lineIds: ['456/existingNested/newValue/value/NewChild/0']
289
+ }
290
+ ]
291
+ },
292
+ lineIds: ['456/existingNested/newValue']
293
+ },
294
+ lineIds: ['456/existingNested']
295
+ }
296
+ ],
297
+ _b));
298
+ });
299
+ it('should create INSERT_ATTRIBUTE with full path when changeOverrides is provided', function () {
300
+ var _a;
301
+ var changes = (_a = {},
302
+ _a[entityUri] = [
303
+ {
304
+ id: 'existingChange',
305
+ type: DCRTypes.INSERT_ATTRIBUTE,
306
+ attributePath: 'AddressNested/26fvrHXjx/PostalCode',
307
+ newValue: { value: '12345' },
308
+ attributeType: 'configuration/entityTypes/HCP/attributes/AddressNested/attributes/PostalCode'
309
+ }
310
+ ],
311
+ _a);
312
+ var childAttrType = createSimpleAttrType({
313
+ name: 'City',
314
+ uri: 'configuration/entityTypes/HCP/attributes/AddressNested/attributes/City'
315
+ });
316
+ var added = [
317
+ {
318
+ id: 'added|city1',
319
+ objectUri: entityUri,
320
+ attributeType: childAttrType,
321
+ changeOverrides: { attributePath: 'AddressNested/26fvrHXjx/City' }
322
+ }
323
+ ];
324
+ var result = mergeAddedAttributesWithDCRChanges(changes, added);
325
+ expect(result[entityUri]).toHaveLength(2);
326
+ expect(result[entityUri][1]).toEqual(expect.objectContaining({
327
+ id: 'added|city1',
328
+ type: DCRTypes.INSERT_ATTRIBUTE,
329
+ attributePath: 'AddressNested/26fvrHXjx/City',
330
+ newValue: expect.objectContaining({
331
+ value: undefined,
332
+ addedId: 'added|city1'
333
+ })
334
+ }));
335
+ });
336
+ it('should fill existing UPDATE_ROLES change with empty newValue instead of creating duplicate', function () {
337
+ var _a, _b;
338
+ var changes = (_a = {},
339
+ _a[entityUri] = [
340
+ {
341
+ id: 'existingRoles',
342
+ type: DCRTypes.UPDATE_ROLES,
343
+ oldValue: ['admin', 'user'],
344
+ newValue: undefined
345
+ }
346
+ ],
347
+ _a);
348
+ var added = [
349
+ {
350
+ id: 'added|role2',
351
+ objectUri: entityUri,
352
+ attributeType: EntityAttrTypes.roles
353
+ }
354
+ ];
355
+ var result = mergeAddedAttributesWithDCRChanges(changes, added, false);
356
+ expect(result).toEqual((_b = {},
357
+ _b[entityUri] = [{ id: 'existingRoles', type: DCRTypes.UPDATE_ROLES, oldValue: ['admin', 'user'], newValue: [] }],
358
+ _b));
359
+ });
360
+ it('should attach root attribute to existing CREATE_ENTITY change instead of creating INSERT_ATTRIBUTE', function () {
361
+ var _a, _b;
362
+ var createEntityChanges = (_a = {},
363
+ _a[entityUri] = [
364
+ {
365
+ id: 'createChange1',
366
+ type: DCRTypes.CREATE_ENTITY,
367
+ newValue: {
368
+ value: undefined,
369
+ attributes: {
370
+ ExistingAttr: [{ value: 'existing' }]
371
+ }
372
+ }
373
+ }
374
+ ],
375
+ _a);
376
+ var attrType = createSimpleAttrType();
377
+ var added = [
378
+ {
379
+ id: 'added|abc',
380
+ objectUri: entityUri,
381
+ attributeType: attrType
382
+ }
383
+ ];
384
+ var result = mergeAddedAttributesWithDCRChanges(createEntityChanges, added);
385
+ expect(result).toEqual((_b = {},
386
+ _b[entityUri] = [
387
+ {
388
+ id: 'createChange1',
389
+ type: DCRTypes.CREATE_ENTITY,
390
+ newValue: {
391
+ value: undefined,
392
+ attributes: {
393
+ ExistingAttr: [
394
+ { value: 'existing', lineIds: ['456/createChange1/newValue/attributes/ExistingAttr/0'] }
395
+ ],
396
+ FirstName: [
397
+ {
398
+ value: undefined,
399
+ addedId: 'added|abc',
400
+ lineIds: ['456/createChange1/newValue/attributes/FirstName/0']
401
+ }
402
+ ]
403
+ },
404
+ lineIds: ['456/createChange1/newValue']
405
+ },
406
+ lineIds: ['456/createChange1']
407
+ }
408
+ ],
409
+ _b));
410
+ });
411
+ it('should attach root attribute to CREATE_RELATIONSHIP change', function () {
412
+ var _a, _b;
413
+ var createRelChanges = (_a = {},
414
+ _a[entityUri] = [
415
+ {
416
+ id: 'createRel1',
417
+ type: DCRTypes.CREATE_RELATIONSHIP,
418
+ newValue: {
419
+ value: undefined,
420
+ attributes: {}
421
+ }
422
+ }
423
+ ],
424
+ _a);
425
+ var attrType = createSimpleAttrType();
426
+ var added = [
427
+ {
428
+ id: 'added|rel1',
429
+ objectUri: entityUri,
430
+ attributeType: attrType
431
+ }
432
+ ];
433
+ var result = mergeAddedAttributesWithDCRChanges(createRelChanges, added);
434
+ expect(result).toEqual((_b = {},
435
+ _b[entityUri] = [
436
+ {
437
+ id: 'createRel1',
438
+ type: DCRTypes.CREATE_RELATIONSHIP,
439
+ newValue: {
440
+ value: undefined,
441
+ attributes: {
442
+ FirstName: [
443
+ {
444
+ value: undefined,
445
+ addedId: 'added|rel1',
446
+ lineIds: ['456/createRel1/newValue/attributes/FirstName/0']
447
+ }
448
+ ]
449
+ },
450
+ lineIds: ['456/createRel1/newValue']
451
+ },
452
+ lineIds: ['456/createRel1']
453
+ }
454
+ ],
455
+ _b));
456
+ });
457
+ it('should attach roles to CREATE_ENTITY newValue instead of creating UPDATE_ROLES', function () {
458
+ var _a, _b;
459
+ var createEntityChanges = (_a = {},
460
+ _a[entityUri] = [
461
+ {
462
+ id: 'createChange1',
463
+ type: DCRTypes.CREATE_ENTITY,
464
+ newValue: {
465
+ value: undefined,
466
+ attributes: {}
467
+ }
468
+ }
469
+ ],
470
+ _a);
471
+ var added = [
472
+ {
473
+ id: 'added|role1',
474
+ objectUri: entityUri,
475
+ attributeType: EntityAttrTypes.roles
476
+ }
477
+ ];
478
+ var result = mergeAddedAttributesWithDCRChanges(createEntityChanges, added);
479
+ expect(result).toEqual((_b = {},
480
+ _b[entityUri] = [
481
+ {
482
+ id: 'createChange1',
483
+ type: DCRTypes.CREATE_ENTITY,
484
+ newValue: {
485
+ value: undefined,
486
+ attributes: {},
487
+ roles: { value: [], addedId: 'added|role1' },
488
+ lineIds: ['456/createChange1/newValue']
489
+ },
490
+ lineIds: ['456/createChange1']
491
+ }
492
+ ],
493
+ _b));
494
+ });
495
+ it('should attach tags to CREATE_ENTITY newValue instead of creating UPDATE_TAGS', function () {
496
+ var _a, _b;
497
+ var createEntityChanges = (_a = {},
498
+ _a[entityUri] = [
499
+ {
500
+ id: 'createChange1',
501
+ type: DCRTypes.CREATE_ENTITY,
502
+ newValue: {
503
+ value: undefined,
504
+ attributes: {}
505
+ }
506
+ }
507
+ ],
508
+ _a);
509
+ var added = [
510
+ {
511
+ id: 'added|tag1',
512
+ objectUri: entityUri,
513
+ attributeType: EntityAttrTypes.tags
514
+ }
515
+ ];
516
+ var result = mergeAddedAttributesWithDCRChanges(createEntityChanges, added);
517
+ expect(result).toEqual((_b = {},
518
+ _b[entityUri] = [
519
+ {
520
+ id: 'createChange1',
521
+ type: DCRTypes.CREATE_ENTITY,
522
+ newValue: {
523
+ value: undefined,
524
+ attributes: {},
525
+ tags: { value: [], addedId: 'added|tag1' },
526
+ lineIds: ['456/createChange1/newValue']
527
+ },
528
+ lineIds: ['456/createChange1']
529
+ }
530
+ ],
531
+ _b));
532
+ });
533
+ it('should attach startDate to CREATE_ENTITY newValue instead of creating UPDATE_START_DATE', function () {
534
+ var _a, _b;
535
+ var createEntityChanges = (_a = {},
536
+ _a[entityUri] = [
537
+ {
538
+ id: 'createChange1',
539
+ type: DCRTypes.CREATE_ENTITY,
540
+ newValue: {
541
+ value: undefined,
542
+ attributes: {}
543
+ }
544
+ }
545
+ ],
546
+ _a);
547
+ var added = [
548
+ {
549
+ id: 'added|sd1',
550
+ objectUri: entityUri,
551
+ attributeType: EntityAttrTypes.startDate
552
+ }
553
+ ];
554
+ var result = mergeAddedAttributesWithDCRChanges(createEntityChanges, added);
555
+ expect(result).toEqual((_b = {},
556
+ _b[entityUri] = [
557
+ {
558
+ id: 'createChange1',
559
+ type: DCRTypes.CREATE_ENTITY,
560
+ newValue: {
561
+ value: undefined,
562
+ attributes: {},
563
+ startDate: { addedId: 'added|sd1' },
564
+ lineIds: ['456/createChange1/newValue']
565
+ },
566
+ lineIds: ['456/createChange1']
567
+ }
568
+ ],
569
+ _b));
570
+ });
571
+ it('should attach startDate to CREATE_RELATIONSHIP newValue instead of creating UPDATE_START_DATE', function () {
572
+ var _a, _b;
573
+ var relationUri = 'relations/rel345';
574
+ var createRelChanges = (_a = {},
575
+ _a[relationUri] = [
576
+ {
577
+ id: 'createRelChange1',
578
+ type: DCRTypes.CREATE_RELATIONSHIP,
579
+ newValue: {
580
+ attributes: { Status: [{ value: 'Active' }] },
581
+ type: 'configuration/relationTypes/HCPtoHCA',
582
+ uri: relationUri
583
+ }
584
+ }
585
+ ],
586
+ _a);
587
+ var added = [
588
+ {
589
+ id: 'added|sd1',
590
+ objectUri: relationUri,
591
+ parentLineId: 'rel345/createRelChange1',
592
+ attributeType: EntityAttrTypes.startDate
593
+ }
594
+ ];
595
+ var result = mergeAddedAttributesWithDCRChanges(createRelChanges, added);
596
+ expect(result).toEqual((_b = {},
597
+ _b[relationUri] = [
598
+ {
599
+ id: 'createRelChange1',
600
+ type: DCRTypes.CREATE_RELATIONSHIP,
601
+ newValue: {
602
+ attributes: {
603
+ Status: [
604
+ { value: 'Active', lineIds: ['rel345/createRelChange1/newValue/attributes/Status/0'] }
605
+ ]
606
+ },
607
+ type: 'configuration/relationTypes/HCPtoHCA',
608
+ uri: relationUri,
609
+ startDate: { addedId: 'added|sd1' },
610
+ lineIds: ['rel345/createRelChange1/newValue']
611
+ },
612
+ lineIds: ['rel345/createRelChange1']
613
+ }
614
+ ],
615
+ _b));
616
+ });
617
+ it('should attach endDate to CREATE_RELATIONSHIP newValue instead of creating UPDATE_END_DATE', function () {
618
+ var _a, _b;
619
+ var relationUri = 'relations/rel345';
620
+ var createRelChanges = (_a = {},
621
+ _a[relationUri] = [
622
+ {
623
+ id: 'createRelChange1',
624
+ type: DCRTypes.CREATE_RELATIONSHIP,
625
+ newValue: {
626
+ attributes: {},
627
+ type: 'configuration/relationTypes/HCPtoHCA',
628
+ uri: relationUri
629
+ }
630
+ }
631
+ ],
632
+ _a);
633
+ var added = [
634
+ {
635
+ id: 'added|ed1',
636
+ objectUri: relationUri,
637
+ parentLineId: 'rel345/createRelChange1',
638
+ attributeType: EntityAttrTypes.endDate
639
+ }
640
+ ];
641
+ var result = mergeAddedAttributesWithDCRChanges(createRelChanges, added);
642
+ expect(result).toEqual((_b = {},
643
+ _b[relationUri] = [
644
+ {
645
+ id: 'createRelChange1',
646
+ type: DCRTypes.CREATE_RELATIONSHIP,
647
+ newValue: {
648
+ attributes: {},
649
+ type: 'configuration/relationTypes/HCPtoHCA',
650
+ uri: relationUri,
651
+ endDate: { addedId: 'added|ed1' },
652
+ lineIds: ['rel345/createRelChange1/newValue']
653
+ },
654
+ lineIds: ['rel345/createRelChange1']
655
+ }
656
+ ],
657
+ _b));
658
+ });
659
+ it('should attach startDate to CREATE_RELATIONSHIP with addedId when enriched', function () {
660
+ var _a, _b;
661
+ var relationUri = 'relations/rel345';
662
+ var createRelChanges = (_a = {},
663
+ _a[relationUri] = [
664
+ {
665
+ id: 'createRelChange1',
666
+ type: DCRTypes.CREATE_RELATIONSHIP,
667
+ newValue: {
668
+ attributes: {},
669
+ type: 'configuration/relationTypes/HCPtoHCA',
670
+ uri: relationUri
671
+ }
672
+ }
673
+ ],
674
+ _a);
675
+ var added = [
676
+ {
677
+ id: 'added|sd1',
678
+ objectUri: relationUri,
679
+ parentLineId: 'rel345/createRelChange1',
680
+ attributeType: EntityAttrTypes.startDate
681
+ }
682
+ ];
683
+ var result = mergeAddedAttributesWithDCRChanges(createRelChanges, added, true);
684
+ expect(result).toEqual((_b = {},
685
+ _b[relationUri] = [
686
+ {
687
+ id: 'createRelChange1',
688
+ type: DCRTypes.CREATE_RELATIONSHIP,
689
+ newValue: {
690
+ attributes: {},
691
+ type: 'configuration/relationTypes/HCPtoHCA',
692
+ uri: relationUri,
693
+ startDate: { addedId: 'added|sd1' },
694
+ lineIds: ['rel345/createRelChange1/newValue']
695
+ },
696
+ lineIds: ['rel345/createRelChange1']
697
+ }
698
+ ],
699
+ _b));
700
+ });
701
+ it('should create separate UPDATE_START_DATE when no CREATE_RELATIONSHIP exists', function () {
702
+ var _a, _b;
703
+ var relationUri = 'relations/rel345';
704
+ var existingRelChanges = (_a = {},
705
+ _a[relationUri] = [
706
+ {
707
+ id: 'updateChange1',
708
+ type: DCRTypes.UPDATE_ATTRIBUTE,
709
+ newValue: { value: 'x' }
710
+ }
711
+ ],
712
+ _a);
713
+ var added = [
714
+ {
715
+ id: 'added|sd1',
716
+ objectUri: relationUri,
717
+ parentLineId: 'rel345/updateChange1',
718
+ attributeType: EntityAttrTypes.startDate
719
+ }
720
+ ];
721
+ var result = mergeAddedAttributesWithDCRChanges(existingRelChanges, added);
722
+ expect(result).toEqual((_b = {},
723
+ _b[relationUri] = [
724
+ {
725
+ id: 'updateChange1',
726
+ type: DCRTypes.UPDATE_ATTRIBUTE,
727
+ newValue: { value: 'x', lineIds: ['rel345/updateChange1/newValue'] },
728
+ lineIds: ['rel345/updateChange1']
729
+ },
730
+ {
731
+ id: 'added|sd1',
732
+ type: DCRTypes.UPDATE_START_DATE,
733
+ objectType: EntityAttrTypes.startDate.uri,
734
+ newValue: { value: undefined, addedId: 'added|sd1', lineIds: ['rel345/added|sd1/newValue'] },
735
+ lineIds: ['rel345/added|sd1']
736
+ }
737
+ ],
738
+ _b));
739
+ });
740
+ it('should resolve objectUri from objectId when full URI is not in changes', function () {
741
+ var changes = {
742
+ 'entities/someId123': [{ id: 'c1', type: DCRTypes.UPDATE_ATTRIBUTE, newValue: { value: 'x' } }]
743
+ };
744
+ var attrType = createSimpleAttrType();
745
+ var added = [
746
+ {
747
+ id: 'added|resolve1',
748
+ objectUri: 'someId123',
749
+ attributeType: attrType
750
+ }
751
+ ];
752
+ var result = mergeAddedAttributesWithDCRChanges(changes, added, false);
753
+ expect(result).toEqual({
754
+ 'entities/someId123': [
755
+ { id: 'c1', type: DCRTypes.UPDATE_ATTRIBUTE, newValue: { value: 'x' } },
756
+ {
757
+ id: 'added|resolve1',
758
+ type: DCRTypes.INSERT_ATTRIBUTE,
759
+ attributePath: 'FirstName',
760
+ attributeType: 'configuration/entityTypes/HCP/attributes/FirstName',
761
+ newValue: { value: undefined }
762
+ }
763
+ ]
764
+ });
765
+ });
766
+ });