@justair/justair-library 4.2.0-delta → 4.2.0-echo
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/package.json +1 -1
- package/src/models/alerts.js +21 -10
- package/src/models/organizations.js +1 -0
package/package.json
CHANGED
package/src/models/alerts.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import mongoose, { Schema } from "mongoose";
|
|
2
2
|
|
|
3
|
-
const recipientSchema = new Schema(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
const recipientSchema = new Schema(
|
|
4
|
+
{
|
|
5
|
+
adminId: {
|
|
6
|
+
type: mongoose.Types.ObjectId,
|
|
7
|
+
ref: "Admin",
|
|
8
|
+
},
|
|
9
|
+
typeOfCommunication: String,
|
|
10
|
+
dateCommunicated: {
|
|
11
|
+
type: Date,
|
|
12
|
+
defult: Date.now,
|
|
13
|
+
},
|
|
12
14
|
},
|
|
13
|
-
}
|
|
15
|
+
{ _id: false }
|
|
16
|
+
);
|
|
14
17
|
|
|
15
18
|
const alertsSchema = mongoose.Schema(
|
|
16
19
|
{
|
|
@@ -18,6 +21,7 @@ const alertsSchema = mongoose.Schema(
|
|
|
18
21
|
type: String,
|
|
19
22
|
enum: ["Data Review"],
|
|
20
23
|
},
|
|
24
|
+
alertConfigurationId: mongoose.Types.ObjectId,
|
|
21
25
|
orgId: { type: mongoose.Types.ObjectId, ref: "Organizations" },
|
|
22
26
|
monitorId: { type: mongoose.Types.ObjectId, ref: "Monitors" },
|
|
23
27
|
status: {
|
|
@@ -36,6 +40,7 @@ const alertsSchema = mongoose.Schema(
|
|
|
36
40
|
alertsSchema.index({ orgId: 1 });
|
|
37
41
|
alertsSchema.index({ monitorId: 1 });
|
|
38
42
|
alertsSchema.index({ type: 1 });
|
|
43
|
+
alertsSchema.index({ alertConfigurationId: 1 });
|
|
39
44
|
|
|
40
45
|
const alertsAuditSchema = mongoose.Schema(
|
|
41
46
|
{
|
|
@@ -45,6 +50,7 @@ const alertsAuditSchema = mongoose.Schema(
|
|
|
45
50
|
type: String,
|
|
46
51
|
enum: ["Data Review"],
|
|
47
52
|
},
|
|
53
|
+
alertConfigurationId: mongoose.Types.ObjectId,
|
|
48
54
|
orgId: { type: mongoose.Types.ObjectId, ref: "Organizations" },
|
|
49
55
|
monitorId: { type: mongoose.Types.ObjectId, ref: "Monitors" },
|
|
50
56
|
status: {
|
|
@@ -71,6 +77,7 @@ alertsSchema.pre("findOneAndDelete", async function () {
|
|
|
71
77
|
timeUpdated: docToDelete.updatedAt,
|
|
72
78
|
type: docToDelete.type,
|
|
73
79
|
orgId: docToDelete.orgId,
|
|
80
|
+
alertConfigurationId: docToDelete.alertConfigurationId,
|
|
74
81
|
monitorId: docToDelete.monitorId,
|
|
75
82
|
status: docToDelete.status,
|
|
76
83
|
actionBy: docToDelete.actionBy,
|
|
@@ -92,6 +99,7 @@ alertsSchema.pre("deleteMany", async function () {
|
|
|
92
99
|
const auditLogs = docsToDelete.map((doc) => ({
|
|
93
100
|
timeUpdated: doc.updatedAt,
|
|
94
101
|
type: doc.type,
|
|
102
|
+
alertConfigurationId: doc.alertConfigurationId,
|
|
95
103
|
orgId: doc.orgId,
|
|
96
104
|
monitorId: doc.monitorId,
|
|
97
105
|
status: doc.status,
|
|
@@ -115,6 +123,7 @@ alertsSchema.pre("deleteOne", async function () {
|
|
|
115
123
|
const auditLog = new AlertsAudit({
|
|
116
124
|
timeUpdated: docToDelete.updatedAt,
|
|
117
125
|
type: docToDelete.type,
|
|
126
|
+
alertConfigurationId: docToDelete.alertConfigurationId,
|
|
118
127
|
orgId: docToDelete.orgId,
|
|
119
128
|
monitorId: docToDelete.monitorId,
|
|
120
129
|
status: docToDelete.status,
|
|
@@ -135,6 +144,7 @@ alertsSchema.pre("findOneAndUpdate", async function () {
|
|
|
135
144
|
const auditLog = new AlertsAudit({
|
|
136
145
|
timeUpdated: docToUpdate.updatedAt,
|
|
137
146
|
type: docToUpdate.type,
|
|
147
|
+
alertConfigurationId: docToUpdate.alertConfigurationId,
|
|
138
148
|
orgId: docToUpdate.orgId,
|
|
139
149
|
monitorId: docToUpdate.monitorId,
|
|
140
150
|
status: docToUpdate.status,
|
|
@@ -155,6 +165,7 @@ alertsSchema.pre("updateMany", async function () {
|
|
|
155
165
|
const auditLogs = docsToUpdate.map((doc) => ({
|
|
156
166
|
timeUpdated: doc.updatedAt,
|
|
157
167
|
type: doc.type,
|
|
168
|
+
alertConfigurationId: doc.alertConfigurationId,
|
|
158
169
|
orgId: doc.orgId,
|
|
159
170
|
monitorId: doc.monitorId,
|
|
160
171
|
status: doc.status,
|