@reltio/components 1.4.2243 → 1.4.2244

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/ActivenessDateControl/ActivenessDateControl.d.ts +9 -0
  2. package/ActivenessDateControl/ActivenessDateControl.js +11 -0
  3. package/ActivenessDateControl/index.d.ts +1 -0
  4. package/ActivenessDateControl/index.js +1 -0
  5. package/EntitySelector/EntitySelector.d.ts +2 -1
  6. package/EntitySelector/EntitySelector.js +2 -2
  7. package/EntitySelector/index.d.ts +1 -0
  8. package/MoreAttributesButton/MoreAttributesButton.d.ts +3 -2
  9. package/MoreAttributesButton/MoreAttributesButton.js +8 -8
  10. package/MoreAttributesButton/useMoreAttributesItems.d.ts +4 -4
  11. package/cjs/ActivenessDateControl/ActivenessDateControl.d.ts +9 -0
  12. package/cjs/ActivenessDateControl/ActivenessDateControl.js +18 -0
  13. package/cjs/ActivenessDateControl/index.d.ts +1 -0
  14. package/cjs/ActivenessDateControl/index.js +5 -0
  15. package/cjs/EntitySelector/EntitySelector.d.ts +2 -1
  16. package/cjs/EntitySelector/EntitySelector.js +2 -2
  17. package/cjs/EntitySelector/index.d.ts +1 -0
  18. package/cjs/MoreAttributesButton/MoreAttributesButton.d.ts +3 -2
  19. package/cjs/MoreAttributesButton/MoreAttributesButton.js +8 -8
  20. package/cjs/MoreAttributesButton/useMoreAttributesItems.d.ts +4 -4
  21. package/cjs/features/activity-log/ActivityLog/ActivityLog.test.js +28 -0
  22. package/cjs/features/activity-log/ActivityLog/components/ActivityItem/ActivityItem.js +22 -11
  23. package/cjs/features/activity-log/ActivityLog/components/ActivityItem/ActivityItem.module.css.js +9 -0
  24. package/cjs/features/activity-log/ActivityLog/constants.d.ts +17 -0
  25. package/cjs/features/activity-log/ActivityLog/constants.js +20 -0
  26. package/cjs/features/workflow/ChangeRequestEditor/ChangeRequestEditor.d.ts +1 -1
  27. package/cjs/features/workflow/ChangeRequestEditor/ChangeRequestEditor.js +20 -9
  28. package/cjs/features/workflow/ChangeRequestEditor/components/AddSameAttributeButton/AddSameAttributeButton.d.ts +7 -0
  29. package/cjs/features/workflow/ChangeRequestEditor/components/AddSameAttributeButton/AddSameAttributeButton.js +67 -0
  30. package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemLabel/ChangeItemLabel.js +3 -1
  31. package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemLabel/ChangeItemLabel.module.css.js +2 -2
  32. package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.d.ts +2 -2
  33. package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.js +25 -6
  34. package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.module.css.js +2 -2
  35. package/cjs/features/workflow/ChangeRequestEditor/components/DCRImageEditor/DCRImageEditor.d.ts +9 -0
  36. package/cjs/features/workflow/ChangeRequestEditor/components/DCRImageEditor/DCRImageEditor.js +79 -0
  37. package/cjs/features/workflow/ChangeRequestEditor/components/DCRImageEditor/index.d.ts +1 -0
  38. package/cjs/features/workflow/ChangeRequestEditor/components/DCRImageEditor/index.js +5 -0
  39. package/cjs/features/workflow/ChangeRequestEditor/components/DCRValueEditorFactory/DCRValueEditorFactory.d.ts +2 -2
  40. package/cjs/features/workflow/ChangeRequestEditor/components/DCRValueEditorFactory/DCRValueEditorFactory.js +2 -2
  41. package/cjs/features/workflow/ChangeRequestEditor/components/EditorStatusChip/EditorStatusChip.d.ts +11 -0
  42. package/cjs/features/workflow/ChangeRequestEditor/components/EditorStatusChip/EditorStatusChip.js +41 -0
  43. package/cjs/features/workflow/ChangeRequestEditor/components/EditorStatusChip/EditorStatusChip.module.css.js +9 -0
  44. package/cjs/features/workflow/ChangeRequestEditor/components/EditorStatusChip/index.d.ts +1 -0
  45. package/cjs/features/workflow/ChangeRequestEditor/components/EditorStatusChip/index.js +6 -0
  46. package/cjs/features/workflow/ChangeRequestEditor/components/EntityChangesGroup/EntityChangesGroup.d.ts +1 -1
  47. package/cjs/features/workflow/ChangeRequestEditor/components/EntityChangesGroup/EntityChangesGroup.js +134 -5
  48. package/cjs/features/workflow/ChangeRequestEditor/components/EntityChangesGroup/SkeletonEntityChangesGroupLoader.js +2 -2
  49. package/cjs/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemEditor}/ChangeItemEditor.d.ts +1 -1
  50. package/cjs/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditor/ChangeItemEditor.js +110 -0
  51. package/cjs/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditor/ChangeItemEditor.module.css.js +9 -0
  52. package/cjs/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemEditor}/SkeletonChangeItemEditorLoader.js +6 -5
  53. package/cjs/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemEditor}/index.d.ts +0 -1
  54. package/cjs/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemEditor}/index.js +1 -3
  55. package/cjs/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditorRecentlyAdded/ChangeItemEditorRecentlyAdded.d.ts +8 -0
  56. package/cjs/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditorRecentlyAdded/ChangeItemEditorRecentlyAdded.js +89 -0
  57. package/cjs/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditorRecentlyAdded/index.d.ts +1 -0
  58. package/cjs/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditorRecentlyAdded/index.js +5 -0
  59. package/cjs/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemOldValue}/ChangeItemOldValue.d.ts +1 -1
  60. package/cjs/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemOldValue}/ChangeItemOldValue.js +12 -11
  61. package/cjs/features/workflow/ChangeRequestEditor/components/editors/ChangeItemOldValue/ChangeItemOldValue.module.css.js +9 -0
  62. package/cjs/features/workflow/ChangeRequestEditor/components/editors/ChangeItemOldValue/index.d.ts +1 -0
  63. package/cjs/features/workflow/ChangeRequestEditor/components/editors/ChangeItemOldValue/index.js +5 -0
  64. package/cjs/features/workflow/ChangeRequestEditor/components/editors/MoreAttributesEditor/MoreAttributesEditor.d.ts +11 -0
  65. package/cjs/features/workflow/ChangeRequestEditor/components/editors/MoreAttributesEditor/MoreAttributesEditor.js +34 -0
  66. package/cjs/features/workflow/ChangeRequestEditor/components/editors/MoreAttributesEditor/MoreAttributesEditor.module.css.js +9 -0
  67. package/cjs/features/workflow/ChangeRequestEditor/components/editors/MoreAttributesEditor/index.d.ts +1 -0
  68. package/cjs/features/workflow/ChangeRequestEditor/components/editors/MoreAttributesEditor/index.js +5 -0
  69. package/cjs/features/workflow/ChangeRequestEditor/components/editors/editors.module.css.js +9 -0
  70. package/cjs/features/workflow/ChangeRequestEditor/components/editors/index.d.ts +4 -0
  71. package/cjs/features/workflow/ChangeRequestEditor/components/editors/index.js +12 -0
  72. package/cjs/features/workflow/ChangeRequestEditor/helpers/addedAttributes.d.ts +11 -0
  73. package/cjs/features/workflow/ChangeRequestEditor/helpers/addedAttributes.js +74 -0
  74. package/cjs/features/workflow/ChangeRequestEditor/helpers/changesList.d.ts +2 -0
  75. package/cjs/features/workflow/ChangeRequestEditor/helpers/changesList.js +157 -0
  76. package/cjs/features/workflow/ChangeRequestEditor/helpers/changesList.test.d.ts +1 -0
  77. package/cjs/features/workflow/ChangeRequestEditor/helpers/changesList.test.js +203 -0
  78. package/cjs/features/workflow/ChangeRequestEditor/helpers/helpers.d.ts +6 -3
  79. package/cjs/features/workflow/ChangeRequestEditor/helpers/helpers.js +22 -3
  80. package/cjs/features/workflow/ChangeRequestEditor/helpers/mergeAddedAttributesWithDCRChanges.d.ts +3 -0
  81. package/cjs/features/workflow/ChangeRequestEditor/helpers/mergeAddedAttributesWithDCRChanges.js +190 -0
  82. package/cjs/features/workflow/ChangeRequestEditor/helpers/mergeAddedAttributesWithDCRChanges.test.d.ts +1 -0
  83. package/cjs/features/workflow/ChangeRequestEditor/helpers/mergeAddedAttributesWithDCRChanges.test.js +768 -0
  84. package/cjs/features/workflow/ChangeRequestEditor/hooks/useChangeRequestEditor.d.ts +4 -3
  85. package/cjs/features/workflow/ChangeRequestEditor/hooks/useChangeRequestEditor.js +9 -1
  86. package/cjs/features/workflow/ChangeRequestEditor/hooks/useNewAttributesEditor.d.ts +18 -0
  87. package/cjs/features/workflow/ChangeRequestEditor/hooks/useNewAttributesEditor.js +65 -0
  88. package/cjs/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.js +7 -3
  89. package/cjs/features/workflow/contexts/AddedAttributesContext/index.d.ts +39 -0
  90. package/cjs/features/workflow/contexts/AddedAttributesContext/index.js +152 -0
  91. package/cjs/features/workflow/contexts/ChangeRequestEditorContext/index.d.ts +3 -2
  92. package/cjs/features/workflow/contexts/ChangeRequestEditorContext/index.js +47 -7
  93. package/cjs/features/workflow/contexts/ScrollToAddedAttributeContext/index.d.ts +11 -0
  94. package/cjs/features/workflow/contexts/ScrollToAddedAttributeContext/index.js +78 -0
  95. package/cjs/features/workflow/helpers/attributes.js +16 -13
  96. package/cjs/features/workflow/helpers/attributes.test.js +6 -3
  97. package/cjs/features/workflow/helpers/dcr.d.ts +6 -1
  98. package/cjs/features/workflow/helpers/dcr.js +113 -18
  99. package/cjs/features/workflow/helpers/dcr.test.js +122 -0
  100. package/cjs/features/workflow/helpers/merge.d.ts +3 -0
  101. package/cjs/features/workflow/helpers/merge.js +32 -20
  102. package/cjs/features/workflow/helpers/merge.test.js +2 -1
  103. package/cjs/features/workflow/helpers/moreAttributesScope.d.ts +4 -0
  104. package/cjs/features/workflow/helpers/moreAttributesScope.js +20 -0
  105. package/cjs/features/workflow/helpers/validation.js +31 -6
  106. package/cjs/features/workflow/hooks/useApplyDcrChanges.d.ts +2 -2
  107. package/cjs/features/workflow/hooks/useApplyDcrChanges.js +80 -63
  108. package/cjs/features/workflow/types.d.ts +12 -2
  109. package/features/activity-log/ActivityLog/ActivityLog.test.js +28 -0
  110. package/features/activity-log/ActivityLog/components/ActivityItem/ActivityItem.js +15 -4
  111. package/features/activity-log/ActivityLog/components/ActivityItem/ActivityItem.module.css.js +9 -0
  112. package/features/activity-log/ActivityLog/constants.d.ts +17 -0
  113. package/features/activity-log/ActivityLog/constants.js +17 -0
  114. package/features/workflow/ChangeRequestEditor/ChangeRequestEditor.d.ts +1 -1
  115. package/features/workflow/ChangeRequestEditor/ChangeRequestEditor.js +20 -9
  116. package/features/workflow/ChangeRequestEditor/components/AddSameAttributeButton/AddSameAttributeButton.d.ts +7 -0
  117. package/features/workflow/ChangeRequestEditor/components/AddSameAttributeButton/AddSameAttributeButton.js +37 -0
  118. package/features/workflow/ChangeRequestEditor/components/ChangeItemLabel/ChangeItemLabel.js +3 -1
  119. package/features/workflow/ChangeRequestEditor/components/ChangeItemLabel/ChangeItemLabel.module.css.js +2 -2
  120. package/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.d.ts +2 -2
  121. package/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.js +26 -7
  122. package/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.module.css.js +2 -2
  123. package/features/workflow/ChangeRequestEditor/components/DCRImageEditor/DCRImageEditor.d.ts +9 -0
  124. package/features/workflow/ChangeRequestEditor/components/DCRImageEditor/DCRImageEditor.js +49 -0
  125. package/features/workflow/ChangeRequestEditor/components/DCRImageEditor/index.d.ts +1 -0
  126. package/features/workflow/ChangeRequestEditor/components/DCRImageEditor/index.js +1 -0
  127. package/features/workflow/ChangeRequestEditor/components/DCRValueEditorFactory/DCRValueEditorFactory.d.ts +2 -2
  128. package/features/workflow/ChangeRequestEditor/components/DCRValueEditorFactory/DCRValueEditorFactory.js +2 -2
  129. package/features/workflow/ChangeRequestEditor/components/EditorStatusChip/EditorStatusChip.d.ts +11 -0
  130. package/features/workflow/ChangeRequestEditor/components/EditorStatusChip/EditorStatusChip.js +34 -0
  131. package/features/workflow/ChangeRequestEditor/components/EditorStatusChip/EditorStatusChip.module.css.js +9 -0
  132. package/features/workflow/ChangeRequestEditor/components/EditorStatusChip/index.d.ts +1 -0
  133. package/features/workflow/ChangeRequestEditor/components/EditorStatusChip/index.js +1 -0
  134. package/features/workflow/ChangeRequestEditor/components/EntityChangesGroup/EntityChangesGroup.d.ts +1 -1
  135. package/features/workflow/ChangeRequestEditor/components/EntityChangesGroup/EntityChangesGroup.js +112 -6
  136. package/features/workflow/ChangeRequestEditor/components/EntityChangesGroup/SkeletonEntityChangesGroupLoader.js +1 -1
  137. package/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemEditor}/ChangeItemEditor.d.ts +1 -1
  138. package/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditor/ChangeItemEditor.js +80 -0
  139. package/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditor/ChangeItemEditor.module.css.js +9 -0
  140. package/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemEditor}/SkeletonChangeItemEditorLoader.js +6 -5
  141. package/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemEditor}/index.d.ts +0 -1
  142. package/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemEditor}/index.js +0 -1
  143. package/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditorRecentlyAdded/ChangeItemEditorRecentlyAdded.d.ts +8 -0
  144. package/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditorRecentlyAdded/ChangeItemEditorRecentlyAdded.js +59 -0
  145. package/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditorRecentlyAdded/index.d.ts +1 -0
  146. package/features/workflow/ChangeRequestEditor/components/editors/ChangeItemEditorRecentlyAdded/index.js +1 -0
  147. package/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemOldValue}/ChangeItemOldValue.d.ts +1 -1
  148. package/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemOldValue}/ChangeItemOldValue.js +10 -9
  149. package/features/workflow/ChangeRequestEditor/components/editors/ChangeItemOldValue/ChangeItemOldValue.module.css.js +9 -0
  150. package/features/workflow/ChangeRequestEditor/components/editors/ChangeItemOldValue/index.d.ts +1 -0
  151. package/features/workflow/ChangeRequestEditor/components/editors/ChangeItemOldValue/index.js +1 -0
  152. package/features/workflow/ChangeRequestEditor/components/editors/MoreAttributesEditor/MoreAttributesEditor.d.ts +11 -0
  153. package/features/workflow/ChangeRequestEditor/components/editors/MoreAttributesEditor/MoreAttributesEditor.js +27 -0
  154. package/features/workflow/ChangeRequestEditor/components/editors/MoreAttributesEditor/MoreAttributesEditor.module.css.js +9 -0
  155. package/features/workflow/ChangeRequestEditor/components/editors/MoreAttributesEditor/index.d.ts +1 -0
  156. package/features/workflow/ChangeRequestEditor/components/editors/MoreAttributesEditor/index.js +1 -0
  157. package/features/workflow/ChangeRequestEditor/components/editors/editors.module.css.js +9 -0
  158. package/features/workflow/ChangeRequestEditor/components/editors/index.d.ts +4 -0
  159. package/features/workflow/ChangeRequestEditor/components/editors/index.js +4 -0
  160. package/features/workflow/ChangeRequestEditor/helpers/addedAttributes.d.ts +11 -0
  161. package/features/workflow/ChangeRequestEditor/helpers/addedAttributes.js +62 -0
  162. package/features/workflow/ChangeRequestEditor/helpers/changesList.d.ts +2 -0
  163. package/features/workflow/ChangeRequestEditor/helpers/changesList.js +153 -0
  164. package/features/workflow/ChangeRequestEditor/helpers/changesList.test.d.ts +1 -0
  165. package/features/workflow/ChangeRequestEditor/helpers/changesList.test.js +201 -0
  166. package/features/workflow/ChangeRequestEditor/helpers/helpers.d.ts +6 -3
  167. package/features/workflow/ChangeRequestEditor/helpers/helpers.js +19 -3
  168. package/features/workflow/ChangeRequestEditor/helpers/mergeAddedAttributesWithDCRChanges.d.ts +3 -0
  169. package/features/workflow/ChangeRequestEditor/helpers/mergeAddedAttributesWithDCRChanges.js +186 -0
  170. package/features/workflow/ChangeRequestEditor/helpers/mergeAddedAttributesWithDCRChanges.test.d.ts +1 -0
  171. package/features/workflow/ChangeRequestEditor/helpers/mergeAddedAttributesWithDCRChanges.test.js +766 -0
  172. package/features/workflow/ChangeRequestEditor/hooks/useChangeRequestEditor.d.ts +4 -3
  173. package/features/workflow/ChangeRequestEditor/hooks/useChangeRequestEditor.js +9 -1
  174. package/features/workflow/ChangeRequestEditor/hooks/useNewAttributesEditor.d.ts +18 -0
  175. package/features/workflow/ChangeRequestEditor/hooks/useNewAttributesEditor.js +61 -0
  176. package/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.js +7 -3
  177. package/features/workflow/contexts/AddedAttributesContext/index.d.ts +39 -0
  178. package/features/workflow/contexts/AddedAttributesContext/index.js +125 -0
  179. package/features/workflow/contexts/ChangeRequestEditorContext/index.d.ts +3 -2
  180. package/features/workflow/contexts/ChangeRequestEditorContext/index.js +47 -7
  181. package/features/workflow/contexts/ScrollToAddedAttributeContext/index.d.ts +11 -0
  182. package/features/workflow/contexts/ScrollToAddedAttributeContext/index.js +51 -0
  183. package/features/workflow/helpers/attributes.js +16 -13
  184. package/features/workflow/helpers/attributes.test.js +6 -3
  185. package/features/workflow/helpers/dcr.d.ts +6 -1
  186. package/features/workflow/helpers/dcr.js +112 -18
  187. package/features/workflow/helpers/dcr.test.js +123 -1
  188. package/features/workflow/helpers/merge.d.ts +3 -0
  189. package/features/workflow/helpers/merge.js +30 -19
  190. package/features/workflow/helpers/merge.test.js +2 -1
  191. package/features/workflow/helpers/moreAttributesScope.d.ts +4 -0
  192. package/features/workflow/helpers/moreAttributesScope.js +14 -0
  193. package/features/workflow/helpers/validation.js +31 -6
  194. package/features/workflow/hooks/useApplyDcrChanges.d.ts +2 -2
  195. package/features/workflow/hooks/useApplyDcrChanges.js +83 -66
  196. package/features/workflow/types.d.ts +12 -2
  197. package/package.json +2 -2
  198. package/cjs/features/activity-log/ActivityLog/components/ActivityItem/styles.d.ts +0 -1
  199. package/cjs/features/activity-log/ActivityLog/components/ActivityItem/styles.js +0 -57
  200. package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemEditor/ChangeItemEditor.js +0 -95
  201. package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemEditor/ChangeItemEditor.module.css.js +0 -9
  202. package/cjs/features/workflow/ChangeRequestEditor/components/StatusChips/StatusChips.d.ts +0 -7
  203. package/cjs/features/workflow/ChangeRequestEditor/components/StatusChips/StatusChips.js +0 -21
  204. package/cjs/features/workflow/ChangeRequestEditor/components/StatusChips/StatusChips.module.css.js +0 -9
  205. package/cjs/features/workflow/ChangeRequestEditor/components/StatusChips/index.d.ts +0 -1
  206. package/cjs/features/workflow/ChangeRequestEditor/components/StatusChips/index.js +0 -5
  207. package/features/activity-log/ActivityLog/components/ActivityItem/styles.d.ts +0 -1
  208. package/features/activity-log/ActivityLog/components/ActivityItem/styles.js +0 -54
  209. package/features/workflow/ChangeRequestEditor/components/ChangeItemEditor/ChangeItemEditor.js +0 -65
  210. package/features/workflow/ChangeRequestEditor/components/ChangeItemEditor/ChangeItemEditor.module.css.js +0 -9
  211. package/features/workflow/ChangeRequestEditor/components/StatusChips/StatusChips.d.ts +0 -7
  212. package/features/workflow/ChangeRequestEditor/components/StatusChips/StatusChips.js +0 -14
  213. package/features/workflow/ChangeRequestEditor/components/StatusChips/StatusChips.module.css.js +0 -9
  214. package/features/workflow/ChangeRequestEditor/components/StatusChips/index.d.ts +0 -1
  215. package/features/workflow/ChangeRequestEditor/components/StatusChips/index.js +0 -1
  216. /package/cjs/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemEditor}/SkeletonChangeItemEditorLoader.d.ts +0 -0
  217. /package/features/workflow/ChangeRequestEditor/components/{ChangeItemEditor → editors/ChangeItemEditor}/SkeletonChangeItemEditorLoader.d.ts +0 -0
@@ -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) {
@@ -64,7 +107,7 @@ var isCreateEntityOperation = function (dcr) {
64
107
  };
65
108
  exports.isCreateEntityOperation = isCreateEntityOperation;
66
109
  var cleanValueRecursively = function (value) {
67
- if (typeof value === 'string' || (0, ramda_1.isEmpty)(value)) {
110
+ if ((0, ramda_1.isNil)(value) || typeof value === 'string' || (0, ramda_1.isEmpty)(value)) {
68
111
  return value;
69
112
  }
70
113
  var cleanedProperties = (0, ramda_1.map)(function (propertyValues) {
@@ -76,7 +119,7 @@ var cleanValueRecursively = function (value) {
76
119
  })
77
120
  .filter(function (item) {
78
121
  var itemValue = item.value;
79
- return !(0, ramda_1.isEmpty)(itemValue) && !(0, ramda_1.isNil)(itemValue);
122
+ return (!(0, ramda_1.isEmpty)(itemValue) && !(0, ramda_1.isNil)(itemValue)) || 'lookupCode' in item;
80
123
  });
81
124
  }, value);
82
125
  return (0, ramda_1.filter)(function (propertyValues) { return !(0, ramda_1.isEmpty)(propertyValues); }, cleanedProperties);
@@ -116,12 +159,16 @@ var calculateValuePath = function (key, change) {
116
159
  case mdm_sdk_1.DCRTypes.UPDATE_END_DATE:
117
160
  return __spreadArray(__spreadArray([], path, true), [0], false);
118
161
  case mdm_sdk_1.DCRTypes.CREATE_RELATIONSHIP:
162
+ case mdm_sdk_1.DCRTypes.CREATE_ENTITY:
119
163
  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'];
164
+ switch (path[1]) {
165
+ case 'roles':
166
+ case 'tags':
167
+ return path;
168
+ case 'activeness.startDate':
169
+ return [path[0], 'startDate'];
170
+ case 'activeness.endDate':
171
+ return [path[0], 'endDate'];
125
172
  }
126
173
  }
127
174
  return __spreadArray(__spreadArray([], path, true), ['value'], false);
@@ -130,6 +177,12 @@ var calculateValuePath = function (key, change) {
130
177
  }
131
178
  };
132
179
  var valuesAreEqual = function (oldValue, newValue) {
180
+ if (typeof oldValue === 'object' &&
181
+ typeof newValue === 'object' &&
182
+ !Array.isArray(oldValue) &&
183
+ !Array.isArray(newValue)) {
184
+ return (0, ramda_1.equals)(oldValue, newValue);
185
+ }
133
186
  var sortWithLocale = function (array) { return array.slice().sort(function (a, b) { return a.localeCompare(b); }); };
134
187
  if (Array.isArray(oldValue) && Array.isArray(newValue)) {
135
188
  return oldValue.length === newValue.length && (0, ramda_1.equals)(sortWithLocale(oldValue), sortWithLocale(newValue));
@@ -150,6 +203,7 @@ var buildDCRSavePlan = function (changes, getLinesByChangeId, metadata) {
150
203
  var rejectedChangeIds = [];
151
204
  var updatedChanges = {};
152
205
  var deleteAttributes = {};
206
+ var insertAttributes = {};
153
207
  for (var _i = 0, _c = Object.entries(changes); _i < _c.length; _i++) {
154
208
  var _d = _c[_i], objectUri = _d[0], objectChanges = _d[1];
155
209
  var rawChanges = new Map();
@@ -159,18 +213,28 @@ var buildDCRSavePlan = function (changes, getLinesByChangeId, metadata) {
159
213
  var key = _a[0], lineData = _a[1];
160
214
  return key.split('/').length === 3 &&
161
215
  (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));
216
+ ((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
217
  }))(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
- }));
218
+ var isNew = isAddedChange(change.id);
219
+ if (!isNew) {
220
+ rejectedChangeIds.push.apply(rejectedChangeIds, rejectedRootLines.map(function (_a) {
221
+ var key = _a[0];
222
+ return key.split('/')[1];
223
+ }));
224
+ }
225
+ var newValueObj = change.newValue;
226
+ var hasNonEmptyNewValue = Array.isArray(change.newValue) ||
227
+ !(0, mdm_sdk_1.isEmptyValue)(newValueObj === null || newValueObj === void 0 ? void 0 : newValueObj.value) ||
228
+ 'lookupCode' in (newValueObj !== null && newValueObj !== void 0 ? newValueObj : {});
229
+ if (isNew && otherLines.length === 0 && rejectedRootLines.length === 0 && hasNonEmptyNewValue) {
230
+ rawChanges.set(change.id, change);
231
+ }
168
232
  var rejectedRootLinesMap = new Map(rejectedRootLines);
169
233
  for (var _j = 0, otherLines_1 = otherLines; _j < otherLines_1.length; _j++) {
170
234
  var _k = otherLines_1[_j], key = _k[0], lineData = _k[1];
171
235
  var rootId = key.split('/').slice(0, 3).join('/');
172
236
  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)) {
237
+ if (!isNew && rootId === key && change.type === mdm_sdk_1.DCRTypes.UPDATE_ATTRIBUTE && (0, mdm_sdk_1.isEmptyValue)(newValue)) {
174
238
  var attributeUri = [objectUri, 'attributes', change.attributePath].join('/');
175
239
  var entry = __assign(__assign({}, (0, mdm_sdk_1.createEntryDeleteAttribute)({ uri: attributeUri })[0]), (change.crosswalk && { crosswalk: change.crosswalk }));
176
240
  deleteAttributes[objectUri] = (0, ramda_1.uniqBy)((0, ramda_1.prop)('uri'), (0, ramda_1.append)(entry, (0, ramda_1.propOr)([], objectUri, deleteAttributes)));
@@ -182,12 +246,14 @@ var buildDCRSavePlan = function (changes, getLinesByChangeId, metadata) {
182
246
  var oldValue = getOldValueByNewValuePath(valuePath, change);
183
247
  var initialChange = rawChanges.has(change.id) ? rawChanges.get(change.id) : change;
184
248
  var updatedChange = void 0;
185
- if (lineData.isRejected || (0, ramda_1.isEmpty)(newValue)) {
249
+ if (lineData.isRejected || (0, mdm_sdk_1.isEmptyValue)(newValue)) {
186
250
  updatedChange = (0, ramda_1.assocPath)(valuePath, null, initialChange);
187
251
  }
188
252
  else if (!valuesAreEqual(oldDCRValue, newValue)) {
189
253
  if (oldValue && valuesAreEqual(oldValue, newValue)) {
190
- rejectedChangeIds.push(change.id);
254
+ if (!isNew) {
255
+ rejectedChangeIds.push(change.id);
256
+ }
191
257
  }
192
258
  else {
193
259
  var processedNewValue = typeof oldDCRValue === 'string' && typeof newValue === 'number'
@@ -212,7 +278,15 @@ var buildDCRSavePlan = function (changes, getLinesByChangeId, metadata) {
212
278
  var isNestedChange = (0, ramda_1.has)('attributeType', cleanedChange) &&
213
279
  (0, mdm_sdk_1.isNested)((0, mdm_sdk_1.findAttributeTypeByUri)(metadata, cleanedChange.attributeType));
214
280
  if (isNestedChange && (0, ramda_1.isEmpty)((_b = cleanedChange.newValue) === null || _b === void 0 ? void 0 : _b.value)) {
215
- rejectedChangeIds.push(cleanedChange.id);
281
+ if (!isAddedChange(cleanedChange.id)) {
282
+ rejectedChangeIds.push(cleanedChange.id);
283
+ }
284
+ }
285
+ else if (isAddedChange(cleanedChange.id)) {
286
+ var diffEntry = dcrChangeToInsertDiffEntry(cleanedChange, objectUri, metadata);
287
+ if (diffEntry) {
288
+ insertAttributes[objectUri] = (0, ramda_1.append)(diffEntry, (0, ramda_1.propOr)([], objectUri, insertAttributes));
289
+ }
216
290
  }
217
291
  else {
218
292
  updatedChanges[objectUri] = (0, ramda_1.append)(cleanedChange, (0, ramda_1.propOr)([], objectUri, updatedChanges));
@@ -227,11 +301,32 @@ var buildDCRSavePlan = function (changes, getLinesByChangeId, metadata) {
227
301
  }, (0, ramda_1.toPairs)(deleteAttributes));
228
302
  var deleteRelationAttributes = (0, ramda_1.fromPairs)(deleteAttributesGroups.relation || []);
229
303
  var deleteEntityAttributes = (0, ramda_1.fromPairs)(deleteAttributesGroups.entity || []);
304
+ var insertAttributesGroups = (0, ramda_1.groupBy)(function (_a) {
305
+ var uri = _a[0];
306
+ return ((0, mdm_sdk_1.isRelationUri)(uri) ? 'relation' : 'entity');
307
+ }, (0, ramda_1.toPairs)(insertAttributes));
308
+ var insertRelationAttributes = (0, ramda_1.fromPairs)(insertAttributesGroups.relation || []);
309
+ var insertEntityAttributes = (0, ramda_1.fromPairs)(insertAttributesGroups.entity || []);
230
310
  return {
231
311
  rejectedChangeIds: rejectedChangeIds,
232
312
  updatedChanges: updatedChanges,
233
313
  deleteEntityAttributes: deleteEntityAttributes,
234
- deleteRelationAttributes: deleteRelationAttributes
314
+ deleteRelationAttributes: deleteRelationAttributes,
315
+ insertEntityAttributes: insertEntityAttributes,
316
+ insertRelationAttributes: insertRelationAttributes
235
317
  };
236
318
  };
237
319
  exports.buildDCRSavePlan = buildDCRSavePlan;
320
+ var mergeExistingRolesAndTags = function (diff, entity) {
321
+ return diff.map(function (entry) {
322
+ var _a, _b;
323
+ if (entry.type === mdm_sdk_1.EventType.UPDATE_TAGS && ((_a = entity.tags) === null || _a === void 0 ? void 0 : _a.length)) {
324
+ return __assign(__assign({}, entry), { newValue: (0, ramda_1.uniq)(__spreadArray(__spreadArray([], entity.tags, true), entry.newValue, true)) });
325
+ }
326
+ if (entry.type === mdm_sdk_1.EventType.UPDATE_ROLES && ((_b = entity.roles) === null || _b === void 0 ? void 0 : _b.length)) {
327
+ return __assign(__assign({}, entry), { newValue: (0, ramda_1.uniq)(__spreadArray(__spreadArray([], entity.roles, true), entry.newValue, true)) });
328
+ }
329
+ return entry;
330
+ });
331
+ };
332
+ exports.mergeExistingRolesAndTags = mergeExistingRolesAndTags;
@@ -146,4 +146,126 @@ describe('dcr helpers tests', function () {
146
146
  expect((0, dcr_1.isCreateEntityOperation)(change)).toBe(true);
147
147
  expect((0, dcr_1.isCreateEntityOperation)(__assign(__assign({}, change), { type: mdm_sdk_1.DCRTypes.CREATE_RELATIONSHIP }))).toBe(false);
148
148
  });
149
+ describe('buildDCRSavePlan', function () {
150
+ var emptyMetadata = { entityTypes: [], relationTypes: [] };
151
+ var noLineData = function () { return []; };
152
+ var emptyPlan = {
153
+ rejectedChangeIds: [],
154
+ updatedChanges: {},
155
+ deleteEntityAttributes: {},
156
+ deleteRelationAttributes: {},
157
+ insertEntityAttributes: {},
158
+ insertRelationAttributes: {}
159
+ };
160
+ it('should include added attribute with defaultValue when no lineData exists', function () {
161
+ var changes = {
162
+ 'entities/456': [
163
+ {
164
+ id: 'added|simple1',
165
+ type: mdm_sdk_1.DCRTypes.INSERT_ATTRIBUTE,
166
+ attributePath: 'Surname',
167
+ attributeType: 'configuration/entityTypes/HCP/attributes/Surname',
168
+ newValue: { value: 'DefaultSurname' }
169
+ }
170
+ ]
171
+ };
172
+ var result = (0, dcr_1.buildDCRSavePlan)(changes, noLineData, emptyMetadata);
173
+ expect(result).toEqual(__assign(__assign({}, emptyPlan), { insertEntityAttributes: {
174
+ 'entities/456': [
175
+ {
176
+ type: 'INSERT_ATTRIBUTE',
177
+ uri: 'entities/456/attributes/Surname',
178
+ newValue: [{ value: 'DefaultSurname' }]
179
+ }
180
+ ]
181
+ } }));
182
+ });
183
+ it('should include added lookup attribute with lookupCode when no lineData exists', function () {
184
+ var changes = {
185
+ 'entities/456': [
186
+ {
187
+ id: 'added|lookup1',
188
+ type: mdm_sdk_1.DCRTypes.INSERT_ATTRIBUTE,
189
+ attributePath: 'Country',
190
+ attributeType: 'configuration/entityTypes/HCP/attributes/Country',
191
+ newValue: { value: '', lookupCode: 'ALBY' }
192
+ }
193
+ ]
194
+ };
195
+ var result = (0, dcr_1.buildDCRSavePlan)(changes, noLineData, emptyMetadata);
196
+ expect(result).toEqual(__assign(__assign({}, emptyPlan), { insertEntityAttributes: {
197
+ 'entities/456': [
198
+ {
199
+ type: 'INSERT_ATTRIBUTE',
200
+ uri: 'entities/456/attributes/Country',
201
+ newValue: [{ value: '', lookupCode: 'ALBY' }]
202
+ }
203
+ ]
204
+ } }));
205
+ });
206
+ it('should preserve lookup sub-attribute with lookupCode inside nested parent', function () {
207
+ var metadata = {
208
+ entityTypes: [
209
+ {
210
+ uri: 'configuration/entityTypes/HCP',
211
+ attributes: [
212
+ {
213
+ uri: 'configuration/entityTypes/HCP/attributes/Details',
214
+ name: 'Details',
215
+ type: 'Nested',
216
+ attributes: [
217
+ {
218
+ uri: 'configuration/entityTypes/HCP/attributes/Details/attributes/Country',
219
+ name: 'Country',
220
+ type: 'String'
221
+ },
222
+ {
223
+ uri: 'configuration/entityTypes/HCP/attributes/Details/attributes/Notes',
224
+ name: 'Notes',
225
+ type: 'String'
226
+ }
227
+ ]
228
+ }
229
+ ]
230
+ }
231
+ ]
232
+ };
233
+ var changes = {
234
+ 'entities/456': [
235
+ {
236
+ id: 'added|nested1',
237
+ type: mdm_sdk_1.DCRTypes.INSERT_ATTRIBUTE,
238
+ attributePath: 'Details',
239
+ attributeType: 'configuration/entityTypes/HCP/attributes/Details',
240
+ newValue: {
241
+ value: {
242
+ Country: [{ value: '', lookupCode: 'ALBY' }],
243
+ Notes: [{ value: '' }]
244
+ }
245
+ }
246
+ }
247
+ ]
248
+ };
249
+ var notesLineData = [
250
+ ['456/added|nested1/newValue/value/Notes/0', { value: { value: 'User typed note' } }]
251
+ ];
252
+ var result = (0, dcr_1.buildDCRSavePlan)(changes, function (changeId) { return (changeId === 'added|nested1' ? notesLineData : []); }, metadata);
253
+ expect(result).toEqual(__assign(__assign({}, emptyPlan), { insertEntityAttributes: {
254
+ 'entities/456': [
255
+ {
256
+ type: 'INSERT_ATTRIBUTE',
257
+ uri: 'entities/456/attributes/Details',
258
+ newValue: [
259
+ {
260
+ value: {
261
+ Country: [{ value: '', lookupCode: 'ALBY' }],
262
+ Notes: [{ value: 'User typed note' }]
263
+ }
264
+ }
265
+ ]
266
+ }
267
+ ]
268
+ } }));
269
+ });
270
+ });
149
271
  });
@@ -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;
@@ -233,13 +233,13 @@ var getRequiredAttributeUris = function (metadata, typeUri) {
233
233
  return requiredAttrTypes.map(function (attr) { return attr.uri; });
234
234
  };
235
235
  var createRequiredError = function (_a) {
236
- var attributeType = _a.attributeType, attributeTypeUri = _a.attributeTypeUri, parentUri = _a.parentUri, lineIds = _a.lineIds, metadata = _a.metadata, entityUri = _a.entityUri, entitiesMap = _a.entitiesMap, valueUri = _a.valueUri;
236
+ var attributeType = _a.attributeType, attributeTypeUri = _a.attributeTypeUri, parentUri = _a.parentUri, lineIds = _a.lineIds, metadata = _a.metadata, entityUri = _a.entityUri, entitiesMap = _a.entitiesMap, valueUri = _a.valueUri, _b = _a.errorType, errorType = _b === void 0 ? mdm_sdk_1.ErrorType.missed : _b, _c = _a.message, message = _c === void 0 ? ui_i18n_1.default.text('Attribute is required') : _c;
237
237
  var error = (0, mdm_sdk_1.buildError)({
238
- type: mdm_sdk_1.ErrorType.missed,
238
+ type: errorType,
239
239
  attributeType: attributeType,
240
240
  attributeTypeUri: attributeTypeUri,
241
241
  parentUri: parentUri,
242
- message: ui_i18n_1.default.text('Attribute is required'),
242
+ message: message,
243
243
  source: mdm_sdk_1.ErrorSource.local,
244
244
  uri: lineIds[0]
245
245
  });
@@ -259,27 +259,37 @@ var createRequiredError = function (_a) {
259
259
  var validateRequiredComplexAttributes = function (_a) {
260
260
  var _b;
261
261
  var metadata = _a.metadata, change = _a.change, userChanges = _a.userChanges, entityUri = _a.entityUri;
262
- if (userChanges.length === 0 || change.type === mdm_sdk_1.DCRTypes.DELETE_ATTRIBUTE) {
262
+ if (change.type === mdm_sdk_1.DCRTypes.DELETE_ATTRIBUTE) {
263
263
  return [];
264
264
  }
265
265
  var valueHolder = change.type === mdm_sdk_1.DCRTypes.CREATE_ENTITY || change.type === mdm_sdk_1.DCRTypes.CREATE_RELATIONSHIP ? 'attributes' : 'value';
266
266
  var rootAttributeTypeUri = change.refAttributeType || change.attributeType || change.objectType;
267
+ if (!rootAttributeTypeUri) {
268
+ return [];
269
+ }
267
270
  var attributeType = (0, mdm_sdk_1.findAttributeTypeByUri)(metadata, rootAttributeTypeUri);
268
271
  var isReferenceType = (0, mdm_sdk_1.isReference)(attributeType);
269
- var entityTypeUri = isReferenceType ? attributeType.relationshipTypeURI : getEntityTypeUriFromChange(change);
270
- var requiredAttributeUris = getRequiredAttributeUris(metadata, entityTypeUri);
271
272
  var calculateLineIdFromPath = function (path) {
272
273
  if (path === void 0) { path = ''; }
273
274
  var entityId = entityUri.split('/').pop() || '';
274
275
  return "".concat(entityId, "/").concat(change.id, "/newValue").concat(path ? "/".concat(path) : '');
275
276
  };
277
+ var entityTypeUri = isReferenceType ? attributeType.relationshipTypeURI : getEntityTypeUriFromChange(change);
278
+ var requiredAttributeUris = getRequiredAttributeUris(metadata, entityTypeUri);
276
279
  var checkIsChangeRejected = function (path) {
277
280
  var _a, _b, _c;
278
281
  var searchLineId = calculateLineIdFromPath(path);
279
282
  var lineUserChanges = userChanges.find(function (userChange) { return userChange.lineId === searchLineId; });
280
283
  return (((_a = lineUserChanges === null || lineUserChanges === void 0 ? void 0 : lineUserChanges.data) === null || _a === void 0 ? void 0 : _a.isRejected) || (lineUserChanges && (0, mdm_sdk_1.isEmptyValue)((_c = (_b = lineUserChanges === null || lineUserChanges === void 0 ? void 0 : lineUserChanges.data) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.value)));
281
284
  };
285
+ var checkHasUserValue = function (path) {
286
+ var _a, _b;
287
+ var searchLineId = calculateLineIdFromPath(path);
288
+ var lineUserChange = userChanges.find(function (userChange) { return userChange.lineId === searchLineId; });
289
+ return Boolean(lineUserChange && !(0, mdm_sdk_1.isEmptyValue)((_b = (_a = lineUserChange.data) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.value));
290
+ };
282
291
  var collectErrors = function (attributes) {
292
+ var _a;
283
293
  var errors = [];
284
294
  var visitValue = function (value, path) {
285
295
  var isRejected = checkIsChangeRejected(path.slice(0, -1).join('/'));
@@ -289,6 +299,9 @@ var validateRequiredComplexAttributes = function (_a) {
289
299
  if (isRejected) {
290
300
  return false;
291
301
  }
302
+ if (value === undefined) {
303
+ return checkHasUserValue(path.slice(0, -1).join('/'));
304
+ }
292
305
  var anyFieldHasValue = false;
293
306
  Object.entries(value).forEach(function (_a) {
294
307
  var fieldName = _a[0], subAttributes = _a[1];
@@ -326,6 +339,18 @@ var validateRequiredComplexAttributes = function (_a) {
326
339
  lineIds: [calculateLineIdFromPath()]
327
340
  }));
328
341
  }
342
+ if (isReferenceType && change.type === mdm_sdk_1.DCRTypes.INSERT_ATTRIBUTE) {
343
+ var refEntity = (_a = change.newValue) === null || _a === void 0 ? void 0 : _a.refEntity;
344
+ if (!(refEntity === null || refEntity === void 0 ? void 0 : refEntity.objectURI)) {
345
+ errors.push(createRequiredError({
346
+ attributeType: attributeType,
347
+ attributeTypeUri: attributeType.uri,
348
+ lineIds: [calculateLineIdFromPath()],
349
+ errorType: mdm_sdk_1.ErrorType.missedRefEntity,
350
+ message: ui_i18n_1.default.text('Entity is required')
351
+ }));
352
+ }
353
+ }
329
354
  return errors;
330
355
  };
331
356
  return collectErrors((_b = change.newValue) === null || _b === void 0 ? void 0 : _b[valueHolder]);
@@ -1,3 +1,3 @@
1
- import { ChangeRequest } from '@reltio/mdm-sdk';
2
- import { BeforeActionOutcome } from '../types';
1
+ import { type ChangeRequest } from '@reltio/mdm-sdk';
2
+ import type { BeforeActionOutcome } from '../types';
3
3
  export declare const useApplyDcrChanges: (dcr: ChangeRequest) => () => Promise<BeforeActionOutcome>;