@contrail/transform-data 1.0.11 → 1.0.13
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.
|
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: () => 'Revisable Entity\\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
|
+
};
|
|
@@ -7,6 +7,9 @@ export declare class MapFileUtil {
|
|
|
7
7
|
constructor(entities: any);
|
|
8
8
|
getMapFile(fileId: string): Promise<any>;
|
|
9
9
|
getMappingSectionFromMap(mapFile: any, objectClass: string, direction: string): {};
|
|
10
|
+
getFullMapSection(transformMapFile: string, mapKey: string): Promise<any>;
|
|
10
11
|
getMappingSection(fileId: string, objectClass: string, direction: string): Promise<{}>;
|
|
12
|
+
getMapKey(fileId: any, data: any, type: string, direction: string): Promise<string>;
|
|
11
13
|
static getTransformTasks(mapSection: object): TransformTask[];
|
|
14
|
+
applyTransformMap(fileId: any, data: any, mapKey: string, direction: string): Promise<any>;
|
|
12
15
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MapFileUtil = void 0;
|
|
4
|
+
const processor_1 = require("../processor");
|
|
4
5
|
class MapFileUtil {
|
|
5
6
|
constructor(entities) {
|
|
6
7
|
this.entities = entities;
|
|
@@ -51,11 +52,29 @@ class MapFileUtil {
|
|
|
51
52
|
}
|
|
52
53
|
return mapping;
|
|
53
54
|
}
|
|
55
|
+
async getFullMapSection(transformMapFile, mapKey) {
|
|
56
|
+
if (mapKey) {
|
|
57
|
+
const mapFile = await this.getMapFile(transformMapFile);
|
|
58
|
+
if (mapFile) {
|
|
59
|
+
const mapSection = mapFile[mapKey];
|
|
60
|
+
return mapSection;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
54
65
|
async getMappingSection(fileId, objectClass, direction) {
|
|
55
66
|
const map = await this.getMapFile(fileId);
|
|
56
67
|
const mapSection = this.getMappingSectionFromMap(map, objectClass, direction);
|
|
57
68
|
return mapSection;
|
|
58
69
|
}
|
|
70
|
+
async getMapKey(fileId, data, type, direction) {
|
|
71
|
+
const mappingData = await this.getMappingSection(fileId, 'typeConversion', direction);
|
|
72
|
+
if (mappingData && mappingData[type] && mappingData[type]['getMapKey']) {
|
|
73
|
+
const mapKey = await mappingData[type]['getMapKey'](data);
|
|
74
|
+
return mapKey;
|
|
75
|
+
}
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
59
78
|
static getTransformTasks(mapSection) {
|
|
60
79
|
const tasks = [];
|
|
61
80
|
const order = mapSection['transformOrder'];
|
|
@@ -77,6 +96,19 @@ class MapFileUtil {
|
|
|
77
96
|
}
|
|
78
97
|
return tasks;
|
|
79
98
|
}
|
|
99
|
+
async applyTransformMap(fileId, data, mapKey, direction) {
|
|
100
|
+
if (fileId && data) {
|
|
101
|
+
const mapping = await this.getMappingSection(fileId, mapKey, direction);
|
|
102
|
+
if (mapping) {
|
|
103
|
+
const tasks = MapFileUtil.getTransformTasks(mapping);
|
|
104
|
+
if (tasks.length > 0) {
|
|
105
|
+
const convertedArray = processor_1.TransformProcessor.transformData([data], tasks);
|
|
106
|
+
data = convertedArray[0];
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return data;
|
|
111
|
+
}
|
|
80
112
|
}
|
|
81
113
|
exports.MapFileUtil = MapFileUtil;
|
|
82
114
|
MapFileUtil.FILE_NOT_FOUND = 'Mapping File not found for id: ';
|
|
@@ -17,7 +17,7 @@ class TransformProcessor {
|
|
|
17
17
|
morph_transformer_1.MorphTransformer.transformData(rows, transformTask.functionTransformers, transformTask.dependencies);
|
|
18
18
|
break;
|
|
19
19
|
case 'REKEY':
|
|
20
|
-
rekey_1.RekeyTransformer.transformData(rows, transformTask.rekeyTransformers, transformTask.rekeyDelete, transformTask.
|
|
20
|
+
rekey_1.RekeyTransformer.transformData(rows, transformTask.rekeyTransformers, transformTask.rekeyDelete, transformTask.rekeyKeepMissingValues);
|
|
21
21
|
break;
|
|
22
22
|
case 'REMOVE':
|
|
23
23
|
remove_1.RemoveTransformer.transformData(rows, transformTask.removeKeys);
|