@forzalabs/remora 0.0.43-nasco.3 → 0.0.45-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 +1 -1
- package/definitions/json_schemas/producer-schema.json +7 -2
- package/definitions/json_schemas/source-schema.json +1 -1
- package/engines/CryptoEngine.js +4 -0
- package/engines/SecretManager.js +5 -0
- package/engines/ai/DeveloperEngine.js +1 -1
- package/engines/consumer/ConsumerEngine.js +4 -3
- package/engines/consumer/PostProcessor.js +8 -7
- package/engines/execution/ExecutionEnvironment.js +1 -1
- package/engines/execution/RequestExecutor.js +0 -1
- package/engines/producer/ProducerEngine.js +160 -0
- package/engines/producer/ProducerManager.js +28 -0
- package/engines/sql/SQLCompiler.js +3 -2
- package/package.json +1 -1
package/Constants.js
CHANGED
|
@@ -70,9 +70,14 @@
|
|
|
70
70
|
"mask",
|
|
71
71
|
"crypt",
|
|
72
72
|
"random",
|
|
73
|
-
"seeded-random"
|
|
73
|
+
"seeded-random",
|
|
74
|
+
"none"
|
|
74
75
|
],
|
|
75
|
-
"description": "Masking type to apply to this dimension. 'hash' replaces with a hashed value. 'mask' replaces characters with a mask character. 'crypt' encrypts the value. 'random' replaces with a random value. 'seeded-random' replaces with a random value generated from a seed."
|
|
76
|
+
"description": "Masking type to apply to this dimension. 'hash' replaces with a hashed value. 'mask' replaces characters with a mask character. 'crypt' encrypts the value. 'random' replaces with a random value. 'seeded-random' replaces with a random value generated from a seed. You can use environment variables by using the {your-env-var} notation",
|
|
77
|
+
"examples": [
|
|
78
|
+
"hash",
|
|
79
|
+
"{REMORA_MASK_IN_DEV}"
|
|
80
|
+
]
|
|
76
81
|
}
|
|
77
82
|
},
|
|
78
83
|
"required": [
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"authentication": {
|
|
31
31
|
"type": "object",
|
|
32
|
-
"description": "Authentication details for connecting to the data source",
|
|
32
|
+
"description": "Authentication details for connecting to the data source. You can use environment variables by using the {your-env-var} notation",
|
|
33
33
|
"properties": {
|
|
34
34
|
"method": {
|
|
35
35
|
"type": "string",
|
package/engines/CryptoEngine.js
CHANGED
|
@@ -18,6 +18,8 @@ class CryptoEngineClass {
|
|
|
18
18
|
throw new Error('Not implemented yet');
|
|
19
19
|
case 'mask':
|
|
20
20
|
throw new Error('Not implemented yet');
|
|
21
|
+
case 'none':
|
|
22
|
+
return `${fieldReference} AS "${fieldName}"`;
|
|
21
23
|
default:
|
|
22
24
|
throw new Error('This type is not ');
|
|
23
25
|
}
|
|
@@ -55,6 +57,8 @@ class CryptoEngineClass {
|
|
|
55
57
|
throw new Error('Not implemented yet');
|
|
56
58
|
case 'mask':
|
|
57
59
|
throw new Error('Not implemented yet');
|
|
60
|
+
case 'none':
|
|
61
|
+
return value;
|
|
58
62
|
default:
|
|
59
63
|
throw new Error(`This type doesn't exist`);
|
|
60
64
|
}
|
package/engines/SecretManager.js
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
class SecretManagerClass {
|
|
4
4
|
constructor() {
|
|
5
|
+
/**
|
|
6
|
+
* If the value is a secret (or .env setting), replace it with the value inside the .env configuration file
|
|
7
|
+
* Starts with "{" and ends with "}".
|
|
8
|
+
* e.g. {AWS_ID}
|
|
9
|
+
*/
|
|
5
10
|
this.replaceSecret = (value) => {
|
|
6
11
|
if (!value || value.length <= 2 || !value.startsWith('{') || !value.endsWith('}'))
|
|
7
12
|
return value;
|
|
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const Affirm_1 = __importDefault(require("../../core/Affirm"));
|
|
16
|
-
const ProducerEngine_1 = __importDefault(require("../ProducerEngine"));
|
|
16
|
+
const ProducerEngine_1 = __importDefault(require("../producer/ProducerEngine"));
|
|
17
17
|
const path_1 = __importDefault(require("path"));
|
|
18
18
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
19
19
|
class DeveloperEngineClass {
|
|
@@ -19,6 +19,7 @@ const Helper_1 = __importDefault(require("../../helper/Helper"));
|
|
|
19
19
|
const DeploymentPlanner_1 = __importDefault(require("../deployment/DeploymentPlanner"));
|
|
20
20
|
const Environment_1 = __importDefault(require("../Environment"));
|
|
21
21
|
const ExecutionEnvironment_1 = __importDefault(require("../execution/ExecutionEnvironment"));
|
|
22
|
+
const ProducerManager_1 = __importDefault(require("../producer/ProducerManager"));
|
|
22
23
|
const SQLCompiler_1 = __importDefault(require("../sql/SQLCompiler"));
|
|
23
24
|
const SQLUtils_1 = __importDefault(require("../sql/SQLUtils"));
|
|
24
25
|
const UsageManager_1 = __importDefault(require("../UsageManager"));
|
|
@@ -145,14 +146,14 @@ class ConsumerEngineClass {
|
|
|
145
146
|
(0, Affirm_1.default)(consumer, `Invalid consumer`);
|
|
146
147
|
const compiled = this.compile(consumer);
|
|
147
148
|
const outDimensions = compiled.map(x => {
|
|
148
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
149
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
149
150
|
return ({
|
|
150
151
|
name: (_a = x.consumerAlias) !== null && _a !== void 0 ? _a : x.consumerKey,
|
|
151
152
|
type: (_b = x.dimension) === null || _b === void 0 ? void 0 : _b.type,
|
|
152
153
|
classification: (_c = x.dimension) === null || _c === void 0 ? void 0 : _c.classification,
|
|
153
154
|
description: (_e = (_d = x.dimension) === null || _d === void 0 ? void 0 : _d.description) !== null && _e !== void 0 ? _e : (_f = x.measure) === null || _f === void 0 ? void 0 : _f.description,
|
|
154
|
-
mask: (
|
|
155
|
-
pk: (
|
|
155
|
+
mask: ProducerManager_1.default.getMask(x.dimension),
|
|
156
|
+
pk: (_g = x.dimension) === null || _g === void 0 ? void 0 : _g.pk
|
|
156
157
|
});
|
|
157
158
|
});
|
|
158
159
|
return {
|
|
@@ -18,6 +18,7 @@ const CryptoEngine_1 = __importDefault(require("../CryptoEngine"));
|
|
|
18
18
|
const DatasetRecord_1 = __importDefault(require("../dataset/DatasetRecord"));
|
|
19
19
|
const Environment_1 = __importDefault(require("../Environment"));
|
|
20
20
|
const FileCompiler_1 = __importDefault(require("../file/FileCompiler"));
|
|
21
|
+
const ProducerManager_1 = __importDefault(require("../producer/ProducerManager"));
|
|
21
22
|
const TypeCaster_1 = __importDefault(require("../transform/TypeCaster"));
|
|
22
23
|
const ConsumerManager_1 = __importDefault(require("./ConsumerManager"));
|
|
23
24
|
class PostProcessorClass {
|
|
@@ -36,12 +37,12 @@ class PostProcessorClass {
|
|
|
36
37
|
newDataset = this.renameDimensions(newDataset, consumer);
|
|
37
38
|
newDataset = yield this.reorderDimensions(newDataset, consumer);
|
|
38
39
|
newDataset = yield newDataset.map(record => {
|
|
39
|
-
var _a, _b
|
|
40
|
+
var _a, _b;
|
|
40
41
|
for (const field of fields) {
|
|
41
42
|
const { key, alias } = field.cField;
|
|
42
43
|
const fieldKey = alias !== null && alias !== void 0 ? alias : key;
|
|
43
|
-
const maskType = (
|
|
44
|
-
const fieldType = (
|
|
44
|
+
const maskType = ProducerManager_1.default.getMask(field.dimension);
|
|
45
|
+
const fieldType = (_b = (_a = field.dimension) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : 'string';
|
|
45
46
|
const fieldValue = this._getFieldValue(record, field);
|
|
46
47
|
if (Algo_1.default.hasVal(maskType))
|
|
47
48
|
record.setValue(fieldKey, CryptoEngine_1.default.hashValue(maskType, fieldValue, fieldType));
|
|
@@ -105,10 +106,10 @@ class PostProcessorClass {
|
|
|
105
106
|
const columns = FileCompiler_1.default.compileProducer(producer, source);
|
|
106
107
|
(0, Affirm_1.default)(columns, `Invalid columns from compilation for producer "${producer.name}"`);
|
|
107
108
|
const unpackDimension = (item, dimension) => {
|
|
108
|
-
var _a, _b
|
|
109
|
+
var _a, _b;
|
|
109
110
|
const { nameInProducer, aliasInProducer } = dimension;
|
|
110
|
-
const maskType = (
|
|
111
|
-
const fieldType = (
|
|
111
|
+
const maskType = ProducerManager_1.default.getMask(dimension.dimension);
|
|
112
|
+
const fieldType = (_b = (_a = dimension.dimension) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : 'string';
|
|
112
113
|
const keys = aliasInProducer.split('.');
|
|
113
114
|
// Parse the JSON content from the DatasetRecord first
|
|
114
115
|
let prevValue;
|
|
@@ -128,7 +129,7 @@ class PostProcessorClass {
|
|
|
128
129
|
prevValue = recordObj;
|
|
129
130
|
}
|
|
130
131
|
}
|
|
131
|
-
catch (
|
|
132
|
+
catch (_c) {
|
|
132
133
|
// Fallback to using the record's values directly
|
|
133
134
|
const recordObj = {};
|
|
134
135
|
const dimensions = dataset.getDimensions();
|
|
@@ -17,7 +17,7 @@ const DriverFactory_1 = __importDefault(require("../../drivers/DriverFactory"));
|
|
|
17
17
|
const ConsumerEngine_1 = __importDefault(require("../consumer/ConsumerEngine"));
|
|
18
18
|
const PostProcessor_1 = __importDefault(require("../consumer/PostProcessor"));
|
|
19
19
|
const FileExporter_1 = __importDefault(require("../file/FileExporter"));
|
|
20
|
-
const ProducerEngine_1 = __importDefault(require("../ProducerEngine"));
|
|
20
|
+
const ProducerEngine_1 = __importDefault(require("../producer/ProducerEngine"));
|
|
21
21
|
const SQLBuilder_1 = __importDefault(require("../sql/SQLBuilder"));
|
|
22
22
|
const SQLCompiler_1 = __importDefault(require("../sql/SQLCompiler"));
|
|
23
23
|
const ExecutionPlanner_1 = __importDefault(require("./ExecutionPlanner"));
|
|
@@ -21,7 +21,6 @@ class RequestExecutorClass {
|
|
|
21
21
|
this.execute = (dataset, request) => __awaiter(this, void 0, void 0, function* () {
|
|
22
22
|
(0, Affirm_1.default)(dataset, 'Invalid data');
|
|
23
23
|
(0, Affirm_1.default)(request, 'Invalid request');
|
|
24
|
-
(0, Affirm_1.default)(Array.isArray(dataset), `Invalid data type: should be an array`);
|
|
25
24
|
if (request.filters)
|
|
26
25
|
dataset = yield this.applyFilters(dataset, request.filters);
|
|
27
26
|
if (request.order)
|
|
@@ -0,0 +1,160 @@
|
|
|
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 DeploymentPlanner_1 = __importDefault(require("../deployment/DeploymentPlanner"));
|
|
18
|
+
const Environment_1 = __importDefault(require("../Environment"));
|
|
19
|
+
const FileCompiler_1 = __importDefault(require("../file/FileCompiler"));
|
|
20
|
+
const SQLCompiler_1 = __importDefault(require("../sql/SQLCompiler"));
|
|
21
|
+
const SQLUtils_1 = __importDefault(require("../sql/SQLUtils"));
|
|
22
|
+
const DatasetManager_1 = __importDefault(require("../dataset/DatasetManager"));
|
|
23
|
+
const Logger_1 = __importDefault(require("../../helper/Logger"));
|
|
24
|
+
class ProducerEngineClass {
|
|
25
|
+
constructor() {
|
|
26
|
+
this.compile = (producer) => {
|
|
27
|
+
(0, Affirm_1.default)(producer, 'Invalid producer');
|
|
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
|
+
switch (source.engine) {
|
|
31
|
+
case 'aws-redshift':
|
|
32
|
+
case 'postgres': {
|
|
33
|
+
const sql = SQLCompiler_1.default.compileProducer(producer, source);
|
|
34
|
+
(0, Affirm_1.default)(sql, `Invalid SQL from compilation for producer "${producer.name}"`);
|
|
35
|
+
return sql;
|
|
36
|
+
}
|
|
37
|
+
case 'aws-s3': {
|
|
38
|
+
const columns = FileCompiler_1.default.compileProducer(producer, source);
|
|
39
|
+
(0, Affirm_1.default)(columns, `Invalid columns from compilation for producer "${producer.name}"`);
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
default: throw new Error(`Invalid engine type "${source.engine}" for producer "${producer.name}": not implemented yet`);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
this.deploy = (producer) => __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
(0, Affirm_1.default)(producer, 'Invalid producer');
|
|
47
|
+
const source = Environment_1.default.getSource(producer.source);
|
|
48
|
+
(0, Affirm_1.default)(source, `No source found for producer "${producer.name}" with name "${producer.source}"`);
|
|
49
|
+
const driver = yield DriverFactory_1.default.instantiateSource(source);
|
|
50
|
+
(0, Affirm_1.default)(driver, `No driver found for producer "${producer.name}" with driver type "${source.engine}"`);
|
|
51
|
+
const plan = DeploymentPlanner_1.default.planProducer(producer);
|
|
52
|
+
for (const planStep of plan) {
|
|
53
|
+
switch (planStep.type) {
|
|
54
|
+
case 'create-view': {
|
|
55
|
+
const internalSchema = Environment_1.default.get('REMORA_SCHEMA');
|
|
56
|
+
(0, Affirm_1.default)(internalSchema, `Missing "REMORA_SCHEMA" on project settings (needed due to "${producer.name}" wanting to create a view)`);
|
|
57
|
+
const sql = SQLCompiler_1.default.compileProducer(producer, source);
|
|
58
|
+
const vSQL = `CREATE OR REPLACE VIEW "${internalSchema}"."${SQLUtils_1.default.viewName(producer.name)}" AS ${sql}`;
|
|
59
|
+
yield driver.execute(vSQL);
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
default: throw new Error(`Invalid execution consumer plan step type "${planStep.type}"`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
this.readFile = (producer, options) => __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
var _a;
|
|
68
|
+
(0, Affirm_1.default)(producer, 'Invalid producer');
|
|
69
|
+
(0, Affirm_1.default)(options, 'Invalid options');
|
|
70
|
+
if (options.readmode === 'lines')
|
|
71
|
+
(0, Affirm_1.default)(options.lines, 'Invalid lines');
|
|
72
|
+
const source = Environment_1.default.getSource(producer.source);
|
|
73
|
+
(0, Affirm_1.default)(source, `No source found for producer "${producer.name}" with name "${producer.source}"`);
|
|
74
|
+
const driver = yield DriverFactory_1.default.instantiateSource(source);
|
|
75
|
+
(0, Affirm_1.default)(driver, `No driver found for producer "${producer.name}" with driver type "${source.engine}"`);
|
|
76
|
+
const { settings: { fileKey, fileType, sheetName, hasHeaderRow } } = producer;
|
|
77
|
+
let dataset = DatasetManager_1.default.create(producer);
|
|
78
|
+
let lines = [];
|
|
79
|
+
switch (options.readmode) {
|
|
80
|
+
case 'lines':
|
|
81
|
+
lines = yield driver.readLinesInRange({ fileKey, fileType, options: { lineFrom: options.lines.from, lineTo: options.lines.to, sheetName, hasHeaderRow } });
|
|
82
|
+
break;
|
|
83
|
+
case 'all':
|
|
84
|
+
lines = yield driver.readAll({ fileKey, fileType, options: { sheetName, hasHeaderRow } });
|
|
85
|
+
break;
|
|
86
|
+
case 'download':
|
|
87
|
+
dataset = yield driver.download(dataset);
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
switch ((_a = producer.settings.fileType) === null || _a === void 0 ? void 0 : _a.toUpperCase()) {
|
|
91
|
+
case 'CSV':
|
|
92
|
+
case 'TXT':
|
|
93
|
+
return { data: lines, dataset, dataType: 'lines-of-text' };
|
|
94
|
+
case 'XLS':
|
|
95
|
+
case 'XLSX':
|
|
96
|
+
return { data: lines, dataset, dataType: 'lines-of-text' };
|
|
97
|
+
case 'JSONL':
|
|
98
|
+
case 'JSON': {
|
|
99
|
+
if (lines.length === 1) {
|
|
100
|
+
// Attempt to handle cases where a single line might contain multiple JSON objects separated by newlines
|
|
101
|
+
// Or if the entire file content is a single JSON array stringified.
|
|
102
|
+
try {
|
|
103
|
+
const parsedAsArray = JSON.parse(lines[0]);
|
|
104
|
+
if (Array.isArray(parsedAsArray)) {
|
|
105
|
+
return { data: parsedAsArray, dataset, dataType: 'array-of-json' };
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
// If parsing as array fails, proceed to split by newline
|
|
110
|
+
console.warn('Failed to parse single line as JSON array, splitting by newline:', error);
|
|
111
|
+
}
|
|
112
|
+
lines = lines[0].split('\\n');
|
|
113
|
+
}
|
|
114
|
+
const json = lines.filter(line => line.trim() !== '').map(x => JSON.parse(x));
|
|
115
|
+
return { data: json, dataset, dataType: 'array-of-json' };
|
|
116
|
+
}
|
|
117
|
+
case 'XML': {
|
|
118
|
+
// The driver's _readXmlLines method now returns an array of JSON strings.
|
|
119
|
+
// Each string needs to be parsed into a JSON object.
|
|
120
|
+
const json = lines.filter(line => line.trim() !== '').map(x => JSON.parse(x));
|
|
121
|
+
return { data: json, dataset, dataType: 'array-of-json' };
|
|
122
|
+
}
|
|
123
|
+
default:
|
|
124
|
+
throw new Error(`Invalid file type "${producer.settings.fileType}" for engine type "${source.engine}" for producer "${producer.name}": not supported`);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
this.readSampleData = (producer_1, ...args_1) => __awaiter(this, [producer_1, ...args_1], void 0, function* (producer, sampleSize = 10, discover = false) {
|
|
128
|
+
(0, Affirm_1.default)(producer, 'Invalid producer');
|
|
129
|
+
(0, Affirm_1.default)(sampleSize > 0, 'Sample size must be greater than 0');
|
|
130
|
+
const source = Environment_1.default.getSource(producer.source);
|
|
131
|
+
(0, Affirm_1.default)(source, `No source found for producer "${producer.name}" with name "${producer.source}"`);
|
|
132
|
+
let dataset = DatasetManager_1.default.create(producer);
|
|
133
|
+
switch (source.engine) {
|
|
134
|
+
case 'aws-redshift': {
|
|
135
|
+
const sql = `SELECT * FROM "${source.authentication['schema']}"."${producer.settings.sqlTable}" LIMIT ${sampleSize}`;
|
|
136
|
+
(0, Affirm_1.default)(sql, `Invalid SQL from deployment compilation for producer "${producer.name}"`);
|
|
137
|
+
const driver = yield DriverFactory_1.default.instantiateSource(source);
|
|
138
|
+
(0, Affirm_1.default)(driver, `No driver found for producer "${producer.name}" with driver type "${source.engine}"`);
|
|
139
|
+
const res = yield driver.query(sql);
|
|
140
|
+
dataset = yield dataset.loadFromMemory(res.rows, producer, discover);
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
case 'local':
|
|
144
|
+
case 'aws-s3': {
|
|
145
|
+
const fileData = yield this.readFile(producer, { readmode: 'lines', lines: { from: 0, to: sampleSize } });
|
|
146
|
+
dataset = yield dataset.loadFromMemory(fileData.data, producer, discover);
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
default:
|
|
150
|
+
throw new Error(`Invalid engine type "${source.engine}" for producer "${producer.name}": not supported`);
|
|
151
|
+
}
|
|
152
|
+
const sampleData = [...yield dataset.readLines(sampleSize)];
|
|
153
|
+
dataset.destroy();
|
|
154
|
+
Logger_1.default.log(`Finished reading sample dataset:\n${dataset.printStats()}`);
|
|
155
|
+
return sampleData;
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
const ProducerEngine = new ProducerEngineClass();
|
|
160
|
+
exports.default = ProducerEngine;
|
|
@@ -0,0 +1,28 @@
|
|
|
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.getMask = (dimension) => {
|
|
11
|
+
if (!dimension || !dimension.mask)
|
|
12
|
+
return null;
|
|
13
|
+
const mask = SecretManager_1.default.replaceSecret(dimension.mask);
|
|
14
|
+
const allowedMaskValues = [
|
|
15
|
+
'hash',
|
|
16
|
+
'mask',
|
|
17
|
+
'crypt',
|
|
18
|
+
'random',
|
|
19
|
+
'seeded-random',
|
|
20
|
+
'none'
|
|
21
|
+
];
|
|
22
|
+
(0, Affirm_1.default)(allowedMaskValues.includes(mask), `Mask value "${mask}" in dimension "${dimension.name}" is not a valid value.`);
|
|
23
|
+
return mask;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const ProducerManager = new ProducerManagerClass();
|
|
28
|
+
exports.default = ProducerManager;
|
|
@@ -8,6 +8,7 @@ const Algo_1 = __importDefault(require("../../core/Algo"));
|
|
|
8
8
|
const ConsumerEngine_1 = __importDefault(require("../consumer/ConsumerEngine"));
|
|
9
9
|
const CryptoEngine_1 = __importDefault(require("../CryptoEngine"));
|
|
10
10
|
const Environment_1 = __importDefault(require("../Environment"));
|
|
11
|
+
const ProducerManager_1 = __importDefault(require("../producer/ProducerManager"));
|
|
11
12
|
const SQLUtils_1 = __importDefault(require("../sql/SQLUtils"));
|
|
12
13
|
class SQLCompilerClass {
|
|
13
14
|
constructor() {
|
|
@@ -23,10 +24,10 @@ class SQLCompilerClass {
|
|
|
23
24
|
(0, Affirm_1.default)(producer.settings.sqlTable, `Misconfiguration for producer "${producer.name}": SQL table name is missing. Required since no override to the SQL was used.`);
|
|
24
25
|
const dimensions = producer.dimensions.map(x => {
|
|
25
26
|
var _a;
|
|
26
|
-
const maskType = x
|
|
27
|
+
const maskType = ProducerManager_1.default.getMask(x);
|
|
27
28
|
const columnReference = (_a = x.alias) !== null && _a !== void 0 ? _a : x.name;
|
|
28
29
|
const fieldReference = `"${producer.settings.sqlTable}"."${columnReference}"`;
|
|
29
|
-
if (
|
|
30
|
+
if (maskType && maskType === 'hash')
|
|
30
31
|
return CryptoEngine_1.default.hashQuery(maskType, fieldReference, x.name);
|
|
31
32
|
else
|
|
32
33
|
return `${fieldReference} AS "${x.name}"`;
|