@contrail/flexplm 1.1.24 → 1.1.26
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.
- package/lib/publish/base-process-publish-assortment.js +16 -16
- package/lib/publish/base-process-publish-assortment.spec.js +43 -0
- package/lib/util/data-converter.js +37 -4
- package/package.json +1 -1
- package/src/publish/base-process-publish-assortment.spec.ts +51 -0
- package/src/publish/base-process-publish-assortment.ts +16 -16
- package/src/util/data-converter.ts +39 -5
|
@@ -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
|
|
405
|
-
const itemId = item
|
|
406
|
-
const itemFamilyId = item
|
|
407
|
-
console.debug('itemId: ' + item
|
|
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
|
|
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
|
|
425
|
-
const itemId = item
|
|
426
|
-
const itemFamilyId = item
|
|
427
|
-
console.debug('itemId: ' + item
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
+
});
|
|
@@ -374,20 +374,53 @@ class DataConverter {
|
|
|
374
374
|
}
|
|
375
375
|
}
|
|
376
376
|
if (!objectReferenceId) {
|
|
377
|
-
console.warn(`The passed in object reference criteria ${JSON.stringify(combinedCriteria)}
|
|
377
|
+
console.warn(`The passed in object reference criteria ${JSON.stringify(combinedCriteria)} didn't match any entities.`);
|
|
378
378
|
return objectReferenceId;
|
|
379
379
|
}
|
|
380
380
|
this.objRefCache[cacheKey] = objectReferenceId;
|
|
381
381
|
return objectReferenceId;
|
|
382
382
|
}
|
|
383
383
|
async getAllObjectReferences(entityType, rootTypeCriteria) {
|
|
384
|
+
const entities = new sdk_1.Entities();
|
|
384
385
|
let loads = [];
|
|
385
386
|
let nextPageKey;
|
|
387
|
+
let usedV2 = false;
|
|
386
388
|
do {
|
|
387
|
-
const loadPage = await
|
|
388
|
-
|
|
389
|
-
|
|
389
|
+
const loadPage = await entities.get({
|
|
390
|
+
entityName: entityType,
|
|
391
|
+
criteria: rootTypeCriteria,
|
|
392
|
+
apiVersion: sdk_1.API_VERSION.V2,
|
|
393
|
+
nextPageKey,
|
|
394
|
+
});
|
|
395
|
+
nextPageKey = loadPage?.nextPageKey;
|
|
396
|
+
if (Object.keys(loadPage).includes('results')) {
|
|
397
|
+
usedV2 = true;
|
|
398
|
+
loads.push(...loadPage.results);
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
nextPageKey = null;
|
|
402
|
+
}
|
|
390
403
|
} while (nextPageKey);
|
|
404
|
+
if (!usedV2) {
|
|
405
|
+
const take = 1000;
|
|
406
|
+
let skip = 0;
|
|
407
|
+
let done = false;
|
|
408
|
+
while (!done) {
|
|
409
|
+
const loadPage = await entities.get({
|
|
410
|
+
entityName: entityType,
|
|
411
|
+
criteria: rootTypeCriteria,
|
|
412
|
+
take,
|
|
413
|
+
skip,
|
|
414
|
+
});
|
|
415
|
+
loads.push(...loadPage);
|
|
416
|
+
if (loadPage.length !== take) {
|
|
417
|
+
done = true;
|
|
418
|
+
}
|
|
419
|
+
else {
|
|
420
|
+
skip += take;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
391
424
|
return loads;
|
|
392
425
|
}
|
|
393
426
|
checkKeysAndValues(criteria, arrayOfObjects, entityTypePath) {
|
package/package.json
CHANGED
|
@@ -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
|
|
501
|
-
const itemId = item
|
|
502
|
-
const itemFamilyId = item
|
|
503
|
-
console.debug('itemId: ' + item
|
|
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
|
|
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
|
|
522
|
-
const itemId = item
|
|
523
|
-
const itemFamilyId = item
|
|
524
|
-
console.debug('itemId: ' + item
|
|
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
|
|
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
|
|
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
|
|
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
|
|
858
|
+
item = fullAi?.item;
|
|
859
859
|
}
|
|
860
860
|
const projectItem = this.getProjectItem(itemFamilyChanges, entityReference);
|
|
861
861
|
let seasonalData = await this.getSeasonalData(projectItem);
|
|
@@ -458,7 +458,7 @@ export class DataConverter {
|
|
|
458
458
|
}
|
|
459
459
|
|
|
460
460
|
if (!objectReferenceId) {
|
|
461
|
-
console.warn(`The passed in object reference criteria ${JSON.stringify(combinedCriteria)}
|
|
461
|
+
console.warn(`The passed in object reference criteria ${JSON.stringify(combinedCriteria)} didn't match any entities.`);
|
|
462
462
|
return objectReferenceId;
|
|
463
463
|
}
|
|
464
464
|
|
|
@@ -475,13 +475,47 @@ export class DataConverter {
|
|
|
475
475
|
* @returns {Promise<Array>} A Promise that resolves to an array containing all object references.
|
|
476
476
|
*/
|
|
477
477
|
async getAllObjectReferences(entityType, rootTypeCriteria) {
|
|
478
|
-
|
|
478
|
+
const entities = new Entities();
|
|
479
|
+
let loads = [];
|
|
479
480
|
let nextPageKey;
|
|
481
|
+
let usedV2 = false;
|
|
480
482
|
do {
|
|
481
|
-
const loadPage = await
|
|
482
|
-
|
|
483
|
-
|
|
483
|
+
const loadPage = await entities.get({
|
|
484
|
+
entityName: entityType,
|
|
485
|
+
criteria: rootTypeCriteria,
|
|
486
|
+
apiVersion: API_VERSION.V2,
|
|
487
|
+
nextPageKey,
|
|
488
|
+
});
|
|
489
|
+
nextPageKey = loadPage?.nextPageKey;
|
|
490
|
+
if (Object.keys(loadPage).includes('results')) {
|
|
491
|
+
usedV2 = true;
|
|
492
|
+
loads.push(...loadPage.results);
|
|
493
|
+
} else {
|
|
494
|
+
nextPageKey = null;
|
|
495
|
+
}
|
|
484
496
|
} while (nextPageKey);
|
|
497
|
+
|
|
498
|
+
if (!usedV2) {
|
|
499
|
+
const take = 1000;
|
|
500
|
+
let skip = 0;
|
|
501
|
+
let done = false;
|
|
502
|
+
while (!done) {
|
|
503
|
+
const loadPage = await entities.get({
|
|
504
|
+
entityName: entityType,
|
|
505
|
+
criteria: rootTypeCriteria,
|
|
506
|
+
take,
|
|
507
|
+
skip,
|
|
508
|
+
});
|
|
509
|
+
loads.push(...loadPage);
|
|
510
|
+
|
|
511
|
+
if (loadPage.length !== take) {
|
|
512
|
+
done = true;
|
|
513
|
+
} else {
|
|
514
|
+
skip += take;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
485
519
|
return loads;
|
|
486
520
|
}
|
|
487
521
|
|