payservedb 10.1.2 → 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 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payservedb",
3
- "version": "10.1.2",
3
+ "version": "10.1.4",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -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;
@@ -93,8 +93,8 @@ const unitSchema = new mongoose.Schema({
93
93
  occupants: [
94
94
  {
95
95
  customerId: { type: mongoose.Schema.Types.ObjectId, ref: 'Customer' },
96
- customerType: { type: String, enum: ['home owner', 'tenant'] },
97
- residentType: { type: String, enum: ['resident'] },
96
+ customerType: { type: String},
97
+ residentType: { type: String},
98
98
  moveInDate: { type: Date },
99
99
  moveOutDate: { type: Date, default: null }
100
100
  }