@contrail/transform-data 1.0.13 → 1.0.14
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.
|
@@ -6,10 +6,10 @@ export declare class MapFileUtil {
|
|
|
6
6
|
static ERROR_RETRIEVING: string;
|
|
7
7
|
constructor(entities: any);
|
|
8
8
|
getMapFile(fileId: string): Promise<any>;
|
|
9
|
-
getMappingSectionFromMap(mapFile: any,
|
|
10
|
-
getFullMapSection(transformMapFile: string,
|
|
11
|
-
getMappingSection(fileId: string,
|
|
9
|
+
getMappingSectionFromMap(mapFile: any, mapSectionKey: string, direction: string): {};
|
|
10
|
+
getFullMapSection(transformMapFile: string, mapSectionKey: string): Promise<any>;
|
|
11
|
+
getMappingSection(fileId: string, mapSectionKey: string, direction: string): Promise<{}>;
|
|
12
12
|
getMapKey(fileId: any, data: any, type: string, direction: string): Promise<string>;
|
|
13
|
-
static getTransformTasks(
|
|
14
|
-
applyTransformMap(fileId: any, data: any,
|
|
13
|
+
static getTransformTasks(directionalMapSection: object): TransformTask[];
|
|
14
|
+
applyTransformMap(fileId: any, data: any, mapSectionKey: string, direction: string): Promise<any>;
|
|
15
15
|
}
|
|
@@ -42,30 +42,30 @@ class MapFileUtil {
|
|
|
42
42
|
this.cache[fileId] = mappingFile;
|
|
43
43
|
return mappingFile;
|
|
44
44
|
}
|
|
45
|
-
getMappingSectionFromMap(mapFile,
|
|
45
|
+
getMappingSectionFromMap(mapFile, mapSectionKey, direction) {
|
|
46
46
|
let mapping = {};
|
|
47
|
-
if (mapFile[
|
|
48
|
-
const classMapping = mapFile[
|
|
47
|
+
if (mapFile[mapSectionKey]) {
|
|
48
|
+
const classMapping = mapFile[mapSectionKey];
|
|
49
49
|
if (classMapping[direction]) {
|
|
50
50
|
mapping = classMapping[direction];
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
return mapping;
|
|
54
54
|
}
|
|
55
|
-
async getFullMapSection(transformMapFile,
|
|
56
|
-
if (
|
|
55
|
+
async getFullMapSection(transformMapFile, mapSectionKey) {
|
|
56
|
+
if (mapSectionKey) {
|
|
57
57
|
const mapFile = await this.getMapFile(transformMapFile);
|
|
58
58
|
if (mapFile) {
|
|
59
|
-
const mapSection = mapFile[
|
|
59
|
+
const mapSection = mapFile[mapSectionKey];
|
|
60
60
|
return mapSection;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
return undefined;
|
|
64
64
|
}
|
|
65
|
-
async getMappingSection(fileId,
|
|
65
|
+
async getMappingSection(fileId, mapSectionKey, direction) {
|
|
66
66
|
const map = await this.getMapFile(fileId);
|
|
67
|
-
const
|
|
68
|
-
return
|
|
67
|
+
const directional = this.getMappingSectionFromMap(map, mapSectionKey, direction);
|
|
68
|
+
return directional;
|
|
69
69
|
}
|
|
70
70
|
async getMapKey(fileId, data, type, direction) {
|
|
71
71
|
const mappingData = await this.getMappingSection(fileId, 'typeConversion', direction);
|
|
@@ -75,9 +75,9 @@ class MapFileUtil {
|
|
|
75
75
|
}
|
|
76
76
|
return undefined;
|
|
77
77
|
}
|
|
78
|
-
static getTransformTasks(
|
|
78
|
+
static getTransformTasks(directionalMapSection) {
|
|
79
79
|
const tasks = [];
|
|
80
|
-
const order =
|
|
80
|
+
const order = directionalMapSection['transformOrder'];
|
|
81
81
|
if (order) {
|
|
82
82
|
for (const step of order) {
|
|
83
83
|
const task = {
|
|
@@ -88,7 +88,7 @@ class MapFileUtil {
|
|
|
88
88
|
for (const mapping of ['conditionalTransformDefinitions', 'functionTransformers', 'rekeyTransformers', 'removeKeys']) {
|
|
89
89
|
const mapKey = step[mapping + 'Key'];
|
|
90
90
|
if (mapKey) {
|
|
91
|
-
task[mapping] =
|
|
91
|
+
task[mapping] = directionalMapSection[mapKey];
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
tasks.push(task);
|
|
@@ -96,9 +96,9 @@ class MapFileUtil {
|
|
|
96
96
|
}
|
|
97
97
|
return tasks;
|
|
98
98
|
}
|
|
99
|
-
async applyTransformMap(fileId, data,
|
|
99
|
+
async applyTransformMap(fileId, data, mapSectionKey, direction) {
|
|
100
100
|
if (fileId && data) {
|
|
101
|
-
const mapping = await this.getMappingSection(fileId,
|
|
101
|
+
const mapping = await this.getMappingSection(fileId, mapSectionKey, direction);
|
|
102
102
|
if (mapping) {
|
|
103
103
|
const tasks = MapFileUtil.getTransformTasks(mapping);
|
|
104
104
|
if (tasks.length > 0) {
|