@forzalabs/remora 0.0.17 → 0.0.19
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 +1 -1
- package/actions/compile.js +1 -1
- package/actions/run.js +21 -8
- package/engines/Environment.js +10 -0
- package/engines/UserManager.js +11 -0
- package/engines/Validator.js +8 -6
- package/engines/consumer/PostProcessor.js +0 -1
- package/package.json +1 -1
package/Constants.js
CHANGED
package/actions/compile.js
CHANGED
|
@@ -39,7 +39,7 @@ const compile = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
39
39
|
errors = [...errors, ...envErrors];
|
|
40
40
|
if (errors.length === 0) {
|
|
41
41
|
spinner.succeed(chalk_1.default.green('Project structure validated successfully'));
|
|
42
|
-
console.log(chalk_1.default.
|
|
42
|
+
console.log(chalk_1.default.blueBright.bold('✅ Compilation complete!'));
|
|
43
43
|
}
|
|
44
44
|
else {
|
|
45
45
|
spinner.fail(chalk_1.default.red('Validation failed with errors:'));
|
package/actions/run.js
CHANGED
|
@@ -19,9 +19,11 @@ const Environment_1 = __importDefault(require("../engines/Environment"));
|
|
|
19
19
|
const UserManager_1 = __importDefault(require("../engines/UserManager"));
|
|
20
20
|
const ConsumerEngine_1 = __importDefault(require("../engines/consumer/ConsumerEngine"));
|
|
21
21
|
const compile_1 = require("./compile");
|
|
22
|
+
const Helper_1 = __importDefault(require("../helper/Helper"));
|
|
22
23
|
const run = (consumerName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
24
|
try {
|
|
24
25
|
(0, compile_1.compile)();
|
|
26
|
+
console.log();
|
|
25
27
|
const spinner = (0, ora_1.default)(chalk_1.default.blue('Running consumer(s)...\n')).start();
|
|
26
28
|
const user = UserManager_1.default.getUser();
|
|
27
29
|
const consumersToExecute = (consumerName && consumerName.length > 0)
|
|
@@ -30,19 +32,30 @@ const run = (consumerName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
30
32
|
const results = [];
|
|
31
33
|
for (let i = 0; i < consumersToExecute.length; i++) {
|
|
32
34
|
const consumer = consumersToExecute[i];
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
try {
|
|
36
|
+
const response = yield ConsumerEngine_1.default.execute(consumer, {}, user);
|
|
37
|
+
results.push({ success: true, consumer, response });
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
results.push({ success: false, consumer, error: Helper_1.default.asError(error).message });
|
|
41
|
+
}
|
|
35
42
|
}
|
|
36
|
-
spinner.succeed('All consumers have been
|
|
37
|
-
results.forEach(
|
|
38
|
-
if (
|
|
39
|
-
|
|
43
|
+
spinner.succeed('All consumers have been executed:');
|
|
44
|
+
results.forEach(({ response, consumer, success, error }) => {
|
|
45
|
+
if (success) {
|
|
46
|
+
if (response.fileUri)
|
|
47
|
+
console.log(chalk_1.default.green(`• Consumer ${consumer.name} -> ${response.fileUri}`));
|
|
48
|
+
else
|
|
49
|
+
console.log(chalk_1.default.green(`• Consumer ${consumer.name} -> ${response.data.slice(0, 5).join('\n')}`));
|
|
40
50
|
}
|
|
41
51
|
else {
|
|
42
|
-
console.log(chalk_1.default.
|
|
52
|
+
console.log(chalk_1.default.red(`• Consumer ${consumer.name} -> Failed: ${error}`));
|
|
43
53
|
}
|
|
44
54
|
});
|
|
45
|
-
|
|
55
|
+
if (results.some(x => !x.success))
|
|
56
|
+
console.log(chalk_1.default.blueBright('\nℹ️ Run completed with errors'));
|
|
57
|
+
else
|
|
58
|
+
console.log(chalk_1.default.green('\n✅ Run complete!'));
|
|
46
59
|
process.exit(1);
|
|
47
60
|
}
|
|
48
61
|
catch (err) {
|
package/engines/Environment.js
CHANGED
|
@@ -123,7 +123,17 @@ class EnvironmentClass {
|
|
|
123
123
|
try {
|
|
124
124
|
errors = [...errors, ...Validator_1.default.validateSources(this._env.sources)];
|
|
125
125
|
errors = [...errors, ...Validator_1.default.validateProducers(this._env.producers)];
|
|
126
|
+
this._env.producers.forEach(prod => {
|
|
127
|
+
const ce = Validator_1.default.validateProducer(prod);
|
|
128
|
+
if (ce.length > 0)
|
|
129
|
+
errors.push(`Producer "${prod.name}" errors:\n${ce.map(x => `\t-${x}\n`)}`);
|
|
130
|
+
});
|
|
126
131
|
errors = [...errors, ...Validator_1.default.validateConsumers(this._env.consumers)];
|
|
132
|
+
this._env.consumers.forEach(cons => {
|
|
133
|
+
const ce = Validator_1.default.validateConsumer(cons);
|
|
134
|
+
if (ce.length > 0)
|
|
135
|
+
errors.push(`Consumer "${cons.name}" errors:\n${ce.map(x => `\t-${x}\n`)}`);
|
|
136
|
+
});
|
|
127
137
|
}
|
|
128
138
|
catch (e) {
|
|
129
139
|
if (errors.length === 0)
|
package/engines/UserManager.js
CHANGED
|
@@ -20,6 +20,8 @@ class UserManagerClass {
|
|
|
20
20
|
this.getUser = () => {
|
|
21
21
|
if (Helper_1.default.isDev())
|
|
22
22
|
return DEV_USER;
|
|
23
|
+
else
|
|
24
|
+
return MOCK_USER;
|
|
23
25
|
// TODO: figure out how to handle users
|
|
24
26
|
};
|
|
25
27
|
this.findOIDC = (oid) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -41,3 +43,12 @@ const DEV_USER = {
|
|
|
41
43
|
_signature: '',
|
|
42
44
|
lastLogin: new Date().toJSON()
|
|
43
45
|
};
|
|
46
|
+
const MOCK_USER = {
|
|
47
|
+
_id: '__mock__',
|
|
48
|
+
auth: { oid: '', provider: 'azure' },
|
|
49
|
+
email: '',
|
|
50
|
+
name: 'mock',
|
|
51
|
+
roles: ['user'],
|
|
52
|
+
_signature: '',
|
|
53
|
+
lastLogin: new Date().toJSON()
|
|
54
|
+
};
|
package/engines/Validator.js
CHANGED
|
@@ -65,7 +65,6 @@ class ValidatorClass {
|
|
|
65
65
|
const dupes = Algo_1.default.duplicatesObject(consumers, 'name');
|
|
66
66
|
if (dupes.length > 0)
|
|
67
67
|
errors.push(`Duplicate name(s) found in consumers: "${dupes.map(x => x.name).join(', ')}"`);
|
|
68
|
-
errors.push(...consumers.flatMap(x => this.validateConsumer(x)));
|
|
69
68
|
}
|
|
70
69
|
catch (e) {
|
|
71
70
|
if (errors.length === 0)
|
|
@@ -121,7 +120,7 @@ class ValidatorClass {
|
|
|
121
120
|
const groupingFields = fields.filter(x => x.grouping);
|
|
122
121
|
if (groupingFields.length > 1)
|
|
123
122
|
errors.push(`There can't be 2 fields with grouping defined at the same level (${groupingFields.map(x => x.key).join(', ')}). Level: ${level}`);
|
|
124
|
-
groupingFields.forEach(
|
|
123
|
+
groupingFields.forEach(field => {
|
|
125
124
|
if (field.grouping)
|
|
126
125
|
errors = [...errors, ...validateGroupingLevels(field.grouping.subFields, level + 1)];
|
|
127
126
|
});
|
|
@@ -134,13 +133,16 @@ class ValidatorClass {
|
|
|
134
133
|
const duplicatesTypes = Algo_1.default.uniq(duplicatesOutputs.map(x => x.format));
|
|
135
134
|
errors.push(`There are outputs with the same type. (duplicates type: ${duplicatesTypes.join(' and ')})`);
|
|
136
135
|
}
|
|
137
|
-
for (
|
|
138
|
-
const output = consumer.outputs[i];
|
|
136
|
+
for (const output of consumer.outputs) {
|
|
139
137
|
const format = output.format.toUpperCase();
|
|
140
138
|
if (format === 'SQL' && output.accellerated && output.direct)
|
|
141
139
|
errors.push(`An output SQL cannot be both direct and accelerated (output: ${format})`);
|
|
142
|
-
if ((format === 'CSV' || format === 'JSON' || format === 'PARQUET')
|
|
143
|
-
|
|
140
|
+
if ((format === 'CSV' || format === 'JSON' || format === 'PARQUET')) {
|
|
141
|
+
if (!output.exportDestination)
|
|
142
|
+
errors.push(`A static file output must have an export destination set (${format})`);
|
|
143
|
+
else if (!Environment_1.default.getSource(output.exportDestination))
|
|
144
|
+
errors.push(`The export destination "${output.exportDestination}" was not found in the sources.`);
|
|
145
|
+
}
|
|
144
146
|
}
|
|
145
147
|
}
|
|
146
148
|
catch (e) {
|
|
@@ -74,7 +74,6 @@ class PostProcessorClass {
|
|
|
74
74
|
(0, Affirm_1.default)(data, 'Invalid data');
|
|
75
75
|
(0, Affirm_1.default)(Array.isArray(data), 'Invalid data type, must be an array');
|
|
76
76
|
(0, Affirm_1.default)(producer, 'Invalid producer');
|
|
77
|
-
console.log('BBBBBBBBB');
|
|
78
77
|
const source = Environment_1.default.getSource(producer.source);
|
|
79
78
|
(0, Affirm_1.default)(source, `No source found for producer "${producer.name}" with name "${producer.source}"`);
|
|
80
79
|
const columns = FileCompiler_1.default.compileProducer(producer, source);
|