@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
@@ -1,5 +1,6 @@
1
- import { AttributeDelete, ChangeRequest, DCRChange, DCRChanges, DCRObjectInfo, DCRObjectsInfo, GroupedObjectsInfo, Metadata } from '@reltio/mdm-sdk';
1
+ import { AttributeDelete, AttributeInsert, ChangeRequest, DCRChange, DCRChanges, DCRObjectInfo, DCRObjectsInfo, EndDateUpdate, Entity, GroupedObjectsInfo, Metadata, RolesUpdate, StartDateUpdate, TagsUpdate } from '@reltio/mdm-sdk';
2
2
  import { LineData } from '../types';
3
+ type CumulativeUpdateDiffEntry = AttributeInsert | EndDateUpdate | StartDateUpdate | TagsUpdate | RolesUpdate;
3
4
  export declare const getEntitiesObjects: any;
4
5
  export declare const getRelationsObjects: any;
5
6
  export declare const extractObjectsFromChangeRequest: (changes: DCRChanges, objectsInfo: DCRObjectsInfo) => DCRObjectInfo[];
@@ -13,4 +14,8 @@ export declare const buildDCRSavePlan: (changes: DCRChanges, getLinesByChangeId:
13
14
  updatedChanges: Record<string, DCRChange[]>;
14
15
  deleteEntityAttributes: Record<string, AttributeDelete[]>;
15
16
  deleteRelationAttributes: Record<string, AttributeDelete[]>;
17
+ insertEntityAttributes: Record<string, CumulativeUpdateDiffEntry[]>;
18
+ insertRelationAttributes: Record<string, CumulativeUpdateDiffEntry[]>;
16
19
  };
20
+ export declare const mergeExistingRolesAndTags: (diff: CumulativeUpdateDiffEntry[], entity: Entity) => CumulativeUpdateDiffEntry[];
21
+ export {};
@@ -20,9 +20,52 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
20
20
  return to.concat(ar || Array.prototype.slice.call(from));
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.buildDCRSavePlan = exports.isCreateEntityOperation = exports.getEntityUriForChangeRequest = exports.concatEntityRelationsObjects = exports.createEntityRelationsObjectByRelation = exports.createEntityRelationsObjectByEntity = exports.extractObjectsFromChangeRequest = exports.getRelationsObjects = exports.getEntitiesObjects = void 0;
23
+ exports.mergeExistingRolesAndTags = exports.buildDCRSavePlan = exports.isCreateEntityOperation = exports.getEntityUriForChangeRequest = exports.concatEntityRelationsObjects = exports.createEntityRelationsObjectByRelation = exports.createEntityRelationsObjectByEntity = exports.extractObjectsFromChangeRequest = exports.getRelationsObjects = exports.getEntitiesObjects = void 0;
24
24
  var mdm_sdk_1 = require("@reltio/mdm-sdk");
25
25
  var ramda_1 = require("ramda");
26
+ var AddedAttributesContext_1 = require("../contexts/AddedAttributesContext");
27
+ var isAddedChange = function (changeId) { return changeId === null || changeId === void 0 ? void 0 : changeId.startsWith(AddedAttributesContext_1.ADDED_CHANGE_ID_PREFIX); };
28
+ var normalizeReferenceValueForApi = function (val, change, metadata) {
29
+ var attrType = (0, mdm_sdk_1.findAttributeTypeByUri)(metadata, change.attributeType);
30
+ return __assign(__assign(__assign({}, val), { refEntity: {
31
+ objectURI: val.refEntity.objectURI,
32
+ type: (0, mdm_sdk_1.getReferencedEntityTypeUriFromAttrType)(attrType)
33
+ } }), (change.crosswalk && {
34
+ refRelation: {
35
+ type: change.crosswalk.type
36
+ }
37
+ }));
38
+ };
39
+ var dcrChangeToInsertDiffEntry = function (change, objectUri, metadata) {
40
+ var _a, _b;
41
+ switch (change.type) {
42
+ case mdm_sdk_1.DCRTypes.INSERT_ATTRIBUTE: {
43
+ var newVal = change.newValue;
44
+ var normalized = newVal.refEntity !== undefined ? normalizeReferenceValueForApi(newVal, change, metadata) : newVal;
45
+ var attributePath = change.attributePath;
46
+ if (change.refObjectURI && change.refAttributeType) {
47
+ var refAttrName = change.refAttributeType.split('/attributes/')[1];
48
+ var refInstanceId = change.refObjectURI.split('/')[1];
49
+ attributePath = "".concat(refAttrName, "/").concat(refInstanceId, "/").concat(attributePath);
50
+ }
51
+ return {
52
+ type: mdm_sdk_1.EventType.INSERT_ATTRIBUTE,
53
+ uri: "".concat(objectUri, "/attributes/").concat(attributePath),
54
+ newValue: [normalized]
55
+ };
56
+ }
57
+ case mdm_sdk_1.DCRTypes.UPDATE_TAGS:
58
+ return { type: mdm_sdk_1.EventType.UPDATE_TAGS, newValue: change.newValue };
59
+ case mdm_sdk_1.DCRTypes.UPDATE_ROLES:
60
+ return { type: mdm_sdk_1.EventType.UPDATE_ROLES, newValue: change.newValue };
61
+ case mdm_sdk_1.DCRTypes.UPDATE_START_DATE:
62
+ return { type: mdm_sdk_1.EventType.UPDATE_START_DATE, newValue: { value: (_a = change.newValue) === null || _a === void 0 ? void 0 : _a[0] } };
63
+ case mdm_sdk_1.DCRTypes.UPDATE_END_DATE:
64
+ return { type: mdm_sdk_1.EventType.UPDATE_END_DATE, newValue: { value: (_b = change.newValue) === null || _b === void 0 ? void 0 : _b[0] } };
65
+ default:
66
+ return null;
67
+ }
68
+ };
26
69
  exports.getEntitiesObjects = (0, ramda_1.filter)((0, ramda_1.pipe)((0, ramda_1.prop)('uri'), mdm_sdk_1.isEntityUri));
27
70
  exports.getRelationsObjects = (0, ramda_1.filter)((0, ramda_1.pipe)((0, ramda_1.prop)('uri'), mdm_sdk_1.isRelationUri));
28
71
  var getRelations = function (objectsWithChanges, entityUri) {
@@ -45,11 +88,12 @@ exports.createEntityRelationsObjectByRelation = (0, ramda_1.curry)(function (obj
45
88
  return entity ? { entity: __assign(__assign({}, entity), { uri: relation.startObjectUri }), relations: relations } : { relations: relations };
46
89
  });
47
90
  var concatEntityRelationsObjects = function (acc, object) {
91
+ var _a, _b;
48
92
  var entity = object.entity, relations = object.relations;
49
93
  var entityUri = entity.uri;
50
94
  var mergedRelations = (0, ramda_1.pipe)((0, ramda_1.pathOr)([], [entityUri, 'relations']), (0, ramda_1.concat)(relations), ramda_1.uniq)(acc);
51
95
  acc[entityUri] = {
52
- entity: entity,
96
+ entity: (_b = (_a = acc[entityUri]) === null || _a === void 0 ? void 0 : _a.entity) !== null && _b !== void 0 ? _b : entity,
53
97
  relations: mergedRelations
54
98
  };
55
99
  return acc;
@@ -64,7 +108,7 @@ var isCreateEntityOperation = function (dcr) {
64
108
  };
65
109
  exports.isCreateEntityOperation = isCreateEntityOperation;
66
110
  var cleanValueRecursively = function (value) {
67
- if (typeof value === 'string' || (0, ramda_1.isEmpty)(value)) {
111
+ if ((0, ramda_1.isNil)(value) || typeof value === 'string' || (0, ramda_1.isEmpty)(value)) {
68
112
  return value;
69
113
  }
70
114
  var cleanedProperties = (0, ramda_1.map)(function (propertyValues) {
@@ -76,7 +120,7 @@ var cleanValueRecursively = function (value) {
76
120
  })
77
121
  .filter(function (item) {
78
122
  var itemValue = item.value;
79
- return !(0, ramda_1.isEmpty)(itemValue) && !(0, ramda_1.isNil)(itemValue);
123
+ return (!(0, ramda_1.isEmpty)(itemValue) && !(0, ramda_1.isNil)(itemValue)) || 'lookupCode' in item;
80
124
  });
81
125
  }, value);
82
126
  return (0, ramda_1.filter)(function (propertyValues) { return !(0, ramda_1.isEmpty)(propertyValues); }, cleanedProperties);
@@ -116,12 +160,16 @@ var calculateValuePath = function (key, change) {
116
160
  case mdm_sdk_1.DCRTypes.UPDATE_END_DATE:
117
161
  return __spreadArray(__spreadArray([], path, true), [0], false);
118
162
  case mdm_sdk_1.DCRTypes.CREATE_RELATIONSHIP:
163
+ case mdm_sdk_1.DCRTypes.CREATE_ENTITY:
119
164
  if (path.length === 2) {
120
- if (path[1] === 'activeness.startDate') {
121
- return [path[0], 'startDate'];
122
- }
123
- if (path[1] === 'activeness.endDate') {
124
- return [path[0], 'endDate'];
165
+ switch (path[1]) {
166
+ case 'roles':
167
+ case 'tags':
168
+ return path;
169
+ case 'activeness.startDate':
170
+ return [path[0], 'startDate'];
171
+ case 'activeness.endDate':
172
+ return [path[0], 'endDate'];
125
173
  }
126
174
  }
127
175
  return __spreadArray(__spreadArray([], path, true), ['value'], false);
@@ -130,6 +178,12 @@ var calculateValuePath = function (key, change) {
130
178
  }
131
179
  };
132
180
  var valuesAreEqual = function (oldValue, newValue) {
181
+ if (typeof oldValue === 'object' &&
182
+ typeof newValue === 'object' &&
183
+ !Array.isArray(oldValue) &&
184
+ !Array.isArray(newValue)) {
185
+ return (0, ramda_1.equals)(oldValue, newValue);
186
+ }
133
187
  var sortWithLocale = function (array) { return array.slice().sort(function (a, b) { return a.localeCompare(b); }); };
134
188
  if (Array.isArray(oldValue) && Array.isArray(newValue)) {
135
189
  return oldValue.length === newValue.length && (0, ramda_1.equals)(sortWithLocale(oldValue), sortWithLocale(newValue));
@@ -150,6 +204,7 @@ var buildDCRSavePlan = function (changes, getLinesByChangeId, metadata) {
150
204
  var rejectedChangeIds = [];
151
205
  var updatedChanges = {};
152
206
  var deleteAttributes = {};
207
+ var insertAttributes = {};
153
208
  for (var _i = 0, _c = Object.entries(changes); _i < _c.length; _i++) {
154
209
  var _d = _c[_i], objectUri = _d[0], objectChanges = _d[1];
155
210
  var rawChanges = new Map();
@@ -159,18 +214,28 @@ var buildDCRSavePlan = function (changes, getLinesByChangeId, metadata) {
159
214
  var key = _a[0], lineData = _a[1];
160
215
  return key.split('/').length === 3 &&
161
216
  (lineData.isRejected ||
162
- ((0, ramda_1.isEmpty)((_b = lineData.value) === null || _b === void 0 ? void 0 : _b.value) && change.type !== mdm_sdk_1.DCRTypes.UPDATE_ATTRIBUTE));
217
+ ((0, mdm_sdk_1.isEmptyValue)((_b = lineData.value) === null || _b === void 0 ? void 0 : _b.value) && change.type !== mdm_sdk_1.DCRTypes.UPDATE_ATTRIBUTE));
163
218
  }))(change), rejectedRootLines = _h[0], otherLines = _h[1];
164
- rejectedChangeIds.push.apply(rejectedChangeIds, rejectedRootLines.map(function (_a) {
165
- var key = _a[0];
166
- return key.split('/')[1];
167
- }));
219
+ var isNew = isAddedChange(change.id);
220
+ if (!isNew) {
221
+ rejectedChangeIds.push.apply(rejectedChangeIds, rejectedRootLines.map(function (_a) {
222
+ var key = _a[0];
223
+ return key.split('/')[1];
224
+ }));
225
+ }
226
+ var newValueObj = change.newValue;
227
+ var hasNonEmptyNewValue = Array.isArray(change.newValue) ||
228
+ !(0, mdm_sdk_1.isEmptyValue)(newValueObj === null || newValueObj === void 0 ? void 0 : newValueObj.value) ||
229
+ 'lookupCode' in (newValueObj !== null && newValueObj !== void 0 ? newValueObj : {});
230
+ if (isNew && otherLines.length === 0 && rejectedRootLines.length === 0 && hasNonEmptyNewValue) {
231
+ rawChanges.set(change.id, change);
232
+ }
168
233
  var rejectedRootLinesMap = new Map(rejectedRootLines);
169
234
  for (var _j = 0, otherLines_1 = otherLines; _j < otherLines_1.length; _j++) {
170
235
  var _k = otherLines_1[_j], key = _k[0], lineData = _k[1];
171
236
  var rootId = key.split('/').slice(0, 3).join('/');
172
237
  var newValue = (_a = lineData.value) === null || _a === void 0 ? void 0 : _a.value;
173
- if (rootId === key && change.type === mdm_sdk_1.DCRTypes.UPDATE_ATTRIBUTE && (0, ramda_1.isEmpty)(newValue)) {
238
+ if (!isNew && rootId === key && change.type === mdm_sdk_1.DCRTypes.UPDATE_ATTRIBUTE && (0, mdm_sdk_1.isEmptyValue)(newValue)) {
174
239
  var attributeUri = [objectUri, 'attributes', change.attributePath].join('/');
175
240
  var entry = __assign(__assign({}, (0, mdm_sdk_1.createEntryDeleteAttribute)({ uri: attributeUri })[0]), (change.crosswalk && { crosswalk: change.crosswalk }));
176
241
  deleteAttributes[objectUri] = (0, ramda_1.uniqBy)((0, ramda_1.prop)('uri'), (0, ramda_1.append)(entry, (0, ramda_1.propOr)([], objectUri, deleteAttributes)));
@@ -182,18 +247,28 @@ var buildDCRSavePlan = function (changes, getLinesByChangeId, metadata) {
182
247
  var oldValue = getOldValueByNewValuePath(valuePath, change);
183
248
  var initialChange = rawChanges.has(change.id) ? rawChanges.get(change.id) : change;
184
249
  var updatedChange = void 0;
185
- if (lineData.isRejected || (0, ramda_1.isEmpty)(newValue)) {
250
+ if (lineData.isRejected || (0, mdm_sdk_1.isEmptyValue)(newValue)) {
186
251
  updatedChange = (0, ramda_1.assocPath)(valuePath, null, initialChange);
187
252
  }
188
253
  else if (!valuesAreEqual(oldDCRValue, newValue)) {
189
254
  if (oldValue && valuesAreEqual(oldValue, newValue)) {
190
- rejectedChangeIds.push(change.id);
255
+ if (!isNew) {
256
+ rejectedChangeIds.push(change.id);
257
+ }
191
258
  }
192
259
  else {
193
260
  var processedNewValue = typeof oldDCRValue === 'string' && typeof newValue === 'number'
194
261
  ? newValue.toString()
195
262
  : newValue;
196
263
  updatedChange = (0, ramda_1.assocPath)(valuePath, processedNewValue, initialChange);
264
+ var lineValue = lineData.value;
265
+ if (lineValue && typeof lineValue === 'object' && 'lookupCode' in lineValue) {
266
+ var parentPath = valuePath.slice(0, -1);
267
+ updatedChange = (0, ramda_1.assocPath)(__spreadArray(__spreadArray([], parentPath, true), ['lookupCode'], false), lineValue.lookupCode, updatedChange);
268
+ if ('lookupRawValue' in lineValue) {
269
+ updatedChange = (0, ramda_1.assocPath)(__spreadArray(__spreadArray([], parentPath, true), ['lookupRawValue'], false), lineValue.lookupRawValue, updatedChange);
270
+ }
271
+ }
197
272
  }
198
273
  }
199
274
  if (updatedChange) {
@@ -212,7 +287,15 @@ var buildDCRSavePlan = function (changes, getLinesByChangeId, metadata) {
212
287
  var isNestedChange = (0, ramda_1.has)('attributeType', cleanedChange) &&
213
288
  (0, mdm_sdk_1.isNested)((0, mdm_sdk_1.findAttributeTypeByUri)(metadata, cleanedChange.attributeType));
214
289
  if (isNestedChange && (0, ramda_1.isEmpty)((_b = cleanedChange.newValue) === null || _b === void 0 ? void 0 : _b.value)) {
215
- rejectedChangeIds.push(cleanedChange.id);
290
+ if (!isAddedChange(cleanedChange.id)) {
291
+ rejectedChangeIds.push(cleanedChange.id);
292
+ }
293
+ }
294
+ else if (isAddedChange(cleanedChange.id)) {
295
+ var diffEntry = dcrChangeToInsertDiffEntry(cleanedChange, objectUri, metadata);
296
+ if (diffEntry) {
297
+ insertAttributes[objectUri] = (0, ramda_1.append)(diffEntry, (0, ramda_1.propOr)([], objectUri, insertAttributes));
298
+ }
216
299
  }
217
300
  else {
218
301
  updatedChanges[objectUri] = (0, ramda_1.append)(cleanedChange, (0, ramda_1.propOr)([], objectUri, updatedChanges));
@@ -227,11 +310,32 @@ var buildDCRSavePlan = function (changes, getLinesByChangeId, metadata) {
227
310
  }, (0, ramda_1.toPairs)(deleteAttributes));
228
311
  var deleteRelationAttributes = (0, ramda_1.fromPairs)(deleteAttributesGroups.relation || []);
229
312
  var deleteEntityAttributes = (0, ramda_1.fromPairs)(deleteAttributesGroups.entity || []);
313
+ var insertAttributesGroups = (0, ramda_1.groupBy)(function (_a) {
314
+ var uri = _a[0];
315
+ return ((0, mdm_sdk_1.isRelationUri)(uri) ? 'relation' : 'entity');
316
+ }, (0, ramda_1.toPairs)(insertAttributes));
317
+ var insertRelationAttributes = (0, ramda_1.fromPairs)(insertAttributesGroups.relation || []);
318
+ var insertEntityAttributes = (0, ramda_1.fromPairs)(insertAttributesGroups.entity || []);
230
319
  return {
231
320
  rejectedChangeIds: rejectedChangeIds,
232
321
  updatedChanges: updatedChanges,
233
322
  deleteEntityAttributes: deleteEntityAttributes,
234
- deleteRelationAttributes: deleteRelationAttributes
323
+ deleteRelationAttributes: deleteRelationAttributes,
324
+ insertEntityAttributes: insertEntityAttributes,
325
+ insertRelationAttributes: insertRelationAttributes
235
326
  };
236
327
  };
237
328
  exports.buildDCRSavePlan = buildDCRSavePlan;
329
+ var mergeExistingRolesAndTags = function (diff, entity) {
330
+ return diff.map(function (entry) {
331
+ var _a, _b;
332
+ if (entry.type === mdm_sdk_1.EventType.UPDATE_TAGS && ((_a = entity.tags) === null || _a === void 0 ? void 0 : _a.length)) {
333
+ return __assign(__assign({}, entry), { newValue: (0, ramda_1.uniq)(__spreadArray(__spreadArray([], entity.tags, true), entry.newValue, true)) });
334
+ }
335
+ if (entry.type === mdm_sdk_1.EventType.UPDATE_ROLES && ((_b = entity.roles) === null || _b === void 0 ? void 0 : _b.length)) {
336
+ return __assign(__assign({}, entry), { newValue: (0, ramda_1.uniq)(__spreadArray(__spreadArray([], entity.roles, true), entry.newValue, true)) });
337
+ }
338
+ return entry;
339
+ });
340
+ };
341
+ exports.mergeExistingRolesAndTags = mergeExistingRolesAndTags;
@@ -128,6 +128,55 @@ describe('dcr helpers tests', function () {
128
128
  'entities/10f6Jabc': objects[3]
129
129
  });
130
130
  });
131
+ it('concatEntityRelationsObjects preserves existing entity when duplicate uri appears', function () {
132
+ var originalEntity = {
133
+ uri: 'entities/10f6JMNk',
134
+ isExist: true,
135
+ label: 'Test Label',
136
+ secondaryLabel: '',
137
+ type: 'configuration/entityTypes/Type'
138
+ };
139
+ var fetchedEntity = {
140
+ uri: 'entities/10f6JMNk',
141
+ type: 'configuration/entityTypes/Type',
142
+ label: 'Test Label',
143
+ secondaryLabel: '',
144
+ roles: ['configuration/roles/Admin']
145
+ };
146
+ var objects = [
147
+ {
148
+ entity: originalEntity,
149
+ relations: [
150
+ {
151
+ uri: 'relations/rel1',
152
+ type: 'configuration/relationTypes/HasAddress',
153
+ startObjectUri: 'entities/10f6JMNk',
154
+ startObjectLabel: 'label 1',
155
+ endObjectUri: 'entities/abc',
156
+ endObjectLabel: 'label 2',
157
+ isExist: true
158
+ }
159
+ ]
160
+ },
161
+ {
162
+ entity: fetchedEntity,
163
+ relations: [
164
+ {
165
+ uri: 'relations/rel2',
166
+ type: 'configuration/relationTypes/HasAddress',
167
+ startObjectUri: 'entities/10f6JMNk',
168
+ startObjectLabel: 'label 1',
169
+ endObjectUri: 'entities/def',
170
+ endObjectLabel: 'label 3',
171
+ isExist: true
172
+ }
173
+ ]
174
+ }
175
+ ];
176
+ var result = objects.reduce(function (acc, object) { return (0, dcr_1.concatEntityRelationsObjects)(acc, object); }, {});
177
+ expect(result['entities/10f6JMNk'].entity).toBe(originalEntity);
178
+ expect(result['entities/10f6JMNk'].relations).toEqual([objects[1].relations[0], objects[0].relations[0]]);
179
+ });
131
180
  it('getEntityUriForChangeRequest behaviour', function () {
132
181
  expect((0, dcr_1.getEntityUriForChangeRequest)('dcrUri', 'entityUri')).toBe('dcrUri/changes/entityUri');
133
182
  });
@@ -146,4 +195,126 @@ describe('dcr helpers tests', function () {
146
195
  expect((0, dcr_1.isCreateEntityOperation)(change)).toBe(true);
147
196
  expect((0, dcr_1.isCreateEntityOperation)(__assign(__assign({}, change), { type: mdm_sdk_1.DCRTypes.CREATE_RELATIONSHIP }))).toBe(false);
148
197
  });
198
+ describe('buildDCRSavePlan', function () {
199
+ var emptyMetadata = { entityTypes: [], relationTypes: [] };
200
+ var noLineData = function () { return []; };
201
+ var emptyPlan = {
202
+ rejectedChangeIds: [],
203
+ updatedChanges: {},
204
+ deleteEntityAttributes: {},
205
+ deleteRelationAttributes: {},
206
+ insertEntityAttributes: {},
207
+ insertRelationAttributes: {}
208
+ };
209
+ it('should include added attribute with defaultValue when no lineData exists', function () {
210
+ var changes = {
211
+ 'entities/456': [
212
+ {
213
+ id: 'added|simple1',
214
+ type: mdm_sdk_1.DCRTypes.INSERT_ATTRIBUTE,
215
+ attributePath: 'Surname',
216
+ attributeType: 'configuration/entityTypes/HCP/attributes/Surname',
217
+ newValue: { value: 'DefaultSurname' }
218
+ }
219
+ ]
220
+ };
221
+ var result = (0, dcr_1.buildDCRSavePlan)(changes, noLineData, emptyMetadata);
222
+ expect(result).toEqual(__assign(__assign({}, emptyPlan), { insertEntityAttributes: {
223
+ 'entities/456': [
224
+ {
225
+ type: 'INSERT_ATTRIBUTE',
226
+ uri: 'entities/456/attributes/Surname',
227
+ newValue: [{ value: 'DefaultSurname' }]
228
+ }
229
+ ]
230
+ } }));
231
+ });
232
+ it('should include added lookup attribute with lookupCode when no lineData exists', function () {
233
+ var changes = {
234
+ 'entities/456': [
235
+ {
236
+ id: 'added|lookup1',
237
+ type: mdm_sdk_1.DCRTypes.INSERT_ATTRIBUTE,
238
+ attributePath: 'Country',
239
+ attributeType: 'configuration/entityTypes/HCP/attributes/Country',
240
+ newValue: { value: '', lookupCode: 'ALBY' }
241
+ }
242
+ ]
243
+ };
244
+ var result = (0, dcr_1.buildDCRSavePlan)(changes, noLineData, emptyMetadata);
245
+ expect(result).toEqual(__assign(__assign({}, emptyPlan), { insertEntityAttributes: {
246
+ 'entities/456': [
247
+ {
248
+ type: 'INSERT_ATTRIBUTE',
249
+ uri: 'entities/456/attributes/Country',
250
+ newValue: [{ value: '', lookupCode: 'ALBY' }]
251
+ }
252
+ ]
253
+ } }));
254
+ });
255
+ it('should preserve lookup sub-attribute with lookupCode inside nested parent', function () {
256
+ var metadata = {
257
+ entityTypes: [
258
+ {
259
+ uri: 'configuration/entityTypes/HCP',
260
+ attributes: [
261
+ {
262
+ uri: 'configuration/entityTypes/HCP/attributes/Details',
263
+ name: 'Details',
264
+ type: 'Nested',
265
+ attributes: [
266
+ {
267
+ uri: 'configuration/entityTypes/HCP/attributes/Details/attributes/Country',
268
+ name: 'Country',
269
+ type: 'String'
270
+ },
271
+ {
272
+ uri: 'configuration/entityTypes/HCP/attributes/Details/attributes/Notes',
273
+ name: 'Notes',
274
+ type: 'String'
275
+ }
276
+ ]
277
+ }
278
+ ]
279
+ }
280
+ ]
281
+ };
282
+ var changes = {
283
+ 'entities/456': [
284
+ {
285
+ id: 'added|nested1',
286
+ type: mdm_sdk_1.DCRTypes.INSERT_ATTRIBUTE,
287
+ attributePath: 'Details',
288
+ attributeType: 'configuration/entityTypes/HCP/attributes/Details',
289
+ newValue: {
290
+ value: {
291
+ Country: [{ value: '', lookupCode: 'ALBY' }],
292
+ Notes: [{ value: '' }]
293
+ }
294
+ }
295
+ }
296
+ ]
297
+ };
298
+ var notesLineData = [
299
+ ['456/added|nested1/newValue/value/Notes/0', { value: { value: 'User typed note' } }]
300
+ ];
301
+ var result = (0, dcr_1.buildDCRSavePlan)(changes, function (changeId) { return (changeId === 'added|nested1' ? notesLineData : []); }, metadata);
302
+ expect(result).toEqual(__assign(__assign({}, emptyPlan), { insertEntityAttributes: {
303
+ 'entities/456': [
304
+ {
305
+ type: 'INSERT_ATTRIBUTE',
306
+ uri: 'entities/456/attributes/Details',
307
+ newValue: [
308
+ {
309
+ value: {
310
+ Country: [{ value: '', lookupCode: 'ALBY' }],
311
+ Notes: [{ value: 'User typed note' }]
312
+ }
313
+ }
314
+ ]
315
+ }
316
+ ]
317
+ } }));
318
+ });
319
+ });
149
320
  });
@@ -1,4 +1,7 @@
1
1
  import { GroupedObjectsInfo, Metadata, EnrichedDCRChanges, EnrichedChangeValue, ChangeValue, DCRChanges } from '@reltio/mdm-sdk';
2
2
  import { Diff } from '../types';
3
3
  export declare const extractLineIds: (value: ChangeValue | EnrichedChangeValue) => string[] | undefined;
4
+ export declare const extractAddedId: (value: {
5
+ addedId?: string;
6
+ }) => string | undefined;
4
7
  export declare const mergeChanges: (metadata: Metadata, changes: EnrichedDCRChanges | DCRChanges, entityInfo: GroupedObjectsInfo["entity"], relationsInfo: GroupedObjectsInfo["relations"]) => [Diff[], Diff[]];
@@ -11,7 +11,7 @@ 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.mergeChanges = exports.extractLineIds = void 0;
14
+ exports.mergeChanges = exports.extractAddedId = exports.extractLineIds = void 0;
15
15
  var ramda_1 = require("ramda");
16
16
  var mdm_sdk_1 = require("@reltio/mdm-sdk");
17
17
  var attributes_1 = require("./attributes");
@@ -27,6 +27,10 @@ var extractLineIds = function (value) {
27
27
  return typeof value === 'object' && 'lineIds' in value ? value.lineIds : undefined;
28
28
  };
29
29
  exports.extractLineIds = extractLineIds;
30
+ var extractAddedId = function (value) {
31
+ return typeof value === 'object' && value !== null && 'addedId' in value ? value.addedId : undefined;
32
+ };
33
+ exports.extractAddedId = extractAddedId;
30
34
  var prepareStartOrEndDate = function (_a) {
31
35
  var newValue = _a.newValue, oldValue = _a.oldValue;
32
36
  var actualNewValue = newValue && 'value' in newValue ? newValue.value : newValue;
@@ -72,6 +76,15 @@ var prepareStartOrEndDate = function (_a) {
72
76
  }
73
77
  ];
74
78
  }
79
+ var addedId = newValue === null || newValue === void 0 ? void 0 : newValue.addedId;
80
+ if (addedId) {
81
+ return [
82
+ {
83
+ type: mdm_sdk_1.DCRTypes.INSERT_ATTRIBUTE,
84
+ newValue: __assign({ value: undefined, lineIds: (0, exports.extractLineIds)(newValue) }, (addedId && { addedId: addedId }))
85
+ }
86
+ ];
87
+ }
75
88
  };
76
89
  var prepareRolesOrTags = function (change) {
77
90
  var _a = change.newValue, newValue = _a === void 0 ? [] : _a, _b = change.oldValue, oldValue = _b === void 0 ? [] : _b;
@@ -79,11 +92,12 @@ var prepareRolesOrTags = function (change) {
79
92
  var preparedOldValue = 'value' in oldValue ? oldValue.value : oldValue;
80
93
  var diffNewValue = (0, ramda_1.difference)(preparedNewValue, preparedOldValue);
81
94
  var diffOldValue = (0, ramda_1.difference)(preparedOldValue, preparedNewValue);
95
+ var addedId = (0, exports.extractAddedId)(newValue);
82
96
  var items = [];
83
97
  if (diffNewValue.length) {
84
98
  items.push({
85
99
  type: mdm_sdk_1.DCRTypes.INSERT_ATTRIBUTE,
86
- newValue: { value: diffNewValue, lineIds: (0, exports.extractLineIds)(newValue) }
100
+ newValue: __assign({ value: diffNewValue, lineIds: (0, exports.extractLineIds)(newValue) }, (addedId && { addedId: addedId }))
87
101
  });
88
102
  }
89
103
  if (diffOldValue.length) {
@@ -92,6 +106,12 @@ var prepareRolesOrTags = function (change) {
92
106
  oldValue: { value: diffOldValue, lineIds: (0, exports.extractLineIds)(oldValue) }
93
107
  });
94
108
  }
109
+ if (items.length === 0 && addedId) {
110
+ items.push({
111
+ type: mdm_sdk_1.DCRTypes.INSERT_ATTRIBUTE,
112
+ newValue: { value: [], lineIds: (0, exports.extractLineIds)(newValue), addedId: addedId }
113
+ });
114
+ }
95
115
  return items;
96
116
  };
97
117
  var getPath = function (change) {
@@ -147,46 +167,38 @@ var createEntityOrRelation = function (metadata, value) {
147
167
  newObject['defaultProfilePicValue'] = [defaultProfilePicValue];
148
168
  }
149
169
  if (roles) {
170
+ var addedId = (0, exports.extractAddedId)(roles);
150
171
  newObject[mdm_sdk_1.EntityAttrTypes.roles.name] = [
151
172
  {
152
173
  type: mdm_sdk_1.DCRTypes.INSERT_ATTRIBUTE,
153
- newValue: {
154
- value: roles.map((0, mdm_sdk_1.getRoleLabel)(metadata)).join(', '),
155
- lineIds: lineIds && ["".concat(lineIds[0], "/").concat(mdm_sdk_1.EntityAttrTypes.roles.name)]
156
- }
174
+ newValue: __assign({ value: addedId ? [] : roles.map((0, mdm_sdk_1.getRoleLabel)(metadata)), lineIds: lineIds && ["".concat(lineIds[0], "/").concat(mdm_sdk_1.EntityAttrTypes.roles.name)] }, (addedId && { addedId: addedId }))
157
175
  }
158
176
  ];
159
177
  }
160
178
  if (tags) {
179
+ var addedId = (0, exports.extractAddedId)(tags);
161
180
  newObject[mdm_sdk_1.EntityAttrTypes.tags.name] = [
162
181
  {
163
182
  type: mdm_sdk_1.DCRTypes.INSERT_ATTRIBUTE,
164
- newValue: {
165
- value: tags.join(', '),
166
- lineIds: lineIds && ["".concat(lineIds[0], "/").concat(mdm_sdk_1.EntityAttrTypes.tags.name)]
167
- }
183
+ newValue: __assign({ value: addedId ? [] : tags, lineIds: lineIds && ["".concat(lineIds[0], "/").concat(mdm_sdk_1.EntityAttrTypes.tags.name)] }, (addedId && { addedId: addedId }))
168
184
  }
169
185
  ];
170
186
  }
171
- if (startDate) {
187
+ if (startDate !== undefined) {
188
+ var addedId = (0, exports.extractAddedId)(startDate);
172
189
  newObject[mdm_sdk_1.EntityAttrTypes.startDate.name] = [
173
190
  {
174
191
  type: mdm_sdk_1.DCRTypes.INSERT_ATTRIBUTE,
175
- newValue: {
176
- value: startDate,
177
- lineIds: lineIds && ["".concat(lineIds[0], "/").concat(mdm_sdk_1.EntityAttrTypes.startDate.name)]
178
- }
192
+ newValue: __assign({ value: addedId ? undefined : startDate, lineIds: lineIds && ["".concat(lineIds[0], "/").concat(mdm_sdk_1.EntityAttrTypes.startDate.name)] }, (addedId && { addedId: addedId }))
179
193
  }
180
194
  ];
181
195
  }
182
- if (endDate) {
196
+ if (endDate !== undefined) {
197
+ var addedId = (0, exports.extractAddedId)(endDate);
183
198
  newObject[mdm_sdk_1.EntityAttrTypes.endDate.name] = [
184
199
  {
185
200
  type: mdm_sdk_1.DCRTypes.INSERT_ATTRIBUTE,
186
- newValue: {
187
- value: endDate,
188
- lineIds: lineIds && ["".concat(lineIds[0], "/").concat(mdm_sdk_1.EntityAttrTypes.endDate.name)]
189
- }
201
+ newValue: __assign({ value: addedId ? undefined : endDate, lineIds: lineIds && ["".concat(lineIds[0], "/").concat(mdm_sdk_1.EntityAttrTypes.endDate.name)] }, (addedId && { addedId: addedId }))
190
202
  }
191
203
  ];
192
204
  }
@@ -63,7 +63,8 @@ describe('mergeChanges tests', function () {
63
63
  level: 1,
64
64
  newValue: changes[entityUri][0].newValue,
65
65
  operation: 'ignored',
66
- isReferenceSubAttribute: false
66
+ isReferenceSubAttribute: false,
67
+ attributePath: 'Identifiers/45uypcuAz/Type/45uypcyRF'
67
68
  }
68
69
  ],
69
70
  []
@@ -0,0 +1,4 @@
1
+ import { type AttributeType, type Metadata } from '@reltio/mdm-sdk';
2
+ export declare const getAvailableAttributeTypesForEntity: (metadata: Metadata, entityTypeUri: string) => AttributeType[];
3
+ export declare const getAvailableAttributeTypesForRelation: (metadata: Metadata, relationTypeUri: string) => AttributeType[];
4
+ export declare const getAvailableSubAttributesForNestedOrReference: (metadata: Metadata, attributeType: AttributeType) => AttributeType[];
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAvailableSubAttributesForNestedOrReference = exports.getAvailableAttributeTypesForRelation = exports.getAvailableAttributeTypesForEntity = void 0;
4
+ var mdm_sdk_1 = require("@reltio/mdm-sdk");
5
+ var attributesView_1 = require("../../../helpers/attributesView");
6
+ var getAvailableAttributeTypesForEntity = function (metadata, entityTypeUri) {
7
+ return (0, mdm_sdk_1.getCreatableAttributeTypes)(mdm_sdk_1.Mode.Suggesting, (0, attributesView_1.getFilteredAttrTypes)(metadata, entityTypeUri, [], []));
8
+ };
9
+ exports.getAvailableAttributeTypesForEntity = getAvailableAttributeTypesForEntity;
10
+ var getAvailableAttributeTypesForRelation = function (metadata, relationTypeUri) {
11
+ return (0, mdm_sdk_1.getCreatableAttributeTypes)(mdm_sdk_1.Mode.Suggesting, (0, mdm_sdk_1.getRelationAttributesList)(metadata, relationTypeUri));
12
+ };
13
+ exports.getAvailableAttributeTypesForRelation = getAvailableAttributeTypesForRelation;
14
+ var getAvailableSubAttributesForNestedOrReference = function (metadata, attributeType) {
15
+ var subAttributes = (0, mdm_sdk_1.isReference)(attributeType)
16
+ ? (0, mdm_sdk_1.getEditableAttributeTypeSubAttributes)(metadata, attributeType) || []
17
+ : (0, mdm_sdk_1.getAttributeTypeSubAttributes)(metadata, attributeType) || [];
18
+ return (0, mdm_sdk_1.getCreatableAttributeTypes)(mdm_sdk_1.Mode.Suggesting, subAttributes);
19
+ };
20
+ exports.getAvailableSubAttributesForNestedOrReference = getAvailableSubAttributesForNestedOrReference;