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.
- package/lib/app/settings.d.ts.map +1 -1
- package/lib/contracts/settings.d.ts +1 -2
- package/lib/contracts/settings.d.ts.map +1 -1
- package/lib/services/database.d.ts +2 -0
- package/lib/services/database.d.ts.map +1 -1
- package/lib/services/sequelize.d.ts +0 -1
- package/lib/services/sequelize.d.ts.map +1 -1
- package/lib/utils/database.d.ts +1 -2
- package/lib/utils/database.d.ts.map +1 -1
- package/package.json +1 -1
- package/lib/app/classes/broadcast.js +0 -79
- package/lib/app/classes/cache.js +0 -94
- package/lib/app/classes/communication.js +0 -99
- package/lib/app/classes/communicationcontext.js +0 -1
- package/lib/app/classes/event.js +0 -94
- package/lib/app/classes/index.js +0 -105
- package/lib/app/classes/managed.js +0 -145
- package/lib/app/classes/service.js +0 -232
- package/lib/app/classes/servicemodel.js +0 -22
- package/lib/app/classes/singleton.js +0 -26
- package/lib/app/classes/socket/clienthandler.js +0 -54
- package/lib/app/classes/socket/eventhandler.js +0 -51
- package/lib/app/classes/socket/index.js +0 -20
- package/lib/app/classes/system.js +0 -49
- package/lib/app/controller.js +0 -97
- package/lib/app/core.js +0 -47
- package/lib/app/error.js +0 -66
- package/lib/app/exodus.js +0 -97
- package/lib/app/index.js +0 -68
- package/lib/app/settings.js +0 -162
- package/lib/certificates/private_key.pem +0 -27
- package/lib/certificates/public_key.pem +0 -9
- package/lib/contracts/communication/communication.js +0 -39
- package/lib/contracts/communication/index.js +0 -27
- package/lib/contracts/communication/operation.js +0 -5
- package/lib/contracts/console.js +0 -5
- package/lib/contracts/contansts.js +0 -13
- package/lib/contracts/core.js +0 -12
- package/lib/contracts/entity.js +0 -5
- package/lib/contracts/http.js +0 -52
- package/lib/contracts/index.js +0 -104
- package/lib/contracts/messaging.js +0 -50
- package/lib/contracts/security.js +0 -5
- package/lib/contracts/service.js +0 -11
- package/lib/contracts/session.js +0 -5
- package/lib/contracts/settings.js +0 -5
- package/lib/contracts/singleton.js +0 -5
- package/lib/contracts/socket.js +0 -11
- package/lib/contracts/tasks.js +0 -1
- package/lib/controllers/api/file.js +0 -24
- package/lib/controllers/api/index.js +0 -13
- package/lib/controllers/api/log.js +0 -55
- package/lib/controllers/api/report.js +0 -55
- package/lib/controllers/index.js +0 -16
- package/lib/controllers/messaging/application.js +0 -75
- package/lib/controllers/messaging/database.js +0 -64
- package/lib/controllers/messaging/environment.js +0 -111
- package/lib/express.d.js +0 -5
- package/lib/index.js +0 -104
- package/lib/middlewares/access.js +0 -114
- package/lib/middlewares/authentication.js +0 -104
- package/lib/middlewares/file.js +0 -41
- package/lib/middlewares/index.js +0 -36
- package/lib/models/Application.js +0 -65
- package/lib/models/DatabaseHost.js +0 -62
- package/lib/models/EnvConnection.js +0 -41
- package/lib/models/Log.js +0 -67
- package/lib/models/Report.js +0 -65
- package/lib/models/System.js +0 -54
- package/lib/models/index.js +0 -82
- package/lib/routes/api/index.js +0 -16
- package/lib/routes/api/v1/index.js +0 -38
- package/lib/routes/api/v1/logs.js +0 -19
- package/lib/routes/api/v1/report.js +0 -19
- package/lib/routes/api/v1/sse.js +0 -36
- package/lib/routes/index.js +0 -27
- package/lib/routes/messaging/index.js +0 -34
- package/lib/services/database.js +0 -115
- package/lib/services/ecosystem.js +0 -46
- package/lib/services/express.js +0 -162
- package/lib/services/file.js +0 -65
- package/lib/services/file_new.js +0 -136
- package/lib/services/index.js +0 -108
- package/lib/services/log.js +0 -26
- package/lib/services/rabitmq.js +0 -187
- package/lib/services/redis.js +0 -84
- package/lib/services/security.js +0 -231
- package/lib/services/sequelize.js +0 -323
- package/lib/services/socket.js +0 -123
- package/lib/services/task/TaskServiceBase.js +0 -17
- package/lib/services/task/index.js +0 -40
- package/lib/services/task/queue/QueueService.js +0 -48
- package/lib/services/task/queue/QueueTask.js +0 -134
- package/lib/services/task/queue/SingleQueue.js +0 -68
- package/lib/services/task/queue/index.js +0 -27
- package/lib/services/task/scheduler/SchedulerService.js +0 -31
- package/lib/services/task/scheduler/SchedulerTask.js +0 -211
- package/lib/services/task/scheduler/index.js +0 -20
- package/lib/services/test.js +0 -27
- package/lib/socket.d.js +0 -3
- package/lib/tasks/index.js +0 -27
- package/lib/tasks/queue/application.js +0 -44
- package/lib/tasks/queue/environment.js +0 -92
- package/lib/tasks/queue/index.js +0 -20
- package/lib/tasks/queue/teste.js +0 -21
- package/lib/tasks/schedule/index.js +0 -13
- package/lib/tasks/schedule/restart.js +0 -19
- package/lib/tasks/schedule/teste.js +0 -61
- package/lib/utils/api.js +0 -65
- package/lib/utils/database.js +0 -155
- package/lib/utils/date.js +0 -28
- package/lib/utils/index.js +0 -60
- package/lib/utils/logger.js +0 -51
- package/lib/utils/session.js +0 -23
package/lib/contracts/index.js
DELETED
@@ -1,104 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
var _console = require("./console");
|
7
|
-
Object.keys(_console).forEach(function (key) {
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
9
|
-
if (key in exports && exports[key] === _console[key]) return;
|
10
|
-
Object.defineProperty(exports, key, {
|
11
|
-
enumerable: true,
|
12
|
-
get: function () {
|
13
|
-
return _console[key];
|
14
|
-
}
|
15
|
-
});
|
16
|
-
});
|
17
|
-
var _entity = require("./entity");
|
18
|
-
Object.keys(_entity).forEach(function (key) {
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
20
|
-
if (key in exports && exports[key] === _entity[key]) return;
|
21
|
-
Object.defineProperty(exports, key, {
|
22
|
-
enumerable: true,
|
23
|
-
get: function () {
|
24
|
-
return _entity[key];
|
25
|
-
}
|
26
|
-
});
|
27
|
-
});
|
28
|
-
var _http = require("./http");
|
29
|
-
Object.keys(_http).forEach(function (key) {
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
31
|
-
if (key in exports && exports[key] === _http[key]) return;
|
32
|
-
Object.defineProperty(exports, key, {
|
33
|
-
enumerable: true,
|
34
|
-
get: function () {
|
35
|
-
return _http[key];
|
36
|
-
}
|
37
|
-
});
|
38
|
-
});
|
39
|
-
var _messaging = require("./messaging");
|
40
|
-
Object.keys(_messaging).forEach(function (key) {
|
41
|
-
if (key === "default" || key === "__esModule") return;
|
42
|
-
if (key in exports && exports[key] === _messaging[key]) return;
|
43
|
-
Object.defineProperty(exports, key, {
|
44
|
-
enumerable: true,
|
45
|
-
get: function () {
|
46
|
-
return _messaging[key];
|
47
|
-
}
|
48
|
-
});
|
49
|
-
});
|
50
|
-
var _session = require("./session");
|
51
|
-
Object.keys(_session).forEach(function (key) {
|
52
|
-
if (key === "default" || key === "__esModule") return;
|
53
|
-
if (key in exports && exports[key] === _session[key]) return;
|
54
|
-
Object.defineProperty(exports, key, {
|
55
|
-
enumerable: true,
|
56
|
-
get: function () {
|
57
|
-
return _session[key];
|
58
|
-
}
|
59
|
-
});
|
60
|
-
});
|
61
|
-
var _settings = require("./settings");
|
62
|
-
Object.keys(_settings).forEach(function (key) {
|
63
|
-
if (key === "default" || key === "__esModule") return;
|
64
|
-
if (key in exports && exports[key] === _settings[key]) return;
|
65
|
-
Object.defineProperty(exports, key, {
|
66
|
-
enumerable: true,
|
67
|
-
get: function () {
|
68
|
-
return _settings[key];
|
69
|
-
}
|
70
|
-
});
|
71
|
-
});
|
72
|
-
var _singleton = require("./singleton");
|
73
|
-
Object.keys(_singleton).forEach(function (key) {
|
74
|
-
if (key === "default" || key === "__esModule") return;
|
75
|
-
if (key in exports && exports[key] === _singleton[key]) return;
|
76
|
-
Object.defineProperty(exports, key, {
|
77
|
-
enumerable: true,
|
78
|
-
get: function () {
|
79
|
-
return _singleton[key];
|
80
|
-
}
|
81
|
-
});
|
82
|
-
});
|
83
|
-
var _socket = require("./socket");
|
84
|
-
Object.keys(_socket).forEach(function (key) {
|
85
|
-
if (key === "default" || key === "__esModule") return;
|
86
|
-
if (key in exports && exports[key] === _socket[key]) return;
|
87
|
-
Object.defineProperty(exports, key, {
|
88
|
-
enumerable: true,
|
89
|
-
get: function () {
|
90
|
-
return _socket[key];
|
91
|
-
}
|
92
|
-
});
|
93
|
-
});
|
94
|
-
var _communication = require("./communication");
|
95
|
-
Object.keys(_communication).forEach(function (key) {
|
96
|
-
if (key === "default" || key === "__esModule") return;
|
97
|
-
if (key in exports && exports[key] === _communication[key]) return;
|
98
|
-
Object.defineProperty(exports, key, {
|
99
|
-
enumerable: true,
|
100
|
-
get: function () {
|
101
|
-
return _communication[key];
|
102
|
-
}
|
103
|
-
});
|
104
|
-
});
|
@@ -1,50 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.EMessagingQueue = void 0;
|
7
|
-
let EMessagingQueue = exports.EMessagingQueue = /*#__PURE__*/function (EMessagingQueue) {
|
8
|
-
EMessagingQueue["test"] = "exodus.queue.test";
|
9
|
-
EMessagingQueue["accountCreated"] = "exodus.account.created";
|
10
|
-
EMessagingQueue["accountDelete"] = "exodus.account.delete";
|
11
|
-
EMessagingQueue["accountUpdated"] = "exodus.account.updated";
|
12
|
-
EMessagingQueue["accountSync"] = "exodus.account.sync";
|
13
|
-
EMessagingQueue["environmentSync"] = "exodus.environment.sync";
|
14
|
-
EMessagingQueue["environmentCreated"] = "exodus.environment.created";
|
15
|
-
EMessagingQueue["environmentDeleted"] = "exodus.environment.deleted";
|
16
|
-
EMessagingQueue["environmentUpdatedToken"] = "exodus.environment.updated.token";
|
17
|
-
EMessagingQueue["environmentUpdatedDatabase"] = "exodus.environment.updated.database";
|
18
|
-
EMessagingQueue["databaseSync"] = "exodus.database.sync";
|
19
|
-
EMessagingQueue["databaseCreated"] = "exodus.database.created";
|
20
|
-
EMessagingQueue["databaseUpdate"] = "exodus.database.updated";
|
21
|
-
EMessagingQueue["databaseDeleted"] = "exodus.database.deleted";
|
22
|
-
EMessagingQueue["applicationSync"] = "exodus.application.sync";
|
23
|
-
EMessagingQueue["applicationCreated"] = "exodus.application.created";
|
24
|
-
EMessagingQueue["applicationUpdate"] = "exodus.application.updated";
|
25
|
-
EMessagingQueue["applicationDeleted"] = "exodus.application.deleted";
|
26
|
-
EMessagingQueue["smsSend"] = "exodus.sms.send";
|
27
|
-
EMessagingQueue["smsSendBulk"] = "exodus.sms.send.bulk";
|
28
|
-
EMessagingQueue["smsConfirmationSend"] = "exodus.sms.confirmation.send";
|
29
|
-
EMessagingQueue["smsConfirmationSendBulk"] = "exodus.sms.confirmation.send.bulk";
|
30
|
-
EMessagingQueue["smsUpdate"] = "exodus.sms.update";
|
31
|
-
EMessagingQueue["smsCreateWallet"] = "exodus.sms.create.wallet";
|
32
|
-
EMessagingQueue["smsCloseWallet"] = "exodus.sms.close.wallet";
|
33
|
-
EMessagingQueue["smsConfirmationCreateWallet"] = "exodus.sms.confirmation.create.wallet";
|
34
|
-
EMessagingQueue["whatsappOnMessage"] = "exodus.whatsapp.on-message";
|
35
|
-
EMessagingQueue["whatsappOnUpdateMessage"] = "exodus.whatsapp.on-update-message";
|
36
|
-
EMessagingQueue["whatsappOnMessageMediaDownload"] = "exodus.whatsapp.on-message-media-download";
|
37
|
-
EMessagingQueue["whatsappOnContactUpdate"] = "exodus.whatsapp.on-contact-update";
|
38
|
-
EMessagingQueue["whatsappOnContactUpsert"] = "exodus.whatsapp.on-contact-upsert";
|
39
|
-
EMessagingQueue["whatsappSendMessage"] = "exodus.whatsapp.send-message";
|
40
|
-
EMessagingQueue["whatsappHasAccount"] = "exodus.whatsapp.has-account";
|
41
|
-
EMessagingQueue["whatsappHasAccountResponse"] = "exodus.whatsapp.has-account-response";
|
42
|
-
EMessagingQueue["whatsappReadAllMessages"] = "exodus.whatsapp.read-all-messages";
|
43
|
-
EMessagingQueue["whatsappPresenceUpdate"] = "exodus.whatsapp.presence-update";
|
44
|
-
EMessagingQueue["whatsappPresenceSubscribe"] = "exodus.whatsapp.presence-subscribe";
|
45
|
-
EMessagingQueue["whatsappOnContactPresenceUpdate"] = "exodus.whatsapp.contact-presence-update";
|
46
|
-
EMessagingQueue["conversationOnCreateConnection"] = "exodus.conversation.on-create-connection";
|
47
|
-
EMessagingQueue["conversationOnDeleteConnection"] = "exodus.conversation.on-delete-connection";
|
48
|
-
EMessagingQueue["conversationOnUpdateConnection"] = "exodus.conversation.on-update-connection";
|
49
|
-
return EMessagingQueue;
|
50
|
-
}({}); // Mapeamento de tópicos para tipos
|
package/lib/contracts/service.js
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.eEventCommunication = void 0;
|
7
|
-
let eEventCommunication = exports.eEventCommunication = /*#__PURE__*/function (eEventCommunication) {
|
8
|
-
eEventCommunication["RECEIVED_MASTER_MESSAGE"] = "received.master.message";
|
9
|
-
eEventCommunication["RECEIVED_CLUSTER_MESSAGE"] = "received.cluster.message";
|
10
|
-
return eEventCommunication;
|
11
|
-
}({});
|
package/lib/contracts/session.js
DELETED
package/lib/contracts/socket.js
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.ESocketEvent = void 0;
|
7
|
-
let ESocketEvent = exports.ESocketEvent = /*#__PURE__*/function (ESocketEvent) {
|
8
|
-
ESocketEvent["test"] = "exodus.socket.event.test";
|
9
|
-
ESocketEvent["test2"] = "exodus.socket.event.test2";
|
10
|
-
return ESocketEvent;
|
11
|
-
}({}); // Mapeamento de tópicos para tipos
|
package/lib/contracts/tasks.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";
|
@@ -1,24 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.default = void 0;
|
7
|
-
var _controller = _interopRequireDefault(require("../../app/controller"));
|
8
|
-
require("express-async-errors");
|
9
|
-
var _http = require("../../contracts/http");
|
10
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
11
|
-
// !Tratamento de erros asyncronos
|
12
|
-
|
13
|
-
class FileController extends _controller.default {
|
14
|
-
upload = async (req, res) => {
|
15
|
-
this.send({
|
16
|
-
message: 'Salvo com sucesso',
|
17
|
-
type: 'success',
|
18
|
-
status: true,
|
19
|
-
data: req.file.filename,
|
20
|
-
code: _http.EHttpResponseCode.created
|
21
|
-
}, res);
|
22
|
-
};
|
23
|
-
}
|
24
|
-
var _default = exports.default = FileController;
|
@@ -1,13 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
Object.defineProperty(exports, "FileController", {
|
7
|
-
enumerable: true,
|
8
|
-
get: function () {
|
9
|
-
return _file.default;
|
10
|
-
}
|
11
|
-
});
|
12
|
-
var _file = _interopRequireDefault(require("./file"));
|
13
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
@@ -1,55 +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 _Log = require("../../models/Log");
|
9
|
-
var _services = require("../../services");
|
10
|
-
var _utils = require("../../utils");
|
11
|
-
class LogController extends _app.HttpController {
|
12
|
-
list = async (req, res) => {
|
13
|
-
const {
|
14
|
-
page = 1,
|
15
|
-
filters = {},
|
16
|
-
limit = 10,
|
17
|
-
order = 'ASC',
|
18
|
-
orderBy = 'happenedAt'
|
19
|
-
} = req.body;
|
20
|
-
const offset = (Number(page) - 1) * Number(limit);
|
21
|
-
try {
|
22
|
-
const Entity = await _services.SequelizeService.singleton().getModel(_Log.Log, req.tenant.id);
|
23
|
-
/* filters */
|
24
|
-
const where = (0, _utils.processFilters)(filters);
|
25
|
-
const {
|
26
|
-
rows,
|
27
|
-
count
|
28
|
-
} = await Entity.findAndCountAll({
|
29
|
-
where,
|
30
|
-
order: [[orderBy, order]],
|
31
|
-
limit: Number(limit),
|
32
|
-
offset: offset < 0 ? 0 : offset
|
33
|
-
});
|
34
|
-
const pages = Math.ceil(count / Number(limit));
|
35
|
-
const hasMore = offset + Number(limit) < count;
|
36
|
-
this.send({
|
37
|
-
message: 'carregado com sucesso',
|
38
|
-
status: true,
|
39
|
-
type: 'success',
|
40
|
-
data: {
|
41
|
-
data: rows,
|
42
|
-
total: count,
|
43
|
-
pages,
|
44
|
-
hasMore
|
45
|
-
}
|
46
|
-
}, res);
|
47
|
-
} catch (error) {
|
48
|
-
throw new _app.HttpError({
|
49
|
-
message: 'Não foi possível obter a lista de mensagens',
|
50
|
-
error
|
51
|
-
});
|
52
|
-
}
|
53
|
-
};
|
54
|
-
}
|
55
|
-
var _default = exports.default = LogController;
|
@@ -1,55 +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 _services = require("../../services");
|
9
|
-
var _utils = require("../../utils");
|
10
|
-
var _Report = require("../../models/Report");
|
11
|
-
class ReportController extends _app.HttpController {
|
12
|
-
list = async (req, res) => {
|
13
|
-
const {
|
14
|
-
page = 1,
|
15
|
-
filters = {},
|
16
|
-
limit = 10,
|
17
|
-
order = 'ASC',
|
18
|
-
orderBy = 'category'
|
19
|
-
} = req.body;
|
20
|
-
const offset = (Number(page) - 1) * Number(limit);
|
21
|
-
try {
|
22
|
-
const Entity = await _services.SequelizeService.singleton().getModel(_Report.Report, req.tenant.id);
|
23
|
-
/* filters */
|
24
|
-
const where = (0, _utils.processFilters)(filters);
|
25
|
-
const {
|
26
|
-
rows,
|
27
|
-
count
|
28
|
-
} = await Entity.findAndCountAll({
|
29
|
-
where,
|
30
|
-
order: [[orderBy, order]],
|
31
|
-
limit: Number(limit),
|
32
|
-
offset: offset < 0 ? 0 : offset
|
33
|
-
});
|
34
|
-
const pages = Math.ceil(count / Number(limit));
|
35
|
-
const hasMore = offset + Number(limit) < count;
|
36
|
-
this.send({
|
37
|
-
message: 'carregado com sucesso',
|
38
|
-
status: true,
|
39
|
-
type: 'success',
|
40
|
-
data: {
|
41
|
-
data: rows,
|
42
|
-
total: count,
|
43
|
-
pages,
|
44
|
-
hasMore
|
45
|
-
}
|
46
|
-
}, res);
|
47
|
-
} catch (error) {
|
48
|
-
throw new _app.HttpError({
|
49
|
-
message: 'Não foi possível obter a lista de relatórios',
|
50
|
-
error
|
51
|
-
});
|
52
|
-
}
|
53
|
-
};
|
54
|
-
}
|
55
|
-
var _default = exports.default = ReportController;
|
package/lib/controllers/index.js
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
var _api = require("./api");
|
7
|
-
Object.keys(_api).forEach(function (key) {
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
9
|
-
if (key in exports && exports[key] === _api[key]) return;
|
10
|
-
Object.defineProperty(exports, key, {
|
11
|
-
enumerable: true,
|
12
|
-
get: function () {
|
13
|
-
return _api[key];
|
14
|
-
}
|
15
|
-
});
|
16
|
-
});
|
@@ -1,75 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.default = void 0;
|
7
|
-
var _controller = require("../../app/controller");
|
8
|
-
var _error = require("../../app/error");
|
9
|
-
var _Application = require("../../models/Application");
|
10
|
-
var _logger = _interopRequireDefault(require("../../utils/logger"));
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
12
|
-
//TODO: a ordem de inicialização do sistema impede as tasks estarem disponiveis até o momento
|
13
|
-
//TODO: deveria ser assim?
|
14
|
-
class ApplicationController extends _controller.MessagingController {
|
15
|
-
created = async (data, ack) => {
|
16
|
-
/* ApplicationSyncQueue.addJob({ create: data });
|
17
|
-
ack(); */
|
18
|
-
|
19
|
-
try {
|
20
|
-
await _Application.Application.create(data);
|
21
|
-
} catch (error) {
|
22
|
-
new _error.ErrorHandler('Houve um erro ao tentar criar a aplicação', error);
|
23
|
-
} finally {
|
24
|
-
ack();
|
25
|
-
}
|
26
|
-
};
|
27
|
-
update = async (data, ack) => {
|
28
|
-
/* ApplicationSyncQueue.addJob({ update: data });
|
29
|
-
ack(); */
|
30
|
-
|
31
|
-
try {
|
32
|
-
const app = await _Application.Application.findByPk(data.uuid);
|
33
|
-
if (!app) throw new Error('Aplicação não encontrada: ' + data.uuid);
|
34
|
-
await app.update(data.updated);
|
35
|
-
} catch (error) {
|
36
|
-
new _error.ErrorHandler('Houve um erro ao tentar atualizar a aplicação, check o log...', error);
|
37
|
-
} finally {
|
38
|
-
ack();
|
39
|
-
}
|
40
|
-
};
|
41
|
-
delete = async (data, ack) => {
|
42
|
-
try {
|
43
|
-
const app = await _Application.Application.findByPk(data.uuid);
|
44
|
-
if (!app) throw new Error('Aplicação não encontrada: ' + data.uuid);
|
45
|
-
await app.destroy();
|
46
|
-
} catch (error) {
|
47
|
-
new _error.ErrorHandler('Houve um erro ao tentar excluír a aplicação', error);
|
48
|
-
} finally {
|
49
|
-
ack();
|
50
|
-
}
|
51
|
-
};
|
52
|
-
sync = async (data, ack) => {
|
53
|
-
try {
|
54
|
-
data.forEach(async app => {
|
55
|
-
try {
|
56
|
-
const host = await _Application.Application.findByPk(app.uuid);
|
57
|
-
if (!host) {
|
58
|
-
(0, _logger.default)().info(app, `Sincronizando nova integração do banco de dados ${app.name}`);
|
59
|
-
this.log(`Sincronizando nova integração do banco de dados ${app.name}`, 'info');
|
60
|
-
// ApplicationSyncQueue.addJob({ create: app });
|
61
|
-
|
62
|
-
await _Application.Application.create(app);
|
63
|
-
}
|
64
|
-
} catch (error) {
|
65
|
-
new _error.ErrorHandler('Houve um erro ao tentar sincronizar uma integração', error);
|
66
|
-
}
|
67
|
-
});
|
68
|
-
} catch (error) {
|
69
|
-
new _error.ErrorHandler('Houve um erro ao tentar sincronizar uma integração', error);
|
70
|
-
} finally {
|
71
|
-
ack();
|
72
|
-
}
|
73
|
-
};
|
74
|
-
}
|
75
|
-
var _default = exports.default = ApplicationController;
|
@@ -1,64 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.default = void 0;
|
7
|
-
var _controller = require("../../app/controller");
|
8
|
-
var _models = require("../../models");
|
9
|
-
var _app = require("../../app");
|
10
|
-
var _utils = require("../../utils");
|
11
|
-
class DatabaseController extends _controller.MessagingController {
|
12
|
-
created = async (data, ack) => {
|
13
|
-
try {
|
14
|
-
await _models.DatabaseHost.create(data);
|
15
|
-
} catch (error) {
|
16
|
-
new _app.ErrorHandler('Houve um erro ao tentar criar um banco de dados', error);
|
17
|
-
} finally {
|
18
|
-
ack();
|
19
|
-
}
|
20
|
-
};
|
21
|
-
update = async (data, ack) => {
|
22
|
-
try {
|
23
|
-
const host = await _models.DatabaseHost.findByPk(data.uuid);
|
24
|
-
if (!host) throw new Error('Banco de dados não encontrado');
|
25
|
-
await host.update(data.updated);
|
26
|
-
} catch (error) {
|
27
|
-
new _app.ErrorHandler('Houve um erro ao tentar atualizar um banco de dados', error);
|
28
|
-
} finally {
|
29
|
-
ack();
|
30
|
-
}
|
31
|
-
};
|
32
|
-
delete = async (data, ack) => {
|
33
|
-
try {
|
34
|
-
const host = await _models.DatabaseHost.findByPk(data.uuid);
|
35
|
-
if (!host) throw new Error('Banco de dados não encontrado');
|
36
|
-
await host.destroy();
|
37
|
-
} catch (error) {
|
38
|
-
new _app.ErrorHandler('Houve um erro ao tentar excluír um banco de dados', error);
|
39
|
-
} finally {
|
40
|
-
ack();
|
41
|
-
}
|
42
|
-
};
|
43
|
-
sync = async (data, ack) => {
|
44
|
-
try {
|
45
|
-
data.forEach(async database => {
|
46
|
-
try {
|
47
|
-
const host = await _models.DatabaseHost.findByPk(database.uuid);
|
48
|
-
if (!host) {
|
49
|
-
(0, _utils.logger)().info(database, `Sincronizando novo host ${database.host}`);
|
50
|
-
this.log(`Sincronizando novo host ${database.host}`, 'info');
|
51
|
-
await _models.DatabaseHost.create(database);
|
52
|
-
}
|
53
|
-
} catch (error) {
|
54
|
-
new _app.ErrorHandler('Houve um erro ao tentar sincronizar um novo host', error);
|
55
|
-
}
|
56
|
-
});
|
57
|
-
} catch (error) {
|
58
|
-
new _app.ErrorHandler('Houve um erro ao tentar sincronizar um novo host', error);
|
59
|
-
} finally {
|
60
|
-
ack();
|
61
|
-
}
|
62
|
-
};
|
63
|
-
}
|
64
|
-
var _default = exports.default = DatabaseController;
|
@@ -1,111 +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 _models = require("../../models");
|
9
|
-
var _services = require("../../services");
|
10
|
-
var _utils = require("../../utils");
|
11
|
-
//TODO: a ordem de inicialização do sistema impede as tasks estarem disponiveis até o momento
|
12
|
-
//TODO: deveria ser assim?
|
13
|
-
class EnvironmentController extends _app.MessagingController {
|
14
|
-
created = async (data, ack) => {
|
15
|
-
/* EnvironmentSyncQueue.addJob({ create: data });
|
16
|
-
ack(); */
|
17
|
-
|
18
|
-
try {
|
19
|
-
const db = data.database;
|
20
|
-
const token = data.envToken;
|
21
|
-
await _services.SequelizeService.singleton().createDB(db, token);
|
22
|
-
await _models.EnvDBHost.create({
|
23
|
-
envUuid: data.uuid,
|
24
|
-
hostUuid: data.database,
|
25
|
-
envToken: data.envToken
|
26
|
-
});
|
27
|
-
this.log(`New database created successfully: ${db}`);
|
28
|
-
} catch (error) {
|
29
|
-
new _app.ErrorHandler('Erro ao criar o novo banco de dados', error);
|
30
|
-
} finally {
|
31
|
-
ack();
|
32
|
-
}
|
33
|
-
};
|
34
|
-
deleted = async (data, ack) => {
|
35
|
-
try {
|
36
|
-
const token = data.token;
|
37
|
-
const db = data.database;
|
38
|
-
await _services.SequelizeService.singleton().deleteDB(db, token);
|
39
|
-
const relation = await _models.EnvDBHost.findOne({
|
40
|
-
where: {
|
41
|
-
envUuid: data.uuid
|
42
|
-
}
|
43
|
-
});
|
44
|
-
if (!relation) throw new Error('relação env-db não encontrada');
|
45
|
-
await relation.destroy();
|
46
|
-
this.log(`Database deleted successfully: ${token}`);
|
47
|
-
} catch (error) {
|
48
|
-
new _app.ErrorHandler('Erro ao deletar a relação env-db', error);
|
49
|
-
} finally {
|
50
|
-
ack();
|
51
|
-
}
|
52
|
-
};
|
53
|
-
updatedDatabase = async (data, ack) => {
|
54
|
-
/* EnvironmentSyncQueue.addJob({ update: data });
|
55
|
-
ack(); */
|
56
|
-
|
57
|
-
try {
|
58
|
-
const relation = await _models.EnvDBHost.findOne({
|
59
|
-
where: {
|
60
|
-
envUuid: data.envUuid
|
61
|
-
}
|
62
|
-
});
|
63
|
-
if (!relation) throw new Error('relação env-db não encontrada');
|
64
|
-
await relation.update({
|
65
|
-
hostUuid: data.database
|
66
|
-
});
|
67
|
-
this.log(`A relação para o ambiente ${data.envUuid} foi atualizada, a migração deverá ser realizada de forma manual`);
|
68
|
-
} catch (error) {
|
69
|
-
new _app.ErrorHandler('Erro ao atualizar a relação EDB', error);
|
70
|
-
} finally {
|
71
|
-
ack();
|
72
|
-
}
|
73
|
-
};
|
74
|
-
sync = async (data, ack) => {
|
75
|
-
/* EnvironmentSyncQueue.addJob({ sync: data });
|
76
|
-
ack(); */
|
77
|
-
|
78
|
-
try {
|
79
|
-
data.forEach(async env => {
|
80
|
-
try {
|
81
|
-
const host = await _models.EnvDBHost.findOne({
|
82
|
-
where: {
|
83
|
-
envUuid: env.uuid
|
84
|
-
}
|
85
|
-
});
|
86
|
-
if (!host) {
|
87
|
-
(0, _utils.logger)().info(env, `Sincronizando relação env-db ${env.uuid}`);
|
88
|
-
this.log(`Sincronizando relação env-db ${env.uuid}`, 'info');
|
89
|
-
await _models.EnvDBHost.create({
|
90
|
-
envUuid: env.uuid,
|
91
|
-
hostUuid: env.database,
|
92
|
-
envToken: env.envToken
|
93
|
-
});
|
94
|
-
}
|
95
|
-
if (!(await _services.SequelizeService.singleton().hasDB(env.database, env.envToken))) {
|
96
|
-
(0, _utils.logger)().info(env, `Sincronizando novo banco de dados ${env.uuid}`);
|
97
|
-
this.log(`Sincronizando novo banco de dados ${env.uuid}`, 'info');
|
98
|
-
await _services.SequelizeService.singleton().createDB(env.database, env.envToken);
|
99
|
-
}
|
100
|
-
} catch (error) {
|
101
|
-
new _app.ErrorHandler('Houve um erro ao tentar sincronizar um novo ambiente/relação ou banco de dados', error);
|
102
|
-
}
|
103
|
-
});
|
104
|
-
} catch (error) {
|
105
|
-
new _app.ErrorHandler('Houve um erro ao tentar sincronizar um novo ambiente/relação ou banco de dados', error);
|
106
|
-
} finally {
|
107
|
-
ack();
|
108
|
-
}
|
109
|
-
};
|
110
|
-
}
|
111
|
-
var _default = exports.default = EnvironmentController;
|