@oneuptime/common 7.0.3655 → 7.0.3669
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/Alert.ts +3 -3
- package/Models/DatabaseModels/Incident.ts +3 -3
- package/Models/DatabaseModels/ScheduledMaintenance.ts +3 -3
- package/Server/API/BaseAPI.ts +48 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1739374537088-MigrationName.ts +29 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +2 -0
- package/Server/Services/IncidentService.ts +101 -0
- package/Server/Services/MonitorService.ts +43 -0
- package/Server/Services/WorkspaceNotificationRuleService.ts +440 -14
- package/Server/Services/WorkspaceProjectAuthTokenService.ts +43 -15
- package/Server/Utils/Slack/Slack.ts +156 -23
- package/Types/Workspace/NotificationRules/BaseNotificationRule.ts +9 -0
- package/Types/Workspace/NotificationRules/NotificationRuleCondition.ts +23 -32
- package/Types/Workspace/NotificationRules/NotificationRuleTypes/AlertNotificationRule.ts +15 -0
- package/Types/Workspace/NotificationRules/NotificationRuleTypes/IncidentNotificationRule.ts +15 -0
- package/Types/Workspace/NotificationRules/NotificationRuleTypes/MonitorStatusNotificationRule.ts +7 -0
- package/Types/Workspace/NotificationRules/NotificationRuleTypes/ScheduledMaintenanceNotificationRule.ts +14 -0
- package/Types/Workspace/NotificationRules/NotificationRuleUtil.ts +261 -0
- package/Types/Workspace/WorkspaceChannelInvitationPayload.ts +4 -0
- package/Types/Workspace/WorkspaceMessagePayload.ts +30 -0
- package/build/dist/Models/DatabaseModels/Alert.js +4 -4
- package/build/dist/Models/DatabaseModels/Alert.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Incident.js +4 -4
- package/build/dist/Models/DatabaseModels/Incident.js.map +1 -1
- package/build/dist/Models/DatabaseModels/ScheduledMaintenance.js +4 -4
- package/build/dist/Models/DatabaseModels/ScheduledMaintenance.js.map +1 -1
- package/build/dist/Server/API/BaseAPI.js +34 -2
- package/build/dist/Server/API/BaseAPI.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1739374537088-MigrationName.js +16 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1739374537088-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/IncidentService.js +84 -0
- package/build/dist/Server/Services/IncidentService.js.map +1 -1
- package/build/dist/Server/Services/MonitorService.js +34 -0
- package/build/dist/Server/Services/MonitorService.js.map +1 -1
- package/build/dist/Server/Services/WorkspaceNotificationRuleService.js +314 -10
- package/build/dist/Server/Services/WorkspaceNotificationRuleService.js.map +1 -1
- package/build/dist/Server/Services/WorkspaceProjectAuthTokenService.js +29 -4
- package/build/dist/Server/Services/WorkspaceProjectAuthTokenService.js.map +1 -1
- package/build/dist/Server/Utils/Slack/Slack.js +99 -13
- package/build/dist/Server/Utils/Slack/Slack.js.map +1 -1
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleCondition.js +20 -21
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleCondition.js.map +1 -1
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleTypes/AlertNotificationRule.js +2 -0
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleTypes/AlertNotificationRule.js.map +1 -0
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleTypes/IncidentNotificationRule.js +2 -0
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleTypes/IncidentNotificationRule.js.map +1 -0
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleTypes/MonitorStatusNotificationRule.js +2 -0
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleTypes/MonitorStatusNotificationRule.js.map +1 -0
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleTypes/ScheduledMaintenanceNotificationRule.js +2 -0
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleTypes/ScheduledMaintenanceNotificationRule.js.map +1 -0
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleUtil.js +216 -0
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleUtil.js.map +1 -0
- package/build/dist/Types/Workspace/WorkspaceChannelInvitationPayload.js +2 -0
- package/build/dist/Types/Workspace/WorkspaceChannelInvitationPayload.js.map +1 -0
- package/build/dist/Types/Workspace/WorkspaceMessagePayload.js +2 -0
- package/build/dist/Types/Workspace/WorkspaceMessagePayload.js.map +1 -0
- package/package.json +2 -2
- package/Types/Workspace/NotificationRules/SlackNotificationRule.ts +0 -19
- package/Types/Workspace/WorkspaceNotificationPayload.ts +0 -29
- package/build/dist/Types/Workspace/NotificationRules/SlackNotificationRule.js +0 -2
- package/build/dist/Types/Workspace/NotificationRules/SlackNotificationRule.js.map +0 -1
- package/build/dist/Types/Workspace/WorkspaceNotificationPayload.js +0 -2
- package/build/dist/Types/Workspace/WorkspaceNotificationPayload.js.map +0 -1
|
@@ -1045,13 +1045,13 @@ export default class Alert extends BaseModel {
|
|
|
1045
1045
|
isDefaultValueColumn: false,
|
|
1046
1046
|
required: false,
|
|
1047
1047
|
type: TableColumnType.ShortText,
|
|
1048
|
-
title: "Post Updates To
|
|
1049
|
-
description: "Post Updates To
|
|
1048
|
+
title: "Post Updates To Workspace Channel Name",
|
|
1049
|
+
description: "Post Updates To Workspace Channel Name",
|
|
1050
1050
|
})
|
|
1051
1051
|
@Column({
|
|
1052
1052
|
type: ColumnType.ShortText,
|
|
1053
1053
|
length: ColumnLength.ShortText,
|
|
1054
1054
|
nullable: true,
|
|
1055
1055
|
})
|
|
1056
|
-
public
|
|
1056
|
+
public postUpdatesToWorkspaceChannelName?: number = undefined;
|
|
1057
1057
|
}
|
|
@@ -1130,13 +1130,13 @@ export default class Incident extends BaseModel {
|
|
|
1130
1130
|
isDefaultValueColumn: false,
|
|
1131
1131
|
required: false,
|
|
1132
1132
|
type: TableColumnType.ShortText,
|
|
1133
|
-
title: "Post Updates To
|
|
1134
|
-
description: "Post Updates To
|
|
1133
|
+
title: "Post Updates To Workspace Channel Name",
|
|
1134
|
+
description: "Post Updates To Workspace Channel Name",
|
|
1135
1135
|
})
|
|
1136
1136
|
@Column({
|
|
1137
1137
|
type: ColumnType.ShortText,
|
|
1138
1138
|
length: ColumnLength.ShortText,
|
|
1139
1139
|
nullable: true,
|
|
1140
1140
|
})
|
|
1141
|
-
public
|
|
1141
|
+
public postUpdatesToWorkspaceChannelName?: number = undefined;
|
|
1142
1142
|
}
|
|
@@ -989,13 +989,13 @@ export default class ScheduledMaintenance extends BaseModel {
|
|
|
989
989
|
isDefaultValueColumn: false,
|
|
990
990
|
required: false,
|
|
991
991
|
type: TableColumnType.ShortText,
|
|
992
|
-
title: "Post Updates To
|
|
993
|
-
description: "Post Updates To
|
|
992
|
+
title: "Post Updates To Workspace Channel Name",
|
|
993
|
+
description: "Post Updates To Workspace Channel Name",
|
|
994
994
|
})
|
|
995
995
|
@Column({
|
|
996
996
|
type: ColumnType.ShortText,
|
|
997
997
|
length: ColumnLength.ShortText,
|
|
998
998
|
nullable: true,
|
|
999
999
|
})
|
|
1000
|
-
public
|
|
1000
|
+
public postUpdatesToWorkspaceChannelName?: number = undefined;
|
|
1001
1001
|
}
|
package/Server/API/BaseAPI.ts
CHANGED
|
@@ -131,6 +131,30 @@ export default class BaseAPI<
|
|
|
131
131
|
},
|
|
132
132
|
);
|
|
133
133
|
|
|
134
|
+
router.post(
|
|
135
|
+
`${new this.entityType().getCrudApiPath()?.toString()}/:id/update-item`,
|
|
136
|
+
UserMiddleware.getUserMiddleware,
|
|
137
|
+
async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
|
|
138
|
+
try {
|
|
139
|
+
await this.updateItem(req, res);
|
|
140
|
+
} catch (err) {
|
|
141
|
+
next(err);
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
router.get(
|
|
147
|
+
`${new this.entityType().getCrudApiPath()?.toString()}/:id/update-item`,
|
|
148
|
+
UserMiddleware.getUserMiddleware,
|
|
149
|
+
async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
|
|
150
|
+
try {
|
|
151
|
+
await this.updateItem(req, res);
|
|
152
|
+
} catch (err) {
|
|
153
|
+
next(err);
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
);
|
|
157
|
+
|
|
134
158
|
// Delete
|
|
135
159
|
router.delete(
|
|
136
160
|
`${new this.entityType().getCrudApiPath()?.toString()}/:id`,
|
|
@@ -144,6 +168,30 @@ export default class BaseAPI<
|
|
|
144
168
|
},
|
|
145
169
|
);
|
|
146
170
|
|
|
171
|
+
router.post(
|
|
172
|
+
`${new this.entityType().getCrudApiPath()?.toString()}/:id/delete-item`,
|
|
173
|
+
UserMiddleware.getUserMiddleware,
|
|
174
|
+
async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
|
|
175
|
+
try {
|
|
176
|
+
await this.deleteItem(req, res);
|
|
177
|
+
} catch (err) {
|
|
178
|
+
next(err);
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
router.get(
|
|
184
|
+
`${new this.entityType().getCrudApiPath()?.toString()}/:id/delete-item`,
|
|
185
|
+
UserMiddleware.getUserMiddleware,
|
|
186
|
+
async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
|
|
187
|
+
try {
|
|
188
|
+
await this.deleteItem(req, res);
|
|
189
|
+
} catch (err) {
|
|
190
|
+
next(err);
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
);
|
|
194
|
+
|
|
147
195
|
this.router = router;
|
|
148
196
|
this.service = service;
|
|
149
197
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
2
|
+
|
|
3
|
+
export class MigrationName1739374537088 implements MigrationInterface {
|
|
4
|
+
public name = "MigrationName1739374537088";
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(
|
|
8
|
+
`ALTER TABLE "Incident" RENAME COLUMN "postUpdatesToSlackChannelId" TO "postUpdatesToWorkspaceChannelName"`,
|
|
9
|
+
);
|
|
10
|
+
await queryRunner.query(
|
|
11
|
+
`ALTER TABLE "Alert" RENAME COLUMN "postUpdatesToSlackChannelId" TO "postUpdatesToWorkspaceChannelName"`,
|
|
12
|
+
);
|
|
13
|
+
await queryRunner.query(
|
|
14
|
+
`ALTER TABLE "ScheduledMaintenance" RENAME COLUMN "postUpdatesToSlackChannelId" TO "postUpdatesToWorkspaceChannelName"`,
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
19
|
+
await queryRunner.query(
|
|
20
|
+
`ALTER TABLE "ScheduledMaintenance" RENAME COLUMN "postUpdatesToWorkspaceChannelName" TO "postUpdatesToSlackChannelId"`,
|
|
21
|
+
);
|
|
22
|
+
await queryRunner.query(
|
|
23
|
+
`ALTER TABLE "Alert" RENAME COLUMN "postUpdatesToWorkspaceChannelName" TO "postUpdatesToSlackChannelId"`,
|
|
24
|
+
);
|
|
25
|
+
await queryRunner.query(
|
|
26
|
+
`ALTER TABLE "Incident" RENAME COLUMN "postUpdatesToWorkspaceChannelName" TO "postUpdatesToSlackChannelId"`,
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -103,6 +103,7 @@ import { MigrationName1739209832500 } from "./1739209832500-MigrationName";
|
|
|
103
103
|
import { MigrationName1739210586538 } from "./1739210586538-MigrationName";
|
|
104
104
|
import { MigrationName1739217257089 } from "./1739217257089-MigrationName";
|
|
105
105
|
import { MigrationName1739282331053 } from "./1739282331053-MigrationName";
|
|
106
|
+
import { MigrationName1739374537088 } from "./1739374537088-MigrationName";
|
|
106
107
|
|
|
107
108
|
export default [
|
|
108
109
|
InitialMigration,
|
|
@@ -210,4 +211,5 @@ export default [
|
|
|
210
211
|
MigrationName1739210586538,
|
|
211
212
|
MigrationName1739217257089,
|
|
212
213
|
MigrationName1739282331053,
|
|
214
|
+
MigrationName1739374537088,
|
|
213
215
|
];
|
|
@@ -54,6 +54,10 @@ import Label from "../../Models/DatabaseModels/Label";
|
|
|
54
54
|
import LabelService from "./LabelService";
|
|
55
55
|
import IncidentSeverity from "../../Models/DatabaseModels/IncidentSeverity";
|
|
56
56
|
import IncidentSeverityService from "./IncidentSeverityService";
|
|
57
|
+
import {
|
|
58
|
+
WorkspaceMessageBlock,
|
|
59
|
+
WorkspacePayloadMarkdown,
|
|
60
|
+
} from "../../Types/Workspace/WorkspaceMessagePayload";
|
|
57
61
|
|
|
58
62
|
export class Service extends DatabaseService<Model> {
|
|
59
63
|
public constructor() {
|
|
@@ -1314,5 +1318,102 @@ ${incidentSeverity.name}
|
|
|
1314
1318
|
logger.error(err);
|
|
1315
1319
|
});
|
|
1316
1320
|
}
|
|
1321
|
+
|
|
1322
|
+
public async getWorkspaceMessageBlocksForIncidentCreate(data: {
|
|
1323
|
+
incidentId: ObjectID;
|
|
1324
|
+
}): Promise<Array<WorkspaceMessageBlock>> {
|
|
1325
|
+
const incident: Model | null = await this.findOneById({
|
|
1326
|
+
id: data.incidentId,
|
|
1327
|
+
select: {
|
|
1328
|
+
projectId: true,
|
|
1329
|
+
incidentNumber: true,
|
|
1330
|
+
title: true,
|
|
1331
|
+
description: true,
|
|
1332
|
+
incidentSeverity: {
|
|
1333
|
+
name: true,
|
|
1334
|
+
},
|
|
1335
|
+
rootCause: true,
|
|
1336
|
+
remediationNotes: true,
|
|
1337
|
+
currentIncidentState: {
|
|
1338
|
+
name: true,
|
|
1339
|
+
},
|
|
1340
|
+
},
|
|
1341
|
+
props: {
|
|
1342
|
+
isRoot: true,
|
|
1343
|
+
},
|
|
1344
|
+
});
|
|
1345
|
+
|
|
1346
|
+
if (!incident) {
|
|
1347
|
+
throw new BadDataException("Incident not found");
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
const blocks: Array<WorkspaceMessageBlock> = [];
|
|
1351
|
+
|
|
1352
|
+
if (incident.incidentNumber) {
|
|
1353
|
+
const markdownBlock1: WorkspacePayloadMarkdown = {
|
|
1354
|
+
_type: "WorkspacePayloadMarkdown",
|
|
1355
|
+
text: `**Incident #${incident.incidentNumber} Created**`,
|
|
1356
|
+
};
|
|
1357
|
+
blocks.push(markdownBlock1);
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
if (incident.title) {
|
|
1361
|
+
const markdownBlock2: WorkspacePayloadMarkdown = {
|
|
1362
|
+
_type: "WorkspacePayloadMarkdown",
|
|
1363
|
+
text: `**Incident Title**:
|
|
1364
|
+
${incident.title}`,
|
|
1365
|
+
};
|
|
1366
|
+
blocks.push(markdownBlock2);
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
if (incident.description) {
|
|
1370
|
+
const markdownBlock3: WorkspacePayloadMarkdown = {
|
|
1371
|
+
_type: "WorkspacePayloadMarkdown",
|
|
1372
|
+
text: `**Description**:
|
|
1373
|
+
${incident.description}`,
|
|
1374
|
+
};
|
|
1375
|
+
blocks.push(markdownBlock3);
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
if (incident.incidentSeverity?.name) {
|
|
1379
|
+
const markdownBlock4: WorkspacePayloadMarkdown = {
|
|
1380
|
+
_type: "WorkspacePayloadMarkdown",
|
|
1381
|
+
text: `**Severity**:
|
|
1382
|
+
${incident.incidentSeverity.name}`,
|
|
1383
|
+
};
|
|
1384
|
+
blocks.push(markdownBlock4);
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
if (incident.rootCause) {
|
|
1388
|
+
const markdownBlock5: WorkspacePayloadMarkdown = {
|
|
1389
|
+
_type: "WorkspacePayloadMarkdown",
|
|
1390
|
+
text: `**Root Cause**:
|
|
1391
|
+
${incident.rootCause}`,
|
|
1392
|
+
};
|
|
1393
|
+
blocks.push(markdownBlock5);
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
if (incident.remediationNotes) {
|
|
1397
|
+
const markdownBlock6: WorkspacePayloadMarkdown = {
|
|
1398
|
+
_type: "WorkspacePayloadMarkdown",
|
|
1399
|
+
text: `**Remediation Notes**:
|
|
1400
|
+
${incident.remediationNotes}`,
|
|
1401
|
+
};
|
|
1402
|
+
blocks.push(markdownBlock6);
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
if (incident.currentIncidentState?.name) {
|
|
1406
|
+
const markdownBlock7: WorkspacePayloadMarkdown = {
|
|
1407
|
+
_type: "WorkspacePayloadMarkdown",
|
|
1408
|
+
text: `**Incident State**:
|
|
1409
|
+
${incident.currentIncidentState.name}`,
|
|
1410
|
+
};
|
|
1411
|
+
blocks.push(markdownBlock7);
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
// TODO: Add buttons to Post Private Note, Ack Incident, Resolve Incident. etc.
|
|
1415
|
+
|
|
1416
|
+
return blocks as Array<WorkspaceMessageBlock>;
|
|
1417
|
+
}
|
|
1317
1418
|
}
|
|
1318
1419
|
export default new Service();
|
|
@@ -52,6 +52,7 @@ import NotificationSettingEventType from "../../Types/NotificationSetting/Notifi
|
|
|
52
52
|
import Query from "../Types/Database/Query";
|
|
53
53
|
import DeleteBy from "../Types/Database/DeleteBy";
|
|
54
54
|
import StatusPageResourceService from "./StatusPageResourceService";
|
|
55
|
+
import Label from "../../Models/DatabaseModels/Label";
|
|
55
56
|
|
|
56
57
|
export class Service extends DatabaseService<Model> {
|
|
57
58
|
public constructor() {
|
|
@@ -643,6 +644,48 @@ export class Service extends DatabaseService<Model> {
|
|
|
643
644
|
}
|
|
644
645
|
}
|
|
645
646
|
|
|
647
|
+
public async getLabelsForMonitors(data: {
|
|
648
|
+
monitorIds: Array<ObjectID>;
|
|
649
|
+
}): Promise<Array<Label>> {
|
|
650
|
+
if (data.monitorIds.length === 0) {
|
|
651
|
+
return [];
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
const monitors: Array<Model> = await this.findBy({
|
|
655
|
+
query: {
|
|
656
|
+
_id: QueryHelper.any(data.monitorIds),
|
|
657
|
+
},
|
|
658
|
+
select: {
|
|
659
|
+
_id: true,
|
|
660
|
+
name: true,
|
|
661
|
+
labels: true,
|
|
662
|
+
},
|
|
663
|
+
props: {
|
|
664
|
+
isRoot: true,
|
|
665
|
+
},
|
|
666
|
+
skip: 0,
|
|
667
|
+
limit: LIMIT_PER_PROJECT,
|
|
668
|
+
});
|
|
669
|
+
|
|
670
|
+
const labels: Array<Label> = [];
|
|
671
|
+
|
|
672
|
+
for (const monitor of monitors) {
|
|
673
|
+
if (monitor.labels) {
|
|
674
|
+
for (const label of monitor.labels) {
|
|
675
|
+
const isLabelAlreadyAdded: boolean = labels.some((l: Label) => {
|
|
676
|
+
return l.id!.toString() === label.id!.toString();
|
|
677
|
+
});
|
|
678
|
+
|
|
679
|
+
if (!isLabelAlreadyAdded) {
|
|
680
|
+
labels.push(label);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
return labels;
|
|
687
|
+
}
|
|
688
|
+
|
|
646
689
|
public async notifyOwnersWhenNoProbeIsEnabled(data: {
|
|
647
690
|
monitorId: ObjectID;
|
|
648
691
|
isNoProbesEnabled: boolean;
|