@forzalabs/remora 1.0.22 → 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.
Files changed (111) hide show
  1. package/actions/automap.js +26 -42
  2. package/actions/compile.js +27 -43
  3. package/actions/create_consumer.js +24 -40
  4. package/actions/create_producer.js +16 -32
  5. package/actions/debug.js +18 -34
  6. package/actions/deploy.js +30 -46
  7. package/actions/discover.js +13 -29
  8. package/actions/init.js +29 -45
  9. package/actions/mock.js +16 -32
  10. package/actions/run.js +34 -52
  11. package/actions/sample.js +42 -58
  12. package/index.js +109 -119
  13. package/package.json +4 -4
  14. package/workers/ExecutorWorker.js +18 -34
  15. package/Constants.js +0 -34
  16. package/core/Affirm.js +0 -42
  17. package/core/Algo.js +0 -160
  18. package/core/dste/DSTE.js +0 -113
  19. package/core/logger/DebugLogService.js +0 -48
  20. package/core/logger/DevelopmentLogService.js +0 -70
  21. package/core/logger/LocalLogService.js +0 -70
  22. package/core/logger/Logger.js +0 -54
  23. package/database/DatabaseEngine.js +0 -149
  24. package/database/DatabaseStructure.js +0 -27
  25. package/definitions/DatasetDefinitions.js +0 -2
  26. package/definitions/ExecutorDefinitions.js +0 -2
  27. package/definitions/ProcessENV.js +0 -169
  28. package/definitions/agents/DestinationDriver.js +0 -2
  29. package/definitions/agents/SourceDriver.js +0 -2
  30. package/definitions/cli.js +0 -2
  31. package/definitions/database/ApiKeys.js +0 -2
  32. package/definitions/database/Stored.js +0 -7
  33. package/definitions/database/UsageStat.js +0 -2
  34. package/definitions/database/User.js +0 -2
  35. package/definitions/json_schemas/consumer-schema.json +0 -1226
  36. package/definitions/json_schemas/producer-schema.json +0 -308
  37. package/definitions/json_schemas/project-schema.json +0 -100
  38. package/definitions/json_schemas/source-schema.json +0 -249
  39. package/definitions/requests/ConsumerRequest.js +0 -2
  40. package/definitions/requests/Developer.js +0 -2
  41. package/definitions/requests/Mapping.js +0 -2
  42. package/definitions/requests/ProducerRequest.js +0 -2
  43. package/definitions/requests/Request.js +0 -2
  44. package/definitions/resources/Compiled.js +0 -2
  45. package/definitions/resources/Consumer.js +0 -2
  46. package/definitions/resources/Environment.js +0 -2
  47. package/definitions/resources/Library.js +0 -2
  48. package/definitions/resources/Producer.js +0 -2
  49. package/definitions/resources/Project.js +0 -2
  50. package/definitions/resources/Schema.js +0 -2
  51. package/definitions/resources/Source.js +0 -2
  52. package/definitions/temp.js +0 -2
  53. package/definitions/transform/Transformations.js +0 -2
  54. package/drivers/DeltaShareDriver.js +0 -186
  55. package/drivers/DriverFactory.js +0 -72
  56. package/drivers/DriverHelper.js +0 -248
  57. package/drivers/HttpApiDriver.js +0 -208
  58. package/drivers/RedshiftDriver.js +0 -184
  59. package/drivers/files/LocalDestinationDriver.js +0 -146
  60. package/drivers/files/LocalSourceDriver.js +0 -405
  61. package/drivers/s3/S3DestinationDriver.js +0 -197
  62. package/drivers/s3/S3SourceDriver.js +0 -495
  63. package/engines/CryptoEngine.js +0 -75
  64. package/engines/Environment.js +0 -170
  65. package/engines/ProcessENVManager.js +0 -112
  66. package/engines/RandomEngine.js +0 -47
  67. package/engines/SecretManager.js +0 -23
  68. package/engines/UserManager.js +0 -66
  69. package/engines/ai/AutoMapperEngine.js +0 -37
  70. package/engines/ai/DeveloperEngine.js +0 -497
  71. package/engines/ai/LLM.js +0 -255
  72. package/engines/consumer/ConsumerManager.js +0 -218
  73. package/engines/consumer/ConsumerOnFinishManager.js +0 -202
  74. package/engines/dataset/Dataset.js +0 -824
  75. package/engines/dataset/DatasetManager.js +0 -211
  76. package/engines/dataset/DatasetRecord.js +0 -120
  77. package/engines/dataset/DatasetRecordPool.js +0 -77
  78. package/engines/execution/RequestExecutor.js +0 -67
  79. package/engines/parsing/CSVParser.js +0 -60
  80. package/engines/parsing/LineParser.js +0 -71
  81. package/engines/parsing/ParseCompression.js +0 -101
  82. package/engines/parsing/ParseHelper.js +0 -18
  83. package/engines/parsing/ParseManager.js +0 -54
  84. package/engines/parsing/XLSParser.js +0 -87
  85. package/engines/parsing/XMLParser.js +0 -115
  86. package/engines/producer/ProducerEngine.js +0 -127
  87. package/engines/producer/ProducerManager.js +0 -43
  88. package/engines/scheduler/CronScheduler.js +0 -222
  89. package/engines/scheduler/QueueManager.js +0 -314
  90. package/engines/schema/SchemaValidator.js +0 -67
  91. package/engines/transform/JoinEngine.js +0 -232
  92. package/engines/transform/TransformationEngine.js +0 -277
  93. package/engines/transform/TypeCaster.js +0 -59
  94. package/engines/usage/DataframeManager.js +0 -55
  95. package/engines/usage/UsageDataManager.js +0 -151
  96. package/engines/usage/UsageManager.js +0 -65
  97. package/engines/validation/Validator.js +0 -216
  98. package/executors/ConsumerExecutor.js +0 -280
  99. package/executors/Executor.js +0 -177
  100. package/executors/ExecutorOrchestrator.js +0 -331
  101. package/executors/ExecutorPerformance.js +0 -17
  102. package/executors/ExecutorProgress.js +0 -54
  103. package/executors/ExecutorScope.js +0 -52
  104. package/executors/OutputExecutor.js +0 -118
  105. package/executors/ProducerExecutor.js +0 -108
  106. package/helper/Helper.js +0 -149
  107. package/helper/Logger.js +0 -84
  108. package/helper/Runtime.js +0 -20
  109. package/helper/Settings.js +0 -13
  110. package/licencing/LicenceManager.js +0 -64
  111. package/settings.js +0 -12
@@ -1,170 +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 fs_1 = __importDefault(require("fs"));
7
- const path_1 = __importDefault(require("path"));
8
- const Affirm_1 = __importDefault(require("../core/Affirm"));
9
- const SchemaValidator_1 = __importDefault(require("./schema/SchemaValidator"));
10
- const Validator_1 = __importDefault(require("./validation/Validator"));
11
- const Constants_1 = __importDefault(require("../Constants"));
12
- const Logger_1 = __importDefault(require("../helper/Logger"));
13
- class EnvironmentClass {
14
- constructor() {
15
- this._env = null;
16
- this.load = (remoraPath) => {
17
- const envPath = path_1.default.join(remoraPath, 'remora');
18
- // Read and parse project.json
19
- const projectPath = path_1.default.join(envPath, 'project.json');
20
- if (!fs_1.default.existsSync(projectPath))
21
- throw new Error('Project configuration file not found');
22
- const projectConfig = JSON.parse(fs_1.default.readFileSync(projectPath, 'utf-8'));
23
- // Validate project schema
24
- const isValid = SchemaValidator_1.default.validate('project-schema', projectConfig);
25
- if (!isValid)
26
- throw new Error('Invalid project configuration');
27
- const loadConfigurations = (basePath, paths) => {
28
- const configs = [];
29
- for (const configPath of paths) {
30
- const fullPath = path_1.default.join(basePath, configPath);
31
- try {
32
- if (fs_1.default.statSync(fullPath).isDirectory()) {
33
- const files = fs_1.default.readdirSync(fullPath).filter(file => file.endsWith('.json'));
34
- for (const file of files) {
35
- const config = JSON.parse(fs_1.default.readFileSync(path_1.default.join(fullPath, file), 'utf-8'));
36
- configs.push(config);
37
- }
38
- }
39
- else {
40
- const config = JSON.parse(fs_1.default.readFileSync(fullPath, 'utf-8'));
41
- configs.push(config);
42
- }
43
- }
44
- catch (error) {
45
- throw new Error(`Error loading from ${path_1.default.resolve(remoraPath)} configuration from ${configPath}: ${error.message}`);
46
- }
47
- }
48
- return configs;
49
- };
50
- // Unload all the schemes other than the default ones, because otherwise the RW could keep loaded schemes not saved in the remora folder
51
- SchemaValidator_1.default.unloadSchemas();
52
- // Load all schemas first since they're needed for validation
53
- const schemas = loadConfigurations(envPath, projectConfig.schemas);
54
- schemas.forEach(schema => {
55
- SchemaValidator_1.default.addSchema(schema, schema.title);
56
- });
57
- // Load configurations with validation
58
- const sources = loadConfigurations(envPath, projectConfig.sources);
59
- sources.forEach(source => {
60
- if (!SchemaValidator_1.default.validate('source-schema', source))
61
- throw new Error(`Invalid source configuration: ${source.name}`);
62
- });
63
- const producers = loadConfigurations(envPath, projectConfig.producers);
64
- producers.forEach(producer => {
65
- if (!SchemaValidator_1.default.validate('producer-schema', producer))
66
- throw new Error(`Invalid producer configuration: ${producer.name}`);
67
- });
68
- const consumers = loadConfigurations(envPath, projectConfig.consumers);
69
- consumers.forEach(consumer => {
70
- if (!SchemaValidator_1.default.validate('consumer-schema', consumer))
71
- throw new Error(`Invalid consumer configuration: ${consumer.name}`);
72
- });
73
- // Load the project settings
74
- const envSettings = new Map(Object.entries(Object.assign({}, projectConfig.settings))
75
- .map(([key, value]) => [key, String(value)]));
76
- if (!envSettings.has('SQL_MAX_QUERY_ROWS'))
77
- envSettings.set('SQL_MAX_QUERY_ROWS', Constants_1.default.defaults.SQL_MAX_QUERY_ROWS.toString());
78
- if (!envSettings.has('STRING_MAX_CHARACTERS_LENGTH'))
79
- envSettings.set('STRING_MAX_CHARACTERS_LENGTH', Constants_1.default.defaults.STRING_MAX_CHARACTERS_LENGTH.toString());
80
- if (!envSettings.has('MAX_ITEMS_IN_MEMORY'))
81
- envSettings.set('MAX_ITEMS_IN_MEMORY', Constants_1.default.defaults.MAX_ITEMS_IN_MEMORY.toString());
82
- const debugMode = envSettings.get('DEBUG_MODE');
83
- try {
84
- if (debugMode && debugMode.length > 0 && JSON.parse(debugMode) === true)
85
- Logger_1.default.setLevel('debug');
86
- }
87
- catch (_a) {
88
- console.warn(`Invalid project setting "DEBUG_MODE" (${debugMode})`);
89
- }
90
- // Initialize environment
91
- this.init({
92
- settings: envSettings,
93
- sources,
94
- producers,
95
- consumers,
96
- schemas,
97
- sqlLibrary: [] // TODO: Add SQL library loading if needed
98
- });
99
- };
100
- this.init = (env) => {
101
- this._env = env;
102
- };
103
- this.get = (setting) => {
104
- return this._env.settings.get(setting);
105
- };
106
- this.getSource = (sourceName) => {
107
- (0, Affirm_1.default)(sourceName, 'Invalid source name');
108
- return this._env.sources.find(x => x.name === sourceName);
109
- };
110
- /**
111
- * A consumer can reference another consumer, in this case I need to keep digging to find the real producer
112
- */
113
- this.getFirstProducer = (producerName) => {
114
- (0, Affirm_1.default)(producerName, `Invalid producer name`);
115
- const prod = this._env.producers.find(x => x.name.toLocaleLowerCase() === producerName.toLowerCase());
116
- if (!prod) {
117
- const consumer = this.getConsumer(producerName);
118
- (0, Affirm_1.default)(consumer, `Invalid producer name`);
119
- return this.getFirstProducer(consumer.producers[0].name);
120
- }
121
- return prod;
122
- };
123
- this.getProducer = (producerName) => {
124
- (0, Affirm_1.default)(producerName, `Invalid producer name`);
125
- return this._env.producers.find(x => x.name.toLowerCase() === producerName.toLowerCase());
126
- };
127
- this.getConsumer = (consumerName) => {
128
- (0, Affirm_1.default)(consumerName, `Invalid consumer name`);
129
- return this._env.consumers.find(x => x.name.toLowerCase() === consumerName.toLowerCase());
130
- };
131
- this.getAllConsumers = () => {
132
- (0, Affirm_1.default)(this._env, 'Environment not initialized');
133
- return this._env.consumers || [];
134
- };
135
- this.getSchema = (schemaName) => {
136
- (0, Affirm_1.default)(schemaName, 'Invalid schema name');
137
- return this._env.schemas.find(x => x.title === schemaName);
138
- };
139
- this.getSqlInLibrary = (name) => {
140
- (0, Affirm_1.default)(name, `Invalid sql library item name`);
141
- return this._env.sqlLibrary.find(x => x.name === name);
142
- };
143
- this.validate = () => {
144
- (0, Affirm_1.default)(this._env, 'Invalid environment');
145
- let errors = [];
146
- try {
147
- errors = [...errors, ...Validator_1.default.validateSources(this._env.sources)];
148
- errors = [...errors, ...Validator_1.default.validateProducers(this._env.producers)];
149
- this._env.producers.forEach(prod => {
150
- const ce = Validator_1.default.validateProducer(prod);
151
- if (ce.length > 0)
152
- errors.push(`Producer "${prod.name}" errors:\n${ce.map(x => `\t-${x}\n`)}`);
153
- });
154
- errors = [...errors, ...Validator_1.default.validateConsumers(this._env.consumers)];
155
- this._env.consumers.forEach(cons => {
156
- const ce = Validator_1.default.validateConsumer(cons);
157
- if (ce.length > 0)
158
- errors.push(`Consumer "${cons.name}" errors:\n${ce.map(x => `\t-${x}\n`)}`);
159
- });
160
- }
161
- catch (e) {
162
- if (errors.length === 0)
163
- errors.push(`There was an error in the validation Environment. (error: ${e})`);
164
- }
165
- return errors;
166
- };
167
- }
168
- }
169
- const Environment = new EnvironmentClass();
170
- exports.default = Environment;
@@ -1,112 +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 process_1 = __importDefault(require("process"));
50
- const Affirm_1 = __importDefault(require("../core/Affirm"));
51
- const ProcessENV_1 = require("../definitions/ProcessENV");
52
- const Algo_1 = __importDefault(require("../core/Algo"));
53
- const Logger_1 = __importDefault(require("../helper/Logger"));
54
- class ProcessENVManagerClass {
55
- constructor() {
56
- this._USER_ACCEPTED_ENV_VARIABLE_BEGINNING = 'REMORA';
57
- /**
58
- * Load the environment variables in the manager.
59
- * WARN: call this after the environment has been setup (after the process.env variables have been loaded).
60
- */
61
- this.init = () => __awaiter(this, void 0, void 0, function* () {
62
- const appName = process_1.default.env.REMORA_APP;
63
- (0, Affirm_1.default)(appName, `Missing REMORA_APP in the environment variables. Add the environment variable REMORA_APP=<cli | worker | backend | frontend> depending on the app you are running.`);
64
- this._loadedVariables = {};
65
- for (const variable of ProcessENV_1.REMORA_ENV_VARIABLES) {
66
- if (variable.apps.some(x => x.name === appName)) {
67
- const { apps, name } = variable;
68
- const app = apps.find(x => x.name === appName);
69
- const value = this._loadEnvVarValue(name);
70
- if (app.required && !Algo_1.default.hasVal(value))
71
- throw new Error(`Missing required Remora environment variable: ${variable}`);
72
- this._loadedVariables[name] = value;
73
- }
74
- }
75
- const userRemoraEnvVariables = Object.keys(process_1.default.env)
76
- .filter(x => x.startsWith(this._USER_ACCEPTED_ENV_VARIABLE_BEGINNING))
77
- .map(x => ({ name: x, value: process_1.default.env[x] }));
78
- for (const envVar of userRemoraEnvVariables) {
79
- const varName = envVar.name;
80
- this._loadedVariables[varName] = this._loadEnvVarValue(varName);
81
- }
82
- });
83
- this._loadEnvVarValue = (varName) => {
84
- if (process_1.default.env[varName] && process_1.default.env[varName].includes('run/secrets/'))
85
- return fs.readFileSync(process_1.default.env[varName], 'utf-8');
86
- else
87
- return process_1.default.env[varName];
88
- };
89
- /**
90
- * Get the value of an environment variable and give an error/warn if not implemented.
91
- * @param variable The name of the environment variable desired (usually all UPPER_CASE)
92
- * @returns The value of environment variable
93
- */
94
- this.getEnvVariable = (variable) => {
95
- (0, Affirm_1.default)(variable, `Cannot read an undefined env variable`);
96
- if (!Algo_1.default.hasVal(this._loadedVariables)) {
97
- Logger_1.default.log(`Trying to read an environment variable (${variable}) before initializing the env manager.`);
98
- return null;
99
- }
100
- const result = this._loadedVariables[variable];
101
- if (Algo_1.default.hasVal(result)) {
102
- return result;
103
- }
104
- else {
105
- console.warn(`Trying to read an environment variable that was not found: ${variable}`);
106
- return undefined;
107
- }
108
- };
109
- }
110
- }
111
- const ProcessENVManager = new ProcessENVManagerClass();
112
- exports.default = ProcessENVManager;
@@ -1,47 +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 seedrandom_1 = __importDefault(require("seedrandom"));
7
- const Algo_1 = __importDefault(require("../core/Algo"));
8
- class RandomEngineClass {
9
- constructor() {
10
- this.rng = (min, max) => {
11
- const rng = Math.random;
12
- if (Algo_1.default.hasVal(min) || Algo_1.default.hasVal(max))
13
- return Math.floor(rng() * (max - min + 1)) + min;
14
- else
15
- return rng();
16
- };
17
- this.sRng = (seed, min, max) => {
18
- const rng = (0, seedrandom_1.default)(String(seed));
19
- if (Algo_1.default.hasVal(min) || Algo_1.default.hasVal(max))
20
- return Math.floor(rng() * (max - min + 1)) + min;
21
- else
22
- return rng();
23
- };
24
- this.rngDate = (min, max) => {
25
- let myMin = min;
26
- let myMax = max;
27
- if (!Algo_1.default.hasVal(min) && !Algo_1.default.hasVal(max)) {
28
- myMin = new Date('1900-01-01').getTime();
29
- myMax = new Date().getTime();
30
- }
31
- const randomNumber = this.rng(myMin, myMax);
32
- return new Date(randomNumber).toJSON();
33
- };
34
- this.sRngDate = (seed, min, max) => {
35
- let myMin = min;
36
- let myMax = max;
37
- if (!Algo_1.default.hasVal(min) && !Algo_1.default.hasVal(max)) {
38
- myMin = new Date('1900-01-01').getTime();
39
- myMax = new Date().getTime();
40
- }
41
- const randomNumber = this.sRng(seed, myMin, myMax);
42
- return new Date(randomNumber).toJSON();
43
- };
44
- }
45
- }
46
- const RandomEngine = new RandomEngineClass();
47
- exports.default = RandomEngine;
@@ -1,23 +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 ProcessENVManager_1 = __importDefault(require("./ProcessENVManager"));
7
- class SecretManagerClass {
8
- constructor() {
9
- /**
10
- * If the value is a secret (or .env setting), replace it with the value inside the .env configuration file
11
- * Starts with "{" and ends with "}".
12
- * e.g. {AWS_ID}
13
- */
14
- this.replaceSecret = (value) => {
15
- if (!value || value.length <= 2 || !value.startsWith('{') || !value.endsWith('}'))
16
- return value;
17
- const parsedValue = value.slice(1, value.length - 1);
18
- return ProcessENVManager_1.default.getEnvVariable(parsedValue);
19
- };
20
- }
21
- }
22
- const SecretManager = new SecretManagerClass();
23
- exports.default = SecretManager;
@@ -1,66 +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 DatabaseEngine_1 = __importDefault(require("../database/DatabaseEngine"));
16
- const Helper_1 = __importDefault(require("../helper/Helper"));
17
- const Settings_1 = __importDefault(require("../helper/Settings"));
18
- class UserManagerClass {
19
- constructor() {
20
- this.getUser = () => {
21
- if (Helper_1.default.isDev())
22
- return DEV_USER;
23
- else
24
- return MOCK_USER;
25
- // TODO: figure out how to handle users
26
- };
27
- this.getRemoraWorkerUser = () => {
28
- const remora = {
29
- _id: '__remora_worker__',
30
- auth: { oid: '', provider: 'internal' },
31
- email: '',
32
- name: 'Remora Worker',
33
- roles: ['root'],
34
- _signature: '',
35
- lastLogin: new Date().toJSON()
36
- };
37
- return remora;
38
- };
39
- this.findOIDC = (oid) => __awaiter(this, void 0, void 0, function* () {
40
- return yield DatabaseEngine_1.default.findOne(Settings_1.default.db.collections.users, { 'auth.oid': oid });
41
- });
42
- this.update = (user) => __awaiter(this, void 0, void 0, function* () {
43
- return yield DatabaseEngine_1.default.upsert(Settings_1.default.db.collections.users, user._id, user);
44
- });
45
- }
46
- }
47
- const UserManager = new UserManagerClass();
48
- exports.default = UserManager;
49
- const DEV_USER = {
50
- _id: '__dev__',
51
- auth: { oid: '', provider: 'azure' },
52
- email: '',
53
- name: 'Dev',
54
- roles: ['admin'],
55
- _signature: '',
56
- lastLogin: new Date().toJSON()
57
- };
58
- const MOCK_USER = {
59
- _id: '__mock__',
60
- auth: { oid: '', provider: 'azure' },
61
- email: 'mock.user@email.com',
62
- name: 'Mock User',
63
- roles: ['user'],
64
- _signature: '',
65
- lastLogin: new Date().toJSON()
66
- };
@@ -1,37 +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 LLM_1 = __importDefault(require("./LLM"));
17
- class AutoMapperEngineClass {
18
- constructor() {
19
- /**
20
- * input: the first ten lines of the uploaded file
21
- * outputs: the selected schemas
22
- */
23
- this.map = (input, outputs, fileName, sources) => __awaiter(this, void 0, void 0, function* () {
24
- (0, Affirm_1.default)(input, 'Invalid input');
25
- (0, Affirm_1.default)(outputs, 'Invalid outputs');
26
- const llm = new LLM_1.default();
27
- const producersRes = yield llm.inferProducers(input, outputs, fileName, sources);
28
- const consumersRes = yield llm.inferConsumers(producersRes.producers, outputs);
29
- return {
30
- consumers: consumersRes.consumers,
31
- producers: producersRes.producers
32
- };
33
- });
34
- }
35
- }
36
- const AutoMapperEngine = new AutoMapperEngineClass();
37
- exports.default = AutoMapperEngine;