@dracul/audit-backend 1.12.5 → 1.13.0
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.
|
@@ -10,10 +10,7 @@ const {
|
|
|
10
10
|
} = require("../../services/AuditService.js");
|
|
11
11
|
|
|
12
12
|
const {
|
|
13
|
-
AUDIT_SHOW
|
|
14
|
-
AUDIT_UPDATE,
|
|
15
|
-
AUDIT_CREATE,
|
|
16
|
-
AUDIT_DELETE
|
|
13
|
+
AUDIT_SHOW
|
|
17
14
|
} = require("../../permissions/AuditPermissions.js");
|
|
18
15
|
|
|
19
16
|
const {
|
|
@@ -56,39 +53,6 @@ const resolvers = {
|
|
|
56
53
|
if (!rbac.isAllowed(user.id, AUDIT_SHOW)) throw new ForbiddenError("Not Authorized");
|
|
57
54
|
return paginateAudit(pageNumber, itemsPerPage, search, filters, orderBy, orderDesc);
|
|
58
55
|
}
|
|
59
|
-
},
|
|
60
|
-
Mutation: {
|
|
61
|
-
createAudit: (_, {
|
|
62
|
-
input
|
|
63
|
-
}, {
|
|
64
|
-
user,
|
|
65
|
-
rbac
|
|
66
|
-
}) => {
|
|
67
|
-
if (!user) throw new AuthenticationError("Unauthenticated");
|
|
68
|
-
if (!rbac.isAllowed(user.id, AUDIT_CREATE)) throw new ForbiddenError("Not Authorized");
|
|
69
|
-
return createAudit(user, input);
|
|
70
|
-
},
|
|
71
|
-
updateAudit: (_, {
|
|
72
|
-
id,
|
|
73
|
-
input
|
|
74
|
-
}, {
|
|
75
|
-
user,
|
|
76
|
-
rbac
|
|
77
|
-
}) => {
|
|
78
|
-
if (!user) throw new AuthenticationError("Unauthenticated");
|
|
79
|
-
if (!rbac.isAllowed(user.id, AUDIT_UPDATE)) throw new ForbiddenError("Not Authorized");
|
|
80
|
-
return updateAudit(user, id, input);
|
|
81
|
-
},
|
|
82
|
-
deleteAudit: (_, {
|
|
83
|
-
id
|
|
84
|
-
}, {
|
|
85
|
-
user,
|
|
86
|
-
rbac
|
|
87
|
-
}) => {
|
|
88
|
-
if (!user) throw new AuthenticationError("Unauthenticated");
|
|
89
|
-
if (!rbac.isAllowed(user.id, AUDIT_DELETE)) throw new ForbiddenError("Not Authorized");
|
|
90
|
-
return deleteAudit(id);
|
|
91
|
-
}
|
|
92
56
|
}
|
|
93
57
|
};
|
|
94
58
|
module.exports = resolvers;
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
enum actionEnum{
|
|
2
|
-
RESTART,
|
|
3
|
-
UPDATE,
|
|
4
|
-
REMOVE,
|
|
5
|
-
CREATE
|
|
6
|
-
}
|
|
7
|
-
|
|
8
1
|
type Audit{
|
|
9
2
|
id: ID!
|
|
10
3
|
user: User!
|
|
11
|
-
action:
|
|
12
|
-
|
|
4
|
+
action: String!
|
|
5
|
+
resource: String!
|
|
13
6
|
createdAt: String,
|
|
14
7
|
description: String
|
|
15
8
|
}
|
|
@@ -24,23 +17,4 @@ type Query {
|
|
|
24
17
|
findAudit(id:ID!): Audit
|
|
25
18
|
fetchAudit: [Audit]
|
|
26
19
|
paginateAudit( pageNumber: Int, itemsPerPage: Int, search: String, filters: [FilterInput],orderBy: String, orderDesc: Boolean): AuditPaginated
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
input AuditInput{
|
|
30
|
-
user: ID!
|
|
31
|
-
action: actionEnum!
|
|
32
|
-
target: String!
|
|
33
|
-
description: String
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
type AuditDelete{
|
|
37
|
-
id: ID!
|
|
38
|
-
success: Boolean!
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
type Mutation {
|
|
43
|
-
createAudit(input: AuditInput): Audit
|
|
44
|
-
updateAudit(id: ID!, input: AuditInput): Audit
|
|
45
|
-
deleteAudit(id: ID!): AuditDelete!
|
|
46
|
-
}
|
|
20
|
+
}
|
package/lib/models/AuditModel.js
CHANGED
|
@@ -117,13 +117,13 @@ const paginateAudit = function (pageNumber = 1, itemsPerPage = 5, search = null,
|
|
|
117
117
|
const createAudit = async function (authUser, {
|
|
118
118
|
user,
|
|
119
119
|
action,
|
|
120
|
-
|
|
120
|
+
resource,
|
|
121
121
|
description
|
|
122
122
|
}) {
|
|
123
123
|
const doc = new Audit({
|
|
124
124
|
user,
|
|
125
125
|
action,
|
|
126
|
-
|
|
126
|
+
resource,
|
|
127
127
|
description
|
|
128
128
|
});
|
|
129
129
|
doc.id = doc._id;
|
|
@@ -147,7 +147,7 @@ const createAudit = async function (authUser, {
|
|
|
147
147
|
const updateAudit = async function (authUser, id, {
|
|
148
148
|
user,
|
|
149
149
|
action,
|
|
150
|
-
|
|
150
|
+
resource
|
|
151
151
|
}) {
|
|
152
152
|
return new Promise((resolve, rejects) => {
|
|
153
153
|
Audit.findOneAndUpdate({
|
|
@@ -155,7 +155,7 @@ const updateAudit = async function (authUser, id, {
|
|
|
155
155
|
}, {
|
|
156
156
|
user,
|
|
157
157
|
action,
|
|
158
|
-
|
|
158
|
+
resource
|
|
159
159
|
}, {
|
|
160
160
|
new: true,
|
|
161
161
|
runValidators: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dracul/audit-backend",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"description": "Audit Backend",
|
|
5
5
|
"author": "Cristian Incarnato <cristian.cdi@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/draculjs/modular-framework#readme",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"@dracul/common-backend": "^1.11.4",
|
|
29
29
|
"@dracul/logger-backend": "^1.7.12",
|
|
30
30
|
"@dracul/notification-backend": "^1.11.3",
|
|
31
|
-
"@dracul/settings-backend": "^1.
|
|
32
|
-
"@dracul/user-backend": "^1.
|
|
31
|
+
"@dracul/settings-backend": "^1.13.0",
|
|
32
|
+
"@dracul/user-backend": "^1.13.0",
|
|
33
33
|
"apollo-server-express": "^2.12.0",
|
|
34
34
|
"dayjs": "^1.10.7",
|
|
35
35
|
"dotenv": "^16.0.3",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"mongoose-softdelete": "1.1.0",
|
|
65
65
|
"mongoose-unique-validator": "^2.0.3"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "9738c340cc32c1a3de1bed55e2d744704e60c842"
|
|
68
68
|
}
|