@oneuptime/common 7.0.3526 → 7.0.3538
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/Models/DatabaseModels/AlertFeed.ts +12 -4
- package/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.ts +2 -0
- package/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.ts +59 -2
- package/Models/DatabaseModels/UserNotificationRule.ts +50 -0
- package/Models/DatabaseModels/UserOnCallLog.ts +48 -1
- package/Models/DatabaseModels/UserOnCallLogTimeline.ts +49 -2
- package/Server/API/UserOnCallLogTimelineAPI.ts +32 -8
- package/Server/Infrastructure/Postgres/SchemaMigrations/1737141420441-MigrationName.ts +131 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +2 -0
- package/Server/Services/AlertInternalNoteService.ts +73 -0
- package/Server/Services/AlertOwnerTeamService.ts +112 -0
- package/Server/Services/AlertOwnerUserService.ts +114 -0
- package/Server/Services/AlertService.ts +121 -0
- package/Server/Services/AlertStateTimelineService.ts +52 -0
- package/Server/Services/OnCallDutyPolicyEscalationRuleService.ts +32 -14
- package/Server/Services/OnCallDutyPolicyExecutionLogService.ts +86 -27
- package/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.ts +30 -12
- package/Server/Services/UserNotificationRuleService.ts +450 -67
- package/Server/Services/UserOnCallLogService.ts +61 -18
- package/Server/Services/UserOnCallLogTimelineService.ts +25 -11
- package/Types/Email/EmailTemplateType.ts +1 -0
- package/Types/NotificationRule/NotificationRuleType.ts +1 -1
- package/build/dist/Models/DatabaseModels/AlertFeed.js +12 -4
- package/build/dist/Models/DatabaseModels/AlertFeed.js.map +1 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.js +2 -0
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.js.map +1 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.js +60 -2
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserNotificationRule.js +49 -0
- package/build/dist/Models/DatabaseModels/UserNotificationRule.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserOnCallLog.js +48 -1
- package/build/dist/Models/DatabaseModels/UserOnCallLog.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserOnCallLogTimeline.js +50 -2
- package/build/dist/Models/DatabaseModels/UserOnCallLogTimeline.js.map +1 -1
- package/build/dist/Server/API/UserOnCallLogTimelineAPI.js +10 -2
- package/build/dist/Server/API/UserOnCallLogTimelineAPI.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1737141420441-MigrationName.js +50 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1737141420441-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +2 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Services/AlertInternalNoteService.js +56 -0
- package/build/dist/Server/Services/AlertInternalNoteService.js.map +1 -1
- package/build/dist/Server/Services/AlertOwnerTeamService.js +86 -0
- package/build/dist/Server/Services/AlertOwnerTeamService.js.map +1 -1
- package/build/dist/Server/Services/AlertOwnerUserService.js +89 -0
- package/build/dist/Server/Services/AlertOwnerUserService.js.map +1 -1
- package/build/dist/Server/Services/AlertService.js +107 -3
- package/build/dist/Server/Services/AlertService.js.map +1 -1
- package/build/dist/Server/Services/AlertStateTimelineService.js +44 -1
- package/build/dist/Server/Services/AlertStateTimelineService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js +18 -8
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogService.js +70 -24
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.js +26 -11
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.js.map +1 -1
- package/build/dist/Server/Services/UserNotificationRuleService.js +334 -67
- package/build/dist/Server/Services/UserNotificationRuleService.js.map +1 -1
- package/build/dist/Server/Services/UserOnCallLogService.js +66 -27
- package/build/dist/Server/Services/UserOnCallLogService.js.map +1 -1
- package/build/dist/Server/Services/UserOnCallLogTimelineService.js +16 -5
- package/build/dist/Server/Services/UserOnCallLogTimelineService.js.map +1 -1
- package/build/dist/Types/Email/EmailTemplateType.js +1 -0
- package/build/dist/Types/Email/EmailTemplateType.js.map +1 -1
- package/build/dist/Types/NotificationRule/NotificationRuleType.js +1 -1
- package/build/dist/Types/NotificationRule/NotificationRuleType.js.map +1 -1
- package/package.json +2 -2
|
@@ -14,6 +14,9 @@ import OnCallDutyPolicy from "../../Models/DatabaseModels/OnCallDutyPolicy";
|
|
|
14
14
|
import OnCallDutyPolicyService from "./OnCallDutyPolicyService";
|
|
15
15
|
import ObjectID from "../../Types/ObjectID";
|
|
16
16
|
import Color from "../../Types/Color";
|
|
17
|
+
import AlertFeedService from "./AlertFeedService";
|
|
18
|
+
import { AlertFeedEventType } from "../../Models/DatabaseModels/AlertFeed";
|
|
19
|
+
import BadDataException from "../../Types/Exception/BadDataException";
|
|
17
20
|
|
|
18
21
|
export class Service extends DatabaseService<Model> {
|
|
19
22
|
public constructor() {
|
|
@@ -39,7 +42,7 @@ export class Service extends DatabaseService<Model> {
|
|
|
39
42
|
_onCreate: OnCreate<Model>,
|
|
40
43
|
createdItem: Model,
|
|
41
44
|
): Promise<Model> {
|
|
42
|
-
if (createdItem.triggeredByIncidentId) {
|
|
45
|
+
if (createdItem.triggeredByIncidentId || createdItem.triggeredByAlertId) {
|
|
43
46
|
const onCallPolicy: OnCallDutyPolicy | null =
|
|
44
47
|
await OnCallDutyPolicyService.findOneById({
|
|
45
48
|
id: createdItem.onCallDutyPolicyId!,
|
|
@@ -54,13 +57,31 @@ export class Service extends DatabaseService<Model> {
|
|
|
54
57
|
});
|
|
55
58
|
|
|
56
59
|
if (onCallPolicy && onCallPolicy.id) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
const feedInfoInMarkdown: string = `**On Call Policy Started Executing:** On Call Policy **${onCallPolicy.name}** started executing. Users on call on this policy will now be notified.`;
|
|
61
|
+
|
|
62
|
+
if (
|
|
63
|
+
onCallPolicy &&
|
|
64
|
+
onCallPolicy.id &&
|
|
65
|
+
createdItem.triggeredByIncidentId
|
|
66
|
+
) {
|
|
67
|
+
await IncidentFeedService.createIncidentFeed({
|
|
68
|
+
incidentId: createdItem.triggeredByIncidentId,
|
|
69
|
+
projectId: createdItem.projectId!,
|
|
70
|
+
incidentFeedEventType: IncidentFeedEventType.OnCallPolicy,
|
|
71
|
+
displayColor: Yellow500,
|
|
72
|
+
feedInfoInMarkdown: feedInfoInMarkdown,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (onCallPolicy && onCallPolicy.id && createdItem.triggeredByAlertId) {
|
|
77
|
+
await AlertFeedService.createAlertFeed({
|
|
78
|
+
alertId: createdItem.triggeredByAlertId,
|
|
79
|
+
projectId: createdItem.projectId!,
|
|
80
|
+
alertFeedEventType: AlertFeedEventType.OnCallPolicy,
|
|
81
|
+
displayColor: Yellow500,
|
|
82
|
+
feedInfoInMarkdown: feedInfoInMarkdown,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
64
85
|
}
|
|
65
86
|
}
|
|
66
87
|
|
|
@@ -92,12 +113,27 @@ export class Service extends DatabaseService<Model> {
|
|
|
92
113
|
},
|
|
93
114
|
});
|
|
94
115
|
|
|
116
|
+
let userNotificationEventType: UserNotificationEventType | null = null;
|
|
117
|
+
|
|
118
|
+
if (createdItem.triggeredByIncidentId) {
|
|
119
|
+
userNotificationEventType = UserNotificationEventType.IncidentCreated;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (createdItem.triggeredByAlertId) {
|
|
123
|
+
userNotificationEventType = UserNotificationEventType.AlertCreated;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (!userNotificationEventType) {
|
|
127
|
+
throw new BadDataException("Invalid userNotificationEventType");
|
|
128
|
+
}
|
|
129
|
+
|
|
95
130
|
await OnCallDutyPolicyEscalationRuleService.startRuleExecution(
|
|
96
131
|
executionRule.id!,
|
|
97
132
|
{
|
|
98
133
|
projectId: createdItem.projectId!,
|
|
99
134
|
triggeredByIncidentId: createdItem.triggeredByIncidentId,
|
|
100
|
-
|
|
135
|
+
triggeredByAlertId: createdItem.triggeredByAlertId,
|
|
136
|
+
userNotificationEventType: userNotificationEventType,
|
|
101
137
|
onCallPolicyExecutionLogId: createdItem.id!,
|
|
102
138
|
onCallPolicyId: createdItem.onCallDutyPolicyId!,
|
|
103
139
|
},
|
|
@@ -107,7 +143,7 @@ export class Service extends DatabaseService<Model> {
|
|
|
107
143
|
id: createdItem.id!,
|
|
108
144
|
data: {
|
|
109
145
|
status: OnCallDutyPolicyStatus.Executing,
|
|
110
|
-
statusMessage: "First escalation rule executed
|
|
146
|
+
statusMessage: "First escalation rule executed...",
|
|
111
147
|
},
|
|
112
148
|
props: {
|
|
113
149
|
isRoot: true,
|
|
@@ -165,6 +201,7 @@ export class Service extends DatabaseService<Model> {
|
|
|
165
201
|
status: true,
|
|
166
202
|
statusMessage: true,
|
|
167
203
|
triggeredByIncidentId: true,
|
|
204
|
+
triggeredByAlertId: true,
|
|
168
205
|
},
|
|
169
206
|
props: {
|
|
170
207
|
isRoot: true,
|
|
@@ -174,7 +211,8 @@ export class Service extends DatabaseService<Model> {
|
|
|
174
211
|
|
|
175
212
|
if (
|
|
176
213
|
onCalldutyPolicyExecutionLog &&
|
|
177
|
-
onCalldutyPolicyExecutionLog.triggeredByIncidentId
|
|
214
|
+
(onCalldutyPolicyExecutionLog.triggeredByIncidentId ||
|
|
215
|
+
onCalldutyPolicyExecutionLog.triggeredByAlertId)
|
|
178
216
|
) {
|
|
179
217
|
const onCallPolicy: OnCallDutyPolicy | null =
|
|
180
218
|
await OnCallDutyPolicyService.findOneById({
|
|
@@ -190,22 +228,43 @@ export class Service extends DatabaseService<Model> {
|
|
|
190
228
|
});
|
|
191
229
|
|
|
192
230
|
if (onCallPolicy && onCallPolicy.id) {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
231
|
+
const moreInformationInMarkdown: string = `**Status:** ${onCalldutyPolicyExecutionLog.status}
|
|
232
|
+
|
|
233
|
+
**Message:** ${onCalldutyPolicyExecutionLog.statusMessage}`;
|
|
234
|
+
|
|
235
|
+
const feedInfoInMarkdown: string = `**On Call Policy Status Updated:**
|
|
236
|
+
|
|
237
|
+
On-call policy **${onCallPolicy.name}** status updated to **${onCalldutyPolicyExecutionLog.status}**`;
|
|
238
|
+
|
|
239
|
+
if (onCalldutyPolicyExecutionLog.triggeredByIncidentId) {
|
|
240
|
+
await IncidentFeedService.createIncidentFeed({
|
|
241
|
+
incidentId: onCalldutyPolicyExecutionLog.triggeredByIncidentId,
|
|
242
|
+
projectId: onCalldutyPolicyExecutionLog.projectId!,
|
|
243
|
+
incidentFeedEventType: IncidentFeedEventType.OnCallPolicy,
|
|
244
|
+
displayColor: onCalldutyPolicyExecutionLog.status
|
|
245
|
+
? this.getDisplayColorByStatus(
|
|
246
|
+
onCalldutyPolicyExecutionLog.status,
|
|
247
|
+
)
|
|
248
|
+
: Blue500,
|
|
249
|
+
moreInformationInMarkdown: moreInformationInMarkdown,
|
|
250
|
+
feedInfoInMarkdown: feedInfoInMarkdown,
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (onCalldutyPolicyExecutionLog.triggeredByAlertId) {
|
|
255
|
+
await AlertFeedService.createAlertFeed({
|
|
256
|
+
alertId: onCalldutyPolicyExecutionLog.triggeredByAlertId,
|
|
257
|
+
projectId: onCalldutyPolicyExecutionLog.projectId!,
|
|
258
|
+
alertFeedEventType: AlertFeedEventType.OnCallPolicy,
|
|
259
|
+
displayColor: onCalldutyPolicyExecutionLog.status
|
|
260
|
+
? this.getDisplayColorByStatus(
|
|
261
|
+
onCalldutyPolicyExecutionLog.status,
|
|
262
|
+
)
|
|
263
|
+
: Blue500,
|
|
264
|
+
moreInformationInMarkdown: moreInformationInMarkdown,
|
|
265
|
+
feedInfoInMarkdown: feedInfoInMarkdown,
|
|
266
|
+
});
|
|
267
|
+
}
|
|
209
268
|
}
|
|
210
269
|
}
|
|
211
270
|
}
|
|
@@ -9,6 +9,8 @@ import Color from "../../Types/Color";
|
|
|
9
9
|
import ObjectID from "../../Types/ObjectID";
|
|
10
10
|
import logger from "../Utils/Logger";
|
|
11
11
|
import { LIMIT_PER_PROJECT } from "../../Types/Database/LimitMax";
|
|
12
|
+
import AlertFeedService from "./AlertFeedService";
|
|
13
|
+
import { AlertFeedEventType } from "../../Models/DatabaseModels/AlertFeed";
|
|
12
14
|
|
|
13
15
|
export class Service extends DatabaseService<Model> {
|
|
14
16
|
public constructor() {
|
|
@@ -36,7 +38,7 @@ export class Service extends DatabaseService<Model> {
|
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
40
|
|
|
39
|
-
public async
|
|
41
|
+
public async addToIncidentOrAlertFeed(data: {
|
|
40
42
|
onCallDutyPolicyExecutionLogTimelineId: ObjectID;
|
|
41
43
|
}): Promise<void> {
|
|
42
44
|
logger.debug(
|
|
@@ -50,6 +52,7 @@ export class Service extends DatabaseService<Model> {
|
|
|
50
52
|
_id: true,
|
|
51
53
|
onCallDutyPolicyId: true,
|
|
52
54
|
triggeredByIncidentId: true,
|
|
55
|
+
triggeredByAlertId: true,
|
|
53
56
|
projectId: true,
|
|
54
57
|
status: true,
|
|
55
58
|
statusMessage: true,
|
|
@@ -89,7 +92,10 @@ export class Service extends DatabaseService<Model> {
|
|
|
89
92
|
return;
|
|
90
93
|
}
|
|
91
94
|
|
|
92
|
-
if (
|
|
95
|
+
if (
|
|
96
|
+
!onCallDutyPolicyExecutionLogTimeline.triggeredByIncidentId &&
|
|
97
|
+
!onCallDutyPolicyExecutionLogTimeline.triggeredByAlertId
|
|
98
|
+
) {
|
|
93
99
|
return;
|
|
94
100
|
}
|
|
95
101
|
|
|
@@ -120,14 +126,26 @@ The on-call policy **${onCallDutyPolicyExecutionLogTimeline.onCallDutyPolicy.nam
|
|
|
120
126
|
|
|
121
127
|
logger.debug("Feed Info in Markdown: " + feedInfoInMarkdown);
|
|
122
128
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
if (onCallDutyPolicyExecutionLogTimeline.triggeredByIncidentId) {
|
|
130
|
+
await IncidentFeedService.createIncidentFeed({
|
|
131
|
+
incidentId:
|
|
132
|
+
onCallDutyPolicyExecutionLogTimeline.triggeredByIncidentId,
|
|
133
|
+
projectId: onCallDutyPolicyExecutionLogTimeline.projectId!,
|
|
134
|
+
incidentFeedEventType: IncidentFeedEventType.OnCallPolicy,
|
|
135
|
+
displayColor: displayColor,
|
|
136
|
+
feedInfoInMarkdown: feedInfoInMarkdown,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (onCallDutyPolicyExecutionLogTimeline.triggeredByAlertId) {
|
|
141
|
+
await AlertFeedService.createAlertFeed({
|
|
142
|
+
alertId: onCallDutyPolicyExecutionLogTimeline.triggeredByAlertId,
|
|
143
|
+
projectId: onCallDutyPolicyExecutionLogTimeline.projectId!,
|
|
144
|
+
alertFeedEventType: AlertFeedEventType.OnCallPolicy,
|
|
145
|
+
displayColor: displayColor,
|
|
146
|
+
feedInfoInMarkdown: feedInfoInMarkdown,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
131
149
|
|
|
132
150
|
logger.debug("Incident Feed created");
|
|
133
151
|
}
|
|
@@ -141,7 +159,7 @@ The on-call policy **${onCallDutyPolicyExecutionLogTimeline.onCallDutyPolicy.nam
|
|
|
141
159
|
logger.debug("OnCallDutyPolicyExecutionLogTimelineService.onCreateSuccess");
|
|
142
160
|
logger.debug(createdItem);
|
|
143
161
|
|
|
144
|
-
await this.
|
|
162
|
+
await this.addToIncidentOrAlertFeed({
|
|
145
163
|
onCallDutyPolicyExecutionLogTimelineId: createdItem.id!,
|
|
146
164
|
});
|
|
147
165
|
|
|
@@ -166,7 +184,7 @@ The on-call policy **${onCallDutyPolicyExecutionLogTimeline.onCallDutyPolicy.nam
|
|
|
166
184
|
});
|
|
167
185
|
|
|
168
186
|
for (const updatedItem of updatedItems) {
|
|
169
|
-
await this.
|
|
187
|
+
await this.addToIncidentOrAlertFeed({
|
|
170
188
|
onCallDutyPolicyExecutionLogTimelineId: updatedItem.id as ObjectID,
|
|
171
189
|
});
|
|
172
190
|
}
|