@dracul/audit-backend 1.13.2 → 1.14.10
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.
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const AUDIT_MENU = "AUDIT_MENU";
|
|
4
3
|
const AUDIT_SHOW = "AUDIT_SHOW";
|
|
5
|
-
const AUDIT_UPDATE = "AUDIT_UPDATE";
|
|
6
|
-
const AUDIT_CREATE = "AUDIT_CREATE";
|
|
7
|
-
const AUDIT_DELETE = "AUDIT_DELETE";
|
|
8
4
|
module.exports = {
|
|
9
|
-
|
|
10
|
-
AUDIT_CREATE,
|
|
11
|
-
AUDIT_SHOW,
|
|
12
|
-
AUDIT_UPDATE,
|
|
13
|
-
AUDIT_DELETE
|
|
5
|
+
AUDIT_SHOW
|
|
14
6
|
};
|
|
@@ -26,7 +26,12 @@ const paginateAudit = function (pageNumber = 1, itemsPerPage = 5, search = null,
|
|
|
26
26
|
|
|
27
27
|
if (search) {
|
|
28
28
|
qs = {
|
|
29
|
-
$or: [
|
|
29
|
+
$or: [{
|
|
30
|
+
action: {
|
|
31
|
+
$regex: search,
|
|
32
|
+
$options: 'i'
|
|
33
|
+
}
|
|
34
|
+
}]
|
|
30
35
|
};
|
|
31
36
|
}
|
|
32
37
|
|
|
@@ -144,56 +149,9 @@ const createAudit = async function (authUser, {
|
|
|
144
149
|
});
|
|
145
150
|
};
|
|
146
151
|
|
|
147
|
-
const updateAudit = async function (authUser, id, {
|
|
148
|
-
user,
|
|
149
|
-
action,
|
|
150
|
-
resource
|
|
151
|
-
}) {
|
|
152
|
-
return new Promise((resolve, rejects) => {
|
|
153
|
-
Audit.findOneAndUpdate({
|
|
154
|
-
_id: id
|
|
155
|
-
}, {
|
|
156
|
-
user,
|
|
157
|
-
action,
|
|
158
|
-
resource
|
|
159
|
-
}, {
|
|
160
|
-
new: true,
|
|
161
|
-
runValidators: true,
|
|
162
|
-
context: 'query'
|
|
163
|
-
}, (error, doc) => {
|
|
164
|
-
if (error) {
|
|
165
|
-
if (error.name == "ValidationError") {
|
|
166
|
-
return rejects(new UserInputError(error.message, {
|
|
167
|
-
inputErrors: error.errors
|
|
168
|
-
}));
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return rejects(error);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
doc.populate('user').execPopulate(() => resolve(doc));
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
const deleteAudit = function (id) {
|
|
180
|
-
return new Promise((resolve, rejects) => {
|
|
181
|
-
findAudit(id).then(doc => {
|
|
182
|
-
doc.delete(function (err) {
|
|
183
|
-
err ? rejects(err) : resolve({
|
|
184
|
-
id: id,
|
|
185
|
-
success: true
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
};
|
|
191
|
-
|
|
192
152
|
module.exports = {
|
|
193
153
|
createAudit,
|
|
194
154
|
fetchAudit,
|
|
195
|
-
updateAudit,
|
|
196
|
-
deleteAudit,
|
|
197
155
|
paginateAudit,
|
|
198
156
|
findAudit
|
|
199
157
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dracul/audit-backend",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.10",
|
|
4
4
|
"description": "Audit Backend",
|
|
5
5
|
"author": "Cristian Incarnato <cristian.cdi@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/draculjs/modular-framework#readme",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@dracul/common-backend": "^1.11.4",
|
|
29
29
|
"@dracul/logger-backend": "^1.7.12",
|
|
30
|
-
"@dracul/notification-backend": "^1.11.
|
|
30
|
+
"@dracul/notification-backend": "^1.11.4",
|
|
31
31
|
"@dracul/settings-backend": "^1.13.2",
|
|
32
|
-
"@dracul/user-backend": "^1.
|
|
32
|
+
"@dracul/user-backend": "^1.14.10",
|
|
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": "4d85c98931f48da6899c1b371133dfb6cc098218"
|
|
68
68
|
}
|