aloux-iam 0.0.115 → 0.0.116
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/.gitattributes +2 -2
- package/CONTRIBUTING.md +1 -1
- package/LICENSE +21 -21
- package/README.md +271 -271
- package/index.js +38 -38
- package/lib/config/utils.js +13 -13
- package/lib/controllers/auth.js +166 -166
- package/lib/controllers/functions.js +86 -86
- package/lib/controllers/history.js +97 -97
- package/lib/controllers/menu.js +101 -101
- package/lib/controllers/operationsAWS.js +228 -228
- package/lib/controllers/permission.js +90 -90
- package/lib/controllers/user.js +848 -880
- package/lib/middleware.js +146 -146
- package/lib/models/Business.js +14 -14
- package/lib/models/Functions.js +13 -13
- package/lib/models/History.js +15 -15
- package/lib/models/Menu.js +17 -17
- package/lib/models/Permission.js +16 -16
- package/lib/models/User.js +115 -115
- package/lib/models/UserProvisional.js +10 -10
- package/lib/router.js +82 -104
- package/lib/services/auth.js +956 -956
- package/lib/services/bigQuery.js +87 -87
- package/lib/services/s3.js +71 -71
- package/lib/services/ses.js +97 -97
- package/lib/services/sns.js +21 -21
- package/lib/services/user.js +99 -99
- package/lib/swagger.yaml +1231 -1231
- package/package.json +38 -38
- package/lib/controllers/label.js +0 -82
- package/lib/controllers/log.js +0 -268
- package/lib/models/Label.js +0 -13
- package/lib/models/Log.js +0 -11
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
const History = require("../models/History");
|
|
2
|
-
const self = module.exports;
|
|
3
|
-
|
|
4
|
-
self.create = async (data) => {
|
|
5
|
-
try {
|
|
6
|
-
const history = new History({
|
|
7
|
-
method: data.originalMethod,
|
|
8
|
-
path: data.route.path,
|
|
9
|
-
payload: data.body,
|
|
10
|
-
createdAt: Date.now(),
|
|
11
|
-
});
|
|
12
|
-
const newHistory = await history.save();
|
|
13
|
-
return newHistory;
|
|
14
|
-
} catch (error) {
|
|
15
|
-
return error;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
self.response = async (_history, response, _createdBy, permission) => {
|
|
20
|
-
try {
|
|
21
|
-
if (_createdBy) {
|
|
22
|
-
await History.updateOne(
|
|
23
|
-
{ _id: _history },
|
|
24
|
-
{ response: response, _createdBy: _createdBy, permission: permission }
|
|
25
|
-
);
|
|
26
|
-
} else {
|
|
27
|
-
await History.updateOne(
|
|
28
|
-
{ _id: _history },
|
|
29
|
-
{ response: response, permission: permission }
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
return true;
|
|
33
|
-
} catch (error) {
|
|
34
|
-
return error;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
self.retrieve = async (req, res) => {
|
|
39
|
-
try {
|
|
40
|
-
let query = { $and: [] };
|
|
41
|
-
const response = { items: [], count: 0 };
|
|
42
|
-
|
|
43
|
-
if (req.body?.filter?.method) {
|
|
44
|
-
query.$and.push({ method: req.body.filter.method });
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (req.body?.filter?.description) {
|
|
48
|
-
query.$and.push({
|
|
49
|
-
permission: { $regex: req.body.filter.description, $options: "i" },
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (req.body?.filter?._user) {
|
|
54
|
-
query.$and.push({ _createdBy: req.body.filter._user });
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (req.body.filter?.dateStart > 0 && req.body.filter?.dateEnd > 0) {
|
|
58
|
-
query.$and.push({
|
|
59
|
-
createdAt: {
|
|
60
|
-
$gte: req.body.filter.dateStart,
|
|
61
|
-
$lte: req.body.filter.dateEnd,
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (query.$and.length === 0) {
|
|
67
|
-
query = {};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
response.count = await History.countDocuments(query);
|
|
71
|
-
response.items = await History.find(query)
|
|
72
|
-
.populate({ path: "_createdBy", select: { name: 1, lastName: 1 } })
|
|
73
|
-
.sort({ createdAt: -1 })
|
|
74
|
-
.skip((req.body.config.page - 1) * req.body.config.itemsPerPage)
|
|
75
|
-
.limit(req.body.config.itemsPerPage)
|
|
76
|
-
.lean();
|
|
77
|
-
|
|
78
|
-
res.status(200).send(response);
|
|
79
|
-
} catch (error) {
|
|
80
|
-
res.status(400).send(error);
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
self.detail = async (req, res) => {
|
|
85
|
-
try {
|
|
86
|
-
const history = await History.findOne({ _id: req.params.HISTORY_ID });
|
|
87
|
-
if (!history) {
|
|
88
|
-
return res.status(404).send({
|
|
89
|
-
error: "No se encontró el elemento",
|
|
90
|
-
suggestion: "Verifica que el id del registro sea correcto",
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
res.status(200).send(history);
|
|
94
|
-
} catch (error) {
|
|
95
|
-
res.status(400).send(error);
|
|
96
|
-
}
|
|
97
|
-
};
|
|
1
|
+
const History = require("../models/History");
|
|
2
|
+
const self = module.exports;
|
|
3
|
+
|
|
4
|
+
self.create = async (data) => {
|
|
5
|
+
try {
|
|
6
|
+
const history = new History({
|
|
7
|
+
method: data.originalMethod,
|
|
8
|
+
path: data.route.path,
|
|
9
|
+
payload: data.body,
|
|
10
|
+
createdAt: Date.now(),
|
|
11
|
+
});
|
|
12
|
+
const newHistory = await history.save();
|
|
13
|
+
return newHistory;
|
|
14
|
+
} catch (error) {
|
|
15
|
+
return error;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
self.response = async (_history, response, _createdBy, permission) => {
|
|
20
|
+
try {
|
|
21
|
+
if (_createdBy) {
|
|
22
|
+
await History.updateOne(
|
|
23
|
+
{ _id: _history },
|
|
24
|
+
{ response: response, _createdBy: _createdBy, permission: permission }
|
|
25
|
+
);
|
|
26
|
+
} else {
|
|
27
|
+
await History.updateOne(
|
|
28
|
+
{ _id: _history },
|
|
29
|
+
{ response: response, permission: permission }
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
} catch (error) {
|
|
34
|
+
return error;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
self.retrieve = async (req, res) => {
|
|
39
|
+
try {
|
|
40
|
+
let query = { $and: [] };
|
|
41
|
+
const response = { items: [], count: 0 };
|
|
42
|
+
|
|
43
|
+
if (req.body?.filter?.method) {
|
|
44
|
+
query.$and.push({ method: req.body.filter.method });
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (req.body?.filter?.description) {
|
|
48
|
+
query.$and.push({
|
|
49
|
+
permission: { $regex: req.body.filter.description, $options: "i" },
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (req.body?.filter?._user) {
|
|
54
|
+
query.$and.push({ _createdBy: req.body.filter._user });
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (req.body.filter?.dateStart > 0 && req.body.filter?.dateEnd > 0) {
|
|
58
|
+
query.$and.push({
|
|
59
|
+
createdAt: {
|
|
60
|
+
$gte: req.body.filter.dateStart,
|
|
61
|
+
$lte: req.body.filter.dateEnd,
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (query.$and.length === 0) {
|
|
67
|
+
query = {};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
response.count = await History.countDocuments(query);
|
|
71
|
+
response.items = await History.find(query)
|
|
72
|
+
.populate({ path: "_createdBy", select: { name: 1, lastName: 1 } })
|
|
73
|
+
.sort({ createdAt: -1 })
|
|
74
|
+
.skip((req.body.config.page - 1) * req.body.config.itemsPerPage)
|
|
75
|
+
.limit(req.body.config.itemsPerPage)
|
|
76
|
+
.lean();
|
|
77
|
+
|
|
78
|
+
res.status(200).send(response);
|
|
79
|
+
} catch (error) {
|
|
80
|
+
res.status(400).send(error);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
self.detail = async (req, res) => {
|
|
85
|
+
try {
|
|
86
|
+
const history = await History.findOne({ _id: req.params.HISTORY_ID });
|
|
87
|
+
if (!history) {
|
|
88
|
+
return res.status(404).send({
|
|
89
|
+
error: "No se encontró el elemento",
|
|
90
|
+
suggestion: "Verifica que el id del registro sea correcto",
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
res.status(200).send(history);
|
|
94
|
+
} catch (error) {
|
|
95
|
+
res.status(400).send(error);
|
|
96
|
+
}
|
|
97
|
+
};
|
package/lib/controllers/menu.js
CHANGED
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
const Menu = require('../models/Menu')
|
|
2
|
-
const self = module.exports
|
|
3
|
-
|
|
4
|
-
self.create = async (req, res) => {
|
|
5
|
-
try {
|
|
6
|
-
const menu = new Menu(req.body)
|
|
7
|
-
menu.createdAt = (new Date()).getTime()
|
|
8
|
-
menu.status = 'Activo'
|
|
9
|
-
await menu.save()
|
|
10
|
-
res.status(201).send(menu)
|
|
11
|
-
} catch (error) {
|
|
12
|
-
res.status(400).send({error:error.message})
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
self.update = async (req, resp) => {
|
|
17
|
-
try {
|
|
18
|
-
await (new Menu(req.body)).validate()
|
|
19
|
-
const _id = req.params.MENU_ID
|
|
20
|
-
const count = await Menu.findOne({_id}).countDocuments()
|
|
21
|
-
if(!count)
|
|
22
|
-
throw new Error('Upss! No se encontró el registro')
|
|
23
|
-
req.body.lastUpdate = (new Date()).getTime()
|
|
24
|
-
const result = await Menu.updateOne({_id}, req.body)
|
|
25
|
-
resp.status(200).send(req.body)
|
|
26
|
-
} catch (error) {
|
|
27
|
-
resp.status(400).send({error:error.message})
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
self.status = async (req, resp) => {
|
|
31
|
-
try {
|
|
32
|
-
const _id = req.params.MENU_ID
|
|
33
|
-
const user = await Menu.findOne({ _id })
|
|
34
|
-
if(!user)
|
|
35
|
-
throw new Error('Upss! No se encontró el Elemento')
|
|
36
|
-
user.status = req.body.status
|
|
37
|
-
user.lastUpdate = (new Date()).getTime()
|
|
38
|
-
const result = await user.save()
|
|
39
|
-
resp.status(200).send(result)
|
|
40
|
-
} catch (error) {
|
|
41
|
-
resp.status(400).send({error:error.message})
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
self.retrieve = async(req, res) => {
|
|
45
|
-
try {
|
|
46
|
-
const consulta = await Menu.find({}).sort({index:1})
|
|
47
|
-
if(!consulta)
|
|
48
|
-
res.status(404).send()
|
|
49
|
-
res.status(200).send(consulta)
|
|
50
|
-
} catch (error) {
|
|
51
|
-
res.status(400).send(error)
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
self.get = async(req, res) => {
|
|
56
|
-
try {
|
|
57
|
-
const _id = req.params.MENU_ID
|
|
58
|
-
const menu = await Menu.findOne({_id})
|
|
59
|
-
if(!menu)
|
|
60
|
-
res.status(404).send()
|
|
61
|
-
res.status(200).send(menu)
|
|
62
|
-
} catch (error) {
|
|
63
|
-
res.status(400).send(error)
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
self.delete = async(req, res) => {
|
|
68
|
-
try {
|
|
69
|
-
const _id = req.params.MENU_ID
|
|
70
|
-
const response = await Menu.deleteOne({ _id })
|
|
71
|
-
if(!response.deletedCount)
|
|
72
|
-
res.status(404).send({ error : "El registro no existe"})
|
|
73
|
-
else
|
|
74
|
-
res.status(200).send({})
|
|
75
|
-
} catch (error) {
|
|
76
|
-
res.status(400).send({error:error.message})
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
self.order = async (req, resp) => {
|
|
81
|
-
try {
|
|
82
|
-
if(!req.body.length)
|
|
83
|
-
throw new Error('Upss! No se encontró el registro')
|
|
84
|
-
|
|
85
|
-
for(let i in req.body){
|
|
86
|
-
const item = req.body[i]
|
|
87
|
-
await Menu.updateOne({ _id:item._id }, { $set: { index: item.index } })
|
|
88
|
-
}
|
|
89
|
-
resp.status(200).send({})
|
|
90
|
-
} catch (error) {
|
|
91
|
-
resp.status(400).send({error:error.message})
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
self.count = async(req, res) => {
|
|
96
|
-
try {
|
|
97
|
-
let result = await Menu.find({}).countDocuments()
|
|
98
|
-
res.status(200).send({ count: result })
|
|
99
|
-
} catch (error) {
|
|
100
|
-
res.status(400).send({error:error.message})
|
|
101
|
-
}
|
|
1
|
+
const Menu = require('../models/Menu')
|
|
2
|
+
const self = module.exports
|
|
3
|
+
|
|
4
|
+
self.create = async (req, res) => {
|
|
5
|
+
try {
|
|
6
|
+
const menu = new Menu(req.body)
|
|
7
|
+
menu.createdAt = (new Date()).getTime()
|
|
8
|
+
menu.status = 'Activo'
|
|
9
|
+
await menu.save()
|
|
10
|
+
res.status(201).send(menu)
|
|
11
|
+
} catch (error) {
|
|
12
|
+
res.status(400).send({error:error.message})
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
self.update = async (req, resp) => {
|
|
17
|
+
try {
|
|
18
|
+
await (new Menu(req.body)).validate()
|
|
19
|
+
const _id = req.params.MENU_ID
|
|
20
|
+
const count = await Menu.findOne({_id}).countDocuments()
|
|
21
|
+
if(!count)
|
|
22
|
+
throw new Error('Upss! No se encontró el registro')
|
|
23
|
+
req.body.lastUpdate = (new Date()).getTime()
|
|
24
|
+
const result = await Menu.updateOne({_id}, req.body)
|
|
25
|
+
resp.status(200).send(req.body)
|
|
26
|
+
} catch (error) {
|
|
27
|
+
resp.status(400).send({error:error.message})
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
self.status = async (req, resp) => {
|
|
31
|
+
try {
|
|
32
|
+
const _id = req.params.MENU_ID
|
|
33
|
+
const user = await Menu.findOne({ _id })
|
|
34
|
+
if(!user)
|
|
35
|
+
throw new Error('Upss! No se encontró el Elemento')
|
|
36
|
+
user.status = req.body.status
|
|
37
|
+
user.lastUpdate = (new Date()).getTime()
|
|
38
|
+
const result = await user.save()
|
|
39
|
+
resp.status(200).send(result)
|
|
40
|
+
} catch (error) {
|
|
41
|
+
resp.status(400).send({error:error.message})
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
self.retrieve = async(req, res) => {
|
|
45
|
+
try {
|
|
46
|
+
const consulta = await Menu.find({}).sort({index:1})
|
|
47
|
+
if(!consulta)
|
|
48
|
+
res.status(404).send()
|
|
49
|
+
res.status(200).send(consulta)
|
|
50
|
+
} catch (error) {
|
|
51
|
+
res.status(400).send(error)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
self.get = async(req, res) => {
|
|
56
|
+
try {
|
|
57
|
+
const _id = req.params.MENU_ID
|
|
58
|
+
const menu = await Menu.findOne({_id})
|
|
59
|
+
if(!menu)
|
|
60
|
+
res.status(404).send()
|
|
61
|
+
res.status(200).send(menu)
|
|
62
|
+
} catch (error) {
|
|
63
|
+
res.status(400).send(error)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
self.delete = async(req, res) => {
|
|
68
|
+
try {
|
|
69
|
+
const _id = req.params.MENU_ID
|
|
70
|
+
const response = await Menu.deleteOne({ _id })
|
|
71
|
+
if(!response.deletedCount)
|
|
72
|
+
res.status(404).send({ error : "El registro no existe"})
|
|
73
|
+
else
|
|
74
|
+
res.status(200).send({})
|
|
75
|
+
} catch (error) {
|
|
76
|
+
res.status(400).send({error:error.message})
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
self.order = async (req, resp) => {
|
|
81
|
+
try {
|
|
82
|
+
if(!req.body.length)
|
|
83
|
+
throw new Error('Upss! No se encontró el registro')
|
|
84
|
+
|
|
85
|
+
for(let i in req.body){
|
|
86
|
+
const item = req.body[i]
|
|
87
|
+
await Menu.updateOne({ _id:item._id }, { $set: { index: item.index } })
|
|
88
|
+
}
|
|
89
|
+
resp.status(200).send({})
|
|
90
|
+
} catch (error) {
|
|
91
|
+
resp.status(400).send({error:error.message})
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
self.count = async(req, res) => {
|
|
96
|
+
try {
|
|
97
|
+
let result = await Menu.find({}).countDocuments()
|
|
98
|
+
res.status(200).send({ count: result })
|
|
99
|
+
} catch (error) {
|
|
100
|
+
res.status(400).send({error:error.message})
|
|
101
|
+
}
|
|
102
102
|
}
|