@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.
|
@@ -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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
|
|
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
|
}
|