@contrail/flexplm 1.1.23 → 1.1.25

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.
@@ -401,16 +401,16 @@ class BaseProcessPublishAssortment {
401
401
  const assortmentItemsArray = fullChange['assortmentItems'];
402
402
  for (const aItem of assortmentItemsArray) {
403
403
  const meetsCriteria = this.meetsCriteria(aItem);
404
- const item = aItem['item'];
405
- const itemId = item['id'];
406
- const itemFamilyId = item['itemFamilyId'];
407
- console.debug('itemId: ' + item['id']);
408
- if (meetsCriteria) {
404
+ const item = aItem?.item;
405
+ const itemId = item?.id;
406
+ const itemFamilyId = item?.itemFamilyId;
407
+ console.debug('itemId: ' + item?.id);
408
+ if (item && meetsCriteria) {
409
409
  console.debug('adding item to releasedForDevelopmentItemIds');
410
410
  console.debug('itemFamilyId: ' + item['itemFamilyId']);
411
411
  releasedForDevelopmentItemIds.push(itemId);
412
412
  if (!itemFamilySet.has(itemFamilyId) && itemId !== itemFamilyId) {
413
- const familyItem = item['itemFamily'];
413
+ const familyItem = item?.itemFamily;
414
414
  const familyItemMeetsCriteria = this.meetsCriteria({ item: familyItem });
415
415
  if (familyItemMeetsCriteria) {
416
416
  releasedForDevelopmentItemIds.push(itemFamilyId);
@@ -421,14 +421,14 @@ class BaseProcessPublishAssortment {
421
421
  }
422
422
  for (const dItem of deleteChanges) {
423
423
  const meetsCriteria = this.meetsCriteria(dItem);
424
- const item = dItem['item'];
425
- const itemId = item['id'];
426
- const itemFamilyId = item['itemFamilyId'];
427
- console.debug('itemId: ' + item['id']);
428
- if (meetsCriteria) {
424
+ const item = dItem?.item;
425
+ const itemId = item?.id;
426
+ const itemFamilyId = item?.itemFamilyId;
427
+ console.debug('itemId: ' + item?.id);
428
+ if (item && meetsCriteria) {
429
429
  releasedForDevelopmentItemIds.push(itemId);
430
430
  if (!itemFamilySet.has(itemFamilyId) && itemId !== itemFamilyId) {
431
- const familyItem = item['itemFamily'];
431
+ const familyItem = item?.itemFamily;
432
432
  if (familyItem) {
433
433
  const familyItemMeetsCriteria = this.meetsCriteria({ item: familyItem });
434
434
  if (familyItemMeetsCriteria) {
@@ -445,8 +445,7 @@ class BaseProcessPublishAssortment {
445
445
  return releasedForDevelopmentItemIds;
446
446
  }
447
447
  meetsCriteria(aItem) {
448
- const item = aItem['item'];
449
- const lifecycleStage = item['lifecycleStage'];
448
+ const lifecycleStage = aItem?.item?.lifecycleStage;
450
449
  return lifecycleStage && !this.config.itemPreDevelopmentLifecycleStages.includes(lifecycleStage);
451
450
  }
452
451
  async processPublish(pcd, changeDetail, fullChange, deleteChanges) {
@@ -563,7 +562,8 @@ class BaseProcessPublishAssortment {
563
562
  const updateIds = updates.map(item => item.id);
564
563
  const familyItemsRemovedIds = familyItemsRemoved.map(item => item.itemId);
565
564
  for (const [itemId, aItem] of assortmentItemFullChangeMap) {
566
- const { item: { itemFamilyId }, projectItem } = aItem;
565
+ const projectItem = aItem?.projectItem;
566
+ const itemFamilyId = aItem?.item?.itemFamilyId;
567
567
  if (!pcd.releasedForDevelopmentItemIds.includes(itemFamilyId) || !pcd.releasedForDevelopmentItemIds.includes(itemId)) {
568
568
  continue;
569
569
  }
@@ -707,7 +707,7 @@ class BaseProcessPublishAssortment {
707
707
  let item = {};
708
708
  if (itemFamilyChanges.assortmentItemFullChangeMap.has(entityReference)) {
709
709
  const fullAi = itemFamilyChanges.assortmentItemFullChangeMap.get(entityReference);
710
- item = fullAi['item'];
710
+ item = fullAi?.item;
711
711
  }
712
712
  const projectItem = this.getProjectItem(itemFamilyChanges, entityReference);
713
713
  let seasonalData = await this.getSeasonalData(projectItem);
@@ -1051,3 +1051,46 @@ describe('getCarriedFromSeason', () => {
1051
1051
  });
1052
1052
  });
1053
1053
  });
1054
+ describe('meetsCriteria', () => {
1055
+ const config = {
1056
+ identifierAtts: {
1057
+ LCSSeason: ['flexPLMSeasonName']
1058
+ },
1059
+ itemPreDevelopmentLifecycleStages: ['concept']
1060
+ };
1061
+ const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
1062
+ const dc = new data_converter_1.DataConverter(config, mapFileUtil);
1063
+ const bppa = new base_process_publish_assortment_1.BaseProcessPublishAssortment(config, dc, mapFileUtil);
1064
+ it('no item', () => {
1065
+ const aItem = {};
1066
+ const results = bppa.meetsCriteria(aItem);
1067
+ expect(results).toBeFalsy();
1068
+ });
1069
+ it('item - no lifecycle stage', () => {
1070
+ const aItem = {
1071
+ item: {
1072
+ lifecycleStage: ''
1073
+ }
1074
+ };
1075
+ const results = bppa.meetsCriteria(aItem);
1076
+ expect(results).toBeFalsy();
1077
+ });
1078
+ it('item - concept lifecycle stage', () => {
1079
+ const aItem = {
1080
+ item: {
1081
+ lifecycleStage: 'concept'
1082
+ }
1083
+ };
1084
+ const results = bppa.meetsCriteria(aItem);
1085
+ expect(results).toBeFalsy();
1086
+ });
1087
+ it('item - delevopment lifecycle stage', () => {
1088
+ const aItem = {
1089
+ item: {
1090
+ lifecycleStage: 'delevopment'
1091
+ }
1092
+ };
1093
+ const results = bppa.meetsCriteria(aItem);
1094
+ expect(results).toBeTruthy();
1095
+ });
1096
+ });
@@ -327,13 +327,17 @@ class DataConverter {
327
327
  if (!nd) {
328
328
  return objectReferenceId;
329
329
  }
330
+ if (this.transformMapFile) {
331
+ const mapKey = await type_conversion_utils_1.TypeConversionUtils.getMapKeyFromObject(this.transformMapFile, this.mapFileUtil, nd, type_conversion_utils_1.TypeConversionUtils.FLEX2VIBE_DIRECTION);
332
+ nd = await map_utils_1.MapUtil.applyTransformMap(this.transformMapFile, this.mapFileUtil, nd, mapKey, type_conversion_utils_1.TypeConversionUtils.FLEX2VIBE_DIRECTION);
333
+ }
330
334
  const entityType = prop['referencedTypeRootSlug'];
331
335
  const entityTypePath = prop['referencedTypePath'];
332
336
  const entityKeys = Object.keys(nd);
333
337
  const identifierKeys = await type_conversion_utils_1.TypeConversionUtils.getIdentifierPropertiesFromObject(this.transformMapFile, this.mapFileUtil, nd);
334
338
  const hasAllIdentifiers = identifierKeys.every(key => entityKeys.includes(key));
335
339
  if (identifierKeys.length == 0 || !hasAllIdentifiers) {
336
- console.warn(`The inbound ${entityType} doesnt have all "identifier properties, so there is no processing. Identifier properties: ${identifierKeys}`);
340
+ console.warn(`The inbound ${entityType} for prop '${prop['slug']}' doesnt have all "identifier" properties, so there is no processing. Identifier properties: ${identifierKeys}`);
337
341
  return objectReferenceId;
338
342
  }
339
343
  const rootType = await this.typeUtils.getByRootAndPath({ root: entityType });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/flexplm",
3
- "version": "1.1.23",
3
+ "version": "1.1.25",
4
4
  "description": "Library used for integration with flexplm.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -1237,3 +1237,54 @@ describe('getCarriedFromSeason', () =>{
1237
1237
 
1238
1238
  });
1239
1239
 
1240
+ describe('meetsCriteria', () =>{
1241
+ const config = {
1242
+ identifierAtts: {
1243
+ LCSSeason: ['flexPLMSeasonName']
1244
+ },
1245
+ itemPreDevelopmentLifecycleStages: ['concept']
1246
+ } as unknown as FCConfig;
1247
+ const mapFileUtil = new MapFileUtil(new Entities());
1248
+ const dc = new DataConverter(config, mapFileUtil);
1249
+ const bppa = new BaseProcessPublishAssortment(config, dc, mapFileUtil);
1250
+ it('no item', () =>{
1251
+ const aItem = {};
1252
+
1253
+ const results = bppa.meetsCriteria(aItem);
1254
+ expect(results).toBeFalsy();
1255
+ });
1256
+
1257
+ it('item - no lifecycle stage', () =>{
1258
+ const aItem = {
1259
+ item: {
1260
+ lifecycleStage: ''
1261
+ }
1262
+ };
1263
+
1264
+ const results = bppa.meetsCriteria(aItem);
1265
+ expect(results).toBeFalsy();
1266
+ });
1267
+
1268
+ it('item - concept lifecycle stage', () =>{
1269
+ const aItem = {
1270
+ item: {
1271
+ lifecycleStage: 'concept'
1272
+ }
1273
+ };
1274
+
1275
+ const results = bppa.meetsCriteria(aItem);
1276
+ expect(results).toBeFalsy();
1277
+ });
1278
+
1279
+ it('item - delevopment lifecycle stage', () =>{
1280
+ const aItem = {
1281
+ item: {
1282
+ lifecycleStage: 'delevopment'
1283
+ }
1284
+ };
1285
+
1286
+ const results = bppa.meetsCriteria(aItem);
1287
+ expect(results).toBeTruthy();
1288
+ });
1289
+
1290
+ });
@@ -497,16 +497,16 @@ export class BaseProcessPublishAssortment {
497
497
 
498
498
  for (const aItem of assortmentItemsArray) {
499
499
  const meetsCriteria= this.meetsCriteria(aItem);
500
- const item = aItem['item'];
501
- const itemId = item['id'];
502
- const itemFamilyId = item['itemFamilyId'];
503
- console.debug('itemId: ' + item['id']);
504
- if(meetsCriteria){
500
+ const item = aItem?.item;
501
+ const itemId = item?.id;
502
+ const itemFamilyId = item?.itemFamilyId;
503
+ console.debug('itemId: ' + item?.id);
504
+ if(item && meetsCriteria){
505
505
  console.debug('adding item to releasedForDevelopmentItemIds');
506
506
  console.debug('itemFamilyId: ' + item['itemFamilyId']);
507
507
  releasedForDevelopmentItemIds.push(itemId);
508
508
  if(!itemFamilySet.has(itemFamilyId) && itemId !== itemFamilyId){
509
- const familyItem = item['itemFamily'];
509
+ const familyItem = item?.itemFamily;
510
510
  const familyItemMeetsCriteria = this.meetsCriteria({item: familyItem});
511
511
  if(familyItemMeetsCriteria){
512
512
  releasedForDevelopmentItemIds.push(itemFamilyId);
@@ -518,14 +518,14 @@ export class BaseProcessPublishAssortment {
518
518
 
519
519
  for(const dItem of deleteChanges){
520
520
  const meetsCriteria = this.meetsCriteria(dItem);
521
- const item = dItem['item'];
522
- const itemId = item['id'];
523
- const itemFamilyId = item['itemFamilyId'];
524
- console.debug('itemId: ' + item['id']);
525
- if(meetsCriteria) {
521
+ const item = dItem?.item;
522
+ const itemId = item?.id;
523
+ const itemFamilyId = item?.itemFamilyId;
524
+ console.debug('itemId: ' + item?.id);
525
+ if(item && meetsCriteria) {
526
526
  releasedForDevelopmentItemIds.push(itemId);
527
527
  if(!itemFamilySet.has(itemFamilyId) && itemId !== itemFamilyId){
528
- const familyItem = item['itemFamily'];
528
+ const familyItem = item?.itemFamily;
529
529
  if(familyItem){
530
530
  const familyItemMeetsCriteria = this.meetsCriteria({item: familyItem});
531
531
  if(familyItemMeetsCriteria){
@@ -542,8 +542,7 @@ export class BaseProcessPublishAssortment {
542
542
  }
543
543
 
544
544
  meetsCriteria(aItem): boolean {
545
- const item = aItem['item'];
546
- const lifecycleStage = item['lifecycleStage'];
545
+ const lifecycleStage = aItem?.item?.lifecycleStage;
547
546
 
548
547
  return lifecycleStage && !this.config.itemPreDevelopmentLifecycleStages.includes(lifecycleStage);
549
548
  }
@@ -678,7 +677,8 @@ export class BaseProcessPublishAssortment {
678
677
  const familyItemsRemovedIds = familyItemsRemoved.map(item => item.itemId);
679
678
 
680
679
  for (const [itemId, aItem] of assortmentItemFullChangeMap) {
681
- const { item: { itemFamilyId }, projectItem } = aItem;
680
+ const projectItem = aItem?.projectItem;
681
+ const itemFamilyId = aItem?.item?.itemFamilyId;
682
682
 
683
683
  if (!pcd.releasedForDevelopmentItemIds.includes(itemFamilyId) || !pcd.releasedForDevelopmentItemIds.includes(itemId)) {
684
684
  continue;
@@ -855,7 +855,7 @@ export class BaseProcessPublishAssortment {
855
855
  let item = {};
856
856
  if (itemFamilyChanges.assortmentItemFullChangeMap.has(entityReference)) {
857
857
  const fullAi = itemFamilyChanges.assortmentItemFullChangeMap.get(entityReference);
858
- item = fullAi['item'];
858
+ item = fullAi?.item;
859
859
  }
860
860
  const projectItem = this.getProjectItem(itemFamilyChanges, entityReference);
861
861
  let seasonalData = await this.getSeasonalData(projectItem);
@@ -405,6 +405,10 @@ export class DataConverter {
405
405
  if(!nd) {
406
406
  return objectReferenceId;
407
407
  }
408
+ if(this.transformMapFile){
409
+ const mapKey = await TypeConversionUtils.getMapKeyFromObject(this.transformMapFile, this.mapFileUtil, nd, TypeConversionUtils.FLEX2VIBE_DIRECTION);
410
+ nd = await MapUtil.applyTransformMap(this.transformMapFile, this.mapFileUtil, nd, mapKey, TypeConversionUtils.FLEX2VIBE_DIRECTION)
411
+ }
408
412
 
409
413
  const entityType = prop['referencedTypeRootSlug'];
410
414
  const entityTypePath = prop['referencedTypePath'];
@@ -412,7 +416,7 @@ export class DataConverter {
412
416
  const identifierKeys = await TypeConversionUtils.getIdentifierPropertiesFromObject(this.transformMapFile, this.mapFileUtil, nd)
413
417
  const hasAllIdentifiers = identifierKeys.every(key => entityKeys.includes(key));
414
418
  if(identifierKeys.length == 0 || !hasAllIdentifiers){
415
- console.warn(`The inbound ${entityType} doesnt have all "identifier properties, so there is no processing. Identifier properties: ${identifierKeys}`);
419
+ console.warn(`The inbound ${entityType} for prop '${prop['slug']}' doesnt have all "identifier" properties, so there is no processing. Identifier properties: ${identifierKeys}`);
416
420
  return objectReferenceId;
417
421
  }
418
422