payservedb 10.1.3 → 10.1.4
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/index.js +1 -0
- package/package.json +1 -1
- package/src/models/audit_log.js +51 -0
package/index.js
CHANGED
|
@@ -244,6 +244,7 @@ const models = {
|
|
|
244
244
|
MasterWorkplanChild: require("./src/models/master_workplan_child"),
|
|
245
245
|
DutyRosterChecklist: require("./src/models/dutyRosterChecklist"),
|
|
246
246
|
AuditTrail: require("./src/models/auditTrail"),
|
|
247
|
+
AuditLog: require("./src/models/audit_log"),
|
|
247
248
|
DailyChecklist: require("./src/models/dailyChecklist"),
|
|
248
249
|
CoreInvoiceSettings: require("./src/models/coreInvoiceSettings"),
|
|
249
250
|
FacilityInvoice: require("./src/models/facilityInvoice"),
|
package/package.json
CHANGED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
// Immutable trail of critical (state-changing) requests: who did what, to which
|
|
4
|
+
// record, and with what payload. Read requests are never stored here.
|
|
5
|
+
const auditLogSchema = new mongoose.Schema(
|
|
6
|
+
{
|
|
7
|
+
action: {
|
|
8
|
+
type: String,
|
|
9
|
+
enum: ['CREATE', 'UPDATE', 'DELETE'],
|
|
10
|
+
required: true,
|
|
11
|
+
index: true,
|
|
12
|
+
},
|
|
13
|
+
module: { type: String, required: true, index: true },
|
|
14
|
+
description: { type: String, default: '' },
|
|
15
|
+
|
|
16
|
+
resourceType: { type: String, default: null },
|
|
17
|
+
resourceId: { type: String, default: null, index: true },
|
|
18
|
+
// Business reference of the record (e.g. credit reference) for tracing
|
|
19
|
+
reference: { type: String, default: null, index: true },
|
|
20
|
+
accountNumber: { type: String, default: null, index: true },
|
|
21
|
+
facilityId: { type: String, default: null, index: true },
|
|
22
|
+
|
|
23
|
+
status: { type: String, enum: ['SUCCESS', 'FAILED'], default: 'SUCCESS' },
|
|
24
|
+
errorMessage: { type: String, default: null },
|
|
25
|
+
|
|
26
|
+
// Sanitised request body / changes
|
|
27
|
+
payload: { type: mongoose.Schema.Types.Mixed, default: null },
|
|
28
|
+
|
|
29
|
+
actor: {
|
|
30
|
+
userId: { type: String, default: null, index: true },
|
|
31
|
+
fullName: { type: String, default: null },
|
|
32
|
+
email: { type: String, default: null },
|
|
33
|
+
role: { type: String, default: null },
|
|
34
|
+
type: { type: String, default: null },
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
request: {
|
|
38
|
+
method: { type: String, default: null },
|
|
39
|
+
url: { type: String, default: null },
|
|
40
|
+
ip: { type: String, default: null },
|
|
41
|
+
userAgent: { type: String, default: null },
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
{ timestamps: { createdAt: true, updatedAt: false } }
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
auditLogSchema.index({ createdAt: -1 });
|
|
48
|
+
|
|
49
|
+
const AuditLog = mongoose.model('AuditLog', auditLogSchema);
|
|
50
|
+
|
|
51
|
+
module.exports = AuditLog;
|