@contrail/transform-data 1.1.3 → 1.1.4

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 (35) hide show
  1. package/README.md +3 -3
  2. package/lib/conditional/conditional-transformer.d.ts +16 -16
  3. package/lib/conditional/conditional-transformer.js +78 -78
  4. package/lib/conditional/index.d.ts +1 -1
  5. package/lib/conditional/index.js +17 -17
  6. package/lib/index.d.ts +7 -7
  7. package/lib/index.js +23 -23
  8. package/lib/map-file/index.d.ts +1 -1
  9. package/lib/map-file/index.js +17 -17
  10. package/lib/map-file/map-file-util-spec-mockData.js +208 -208
  11. package/lib/map-file/map-file-util.d.ts +18 -18
  12. package/lib/map-file/map-file-util.js +135 -135
  13. package/lib/morph/index.d.ts +1 -1
  14. package/lib/morph/index.js +17 -17
  15. package/lib/morph/morph-transformer.d.ts +4 -4
  16. package/lib/morph/morph-transformer.js +16 -16
  17. package/lib/processor/index.d.ts +2 -2
  18. package/lib/processor/index.js +18 -18
  19. package/lib/processor/process-interfaces.d.ts +18 -18
  20. package/lib/processor/process-interfaces.js +11 -11
  21. package/lib/processor/transform-processor.d.ts +4 -4
  22. package/lib/processor/transform-processor.js +33 -33
  23. package/lib/rekey/index.d.ts +1 -1
  24. package/lib/rekey/index.js +17 -17
  25. package/lib/rekey/rekey-transformer.d.ts +4 -4
  26. package/lib/rekey/rekey-transformer.js +26 -26
  27. package/lib/remove/index.d.ts +1 -1
  28. package/lib/remove/index.js +17 -17
  29. package/lib/remove/remove-transformer.d.ts +4 -4
  30. package/lib/remove/remove-transformer.js +16 -16
  31. package/lib/value-function/index.d.ts +1 -1
  32. package/lib/value-function/index.js +17 -17
  33. package/lib/value-function/value-function-transformer.d.ts +4 -4
  34. package/lib/value-function/value-function-transformer.js +16 -16
  35. package/package.json +53 -53
@@ -1,135 +1,135 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MapFileUtil = void 0;
4
- const processor_1 = require("../processor");
5
- class MapFileUtil {
6
- constructor(entities, useStaticCache = true) {
7
- this.entities = entities;
8
- if (!useStaticCache) {
9
- this.instanceCache = {};
10
- }
11
- }
12
- getCache() {
13
- return this.instanceCache || MapFileUtil.STATIC_CACHE;
14
- }
15
- clearCache() {
16
- if (this.instanceCache) {
17
- this.instanceCache = {};
18
- }
19
- else {
20
- MapFileUtil.STATIC_CACHE = {};
21
- }
22
- }
23
- async getMapFile(fileId) {
24
- if (!fileId) {
25
- return {};
26
- }
27
- const cache = this.getCache();
28
- if (cache[fileId]) {
29
- return cache[fileId];
30
- }
31
- const options = {
32
- entityName: 'file',
33
- id: fileId,
34
- };
35
- const file = await this.entities.get(options);
36
- if (!file) {
37
- throw new Error(MapFileUtil.FILE_NOT_FOUND + fileId);
38
- }
39
- let mappingFile = {};
40
- try {
41
- const downloadUrl = file['downloadUrl'];
42
- const contentType = '' + file['contentType'];
43
- if (contentType && contentType.toLowerCase().indexOf('json') > -1) {
44
- const response = await fetch(downloadUrl);
45
- mappingFile = await response.json();
46
- }
47
- else {
48
- const requireFromUrl = require('require-from-url/sync');
49
- const maps = requireFromUrl(downloadUrl);
50
- mappingFile = maps['mapping'];
51
- }
52
- }
53
- catch (e) {
54
- throw new Error(MapFileUtil.ERROR_RETRIEVING + e);
55
- }
56
- cache[fileId] = mappingFile;
57
- return mappingFile;
58
- }
59
- getMappingSectionFromMap(mapFile, mapSectionKey, direction) {
60
- let mapping = {};
61
- if (mapFile[mapSectionKey]) {
62
- const classMapping = mapFile[mapSectionKey];
63
- if (classMapping[direction]) {
64
- mapping = classMapping[direction];
65
- }
66
- }
67
- return mapping;
68
- }
69
- async getFullMapSection(transformMapFile, mapSectionKey) {
70
- if (mapSectionKey) {
71
- const mapFile = await this.getMapFile(transformMapFile);
72
- if (mapFile) {
73
- const mapSection = mapFile[mapSectionKey];
74
- return mapSection;
75
- }
76
- }
77
- return undefined;
78
- }
79
- async getMappingSection(fileId, mapSectionKey, direction) {
80
- const map = await this.getMapFile(fileId);
81
- const directional = this.getMappingSectionFromMap(map, mapSectionKey, direction);
82
- return directional;
83
- }
84
- async getMapKey(fileId, data, type, direction) {
85
- const mappingData = await this.getMappingSection(fileId, 'typeConversion', direction);
86
- if (mappingData && mappingData[type] && mappingData[type]['getMapKey']) {
87
- const mapKey = await mappingData[type]['getMapKey'](data);
88
- return mapKey;
89
- }
90
- return undefined;
91
- }
92
- static getTransformTasks(directionalMapSection, orderKey = 'transformOrder') {
93
- const tasks = [];
94
- const order = directionalMapSection[orderKey];
95
- if (order) {
96
- for (const step of order) {
97
- const task = {
98
- processor: step['processor'],
99
- rekeyDelete: step['rekeyDelete'],
100
- rekeyKeepMissingValues: step['rekeyKeepMissingValues'],
101
- };
102
- for (const mapping of [
103
- 'conditionalTransformDefinitions',
104
- 'functionTransformers',
105
- 'rekeyTransformers',
106
- 'removeKeys',
107
- ]) {
108
- const mapKey = step[mapping + 'Key'];
109
- if (mapKey) {
110
- task[mapping] = directionalMapSection[mapKey];
111
- }
112
- }
113
- tasks.push(task);
114
- }
115
- }
116
- return tasks;
117
- }
118
- async applyTransformMap(fileId, data, mapSectionKey, direction, transformTaskOrderKey) {
119
- if (fileId && data) {
120
- const mapping = await this.getMappingSection(fileId, mapSectionKey, direction);
121
- if (mapping) {
122
- const tasks = MapFileUtil.getTransformTasks(mapping, transformTaskOrderKey);
123
- if (tasks.length > 0) {
124
- const convertedArray = processor_1.TransformProcessor.transformData([data], tasks);
125
- data = convertedArray[0];
126
- }
127
- }
128
- }
129
- return data;
130
- }
131
- }
132
- exports.MapFileUtil = MapFileUtil;
133
- MapFileUtil.STATIC_CACHE = {};
134
- MapFileUtil.FILE_NOT_FOUND = 'Mapping File not found for id: ';
135
- MapFileUtil.ERROR_RETRIEVING = 'Error getting mapping file: ';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MapFileUtil = void 0;
4
+ const processor_1 = require("../processor");
5
+ class MapFileUtil {
6
+ constructor(entities, useStaticCache = true) {
7
+ this.entities = entities;
8
+ if (!useStaticCache) {
9
+ this.instanceCache = {};
10
+ }
11
+ }
12
+ getCache() {
13
+ return this.instanceCache || MapFileUtil.STATIC_CACHE;
14
+ }
15
+ clearCache() {
16
+ if (this.instanceCache) {
17
+ this.instanceCache = {};
18
+ }
19
+ else {
20
+ MapFileUtil.STATIC_CACHE = {};
21
+ }
22
+ }
23
+ async getMapFile(fileId) {
24
+ if (!fileId) {
25
+ return {};
26
+ }
27
+ const cache = this.getCache();
28
+ if (cache[fileId]) {
29
+ return cache[fileId];
30
+ }
31
+ const options = {
32
+ entityName: 'file',
33
+ id: fileId,
34
+ };
35
+ const file = await this.entities.get(options);
36
+ if (!file) {
37
+ throw new Error(MapFileUtil.FILE_NOT_FOUND + fileId);
38
+ }
39
+ let mappingFile = {};
40
+ try {
41
+ const downloadUrl = file['downloadUrl'];
42
+ const contentType = '' + file['contentType'];
43
+ if (contentType && contentType.toLowerCase().indexOf('json') > -1) {
44
+ const response = await fetch(downloadUrl);
45
+ mappingFile = await response.json();
46
+ }
47
+ else {
48
+ const requireFromUrl = require('require-from-url/sync');
49
+ const maps = requireFromUrl(downloadUrl);
50
+ mappingFile = maps['mapping'];
51
+ }
52
+ }
53
+ catch (e) {
54
+ throw new Error(MapFileUtil.ERROR_RETRIEVING + e);
55
+ }
56
+ cache[fileId] = mappingFile;
57
+ return mappingFile;
58
+ }
59
+ getMappingSectionFromMap(mapFile, mapSectionKey, direction) {
60
+ let mapping = {};
61
+ if (mapFile[mapSectionKey]) {
62
+ const classMapping = mapFile[mapSectionKey];
63
+ if (classMapping[direction]) {
64
+ mapping = classMapping[direction];
65
+ }
66
+ }
67
+ return mapping;
68
+ }
69
+ async getFullMapSection(transformMapFile, mapSectionKey) {
70
+ if (mapSectionKey) {
71
+ const mapFile = await this.getMapFile(transformMapFile);
72
+ if (mapFile) {
73
+ const mapSection = mapFile[mapSectionKey];
74
+ return mapSection;
75
+ }
76
+ }
77
+ return undefined;
78
+ }
79
+ async getMappingSection(fileId, mapSectionKey, direction) {
80
+ const map = await this.getMapFile(fileId);
81
+ const directional = this.getMappingSectionFromMap(map, mapSectionKey, direction);
82
+ return directional;
83
+ }
84
+ async getMapKey(fileId, data, type, direction) {
85
+ const mappingData = await this.getMappingSection(fileId, 'typeConversion', direction);
86
+ if (mappingData && mappingData[type] && mappingData[type]['getMapKey']) {
87
+ const mapKey = await mappingData[type]['getMapKey'](data);
88
+ return mapKey;
89
+ }
90
+ return undefined;
91
+ }
92
+ static getTransformTasks(directionalMapSection, orderKey = 'transformOrder') {
93
+ const tasks = [];
94
+ const order = directionalMapSection[orderKey];
95
+ if (order) {
96
+ for (const step of order) {
97
+ const task = {
98
+ processor: step['processor'],
99
+ rekeyDelete: step['rekeyDelete'],
100
+ rekeyKeepMissingValues: step['rekeyKeepMissingValues'],
101
+ };
102
+ for (const mapping of [
103
+ 'conditionalTransformDefinitions',
104
+ 'functionTransformers',
105
+ 'rekeyTransformers',
106
+ 'removeKeys',
107
+ ]) {
108
+ const mapKey = step[mapping + 'Key'];
109
+ if (mapKey) {
110
+ task[mapping] = directionalMapSection[mapKey];
111
+ }
112
+ }
113
+ tasks.push(task);
114
+ }
115
+ }
116
+ return tasks;
117
+ }
118
+ async applyTransformMap(fileId, data, mapSectionKey, direction, transformTaskOrderKey) {
119
+ if (fileId && data) {
120
+ const mapping = await this.getMappingSection(fileId, mapSectionKey, direction);
121
+ if (mapping) {
122
+ const tasks = MapFileUtil.getTransformTasks(mapping, transformTaskOrderKey);
123
+ if (tasks.length > 0) {
124
+ const convertedArray = processor_1.TransformProcessor.transformData([data], tasks);
125
+ data = convertedArray[0];
126
+ }
127
+ }
128
+ }
129
+ return data;
130
+ }
131
+ }
132
+ exports.MapFileUtil = MapFileUtil;
133
+ MapFileUtil.STATIC_CACHE = {};
134
+ MapFileUtil.FILE_NOT_FOUND = 'Mapping File not found for id: ';
135
+ MapFileUtil.ERROR_RETRIEVING = 'Error getting mapping file: ';
@@ -1 +1 @@
1
- export * from './morph-transformer';
1
+ export * from './morph-transformer';
@@ -1,17 +1,17 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./morph-transformer"), exports);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./morph-transformer"), exports);
@@ -1,4 +1,4 @@
1
- export declare class MorphTransformer {
2
- static transformData(rows: any[], transformFunctions: Record<string, Function>, dependencies: Record<string, any>): void;
3
- static transformObject(row: any, transformFunctions: Record<string, Function>, dependencies: Record<string, any>): void;
4
- }
1
+ export declare class MorphTransformer {
2
+ static transformData(rows: any[], transformFunctions: Record<string, Function>, dependencies: Record<string, any>): void;
3
+ static transformObject(row: any, transformFunctions: Record<string, Function>, dependencies: Record<string, any>): void;
4
+ }
@@ -1,16 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MorphTransformer = void 0;
4
- class MorphTransformer {
5
- static transformData(rows, transformFunctions, dependencies) {
6
- for (const row of rows) {
7
- MorphTransformer.transformObject(row, transformFunctions, dependencies);
8
- }
9
- }
10
- static transformObject(row, transformFunctions, dependencies) {
11
- for (const [key, fun] of Object.entries(transformFunctions)) {
12
- fun(row, dependencies);
13
- }
14
- }
15
- }
16
- exports.MorphTransformer = MorphTransformer;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MorphTransformer = void 0;
4
+ class MorphTransformer {
5
+ static transformData(rows, transformFunctions, dependencies) {
6
+ for (const row of rows) {
7
+ MorphTransformer.transformObject(row, transformFunctions, dependencies);
8
+ }
9
+ }
10
+ static transformObject(row, transformFunctions, dependencies) {
11
+ for (const [key, fun] of Object.entries(transformFunctions)) {
12
+ fun(row, dependencies);
13
+ }
14
+ }
15
+ }
16
+ exports.MorphTransformer = MorphTransformer;
@@ -1,2 +1,2 @@
1
- export * from './process-interfaces';
2
- export * from './transform-processor';
1
+ export * from './process-interfaces';
2
+ export * from './transform-processor';
@@ -1,18 +1,18 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./process-interfaces"), exports);
18
- __exportStar(require("./transform-processor"), exports);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./process-interfaces"), exports);
18
+ __exportStar(require("./transform-processor"), exports);
@@ -1,18 +1,18 @@
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
- }
9
- export interface TransformTask {
10
- processor: ProcessorKeys;
11
- conditionalTransformDefinitions?: TransformDefinition[];
12
- functionTransformers?: Record<string, Function>;
13
- rekeyTransformers?: Record<string, string>;
14
- rekeyDelete?: boolean;
15
- rekeyKeepMissingValues?: boolean;
16
- removeKeys?: string[];
17
- dependencies?: object;
18
- }
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
+ }
9
+ export interface TransformTask {
10
+ processor: ProcessorKeys;
11
+ conditionalTransformDefinitions?: TransformDefinition[];
12
+ functionTransformers?: Record<string, Function>;
13
+ rekeyTransformers?: Record<string, string>;
14
+ rekeyDelete?: boolean;
15
+ rekeyKeepMissingValues?: boolean;
16
+ removeKeys?: string[];
17
+ dependencies?: object;
18
+ }
@@ -1,11 +1,11 @@
1
- "use strict";
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 = {}));
1
+ "use strict";
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 = {}));
@@ -1,4 +1,4 @@
1
- import { TransformTask } from './process-interfaces';
2
- export declare class TransformProcessor {
3
- static transformData(rows: any[], transformTasks: TransformTask[]): any[];
4
- }
1
+ import { TransformTask } from './process-interfaces';
2
+ export declare class TransformProcessor {
3
+ static transformData(rows: any[], transformTasks: TransformTask[]): any[];
4
+ }
@@ -1,33 +1,33 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TransformProcessor = void 0;
4
- const conditional_1 = require("../conditional");
5
- const morph_transformer_1 = require("../morph/morph-transformer");
6
- const rekey_1 = require("../rekey");
7
- const remove_1 = require("../remove");
8
- const value_function_1 = require("../value-function");
9
- class TransformProcessor {
10
- static transformData(rows, transformTasks) {
11
- for (const transformTask of transformTasks) {
12
- switch (transformTask.processor) {
13
- case 'CONDITIONAL':
14
- conditional_1.ConditionalTransformer.evaluateTransformDefinitionsOnBatch(transformTask.conditionalTransformDefinitions, rows);
15
- break;
16
- case 'MORPH':
17
- morph_transformer_1.MorphTransformer.transformData(rows, transformTask.functionTransformers, transformTask.dependencies);
18
- break;
19
- case 'REKEY':
20
- rekey_1.RekeyTransformer.transformData(rows, transformTask.rekeyTransformers, transformTask.rekeyDelete, transformTask.rekeyKeepMissingValues);
21
- break;
22
- case 'REMOVE':
23
- remove_1.RemoveTransformer.transformData(rows, transformTask.removeKeys);
24
- break;
25
- case 'VALUE_TRANSFORM':
26
- value_function_1.ValueFunctionTransformer.transformData(rows, transformTask.functionTransformers, transformTask.dependencies);
27
- break;
28
- }
29
- }
30
- return rows;
31
- }
32
- }
33
- exports.TransformProcessor = TransformProcessor;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TransformProcessor = void 0;
4
+ const conditional_1 = require("../conditional");
5
+ const morph_transformer_1 = require("../morph/morph-transformer");
6
+ const rekey_1 = require("../rekey");
7
+ const remove_1 = require("../remove");
8
+ const value_function_1 = require("../value-function");
9
+ class TransformProcessor {
10
+ static transformData(rows, transformTasks) {
11
+ for (const transformTask of transformTasks) {
12
+ switch (transformTask.processor) {
13
+ case 'CONDITIONAL':
14
+ conditional_1.ConditionalTransformer.evaluateTransformDefinitionsOnBatch(transformTask.conditionalTransformDefinitions, rows);
15
+ break;
16
+ case 'MORPH':
17
+ morph_transformer_1.MorphTransformer.transformData(rows, transformTask.functionTransformers, transformTask.dependencies);
18
+ break;
19
+ case 'REKEY':
20
+ rekey_1.RekeyTransformer.transformData(rows, transformTask.rekeyTransformers, transformTask.rekeyDelete, transformTask.rekeyKeepMissingValues);
21
+ break;
22
+ case 'REMOVE':
23
+ remove_1.RemoveTransformer.transformData(rows, transformTask.removeKeys);
24
+ break;
25
+ case 'VALUE_TRANSFORM':
26
+ value_function_1.ValueFunctionTransformer.transformData(rows, transformTask.functionTransformers, transformTask.dependencies);
27
+ break;
28
+ }
29
+ }
30
+ return rows;
31
+ }
32
+ }
33
+ exports.TransformProcessor = TransformProcessor;
@@ -1 +1 @@
1
- export * from './rekey-transformer';
1
+ export * from './rekey-transformer';
@@ -1,17 +1,17 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./rekey-transformer"), exports);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./rekey-transformer"), exports);
@@ -1,4 +1,4 @@
1
- export declare class RekeyTransformer {
2
- static transformData(csvJSON: any[], federatedMappings: Record<string, string>, deleteOldKey?: boolean, rekeyKeepMissingValues?: boolean): void;
3
- static transformObject(row: any, federatedMappings: Record<string, string>, deleteOldKey?: boolean, rekeyKeepMissingValues?: boolean): void;
4
- }
1
+ export declare class RekeyTransformer {
2
+ static transformData(csvJSON: any[], federatedMappings: Record<string, string>, deleteOldKey?: boolean, rekeyKeepMissingValues?: boolean): void;
3
+ static transformObject(row: any, federatedMappings: Record<string, string>, deleteOldKey?: boolean, rekeyKeepMissingValues?: boolean): void;
4
+ }
@@ -1,26 +1,26 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RekeyTransformer = void 0;
4
- class RekeyTransformer {
5
- static transformData(csvJSON, federatedMappings, deleteOldKey = false, rekeyKeepMissingValues = false) {
6
- for (const row of csvJSON) {
7
- RekeyTransformer.transformObject(row, federatedMappings, deleteOldKey, rekeyKeepMissingValues);
8
- }
9
- }
10
- static transformObject(row, federatedMappings, deleteOldKey = false, rekeyKeepMissingValues = false) {
11
- const keys = Object.keys(row);
12
- for (const [newKey, oldKey] of Object.entries(federatedMappings)) {
13
- if (!row[newKey]) {
14
- if (rekeyKeepMissingValues || keys.includes(oldKey)) {
15
- row[newKey] = row[oldKey];
16
- }
17
- }
18
- }
19
- if (deleteOldKey) {
20
- for (const oldKey of Object.values(federatedMappings)) {
21
- delete row[oldKey];
22
- }
23
- }
24
- }
25
- }
26
- exports.RekeyTransformer = RekeyTransformer;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RekeyTransformer = void 0;
4
+ class RekeyTransformer {
5
+ static transformData(csvJSON, federatedMappings, deleteOldKey = false, rekeyKeepMissingValues = false) {
6
+ for (const row of csvJSON) {
7
+ RekeyTransformer.transformObject(row, federatedMappings, deleteOldKey, rekeyKeepMissingValues);
8
+ }
9
+ }
10
+ static transformObject(row, federatedMappings, deleteOldKey = false, rekeyKeepMissingValues = false) {
11
+ const keys = Object.keys(row);
12
+ for (const [newKey, oldKey] of Object.entries(federatedMappings)) {
13
+ if (!row[newKey]) {
14
+ if (rekeyKeepMissingValues || keys.includes(oldKey)) {
15
+ row[newKey] = row[oldKey];
16
+ }
17
+ }
18
+ }
19
+ if (deleteOldKey) {
20
+ for (const oldKey of Object.values(federatedMappings)) {
21
+ delete row[oldKey];
22
+ }
23
+ }
24
+ }
25
+ }
26
+ exports.RekeyTransformer = RekeyTransformer;
@@ -1 +1 @@
1
- export * from './remove-transformer';
1
+ export * from './remove-transformer';