@contrail/flexplm 1.1.63 → 1.1.64
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/util/data-converter.d.ts +1 -0
- package/lib/util/data-converter.js +12 -2
- package/lib/util/data-converter.spec.js +40 -0
- package/package.json +1 -1
- package/src/util/data-converter.spec.ts +45 -0
- package/src/util/data-converter.ts +19 -2
- package/src/util/type-conversion-utils.spec.ts +643 -643
|
@@ -30,6 +30,7 @@ export declare class DataConverter {
|
|
|
30
30
|
setObjectReferenceValue(prop: any, nd: any): Promise<any>;
|
|
31
31
|
getAllObjectReferences(entityType: string, rootTypeCriteria: any, postProcessCriteria?: any): Promise<any[]>;
|
|
32
32
|
checkKeysAndValues(criteria: any, arrayOfObjects: any, entityTypePath: any): any[];
|
|
33
|
+
filterOutArchivedAndTrashedEntities(entities: any[]): any[];
|
|
33
34
|
setUserListValue(prop: any, nd: any): Promise<any>;
|
|
34
35
|
getUserByEmail(nd: any): Promise<any>;
|
|
35
36
|
processGroupMemberCheck(prop: any, userEmail: any): Promise<void>;
|
|
@@ -415,7 +415,7 @@ class DataConverter {
|
|
|
415
415
|
nextPageKey = loadPage?.nextPageKey;
|
|
416
416
|
if (Object.keys(loadPage).includes('results')) {
|
|
417
417
|
usedV2 = true;
|
|
418
|
-
let postProcessedResults = loadPage
|
|
418
|
+
let postProcessedResults = this.filterOutArchivedAndTrashedEntities(loadPage?.results);
|
|
419
419
|
if (postProcessedResults?.length > 0 && postProcessCriteria && Object.keys(postProcessCriteria).length !== 0) {
|
|
420
420
|
const subEntityTypePath = rootTypeCriteria.typePath || entityType;
|
|
421
421
|
postProcessedResults = this.checkKeysAndValues(postProcessCriteria, postProcessedResults, subEntityTypePath);
|
|
@@ -437,7 +437,7 @@ class DataConverter {
|
|
|
437
437
|
take,
|
|
438
438
|
skip,
|
|
439
439
|
});
|
|
440
|
-
let postProcessedResults = loadPage;
|
|
440
|
+
let postProcessedResults = this.filterOutArchivedAndTrashedEntities(loadPage);
|
|
441
441
|
if (postProcessCriteria && Object.keys(postProcessCriteria).length !== 0) {
|
|
442
442
|
const subEntityTypePath = rootTypeCriteria.typePath || entityType;
|
|
443
443
|
postProcessedResults = this.checkKeysAndValues(postProcessCriteria, postProcessedResults, subEntityTypePath);
|
|
@@ -476,6 +476,16 @@ class DataConverter {
|
|
|
476
476
|
}
|
|
477
477
|
return arrOfMatchObjects;
|
|
478
478
|
}
|
|
479
|
+
filterOutArchivedAndTrashedEntities(entities) {
|
|
480
|
+
if (!entities || !Array.isArray(entities) || entities.length === 0) {
|
|
481
|
+
return [];
|
|
482
|
+
}
|
|
483
|
+
return entities.filter(entity => {
|
|
484
|
+
const isArchived = entity?.isArchived;
|
|
485
|
+
const isTrashed = entity?.isTrashed;
|
|
486
|
+
return !isArchived && !isTrashed;
|
|
487
|
+
});
|
|
488
|
+
}
|
|
479
489
|
async setUserListValue(prop, nd) {
|
|
480
490
|
if (!nd?.email) {
|
|
481
491
|
return "";
|
|
@@ -665,6 +665,46 @@ describe('checkKeysAndValues', () => {
|
|
|
665
665
|
expect(results.length).toBe(1);
|
|
666
666
|
});
|
|
667
667
|
});
|
|
668
|
+
describe('filterOutArchivedAndTrashedEntities', () => {
|
|
669
|
+
const config = {
|
|
670
|
+
apiHost: 'host',
|
|
671
|
+
userName: () => 'user',
|
|
672
|
+
password: () => 'pass',
|
|
673
|
+
urlContext: 'xxx',
|
|
674
|
+
vibeEventEndpoint: '/rfa/vibeiq/vibeEvents',
|
|
675
|
+
csrfEndpoint: '/servlet/rest/security/csrf',
|
|
676
|
+
itemPreDevelopmentLifecycleStages: ['concept']
|
|
677
|
+
};
|
|
678
|
+
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
679
|
+
const dc = new data_converter_1.DataConverter(config, mapFileUtil);
|
|
680
|
+
it('filter out isArchived and isTrashed entities', () => {
|
|
681
|
+
const entities = [
|
|
682
|
+
{ id: '1', name: 'Entity 1', isArchived: false, isTrashed: false },
|
|
683
|
+
{ id: '2', name: 'Entity 2', isArchived: true, isTrashed: false },
|
|
684
|
+
{ id: '3', name: 'Entity 3', isArchived: false, isTrashed: true },
|
|
685
|
+
{ id: '4', name: 'Entity 4', isArchived: false, isTrashed: false }
|
|
686
|
+
];
|
|
687
|
+
const filteredEntities = dc.filterOutArchivedAndTrashedEntities(entities);
|
|
688
|
+
expect(filteredEntities.length).toBe(2);
|
|
689
|
+
expect(filteredEntities).toEqual([
|
|
690
|
+
{ id: '1', name: 'Entity 1', isArchived: false, isTrashed: false },
|
|
691
|
+
{ id: '4', name: 'Entity 4', isArchived: false, isTrashed: false }
|
|
692
|
+
]);
|
|
693
|
+
});
|
|
694
|
+
it('no entities to filter', () => {
|
|
695
|
+
const entities = [];
|
|
696
|
+
const filteredEntities = dc.filterOutArchivedAndTrashedEntities(entities);
|
|
697
|
+
expect(filteredEntities.length).toBe(0);
|
|
698
|
+
});
|
|
699
|
+
it('all entities are archived or trashed', () => {
|
|
700
|
+
const entities = [
|
|
701
|
+
{ id: '1', name: 'Entity 1', isArchived: true, isTrashed: false },
|
|
702
|
+
{ id: '2', name: 'Entity 2', isArchived: false, isTrashed: true }
|
|
703
|
+
];
|
|
704
|
+
const filteredEntities = dc.filterOutArchivedAndTrashedEntities(entities);
|
|
705
|
+
expect(filteredEntities.length).toBe(0);
|
|
706
|
+
});
|
|
707
|
+
});
|
|
668
708
|
describe('setUserListValue', () => {
|
|
669
709
|
const config = {
|
|
670
710
|
apiHost: 'host',
|
package/package.json
CHANGED
|
@@ -758,6 +758,51 @@ describe('checkKeysAndValues', () =>{
|
|
|
758
758
|
});
|
|
759
759
|
});
|
|
760
760
|
|
|
761
|
+
describe('filterOutArchivedAndTrashedEntities', () =>{
|
|
762
|
+
const config: FCConfig = {
|
|
763
|
+
apiHost: 'host',
|
|
764
|
+
userName: () => 'user',
|
|
765
|
+
password: () => 'pass',
|
|
766
|
+
urlContext: 'xxx',
|
|
767
|
+
vibeEventEndpoint: '/rfa/vibeiq/vibeEvents',
|
|
768
|
+
csrfEndpoint: '/servlet/rest/security/csrf',
|
|
769
|
+
itemPreDevelopmentLifecycleStages: ['concept']
|
|
770
|
+
};
|
|
771
|
+
|
|
772
|
+
const mapFileUtil = new MapFileUtil(new Entities());
|
|
773
|
+
const dc = new DataConverter(config, mapFileUtil);
|
|
774
|
+
|
|
775
|
+
it('filter out isArchived and isTrashed entities', () =>{
|
|
776
|
+
const entities = [
|
|
777
|
+
{id: '1', name: 'Entity 1', isArchived: false, isTrashed: false},
|
|
778
|
+
{id: '2', name: 'Entity 2', isArchived: true, isTrashed: false},
|
|
779
|
+
{id: '3', name: 'Entity 3', isArchived: false, isTrashed: true},
|
|
780
|
+
{id: '4', name: 'Entity 4', isArchived: false, isTrashed: false}
|
|
781
|
+
];
|
|
782
|
+
|
|
783
|
+
const filteredEntities = dc.filterOutArchivedAndTrashedEntities(entities);
|
|
784
|
+
expect(filteredEntities.length).toBe(2);
|
|
785
|
+
expect(filteredEntities).toEqual([
|
|
786
|
+
{id: '1', name: 'Entity 1', isArchived: false, isTrashed: false},
|
|
787
|
+
{id: '4', name: 'Entity 4', isArchived: false, isTrashed: false}
|
|
788
|
+
]);
|
|
789
|
+
});
|
|
790
|
+
it('no entities to filter', () =>{
|
|
791
|
+
const entities = [];
|
|
792
|
+
const filteredEntities = dc.filterOutArchivedAndTrashedEntities(entities);
|
|
793
|
+
expect(filteredEntities.length).toBe(0);
|
|
794
|
+
});
|
|
795
|
+
it('all entities are archived or trashed', () =>{
|
|
796
|
+
const entities = [
|
|
797
|
+
{id: '1', name: 'Entity 1', isArchived: true, isTrashed: false},
|
|
798
|
+
{id: '2', name: 'Entity 2', isArchived: false, isTrashed: true}
|
|
799
|
+
];
|
|
800
|
+
|
|
801
|
+
const filteredEntities = dc.filterOutArchivedAndTrashedEntities(entities);
|
|
802
|
+
expect(filteredEntities.length).toBe(0);
|
|
803
|
+
});
|
|
804
|
+
});
|
|
805
|
+
|
|
761
806
|
describe('setUserListValue', () =>{
|
|
762
807
|
const config: FCConfig = {
|
|
763
808
|
apiHost: 'host',
|
|
@@ -512,7 +512,7 @@ export class DataConverter {
|
|
|
512
512
|
nextPageKey = loadPage?.nextPageKey;
|
|
513
513
|
if (Object.keys(loadPage).includes('results')) {
|
|
514
514
|
usedV2 = true;
|
|
515
|
-
let postProcessedResults = loadPage
|
|
515
|
+
let postProcessedResults = this.filterOutArchivedAndTrashedEntities(loadPage?.results);
|
|
516
516
|
if(postProcessedResults?.length > 0 && postProcessCriteria && Object.keys(postProcessCriteria).length !== 0) {
|
|
517
517
|
const subEntityTypePath = rootTypeCriteria.typePath || entityType;
|
|
518
518
|
postProcessedResults = this.checkKeysAndValues(postProcessCriteria, postProcessedResults, subEntityTypePath);
|
|
@@ -534,7 +534,7 @@ export class DataConverter {
|
|
|
534
534
|
take,
|
|
535
535
|
skip,
|
|
536
536
|
});
|
|
537
|
-
let postProcessedResults = loadPage;
|
|
537
|
+
let postProcessedResults = this.filterOutArchivedAndTrashedEntities(loadPage);
|
|
538
538
|
if(postProcessCriteria && Object.keys(postProcessCriteria).length !== 0) {
|
|
539
539
|
const subEntityTypePath = rootTypeCriteria.typePath || entityType;
|
|
540
540
|
postProcessedResults = this.checkKeysAndValues(postProcessCriteria, postProcessedResults, subEntityTypePath);
|
|
@@ -587,6 +587,23 @@ export class DataConverter {
|
|
|
587
587
|
return arrOfMatchObjects;
|
|
588
588
|
}
|
|
589
589
|
|
|
590
|
+
/** Filters out archived and trashed entities from the provided array of entities.
|
|
591
|
+
*
|
|
592
|
+
* @param entities
|
|
593
|
+
* @returns
|
|
594
|
+
*/
|
|
595
|
+
|
|
596
|
+
filterOutArchivedAndTrashedEntities(entities: any[]) {
|
|
597
|
+
if(!entities || !Array.isArray(entities) || entities.length === 0){
|
|
598
|
+
return [];
|
|
599
|
+
}
|
|
600
|
+
return entities.filter(entity => {
|
|
601
|
+
const isArchived = entity?.isArchived;
|
|
602
|
+
const isTrashed = entity?.isTrashed;
|
|
603
|
+
return !isArchived && !isTrashed;
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
|
|
590
607
|
/** Sets userListId value from FlexPLM data passed in
|
|
591
608
|
*
|
|
592
609
|
* @param prop the VibeIQ property
|