@forzalabs/remora 0.0.46-nasco.3 → 0.0.47-nasco.3

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.
package/Constants.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const CONSTANTS = {
4
- cliVersion: '0.0.46-nasco',
4
+ cliVersion: '0.0.47-nasco',
5
5
  lambdaVersion: 1,
6
6
  port: 5069,
7
7
  defaults: {
@@ -177,6 +177,10 @@
177
177
  "hidden": {
178
178
  "type": "boolean",
179
179
  "description": "If set, the field is kept and used during processing, but omitted when exporting the data"
180
+ },
181
+ "fixed": {
182
+ "type": "boolean",
183
+ "description": "If set, \"default\" must have a value. This field is not searched in the underlying dataset, but is a fixed value set by the \"default\" prop."
180
184
  }
181
185
  },
182
186
  "required": [
@@ -436,6 +440,10 @@
436
440
  "hidden": {
437
441
  "type": "boolean",
438
442
  "description": "If set, the field is kept and used during processing, but omitted when exporting the data"
443
+ },
444
+ "fixed": {
445
+ "type": "boolean",
446
+ "description": "If set, \"default\" must have a value. This field is not searched in the underlying dataset, but is a fixed value set by the \"default\" prop."
439
447
  }
440
448
  },
441
449
  "required": [
@@ -63,6 +63,7 @@ const XMLParser_1 = __importDefault(require("../engines/parsing/XMLParser")); //
63
63
  const Helper_1 = __importDefault(require("../helper/Helper"));
64
64
  const ParseHelper_1 = __importDefault(require("../engines/parsing/ParseHelper"));
65
65
  const FileExporter_1 = __importDefault(require("../engines/file/FileExporter"));
66
+ const Logger_1 = __importDefault(require("../helper/Logger"));
66
67
  class LocalSourceDriver {
67
68
  constructor() {
68
69
  this.init = (source) => __awaiter(this, void 0, void 0, function* () {
@@ -131,6 +132,7 @@ class LocalSourceDriver {
131
132
  const { fileKey } = file;
132
133
  if (fileKey.includes('%')) {
133
134
  const allFileKeys = this.listFiles(fileKey);
135
+ Logger_1.default.log(`Matched ${allFileKeys.length} files, copying to locally and creating unified dataset.`);
134
136
  // Copy files sequentially to avoid file conflicts
135
137
  for (let i = 0; i < allFileKeys.length; i++) {
136
138
  yield copyLocally(allFileKeys[i], i > 0); // Append mode for subsequent files
@@ -138,7 +138,7 @@ class ConsumerManagerClass {
138
138
  if (!column) {
139
139
  // If the consumer doesn't find the field in the producer but has a default value AND set_default onError
140
140
  // then instead of failing, create a placeholder column for the producer
141
- if (field.onError === 'set_default' && Algo_1.default.hasVal(field.default)) {
141
+ if (field.fixed === true && Algo_1.default.hasVal(field.default)) {
142
142
  column = {
143
143
  aliasInProducer: field.key,
144
144
  nameInProducer: (_a = field.alias) !== null && _a !== void 0 ? _a : field.key,
@@ -54,16 +54,8 @@ class PostProcessorClass {
54
54
  return newDataset;
55
55
  });
56
56
  this.updateDimensions = (dataset, consumer) => {
57
- const dimensions = dataset.getDimensions();
58
57
  const fields = ConsumerManager_1.default.getExpandedFields(consumer);
59
- for (const dim of dimensions) {
60
- // This dimension is wanted by the consumer, check if it needs renaming
61
- const consumerField = fields.find(x => x.cField.key === dim.name);
62
- if (consumerField) {
63
- const { cField: { key, alias, hidden } } = consumerField;
64
- dataset.updateDimension(key, { name: alias, hidden: hidden });
65
- }
66
- }
58
+ dataset.updateDimensions(fields);
67
59
  return dataset;
68
60
  };
69
61
  this.dropDimensions = (dataset, consumer) => __awaiter(this, void 0, void 0, function* () {
@@ -237,7 +229,9 @@ class PostProcessorClass {
237
229
  });
238
230
  this._getFieldValue = (record, field) => {
239
231
  var _a, _b, _c;
240
- const { key, alias } = field.cField;
232
+ const { key, alias, fixed, default: defaultValue } = field.cField;
233
+ if (fixed && Algo_1.default.hasVal(defaultValue))
234
+ return defaultValue;
241
235
  const fieldKey = alias !== null && alias !== void 0 ? alias : key;
242
236
  const fieldValue = record.getValue(fieldKey);
243
237
  if (Algo_1.default.hasVal(fieldValue) && !isNaN(fieldValue)) {
@@ -31,6 +31,7 @@ const Affirm_1 = __importDefault(require("../../core/Affirm"));
31
31
  const XMLParser_1 = __importDefault(require("../parsing/XMLParser"));
32
32
  const DriverFactory_1 = __importDefault(require("../../drivers/DriverFactory"));
33
33
  const Helper_1 = __importDefault(require("../../helper/Helper"));
34
+ const Algo_1 = __importDefault(require("../../core/Algo"));
34
35
  class Dataset {
35
36
  constructor(name, file, batchSize = Constants_1.default.defaults.MAX_ITEMS_IN_MEMORY) {
36
37
  this.getPath = () => this._path;
@@ -678,16 +679,28 @@ class Dataset {
678
679
  return this;
679
680
  });
680
681
  this.getDimensions = () => this._dimensions;
681
- this.updateDimension = (dimensionName, newValues) => {
682
- const dimension = this._dimensions.find(x => x.name === dimensionName);
683
- (0, Affirm_1.default)(dimension, `Trying to update the dataset dimension "${dimensionName}", but none was found (${this._dimensions.map(x => x.name).join(', ')})`);
684
- this._startOperation('update-dimension');
685
- const { hidden, name } = newValues;
686
- if (name && name.length > 0)
687
- dimension.name = name;
688
- if (hidden)
689
- dimension.hidden = hidden;
690
- this._finishOperation('update-dimension');
682
+ this.updateDimensions = (fields) => {
683
+ this._startOperation('update-dimensions');
684
+ for (const field of fields) {
685
+ const { cField: { key, alias, hidden, fixed, default: defaultValue } } = field;
686
+ const currentDim = this._dimensions.find(x => x.name === key);
687
+ if (currentDim) {
688
+ currentDim.name = alias !== null && alias !== void 0 ? alias : key;
689
+ currentDim.hidden = hidden;
690
+ }
691
+ else if (fixed && Algo_1.default.hasVal(defaultValue)) {
692
+ this._dimensions.push({
693
+ hidden: hidden,
694
+ index: this._dimensions.length,
695
+ key: key,
696
+ name: alias !== null && alias !== void 0 ? alias : key
697
+ });
698
+ }
699
+ else {
700
+ throw new Error(`Trying to update the dataset dimension "${(alias !== null && alias !== void 0 ? alias : key)}", but none was found (${this._dimensions.map(x => x.name).join(', ')})`);
701
+ }
702
+ }
703
+ this._finishOperation('update-dimensions');
691
704
  return this;
692
705
  };
693
706
  this.dropDimensions = (dimensionNames) => __awaiter(this, void 0, void 0, function* () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forzalabs/remora",
3
- "version": "0.0.46-nasco.3",
3
+ "version": "0.0.47-nasco.3",
4
4
  "description": "A powerful CLI tool for seamless data translation.",
5
5
  "main": "index.js",
6
6
  "private": false,