exodus-framework 2.0.699 → 2.0.701

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 (58) hide show
  1. package/lib/app/app.js +84 -0
  2. package/lib/app/controller.js +95 -0
  3. package/lib/app/core.js +66 -0
  4. package/lib/app/index.js +60 -0
  5. package/lib/app/service.js +24 -0
  6. package/lib/app/settings.js +135 -0
  7. package/lib/app/singleton.js +29 -0
  8. package/lib/contracts/console.js +5 -0
  9. package/lib/contracts/entity.js +5 -0
  10. package/lib/contracts/http.js +50 -0
  11. package/lib/contracts/index.js +104 -0
  12. package/lib/contracts/messaging.js +18 -0
  13. package/lib/contracts/security.js +5 -0
  14. package/lib/contracts/service.js +5 -0
  15. package/lib/contracts/session.js +5 -0
  16. package/lib/contracts/settings.js +5 -0
  17. package/lib/contracts/singleton.js +5 -0
  18. package/lib/contracts/socket.js +11 -0
  19. package/lib/controllers/api/file.js +24 -0
  20. package/lib/controllers/api/index.js +13 -0
  21. package/lib/controllers/index.js +16 -0
  22. package/lib/controllers/messaging/database.js +53 -0
  23. package/lib/controllers/messaging/environment.js +70 -0
  24. package/lib/express.d.js +5 -0
  25. package/lib/index.js +92 -0
  26. package/lib/middlewares/access.js +63 -0
  27. package/lib/middlewares/authentication.js +21 -0
  28. package/lib/middlewares/file.js +41 -0
  29. package/lib/middlewares/index.js +27 -0
  30. package/lib/models/Application.js +61 -0
  31. package/lib/models/Connection.js +54 -0
  32. package/lib/models/EnvConnection.js +41 -0
  33. package/lib/models/index.js +46 -0
  34. package/lib/routes/index.js +16 -0
  35. package/lib/routes/messaging/index.js +26 -0
  36. package/lib/services/error.js +49 -0
  37. package/lib/services/express.js +140 -0
  38. package/lib/services/file.js +65 -0
  39. package/lib/services/index.d.ts +1 -0
  40. package/lib/services/index.d.ts.map +1 -1
  41. package/lib/services/index.js +88 -0
  42. package/lib/services/rabitmq.js +93 -0
  43. package/lib/services/redis.js +60 -0
  44. package/lib/services/security.js +224 -0
  45. package/lib/services/sequelize.d.ts +2 -0
  46. package/lib/services/sequelize.d.ts.map +1 -1
  47. package/lib/services/sequelize.js +265 -0
  48. package/lib/services/socket.js +56 -0
  49. package/lib/services/task.js +162 -0
  50. package/lib/utils/api.js +50 -0
  51. package/lib/utils/database.js +36 -0
  52. package/lib/utils/date.js +28 -0
  53. package/lib/utils/index.d.ts +0 -1
  54. package/lib/utils/index.d.ts.map +1 -1
  55. package/lib/utils/index.js +60 -0
  56. package/lib/utils/logger.js +55 -0
  57. package/lib/utils/session.js +23 -0
  58. package/package.json +1 -1
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,11 @@
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
@@ -0,0 +1,24 @@
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;
@@ -0,0 +1,13 @@
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 }; }
@@ -0,0 +1,16 @@
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
+ });
@@ -0,0 +1,53 @@
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 _utils = require("../../utils");
10
+ class DatabaseController extends _app.MessagingController {
11
+ created = async (data, ack) => {
12
+ try {
13
+ const connection = await _models.Connection.create(data);
14
+ if (!connection) {
15
+ (0, _utils.logger)().error(data, 'Não foi possível criar o banco de dados');
16
+ return this.log('Não foi possível criar um banco de dados', 'danger');
17
+ }
18
+ ack();
19
+ } catch (error) {
20
+ (0, _utils.logger)().error(error);
21
+ this.log('Houve um erro ao tentar criar um banco de dados, check o log...', 'danger');
22
+ }
23
+ };
24
+ update = async (data, ack) => {
25
+ try {
26
+ const connection = await _models.Connection.findByPk(data.uuid);
27
+ if (!connection) {
28
+ (0, _utils.logger)().error(data, 'Não foi possível atualizar um banco de dados. Banco não encontrado');
29
+ return this.log('Não foi possível atualizar um banco de dados. Banco não encontrado', 'danger');
30
+ }
31
+ await connection.update(data.updated);
32
+ ack();
33
+ } catch (error) {
34
+ (0, _utils.logger)().error(error);
35
+ this.log('Houve um erro ao tentar atualizar um banco de dados, check o log...', 'danger');
36
+ }
37
+ };
38
+ delete = async (data, ack) => {
39
+ try {
40
+ const connection = await _models.Connection.findByPk(data.uuid);
41
+ if (!connection) {
42
+ (0, _utils.logger)().error(data, 'Não foi possível excluír um banco de dados. Banco não encontrado');
43
+ return this.log('Não foi possível excluír um banco de dados. Banco não encontrado', 'danger');
44
+ }
45
+ await connection.destroy();
46
+ ack();
47
+ } catch (error) {
48
+ (0, _utils.logger)().error(error);
49
+ this.log('Houve um erro ao tentar excluír um banco de dados, check o log...', 'danger');
50
+ }
51
+ };
52
+ }
53
+ var _default = exports.default = DatabaseController;
@@ -0,0 +1,70 @@
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
+ class EnvironmentController extends _app.MessagingController {
11
+ created = async (data, ack) => {
12
+ const db = data.database;
13
+ const token = data.envToken;
14
+ _services.SequelizeService.singleton().createDB(db, token).then(() => {
15
+ _models.EnvConnection.create({
16
+ envUuid: data.uuid,
17
+ connUuid: data.database,
18
+ envToken: data.envToken
19
+ }).then(() => {
20
+ this.log(`New database created sucessfuly: ${db}`);
21
+ ack();
22
+ }).catch(error => {
23
+ new _services.ApplicationException('Erro ao criar a relação env-db', error);
24
+ });
25
+ }).catch(error => {
26
+ new _services.ApplicationException('Erro ao criar o novo banco de dados', error);
27
+ });
28
+ };
29
+ deleted = async (data, ack) => {
30
+ // const uuid = data.uuid;
31
+ const token = data.token;
32
+ const db = data.database;
33
+ try {
34
+ await _services.SequelizeService.singleton().deleteDB(db, token);
35
+ const relation = await _models.EnvConnection.findOne({
36
+ where: {
37
+ envUuid: data.uuid
38
+ }
39
+ });
40
+ if (relation) await relation.destroy();
41
+ this.log(`Database deleted successfully: ${token}`);
42
+ ack();
43
+ } catch (error) {
44
+ throw new _services.ApplicationException('Erro ao deletar a relação env-db ou não foi possível encontrá-la', error);
45
+ }
46
+ };
47
+ updatedToken = async (data, ack) => {
48
+ //TODO: need implement
49
+ };
50
+ updatedDatabase = async (data, ack) => {
51
+ try {
52
+ const relation = await _models.EnvConnection.findOne({
53
+ where: {
54
+ envUuid: data.envUuid
55
+ }
56
+ });
57
+ if (!relation) {
58
+ new _services.ApplicationException('Não foi possível atualizar a relação EDB, a relação não foi encontrada');
59
+ }
60
+ await relation.update({
61
+ connUuid: data.database
62
+ });
63
+ this.log(`A relação para o ambiente ${data.envUuid} foi atualizada, a migração deverá ser realizada de forma manual`);
64
+ ack();
65
+ } catch (error) {
66
+ new _services.ApplicationException('Erro ao atualizar a relação EDB', error);
67
+ }
68
+ };
69
+ }
70
+ var _default = exports.default = EnvironmentController;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
package/lib/index.js ADDED
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {};
7
+ exports.default = void 0;
8
+ var _app = require("./app");
9
+ Object.keys(_app).forEach(function (key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
12
+ if (key in exports && exports[key] === _app[key]) return;
13
+ Object.defineProperty(exports, key, {
14
+ enumerable: true,
15
+ get: function () {
16
+ return _app[key];
17
+ }
18
+ });
19
+ });
20
+ var _contracts = require("./contracts");
21
+ Object.keys(_contracts).forEach(function (key) {
22
+ if (key === "default" || key === "__esModule") return;
23
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
24
+ if (key in exports && exports[key] === _contracts[key]) return;
25
+ Object.defineProperty(exports, key, {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _contracts[key];
29
+ }
30
+ });
31
+ });
32
+ var _controllers = require("./controllers");
33
+ Object.keys(_controllers).forEach(function (key) {
34
+ if (key === "default" || key === "__esModule") return;
35
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
36
+ if (key in exports && exports[key] === _controllers[key]) return;
37
+ Object.defineProperty(exports, key, {
38
+ enumerable: true,
39
+ get: function () {
40
+ return _controllers[key];
41
+ }
42
+ });
43
+ });
44
+ var _middlewares = require("./middlewares");
45
+ Object.keys(_middlewares).forEach(function (key) {
46
+ if (key === "default" || key === "__esModule") return;
47
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
48
+ if (key in exports && exports[key] === _middlewares[key]) return;
49
+ Object.defineProperty(exports, key, {
50
+ enumerable: true,
51
+ get: function () {
52
+ return _middlewares[key];
53
+ }
54
+ });
55
+ });
56
+ var _models = require("./models");
57
+ Object.keys(_models).forEach(function (key) {
58
+ if (key === "default" || key === "__esModule") return;
59
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
60
+ if (key in exports && exports[key] === _models[key]) return;
61
+ Object.defineProperty(exports, key, {
62
+ enumerable: true,
63
+ get: function () {
64
+ return _models[key];
65
+ }
66
+ });
67
+ });
68
+ var _services = require("./services");
69
+ Object.keys(_services).forEach(function (key) {
70
+ if (key === "default" || key === "__esModule") return;
71
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
72
+ if (key in exports && exports[key] === _services[key]) return;
73
+ Object.defineProperty(exports, key, {
74
+ enumerable: true,
75
+ get: function () {
76
+ return _services[key];
77
+ }
78
+ });
79
+ });
80
+ var _utils = require("./utils");
81
+ Object.keys(_utils).forEach(function (key) {
82
+ if (key === "default" || key === "__esModule") return;
83
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
84
+ if (key in exports && exports[key] === _utils[key]) return;
85
+ Object.defineProperty(exports, key, {
86
+ enumerable: true,
87
+ get: function () {
88
+ return _utils[key];
89
+ }
90
+ });
91
+ });
92
+ var _default = exports.default = _app.Exodus;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _dateFns = require("date-fns");
8
+ var _app = require("../app");
9
+ var _controller = _interopRequireDefault(require("../app/controller"));
10
+ var _http = require("../contracts/http");
11
+ var _models = require("../models");
12
+ var _error = require("../services/error");
13
+ var _security = _interopRequireDefault(require("../services/security"));
14
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
+ class AccessMiddleware extends _controller.default {
16
+ accessLevel = level => {
17
+ return (req, res, next) => {
18
+ if (!level.includes(req.auth.account.type)) {
19
+ throw new _error.ApplicationHttpException('Nível de acesso não permitido para esta rota.', _http.EHttpResponseCode.informationBlocked);
20
+ }
21
+ next();
22
+ };
23
+ };
24
+ getTenant = async (req, res, next) => {
25
+ const account = req.auth?.account;
26
+ const tenantId = req.header('X-Exodus-Tenant-ID');
27
+ const applicationId = req.header('X-Exodus-Application-ID');
28
+ let envUuid = '';
29
+
30
+ /* Aplicações */
31
+ if (applicationId) {
32
+ const application = await _models.Application.findOne({
33
+ where: {
34
+ token: applicationId
35
+ }
36
+ });
37
+ if (!application) {
38
+ throw new _error.ApplicationHttpException('Token de aplicação inválido', _http.EHttpResponseCode.informationUnauthorized);
39
+ } else if (!application.active) {
40
+ throw new _error.ApplicationHttpException('Token desativado', _http.EHttpResponseCode.informationBlocked);
41
+ } else if ((0, _dateFns.isBefore)(application.expiresAt, new Date())) {
42
+ throw new _error.ApplicationHttpException('Token expirado', _http.EHttpResponseCode.informationBlocked);
43
+ } else {
44
+ //valido
45
+ const data = await _security.default.singleton().verifySignature(applicationId, _security.default.singleton().getServicePublicKey());
46
+ if (!data) {
47
+ throw new _error.ApplicationHttpException('Token sem autênticidade.', _http.EHttpResponseCode.informationBlocked);
48
+ }
49
+ envUuid = data.envUuid;
50
+ }
51
+ } else if (tenantId) {
52
+ envUuid = tenantId;
53
+ }
54
+ if (account && account.type != 'ADMINISTRATOR') {
55
+ envUuid = account.envUuid;
56
+ }
57
+ req.tenant = {
58
+ id: envUuid || _app.Core.settings.getDatabase().service.database
59
+ };
60
+ next();
61
+ };
62
+ }
63
+ var _default = exports.default = AccessMiddleware;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _expressJwt = require("express-jwt");
8
+ var _app = require("../app");
9
+ var _controller = _interopRequireDefault(require("../app/controller"));
10
+ var _security = _interopRequireDefault(require("../services/security"));
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ class AuthenticationMiddleware extends _controller.default {
13
+ decryptToken = (0, _expressJwt.expressjwt)({
14
+ secret: async () => {
15
+ return _security.default.singleton().getServicePublicKey().toPEM(false);
16
+ },
17
+ issuer: _app.Core.settings.getAuthentication().serviceIssuer,
18
+ algorithms: ['RS256']
19
+ });
20
+ }
21
+ var _default = exports.default = AuthenticationMiddleware;
@@ -0,0 +1,41 @@
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
+ var _multer = _interopRequireDefault(require("multer"));
9
+ var fs = _interopRequireWildcard(require("fs"));
10
+ var _path = _interopRequireDefault(require("path"));
11
+ var _app = require("../app");
12
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
+ class FileMiddleware extends _controller.default {
16
+ storage;
17
+ constructor() {
18
+ super();
19
+ this.initStorage();
20
+ }
21
+ initStorage() {
22
+ this.storage = _multer.default.diskStorage({
23
+ destination: async (req, file, cb) => {
24
+ !fs.existsSync(_app.Core.settings.getAppication().filePaths.temporary) && fs.mkdirSync(_app.Core.settings.getAppication().filePaths.temporary, {
25
+ recursive: true
26
+ });
27
+ cb(null, _app.Core.settings.getAppication().filePaths.temporary);
28
+ },
29
+ filename: (req, file, cb) => {
30
+ const name = Date.now() + _path.default.extname(file.originalname);
31
+ cb(null, name);
32
+ }
33
+ });
34
+ }
35
+ upload = field => {
36
+ return (0, _multer.default)({
37
+ storage: this.storage
38
+ }).single(field);
39
+ };
40
+ }
41
+ var _default = exports.default = FileMiddleware;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "AccessMiddleware", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _access.default;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "AuthenticationMiddleware", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _authentication.default;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "FileMiddleware", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _file.default;
22
+ }
23
+ });
24
+ var _access = _interopRequireDefault(require("./access"));
25
+ var _authentication = _interopRequireDefault(require("./authentication"));
26
+ var _file = _interopRequireDefault(require("./file"));
27
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Application = void 0;
7
+ var _sequelize = require("sequelize");
8
+ var _database = require("../utils/database");
9
+ class Application extends _sequelize.Model {}
10
+ exports.Application = Application;
11
+ Application.init({
12
+ uuid: {
13
+ type: _sequelize.DataTypes.UUID,
14
+ defaultValue: _sequelize.DataTypes.UUIDV4,
15
+ primaryKey: true,
16
+ allowNull: false,
17
+ autoIncrement: false
18
+ },
19
+ name: {
20
+ type: _sequelize.DataTypes.STRING(200),
21
+ allowNull: false
22
+ },
23
+ token: {
24
+ type: _sequelize.DataTypes.TEXT,
25
+ allowNull: false
26
+ },
27
+ key: {
28
+ type: _sequelize.DataTypes.TEXT,
29
+ allowNull: false
30
+ },
31
+ acess: {
32
+ type: _sequelize.DataTypes.JSON(),
33
+ allowNull: true
34
+ },
35
+ expiresAt: {
36
+ type: _sequelize.DataTypes.DATE,
37
+ allowNull: false
38
+ },
39
+ active: {
40
+ type: _sequelize.DataTypes.BOOLEAN,
41
+ defaultValue: true
42
+ },
43
+ comments: {
44
+ type: _sequelize.DataTypes.STRING(255),
45
+ allowNull: true
46
+ },
47
+ params: {
48
+ type: _sequelize.DataTypes.JSON,
49
+ defaultValue: {},
50
+ allowNull: true
51
+ }
52
+ }, {
53
+ tableName: 'connections',
54
+ sequelize: _database.serviceDB,
55
+ indexes: [{
56
+ fields: ['name']
57
+ }, {
58
+ fields: ['token'],
59
+ unique: true
60
+ }]
61
+ });
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Connection = void 0;
7
+ var _sequelize = require("sequelize");
8
+ var _database = require("../utils/database");
9
+ class Connection extends _sequelize.Model {}
10
+ exports.Connection = Connection;
11
+ Connection.init({
12
+ uuid: {
13
+ type: _sequelize.DataTypes.UUID,
14
+ defaultValue: _sequelize.DataTypes.UUIDV4,
15
+ primaryKey: true,
16
+ allowNull: false,
17
+ autoIncrement: false
18
+ },
19
+ name: {
20
+ type: _sequelize.DataTypes.STRING(200),
21
+ allowNull: false
22
+ },
23
+ dialect: {
24
+ type: _sequelize.DataTypes.ENUM('mysql', 'postgres', 'sqlite', 'mariadb', 'mssql', 'db2', 'snowflake', 'oracle'),
25
+ allowNull: false
26
+ },
27
+ username: {
28
+ type: _sequelize.DataTypes.STRING(100),
29
+ allowNull: false
30
+ },
31
+ credential: {
32
+ type: _sequelize.DataTypes.BLOB('medium'),
33
+ allowNull: false
34
+ },
35
+ password: {
36
+ type: _sequelize.DataTypes.STRING(100),
37
+ allowNull: false
38
+ },
39
+ active: {
40
+ type: _sequelize.DataTypes.BOOLEAN,
41
+ defaultValue: true
42
+ },
43
+ params: {
44
+ type: _sequelize.DataTypes.JSON,
45
+ defaultValue: {},
46
+ allowNull: true
47
+ }
48
+ }, {
49
+ tableName: 'connections',
50
+ sequelize: _database.serviceDB,
51
+ indexes: [{
52
+ fields: ['name']
53
+ }]
54
+ });
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.EnvConnection = void 0;
7
+ var _sequelize = require("sequelize");
8
+ var _utils = require("../utils");
9
+ class EnvConnection extends _sequelize.Model {}
10
+ exports.EnvConnection = EnvConnection;
11
+ EnvConnection.init({
12
+ uuid: {
13
+ type: _sequelize.DataTypes.UUID,
14
+ defaultValue: _sequelize.DataTypes.UUIDV4,
15
+ primaryKey: true,
16
+ allowNull: false,
17
+ autoIncrement: false
18
+ },
19
+ connUuid: {
20
+ type: _sequelize.DataTypes.UUID,
21
+ allowNull: false
22
+ },
23
+ envUuid: {
24
+ type: _sequelize.DataTypes.UUID,
25
+ allowNull: false
26
+ },
27
+ envToken: {
28
+ type: _sequelize.DataTypes.UUID,
29
+ allowNull: false
30
+ }
31
+ }, {
32
+ tableName: 'env_connection',
33
+ sequelize: _utils.serviceDB,
34
+ indexes: [{
35
+ fields: ['envUuid'],
36
+ unique: true
37
+ }, {
38
+ fields: ['envToken', 'connUuid'],
39
+ unique: true
40
+ }]
41
+ });
@@ -0,0 +1,46 @@
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 _Connection = require("./Connection");
11
+ Object.keys(_Connection).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] === _Connection[key]) return;
15
+ Object.defineProperty(exports, key, {
16
+ enumerable: true,
17
+ get: function () {
18
+ return _Connection[key];
19
+ }
20
+ });
21
+ });
22
+ var _EnvConnection = require("./EnvConnection");
23
+ Object.keys(_EnvConnection).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] === _EnvConnection[key]) return;
27
+ Object.defineProperty(exports, key, {
28
+ enumerable: true,
29
+ get: function () {
30
+ return _EnvConnection[key];
31
+ }
32
+ });
33
+ });
34
+ var _Application = require("./Application");
35
+ Object.keys(_Application).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] === _Application[key]) return;
39
+ Object.defineProperty(exports, key, {
40
+ enumerable: true,
41
+ get: function () {
42
+ return _Application[key];
43
+ }
44
+ });
45
+ });
46
+ const NativeModels = exports.NativeModels = [_Connection.Connection, _EnvConnection.EnvConnection, _Application.Application];