@forzalabs/remora 1.0.16 → 1.0.18
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
package/actions/init.js
CHANGED
|
@@ -64,10 +64,10 @@ const init = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
64
64
|
console.log(chalk_1.default.blue('• REMORA_WORKER_HOST') + chalk_1.default.gray(' → URL of your Remora Worker instance'));
|
|
65
65
|
console.log(chalk_1.default.blue('• REMORA_LICENCE_KEY') + chalk_1.default.gray(' → Your valid Remora license key'));
|
|
66
66
|
console.log(chalk_1.default.green('\n🔐 Production environment (store these in your Secret Manager):'));
|
|
67
|
-
console.log(chalk_1.default.yellow('•
|
|
67
|
+
console.log(chalk_1.default.yellow('• ROOT_TEMP_PASSWORD_FILE') + chalk_1.default.gray(' → Temporary root password for first-time setup'));
|
|
68
68
|
console.log(chalk_1.default.yellow('• INSTALLATION_ID') + chalk_1.default.gray(' → Unique ID for this installation instance'));
|
|
69
|
-
console.log(chalk_1.default.yellow('•
|
|
70
|
-
console.log(chalk_1.default.yellow('•
|
|
69
|
+
console.log(chalk_1.default.yellow('• ADMIN_JWT_SECRET_FILE') + chalk_1.default.gray(' → JWT secret for admin-level access'));
|
|
70
|
+
console.log(chalk_1.default.yellow('• JWT_SECRET_FILE') + chalk_1.default.gray(' → JWT secret for regular user authentication'));
|
|
71
71
|
}
|
|
72
72
|
catch (error) {
|
|
73
73
|
console.error(chalk_1.default.red('❌ Error during initialization:'), error instanceof Error ? error.message : String(error));
|
|
@@ -64,6 +64,8 @@ const Helper_1 = __importDefault(require("../../helper/Helper"));
|
|
|
64
64
|
const ParseHelper_1 = __importDefault(require("../../engines/parsing/ParseHelper"));
|
|
65
65
|
const Logger_1 = __importDefault(require("../../helper/Logger"));
|
|
66
66
|
const DriverHelper_1 = __importDefault(require("../DriverHelper"));
|
|
67
|
+
const ExecutorScope_1 = __importDefault(require("../../executors/ExecutorScope"));
|
|
68
|
+
const ParseCompression_1 = __importDefault(require("../../engines/parsing/ParseCompression"));
|
|
67
69
|
class LocalSourceDriver {
|
|
68
70
|
constructor() {
|
|
69
71
|
this.init = (source) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -376,18 +378,26 @@ class LocalSourceDriver {
|
|
|
376
378
|
};
|
|
377
379
|
this.ready = (request) => __awaiter(this, void 0, void 0, function* () {
|
|
378
380
|
(0, Affirm_1.default)(request, 'Invalid ready request');
|
|
379
|
-
const { producer } = request;
|
|
381
|
+
const { producer, scope } = request;
|
|
380
382
|
// TODO: extra logic for encoded files (xml, xls, ...) to be decoded and prepared locally as a plain CSV
|
|
381
383
|
// then return the uri to this new temporary file
|
|
382
|
-
const { fileKey } = producer.settings;
|
|
384
|
+
const { fileKey, compressionType } = producer.settings;
|
|
383
385
|
if (fileKey.includes('%')) {
|
|
384
386
|
const allFileKeys = this.listFiles(fileKey);
|
|
385
|
-
const allFilePaths =
|
|
387
|
+
const allFilePaths = [];
|
|
388
|
+
for (const fileKey of allFileKeys) {
|
|
389
|
+
const localPath = ExecutorScope_1.default.getProducerPath(scope, producer, fileKey);
|
|
390
|
+
ExecutorScope_1.default.ensurePath(localPath);
|
|
391
|
+
yield ParseCompression_1.default.decompressToFile(compressionType, fileKey, this._path, localPath);
|
|
392
|
+
allFilePaths.push(localPath);
|
|
393
|
+
}
|
|
386
394
|
return { files: allFilePaths.map(x => ({ fullUri: x })) };
|
|
387
395
|
}
|
|
388
396
|
else {
|
|
389
|
-
const
|
|
390
|
-
|
|
397
|
+
const localPath = ExecutorScope_1.default.getProducerPath(scope, producer, fileKey);
|
|
398
|
+
ExecutorScope_1.default.ensurePath(localPath);
|
|
399
|
+
yield ParseCompression_1.default.decompressToFile(compressionType, fileKey, this._path, localPath);
|
|
400
|
+
return { files: [{ fullUri: localPath }] };
|
|
391
401
|
}
|
|
392
402
|
});
|
|
393
403
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
const fs = __importStar(require("fs"));
|
|
49
|
+
const decompress_1 = __importDefault(require("decompress"));
|
|
50
|
+
const zlib_1 = __importDefault(require("zlib"));
|
|
51
|
+
const path_1 = __importDefault(require("path"));
|
|
52
|
+
const promises_1 = require("stream/promises");
|
|
53
|
+
class ParseCompressionClass {
|
|
54
|
+
constructor() {
|
|
55
|
+
this.decompressToFile = (compressionType, fileKey, standardPath, localPath) => __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
// Ensure the directory for the file exists
|
|
57
|
+
const fileDir = path_1.default.dirname(localPath);
|
|
58
|
+
if (!fs.existsSync(fileDir)) {
|
|
59
|
+
fs.mkdirSync(fileDir, { recursive: true });
|
|
60
|
+
}
|
|
61
|
+
switch (compressionType === null || compressionType === void 0 ? void 0 : compressionType.toUpperCase()) {
|
|
62
|
+
case 'ZIP':
|
|
63
|
+
case 'TAR':
|
|
64
|
+
yield (0, decompress_1.default)(path_1.default.join(standardPath, fileKey), localPath);
|
|
65
|
+
break;
|
|
66
|
+
case 'GZIP':
|
|
67
|
+
yield this._gzipFile(fileKey, standardPath, localPath);
|
|
68
|
+
break;
|
|
69
|
+
case null:
|
|
70
|
+
case undefined:
|
|
71
|
+
// No decompression needed for request
|
|
72
|
+
break;
|
|
73
|
+
default:
|
|
74
|
+
// throw an error if the request ask for an unsupported compression type
|
|
75
|
+
throw new Error(`this compression type it has not been implemented ${compressionType}`);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
this._gzipFile = (fileKey, standardPath, localPath) => __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
const fileContents = fs.createReadStream(path_1.default.join(standardPath, fileKey));
|
|
80
|
+
const unzip = zlib_1.default.createGunzip();
|
|
81
|
+
const writeStream = fs.createWriteStream(localPath);
|
|
82
|
+
yield (0, promises_1.pipeline)(fileContents, unzip, writeStream);
|
|
83
|
+
});
|
|
84
|
+
// TODO add a decompression method fo tarball (.tar.gz)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const ParseCompression = new ParseCompressionClass();
|
|
88
|
+
exports.default = ParseCompression;
|
|
@@ -155,7 +155,9 @@ class ConsumerExecutorClass {
|
|
|
155
155
|
reader.destroy();
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
|
-
|
|
158
|
+
// Delete original file first to avoid EPERM on Windows
|
|
159
|
+
yield promises_1.default.unlink(datasetPath);
|
|
160
|
+
yield promises_1.default.rename(tempWorkPath, datasetPath);
|
|
159
161
|
return newLineCount;
|
|
160
162
|
});
|
|
161
163
|
this.processDistinctOn = (consumer, datasetPath) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -217,7 +219,9 @@ class ConsumerExecutorClass {
|
|
|
217
219
|
reader.destroy();
|
|
218
220
|
});
|
|
219
221
|
}
|
|
220
|
-
|
|
222
|
+
// Delete original file first to avoid EPERM on Windows
|
|
223
|
+
yield promises_1.default.unlink(datasetPath);
|
|
224
|
+
yield promises_1.default.rename(tempWorkPath, datasetPath);
|
|
221
225
|
return winners.size;
|
|
222
226
|
});
|
|
223
227
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forzalabs/remora",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.18",
|
|
4
4
|
"description": "A powerful CLI tool for seamless data translation.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"private": false,
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"commander": "^10.0.0",
|
|
47
47
|
"cross-env": "^7.0.3",
|
|
48
48
|
"dayjs": "^1.11.13",
|
|
49
|
+
"decompress": "^4.2.1",
|
|
49
50
|
"dotenv": "^16.0.3",
|
|
50
51
|
"fast-xml-parser": "^5.2.3",
|
|
51
52
|
"fs-extra": "^11.1.0",
|