@contrail/flexplm 1.0.16 → 1.0.18

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.
Files changed (47) hide show
  1. package/lib/entity-processor/base-entity-processor.d.ts +30 -30
  2. package/lib/entity-processor/base-entity-processor.js +143 -143
  3. package/lib/flexplm-request.d.ts +3 -3
  4. package/lib/flexplm-request.js +34 -34
  5. package/lib/flexplm-utils.d.ts +5 -5
  6. package/lib/flexplm-utils.js +33 -33
  7. package/lib/index.d.ts +19 -15
  8. package/lib/index.js +35 -31
  9. package/lib/interfaces/interfaces.d.ts +91 -91
  10. package/lib/interfaces/interfaces.js +2 -2
  11. package/lib/interfaces/item-family-changes.d.ts +19 -19
  12. package/lib/interfaces/item-family-changes.js +49 -49
  13. package/lib/interfaces/publish-change-data.d.ts +17 -17
  14. package/lib/interfaces/publish-change-data.js +30 -30
  15. package/lib/publish/base-process-publish-assortment-callback.d.ts +8 -8
  16. package/lib/publish/base-process-publish-assortment-callback.js +19 -19
  17. package/lib/publish/base-process-publish-assortment.d.ts +57 -57
  18. package/lib/publish/base-process-publish-assortment.js +570 -563
  19. package/lib/publish/mockData.d.ts +774 -774
  20. package/lib/publish/mockData.js +3033 -3033
  21. package/lib/util/config-defaults.d.ts +6 -6
  22. package/lib/util/config-defaults.js +71 -71
  23. package/lib/util/data-converter.d.ts +22 -22
  24. package/lib/util/data-converter.js +318 -318
  25. package/lib/util/federation.d.ts +15 -15
  26. package/lib/util/federation.js +149 -149
  27. package/lib/util/flexplm-connect.d.ts +16 -16
  28. package/lib/util/flexplm-connect.js +130 -130
  29. package/lib/util/logger-config.d.ts +1 -1
  30. package/lib/util/logger-config.js +26 -26
  31. package/lib/util/map-util-spec-mockData.d.ts +0 -0
  32. package/lib/util/map-util-spec-mockData.js +203 -0
  33. package/lib/util/map-utils.d.ts +4 -3
  34. package/lib/util/map-utils.js +28 -20
  35. package/lib/util/mockData.d.ts +39 -39
  36. package/lib/util/mockData.js +100 -100
  37. package/lib/util/thumbnail-util.d.ts +15 -15
  38. package/lib/util/thumbnail-util.js +112 -112
  39. package/lib/util/type-conversion-utils-spec-mockData.d.ts +0 -0
  40. package/lib/util/type-conversion-utils-spec-mockData.js +205 -0
  41. package/lib/util/type-conversion-utils.d.ts +10 -0
  42. package/lib/util/type-conversion-utils.js +100 -0
  43. package/lib/util/type-defaults.d.ts +9 -0
  44. package/lib/util/type-defaults.js +117 -0
  45. package/lib/util/type-utils.d.ts +12 -12
  46. package/lib/util/type-utils.js +101 -101
  47. package/package.json +47 -46
@@ -1,112 +1,112 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ThumbnailUtil = void 0;
4
- const app_framework_1 = require("@contrail/app-framework");
5
- const sdk_1 = require("@contrail/sdk");
6
- class ThumbnailUtil {
7
- constructor(config) {
8
- this.config = config;
9
- this.max_thumbnail_size = 5 * 1024 * 1024;
10
- this.entities = new sdk_1.Entities();
11
- if (this.config['max_thumbnail_size']) {
12
- this.max_thumbnail_size = this.config['max_thumbnail_size'];
13
- }
14
- }
15
- async setOutboundThumbnail(data, event) {
16
- if (event?.newData?.primaryViewableId && event?.newData?.largeViewableDownloadUrl) {
17
- const primaryViewableId = event.newData.primaryViewableId;
18
- const fileId = await this.getFileId(primaryViewableId);
19
- if (fileId) {
20
- const key = (event?.propertyDiffs?.largeViewableDownloadUrl)
21
- ? ThumbnailUtil.NEW_THUMBNAIL_ID
22
- : ThumbnailUtil.EXISTING_THUMBNAIL_ID;
23
- data[key] = fileId;
24
- }
25
- }
26
- else if (event?.propertyDiffs?.largeViewableDownloadUrl?.oldValue && !event?.propertyDiffs?.largeViewableDownloadUrl?.newValue) {
27
- data[ThumbnailUtil.NEW_THUMBNAIL_ID] = ThumbnailUtil.REMOVE_THUMBNAIL;
28
- }
29
- return data;
30
- }
31
- async getFileId(primaryViewableId) {
32
- console.info('getFileId()-' + primaryViewableId);
33
- const sizes = await this.getCustomSizes();
34
- const OOBSizes = [{ slug: 'largeViewable' }, { slug: 'mediumViewable' }, { slug: 'smallViewable' }, { slug: 'tinyViewable' }];
35
- sizes.push(...OOBSizes);
36
- console.info('sizes: ' + JSON.stringify(sizes));
37
- const content = await this.getContentEntity(primaryViewableId);
38
- if (app_framework_1.Logger.isDebugOn()) {
39
- console.debug('content: ' + JSON.stringify(content));
40
- }
41
- if (!content) {
42
- return undefined;
43
- }
44
- const contentKeys = Object.getOwnPropertyNames(content);
45
- const fileEntityIds = [];
46
- for (const size of sizes) {
47
- const key = size.slug + 'Id';
48
- if (contentKeys.includes(key) && !fileEntityIds.includes(content[key])) {
49
- fileEntityIds.push(content[key]);
50
- size['fileId'] = content[key];
51
- }
52
- }
53
- const fileResults = await this.getFileEntities(fileEntityIds);
54
- if (app_framework_1.Logger.isDebugOn()) {
55
- console.debug('fileResults: ' + JSON.stringify(fileResults));
56
- }
57
- let fileId = undefined;
58
- let tempFileSize = 0;
59
- const isDebugOn = app_framework_1.Logger.isDebugOn();
60
- for (const sizeObj of sizes) {
61
- if (isDebugOn) {
62
- console.debug('size: ' + JSON.stringify(sizeObj));
63
- }
64
- if (sizeObj['fileId']) {
65
- const file = fileResults.find(f => f['id'] === sizeObj['fileId']);
66
- if (file['size'] > tempFileSize && file['size'] < this.max_thumbnail_size) {
67
- tempFileSize = file['size'];
68
- fileId = file['id'];
69
- if (isDebugOn) {
70
- console.debug('fileId: ' + fileId);
71
- }
72
- }
73
- }
74
- }
75
- console.info('getFileId(): returning-' + fileId);
76
- return fileId;
77
- }
78
- async getCustomSizes() {
79
- const customSizes = await this.entities.get({
80
- entityName: 'content-custom-size'
81
- });
82
- const sizes = [];
83
- sizes.push(...customSizes);
84
- return sizes;
85
- }
86
- async getContentEntity(primaryViewableId) {
87
- const criteria = {
88
- id: primaryViewableId
89
- };
90
- const contentResults = await this.entities.get({
91
- entityName: 'content',
92
- criteria
93
- });
94
- console.info('contentResults: ' + JSON.stringify(contentResults));
95
- const content = (contentResults && contentResults[0]) ? contentResults[0] : undefined;
96
- return content;
97
- }
98
- async getFileEntities(fileEntityIds) {
99
- const criteria = {
100
- ids: fileEntityIds
101
- };
102
- const fileResults = await this.entities.get({
103
- entityName: 'file',
104
- criteria
105
- });
106
- return fileResults;
107
- }
108
- }
109
- exports.ThumbnailUtil = ThumbnailUtil;
110
- ThumbnailUtil.NEW_THUMBNAIL_ID = 'NEW_THUMBNAIL_ID';
111
- ThumbnailUtil.EXISTING_THUMBNAIL_ID = 'EXISTING_THUMBNAIL_ID';
112
- ThumbnailUtil.REMOVE_THUMBNAIL = 'REMOVE_THUMBNAIL';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ThumbnailUtil = void 0;
4
+ const app_framework_1 = require("@contrail/app-framework");
5
+ const sdk_1 = require("@contrail/sdk");
6
+ class ThumbnailUtil {
7
+ constructor(config) {
8
+ this.config = config;
9
+ this.max_thumbnail_size = 5 * 1024 * 1024;
10
+ this.entities = new sdk_1.Entities();
11
+ if (this.config['max_thumbnail_size']) {
12
+ this.max_thumbnail_size = this.config['max_thumbnail_size'];
13
+ }
14
+ }
15
+ async setOutboundThumbnail(data, event) {
16
+ if (event?.newData?.primaryViewableId && event?.newData?.largeViewableDownloadUrl) {
17
+ const primaryViewableId = event.newData.primaryViewableId;
18
+ const fileId = await this.getFileId(primaryViewableId);
19
+ if (fileId) {
20
+ const key = (event?.propertyDiffs?.largeViewableDownloadUrl)
21
+ ? ThumbnailUtil.NEW_THUMBNAIL_ID
22
+ : ThumbnailUtil.EXISTING_THUMBNAIL_ID;
23
+ data[key] = fileId;
24
+ }
25
+ }
26
+ else if (event?.propertyDiffs?.largeViewableDownloadUrl?.oldValue && !event?.propertyDiffs?.largeViewableDownloadUrl?.newValue) {
27
+ data[ThumbnailUtil.NEW_THUMBNAIL_ID] = ThumbnailUtil.REMOVE_THUMBNAIL;
28
+ }
29
+ return data;
30
+ }
31
+ async getFileId(primaryViewableId) {
32
+ console.info('getFileId()-' + primaryViewableId);
33
+ const sizes = await this.getCustomSizes();
34
+ const OOBSizes = [{ slug: 'largeViewable' }, { slug: 'mediumViewable' }, { slug: 'smallViewable' }, { slug: 'tinyViewable' }];
35
+ sizes.push(...OOBSizes);
36
+ console.info('sizes: ' + JSON.stringify(sizes));
37
+ const content = await this.getContentEntity(primaryViewableId);
38
+ if (app_framework_1.Logger.isDebugOn()) {
39
+ console.debug('content: ' + JSON.stringify(content));
40
+ }
41
+ if (!content) {
42
+ return undefined;
43
+ }
44
+ const contentKeys = Object.getOwnPropertyNames(content);
45
+ const fileEntityIds = [];
46
+ for (const size of sizes) {
47
+ const key = size.slug + 'Id';
48
+ if (contentKeys.includes(key) && !fileEntityIds.includes(content[key])) {
49
+ fileEntityIds.push(content[key]);
50
+ size['fileId'] = content[key];
51
+ }
52
+ }
53
+ const fileResults = await this.getFileEntities(fileEntityIds);
54
+ if (app_framework_1.Logger.isDebugOn()) {
55
+ console.debug('fileResults: ' + JSON.stringify(fileResults));
56
+ }
57
+ let fileId = undefined;
58
+ let tempFileSize = 0;
59
+ const isDebugOn = app_framework_1.Logger.isDebugOn();
60
+ for (const sizeObj of sizes) {
61
+ if (isDebugOn) {
62
+ console.debug('size: ' + JSON.stringify(sizeObj));
63
+ }
64
+ if (sizeObj['fileId']) {
65
+ const file = fileResults.find(f => f['id'] === sizeObj['fileId']);
66
+ if (file['size'] > tempFileSize && file['size'] < this.max_thumbnail_size) {
67
+ tempFileSize = file['size'];
68
+ fileId = file['id'];
69
+ if (isDebugOn) {
70
+ console.debug('fileId: ' + fileId);
71
+ }
72
+ }
73
+ }
74
+ }
75
+ console.info('getFileId(): returning-' + fileId);
76
+ return fileId;
77
+ }
78
+ async getCustomSizes() {
79
+ const customSizes = await this.entities.get({
80
+ entityName: 'content-custom-size'
81
+ });
82
+ const sizes = [];
83
+ sizes.push(...customSizes);
84
+ return sizes;
85
+ }
86
+ async getContentEntity(primaryViewableId) {
87
+ const criteria = {
88
+ id: primaryViewableId
89
+ };
90
+ const contentResults = await this.entities.get({
91
+ entityName: 'content',
92
+ criteria
93
+ });
94
+ console.info('contentResults: ' + JSON.stringify(contentResults));
95
+ const content = (contentResults && contentResults[0]) ? contentResults[0] : undefined;
96
+ return content;
97
+ }
98
+ async getFileEntities(fileEntityIds) {
99
+ const criteria = {
100
+ ids: fileEntityIds
101
+ };
102
+ const fileResults = await this.entities.get({
103
+ entityName: 'file',
104
+ criteria
105
+ });
106
+ return fileResults;
107
+ }
108
+ }
109
+ exports.ThumbnailUtil = ThumbnailUtil;
110
+ ThumbnailUtil.NEW_THUMBNAIL_ID = 'NEW_THUMBNAIL_ID';
111
+ ThumbnailUtil.EXISTING_THUMBNAIL_ID = 'EXISTING_THUMBNAIL_ID';
112
+ ThumbnailUtil.REMOVE_THUMBNAIL = 'REMOVE_THUMBNAIL';
@@ -0,0 +1,205 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
3
+ exports.mapping = {
4
+ typeConversion: {
5
+ vibe2flex: {
6
+ 'custom-entity': {
7
+ getMapKey: (entity) => {
8
+ const typePath = entity['typePath'];
9
+ let mapKey = '';
10
+ switch (typePath) {
11
+ case 'custom-entity:pack':
12
+ mapKey = 'packaging';
13
+ break;
14
+ case 'custom-entity:prefix':
15
+ mapKey = 'prefix';
16
+ break;
17
+ case 'custom-entity:catName':
18
+ mapKey = 'catName';
19
+ break;
20
+ case 'custom-entity:partnerOrg':
21
+ mapKey = 'partnerOrg';
22
+ break;
23
+ case 'custom-entity:catFamily':
24
+ mapKey = 'catFamily';
25
+ break;
26
+ case 'custom-entity:formName':
27
+ mapKey = 'formName';
28
+ break;
29
+ }
30
+ return mapKey;
31
+ }
32
+ }
33
+ }
34
+ },
35
+ LCSProduct: {
36
+ vibeOwningKeys: ['itemNumber', 'lifecycleStage'],
37
+ vibe2flex: {
38
+ getClass: () => 'LCSProduct',
39
+ getSoftType: (entity) => {
40
+ const prodType = entity['prodType'];
41
+ let val = '';
42
+ switch (prodType) {
43
+ case 'acc':
44
+ val = 'Product\\Accesories';
45
+ break;
46
+ case 'app':
47
+ val = 'Product\\Apparel';
48
+ break;
49
+ case 'eqp':
50
+ val = 'Product\\Equipment';
51
+ break;
52
+ case 'foot':
53
+ val = 'Product\\Footwear';
54
+ break;
55
+ }
56
+ return val;
57
+ },
58
+ transformOrder: [{ processor: 'REKEY', rekeyDelete: true, rekeyTransformersKey: 'rekey' }, { processor: 'VALUE_TRANSFORM', functionTransformersKey: 'valueTransform' }],
59
+ rekey: {
60
+ productName: 'name',
61
+ vibeIQIdentifier: 'itemNumber'
62
+ },
63
+ valueTransform: {
64
+ transformEx: (row) => {
65
+ return row['otherProp'] + 'xxx';
66
+ }
67
+ }
68
+ },
69
+ flex2vibe: {
70
+ getClass: () => 'item',
71
+ transformOrder: [{ processor: 'REKEY', rekeyDelete: true, rekeyTransformersKey: 'rekey' }],
72
+ rekey: {
73
+ itemNumber: 'vibeIQIdentifier',
74
+ name: 'productName',
75
+ }
76
+ }
77
+ },
78
+ LCSSKU: {
79
+ vibeOwningKeys: ['itemNumber', 'lifecycleStage'],
80
+ vibe2flex: {
81
+ getClass: () => 'LCSSKU',
82
+ getSoftType: (entity) => {
83
+ const prodType = entity['prodType'];
84
+ let val = '';
85
+ switch (prodType) {
86
+ case 'acc':
87
+ val = 'Product\\Accesories';
88
+ break;
89
+ case 'app':
90
+ val = 'Product\\Apparel';
91
+ break;
92
+ case 'eqp':
93
+ val = 'Product\\Equipment';
94
+ break;
95
+ case 'foot':
96
+ val = 'Product\\Footwear';
97
+ break;
98
+ }
99
+ return val;
100
+ },
101
+ transformOrder: [{ processor: 'REKEY', rekeyDelete: true, rekeyTransformersKey: 'rekey' }],
102
+ rekey: {
103
+ skuName: 'optionName',
104
+ vibeIQIdentifier: 'itemNumber'
105
+ }
106
+ },
107
+ flex2vibe: {
108
+ transformOrder: [{ processor: 'REKEY', rekeyDelete: true, rekeyTransformersKey: 'rekey' }],
109
+ rekey: {
110
+ itemNumber: 'vibeIQIdentifier',
111
+ optionName: 'skuName',
112
+ }
113
+ }
114
+ },
115
+ packaging: {
116
+ vibe2flex: {
117
+ transformOrder: [{ processor: 'REKEY', rekeyDelete: true, rekeyTransformersKey: 'rekey' }],
118
+ rekey: {
119
+ retailPackType: 'packType',
120
+ retailIntroDate: 'introDate'
121
+ },
122
+ getSoftType: () => 'Revisable Entity\\packaging',
123
+ getClass: () => 'LCSRevisableEntity'
124
+ },
125
+ flex2vibe: {
126
+ transformOrder: [{ processor: 'REKEY', rekeyDelete: true, rekeyTransformersKey: 'rekey' }],
127
+ rekey: {
128
+ packType: 'retailPackType',
129
+ introDate: 'retailIntroDate'
130
+ },
131
+ getClass: () => 'custom-entity',
132
+ getSoftType: () => 'custom-entity:pack',
133
+ }
134
+ },
135
+ prefix: {
136
+ vibe2flex: {
137
+ transformOrder: [{ processor: 'REKEY', rekeyDelete: true, rekeyTransformersKey: 'rekey' }],
138
+ rekey: {
139
+ retailOwner: 'owner',
140
+ retailIntroDate: 'introDate'
141
+ },
142
+ getSoftType: () => 'Revisable Entity\\prefix',
143
+ getClass: () => 'LCSRevisableEntity'
144
+ },
145
+ flex2vibe: {
146
+ transformOrder: [{ processor: 'REKEY', rekeyDelete: true, rekeyTransformersKey: 'rekey' }],
147
+ rekey: {
148
+ owner: 'retailOwner',
149
+ introDate: 'retailIntroDate'
150
+ },
151
+ getClass: () => 'custom-entity',
152
+ getSoftType: () => 'custom-entity:prefix',
153
+ }
154
+ },
155
+ catName: {
156
+ vibe2flex: {
157
+ transformOrder: [],
158
+ getSoftType: () => 'Revisable Entity\\catName',
159
+ getClass: () => 'LCSLast',
160
+ getIdentifierProperties: () => ['catName', 'catNumber'],
161
+ getInformationalProperties: () => ['longName']
162
+ },
163
+ flex2vibe: {
164
+ transformOrder: [],
165
+ getClass: () => 'custom-entity',
166
+ getSoftType: () => 'custom-entity:catName',
167
+ }
168
+ },
169
+ partnerOrg: {
170
+ vibe2flex: {
171
+ transformOrder: [],
172
+ getSoftType: () => 'Business Object\\partnerOrg',
173
+ getClass: () => 'LCSLifecycleManaged'
174
+ },
175
+ flex2vibe: {
176
+ transformOrder: [],
177
+ getClass: () => 'custom-entity',
178
+ getSoftType: () => 'custom-entity:partnerOrg',
179
+ }
180
+ },
181
+ catFamily: {
182
+ vibe2flex: {
183
+ transformOrder: [],
184
+ getSoftType: () => 'Revisable Entity\\catFamily',
185
+ getClass: () => 'LCSRevisableEntity'
186
+ },
187
+ flex2vibe: {
188
+ transformOrder: [],
189
+ getClass: () => 'custom-entity',
190
+ getSoftType: () => 'custom-entity:catFamily',
191
+ }
192
+ },
193
+ formName: {
194
+ vibe2flex: {
195
+ transformOrder: [],
196
+ getSoftType: () => 'Material\\form',
197
+ getClass: () => 'LCSMaterial'
198
+ },
199
+ flex2vibe: {
200
+ transformOrder: [],
201
+ getClass: () => 'custom-entity',
202
+ getSoftType: () => 'custom-entity:formName',
203
+ }
204
+ },
205
+ };
@@ -0,0 +1,10 @@
1
+ export declare class TypeConversionUtils {
2
+ static NO_ENTITY_TYPE: string;
3
+ static VIBE2FLEX_DIRECTION: string;
4
+ constructor();
5
+ static getObjectClass(transformMapFile: any, mapFileUtil: any, entity: any): Promise<string>;
6
+ static getObjectTypePath(transformMapFile: any, mapFileUtil: any, entity: any): Promise<string>;
7
+ static getIdentifierProperties(transformMapFile: any, mapFileUtil: any, entity: any): Promise<string[]>;
8
+ static getInformationalProperties(transformMapFile: any, mapFileUtil: any, entity: any): Promise<string[]>;
9
+ static getEntityType(entity: any): any;
10
+ }
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypeConversionUtils = void 0;
4
+ const type_defaults_1 = require("./type-defaults");
5
+ const map_utils_1 = require("./map-utils");
6
+ class TypeConversionUtils {
7
+ constructor() {
8
+ }
9
+ static async getObjectClass(transformMapFile, mapFileUtil, entity) {
10
+ let objectClass = entity['flexPLMObjectClass'];
11
+ if (objectClass) {
12
+ return objectClass;
13
+ }
14
+ if (transformMapFile) {
15
+ const type = this.getEntityType(entity);
16
+ const mapKey = await map_utils_1.MapUtil.getMapKey(transformMapFile, mapFileUtil, entity, type, TypeConversionUtils.VIBE2FLEX_DIRECTION);
17
+ const mapData = await mapFileUtil.getMappingSection(transformMapFile, mapKey, TypeConversionUtils.VIBE2FLEX_DIRECTION);
18
+ if (mapData['getClass']) {
19
+ objectClass = await mapData['getClass'](entity);
20
+ }
21
+ }
22
+ if (objectClass) {
23
+ return objectClass;
24
+ }
25
+ return type_defaults_1.TypeDefaults.getDefaultObjectClass(entity);
26
+ }
27
+ static async getObjectTypePath(transformMapFile, mapFileUtil, entity) {
28
+ let typePath = entity['flexPLMTypePath'];
29
+ if (typePath) {
30
+ return typePath;
31
+ }
32
+ if (transformMapFile) {
33
+ const type = this.getEntityType(entity);
34
+ const mapKey = await map_utils_1.MapUtil.getMapKey(transformMapFile, mapFileUtil, entity, type, TypeConversionUtils.VIBE2FLEX_DIRECTION);
35
+ const mapData = await mapFileUtil.getMappingSection(transformMapFile, mapKey, TypeConversionUtils.VIBE2FLEX_DIRECTION);
36
+ if (mapData['getSoftType']) {
37
+ typePath = await mapData['getSoftType'](entity);
38
+ }
39
+ }
40
+ if (typePath) {
41
+ return typePath;
42
+ }
43
+ return type_defaults_1.TypeDefaults.getDefaultObjectTypePath(entity);
44
+ }
45
+ static async getIdentifierProperties(transformMapFile, mapFileUtil, entity) {
46
+ let identifiers = entity['flexPLMIdentifierProperties'];
47
+ if (identifiers) {
48
+ return identifiers;
49
+ }
50
+ if (transformMapFile) {
51
+ const type = this.getEntityType(entity);
52
+ const mapKey = await map_utils_1.MapUtil.getMapKey(transformMapFile, mapFileUtil, entity, type, TypeConversionUtils.VIBE2FLEX_DIRECTION);
53
+ const mapData = await mapFileUtil.getMappingSection(transformMapFile, mapKey, TypeConversionUtils.VIBE2FLEX_DIRECTION);
54
+ if (mapData['getIdentifierProperties']) {
55
+ identifiers = await mapData['getIdentifierProperties'](entity);
56
+ }
57
+ }
58
+ if (identifiers) {
59
+ return identifiers;
60
+ }
61
+ return type_defaults_1.TypeDefaults.getDefaultIdentifierProperties(entity);
62
+ }
63
+ static async getInformationalProperties(transformMapFile, mapFileUtil, entity) {
64
+ let identifiers = entity['flexPLMInformationalProperties'];
65
+ if (identifiers) {
66
+ return identifiers;
67
+ }
68
+ if (transformMapFile) {
69
+ const type = this.getEntityType(entity);
70
+ const mapKey = await map_utils_1.MapUtil.getMapKey(transformMapFile, mapFileUtil, entity, type, TypeConversionUtils.VIBE2FLEX_DIRECTION);
71
+ const mapData = await mapFileUtil.getMappingSection(transformMapFile, mapKey, TypeConversionUtils.VIBE2FLEX_DIRECTION);
72
+ if (mapData['getInformationalProperties']) {
73
+ identifiers = await mapData['getInformationalProperties'](entity);
74
+ }
75
+ }
76
+ if (identifiers) {
77
+ return identifiers;
78
+ }
79
+ return type_defaults_1.TypeDefaults.getDefaultInformationalProperties(entity);
80
+ }
81
+ static getEntityType(entity) {
82
+ let entityType = entity['entityType'];
83
+ if (!entityType) {
84
+ const typePath = entity['typePath'];
85
+ if (typePath) {
86
+ const types = typePath.split(':');
87
+ if (types && types[0]) {
88
+ entityType = types[0];
89
+ }
90
+ }
91
+ }
92
+ if (!entityType) {
93
+ throw Error(TypeConversionUtils.NO_ENTITY_TYPE);
94
+ }
95
+ return entityType;
96
+ }
97
+ }
98
+ exports.TypeConversionUtils = TypeConversionUtils;
99
+ TypeConversionUtils.NO_ENTITY_TYPE = 'Not able to determine the entity type of the entity object';
100
+ TypeConversionUtils.VIBE2FLEX_DIRECTION = 'vibe2flex';
@@ -0,0 +1,9 @@
1
+ export declare class TypeDefaults {
2
+ static NO_ENTITY_TYPE: string;
3
+ constructor();
4
+ static getDefaultObjectClass(entity: any): string;
5
+ static getDefaultObjectTypePath(entity: any): string;
6
+ static getDefaultIdentifierProperties(entity: any): string[];
7
+ static getDefaultInformationalProperties(entity: any): string[];
8
+ static getEntityType(entity: any): any;
9
+ }
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypeDefaults = void 0;
4
+ class TypeDefaults {
5
+ constructor() {
6
+ }
7
+ static getDefaultObjectClass(entity) {
8
+ const entityType = this.getEntityType(entity);
9
+ let objectClass = '';
10
+ if ('item' === entityType) {
11
+ if (entity.roles.includes('family')) {
12
+ objectClass = 'LCSProduct';
13
+ }
14
+ else if (entity.roles.includes('color')) {
15
+ objectClass = 'LCSSKU';
16
+ }
17
+ }
18
+ else if ('project-item' === entityType) {
19
+ if (entity.roles.includes('family')) {
20
+ objectClass = 'LCSProductSeasonLink';
21
+ }
22
+ else if (entity.roles.includes('color')) {
23
+ objectClass = 'LCSSKUSeasonLink';
24
+ }
25
+ }
26
+ else if ('color' === entityType) {
27
+ objectClass = 'LCSColor';
28
+ }
29
+ else if ('custom-entity' === entityType) {
30
+ objectClass = 'LCSRevisableEntity';
31
+ }
32
+ else if ('project' === entityType) {
33
+ objectClass = 'LCSSeason';
34
+ }
35
+ else if ('assortment' === entityType) {
36
+ objectClass = 'SeasonGroup';
37
+ }
38
+ return objectClass;
39
+ }
40
+ static getDefaultObjectTypePath(entity) {
41
+ let typePath = '';
42
+ const entityType = this.getEntityType(entity);
43
+ switch (entityType) {
44
+ case 'item':
45
+ case 'project-item':
46
+ typePath = 'Product';
47
+ break;
48
+ case 'color':
49
+ typePath = 'Color';
50
+ break;
51
+ case 'custom-entity':
52
+ typePath = 'Revisable Entity';
53
+ break;
54
+ case 'assortment':
55
+ typePath = 'Season Group';
56
+ break;
57
+ case 'project':
58
+ typePath = 'Season';
59
+ break;
60
+ }
61
+ return typePath;
62
+ }
63
+ static getDefaultIdentifierProperties(entity) {
64
+ const identifierProps = [];
65
+ const entityType = this.getEntityType(entity);
66
+ switch (entityType) {
67
+ case 'item':
68
+ identifierProps.push('itemNumber');
69
+ break;
70
+ case 'project':
71
+ identifierProps.push('flexPLMSeasonName');
72
+ break;
73
+ case 'assortment':
74
+ identifierProps.push('seasonGroupName');
75
+ break;
76
+ case 'color':
77
+ case 'custom-entity':
78
+ identifierProps.push('name');
79
+ break;
80
+ }
81
+ return identifierProps;
82
+ }
83
+ static getDefaultInformationalProperties(entity) {
84
+ const entityType = this.getEntityType(entity);
85
+ let properties = [];
86
+ if ('item' === entityType) {
87
+ if (entity.roles.includes('family')) {
88
+ properties.push('name');
89
+ }
90
+ else if (entity.roles.includes('color')) {
91
+ properties.push('optionName');
92
+ }
93
+ }
94
+ else if (['project', 'assortment'].includes(entityType)) {
95
+ properties.push('name');
96
+ }
97
+ return properties;
98
+ }
99
+ static getEntityType(entity) {
100
+ let entityType = entity['entityType'];
101
+ if (!entityType) {
102
+ const typePath = entity['typePath'];
103
+ if (typePath) {
104
+ const types = typePath.split(':');
105
+ if (types && types[0]) {
106
+ entityType = types[0];
107
+ }
108
+ }
109
+ }
110
+ if (!entityType) {
111
+ throw Error(TypeDefaults.NO_ENTITY_TYPE);
112
+ }
113
+ return entityType;
114
+ }
115
+ }
116
+ exports.TypeDefaults = TypeDefaults;
117
+ TypeDefaults.NO_ENTITY_TYPE = 'Not able to determine the entity type of the entity object';