@forzalabs/remora 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.
@@ -409,8 +409,7 @@
409
409
  "name",
410
410
  "producers",
411
411
  "fields",
412
- "outputs",
413
- "_version"
412
+ "outputs"
414
413
  ],
415
414
  "additionalProperties": false,
416
415
  "definitions": {
@@ -174,8 +174,7 @@
174
174
  "name",
175
175
  "source",
176
176
  "dimensions",
177
- "settings",
178
- "_version"
177
+ "settings"
179
178
  ],
180
179
  "additionalProperties": false,
181
180
  "examples": [
@@ -170,8 +170,7 @@
170
170
  "required": [
171
171
  "name",
172
172
  "engine",
173
- "authentication",
174
- "_version"
173
+ "authentication"
175
174
  ],
176
175
  "additionalProperties": false,
177
176
  "examples": [
@@ -71,13 +71,13 @@ class ConsumerExecutorClass {
71
71
  return fs_1.default.createWriteStream(workPath);
72
72
  };
73
73
  this.processRecord = (options) => {
74
- var _a;
74
+ var _a, _b;
75
75
  const { consumer, fields, dimensions, producer, record, requestOptions } = options;
76
- // map to consumer fields and apply consumer field logic
76
+ // Map to consumer fields and apply consumer field logic
77
77
  for (const field of fields) {
78
78
  const { cField } = field;
79
79
  const fieldKey = (_a = cField.alias) !== null && _a !== void 0 ? _a : cField.key;
80
- // set the fixed default value for the field, or throw error if not present in the producer
80
+ // Set the fixed default value for the field, or throw error if not present in the producer
81
81
  const dimension = dimensions.find(x => x.name === cField.key);
82
82
  if (!dimension) {
83
83
  if (cField.fixed && Algo_1.default.hasVal(cField.default))
@@ -85,12 +85,16 @@ class ConsumerExecutorClass {
85
85
  else
86
86
  throw new Error(`The requested field "${cField.key}" from the consumer is not present in the underlying producer "${producer.name}" (${dimensions.map(x => x.name).join(', ')})`);
87
87
  }
88
- // change the name of the dimension
88
+ // Change the name of the dimension
89
89
  if (cField.alias && cField.alias !== dimension.name) {
90
90
  record[cField.alias] = record[dimension.name];
91
91
  delete record[dimension.name];
92
92
  }
93
- // apply transformations
93
+ }
94
+ // Transformations need to be applied after the mapping since they might refer to other fields with their new names
95
+ for (const field of fields) {
96
+ const { cField } = field;
97
+ const fieldKey = (_b = cField.alias) !== null && _b !== void 0 ? _b : cField.key;
94
98
  if (cField.transform)
95
99
  record[fieldKey] = TransformationEngine_1.default.applyTransformations(record[fieldKey], cField.transform, cField, record);
96
100
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forzalabs/remora",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "A powerful CLI tool for seamless data translation.",
5
5
  "main": "index.js",
6
6
  "private": false,