@contrail/flexplm 1.1.45 → 1.1.46
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/.github/pull_request_template.md +1 -1
- package/lib/publish/base-process-publish-assortment.js +12 -9
- package/lib/publish/base-process-publish-assortment.spec.js +20 -6
- package/lib/util/type-utils.js +4 -3
- package/package.json +1 -1
- package/src/publish/base-process-publish-assortment.spec.ts +22 -6
- package/src/publish/base-process-publish-assortment.ts +1095 -1090
- package/src/util/type-utils.ts +4 -3
|
@@ -6,10 +6,10 @@ const flexplm_connect_1 = require("../util/flexplm-connect");
|
|
|
6
6
|
const item_family_changes_1 = require("../interfaces/item-family-changes");
|
|
7
7
|
const publish_change_data_1 = require("../interfaces/publish-change-data");
|
|
8
8
|
const map_utils_1 = require("../util/map-utils");
|
|
9
|
+
const type_conversion_utils_1 = require("../util/type-conversion-utils");
|
|
9
10
|
const fsPromise = require("fs/promises");
|
|
10
11
|
const path = require("path");
|
|
11
12
|
const app_framework_1 = require("@contrail/app-framework");
|
|
12
|
-
const type_conversion_utils_1 = require("../util/type-conversion-utils");
|
|
13
13
|
class BaseProcessPublishAssortment {
|
|
14
14
|
constructor(_config, _dc, _mapFileUtil) {
|
|
15
15
|
this.TTL = 7 * 24 * 60 * 60 * 1000;
|
|
@@ -129,15 +129,16 @@ class BaseProcessPublishAssortment {
|
|
|
129
129
|
entityReference: 'assortment:' + assortmentId,
|
|
130
130
|
objectClass: 'LCSSeason',
|
|
131
131
|
};
|
|
132
|
-
const identifierKeys = this.
|
|
133
|
-
|
|
132
|
+
const identifierKeys = await type_conversion_utils_1.TypeConversionUtils.getIdentifierProperties(this.transformMapFile, this.mapFileUtil, assortmentObj);
|
|
133
|
+
const informationKeys = await type_conversion_utils_1.TypeConversionUtils.getInformationalProperties(this.transformMapFile, this.mapFileUtil, assortmentObj);
|
|
134
|
+
for (const key of identifierKeys.concat(informationKeys)) {
|
|
134
135
|
if (assortmentObj[key]) {
|
|
135
136
|
seasonObj[key] = assortmentObj[key];
|
|
136
137
|
}
|
|
137
138
|
}
|
|
138
139
|
const objectKeys = Object.keys(seasonObj);
|
|
139
140
|
const hasAllIdentifiers = identifierKeys.every(key => objectKeys.includes(key));
|
|
140
|
-
if (!hasAllIdentifiers
|
|
141
|
+
if (!hasAllIdentifiers) {
|
|
141
142
|
throw new Error(BaseProcessPublishAssortment.ASSORTMENT_NO_FED_INFO + identifierKeys);
|
|
142
143
|
}
|
|
143
144
|
seasonObj = await map_utils_1.MapUtil.applyTransformMap(this.transformMapFile, this.mapFileUtil, seasonObj, 'LCSSeason', 'vibe2flex');
|
|
@@ -806,13 +807,14 @@ class BaseProcessPublishAssortment {
|
|
|
806
807
|
return await this.dc.getFlexPLMObjectData(projectItem, [], true);
|
|
807
808
|
}
|
|
808
809
|
async getProductFederation(entityReference, itemToFederatedIdMapping, itemFamilyObject) {
|
|
809
|
-
const identifierKeys = this.config?.identifierAtts?.LCSProduct;
|
|
810
810
|
const itemObj = await this.dc.getFlexPLMObjectData(itemFamilyObject, [], true);
|
|
811
811
|
let prodObj = {
|
|
812
812
|
entityReference: 'item:' + entityReference,
|
|
813
813
|
objectClass: 'LCSProduct',
|
|
814
814
|
};
|
|
815
|
-
|
|
815
|
+
const identifierKeys = await type_conversion_utils_1.TypeConversionUtils.getIdentifierProperties(this.transformMapFile, this.mapFileUtil, itemFamilyObject);
|
|
816
|
+
const informationKeys = await type_conversion_utils_1.TypeConversionUtils.getInformationalProperties(this.transformMapFile, this.mapFileUtil, itemFamilyObject);
|
|
817
|
+
for (const key of identifierKeys.concat(informationKeys)) {
|
|
816
818
|
if (itemObj[key]) {
|
|
817
819
|
prodObj[key] = itemObj[key];
|
|
818
820
|
}
|
|
@@ -824,13 +826,14 @@ class BaseProcessPublishAssortment {
|
|
|
824
826
|
return prodObj;
|
|
825
827
|
}
|
|
826
828
|
async getSKUFederation(entityReference, itemToFederatedIdMapping, itemObject) {
|
|
827
|
-
const identifierKeys = this.config?.identifierAtts?.LCSSKU;
|
|
828
829
|
const itemObj = await this.dc.getFlexPLMObjectData(itemObject, [], true);
|
|
829
830
|
let skuObj = {
|
|
830
831
|
entityReference: 'item:' + entityReference,
|
|
831
832
|
objectClass: 'LCSSKU',
|
|
832
833
|
};
|
|
833
|
-
|
|
834
|
+
const identifierKeys = await type_conversion_utils_1.TypeConversionUtils.getIdentifierProperties(this.transformMapFile, this.mapFileUtil, itemObject);
|
|
835
|
+
const informationKeys = await type_conversion_utils_1.TypeConversionUtils.getInformationalProperties(this.transformMapFile, this.mapFileUtil, itemObject);
|
|
836
|
+
for (const key of identifierKeys.concat(informationKeys)) {
|
|
834
837
|
if (itemObj[key]) {
|
|
835
838
|
skuObj[key] = itemObj[key];
|
|
836
839
|
}
|
|
@@ -900,5 +903,5 @@ class BaseProcessPublishAssortment {
|
|
|
900
903
|
}
|
|
901
904
|
exports.BaseProcessPublishAssortment = BaseProcessPublishAssortment;
|
|
902
905
|
BaseProcessPublishAssortment.ASSORTMENT_NOT_PUBLISHABLE = 'Assortment isn\'t marked for publishing to FlexPLM';
|
|
903
|
-
BaseProcessPublishAssortment.ASSORTMENT_NO_FED_INFO = 'Assortment doesn\'t have all "identifier" properties
|
|
906
|
+
BaseProcessPublishAssortment.ASSORTMENT_NO_FED_INFO = 'Assortment doesn\'t have all "identifier" properties, so there is no processing. Identifier properties: ';
|
|
904
907
|
BaseProcessPublishAssortment.NOT_ABLE_TO_PROCESS_DELETE_CHANGES = 'Error: Not able to process delete changes';
|
|
@@ -41,24 +41,29 @@ jest.mock('@contrail/sdk', () => {
|
|
|
41
41
|
};
|
|
42
42
|
});
|
|
43
43
|
describe('process publish assortment', () => {
|
|
44
|
-
const config = {
|
|
45
|
-
identifierAtts: {
|
|
46
|
-
LCSSeason: ['flexPLMSeasonName']
|
|
47
|
-
}
|
|
48
|
-
};
|
|
44
|
+
const config = {};
|
|
49
45
|
beforeEach(() => {
|
|
50
46
|
federatedId = '';
|
|
51
47
|
entityObject = { publishToFlexPLM: true };
|
|
52
48
|
getOptionsObject = {};
|
|
53
49
|
});
|
|
50
|
+
afterEach(() => {
|
|
51
|
+
jest.restoreAllMocks();
|
|
52
|
+
});
|
|
54
53
|
it('No Federation Info', async () => {
|
|
55
54
|
const event = {
|
|
56
55
|
assortmentId: 'B3oRQpYVYzcJAJtQ'
|
|
57
56
|
};
|
|
57
|
+
const identifierKeys = ['flexPLMSeasonName'];
|
|
58
|
+
const informationKeys = ['name'];
|
|
59
|
+
const spyTCU_id_keys = jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'getIdentifierProperties')
|
|
60
|
+
.mockImplementation(async () => identifierKeys);
|
|
61
|
+
const spyTCU_info_keys = jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'getInformationalProperties')
|
|
62
|
+
.mockImplementation(async () => informationKeys);
|
|
58
63
|
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
59
64
|
const dc = new data_converter_1.DataConverter(config, mapFileUtil);
|
|
60
65
|
const results = await new base_process_publish_assortment_1.BaseProcessPublishAssortment(config, dc, mapFileUtil).process(event);
|
|
61
|
-
expect(results['results']['message']).toEqual(base_process_publish_assortment_1.BaseProcessPublishAssortment.ASSORTMENT_NO_FED_INFO +
|
|
66
|
+
expect(results['results']['message']).toEqual(base_process_publish_assortment_1.BaseProcessPublishAssortment.ASSORTMENT_NO_FED_INFO + identifierKeys);
|
|
62
67
|
});
|
|
63
68
|
});
|
|
64
69
|
describe('getPublishInfo', () => {
|
|
@@ -425,9 +430,18 @@ describe('getSeasonFederation', () => {
|
|
|
425
430
|
entityObject = { publishToFlexPLM: true };
|
|
426
431
|
getOptionsObject = {};
|
|
427
432
|
});
|
|
433
|
+
afterEach(() => {
|
|
434
|
+
jest.restoreAllMocks();
|
|
435
|
+
});
|
|
428
436
|
it('No Federation Info', async () => {
|
|
429
437
|
const assortmentId = 'B3oRQpYVYzcJAJtQ';
|
|
430
438
|
try {
|
|
439
|
+
const identifierKeys = ['flexPLMSeasonName'];
|
|
440
|
+
const informationKeys = ['name'];
|
|
441
|
+
const spyTCU_id_keys = jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'getIdentifierProperties')
|
|
442
|
+
.mockImplementation(async () => identifierKeys);
|
|
443
|
+
const spyTCU_info_keys = jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'getInformationalProperties')
|
|
444
|
+
.mockImplementation(async () => informationKeys);
|
|
431
445
|
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
432
446
|
const dc = new data_converter_1.DataConverter(config, mapFileUtil);
|
|
433
447
|
await new base_process_publish_assortment_1.BaseProcessPublishAssortment(config, dc, mapFileUtil).getSeasonFederation(assortmentId);
|
package/lib/util/type-utils.js
CHANGED
|
@@ -85,12 +85,13 @@ class TypeUtils {
|
|
|
85
85
|
filterTypeProperties(type, newData) {
|
|
86
86
|
let filteredProps = type['typeProperties'];
|
|
87
87
|
const typePath = type['typePath'];
|
|
88
|
+
const roles = newData['roles'];
|
|
88
89
|
if (typePath && (typePath.startsWith('item') || typePath.startsWith('project-item'))) {
|
|
89
90
|
if (app_framework_1.Logger.isDebugOn()) {
|
|
90
|
-
console.debug('
|
|
91
|
-
|
|
91
|
+
console.debug('filterTypeProperties():id: ' + newData?.id
|
|
92
|
+
+ ', typePath: ' + typePath
|
|
93
|
+
+ ', newData.roles: ' + newData?.roles);
|
|
92
94
|
}
|
|
93
|
-
const roles = newData['roles'];
|
|
94
95
|
if (roles) {
|
|
95
96
|
const isFamily = roles.includes('family');
|
|
96
97
|
if (app_framework_1.Logger.isDebugOn()) {
|
package/package.json
CHANGED
|
@@ -43,24 +43,30 @@ jest.mock('@contrail/sdk', () => {
|
|
|
43
43
|
};
|
|
44
44
|
});
|
|
45
45
|
describe('process publish assortment', () => {
|
|
46
|
-
const config = {
|
|
47
|
-
identifierAtts: {
|
|
48
|
-
LCSSeason: ['flexPLMSeasonName']
|
|
49
|
-
}
|
|
50
|
-
} as unknown as FCConfig;
|
|
46
|
+
const config = { } as unknown as FCConfig;
|
|
51
47
|
beforeEach(() => {
|
|
52
48
|
federatedId = '';
|
|
53
49
|
entityObject = {publishToFlexPLM:true};
|
|
54
50
|
getOptionsObject = {};
|
|
55
51
|
});
|
|
52
|
+
afterEach(() => {
|
|
53
|
+
jest.restoreAllMocks();
|
|
54
|
+
});
|
|
56
55
|
it('No Federation Info', async () => {
|
|
57
56
|
const event = {
|
|
58
57
|
assortmentId: 'B3oRQpYVYzcJAJtQ'
|
|
59
58
|
};
|
|
59
|
+
const identifierKeys = ['flexPLMSeasonName'];
|
|
60
|
+
const informationKeys = ['name'];
|
|
61
|
+
const spyTCU_id_keys = jest.spyOn(TypeConversionUtils, 'getIdentifierProperties')
|
|
62
|
+
.mockImplementation(async () => identifierKeys);
|
|
63
|
+
const spyTCU_info_keys = jest.spyOn(TypeConversionUtils, 'getInformationalProperties')
|
|
64
|
+
.mockImplementation(async () => informationKeys);
|
|
65
|
+
|
|
60
66
|
const mapFileUtil = new MapFileUtil(new Entities());
|
|
61
67
|
const dc = new DataConverter(config, mapFileUtil);
|
|
62
68
|
const results = await new BaseProcessPublishAssortment(config, dc, mapFileUtil).process(event);
|
|
63
|
-
expect(results['results']['message']).toEqual(BaseProcessPublishAssortment.ASSORTMENT_NO_FED_INFO +
|
|
69
|
+
expect(results['results']['message']).toEqual(BaseProcessPublishAssortment.ASSORTMENT_NO_FED_INFO + identifierKeys);
|
|
64
70
|
});
|
|
65
71
|
});
|
|
66
72
|
|
|
@@ -479,10 +485,20 @@ describe('getSeasonFederation', () =>{
|
|
|
479
485
|
entityObject = { publishToFlexPLM:true};
|
|
480
486
|
getOptionsObject = {};
|
|
481
487
|
});
|
|
488
|
+
afterEach(() => {
|
|
489
|
+
jest.restoreAllMocks();
|
|
490
|
+
});
|
|
482
491
|
it('No Federation Info', async () => {
|
|
483
492
|
const assortmentId = 'B3oRQpYVYzcJAJtQ';
|
|
484
493
|
|
|
485
494
|
try {
|
|
495
|
+
const identifierKeys = ['flexPLMSeasonName'];
|
|
496
|
+
const informationKeys = ['name'];
|
|
497
|
+
const spyTCU_id_keys = jest.spyOn(TypeConversionUtils, 'getIdentifierProperties')
|
|
498
|
+
.mockImplementation(async () => identifierKeys);
|
|
499
|
+
const spyTCU_info_keys = jest.spyOn(TypeConversionUtils, 'getInformationalProperties')
|
|
500
|
+
.mockImplementation(async () => informationKeys);
|
|
501
|
+
|
|
486
502
|
const mapFileUtil = new MapFileUtil(new Entities());
|
|
487
503
|
const dc = new DataConverter(config, mapFileUtil);
|
|
488
504
|
await new BaseProcessPublishAssortment(config, dc, mapFileUtil).getSeasonFederation(assortmentId);
|