@forzalabs/remora 1.0.14 → 1.0.15

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.
@@ -15,7 +15,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const mongodb_1 = require("mongodb");
16
16
  const Helper_1 = __importDefault(require("../helper/Helper"));
17
17
  const Settings_1 = __importDefault(require("../helper/Settings"));
18
- const Affirm_1 = __importDefault(require("../core/Affirm"));
19
18
  class DatabaseEngineClass {
20
19
  constructor() {
21
20
  this.MAX_TRY_CONNECTION = 3;
@@ -23,15 +22,16 @@ class DatabaseEngineClass {
23
22
  this.connect = () => __awaiter(this, void 0, void 0, function* () {
24
23
  // WARNING: this was changed during the deployment to ECS...
25
24
  // I've reverted it, but maybe it needs to be changed or looked into...
26
- (0, Affirm_1.default)(process.env.MONGO_USERNAME, 'No environment setting found for MONGO_USERNAME');
27
- (0, Affirm_1.default)(process.env.MONGO_PASSWORD_FILE, 'No environment setting found for MONGO_PASSWORD');
28
- const mongoUri = 'mongodb://' + process.env.MONGO_USERNAME + ':' + process.env.MONGO_PASSWORD + '@mongo:27017';
29
- this._uri = Helper_1.default.isDev() ? 'mongodb://mongo:27017/remora' : mongoUri;
25
+ var _a;
26
+ this._uri = ((_a = process.env.MONGO_URI) !== null && _a !== void 0 ? _a : Helper_1.default.isDev())
27
+ ? 'mongodb://mongo:27017/remora'
28
+ : 'mongodb://localhost:27017/remora';
29
+ this._client = new mongodb_1.MongoClient(this._uri);
30
30
  const errors = [];
31
31
  this._client = new mongodb_1.MongoClient(this._uri);
32
32
  for (let i = 0; i < this.MAX_TRY_CONNECTION; i++) {
33
33
  try {
34
- console.log(`Attempting to connect to mongo`);
34
+ console.log(`Attempting to connect to mongo "${this._uri}`);
35
35
  yield this._client.connect();
36
36
  this._db = this._client.db(Settings_1.default.db.name);
37
37
  this._connected = true;
@@ -45,7 +45,7 @@ class EnvironmentClass {
45
45
  }
46
46
  }
47
47
  catch (error) {
48
- throw new Error(`Error loading configuration from ${configPath}: ${error.message}`);
48
+ throw new Error(`Error loading from ${path_1.default.resolve(remoraPath)} configuration from ${configPath}: ${error.message}`);
49
49
  }
50
50
  }
51
51
  return configs;
@@ -141,14 +141,18 @@ class ConsumerExecutorClass {
141
141
  }
142
142
  finally { if (e_1) throw e_1.error; }
143
143
  }
144
- writer.close();
145
- reader.close();
144
+ lineReader.close();
146
145
  // Wait for the writer to finish before renaming
147
146
  yield new Promise((resolve, reject) => {
148
- writer.on('finish', resolve);
147
+ writer.on('close', resolve);
149
148
  writer.on('error', reject);
150
149
  writer.end();
151
150
  });
151
+ // Ensure the reader is fully closed before renaming
152
+ yield new Promise(resolve => {
153
+ reader.once('close', resolve);
154
+ reader.destroy();
155
+ });
152
156
  fs_1.default.renameSync(tempWorkPath, datasetPath);
153
157
  return newLineCount;
154
158
  });
@@ -191,7 +195,7 @@ class ConsumerExecutorClass {
191
195
  }
192
196
  finally { if (e_2) throw e_2.error; }
193
197
  }
194
- reader.close();
198
+ lineReader.close();
195
199
  // Write the winning records to the temp file
196
200
  const tempWorkPath = datasetPath + '_tmp';
197
201
  const writer = fs_1.default.createWriteStream(tempWorkPath);
@@ -200,10 +204,15 @@ class ConsumerExecutorClass {
200
204
  }
201
205
  // Wait for the writer to finish before renaming
202
206
  yield new Promise((resolve, reject) => {
203
- writer.on('finish', resolve);
207
+ writer.on('close', resolve);
204
208
  writer.on('error', reject);
205
209
  writer.end();
206
210
  });
211
+ // Ensure the reader is fully closed before renaming
212
+ yield new Promise(resolve => {
213
+ reader.once('close', resolve);
214
+ reader.destroy();
215
+ });
207
216
  fs_1.default.renameSync(tempWorkPath, datasetPath);
208
217
  return winners.size;
209
218
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forzalabs/remora",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
4
4
  "description": "A powerful CLI tool for seamless data translation.",
5
5
  "main": "index.js",
6
6
  "private": false,