@forzalabs/remora 1.0.21 → 1.1.1
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/actions/automap.js +26 -42
- package/actions/compile.js +27 -43
- package/actions/create_consumer.js +24 -40
- package/actions/create_producer.js +16 -32
- package/actions/debug.js +18 -34
- package/actions/deploy.js +30 -46
- package/actions/discover.js +13 -29
- package/actions/init.js +29 -45
- package/actions/mock.js +16 -32
- package/actions/run.js +34 -52
- package/actions/sample.js +42 -58
- package/index.js +38 -43
- package/package.json +4 -4
- package/workers/ExecutorWorker.js +18 -32
- package/Constants.js +0 -34
- package/core/Affirm.js +0 -42
- package/core/Algo.js +0 -160
- package/core/dste/DSTE.js +0 -113
- package/core/logger/DebugLogService.js +0 -48
- package/core/logger/DevelopmentLogService.js +0 -70
- package/core/logger/LocalLogService.js +0 -70
- package/core/logger/Logger.js +0 -54
- package/database/DatabaseEngine.js +0 -149
- package/database/DatabaseStructure.js +0 -27
- package/definitions/DatasetDefinitions.js +0 -2
- package/definitions/ExecutorDefinitions.js +0 -2
- package/definitions/ProcessENV.js +0 -2
- package/definitions/agents/DestinationDriver.js +0 -2
- package/definitions/agents/SourceDriver.js +0 -2
- package/definitions/cli.js +0 -2
- package/definitions/database/ApiKeys.js +0 -2
- package/definitions/database/Stored.js +0 -7
- package/definitions/database/UsageStat.js +0 -2
- package/definitions/database/User.js +0 -2
- package/definitions/json_schemas/consumer-schema.json +0 -1226
- package/definitions/json_schemas/producer-schema.json +0 -308
- package/definitions/json_schemas/project-schema.json +0 -100
- package/definitions/json_schemas/source-schema.json +0 -249
- package/definitions/requests/ConsumerRequest.js +0 -2
- package/definitions/requests/Developer.js +0 -2
- package/definitions/requests/Mapping.js +0 -2
- package/definitions/requests/ProducerRequest.js +0 -2
- package/definitions/requests/Request.js +0 -2
- package/definitions/resources/Compiled.js +0 -2
- package/definitions/resources/Consumer.js +0 -2
- package/definitions/resources/Environment.js +0 -2
- package/definitions/resources/Library.js +0 -2
- package/definitions/resources/Producer.js +0 -2
- package/definitions/resources/Project.js +0 -2
- package/definitions/resources/Schema.js +0 -2
- package/definitions/resources/Source.js +0 -2
- package/definitions/temp.js +0 -2
- package/definitions/transform/Transformations.js +0 -2
- package/drivers/DeltaShareDriver.js +0 -186
- package/drivers/DriverFactory.js +0 -72
- package/drivers/DriverHelper.js +0 -248
- package/drivers/HttpApiDriver.js +0 -208
- package/drivers/RedshiftDriver.js +0 -184
- package/drivers/files/LocalDestinationDriver.js +0 -146
- package/drivers/files/LocalSourceDriver.js +0 -405
- package/drivers/s3/S3DestinationDriver.js +0 -197
- package/drivers/s3/S3SourceDriver.js +0 -495
- package/engines/CryptoEngine.js +0 -75
- package/engines/Environment.js +0 -170
- package/engines/ProcessENVManager.js +0 -83
- package/engines/RandomEngine.js +0 -47
- package/engines/SecretManager.js +0 -23
- package/engines/UserManager.js +0 -66
- package/engines/ai/AutoMapperEngine.js +0 -37
- package/engines/ai/DeveloperEngine.js +0 -497
- package/engines/ai/LLM.js +0 -255
- package/engines/consumer/ConsumerManager.js +0 -218
- package/engines/consumer/ConsumerOnFinishManager.js +0 -202
- package/engines/dataset/Dataset.js +0 -824
- package/engines/dataset/DatasetManager.js +0 -211
- package/engines/dataset/DatasetRecord.js +0 -120
- package/engines/dataset/DatasetRecordPool.js +0 -77
- package/engines/execution/RequestExecutor.js +0 -67
- package/engines/parsing/CSVParser.js +0 -60
- package/engines/parsing/LineParser.js +0 -71
- package/engines/parsing/ParseCompression.js +0 -101
- package/engines/parsing/ParseHelper.js +0 -18
- package/engines/parsing/ParseManager.js +0 -54
- package/engines/parsing/XLSParser.js +0 -87
- package/engines/parsing/XMLParser.js +0 -115
- package/engines/producer/ProducerEngine.js +0 -127
- package/engines/producer/ProducerManager.js +0 -43
- package/engines/scheduler/CronScheduler.js +0 -222
- package/engines/scheduler/QueueManager.js +0 -314
- package/engines/schema/SchemaValidator.js +0 -67
- package/engines/transform/JoinEngine.js +0 -232
- package/engines/transform/TransformationEngine.js +0 -277
- package/engines/transform/TypeCaster.js +0 -59
- package/engines/usage/DataframeManager.js +0 -55
- package/engines/usage/UsageDataManager.js +0 -151
- package/engines/usage/UsageManager.js +0 -65
- package/engines/validation/Validator.js +0 -216
- package/executors/ConsumerExecutor.js +0 -280
- package/executors/Executor.js +0 -177
- package/executors/ExecutorOrchestrator.js +0 -331
- package/executors/ExecutorPerformance.js +0 -17
- package/executors/ExecutorProgress.js +0 -54
- package/executors/ExecutorScope.js +0 -52
- package/executors/OutputExecutor.js +0 -118
- package/executors/ProducerExecutor.js +0 -108
- package/helper/Helper.js +0 -149
- package/helper/Logger.js +0 -84
- package/helper/Runtime.js +0 -20
- package/helper/Settings.js +0 -13
- package/licencing/LicenceManager.js +0 -64
- package/settings.js +0 -12
|
@@ -1,101 +0,0 @@
|
|
|
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, executionPath) => __awaiter(this, void 0, void 0, function* () {
|
|
56
|
-
// Ensure the directory for the file exists
|
|
57
|
-
const fileDir = path_1.default.dirname(executionPath);
|
|
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
|
-
this._warningPossibleConvertionError(compressionType, fileKey);
|
|
65
|
-
yield (0, decompress_1.default)(path_1.default.join(standardPath, fileKey), executionPath);
|
|
66
|
-
return executionPath;
|
|
67
|
-
}
|
|
68
|
-
case 'GZ': {
|
|
69
|
-
this._warningPossibleConvertionError(compressionType, fileKey);
|
|
70
|
-
yield this._gzipFile(fileKey, standardPath, executionPath);
|
|
71
|
-
return executionPath;
|
|
72
|
-
}
|
|
73
|
-
case null:
|
|
74
|
-
case undefined: {
|
|
75
|
-
if (fileKey.includes('.zip') || fileKey.includes('.tar') || fileKey.includes('.gz'))
|
|
76
|
-
console.log(`The file ${fileKey} seems to use a compressionType while there are no producer settings for compressionType `);
|
|
77
|
-
// No decompression needed for request
|
|
78
|
-
return path_1.default.join(standardPath, fileKey);
|
|
79
|
-
}
|
|
80
|
-
default: {
|
|
81
|
-
// throw an error if the request ask for an unsupported compression type
|
|
82
|
-
throw new Error(`this compression type it has not been implemented ${compressionType}`);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
this._warningPossibleConvertionError = (compression, fileKey) => {
|
|
87
|
-
if (!fileKey.split('.').includes(compression.toLowerCase()) && compression) {
|
|
88
|
-
console.warn(`The compressionType ${compression.toUpperCase()} seems different to the file compression of ${fileKey}`);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
this._gzipFile = (fileKey, standardPath, localPath) => __awaiter(this, void 0, void 0, function* () {
|
|
92
|
-
const fileContents = fs.createReadStream(path_1.default.join(standardPath, fileKey));
|
|
93
|
-
const unzip = zlib_1.default.createGunzip();
|
|
94
|
-
const writeStream = fs.createWriteStream(localPath);
|
|
95
|
-
yield (0, promises_1.pipeline)(fileContents, unzip, writeStream);
|
|
96
|
-
});
|
|
97
|
-
// TODO add a decompression method fo tarball (.tar.gz)
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
const ParseCompression = new ParseCompressionClass();
|
|
101
|
-
exports.default = ParseCompression;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const ParseHelper = {
|
|
4
|
-
shouldHaveHeader: (fileType, hasHeaderRow) => {
|
|
5
|
-
if (fileType === 'CSV' || fileType === 'XLS' || fileType === 'XLSX' || fileType === 'TXT') {
|
|
6
|
-
if (fileType !== 'TXT')
|
|
7
|
-
return true;
|
|
8
|
-
else if (fileType === 'TXT' && (hasHeaderRow === true || hasHeaderRow === undefined))
|
|
9
|
-
return true;
|
|
10
|
-
else
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
exports.default = ParseHelper;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const Affirm_1 = __importDefault(require("../../core/Affirm"));
|
|
7
|
-
const CSVParser_1 = __importDefault(require("./CSVParser"));
|
|
8
|
-
const Constants_1 = __importDefault(require("../../Constants"));
|
|
9
|
-
const ProducerManager_1 = __importDefault(require("../producer/ProducerManager"));
|
|
10
|
-
class ParseManagerClass {
|
|
11
|
-
constructor() {
|
|
12
|
-
this._extractHeader = (headerLine, delimiter, producer, discover) => {
|
|
13
|
-
var _a, _b, _c, _d, _e, _f;
|
|
14
|
-
(0, Affirm_1.default)(headerLine, `Invalid CSV header line for producer "${producer.name}"`);
|
|
15
|
-
(0, Affirm_1.default)(delimiter, 'Invalid CSV delimiter');
|
|
16
|
-
(0, Affirm_1.default)(producer, 'Invalid producer');
|
|
17
|
-
let columns = ProducerManager_1.default.getColumns(producer);
|
|
18
|
-
const headerColumns = CSVParser_1.default.parseRow(headerLine, delimiter).map(x => x.trim());
|
|
19
|
-
// If I'm discovering the file, then it means that the dimensions are not set, so I use the ones that I get from the file directly
|
|
20
|
-
if (discover)
|
|
21
|
-
columns = headerColumns.map(x => ({ nameInProducer: x }));
|
|
22
|
-
const csvColumns = [];
|
|
23
|
-
for (const pColumn of columns) {
|
|
24
|
-
// Skip sourceFilename dimensions - they don't exist in the source file
|
|
25
|
-
// They are added dynamically by the driver when reading the file
|
|
26
|
-
if (((_a = pColumn.dimension) === null || _a === void 0 ? void 0 : _a.sourceFilename) === true) {
|
|
27
|
-
// Find the index of $source_filename in the header (it was added by the driver)
|
|
28
|
-
const sourceFilenameIndex = headerColumns.findIndex(x => x === Constants_1.default.SOURCE_FILENAME_COLUMN);
|
|
29
|
-
if (sourceFilenameIndex > -1) {
|
|
30
|
-
csvColumns.push({
|
|
31
|
-
index: sourceFilenameIndex,
|
|
32
|
-
name: Constants_1.default.SOURCE_FILENAME_COLUMN,
|
|
33
|
-
saveAs: pColumn.nameInProducer,
|
|
34
|
-
type: (_c = (_b = pColumn.dimension) === null || _b === void 0 ? void 0 : _b.type) !== null && _c !== void 0 ? _c : 'string'
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
const columnKey = (_d = pColumn.aliasInProducer) !== null && _d !== void 0 ? _d : pColumn.nameInProducer;
|
|
40
|
-
const csvColumnIndex = headerColumns.findIndex(x => x === columnKey);
|
|
41
|
-
(0, Affirm_1.default)(csvColumnIndex > -1, `The column "${pColumn.nameInProducer}" (with key "${columnKey}") of producer "${producer.name}" doesn't exist in the underlying dataset.`);
|
|
42
|
-
csvColumns.push({
|
|
43
|
-
index: csvColumnIndex,
|
|
44
|
-
name: columnKey,
|
|
45
|
-
saveAs: pColumn.nameInProducer,
|
|
46
|
-
type: (_f = (_e = pColumn.dimension) === null || _e === void 0 ? void 0 : _e.type) !== null && _f !== void 0 ? _f : 'string'
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
return csvColumns;
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
const ParseManager = new ParseManagerClass();
|
|
54
|
-
exports.default = ParseManager;
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
12
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
13
|
-
var m = o[Symbol.asyncIterator], i;
|
|
14
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
15
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
16
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
17
|
-
};
|
|
18
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
const DriverHelper_1 = __importDefault(require("../../drivers/DriverHelper"));
|
|
23
|
-
const Affirm_1 = __importDefault(require("../../core/Affirm"));
|
|
24
|
-
const xlsx_1 = __importDefault(require("xlsx"));
|
|
25
|
-
class XLSParserClass {
|
|
26
|
-
constructor() {
|
|
27
|
-
this.getStreamXls = (filePath, sheetName) => __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
const fileXls = xlsx_1.default.readFile(filePath);
|
|
29
|
-
(0, Affirm_1.default)(fileXls.SheetNames.length > 0, 'The Excel file has no sheets.');
|
|
30
|
-
const targetSheetName = yield this.getTargetSheetName(fileXls, sheetName);
|
|
31
|
-
const workSheet = fileXls.Sheets[targetSheetName];
|
|
32
|
-
const xlsStream = xlsx_1.default.stream.to_csv(workSheet);
|
|
33
|
-
return xlsStream;
|
|
34
|
-
});
|
|
35
|
-
this.getHeaderXls = (filePath, sheetName) => __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
const header = yield DriverHelper_1.default.quickReadStream(yield this.getStreamXls(filePath, sheetName), 2);
|
|
37
|
-
return header[0];
|
|
38
|
-
});
|
|
39
|
-
this.getHeaderXlsFromStream = (stream, sheetName) => __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
var _a, e_1, _b, _c;
|
|
41
|
-
let header;
|
|
42
|
-
const workbook = xlsx_1.default.read(stream);
|
|
43
|
-
const targetSheetName = yield this.getTargetSheetName(workbook, sheetName);
|
|
44
|
-
const xlsxStream = xlsx_1.default.stream.to_csv(workbook.Sheets[targetSheetName]);
|
|
45
|
-
try {
|
|
46
|
-
for (var _d = true, xlsxStream_1 = __asyncValues(xlsxStream), xlsxStream_1_1; xlsxStream_1_1 = yield xlsxStream_1.next(), _a = xlsxStream_1_1.done, !_a; _d = true) {
|
|
47
|
-
_c = xlsxStream_1_1.value;
|
|
48
|
-
_d = false;
|
|
49
|
-
const line = _c;
|
|
50
|
-
if (line != '') {
|
|
51
|
-
header = line;
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
57
|
-
finally {
|
|
58
|
-
try {
|
|
59
|
-
if (!_d && !_a && (_b = xlsxStream_1.return)) yield _b.call(xlsxStream_1);
|
|
60
|
-
}
|
|
61
|
-
finally { if (e_1) throw e_1.error; }
|
|
62
|
-
}
|
|
63
|
-
(0, Affirm_1.default)(header, `the file received from the stream is empty`);
|
|
64
|
-
return header;
|
|
65
|
-
});
|
|
66
|
-
this.getTargetSheetName = (workbook, sheetName) => __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
let targetSheetName = sheetName ? sheetName : workbook.SheetNames[0];
|
|
68
|
-
if (!targetSheetName) {
|
|
69
|
-
(0, Affirm_1.default)(workbook.SheetNames.length > 0, 'The Excel file has no sheets.');
|
|
70
|
-
targetSheetName = workbook.SheetNames[0];
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
(0, Affirm_1.default)(workbook.SheetNames.includes(targetSheetName), `The sheet "${targetSheetName}" doesn't exist in the excel (available: ${workbook.SheetNames.join(', ')})`);
|
|
74
|
-
}
|
|
75
|
-
return targetSheetName;
|
|
76
|
-
});
|
|
77
|
-
this.parseXLSStream = (xlsStream, sheetName) => __awaiter(this, void 0, void 0, function* () {
|
|
78
|
-
const workbook = xlsx_1.default.read(xlsStream);
|
|
79
|
-
const targetSheetName = yield this.getTargetSheetName(workbook, sheetName);
|
|
80
|
-
const workSheet = workbook.Sheets[targetSheetName];
|
|
81
|
-
const csvStream = xlsx_1.default.stream.to_csv(workSheet);
|
|
82
|
-
return csvStream;
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
const XLSParser = new XLSParserClass();
|
|
87
|
-
exports.default = XLSParser;
|
|
@@ -1,115 +0,0 @@
|
|
|
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 fast_xml_parser_1 = require("fast-xml-parser");
|
|
49
|
-
const Affirm_1 = __importDefault(require("../../core/Affirm"));
|
|
50
|
-
const Algo_1 = __importDefault(require("../../core/Algo"));
|
|
51
|
-
const fs = __importStar(require("fs"));
|
|
52
|
-
const DEFAULT_OPTIONS = {
|
|
53
|
-
attributeNamePrefix: '@_',
|
|
54
|
-
ignoreAttributes: false,
|
|
55
|
-
parseAttributeValue: true,
|
|
56
|
-
parseTagValue: true,
|
|
57
|
-
trimValues: true,
|
|
58
|
-
isArray: () => {
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
class XMLParserClass {
|
|
63
|
-
constructor(options) {
|
|
64
|
-
this.xmlToJson = (xmlData) => {
|
|
65
|
-
(0, Affirm_1.default)(xmlData, 'XML data cannot be empty');
|
|
66
|
-
try {
|
|
67
|
-
const parsedData = this._parser.parse(xmlData);
|
|
68
|
-
if (typeof parsedData === 'object' && parsedData !== null) {
|
|
69
|
-
const rootKeys = Object.keys(parsedData);
|
|
70
|
-
if (rootKeys.length === 1) {
|
|
71
|
-
const potentialArray = parsedData[rootKeys[0]];
|
|
72
|
-
if (Array.isArray(potentialArray)) {
|
|
73
|
-
return potentialArray;
|
|
74
|
-
}
|
|
75
|
-
if (typeof potentialArray === 'object' && potentialArray !== null) {
|
|
76
|
-
const innerKeys = Object.keys(potentialArray);
|
|
77
|
-
if (innerKeys.length === 1 && Array.isArray(potentialArray[innerKeys[0]])) {
|
|
78
|
-
return potentialArray[innerKeys[0]];
|
|
79
|
-
}
|
|
80
|
-
if (Array.isArray(potentialArray)) {
|
|
81
|
-
return potentialArray;
|
|
82
|
-
}
|
|
83
|
-
const values = Object.values(potentialArray).filter(Array.isArray);
|
|
84
|
-
if (values.length === 1 && Array.isArray(values[0])) {
|
|
85
|
-
return values[0];
|
|
86
|
-
}
|
|
87
|
-
return [potentialArray];
|
|
88
|
-
}
|
|
89
|
-
return [potentialArray];
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return parsedData;
|
|
93
|
-
}
|
|
94
|
-
catch (error) {
|
|
95
|
-
console.error('Error parsing XML:', error);
|
|
96
|
-
throw new Error('Failed to parse XML data.');
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
// TO DO: improve performances for larger file using streams instead of an array of string
|
|
100
|
-
this.readXmlLines = (fileUri, lineFrom, lineTo) => __awaiter(this, void 0, void 0, function* () {
|
|
101
|
-
const fileContent = fs.readFileSync(fileUri, 'utf-8');
|
|
102
|
-
const jsonData = XMLParser.xmlToJson(fileContent);
|
|
103
|
-
// Convert JSON data to string lines. This might need adjustment based on XML structure.
|
|
104
|
-
// Assuming jsonData is an array of objects, where each object is a record.
|
|
105
|
-
let lines = Array.isArray(jsonData) ? jsonData.map(item => JSON.stringify(item)) : [JSON.stringify(jsonData)];
|
|
106
|
-
if (Algo_1.default.hasVal(lineFrom) && Algo_1.default.hasVal(lineTo)) {
|
|
107
|
-
lines = lines.slice(lineFrom, lineTo + 1);
|
|
108
|
-
}
|
|
109
|
-
return lines;
|
|
110
|
-
});
|
|
111
|
-
this._parser = new fast_xml_parser_1.XMLParser(Object.assign(Object.assign({}, DEFAULT_OPTIONS), options)); // Use 'as any' if type issues persist with library
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
const XMLParser = new XMLParserClass();
|
|
115
|
-
exports.default = XMLParser;
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const Affirm_1 = __importDefault(require("../../core/Affirm"));
|
|
16
|
-
const DriverFactory_1 = __importDefault(require("../../drivers/DriverFactory"));
|
|
17
|
-
const Environment_1 = __importDefault(require("../Environment"));
|
|
18
|
-
const DatasetManager_1 = __importDefault(require("../dataset/DatasetManager"));
|
|
19
|
-
const Logger_1 = __importDefault(require("../../helper/Logger"));
|
|
20
|
-
class ProducerEngineClass {
|
|
21
|
-
constructor() {
|
|
22
|
-
this.readFile = (producer, options) => __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
var _a, _b, _c;
|
|
24
|
-
(0, Affirm_1.default)(producer, 'Invalid producer');
|
|
25
|
-
(0, Affirm_1.default)(options, 'Invalid options');
|
|
26
|
-
if (options.readmode === 'lines')
|
|
27
|
-
(0, Affirm_1.default)(options.lines, 'Invalid lines');
|
|
28
|
-
const source = Environment_1.default.getSource(producer.source);
|
|
29
|
-
(0, Affirm_1.default)(source, `No source found for producer "${producer.name}" with name "${producer.source}"`);
|
|
30
|
-
const driver = yield DriverFactory_1.default.instantiateSource(source);
|
|
31
|
-
(0, Affirm_1.default)(driver, `No driver found for producer "${producer.name}" with driver type "${source.engine}"`);
|
|
32
|
-
const { settings: { fileKey, fileType, sheetName, hasHeaderRow } } = producer;
|
|
33
|
-
let dataset = DatasetManager_1.default.create(producer);
|
|
34
|
-
let lines = [];
|
|
35
|
-
switch (options.readmode) {
|
|
36
|
-
case 'lines':
|
|
37
|
-
lines = yield driver.readLinesInRange({
|
|
38
|
-
fileKey,
|
|
39
|
-
fileType,
|
|
40
|
-
options: { lineFrom: options.lines.from, lineTo: options.lines.to, sheetName, hasHeaderRow },
|
|
41
|
-
httpApi: (_a = producer.settings) === null || _a === void 0 ? void 0 : _a.httpApi
|
|
42
|
-
});
|
|
43
|
-
break;
|
|
44
|
-
case 'all':
|
|
45
|
-
lines = yield driver.readAll({
|
|
46
|
-
fileKey, fileType,
|
|
47
|
-
options: { sheetName, hasHeaderRow },
|
|
48
|
-
httpApi: (_b = producer.settings) === null || _b === void 0 ? void 0 : _b.httpApi
|
|
49
|
-
});
|
|
50
|
-
break;
|
|
51
|
-
case 'download':
|
|
52
|
-
dataset = yield driver.download(dataset);
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
switch ((_c = producer.settings.fileType) === null || _c === void 0 ? void 0 : _c.toUpperCase()) {
|
|
56
|
-
case 'CSV':
|
|
57
|
-
case 'TXT':
|
|
58
|
-
return { data: lines, dataset, dataType: 'lines-of-text' };
|
|
59
|
-
case 'XLS':
|
|
60
|
-
case 'XLSX':
|
|
61
|
-
return { data: lines, dataset, dataType: 'lines-of-text' };
|
|
62
|
-
case 'PARQUET':
|
|
63
|
-
case 'JSONL':
|
|
64
|
-
case 'JSON': {
|
|
65
|
-
if (lines.length === 1) {
|
|
66
|
-
// Attempt to handle cases where a single line might contain multiple JSON objects separated by newlines
|
|
67
|
-
// Or if the entire file content is a single JSON array stringified.
|
|
68
|
-
try {
|
|
69
|
-
const parsedAsArray = JSON.parse(lines[0]);
|
|
70
|
-
if (Array.isArray(parsedAsArray)) {
|
|
71
|
-
return { data: parsedAsArray, dataset, dataType: 'array-of-json' };
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
// If parsing as array fails, proceed to split by newline
|
|
76
|
-
console.warn('Failed to parse single line as JSON array, splitting by newline:', error);
|
|
77
|
-
}
|
|
78
|
-
lines = lines[0].split('\\n');
|
|
79
|
-
}
|
|
80
|
-
const json = lines.filter(line => line.trim() !== '').map(x => JSON.parse(x));
|
|
81
|
-
return { data: json, dataset, dataType: 'array-of-json' };
|
|
82
|
-
}
|
|
83
|
-
case 'XML': {
|
|
84
|
-
// The driver's _readXmlLines method now returns an array of JSON strings.
|
|
85
|
-
// Each string needs to be parsed into a JSON object.
|
|
86
|
-
const json = lines.filter(line => line.trim() !== '').map(x => JSON.parse(x));
|
|
87
|
-
return { data: json, dataset, dataType: 'array-of-json' };
|
|
88
|
-
}
|
|
89
|
-
default:
|
|
90
|
-
throw new Error(`Invalid file type "${producer.settings.fileType}" for engine type "${source.engine}" for producer "${producer.name}": not supported`);
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
this.readSampleData = (producer_1, ...args_1) => __awaiter(this, [producer_1, ...args_1], void 0, function* (producer, sampleSize = 10, discover = false) {
|
|
94
|
-
(0, Affirm_1.default)(producer, 'Invalid producer');
|
|
95
|
-
(0, Affirm_1.default)(sampleSize > 0, 'Sample size must be greater than 0');
|
|
96
|
-
const source = Environment_1.default.getSource(producer.source);
|
|
97
|
-
(0, Affirm_1.default)(source, `No source found for producer "${producer.name}" with name "${producer.source}"`);
|
|
98
|
-
let dataset = DatasetManager_1.default.create(producer);
|
|
99
|
-
switch (source.engine) {
|
|
100
|
-
case 'aws-redshift': {
|
|
101
|
-
const sql = `SELECT * FROM "${source.authentication['schema']}"."${producer.settings.sqlTable}" LIMIT ${sampleSize}`;
|
|
102
|
-
(0, Affirm_1.default)(sql, `Invalid SQL from deployment compilation for producer "${producer.name}"`);
|
|
103
|
-
const driver = yield DriverFactory_1.default.instantiateSource(source);
|
|
104
|
-
(0, Affirm_1.default)(driver, `No driver found for producer "${producer.name}" with driver type "${source.engine}"`);
|
|
105
|
-
const res = yield driver.query(sql);
|
|
106
|
-
dataset = yield dataset.loadFromMemory(res.rows, producer, discover);
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
case 'local':
|
|
110
|
-
case 'aws-s3':
|
|
111
|
-
case 'delta-share': {
|
|
112
|
-
const fileData = yield this.readFile(producer, { readmode: 'lines', lines: { from: 0, to: sampleSize } });
|
|
113
|
-
dataset = yield dataset.loadFromMemory(fileData.data, producer, discover);
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
default:
|
|
117
|
-
throw new Error(`Invalid engine type "${source.engine}" for producer "${producer.name}": not supported`);
|
|
118
|
-
}
|
|
119
|
-
const sampleData = [...yield dataset.readLines(sampleSize)];
|
|
120
|
-
dataset.destroy();
|
|
121
|
-
Logger_1.default.log(`Finished reading sample dataset:\n${dataset.printStats()}`);
|
|
122
|
-
return sampleData;
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
const ProducerEngine = new ProducerEngineClass();
|
|
127
|
-
exports.default = ProducerEngine;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const Affirm_1 = __importDefault(require("../../core/Affirm"));
|
|
7
|
-
const SecretManager_1 = __importDefault(require("../SecretManager"));
|
|
8
|
-
class ProducerManagerClass {
|
|
9
|
-
constructor() {
|
|
10
|
-
this.getColumns = (producer) => {
|
|
11
|
-
var _a;
|
|
12
|
-
(0, Affirm_1.default)(producer, `Invalid producer`);
|
|
13
|
-
(0, Affirm_1.default)((_a = producer.settings.fileKey) !== null && _a !== void 0 ? _a : producer.settings.sqlTable, `Missing required file key in producer settings`);
|
|
14
|
-
(0, Affirm_1.default)(producer.settings.fileType, `Missing required file type in producer settings`);
|
|
15
|
-
const columns = producer.dimensions.map(x => ({
|
|
16
|
-
aliasInProducer: x.alias,
|
|
17
|
-
nameInProducer: x.name,
|
|
18
|
-
consumerAlias: null,
|
|
19
|
-
consumerKey: null,
|
|
20
|
-
owner: producer.name,
|
|
21
|
-
dimension: x
|
|
22
|
-
}));
|
|
23
|
-
return columns;
|
|
24
|
-
};
|
|
25
|
-
this.getMask = (dimension) => {
|
|
26
|
-
if (!dimension || !dimension.mask)
|
|
27
|
-
return null;
|
|
28
|
-
const mask = SecretManager_1.default.replaceSecret(dimension.mask);
|
|
29
|
-
const allowedMaskValues = [
|
|
30
|
-
'hash',
|
|
31
|
-
'mask',
|
|
32
|
-
'crypt',
|
|
33
|
-
'random',
|
|
34
|
-
'seeded-random',
|
|
35
|
-
'none'
|
|
36
|
-
];
|
|
37
|
-
(0, Affirm_1.default)(allowedMaskValues.includes(mask), `Mask value "${mask}" in dimension "${dimension.name}" is not a valid value.`);
|
|
38
|
-
return mask;
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
const ProducerManager = new ProducerManagerClass();
|
|
43
|
-
exports.default = ProducerManager;
|