@contrail/flexplm 1.0.18 → 1.1.2
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-spec-mockData.d.ts +0 -0
- package/lib/util/data-converter-spec-mockData.js +205 -0
- package/lib/util/data-converter.js +7 -13
- package/lib/util/map-util-spec-mockData.js +2 -0
- package/lib/util/map-utils.d.ts +3 -1
- package/lib/util/map-utils.js +10 -0
- package/lib/util/type-conversion-utils-spec-mockData.js +4 -4
- package/lib/util/type-conversion-utils.d.ts +2 -0
- package/lib/util/type-conversion-utils.js +19 -12
- package/package.json +2 -2
|
File without changes
|
|
@@ -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
|
+
getIdentifierProperties: () => ['catName', 'catNumber'],
|
|
157
|
+
getInformationalProperties: () => ['longName'],
|
|
158
|
+
vibe2flex: {
|
|
159
|
+
transformOrder: [],
|
|
160
|
+
getSoftType: () => 'Last\\catName',
|
|
161
|
+
getClass: () => 'LCSLast'
|
|
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
|
+
};
|
|
@@ -3,9 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DataConverter = void 0;
|
|
4
4
|
const sdk_1 = require("@contrail/sdk");
|
|
5
5
|
const type_utils_1 = require("./type-utils");
|
|
6
|
-
const transform_data_1 = require("@contrail/transform-data");
|
|
7
6
|
const app_framework_1 = require("@contrail/app-framework");
|
|
8
7
|
const util_1 = require("@contrail/util");
|
|
8
|
+
const type_conversion_utils_1 = require("./type-conversion-utils");
|
|
9
|
+
const map_utils_1 = require("./map-utils");
|
|
9
10
|
class DataConverter {
|
|
10
11
|
constructor(config, mapFileUtil) {
|
|
11
12
|
this.config = config;
|
|
@@ -151,22 +152,15 @@ class DataConverter {
|
|
|
151
152
|
}
|
|
152
153
|
if (value && !(typeof value === 'string')) {
|
|
153
154
|
const unprocessedValue = value;
|
|
154
|
-
const objectClass =
|
|
155
|
+
const objectClass = await type_conversion_utils_1.TypeConversionUtils.getObjectClass(this.transformMapFile, this.mapFileUtil, unprocessedValue);
|
|
156
|
+
const flexPLMTypePath = await type_conversion_utils_1.TypeConversionUtils.getObjectTypePath(this.transformMapFile, this.mapFileUtil, unprocessedValue);
|
|
155
157
|
value = await this.getFlexPLMObjectData(value, [], false);
|
|
156
158
|
value['entityReference'] = entityType + ':' + entityId;
|
|
157
159
|
value['objectClass'] = objectClass;
|
|
158
|
-
value['
|
|
160
|
+
value['flexPLMTypePath'] = flexPLMTypePath;
|
|
159
161
|
if (this.transformMapFile) {
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
const mapping = await this.mapFileUtil.getMappingSection(this.transformMapFile, objClass, 'vibe2flex');
|
|
163
|
-
if (mapping) {
|
|
164
|
-
const tasks = transform_data_1.MapFileUtil.getTransformTasks(mapping);
|
|
165
|
-
if (tasks.length > 0) {
|
|
166
|
-
const convertedArray = transform_data_1.TransformProcessor.transformData([value], tasks);
|
|
167
|
-
value = convertedArray[0];
|
|
168
|
-
}
|
|
169
|
-
}
|
|
162
|
+
const mapKey = await type_conversion_utils_1.TypeConversionUtils.getMapKey(this.transformMapFile, this.mapFileUtil, unprocessedValue, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
163
|
+
value = await map_utils_1.MapUtil.applyTransformMap(this.transformMapFile, this.mapFileUtil, value, mapKey, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
170
164
|
}
|
|
171
165
|
}
|
|
172
166
|
else {
|
|
@@ -153,6 +153,8 @@ exports.mapping = {
|
|
|
153
153
|
}
|
|
154
154
|
},
|
|
155
155
|
catName: {
|
|
156
|
+
getIdentifierProperties: () => ['catName', 'catNumber'],
|
|
157
|
+
getInformationalProperties: () => ['longName'],
|
|
156
158
|
vibe2flex: {
|
|
157
159
|
transformOrder: [],
|
|
158
160
|
getSoftType: () => 'Revisable Entity\\catName',
|
package/lib/util/map-utils.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { MapFileUtil } from '@contrail/transform-data';
|
|
1
2
|
export declare class MapUtil {
|
|
2
3
|
static applyTransformMap(transformMapFile: any, mapFileUtil: any, data: any, type: string, direction: string): Promise<any>;
|
|
3
|
-
static getMapKey(transformMapFile: any, mapFileUtil:
|
|
4
|
+
static getMapKey(transformMapFile: any, mapFileUtil: MapFileUtil, data: any, type: string, direction: string): Promise<string>;
|
|
5
|
+
static getFullMapSection(transformMapFile: string, mapFileUtil: MapFileUtil, mapKey: string): Promise<any>;
|
|
4
6
|
}
|
package/lib/util/map-utils.js
CHANGED
|
@@ -24,5 +24,15 @@ class MapUtil {
|
|
|
24
24
|
}
|
|
25
25
|
return undefined;
|
|
26
26
|
}
|
|
27
|
+
static async getFullMapSection(transformMapFile, mapFileUtil, mapKey) {
|
|
28
|
+
if (mapKey) {
|
|
29
|
+
const mapFile = await mapFileUtil.getMapFile(transformMapFile);
|
|
30
|
+
if (mapFile) {
|
|
31
|
+
const mapSection = mapFile[mapKey];
|
|
32
|
+
return mapSection;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
27
37
|
}
|
|
28
38
|
exports.MapUtil = MapUtil;
|
|
@@ -153,12 +153,12 @@ exports.mapping = {
|
|
|
153
153
|
}
|
|
154
154
|
},
|
|
155
155
|
catName: {
|
|
156
|
+
getIdentifierProperties: () => ['catName', 'catNumber'],
|
|
157
|
+
getInformationalProperties: () => ['longName'],
|
|
156
158
|
vibe2flex: {
|
|
157
159
|
transformOrder: [],
|
|
158
|
-
getSoftType: () => '
|
|
159
|
-
getClass: () => 'LCSLast'
|
|
160
|
-
getIdentifierProperties: () => ['catName', 'catNumber'],
|
|
161
|
-
getInformationalProperties: () => ['longName']
|
|
160
|
+
getSoftType: () => 'Last\\catName',
|
|
161
|
+
getClass: () => 'LCSLast'
|
|
162
162
|
},
|
|
163
163
|
flex2vibe: {
|
|
164
164
|
transformOrder: [],
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MapFileUtil } from '@contrail/transform-data';
|
|
1
2
|
export declare class TypeConversionUtils {
|
|
2
3
|
static NO_ENTITY_TYPE: string;
|
|
3
4
|
static VIBE2FLEX_DIRECTION: string;
|
|
@@ -6,5 +7,6 @@ export declare class TypeConversionUtils {
|
|
|
6
7
|
static getObjectTypePath(transformMapFile: any, mapFileUtil: any, entity: any): Promise<string>;
|
|
7
8
|
static getIdentifierProperties(transformMapFile: any, mapFileUtil: any, entity: any): Promise<string[]>;
|
|
8
9
|
static getInformationalProperties(transformMapFile: any, mapFileUtil: any, entity: any): Promise<string[]>;
|
|
10
|
+
static getMapKey(transformMapFile: any, mapFileUtil: MapFileUtil, entity: any, direction: string): Promise<string>;
|
|
9
11
|
static getEntityType(entity: any): any;
|
|
10
12
|
}
|
|
@@ -12,8 +12,7 @@ class TypeConversionUtils {
|
|
|
12
12
|
return objectClass;
|
|
13
13
|
}
|
|
14
14
|
if (transformMapFile) {
|
|
15
|
-
const
|
|
16
|
-
const mapKey = await map_utils_1.MapUtil.getMapKey(transformMapFile, mapFileUtil, entity, type, TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
15
|
+
const mapKey = await this.getMapKey(transformMapFile, mapFileUtil, entity, TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
17
16
|
const mapData = await mapFileUtil.getMappingSection(transformMapFile, mapKey, TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
18
17
|
if (mapData['getClass']) {
|
|
19
18
|
objectClass = await mapData['getClass'](entity);
|
|
@@ -30,8 +29,7 @@ class TypeConversionUtils {
|
|
|
30
29
|
return typePath;
|
|
31
30
|
}
|
|
32
31
|
if (transformMapFile) {
|
|
33
|
-
const
|
|
34
|
-
const mapKey = await map_utils_1.MapUtil.getMapKey(transformMapFile, mapFileUtil, entity, type, TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
32
|
+
const mapKey = await this.getMapKey(transformMapFile, mapFileUtil, entity, TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
35
33
|
const mapData = await mapFileUtil.getMappingSection(transformMapFile, mapKey, TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
36
34
|
if (mapData['getSoftType']) {
|
|
37
35
|
typePath = await mapData['getSoftType'](entity);
|
|
@@ -48,10 +46,9 @@ class TypeConversionUtils {
|
|
|
48
46
|
return identifiers;
|
|
49
47
|
}
|
|
50
48
|
if (transformMapFile) {
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
if (mapData['getIdentifierProperties']) {
|
|
49
|
+
const mapKey = await this.getMapKey(transformMapFile, mapFileUtil, entity, TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
50
|
+
const mapData = await map_utils_1.MapUtil.getFullMapSection(transformMapFile, mapFileUtil, mapKey);
|
|
51
|
+
if (mapData && mapData['getIdentifierProperties']) {
|
|
55
52
|
identifiers = await mapData['getIdentifierProperties'](entity);
|
|
56
53
|
}
|
|
57
54
|
}
|
|
@@ -66,10 +63,9 @@ class TypeConversionUtils {
|
|
|
66
63
|
return identifiers;
|
|
67
64
|
}
|
|
68
65
|
if (transformMapFile) {
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
if (mapData['getInformationalProperties']) {
|
|
66
|
+
const mapKey = await this.getMapKey(transformMapFile, mapFileUtil, entity, TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
67
|
+
const mapData = await map_utils_1.MapUtil.getFullMapSection(transformMapFile, mapFileUtil, mapKey);
|
|
68
|
+
if (mapData && mapData['getInformationalProperties']) {
|
|
73
69
|
identifiers = await mapData['getInformationalProperties'](entity);
|
|
74
70
|
}
|
|
75
71
|
}
|
|
@@ -78,6 +74,17 @@ class TypeConversionUtils {
|
|
|
78
74
|
}
|
|
79
75
|
return type_defaults_1.TypeDefaults.getDefaultInformationalProperties(entity);
|
|
80
76
|
}
|
|
77
|
+
static async getMapKey(transformMapFile, mapFileUtil, entity, direction) {
|
|
78
|
+
if (transformMapFile) {
|
|
79
|
+
const type = this.getEntityType(entity);
|
|
80
|
+
const mappingData = await mapFileUtil.getMappingSection(transformMapFile, 'typeConversion', direction);
|
|
81
|
+
if (mappingData && mappingData[type] && mappingData[type]['getMapKey']) {
|
|
82
|
+
const mapKey = await mappingData[type]['getMapKey'](entity);
|
|
83
|
+
return mapKey;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return type_defaults_1.TypeDefaults.getDefaultObjectClass(entity);
|
|
87
|
+
}
|
|
81
88
|
static getEntityType(entity) {
|
|
82
89
|
let entityType = entity['entityType'];
|
|
83
90
|
if (!entityType) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrail/flexplm",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Library used for integration with flexplm.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@contrail/app-framework": "^1.2.0",
|
|
42
42
|
"@contrail/sdk": "^1.2.11",
|
|
43
|
-
"@contrail/transform-data": "^1.0.
|
|
43
|
+
"@contrail/transform-data": "^1.0.13",
|
|
44
44
|
"axios": "^1.4.0",
|
|
45
45
|
"p-limit": "^3.1.0"
|
|
46
46
|
}
|