@contrail/flexplm 1.7.7-alpha.eb1d846 → 1.7.8-alpha.48b253c

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.
@@ -909,7 +909,8 @@ class BaseProcessPublishAssortment {
909
909
  ? itemFamilyChanges.assortmentItemFullChangeMap.get(entityReference)?.item
910
910
  : itemFamilyChanges.itemFamilyObject;
911
911
  let seasonalData = await this.getSeasonalData(projectItem);
912
- seasonalData = await map_utils_1.MapUtil.applyTransformMap(this.transformMapFile, this.mapFileUtil, seasonalData, 'LCSProductSeasonLink', 'vibe2flex');
912
+ const productSeasonMapKey = (await type_conversion_utils_1.TypeConversionUtils.getMapKey(this.transformMapFile, this.mapFileUtil, projectItem, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION)) || 'LCSProductSeasonLink';
913
+ seasonalData = await map_utils_1.MapUtil.applyTransformMap(this.transformMapFile, this.mapFileUtil, seasonalData, productSeasonMapKey, 'vibe2flex');
913
914
  const LCSProduct = await this.getProductFederation(entityReference, itemToFederatedIdMapping, prodEntityData);
914
915
  const isCreatable = await type_conversion_utils_1.TypeConversionUtils.isOutboundCreatableFromEntity(this.transformMapFile, this.mapFileUtil, projectItem, { item: prodEntityData, assortment });
915
916
  const eventType = isCreatable ? 'UPSERT_ON_SEASON' : 'UPDATE_ON_SEASON';
@@ -944,7 +945,8 @@ class BaseProcessPublishAssortment {
944
945
  }
945
946
  const projectItem = this.getProjectItem(itemFamilyChanges, entityReference);
946
947
  let seasonalData = await this.getSeasonalData(projectItem);
947
- seasonalData = await map_utils_1.MapUtil.applyTransformMap(this.transformMapFile, this.mapFileUtil, seasonalData, 'LCSSKUSeasonLink', 'vibe2flex');
948
+ const skuSeasonMapKey = (await type_conversion_utils_1.TypeConversionUtils.getMapKey(this.transformMapFile, this.mapFileUtil, projectItem, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION)) || 'LCSSKUSeasonLink';
949
+ seasonalData = await map_utils_1.MapUtil.applyTransformMap(this.transformMapFile, this.mapFileUtil, seasonalData, skuSeasonMapKey, 'vibe2flex');
948
950
  const LCSSKU = await this.getSKUFederation(entityReference, itemToFederatedIdMapping, item);
949
951
  const isCreatable = await type_conversion_utils_1.TypeConversionUtils.isOutboundCreatableFromEntity(this.transformMapFile, this.mapFileUtil, projectItem, { item, assortment });
950
952
  const eventType = isCreatable ? 'UPSERT_ON_SEASON' : 'UPDATE_ON_SEASON';
@@ -1509,6 +1509,9 @@ describe('getEventsForItemFamilyChanges - conditional eventType', () => {
1509
1509
  };
1510
1510
  const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
1511
1511
  const dc = new data_converter_1.DataConverter(config, mapFileUtil);
1512
+ beforeEach(() => {
1513
+ jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'getMapKey').mockResolvedValue(null);
1514
+ });
1512
1515
  afterEach(() => {
1513
1516
  jest.restoreAllMocks();
1514
1517
  });
@@ -1705,6 +1708,108 @@ describe('getEventsForItemFamilyChanges - conditional eventType', () => {
1705
1708
  // Verify SKU event called with assortment entity
1706
1709
  expect(type_conversion_utils_1.TypeConversionUtils.isOutboundCreatableFromEntity).toHaveBeenNthCalledWith(2, undefined, mapFileUtil, colorProjectItem, { item: itemData, assortment });
1707
1710
  });
1711
+ it('should use dynamic map key for LCSSKUSeasonLink when getMapKey returns a custom key', async () => {
1712
+ const bppa = new base_process_publish_assortment_1.BaseProcessPublishAssortment(config, dc, mapFileUtil);
1713
+ const itemFamilyId = 'family123';
1714
+ const colorId = 'color456';
1715
+ const familyItemData = { id: itemFamilyId, identifier: 'FAM-123', itemNumber: 'FAM-123' };
1716
+ const familyProjectItem = { id: 'proj0', updatedOn: '2023-01-15T00:00:00.000Z' };
1717
+ const colorProjectItem = { id: 'proj1', updatedOn: '2023-01-15T00:00:00.000Z' };
1718
+ const assortment = { id: 'assort123', name: 'Fall 2023 Assortment', publishToFlexPLM: true };
1719
+ const seasonFed = { entityReference: 'assortment:assort123', objectClass: 'LCSSeason', flexPLMSeasonName: 'Fall 2023' };
1720
+ const seasonalData = { someData: 'value' };
1721
+ const itemFamilyChanges = new item_family_changes_1.ItemFamilyChanges(itemFamilyId, new Date('2023-01-01T00:00:00.000Z'));
1722
+ itemFamilyChanges.colorUpdates.push(colorId);
1723
+ itemFamilyChanges.assortmentItemFullChangeMap.set(itemFamilyId, { item: familyItemData, projectItem: familyProjectItem });
1724
+ itemFamilyChanges.assortmentItemFullChangeMap.set(colorId, { item: { id: colorId, identifier: 'COLOR-456' }, projectItem: colorProjectItem });
1725
+ jest.spyOn(bppa, 'getAssortment').mockResolvedValue(assortment);
1726
+ jest.spyOn(bppa, 'getProjectItem')
1727
+ .mockReturnValueOnce(familyProjectItem)
1728
+ .mockReturnValueOnce(colorProjectItem);
1729
+ jest.spyOn(bppa, 'getSeasonalData').mockResolvedValue(seasonalData);
1730
+ jest.spyOn(map_utils_1.MapUtil, 'applyTransformMap').mockResolvedValue({ transformedData: 'value' });
1731
+ jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'getIdentifierProperties').mockResolvedValue(['identifier']);
1732
+ jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'getInformationalProperties').mockResolvedValue([]);
1733
+ jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'isOutboundCreatableFromEntity').mockResolvedValue(false);
1734
+ // First call: product path (return null → falls back to default)
1735
+ // Second call: SKU path (return custom key)
1736
+ jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'getMapKey')
1737
+ .mockResolvedValueOnce(null)
1738
+ .mockResolvedValueOnce('LCSSKUSeasonLinkFlexOwned');
1739
+ await bppa.getEventsForItemFamilyChanges(itemFamilyChanges, 'assort123', seasonFed, new Map());
1740
+ expect(map_utils_1.MapUtil.applyTransformMap).toHaveBeenCalledWith(undefined, mapFileUtil, seasonalData, 'LCSSKUSeasonLinkFlexOwned', 'vibe2flex');
1741
+ });
1742
+ it('should fall back to LCSSKUSeasonLink when getMapKey returns null', async () => {
1743
+ const bppa = new base_process_publish_assortment_1.BaseProcessPublishAssortment(config, dc, mapFileUtil);
1744
+ const itemFamilyId = 'family123';
1745
+ const colorId = 'color456';
1746
+ const familyItemData = { id: itemFamilyId, identifier: 'FAM-123', itemNumber: 'FAM-123' };
1747
+ const familyProjectItem = { id: 'proj0', updatedOn: '2023-01-15T00:00:00.000Z' };
1748
+ const colorProjectItem = { id: 'proj1', updatedOn: '2023-01-15T00:00:00.000Z' };
1749
+ const assortment = { id: 'assort123', name: 'Fall 2023 Assortment', publishToFlexPLM: true };
1750
+ const seasonFed = { entityReference: 'assortment:assort123', objectClass: 'LCSSeason', flexPLMSeasonName: 'Fall 2023' };
1751
+ const seasonalData = { someData: 'value' };
1752
+ const itemFamilyChanges = new item_family_changes_1.ItemFamilyChanges(itemFamilyId, new Date('2023-01-01T00:00:00.000Z'));
1753
+ itemFamilyChanges.colorUpdates.push(colorId);
1754
+ itemFamilyChanges.assortmentItemFullChangeMap.set(itemFamilyId, { item: familyItemData, projectItem: familyProjectItem });
1755
+ itemFamilyChanges.assortmentItemFullChangeMap.set(colorId, { item: { id: colorId, identifier: 'COLOR-456' }, projectItem: colorProjectItem });
1756
+ jest.spyOn(bppa, 'getAssortment').mockResolvedValue(assortment);
1757
+ jest.spyOn(bppa, 'getProjectItem')
1758
+ .mockReturnValueOnce(familyProjectItem)
1759
+ .mockReturnValueOnce(colorProjectItem);
1760
+ jest.spyOn(bppa, 'getSeasonalData').mockResolvedValue(seasonalData);
1761
+ jest.spyOn(map_utils_1.MapUtil, 'applyTransformMap').mockResolvedValue({ transformedData: 'value' });
1762
+ jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'getIdentifierProperties').mockResolvedValue(['identifier']);
1763
+ jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'getInformationalProperties').mockResolvedValue([]);
1764
+ jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'isOutboundCreatableFromEntity').mockResolvedValue(false);
1765
+ jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'getMapKey').mockResolvedValue(null);
1766
+ await bppa.getEventsForItemFamilyChanges(itemFamilyChanges, 'assort123', seasonFed, new Map());
1767
+ expect(map_utils_1.MapUtil.applyTransformMap).toHaveBeenCalledWith(undefined, mapFileUtil, seasonalData, 'LCSSKUSeasonLink', 'vibe2flex');
1768
+ });
1769
+ it('should use dynamic map key for LCSProductSeasonLink when getMapKey returns a custom key', async () => {
1770
+ const bppa = new base_process_publish_assortment_1.BaseProcessPublishAssortment(config, dc, mapFileUtil);
1771
+ const itemFamilyId = 'family123';
1772
+ const prodEntityData = { id: itemFamilyId, identifier: 'FAM-123', itemNumber: 'FAM-123' };
1773
+ const projectItem = { id: 'proj1', updatedOn: '2023-01-15T00:00:00.000Z' };
1774
+ const assortment = { id: 'assort123', name: 'Fall 2023 Assortment', publishToFlexPLM: true };
1775
+ const seasonFed = { entityReference: 'assortment:assort123', objectClass: 'LCSSeason', flexPLMSeasonName: 'Fall 2023' };
1776
+ const seasonalData = { someData: 'value' };
1777
+ const itemFamilyChanges = new item_family_changes_1.ItemFamilyChanges(itemFamilyId, new Date('2023-01-01T00:00:00.000Z'));
1778
+ itemFamilyChanges.familyUpdate = true;
1779
+ itemFamilyChanges.assortmentItemFullChangeMap.set(itemFamilyId, { item: prodEntityData, projectItem });
1780
+ jest.spyOn(bppa, 'getAssortment').mockResolvedValue(assortment);
1781
+ jest.spyOn(bppa, 'getProjectItem').mockReturnValue(projectItem);
1782
+ jest.spyOn(bppa, 'getSeasonalData').mockResolvedValue(seasonalData);
1783
+ jest.spyOn(map_utils_1.MapUtil, 'applyTransformMap').mockResolvedValue({ transformedData: 'value' });
1784
+ jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'getIdentifierProperties').mockResolvedValue(['identifier']);
1785
+ jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'getInformationalProperties').mockResolvedValue([]);
1786
+ jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'isOutboundCreatableFromEntity').mockResolvedValue(false);
1787
+ jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'getMapKey').mockResolvedValue('LCSProductSeasonLinkCustom');
1788
+ await bppa.getEventsForItemFamilyChanges(itemFamilyChanges, 'assort123', seasonFed, new Map());
1789
+ expect(map_utils_1.MapUtil.applyTransformMap).toHaveBeenCalledWith(undefined, mapFileUtil, seasonalData, 'LCSProductSeasonLinkCustom', 'vibe2flex');
1790
+ });
1791
+ it('should fall back to LCSProductSeasonLink when getMapKey returns null', async () => {
1792
+ const bppa = new base_process_publish_assortment_1.BaseProcessPublishAssortment(config, dc, mapFileUtil);
1793
+ const itemFamilyId = 'family123';
1794
+ const prodEntityData = { id: itemFamilyId, identifier: 'FAM-123', itemNumber: 'FAM-123' };
1795
+ const projectItem = { id: 'proj1', updatedOn: '2023-01-15T00:00:00.000Z' };
1796
+ const assortment = { id: 'assort123', name: 'Fall 2023 Assortment', publishToFlexPLM: true };
1797
+ const seasonFed = { entityReference: 'assortment:assort123', objectClass: 'LCSSeason', flexPLMSeasonName: 'Fall 2023' };
1798
+ const seasonalData = { someData: 'value' };
1799
+ const itemFamilyChanges = new item_family_changes_1.ItemFamilyChanges(itemFamilyId, new Date('2023-01-01T00:00:00.000Z'));
1800
+ itemFamilyChanges.familyUpdate = true;
1801
+ itemFamilyChanges.assortmentItemFullChangeMap.set(itemFamilyId, { item: prodEntityData, projectItem });
1802
+ jest.spyOn(bppa, 'getAssortment').mockResolvedValue(assortment);
1803
+ jest.spyOn(bppa, 'getProjectItem').mockReturnValue(projectItem);
1804
+ jest.spyOn(bppa, 'getSeasonalData').mockResolvedValue(seasonalData);
1805
+ jest.spyOn(map_utils_1.MapUtil, 'applyTransformMap').mockResolvedValue({ transformedData: 'value' });
1806
+ jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'getIdentifierProperties').mockResolvedValue(['identifier']);
1807
+ jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'getInformationalProperties').mockResolvedValue([]);
1808
+ jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'isOutboundCreatableFromEntity').mockResolvedValue(false);
1809
+ jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'getMapKey').mockResolvedValue(null);
1810
+ await bppa.getEventsForItemFamilyChanges(itemFamilyChanges, 'assort123', seasonFed, new Map());
1811
+ expect(map_utils_1.MapUtil.applyTransformMap).toHaveBeenCalledWith(undefined, mapFileUtil, seasonalData, 'LCSProductSeasonLink', 'vibe2flex');
1812
+ });
1708
1813
  });
1709
1814
  describe('sendToFlexPLM / handleVibeIQFile / sendPublishPayloadEvent', () => {
1710
1815
  const config = {
@@ -1932,6 +2037,7 @@ describe('released family with pre-development options', () => {
1932
2037
  jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'getIdentifierProperties').mockResolvedValue(['itemNumber']);
1933
2038
  jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'getInformationalProperties').mockResolvedValue([]);
1934
2039
  jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'isOutboundCreatableFromEntity').mockResolvedValue(true);
2040
+ jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'getMapKey').mockResolvedValue(null);
1935
2041
  };
1936
2042
  afterEach(() => { jest.restoreAllMocks(); });
1937
2043
  /////////////////////////////////////////////////////////////////////////////
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/flexplm",
3
- "version": "1.7.7-alpha.eb1d846",
3
+ "version": "1.7.8-alpha.48b253c",
4
4
  "description": "Library used for integration with flexplm.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",