exodus-framework 2.0.953 → 2.0.955

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 (114) hide show
  1. package/lib/app/settings.d.ts.map +1 -1
  2. package/lib/contracts/settings.d.ts +1 -2
  3. package/lib/contracts/settings.d.ts.map +1 -1
  4. package/lib/services/database.d.ts +2 -0
  5. package/lib/services/database.d.ts.map +1 -1
  6. package/lib/services/sequelize.d.ts +0 -1
  7. package/lib/services/sequelize.d.ts.map +1 -1
  8. package/lib/utils/database.d.ts +1 -2
  9. package/lib/utils/database.d.ts.map +1 -1
  10. package/package.json +1 -1
  11. package/lib/app/classes/broadcast.js +0 -79
  12. package/lib/app/classes/cache.js +0 -94
  13. package/lib/app/classes/communication.js +0 -99
  14. package/lib/app/classes/communicationcontext.js +0 -1
  15. package/lib/app/classes/event.js +0 -94
  16. package/lib/app/classes/index.js +0 -105
  17. package/lib/app/classes/managed.js +0 -145
  18. package/lib/app/classes/service.js +0 -232
  19. package/lib/app/classes/servicemodel.js +0 -22
  20. package/lib/app/classes/singleton.js +0 -26
  21. package/lib/app/classes/socket/clienthandler.js +0 -54
  22. package/lib/app/classes/socket/eventhandler.js +0 -51
  23. package/lib/app/classes/socket/index.js +0 -20
  24. package/lib/app/classes/system.js +0 -49
  25. package/lib/app/controller.js +0 -97
  26. package/lib/app/core.js +0 -47
  27. package/lib/app/error.js +0 -66
  28. package/lib/app/exodus.js +0 -97
  29. package/lib/app/index.js +0 -68
  30. package/lib/app/settings.js +0 -162
  31. package/lib/certificates/private_key.pem +0 -27
  32. package/lib/certificates/public_key.pem +0 -9
  33. package/lib/contracts/communication/communication.js +0 -39
  34. package/lib/contracts/communication/index.js +0 -27
  35. package/lib/contracts/communication/operation.js +0 -5
  36. package/lib/contracts/console.js +0 -5
  37. package/lib/contracts/contansts.js +0 -13
  38. package/lib/contracts/core.js +0 -12
  39. package/lib/contracts/entity.js +0 -5
  40. package/lib/contracts/http.js +0 -52
  41. package/lib/contracts/index.js +0 -104
  42. package/lib/contracts/messaging.js +0 -50
  43. package/lib/contracts/security.js +0 -5
  44. package/lib/contracts/service.js +0 -11
  45. package/lib/contracts/session.js +0 -5
  46. package/lib/contracts/settings.js +0 -5
  47. package/lib/contracts/singleton.js +0 -5
  48. package/lib/contracts/socket.js +0 -11
  49. package/lib/contracts/tasks.js +0 -1
  50. package/lib/controllers/api/file.js +0 -24
  51. package/lib/controllers/api/index.js +0 -13
  52. package/lib/controllers/api/log.js +0 -55
  53. package/lib/controllers/api/report.js +0 -55
  54. package/lib/controllers/index.js +0 -16
  55. package/lib/controllers/messaging/application.js +0 -75
  56. package/lib/controllers/messaging/database.js +0 -64
  57. package/lib/controllers/messaging/environment.js +0 -111
  58. package/lib/express.d.js +0 -5
  59. package/lib/index.js +0 -104
  60. package/lib/middlewares/access.js +0 -114
  61. package/lib/middlewares/authentication.js +0 -104
  62. package/lib/middlewares/file.js +0 -41
  63. package/lib/middlewares/index.js +0 -36
  64. package/lib/models/Application.js +0 -65
  65. package/lib/models/DatabaseHost.js +0 -62
  66. package/lib/models/EnvConnection.js +0 -41
  67. package/lib/models/Log.js +0 -67
  68. package/lib/models/Report.js +0 -65
  69. package/lib/models/System.js +0 -54
  70. package/lib/models/index.js +0 -82
  71. package/lib/routes/api/index.js +0 -16
  72. package/lib/routes/api/v1/index.js +0 -38
  73. package/lib/routes/api/v1/logs.js +0 -19
  74. package/lib/routes/api/v1/report.js +0 -19
  75. package/lib/routes/api/v1/sse.js +0 -36
  76. package/lib/routes/index.js +0 -27
  77. package/lib/routes/messaging/index.js +0 -34
  78. package/lib/services/database.js +0 -115
  79. package/lib/services/ecosystem.js +0 -46
  80. package/lib/services/express.js +0 -162
  81. package/lib/services/file.js +0 -65
  82. package/lib/services/file_new.js +0 -136
  83. package/lib/services/index.js +0 -108
  84. package/lib/services/log.js +0 -26
  85. package/lib/services/rabitmq.js +0 -187
  86. package/lib/services/redis.js +0 -84
  87. package/lib/services/security.js +0 -231
  88. package/lib/services/sequelize.js +0 -323
  89. package/lib/services/socket.js +0 -123
  90. package/lib/services/task/TaskServiceBase.js +0 -17
  91. package/lib/services/task/index.js +0 -40
  92. package/lib/services/task/queue/QueueService.js +0 -48
  93. package/lib/services/task/queue/QueueTask.js +0 -134
  94. package/lib/services/task/queue/SingleQueue.js +0 -68
  95. package/lib/services/task/queue/index.js +0 -27
  96. package/lib/services/task/scheduler/SchedulerService.js +0 -31
  97. package/lib/services/task/scheduler/SchedulerTask.js +0 -211
  98. package/lib/services/task/scheduler/index.js +0 -20
  99. package/lib/services/test.js +0 -27
  100. package/lib/socket.d.js +0 -3
  101. package/lib/tasks/index.js +0 -27
  102. package/lib/tasks/queue/application.js +0 -44
  103. package/lib/tasks/queue/environment.js +0 -92
  104. package/lib/tasks/queue/index.js +0 -20
  105. package/lib/tasks/queue/teste.js +0 -21
  106. package/lib/tasks/schedule/index.js +0 -13
  107. package/lib/tasks/schedule/restart.js +0 -19
  108. package/lib/tasks/schedule/teste.js +0 -61
  109. package/lib/utils/api.js +0 -65
  110. package/lib/utils/database.js +0 -155
  111. package/lib/utils/date.js +0 -28
  112. package/lib/utils/index.js +0 -60
  113. package/lib/utils/logger.js +0 -51
  114. package/lib/utils/session.js +0 -23
@@ -1,65 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.Report = void 0;
7
- var _sequelize = require("sequelize");
8
- var _servicemodel = _interopRequireDefault(require("../app/classes/servicemodel"));
9
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
- class Report extends _servicemodel.default {
11
- static getConnParams() {
12
- return {
13
- tableName: 'reports',
14
- indexes: [{
15
- fields: ['category']
16
- }, {
17
- fields: ['description']
18
- }, {
19
- fields: ['file']
20
- }]
21
- };
22
- }
23
- static getEntityParams() {
24
- return {
25
- uuid: {
26
- type: _sequelize.DataTypes.UUID,
27
- defaultValue: _sequelize.DataTypes.UUIDV4,
28
- primaryKey: true,
29
- allowNull: false,
30
- autoIncrement: false
31
- },
32
- category: {
33
- type: _sequelize.DataTypes.STRING(100),
34
- allowNull: false
35
- },
36
- origin: {
37
- type: _sequelize.DataTypes.STRING(100),
38
- allowNull: false
39
- },
40
- description: {
41
- type: _sequelize.DataTypes.STRING(255),
42
- allowNull: true
43
- },
44
- file: {
45
- type: _sequelize.DataTypes.STRING(255),
46
- allowNull: true
47
- },
48
- total: {
49
- type: _sequelize.DataTypes.INTEGER(),
50
- allowNull: true
51
- },
52
- params: {
53
- type: _sequelize.DataTypes.JSON,
54
- defaultValue: {},
55
- allowNull: true
56
- },
57
- status: {
58
- type: _sequelize.DataTypes.ENUM('PENDING', 'COMPLETED'),
59
- allowNull: false,
60
- defaultValue: 'PENDING'
61
- }
62
- };
63
- }
64
- }
65
- exports.Report = Report;
@@ -1,54 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.System = void 0;
7
- var _sequelize = require("sequelize");
8
- var _database = require("../utils/database");
9
- var _servicemodel = _interopRequireDefault(require("../app/classes/servicemodel"));
10
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
- class System extends _servicemodel.default {
12
- static getConnParams() {
13
- return {
14
- tableName: 'system',
15
- sequelize: _database.serviceDB,
16
- indexes: [{
17
- fields: ['key']
18
- }, {
19
- fields: ['value']
20
- }, {
21
- fields: ['comments']
22
- }]
23
- };
24
- }
25
- static getEntityParams() {
26
- return {
27
- uuid: {
28
- type: _sequelize.DataTypes.UUID,
29
- defaultValue: _sequelize.DataTypes.UUIDV4,
30
- primaryKey: true,
31
- allowNull: false,
32
- autoIncrement: false
33
- },
34
- key: {
35
- type: _sequelize.DataTypes.STRING(100),
36
- allowNull: false
37
- },
38
- value: {
39
- type: _sequelize.DataTypes.STRING(255),
40
- allowNull: false
41
- },
42
- comments: {
43
- type: _sequelize.DataTypes.STRING(255),
44
- allowNull: true
45
- },
46
- data: {
47
- type: _sequelize.DataTypes.JSON,
48
- defaultValue: {},
49
- allowNull: true
50
- }
51
- };
52
- }
53
- }
54
- exports.System = System;
@@ -1,82 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _exportNames = {
7
- NativeModels: true
8
- };
9
- exports.NativeModels = void 0;
10
- var _Log = require("./Log");
11
- Object.keys(_Log).forEach(function (key) {
12
- if (key === "default" || key === "__esModule") return;
13
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
14
- if (key in exports && exports[key] === _Log[key]) return;
15
- Object.defineProperty(exports, key, {
16
- enumerable: true,
17
- get: function () {
18
- return _Log[key];
19
- }
20
- });
21
- });
22
- var _System = require("./System");
23
- Object.keys(_System).forEach(function (key) {
24
- if (key === "default" || key === "__esModule") return;
25
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
26
- if (key in exports && exports[key] === _System[key]) return;
27
- Object.defineProperty(exports, key, {
28
- enumerable: true,
29
- get: function () {
30
- return _System[key];
31
- }
32
- });
33
- });
34
- var _Report = require("./Report");
35
- Object.keys(_Report).forEach(function (key) {
36
- if (key === "default" || key === "__esModule") return;
37
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
38
- if (key in exports && exports[key] === _Report[key]) return;
39
- Object.defineProperty(exports, key, {
40
- enumerable: true,
41
- get: function () {
42
- return _Report[key];
43
- }
44
- });
45
- });
46
- var _Application = require("./Application");
47
- Object.keys(_Application).forEach(function (key) {
48
- if (key === "default" || key === "__esModule") return;
49
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
50
- if (key in exports && exports[key] === _Application[key]) return;
51
- Object.defineProperty(exports, key, {
52
- enumerable: true,
53
- get: function () {
54
- return _Application[key];
55
- }
56
- });
57
- });
58
- var _DatabaseHost = require("./DatabaseHost");
59
- Object.keys(_DatabaseHost).forEach(function (key) {
60
- if (key === "default" || key === "__esModule") return;
61
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
62
- if (key in exports && exports[key] === _DatabaseHost[key]) return;
63
- Object.defineProperty(exports, key, {
64
- enumerable: true,
65
- get: function () {
66
- return _DatabaseHost[key];
67
- }
68
- });
69
- });
70
- var _EnvConnection = require("./EnvConnection");
71
- Object.keys(_EnvConnection).forEach(function (key) {
72
- if (key === "default" || key === "__esModule") return;
73
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
74
- if (key in exports && exports[key] === _EnvConnection[key]) return;
75
- Object.defineProperty(exports, key, {
76
- enumerable: true,
77
- get: function () {
78
- return _EnvConnection[key];
79
- }
80
- });
81
- });
82
- const NativeModels = exports.NativeModels = [_Log.Log, _System.System, _Report.Report];
@@ -1,16 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _v = require("./v1");
7
- Object.keys(_v).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _v[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _v[key];
14
- }
15
- });
16
- });
@@ -1,38 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _logs = require("./logs");
7
- Object.keys(_logs).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _logs[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _logs[key];
14
- }
15
- });
16
- });
17
- var _report = require("./report");
18
- Object.keys(_report).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _report[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _report[key];
25
- }
26
- });
27
- });
28
- var _sse = require("./sse");
29
- Object.keys(_sse).forEach(function (key) {
30
- if (key === "default" || key === "__esModule") return;
31
- if (key in exports && exports[key] === _sse[key]) return;
32
- Object.defineProperty(exports, key, {
33
- enumerable: true,
34
- get: function () {
35
- return _sse[key];
36
- }
37
- });
38
- });
@@ -1,19 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.logRouter = void 0;
7
- var _express = require("express");
8
- var _log = _interopRequireDefault(require("../../../controllers/api/log"));
9
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
- //* Router
11
- const logRouter = exports.logRouter = (0, _express.Router)();
12
-
13
- //* Middlewares
14
-
15
- //* Controllers
16
- const logController = new _log.default();
17
-
18
- //* Definitions
19
- logRouter.route('/list').post(logController.list);
@@ -1,19 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.reportRouter = void 0;
7
- var _express = require("express");
8
- var _report = _interopRequireDefault(require("../../../controllers/api/report"));
9
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
- //* Router
11
- const reportRouter = exports.reportRouter = (0, _express.Router)();
12
-
13
- //* Middlewares
14
-
15
- //* Controllers
16
- const reportController = new _report.default();
17
-
18
- //* Definitions
19
- reportRouter.route('/list').post(reportController.list);
@@ -1,36 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.sseRouter = void 0;
7
- var _express = require("express");
8
- const sseRouter = exports.sseRouter = (0, _express.Router)();
9
- sseRouter.route('/sse').post((req, res) => {
10
- // Definir cabeçalhos SSE
11
- res.setHeader('Content-Type', 'text/event-stream');
12
- res.setHeader('Cache-Control', 'no-cache');
13
- res.setHeader('Connection', 'keep-alive');
14
- res.flushHeaders(); // Enviar headers imediatamente
15
-
16
- // Função para enviar eventos
17
- const sendEvent = data => {
18
- res.write(`data: ${data}\n\n`); // Formatação para SSE
19
- };
20
-
21
- // Enviar um evento inicial
22
- sendEvent('Conexão SSE estabelecida!');
23
-
24
- // Exemplo: enviar eventos periodicamente
25
- const intervalId = setInterval(() => {
26
- const message = `Mensagem do servidor: ${new Date().toLocaleTimeString()}`;
27
- sendEvent(message);
28
- }, 5000);
29
-
30
- // Limpar intervalo e encerrar conexão quando o cliente fechar a conexão
31
- req.on('close', () => {
32
- clearInterval(intervalId);
33
- res.end();
34
- console.log('Conexão SSE fechada.');
35
- });
36
- });
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _messaging = require("./messaging");
7
- Object.keys(_messaging).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _messaging[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _messaging[key];
14
- }
15
- });
16
- });
17
- var _api = require("./api");
18
- Object.keys(_api).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _api[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _api[key];
25
- }
26
- });
27
- });
@@ -1,34 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _application = _interopRequireDefault(require("../../controllers/messaging/application"));
8
- var _database = _interopRequireDefault(require("../../controllers/messaging/database"));
9
- var _environment = _interopRequireDefault(require("../../controllers/messaging/environment"));
10
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
- //* Controllers
12
- const databaseController = new _database.default();
13
- const envController = new _environment.default();
14
- const appController = new _application.default();
15
-
16
- //* Definitions
17
- const NativeMessagingRoutes = {
18
- /* Connections Library */
19
- 'exodus.database.created': databaseController.created,
20
- 'exodus.database.updated': databaseController.update,
21
- 'exodus.database.deleted': databaseController.delete,
22
- 'exodus.database.sync': databaseController.sync,
23
- /* Application Integrations */
24
- 'exodus.application.created': appController.created,
25
- 'exodus.application.updated': appController.update,
26
- 'exodus.application.deleted': appController.delete,
27
- 'exodus.application.sync': appController.sync,
28
- /* Environment Sync Database Relations */
29
- 'exodus.environment.created': envController.created,
30
- 'exodus.environment.deleted': envController.deleted,
31
- 'exodus.environment.sync': envController.sync,
32
- 'exodus.environment.updated.database': envController.updatedDatabase
33
- };
34
- var _default = exports.default = NativeMessagingRoutes;
@@ -1,115 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _sequelize = require("sequelize");
8
- var _app = require("../app");
9
- var _models = require("../models");
10
- var _utils = require("../utils");
11
- var _security = _interopRequireDefault(require("./security"));
12
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
- class DatabaseService extends _app.Service {
14
- entities;
15
- connections;
16
- async onServiceInit() {
17
- this.entities = new Map();
18
- this.connections = new Map();
19
-
20
- // para busca rápidas
21
- this.connections.set(_app.Core.settings.getDatabase().service.database, _utils.serviceDB);
22
- this.connections.set(_app.Core.settings.getDatabase().master.database, _utils.masterDB);
23
- }
24
-
25
- //* Connection
26
- async initConnection(tenantId) {
27
- const tenantInfo = await this.getTenantInformation(tenantId);
28
- if (!tenantInfo) {
29
- throw new Error(`Não é possível inicia a conexão para o tenant ${tenantId}, a relação EnvDB não foi localizada`);
30
- }
31
- const dbHost = await _models.DatabaseHost.findByPk(tenantInfo.hostUuid);
32
- if (!tenantInfo) {
33
- throw new Error(`Não é possível inicia a conexão para o tenant ${tenantId}, não foi possível localizar a informação de host`);
34
- }
35
- const splitedInfo = dbHost.host.split(':');
36
- const address = splitedInfo[0];
37
- const port = Number(splitedInfo[1]);
38
- const database = this.normalizeDatabaseName(tenantInfo.envToken);
39
- const key = await _security.default.getService().loadKeyByStr(dbHost.credential);
40
- const data = await _security.default.getService().verifySignature(dbHost.password, key);
41
- if (!data) {
42
- throw new Error(`Não foi possível descriptografar as credenciais de conexão para hostUuid: ${tenantInfo.hostUuid}`);
43
- }
44
- const password = data.payload;
45
- const connection = await this.createConnection(address, port, database, dbHost.username, password, dbHost.dialect);
46
- this.connections.set(tenantId, connection);
47
- }
48
- async createConnection(host, port, database, username, password, dialect) {
49
- const sequelize = new _sequelize.Sequelize({
50
- host,
51
- port,
52
- dialect,
53
- database,
54
- username,
55
- password,
56
- define: {
57
- timestamps: true
58
- },
59
- timezone: '-03:00',
60
- logging: _app.Core.settings.getDatabase().service.log,
61
- pool: _app.Core.settings.getDatabase().service.pool
62
- });
63
- try {
64
- await sequelize.authenticate();
65
- return sequelize;
66
- } catch (error) {
67
- new _app.ErrorHandler('Não foi possível realizar uma conexão', error);
68
- return null;
69
- }
70
- }
71
- async getConnection(tenantId) {
72
- if (!this.connections.has(tenantId)) {
73
- await this.initConnection(tenantId);
74
- }
75
- return this.connections.get(tenantId);
76
- }
77
-
78
- //* Environment
79
- async getTenantIds() {
80
- const tenants = await _models.EnvDBHost.findAll({
81
- attributes: ['envUuid']
82
- });
83
- return tenants.map(t => t.envUuid);
84
- }
85
- async getTenantInformation(tenantId) {
86
- const relation = await _models.EnvDBHost.findOne({
87
- where: {
88
- envUuid: tenantId
89
- }
90
- });
91
- return relation;
92
- }
93
-
94
- //* Entity
95
- async loadEntity(entity, tenantId) {
96
- const k = `${tenantId}#${entity.name}`;
97
- const connection = await this.getConnection(tenantId);
98
- const loadedEntity = entity.initialize(connection);
99
- await loadedEntity.sync();
100
- this.entities.set(k, loadedEntity);
101
- }
102
- async getEntity(model, tenantId) {
103
- const k = `${tenantId}#${model.name}`;
104
- if (!this.entities.has(k)) {
105
- await this.loadEntity(model, tenantId);
106
- }
107
- return this.entities.get(k);
108
- }
109
-
110
- //* Utils
111
- normalizeDatabaseName(envToken) {
112
- return `${_app.Core.settings.getDatabase().service.database}_${envToken}`;
113
- }
114
- }
115
- var _default = exports.default = DatabaseService;
@@ -1,46 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _app = require("../app");
8
- var _System = require("../models/System");
9
- var _sequelize = _interopRequireDefault(require("./sequelize"));
10
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
- class EcosystemService extends _app.Service {
12
- async getSystemVariable(tenantId, key) {
13
- const Entity = await _sequelize.default.singleton().getModel(_System.System, tenantId);
14
- return Entity.findOne({
15
- where: {
16
- key
17
- }
18
- });
19
- }
20
- async setSystemVariable(tenantId, key, value) {
21
- const Entity = await _sequelize.default.singleton().getModel(_System.System, tenantId);
22
- const variable = await Entity.findOne({
23
- where: {
24
- key
25
- }
26
- });
27
- if (!variable) throw new Error('System variable not found: ' + key);
28
- variable.value = value;
29
- variable.changed('value', true);
30
- await variable.save();
31
- }
32
- async createSystemVariable(tenantId, key, value) {
33
- const Entity = await _sequelize.default.singleton().getModel(_System.System, tenantId);
34
- const variable = await Entity.findOne({
35
- where: {
36
- key
37
- }
38
- });
39
- if (variable) throw new Error('System variable has exists: ' + key);
40
- return await Entity.create({
41
- key,
42
- value
43
- });
44
- }
45
- }
46
- var _default = exports.default = EcosystemService;