@contrail/transform-data 1.0.6 → 1.0.7

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.
@@ -1,3 +1,4 @@
1
+ import { TransformTask } from "../processor";
1
2
  export declare class MapFileUtil {
2
3
  private entities;
3
4
  private cache;
@@ -7,4 +8,5 @@ export declare class MapFileUtil {
7
8
  getMapFile(fileId: string): Promise<any>;
8
9
  getMappingSectionFromMap(mapFile: any, objectClass: string, direction: string): {};
9
10
  getMappingSection(fileId: string, objectClass: string, direction: string): Promise<{}>;
11
+ static getTransformTasks(mapSection: object): TransformTask[];
10
12
  }
@@ -60,6 +60,26 @@ class MapFileUtil {
60
60
  const mapSection = this.getMappingSectionFromMap(map, objectClass, direction);
61
61
  return mapSection;
62
62
  }
63
+ static getTransformTasks(mapSection) {
64
+ const tasks = [];
65
+ const order = mapSection['transformOrder'];
66
+ if (order) {
67
+ for (const step of order) {
68
+ const task = {
69
+ processor: step['processor'],
70
+ rekeyDelete: step['rekeyDelete']
71
+ };
72
+ for (const mapping of ['conditionalTransformDefinitions', 'functionTransformers', 'rekeyTransformers', 'removeKeys']) {
73
+ const mapKey = step[mapping + 'Key'];
74
+ if (mapKey) {
75
+ task[mapping] = mapSection[mapKey];
76
+ }
77
+ }
78
+ tasks.push(task);
79
+ }
80
+ }
81
+ return tasks;
82
+ }
63
83
  }
64
84
  exports.MapFileUtil = MapFileUtil;
65
85
  MapFileUtil.FILE_NOT_FOUND = 'Mapping File not found for id: ';
@@ -1,6 +1,13 @@
1
1
  import { TransformDefinition } from "../conditional";
2
+ export declare enum ProcessorKeys {
3
+ CONDITIONAL = "CONDITIONAL",
4
+ MORPH = "MORPH",
5
+ REKEY = "REKEY",
6
+ REMOVE = "REMOVE",
7
+ VALUE_TRANSFORM = "VALUE_TRANSFORM"
8
+ }
2
9
  export interface TransformTask {
3
- processor: 'CONDITIONAL' | 'MORPH' | 'REKEY' | 'REMOVE' | 'VALUE_TRANSFORM';
10
+ processor: ProcessorKeys;
4
11
  conditionalTransformDefinitions?: TransformDefinition[];
5
12
  functionTransformers?: Record<string, Function>;
6
13
  rekeyTransformers?: Record<string, string>;
@@ -1,2 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProcessorKeys = void 0;
4
+ var ProcessorKeys;
5
+ (function (ProcessorKeys) {
6
+ ProcessorKeys["CONDITIONAL"] = "CONDITIONAL";
7
+ ProcessorKeys["MORPH"] = "MORPH";
8
+ ProcessorKeys["REKEY"] = "REKEY";
9
+ ProcessorKeys["REMOVE"] = "REMOVE";
10
+ ProcessorKeys["VALUE_TRANSFORM"] = "VALUE_TRANSFORM";
11
+ })(ProcessorKeys = exports.ProcessorKeys || (exports.ProcessorKeys = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/transform-data",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Libraries for transforming data",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",