@reltio/components 1.4.1840 → 1.4.1841

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.
@@ -69,7 +69,7 @@ var useAttributeActions = function (_a) {
69
69
  uri: attributeValue.uri,
70
70
  crosswalk: sourceTable ? { type: type, value: value, sourceTable: sourceTable } : { type: type, value: value }
71
71
  });
72
- }), function (diff) { return ({ uri: (0, mdm_sdk_1.getBaseUri)(attributeValue.uri), diff: diff }); }, mdm_sdk_1.entityCumulativeDelete, handleErrorResponse)(crosswalks);
72
+ }), function (diff) { return ({ uri: (0, mdm_sdk_1.getBaseUri)(attributeValue.uri), diff: diff }); }, (0, mdm_sdk_1.isRelationUri)(attributeValue.uri) ? mdm_sdk_1.entityCumulativeUpdate : mdm_sdk_1.entityCumulativeDelete, handleErrorResponse)(crosswalks);
73
73
  handleAction(action);
74
74
  }, [handleAction, handleErrorResponse]);
75
75
  var pinAttributeAction = (0, react_1.useCallback)(function (_a) {
@@ -74,7 +74,7 @@ var useAttributeActions_1 = require("./useAttributeActions");
74
74
  var test_utils_1 = require("react-dom/test-utils");
75
75
  var react_hooks_1 = require("@testing-library/react-hooks");
76
76
  var mdmSdk = __importStar(require("@reltio/mdm-sdk"));
77
- jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { entityCumulativeDelete: jest.fn(), ignoreAttribute: jest.fn(), pinAttribute: jest.fn(), removeRelation: jest.fn(), updateAttribute: jest.fn(), createAttribute: jest.fn() })); });
77
+ jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { entityCumulativeDelete: jest.fn(), entityCumulativeUpdate: jest.fn(), ignoreAttribute: jest.fn(), pinAttribute: jest.fn(), removeRelation: jest.fn(), updateAttribute: jest.fn(), createAttribute: jest.fn() })); });
78
78
  describe('useAttributeActions', function () {
79
79
  var initialProps = {
80
80
  onSuccess: jest.fn(),
@@ -91,6 +91,12 @@ describe('useAttributeActions', function () {
91
91
  resolveError = function () { return _reject({ errorMessage: 'Some error' }); };
92
92
  });
93
93
  });
94
+ var entityCumulativeUpdateMock = jest.spyOn(mdmSdk, 'entityCumulativeUpdate').mockImplementation(function () {
95
+ return new Promise(function (_resolve, _reject) {
96
+ resolveSuccess = function () { return _resolve({ uri: 'relations/03xNaHt', type: 'configuration/relationTypes/HCPtoHCA' }); };
97
+ resolveError = function () { return _reject({ errorMessage: 'Some error' }); };
98
+ });
99
+ });
94
100
  var removeRelationMock = jest.spyOn(mdmSdk, 'removeRelation').mockImplementation(function () {
95
101
  return new Promise(function (_resolve, _reject) {
96
102
  resolveSuccess = function () { return _resolve({ status: 'success' }); };
@@ -414,6 +420,81 @@ describe('useAttributeActions', function () {
414
420
  }
415
421
  });
416
422
  }); });
423
+ it('should return correct delete action for relation attribute', function () { return __awaiter(void 0, void 0, void 0, function () {
424
+ var deleteAttribute, deleteEvent, requestParams;
425
+ return __generator(this, function (_a) {
426
+ switch (_a.label) {
427
+ case 0:
428
+ deleteAttribute = getActions().deleteAttribute;
429
+ deleteEvent = {
430
+ attributeType: {
431
+ name: 'Int',
432
+ type: 'Int',
433
+ uri: 'configuration/relationTypes/HCPtoHCA/attributes/Int'
434
+ },
435
+ attributeValue: {
436
+ type: 'configuration/relationTypes/HCPtoHCA/attributes/Int',
437
+ ov: true,
438
+ value: '123',
439
+ uri: 'relations/03xNaHt/attributes/Int/10DnwKGs'
440
+ },
441
+ crosswalks: [
442
+ {
443
+ uri: 'relations/03xNaHt/crosswalks/n7HybxF',
444
+ type: 'configuration/sources/Reltio',
445
+ value: '03xNaHt',
446
+ createDate: '2024-02-02T14:11:10.208Z',
447
+ updateDate: '2024-02-02T14:11:10.208Z',
448
+ attributes: [
449
+ 'relations/03xNaHt/attributes/HierarchyCode/10DnwOX8',
450
+ 'relations/03xNaHt/attributes/Int/10DnwKGs'
451
+ ],
452
+ singleAttributeUpdateDates: {
453
+ 'relations/03xNaHt/attributes/HierarchyCode/10DnwOX8': '2024-05-07T08:24:58.683Z',
454
+ 'relations/03xNaHt/attributes/Int/10DnwKGs': '2024-05-07T08:24:58.683Z'
455
+ }
456
+ }
457
+ ]
458
+ };
459
+ deleteAttribute(deleteEvent);
460
+ requestParams = {
461
+ diff: [
462
+ {
463
+ crosswalk: { type: 'configuration/sources/Reltio', value: '03xNaHt' },
464
+ type: 'DELETE_ATTRIBUTE',
465
+ uri: 'relations/03xNaHt/attributes/Int/10DnwKGs'
466
+ }
467
+ ],
468
+ uri: 'relations/03xNaHt'
469
+ };
470
+ expect(entityCumulativeUpdateMock).toHaveBeenCalledWith(requestParams);
471
+ expect(initialProps.onLoad).toHaveBeenCalled();
472
+ expect(initialProps.onSuccess).not.toHaveBeenCalled();
473
+ return [4 /*yield*/, (0, test_utils_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
474
+ return __generator(this, function (_a) {
475
+ resolveSuccess();
476
+ return [2 /*return*/];
477
+ });
478
+ }); })];
479
+ case 1:
480
+ _a.sent();
481
+ expect(initialProps.onSuccess).toHaveBeenCalled();
482
+ deleteAttribute(deleteEvent);
483
+ expect(entityCumulativeUpdateMock).toHaveBeenCalledWith(requestParams);
484
+ expect(initialProps.onError).not.toHaveBeenCalled();
485
+ return [4 /*yield*/, (0, test_utils_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
486
+ return __generator(this, function (_a) {
487
+ resolveError();
488
+ return [2 /*return*/];
489
+ });
490
+ }); })];
491
+ case 2:
492
+ _a.sent();
493
+ expect(initialProps.onError).toHaveBeenCalledWith({ errorMessage: 'Some error' });
494
+ return [2 /*return*/];
495
+ }
496
+ });
497
+ }); });
417
498
  it('should return correct pin action for attribute', function () { return __awaiter(void 0, void 0, void 0, function () {
418
499
  var pinAttribute, attributeValue;
419
500
  return __generator(this, function (_a) {
@@ -36,7 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  };
37
37
  import { useCallback } from 'react';
38
38
  import { andThen, pipe, prop, defaultTo, map } from 'ramda';
39
- import { createAttribute, entityCumulativeDelete, getBaseUri, getReferencedRelationFromAttrValue, ignoreAttribute, isComplexAttribute, isImage, isLookupAttrType, isLookupValue, isReference, pinAttribute, removeRelation, updateAttribute } from '@reltio/mdm-sdk';
39
+ import { createAttribute, entityCumulativeDelete, getBaseUri, isRelationUri, getReferencedRelationFromAttrValue, ignoreAttribute, isComplexAttribute, isImage, isLookupAttrType, isLookupValue, isReference, pinAttribute, removeRelation, updateAttribute, entityCumulativeUpdate } from '@reltio/mdm-sdk';
40
40
  import { noop } from '../../../core';
41
41
  export var useAttributeActions = function (_a) {
42
42
  var _b = _a.onSuccess, onSuccess = _b === void 0 ? noop : _b, _c = _a.onError, onError = _c === void 0 ? noop : _c, _d = _a.onLoad, onLoad = _d === void 0 ? noop : _d;
@@ -66,7 +66,7 @@ export var useAttributeActions = function (_a) {
66
66
  uri: attributeValue.uri,
67
67
  crosswalk: sourceTable ? { type: type, value: value, sourceTable: sourceTable } : { type: type, value: value }
68
68
  });
69
- }), function (diff) { return ({ uri: getBaseUri(attributeValue.uri), diff: diff }); }, entityCumulativeDelete, handleErrorResponse)(crosswalks);
69
+ }), function (diff) { return ({ uri: getBaseUri(attributeValue.uri), diff: diff }); }, isRelationUri(attributeValue.uri) ? entityCumulativeUpdate : entityCumulativeDelete, handleErrorResponse)(crosswalks);
70
70
  handleAction(action);
71
71
  }, [handleAction, handleErrorResponse]);
72
72
  var pinAttributeAction = useCallback(function (_a) {
@@ -49,7 +49,7 @@ import { useAttributeActions } from './useAttributeActions';
49
49
  import { act } from 'react-dom/test-utils';
50
50
  import { renderHook } from '@testing-library/react-hooks';
51
51
  import * as mdmSdk from '@reltio/mdm-sdk';
52
- jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { entityCumulativeDelete: jest.fn(), ignoreAttribute: jest.fn(), pinAttribute: jest.fn(), removeRelation: jest.fn(), updateAttribute: jest.fn(), createAttribute: jest.fn() })); });
52
+ jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { entityCumulativeDelete: jest.fn(), entityCumulativeUpdate: jest.fn(), ignoreAttribute: jest.fn(), pinAttribute: jest.fn(), removeRelation: jest.fn(), updateAttribute: jest.fn(), createAttribute: jest.fn() })); });
53
53
  describe('useAttributeActions', function () {
54
54
  var initialProps = {
55
55
  onSuccess: jest.fn(),
@@ -66,6 +66,12 @@ describe('useAttributeActions', function () {
66
66
  resolveError = function () { return _reject({ errorMessage: 'Some error' }); };
67
67
  });
68
68
  });
69
+ var entityCumulativeUpdateMock = jest.spyOn(mdmSdk, 'entityCumulativeUpdate').mockImplementation(function () {
70
+ return new Promise(function (_resolve, _reject) {
71
+ resolveSuccess = function () { return _resolve({ uri: 'relations/03xNaHt', type: 'configuration/relationTypes/HCPtoHCA' }); };
72
+ resolveError = function () { return _reject({ errorMessage: 'Some error' }); };
73
+ });
74
+ });
69
75
  var removeRelationMock = jest.spyOn(mdmSdk, 'removeRelation').mockImplementation(function () {
70
76
  return new Promise(function (_resolve, _reject) {
71
77
  resolveSuccess = function () { return _resolve({ status: 'success' }); };
@@ -389,6 +395,81 @@ describe('useAttributeActions', function () {
389
395
  }
390
396
  });
391
397
  }); });
398
+ it('should return correct delete action for relation attribute', function () { return __awaiter(void 0, void 0, void 0, function () {
399
+ var deleteAttribute, deleteEvent, requestParams;
400
+ return __generator(this, function (_a) {
401
+ switch (_a.label) {
402
+ case 0:
403
+ deleteAttribute = getActions().deleteAttribute;
404
+ deleteEvent = {
405
+ attributeType: {
406
+ name: 'Int',
407
+ type: 'Int',
408
+ uri: 'configuration/relationTypes/HCPtoHCA/attributes/Int'
409
+ },
410
+ attributeValue: {
411
+ type: 'configuration/relationTypes/HCPtoHCA/attributes/Int',
412
+ ov: true,
413
+ value: '123',
414
+ uri: 'relations/03xNaHt/attributes/Int/10DnwKGs'
415
+ },
416
+ crosswalks: [
417
+ {
418
+ uri: 'relations/03xNaHt/crosswalks/n7HybxF',
419
+ type: 'configuration/sources/Reltio',
420
+ value: '03xNaHt',
421
+ createDate: '2024-02-02T14:11:10.208Z',
422
+ updateDate: '2024-02-02T14:11:10.208Z',
423
+ attributes: [
424
+ 'relations/03xNaHt/attributes/HierarchyCode/10DnwOX8',
425
+ 'relations/03xNaHt/attributes/Int/10DnwKGs'
426
+ ],
427
+ singleAttributeUpdateDates: {
428
+ 'relations/03xNaHt/attributes/HierarchyCode/10DnwOX8': '2024-05-07T08:24:58.683Z',
429
+ 'relations/03xNaHt/attributes/Int/10DnwKGs': '2024-05-07T08:24:58.683Z'
430
+ }
431
+ }
432
+ ]
433
+ };
434
+ deleteAttribute(deleteEvent);
435
+ requestParams = {
436
+ diff: [
437
+ {
438
+ crosswalk: { type: 'configuration/sources/Reltio', value: '03xNaHt' },
439
+ type: 'DELETE_ATTRIBUTE',
440
+ uri: 'relations/03xNaHt/attributes/Int/10DnwKGs'
441
+ }
442
+ ],
443
+ uri: 'relations/03xNaHt'
444
+ };
445
+ expect(entityCumulativeUpdateMock).toHaveBeenCalledWith(requestParams);
446
+ expect(initialProps.onLoad).toHaveBeenCalled();
447
+ expect(initialProps.onSuccess).not.toHaveBeenCalled();
448
+ return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
449
+ return __generator(this, function (_a) {
450
+ resolveSuccess();
451
+ return [2 /*return*/];
452
+ });
453
+ }); })];
454
+ case 1:
455
+ _a.sent();
456
+ expect(initialProps.onSuccess).toHaveBeenCalled();
457
+ deleteAttribute(deleteEvent);
458
+ expect(entityCumulativeUpdateMock).toHaveBeenCalledWith(requestParams);
459
+ expect(initialProps.onError).not.toHaveBeenCalled();
460
+ return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
461
+ return __generator(this, function (_a) {
462
+ resolveError();
463
+ return [2 /*return*/];
464
+ });
465
+ }); })];
466
+ case 2:
467
+ _a.sent();
468
+ expect(initialProps.onError).toHaveBeenCalledWith({ errorMessage: 'Some error' });
469
+ return [2 /*return*/];
470
+ }
471
+ });
472
+ }); });
392
473
  it('should return correct pin action for attribute', function () { return __awaiter(void 0, void 0, void 0, function () {
393
474
  var pinAttribute, attributeValue;
394
475
  return __generator(this, function (_a) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.1840",
3
+ "version": "1.4.1841",
4
4
  "license": "SEE LICENSE IN LICENSE FILE",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",