@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
|
@@ -23,12 +23,20 @@ import Color from "../../Types/Color";
|
|
|
23
23
|
|
|
24
24
|
export enum AlertFeedEventType {
|
|
25
25
|
PublicNote = "PublicNote",
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
SubscriberNotificationSent = "SubscriberNotificationSent",
|
|
27
|
+
OwnerNotificationSent = "OwnerNotificationSent",
|
|
28
|
+
OwnerUserAdded = "OwnerUserAdded",
|
|
29
|
+
OwnerTeamAdded = "OwnerTeamAdded",
|
|
28
30
|
AlertCreated = "AlertCreated",
|
|
29
|
-
|
|
30
|
-
AlertResolved = "AlertResolved",
|
|
31
|
+
AlertStateChanged = "AlertStateChanged",
|
|
31
32
|
PrivateNote = "PrivateNote",
|
|
33
|
+
AlertUpdated = "AlertUpdated",
|
|
34
|
+
RootCause = "RootCause",
|
|
35
|
+
RemediationNotes = "RemediationNotes",
|
|
36
|
+
OwnerUserRemoved = "OwnerUserRemoved",
|
|
37
|
+
OwnerTeamRemoved = "OwnerTeamRemoved",
|
|
38
|
+
OnCallPolicy = "OnCallPolicy",
|
|
39
|
+
OnCallNotification = "OnCallNotification",
|
|
32
40
|
}
|
|
33
41
|
|
|
34
42
|
@EnableDocumentation()
|
|
@@ -216,6 +216,7 @@ export default class OnCallDutyPolicyExecutionLog extends BaseModel {
|
|
|
216
216
|
@TableColumn({
|
|
217
217
|
type: TableColumnType.ObjectID,
|
|
218
218
|
title: "Triggered By Incident ID",
|
|
219
|
+
required: false,
|
|
219
220
|
description:
|
|
220
221
|
"ID of the incident which triggered this on-call escalation policy.",
|
|
221
222
|
})
|
|
@@ -270,6 +271,7 @@ export default class OnCallDutyPolicyExecutionLog extends BaseModel {
|
|
|
270
271
|
@TableColumn({
|
|
271
272
|
type: TableColumnType.ObjectID,
|
|
272
273
|
title: "Triggered By Alert ID",
|
|
274
|
+
required: false,
|
|
273
275
|
description:
|
|
274
276
|
"ID of the incident which triggered this on-call escalation policy.",
|
|
275
277
|
})
|
|
@@ -26,6 +26,7 @@ import OnCallDutyExecutionLogTimelineStatus from "../../Types/OnCallDutyPolicy/O
|
|
|
26
26
|
import Permission from "../../Types/Permission";
|
|
27
27
|
import UserNotificationEventType from "../../Types/UserNotification/UserNotificationEventType";
|
|
28
28
|
import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm";
|
|
29
|
+
import Alert from "./Alert";
|
|
29
30
|
|
|
30
31
|
@TableBillingAccessControl({
|
|
31
32
|
create: PlanType.Growth,
|
|
@@ -216,18 +217,74 @@ export default class OnCallDutyPolicyExecutionLogTimeline extends BaseModel {
|
|
|
216
217
|
@Index()
|
|
217
218
|
@TableColumn({
|
|
218
219
|
type: TableColumnType.ObjectID,
|
|
219
|
-
required:
|
|
220
|
+
required: false,
|
|
220
221
|
canReadOnRelationQuery: true,
|
|
221
222
|
title: "Incident ID",
|
|
222
223
|
description: "ID of your OneUptime Incident in which this object belongs",
|
|
223
224
|
})
|
|
224
225
|
@Column({
|
|
225
226
|
type: ColumnType.ObjectID,
|
|
226
|
-
nullable:
|
|
227
|
+
nullable: true,
|
|
227
228
|
transformer: ObjectID.getDatabaseTransformer(),
|
|
228
229
|
})
|
|
229
230
|
public triggeredByIncidentId?: ObjectID = undefined;
|
|
230
231
|
|
|
232
|
+
@ColumnAccessControl({
|
|
233
|
+
create: [],
|
|
234
|
+
read: [
|
|
235
|
+
Permission.ProjectOwner,
|
|
236
|
+
Permission.ProjectAdmin,
|
|
237
|
+
Permission.ProjectMember,
|
|
238
|
+
Permission.ReadProjectOnCallDutyPolicyExecutionLogTimeline,
|
|
239
|
+
],
|
|
240
|
+
update: [],
|
|
241
|
+
})
|
|
242
|
+
@TableColumn({
|
|
243
|
+
manyToOneRelationColumn: "triggeredByAlertId",
|
|
244
|
+
type: TableColumnType.Entity,
|
|
245
|
+
modelType: Alert,
|
|
246
|
+
title: "Alert",
|
|
247
|
+
description: "Relation to Alert Resource in which this object belongs",
|
|
248
|
+
})
|
|
249
|
+
@ManyToOne(
|
|
250
|
+
() => {
|
|
251
|
+
return Alert;
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
eager: false,
|
|
255
|
+
nullable: true,
|
|
256
|
+
onDelete: "CASCADE",
|
|
257
|
+
orphanedRowAction: "nullify",
|
|
258
|
+
},
|
|
259
|
+
)
|
|
260
|
+
@JoinColumn({ name: "triggeredByAlertId" })
|
|
261
|
+
public triggeredByAlert?: Alert = undefined;
|
|
262
|
+
|
|
263
|
+
@ColumnAccessControl({
|
|
264
|
+
create: [],
|
|
265
|
+
read: [
|
|
266
|
+
Permission.ProjectOwner,
|
|
267
|
+
Permission.ProjectAdmin,
|
|
268
|
+
Permission.ProjectMember,
|
|
269
|
+
Permission.ReadProjectOnCallDutyPolicyExecutionLogTimeline,
|
|
270
|
+
],
|
|
271
|
+
update: [],
|
|
272
|
+
})
|
|
273
|
+
@Index()
|
|
274
|
+
@TableColumn({
|
|
275
|
+
type: TableColumnType.ObjectID,
|
|
276
|
+
required: false,
|
|
277
|
+
canReadOnRelationQuery: true,
|
|
278
|
+
title: "Alert ID",
|
|
279
|
+
description: "ID of your OneUptime Alert in which this object belongs",
|
|
280
|
+
})
|
|
281
|
+
@Column({
|
|
282
|
+
type: ColumnType.ObjectID,
|
|
283
|
+
nullable: true,
|
|
284
|
+
transformer: ObjectID.getDatabaseTransformer(),
|
|
285
|
+
})
|
|
286
|
+
public triggeredByAlertId?: ObjectID = undefined;
|
|
287
|
+
|
|
231
288
|
@ColumnAccessControl({
|
|
232
289
|
create: [],
|
|
233
290
|
read: [
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import IncidentSeverity from "./IncidentSeverity";
|
|
2
|
+
import AlertSeverity from "./AlertSeverity";
|
|
2
3
|
import Project from "./Project";
|
|
3
4
|
import User from "./User";
|
|
4
5
|
import UserCall from "./UserCall";
|
|
@@ -450,6 +451,55 @@ class UserNotificationRule extends BaseModel {
|
|
|
450
451
|
transformer: ObjectID.getDatabaseTransformer(),
|
|
451
452
|
})
|
|
452
453
|
public incidentSeverityId?: ObjectID = undefined;
|
|
454
|
+
|
|
455
|
+
// alert severity.
|
|
456
|
+
|
|
457
|
+
@ColumnAccessControl({
|
|
458
|
+
create: [Permission.CurrentUser],
|
|
459
|
+
read: [Permission.CurrentUser],
|
|
460
|
+
update: [],
|
|
461
|
+
})
|
|
462
|
+
@TableColumn({
|
|
463
|
+
manyToOneRelationColumn: "alertSeverityId",
|
|
464
|
+
type: TableColumnType.Entity,
|
|
465
|
+
modelType: AlertSeverity,
|
|
466
|
+
title: "Alert Severity",
|
|
467
|
+
description:
|
|
468
|
+
"Relation to Alert Severity Resource in which this object belongs",
|
|
469
|
+
})
|
|
470
|
+
@ManyToOne(
|
|
471
|
+
() => {
|
|
472
|
+
return AlertSeverity;
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
eager: false,
|
|
476
|
+
nullable: true,
|
|
477
|
+
onDelete: "CASCADE",
|
|
478
|
+
orphanedRowAction: "nullify",
|
|
479
|
+
},
|
|
480
|
+
)
|
|
481
|
+
@JoinColumn({ name: "alertSeverityId" })
|
|
482
|
+
public alertSeverity?: AlertSeverity = undefined;
|
|
483
|
+
|
|
484
|
+
@ColumnAccessControl({
|
|
485
|
+
create: [Permission.CurrentUser],
|
|
486
|
+
read: [Permission.CurrentUser],
|
|
487
|
+
update: [],
|
|
488
|
+
})
|
|
489
|
+
@Index()
|
|
490
|
+
@TableColumn({
|
|
491
|
+
type: TableColumnType.ObjectID,
|
|
492
|
+
required: false,
|
|
493
|
+
canReadOnRelationQuery: true,
|
|
494
|
+
title: "Alert Severity ID",
|
|
495
|
+
description: "ID of Alert Severity in which this object belongs",
|
|
496
|
+
})
|
|
497
|
+
@Column({
|
|
498
|
+
type: ColumnType.ObjectID,
|
|
499
|
+
nullable: true,
|
|
500
|
+
transformer: ObjectID.getDatabaseTransformer(),
|
|
501
|
+
})
|
|
502
|
+
public alertSeverityId?: ObjectID = undefined;
|
|
453
503
|
}
|
|
454
504
|
|
|
455
505
|
export default UserNotificationRule;
|
|
@@ -28,6 +28,7 @@ import Permission from "../../Types/Permission";
|
|
|
28
28
|
import UserNotificationEventType from "../../Types/UserNotification/UserNotificationEventType";
|
|
29
29
|
import UserNotificationExecutionStatus from "../../Types/UserNotification/UserNotificationExecutionStatus";
|
|
30
30
|
import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm";
|
|
31
|
+
import Alert from "./Alert";
|
|
31
32
|
|
|
32
33
|
@EnableDocumentation()
|
|
33
34
|
@TenantColumn("projectId")
|
|
@@ -368,16 +369,62 @@ export default class UserOnCallLog extends BaseModel {
|
|
|
368
369
|
@TableColumn({
|
|
369
370
|
type: TableColumnType.ObjectID,
|
|
370
371
|
title: "Triggered By Incident ID",
|
|
372
|
+
required: false,
|
|
371
373
|
description:
|
|
372
374
|
"ID of the incident which triggered this on-call escalation policy.",
|
|
373
375
|
})
|
|
374
376
|
@Column({
|
|
375
377
|
type: ColumnType.ObjectID,
|
|
376
|
-
nullable:
|
|
378
|
+
nullable: true,
|
|
377
379
|
transformer: ObjectID.getDatabaseTransformer(),
|
|
378
380
|
})
|
|
379
381
|
public triggeredByIncidentId?: ObjectID = undefined;
|
|
380
382
|
|
|
383
|
+
@ColumnAccessControl({
|
|
384
|
+
create: [],
|
|
385
|
+
read: [Permission.CurrentUser],
|
|
386
|
+
update: [],
|
|
387
|
+
})
|
|
388
|
+
@TableColumn({
|
|
389
|
+
manyToOneRelationColumn: "triggeredByAlertId",
|
|
390
|
+
type: TableColumnType.Entity,
|
|
391
|
+
modelType: Alert,
|
|
392
|
+
title: "Triggered By Alert",
|
|
393
|
+
description: "Relation to Alert which triggered this on-call duty policy.",
|
|
394
|
+
})
|
|
395
|
+
@ManyToOne(
|
|
396
|
+
() => {
|
|
397
|
+
return Alert;
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
eager: false,
|
|
401
|
+
nullable: true,
|
|
402
|
+
onDelete: "CASCADE",
|
|
403
|
+
orphanedRowAction: "nullify",
|
|
404
|
+
},
|
|
405
|
+
)
|
|
406
|
+
@JoinColumn({ name: "triggeredByAlertId" })
|
|
407
|
+
public triggeredByAlert?: Alert = undefined;
|
|
408
|
+
|
|
409
|
+
@ColumnAccessControl({
|
|
410
|
+
create: [],
|
|
411
|
+
read: [Permission.CurrentUser],
|
|
412
|
+
update: [],
|
|
413
|
+
})
|
|
414
|
+
@TableColumn({
|
|
415
|
+
type: TableColumnType.ObjectID,
|
|
416
|
+
title: "Triggered By Alert ID",
|
|
417
|
+
required: false,
|
|
418
|
+
description:
|
|
419
|
+
"ID of the Alert which triggered this on-call escalation policy.",
|
|
420
|
+
})
|
|
421
|
+
@Column({
|
|
422
|
+
type: ColumnType.ObjectID,
|
|
423
|
+
nullable: true,
|
|
424
|
+
transformer: ObjectID.getDatabaseTransformer(),
|
|
425
|
+
})
|
|
426
|
+
public triggeredByAlertId?: ObjectID = undefined;
|
|
427
|
+
|
|
381
428
|
@ColumnAccessControl({
|
|
382
429
|
create: [],
|
|
383
430
|
read: [Permission.CurrentUser],
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Incident from "./Incident";
|
|
2
|
+
import Alert from "./Alert";
|
|
2
3
|
import OnCallDutyPolicy from "./OnCallDutyPolicy";
|
|
3
4
|
import OnCallDutyPolicyEscalationRule from "./OnCallDutyPolicyEscalationRule";
|
|
4
5
|
import OnCallDutyPolicyExecutionLog from "./OnCallDutyPolicyExecutionLog";
|
|
@@ -325,18 +326,64 @@ export default class UserOnCallLogTimeline extends BaseModel {
|
|
|
325
326
|
@Index()
|
|
326
327
|
@TableColumn({
|
|
327
328
|
type: TableColumnType.ObjectID,
|
|
328
|
-
required:
|
|
329
|
+
required: false,
|
|
329
330
|
canReadOnRelationQuery: true,
|
|
330
331
|
title: "Incident ID",
|
|
331
332
|
description: "ID of your OneUptime Incident in which this object belongs",
|
|
332
333
|
})
|
|
333
334
|
@Column({
|
|
334
335
|
type: ColumnType.ObjectID,
|
|
335
|
-
nullable:
|
|
336
|
+
nullable: true,
|
|
336
337
|
transformer: ObjectID.getDatabaseTransformer(),
|
|
337
338
|
})
|
|
338
339
|
public triggeredByIncidentId?: ObjectID = undefined;
|
|
339
340
|
|
|
341
|
+
@ColumnAccessControl({
|
|
342
|
+
create: [],
|
|
343
|
+
read: [Permission.CurrentUser],
|
|
344
|
+
update: [],
|
|
345
|
+
})
|
|
346
|
+
@TableColumn({
|
|
347
|
+
manyToOneRelationColumn: "triggeredByAlertId",
|
|
348
|
+
type: TableColumnType.Entity,
|
|
349
|
+
modelType: Alert,
|
|
350
|
+
title: "Alert",
|
|
351
|
+
description: "Relation to Alert Resource in which this object belongs",
|
|
352
|
+
})
|
|
353
|
+
@ManyToOne(
|
|
354
|
+
() => {
|
|
355
|
+
return Alert;
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
eager: false,
|
|
359
|
+
nullable: true,
|
|
360
|
+
onDelete: "CASCADE",
|
|
361
|
+
orphanedRowAction: "nullify",
|
|
362
|
+
},
|
|
363
|
+
)
|
|
364
|
+
@JoinColumn({ name: "triggeredByAlertId" })
|
|
365
|
+
public triggeredByAlert?: Alert = undefined;
|
|
366
|
+
|
|
367
|
+
@ColumnAccessControl({
|
|
368
|
+
create: [],
|
|
369
|
+
read: [Permission.CurrentUser],
|
|
370
|
+
update: [],
|
|
371
|
+
})
|
|
372
|
+
@Index()
|
|
373
|
+
@TableColumn({
|
|
374
|
+
type: TableColumnType.ObjectID,
|
|
375
|
+
required: false,
|
|
376
|
+
canReadOnRelationQuery: true,
|
|
377
|
+
title: "Alert ID",
|
|
378
|
+
description: "ID of your OneUptime Alert in which this object belongs",
|
|
379
|
+
})
|
|
380
|
+
@Column({
|
|
381
|
+
type: ColumnType.ObjectID,
|
|
382
|
+
nullable: true,
|
|
383
|
+
transformer: ObjectID.getDatabaseTransformer(),
|
|
384
|
+
})
|
|
385
|
+
public triggeredByAlertId?: ObjectID = undefined;
|
|
386
|
+
|
|
340
387
|
@ColumnAccessControl({
|
|
341
388
|
create: [],
|
|
342
389
|
read: [Permission.CurrentUser],
|
|
@@ -55,6 +55,7 @@ export default class UserNotificationLogTimelineAPI extends BaseAPI<
|
|
|
55
55
|
_id: true,
|
|
56
56
|
projectId: true,
|
|
57
57
|
triggeredByIncidentId: true,
|
|
58
|
+
triggeredByAlertId: true,
|
|
58
59
|
},
|
|
59
60
|
props: {
|
|
60
61
|
isRoot: true,
|
|
@@ -115,6 +116,7 @@ export default class UserNotificationLogTimelineAPI extends BaseAPI<
|
|
|
115
116
|
_id: true,
|
|
116
117
|
projectId: true,
|
|
117
118
|
triggeredByIncidentId: true,
|
|
119
|
+
triggeredByAlertId: true,
|
|
118
120
|
},
|
|
119
121
|
props: {
|
|
120
122
|
isRoot: true,
|
|
@@ -147,16 +149,38 @@ export default class UserNotificationLogTimelineAPI extends BaseAPI<
|
|
|
147
149
|
const host: Hostname = await DatabaseConfig.getHost();
|
|
148
150
|
const httpProtocol: Protocol = await DatabaseConfig.getHttpProtocol();
|
|
149
151
|
|
|
150
|
-
|
|
152
|
+
if (timelineItem.triggeredByIncidentId) {
|
|
153
|
+
return Response.redirect(
|
|
154
|
+
req,
|
|
155
|
+
res,
|
|
156
|
+
new URL(
|
|
157
|
+
httpProtocol,
|
|
158
|
+
host,
|
|
159
|
+
DashboardRoute.addRoute(
|
|
160
|
+
`/${timelineItem.projectId?.toString()}/incidents/${timelineItem.triggeredByIncidentId!.toString()}`,
|
|
161
|
+
),
|
|
162
|
+
),
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (timelineItem.triggeredByAlertId) {
|
|
167
|
+
return Response.redirect(
|
|
168
|
+
req,
|
|
169
|
+
res,
|
|
170
|
+
new URL(
|
|
171
|
+
httpProtocol,
|
|
172
|
+
host,
|
|
173
|
+
DashboardRoute.addRoute(
|
|
174
|
+
`/${timelineItem.projectId?.toString()}/alerts/${timelineItem.triggeredByAlertId!.toString()}`,
|
|
175
|
+
),
|
|
176
|
+
),
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return Response.sendErrorResponse(
|
|
151
181
|
req,
|
|
152
182
|
res,
|
|
153
|
-
new
|
|
154
|
-
httpProtocol,
|
|
155
|
-
host,
|
|
156
|
-
DashboardRoute.addRoute(
|
|
157
|
-
`/${timelineItem.projectId?.toString()}/incidents/${timelineItem.triggeredByIncidentId!.toString()}`,
|
|
158
|
-
),
|
|
159
|
-
),
|
|
183
|
+
new BadDataException("Invalid item Id"),
|
|
160
184
|
);
|
|
161
185
|
},
|
|
162
186
|
);
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
2
|
+
|
|
3
|
+
export class MigrationName1737141420441 implements MigrationInterface {
|
|
4
|
+
public name = "MigrationName1737141420441";
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(
|
|
8
|
+
`ALTER TABLE "OnCallDutyPolicyExecutionLogTimeline" ADD "triggeredByAlertId" uuid`,
|
|
9
|
+
);
|
|
10
|
+
await queryRunner.query(
|
|
11
|
+
`ALTER TABLE "UserNotificationRule" ADD "alertSeverityId" uuid`,
|
|
12
|
+
);
|
|
13
|
+
await queryRunner.query(
|
|
14
|
+
`ALTER TABLE "UserOnCallLog" ADD "triggeredByAlertId" uuid`,
|
|
15
|
+
);
|
|
16
|
+
await queryRunner.query(
|
|
17
|
+
`ALTER TABLE "UserOnCallLogTimeline" ADD "triggeredByAlertId" uuid`,
|
|
18
|
+
);
|
|
19
|
+
await queryRunner.query(
|
|
20
|
+
`ALTER TABLE "OnCallDutyPolicyExecutionLogTimeline" DROP CONSTRAINT "FK_90119ec7f77fa2efd82261e0448"`,
|
|
21
|
+
);
|
|
22
|
+
await queryRunner.query(
|
|
23
|
+
`ALTER TABLE "OnCallDutyPolicyExecutionLogTimeline" ALTER COLUMN "triggeredByIncidentId" DROP NOT NULL`,
|
|
24
|
+
);
|
|
25
|
+
await queryRunner.query(
|
|
26
|
+
`ALTER TABLE "UserOnCallLog" DROP CONSTRAINT "FK_eeb0dd05d1dec542c3de5fb5074"`,
|
|
27
|
+
);
|
|
28
|
+
await queryRunner.query(
|
|
29
|
+
`ALTER TABLE "UserOnCallLog" ALTER COLUMN "triggeredByIncidentId" DROP NOT NULL`,
|
|
30
|
+
);
|
|
31
|
+
await queryRunner.query(
|
|
32
|
+
`ALTER TABLE "UserOnCallLogTimeline" DROP CONSTRAINT "FK_58a44736718a5ec4fe41526289a"`,
|
|
33
|
+
);
|
|
34
|
+
await queryRunner.query(
|
|
35
|
+
`ALTER TABLE "UserOnCallLogTimeline" ALTER COLUMN "triggeredByIncidentId" DROP NOT NULL`,
|
|
36
|
+
);
|
|
37
|
+
await queryRunner.query(
|
|
38
|
+
`CREATE INDEX "IDX_30358ab25e4c6c9ad72e74f201" ON "OnCallDutyPolicyExecutionLogTimeline" ("triggeredByAlertId") `,
|
|
39
|
+
);
|
|
40
|
+
await queryRunner.query(
|
|
41
|
+
`CREATE INDEX "IDX_d73339f6c26fd6ebd0326badcd" ON "UserNotificationRule" ("alertSeverityId") `,
|
|
42
|
+
);
|
|
43
|
+
await queryRunner.query(
|
|
44
|
+
`CREATE INDEX "IDX_42d9916277fcbefa0cdd3904c6" ON "UserOnCallLogTimeline" ("triggeredByAlertId") `,
|
|
45
|
+
);
|
|
46
|
+
await queryRunner.query(
|
|
47
|
+
`ALTER TABLE "OnCallDutyPolicyExecutionLogTimeline" ADD CONSTRAINT "FK_90119ec7f77fa2efd82261e0448" FOREIGN KEY ("triggeredByIncidentId") REFERENCES "Incident"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
48
|
+
);
|
|
49
|
+
await queryRunner.query(
|
|
50
|
+
`ALTER TABLE "OnCallDutyPolicyExecutionLogTimeline" ADD CONSTRAINT "FK_30358ab25e4c6c9ad72e74f201c" FOREIGN KEY ("triggeredByAlertId") REFERENCES "Alert"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
51
|
+
);
|
|
52
|
+
await queryRunner.query(
|
|
53
|
+
`ALTER TABLE "UserNotificationRule" ADD CONSTRAINT "FK_d73339f6c26fd6ebd0326badcd7" FOREIGN KEY ("alertSeverityId") REFERENCES "AlertSeverity"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
54
|
+
);
|
|
55
|
+
await queryRunner.query(
|
|
56
|
+
`ALTER TABLE "UserOnCallLog" ADD CONSTRAINT "FK_eeb0dd05d1dec542c3de5fb5074" FOREIGN KEY ("triggeredByIncidentId") REFERENCES "Incident"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
57
|
+
);
|
|
58
|
+
await queryRunner.query(
|
|
59
|
+
`ALTER TABLE "UserOnCallLog" ADD CONSTRAINT "FK_0ee3711cdc64957845d9d028c31" FOREIGN KEY ("triggeredByAlertId") REFERENCES "Alert"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
60
|
+
);
|
|
61
|
+
await queryRunner.query(
|
|
62
|
+
`ALTER TABLE "UserOnCallLogTimeline" ADD CONSTRAINT "FK_58a44736718a5ec4fe41526289a" FOREIGN KEY ("triggeredByIncidentId") REFERENCES "Incident"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
63
|
+
);
|
|
64
|
+
await queryRunner.query(
|
|
65
|
+
`ALTER TABLE "UserOnCallLogTimeline" ADD CONSTRAINT "FK_42d9916277fcbefa0cdd3904c63" FOREIGN KEY ("triggeredByAlertId") REFERENCES "Alert"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
70
|
+
await queryRunner.query(
|
|
71
|
+
`ALTER TABLE "UserOnCallLogTimeline" DROP CONSTRAINT "FK_42d9916277fcbefa0cdd3904c63"`,
|
|
72
|
+
);
|
|
73
|
+
await queryRunner.query(
|
|
74
|
+
`ALTER TABLE "UserOnCallLogTimeline" DROP CONSTRAINT "FK_58a44736718a5ec4fe41526289a"`,
|
|
75
|
+
);
|
|
76
|
+
await queryRunner.query(
|
|
77
|
+
`ALTER TABLE "UserOnCallLog" DROP CONSTRAINT "FK_0ee3711cdc64957845d9d028c31"`,
|
|
78
|
+
);
|
|
79
|
+
await queryRunner.query(
|
|
80
|
+
`ALTER TABLE "UserOnCallLog" DROP CONSTRAINT "FK_eeb0dd05d1dec542c3de5fb5074"`,
|
|
81
|
+
);
|
|
82
|
+
await queryRunner.query(
|
|
83
|
+
`ALTER TABLE "UserNotificationRule" DROP CONSTRAINT "FK_d73339f6c26fd6ebd0326badcd7"`,
|
|
84
|
+
);
|
|
85
|
+
await queryRunner.query(
|
|
86
|
+
`ALTER TABLE "OnCallDutyPolicyExecutionLogTimeline" DROP CONSTRAINT "FK_30358ab25e4c6c9ad72e74f201c"`,
|
|
87
|
+
);
|
|
88
|
+
await queryRunner.query(
|
|
89
|
+
`ALTER TABLE "OnCallDutyPolicyExecutionLogTimeline" DROP CONSTRAINT "FK_90119ec7f77fa2efd82261e0448"`,
|
|
90
|
+
);
|
|
91
|
+
await queryRunner.query(
|
|
92
|
+
`DROP INDEX "public"."IDX_42d9916277fcbefa0cdd3904c6"`,
|
|
93
|
+
);
|
|
94
|
+
await queryRunner.query(
|
|
95
|
+
`DROP INDEX "public"."IDX_d73339f6c26fd6ebd0326badcd"`,
|
|
96
|
+
);
|
|
97
|
+
await queryRunner.query(
|
|
98
|
+
`DROP INDEX "public"."IDX_30358ab25e4c6c9ad72e74f201"`,
|
|
99
|
+
);
|
|
100
|
+
await queryRunner.query(
|
|
101
|
+
`ALTER TABLE "UserOnCallLogTimeline" ALTER COLUMN "triggeredByIncidentId" SET NOT NULL`,
|
|
102
|
+
);
|
|
103
|
+
await queryRunner.query(
|
|
104
|
+
`ALTER TABLE "UserOnCallLogTimeline" ADD CONSTRAINT "FK_58a44736718a5ec4fe41526289a" FOREIGN KEY ("triggeredByIncidentId") REFERENCES "Incident"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
105
|
+
);
|
|
106
|
+
await queryRunner.query(
|
|
107
|
+
`ALTER TABLE "UserOnCallLog" ALTER COLUMN "triggeredByIncidentId" SET NOT NULL`,
|
|
108
|
+
);
|
|
109
|
+
await queryRunner.query(
|
|
110
|
+
`ALTER TABLE "UserOnCallLog" ADD CONSTRAINT "FK_eeb0dd05d1dec542c3de5fb5074" FOREIGN KEY ("triggeredByIncidentId") REFERENCES "Incident"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
111
|
+
);
|
|
112
|
+
await queryRunner.query(
|
|
113
|
+
`ALTER TABLE "OnCallDutyPolicyExecutionLogTimeline" ALTER COLUMN "triggeredByIncidentId" SET NOT NULL`,
|
|
114
|
+
);
|
|
115
|
+
await queryRunner.query(
|
|
116
|
+
`ALTER TABLE "OnCallDutyPolicyExecutionLogTimeline" ADD CONSTRAINT "FK_90119ec7f77fa2efd82261e0448" FOREIGN KEY ("triggeredByIncidentId") REFERENCES "Incident"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
117
|
+
);
|
|
118
|
+
await queryRunner.query(
|
|
119
|
+
`ALTER TABLE "UserOnCallLogTimeline" DROP COLUMN "triggeredByAlertId"`,
|
|
120
|
+
);
|
|
121
|
+
await queryRunner.query(
|
|
122
|
+
`ALTER TABLE "UserOnCallLog" DROP COLUMN "triggeredByAlertId"`,
|
|
123
|
+
);
|
|
124
|
+
await queryRunner.query(
|
|
125
|
+
`ALTER TABLE "UserNotificationRule" DROP COLUMN "alertSeverityId"`,
|
|
126
|
+
);
|
|
127
|
+
await queryRunner.query(
|
|
128
|
+
`ALTER TABLE "OnCallDutyPolicyExecutionLogTimeline" DROP COLUMN "triggeredByAlertId"`,
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -95,6 +95,7 @@ import { MigrationName1736787495707 } from "./1736787495707-MigrationName";
|
|
|
95
95
|
import { MigrationName1736787985322 } from "./1736787985322-MigrationName";
|
|
96
96
|
import { MigrationName1736788706141 } from "./1736788706141-MigrationName";
|
|
97
97
|
import { MigrationName1736856662868 } from "./1736856662868-MigrationName";
|
|
98
|
+
import { MigrationName1737141420441 } from "./1737141420441-MigrationName";
|
|
98
99
|
|
|
99
100
|
export default [
|
|
100
101
|
InitialMigration,
|
|
@@ -194,4 +195,5 @@ export default [
|
|
|
194
195
|
MigrationName1736787985322,
|
|
195
196
|
MigrationName1736788706141,
|
|
196
197
|
MigrationName1736856662868,
|
|
198
|
+
MigrationName1737141420441,
|
|
197
199
|
];
|
|
@@ -1,10 +1,83 @@
|
|
|
1
|
+
import ObjectID from "../../Types/ObjectID";
|
|
1
2
|
import DatabaseService from "./DatabaseService";
|
|
2
3
|
import Model from "Common/Models/DatabaseModels/AlertInternalNote";
|
|
4
|
+
import { OnCreate, OnUpdate } from "../Types/Database/Hooks";
|
|
5
|
+
import AlertFeedService from "./AlertFeedService";
|
|
6
|
+
import { AlertFeedEventType } from "../../Models/DatabaseModels/AlertFeed";
|
|
7
|
+
import { Blue500 } from "../../Types/BrandColors";
|
|
8
|
+
import { LIMIT_PER_PROJECT } from "../../Types/Database/LimitMax";
|
|
3
9
|
|
|
4
10
|
export class Service extends DatabaseService<Model> {
|
|
5
11
|
public constructor() {
|
|
6
12
|
super(Model);
|
|
7
13
|
}
|
|
14
|
+
|
|
15
|
+
public override async onCreateSuccess(
|
|
16
|
+
_onCreate: OnCreate<Model>,
|
|
17
|
+
createdItem: Model,
|
|
18
|
+
): Promise<Model> {
|
|
19
|
+
const userId: ObjectID | null | undefined =
|
|
20
|
+
createdItem.createdByUserId || createdItem.createdByUser?.id;
|
|
21
|
+
|
|
22
|
+
await AlertFeedService.createAlertFeed({
|
|
23
|
+
alertId: createdItem.alertId!,
|
|
24
|
+
projectId: createdItem.projectId!,
|
|
25
|
+
alertFeedEventType: AlertFeedEventType.PrivateNote,
|
|
26
|
+
displayColor: Blue500,
|
|
27
|
+
userId: userId || undefined,
|
|
28
|
+
|
|
29
|
+
feedInfoInMarkdown: `**Posted Internal / Private Note**
|
|
30
|
+
|
|
31
|
+
${createdItem.note}
|
|
32
|
+
`,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
return createdItem;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public override async onUpdateSuccess(
|
|
39
|
+
onUpdate: OnUpdate<Model>,
|
|
40
|
+
_updatedItemIds: Array<ObjectID>,
|
|
41
|
+
): Promise<OnUpdate<Model>> {
|
|
42
|
+
if (onUpdate.updateBy.data.note) {
|
|
43
|
+
const updatedItems: Array<Model> = await this.findBy({
|
|
44
|
+
query: onUpdate.updateBy.query,
|
|
45
|
+
limit: LIMIT_PER_PROJECT,
|
|
46
|
+
skip: 0,
|
|
47
|
+
props: {
|
|
48
|
+
isRoot: true,
|
|
49
|
+
},
|
|
50
|
+
select: {
|
|
51
|
+
alertId: true,
|
|
52
|
+
projectId: true,
|
|
53
|
+
note: true,
|
|
54
|
+
createdByUserId: true,
|
|
55
|
+
createdByUser: {
|
|
56
|
+
_id: true,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const userId: ObjectID | null | undefined =
|
|
62
|
+
onUpdate.updateBy.props.userId;
|
|
63
|
+
|
|
64
|
+
for (const updatedItem of updatedItems) {
|
|
65
|
+
await AlertFeedService.createAlertFeed({
|
|
66
|
+
alertId: updatedItem.alertId!,
|
|
67
|
+
projectId: updatedItem.projectId!,
|
|
68
|
+
alertFeedEventType: AlertFeedEventType.PrivateNote,
|
|
69
|
+
displayColor: Blue500,
|
|
70
|
+
userId: userId || undefined,
|
|
71
|
+
|
|
72
|
+
feedInfoInMarkdown: `**Updated Internal / Private Note**
|
|
73
|
+
|
|
74
|
+
${updatedItem.note}
|
|
75
|
+
`,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return onUpdate;
|
|
80
|
+
}
|
|
8
81
|
}
|
|
9
82
|
|
|
10
83
|
export default new Service();
|