@oneuptime/common 7.0.3148 → 7.0.3153
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 +1010 -0
- package/Models/DatabaseModels/AlertCustomField.ts +340 -0
- package/Models/DatabaseModels/AlertInternalNote.ts +371 -0
- package/Models/DatabaseModels/AlertNoteTemplate.ts +352 -0
- package/Models/DatabaseModels/AlertOwnerTeam.ts +416 -0
- package/Models/DatabaseModels/AlertOwnerUser.ts +415 -0
- package/Models/DatabaseModels/AlertSeverity.ts +426 -0
- package/Models/DatabaseModels/AlertState.ts +502 -0
- package/Models/DatabaseModels/AlertStateTimeline.ts +525 -0
- package/Models/DatabaseModels/Incident.ts +2 -11
- package/Models/DatabaseModels/Index.ts +34 -12
- package/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.ts +55 -0
- package/Models/DatabaseModels/TableView.ts +452 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1727894983857-MigrationName.ts +51 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1727906598804-MigrationName.ts +553 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +4 -0
- package/Server/Services/AlertCustomFieldService.ts +9 -0
- package/Server/Services/AlertInternalNoteService.ts +10 -0
- package/Server/Services/AlertNoteTemplateService.ts +9 -0
- package/Server/Services/AlertOwnerTeamService.ts +10 -0
- package/Server/Services/AlertOwnerUserService.ts +10 -0
- package/Server/Services/AlertService.ts +568 -0
- package/Server/Services/AlertSeverityService.ts +154 -0
- package/Server/Services/AlertStateService.ts +227 -0
- package/Server/Services/AlertStateTimelineService.ts +334 -0
- package/Server/Services/CallLogService.ts +4 -1
- package/Server/Services/DatabaseService.ts +17 -20
- package/Server/Services/EmailLogService.ts +4 -1
- package/Server/Services/IncidentService.ts +4 -1
- package/Server/Services/IncidentStateTimelineService.ts +4 -1
- package/Server/Services/Index.ts +23 -0
- package/Server/Services/MonitorStatusTimelineService.ts +4 -1
- package/Server/Services/OnCallDutyPolicyExecutionLogService.ts +4 -1
- package/Server/Services/OnCallDutyPolicyService.ts +15 -0
- package/Server/Services/ProjectService.ts +99 -1
- package/Server/Services/ScheduledMaintenanceService.ts +4 -1
- package/Server/Services/ScheduledMaintenanceStateTimelineService.ts +4 -1
- package/Server/Services/ShortLinkService.ts +4 -1
- package/Server/Services/SmsLogService.ts +4 -1
- package/Server/Services/TableViewService.ts +10 -0
- package/Server/Services/TelemetryUsageBillingService.ts +4 -1
- package/Server/Services/UserNotificationSettingService.ts +58 -0
- package/Server/Services/UserOnCallLogService.ts +4 -1
- package/Server/Services/WorkflowLogService.ts +4 -1
- package/Server/Types/Workflow/Components/API/Post.ts +25 -0
- package/Server/Utils/Monitor/MonitorAlert.ts +273 -0
- package/Server/Utils/Monitor/MonitorIncident.ts +298 -0
- package/Server/Utils/Monitor/MonitorResource.ts +67 -387
- package/Server/Utils/Monitor/MonitorStatusTimeline.ts +120 -0
- package/Server/Utils/Realtime.ts +1 -35
- package/Types/Email/EmailTemplateType.ts +7 -0
- package/Types/Icon/IconProp.ts +1 -0
- package/Types/Monitor/CriteriaAlert.ts +11 -0
- package/Types/Monitor/MonitorCriteria.ts +2 -0
- package/Types/Monitor/MonitorCriteriaInstance.ts +134 -1
- package/Types/Monitor/MonitorStep.ts +1 -0
- package/Types/Monitor/MonitorSteps.ts +1 -0
- package/Types/NotificationSetting/NotificationSettingEventType.ts +7 -0
- package/Types/Permission.ts +369 -1
- package/Types/Telemetry/TelemetryQuery.ts +10 -0
- package/Types/UserNotification/UserNotificationEventType.ts +1 -0
- package/UI/Components/Card/Card.tsx +40 -31
- package/UI/Components/Card/CardButtons/MoreButton.ts +15 -0
- package/UI/Components/HeaderAlert/HeaderAlert.tsx +75 -16
- package/UI/Components/HeaderAlert/HeaderAlertGroup.tsx +50 -0
- package/UI/Components/HeaderAlert/HeaderModelAlert.tsx +5 -1
- package/UI/Components/Icon/Icon.tsx +8 -0
- package/UI/Components/ModelDetail/CardModelDetail.tsx +4 -2
- package/UI/Components/ModelTable/BaseModelTable.tsx +70 -2
- package/UI/Components/ModelTable/TableView.tsx +317 -0
- package/UI/Components/MoreMenu/Divider.tsx +7 -0
- package/UI/Components/MoreMenu/MoreMenu.tsx +54 -0
- package/UI/Components/MoreMenu/MoreMenuItem.tsx +37 -0
- package/UI/Components/MoreMenu/MoreMenuSection.tsx +22 -0
- package/UI/Components/Toggle/Toggle.tsx +14 -0
- package/build/dist/Models/DatabaseModels/Alert.js +1028 -0
- package/build/dist/Models/DatabaseModels/Alert.js.map +1 -0
- package/build/dist/Models/DatabaseModels/AlertCustomField.js +360 -0
- package/build/dist/Models/DatabaseModels/AlertCustomField.js.map +1 -0
- package/build/dist/Models/DatabaseModels/AlertInternalNote.js +391 -0
- package/build/dist/Models/DatabaseModels/AlertInternalNote.js.map +1 -0
- package/build/dist/Models/DatabaseModels/AlertNoteTemplate.js +372 -0
- package/build/dist/Models/DatabaseModels/AlertNoteTemplate.js.map +1 -0
- package/build/dist/Models/DatabaseModels/AlertOwnerTeam.js +434 -0
- package/build/dist/Models/DatabaseModels/AlertOwnerTeam.js.map +1 -0
- package/build/dist/Models/DatabaseModels/AlertOwnerUser.js +433 -0
- package/build/dist/Models/DatabaseModels/AlertOwnerUser.js.map +1 -0
- package/build/dist/Models/DatabaseModels/AlertSeverity.js +450 -0
- package/build/dist/Models/DatabaseModels/AlertSeverity.js.map +1 -0
- package/build/dist/Models/DatabaseModels/AlertState.js +530 -0
- package/build/dist/Models/DatabaseModels/AlertState.js.map +1 -0
- package/build/dist/Models/DatabaseModels/AlertStateTimeline.js +548 -0
- package/build/dist/Models/DatabaseModels/AlertStateTimeline.js.map +1 -0
- package/build/dist/Models/DatabaseModels/Incident.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Index.js +29 -9
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.js +55 -0
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.js.map +1 -1
- package/build/dist/Models/DatabaseModels/TableView.js +475 -0
- package/build/dist/Models/DatabaseModels/TableView.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1727894983857-MigrationName.js +24 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1727894983857-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1727906598804-MigrationName.js +198 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1727906598804-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +4 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Services/AlertCustomFieldService.js +9 -0
- package/build/dist/Server/Services/AlertCustomFieldService.js.map +1 -0
- package/build/dist/Server/Services/AlertInternalNoteService.js +9 -0
- package/build/dist/Server/Services/AlertInternalNoteService.js.map +1 -0
- package/build/dist/Server/Services/AlertNoteTemplateService.js +9 -0
- package/build/dist/Server/Services/AlertNoteTemplateService.js.map +1 -0
- package/build/dist/Server/Services/AlertOwnerTeamService.js +9 -0
- package/build/dist/Server/Services/AlertOwnerTeamService.js.map +1 -0
- package/build/dist/Server/Services/AlertOwnerUserService.js +9 -0
- package/build/dist/Server/Services/AlertOwnerUserService.js.map +1 -0
- package/build/dist/Server/Services/AlertService.js +418 -0
- package/build/dist/Server/Services/AlertService.js.map +1 -0
- package/build/dist/Server/Services/AlertSeverityService.js +108 -0
- package/build/dist/Server/Services/AlertSeverityService.js.map +1 -0
- package/build/dist/Server/Services/AlertStateService.js +158 -0
- package/build/dist/Server/Services/AlertStateService.js.map +1 -0
- package/build/dist/Server/Services/AlertStateTimelineService.js +267 -0
- package/build/dist/Server/Services/AlertStateTimelineService.js.map +1 -0
- package/build/dist/Server/Services/CallLogService.js +4 -1
- package/build/dist/Server/Services/CallLogService.js.map +1 -1
- package/build/dist/Server/Services/DatabaseService.js +9 -9
- package/build/dist/Server/Services/DatabaseService.js.map +1 -1
- package/build/dist/Server/Services/EmailLogService.js +4 -1
- package/build/dist/Server/Services/EmailLogService.js.map +1 -1
- package/build/dist/Server/Services/IncidentService.js +4 -1
- package/build/dist/Server/Services/IncidentService.js.map +1 -1
- package/build/dist/Server/Services/IncidentStateTimelineService.js +4 -1
- package/build/dist/Server/Services/IncidentStateTimelineService.js.map +1 -1
- package/build/dist/Server/Services/Index.js +21 -0
- package/build/dist/Server/Services/Index.js.map +1 -1
- package/build/dist/Server/Services/MonitorStatusTimelineService.js +4 -1
- package/build/dist/Server/Services/MonitorStatusTimelineService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogService.js +4 -1
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyService.js +8 -0
- package/build/dist/Server/Services/OnCallDutyPolicyService.js.map +1 -1
- package/build/dist/Server/Services/ProjectService.js +80 -1
- package/build/dist/Server/Services/ProjectService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceService.js +4 -1
- package/build/dist/Server/Services/ScheduledMaintenanceService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceStateTimelineService.js +4 -1
- package/build/dist/Server/Services/ScheduledMaintenanceStateTimelineService.js.map +1 -1
- package/build/dist/Server/Services/ShortLinkService.js +4 -1
- package/build/dist/Server/Services/ShortLinkService.js.map +1 -1
- package/build/dist/Server/Services/SmsLogService.js +4 -1
- package/build/dist/Server/Services/SmsLogService.js.map +1 -1
- package/build/dist/Server/Services/TableViewService.js +9 -0
- package/build/dist/Server/Services/TableViewService.js.map +1 -0
- package/build/dist/Server/Services/TelemetryUsageBillingService.js +4 -1
- package/build/dist/Server/Services/TelemetryUsageBillingService.js.map +1 -1
- package/build/dist/Server/Services/UserNotificationSettingService.js +49 -0
- package/build/dist/Server/Services/UserNotificationSettingService.js.map +1 -1
- package/build/dist/Server/Services/UserOnCallLogService.js +4 -1
- package/build/dist/Server/Services/UserOnCallLogService.js.map +1 -1
- package/build/dist/Server/Services/WorkflowLogService.js +4 -1
- package/build/dist/Server/Services/WorkflowLogService.js.map +1 -1
- package/build/dist/Server/Types/Workflow/Components/API/Post.js +14 -0
- package/build/dist/Server/Types/Workflow/Components/API/Post.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorAlert.js +177 -0
- package/build/dist/Server/Utils/Monitor/MonitorAlert.js.map +1 -0
- package/build/dist/Server/Utils/Monitor/MonitorIncident.js +187 -0
- package/build/dist/Server/Utils/Monitor/MonitorIncident.js.map +1 -0
- package/build/dist/Server/Utils/Monitor/MonitorResource.js +46 -254
- package/build/dist/Server/Utils/Monitor/MonitorResource.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorStatusTimeline.js +79 -0
- package/build/dist/Server/Utils/Monitor/MonitorStatusTimeline.js.map +1 -0
- package/build/dist/Server/Utils/Realtime.js +3 -28
- package/build/dist/Server/Utils/Realtime.js.map +1 -1
- package/build/dist/Types/Email/EmailTemplateType.js +4 -0
- package/build/dist/Types/Email/EmailTemplateType.js.map +1 -1
- package/build/dist/Types/Icon/IconProp.js +1 -0
- package/build/dist/Types/Icon/IconProp.js.map +1 -1
- package/build/dist/Types/Monitor/CriteriaAlert.js +2 -0
- package/build/dist/Types/Monitor/CriteriaAlert.js.map +1 -0
- package/build/dist/Types/Monitor/MonitorCriteria.js +1 -0
- package/build/dist/Types/Monitor/MonitorCriteria.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorCriteriaInstance.js +120 -1
- package/build/dist/Types/Monitor/MonitorCriteriaInstance.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorStep.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorSteps.js.map +1 -1
- package/build/dist/Types/NotificationSetting/NotificationSettingEventType.js +5 -0
- package/build/dist/Types/NotificationSetting/NotificationSettingEventType.js.map +1 -1
- package/build/dist/Types/Permission.js +323 -1
- package/build/dist/Types/Permission.js.map +1 -1
- package/build/dist/Types/Telemetry/TelemetryQuery.js +2 -0
- package/build/dist/Types/Telemetry/TelemetryQuery.js.map +1 -0
- package/build/dist/Types/UserNotification/UserNotificationEventType.js +1 -0
- package/build/dist/Types/UserNotification/UserNotificationEventType.js.map +1 -1
- package/build/dist/UI/Components/Card/Card.js +3 -2
- package/build/dist/UI/Components/Card/Card.js.map +1 -1
- package/build/dist/UI/Components/Card/CardButtons/MoreButton.js +12 -0
- package/build/dist/UI/Components/Card/CardButtons/MoreButton.js.map +1 -0
- package/build/dist/UI/Components/HeaderAlert/HeaderAlert.js +53 -9
- package/build/dist/UI/Components/HeaderAlert/HeaderAlert.js.map +1 -1
- package/build/dist/UI/Components/HeaderAlert/HeaderAlertGroup.js +25 -0
- package/build/dist/UI/Components/HeaderAlert/HeaderAlertGroup.js.map +1 -0
- package/build/dist/UI/Components/HeaderAlert/HeaderModelAlert.js +1 -1
- package/build/dist/UI/Components/HeaderAlert/HeaderModelAlert.js.map +1 -1
- package/build/dist/UI/Components/Icon/Icon.js +3 -0
- package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
- package/build/dist/UI/Components/ModelDetail/CardModelDetail.js.map +1 -1
- package/build/dist/UI/Components/ModelTable/BaseModelTable.js +46 -0
- package/build/dist/UI/Components/ModelTable/BaseModelTable.js.map +1 -1
- package/build/dist/UI/Components/ModelTable/TableView.js +183 -0
- package/build/dist/UI/Components/ModelTable/TableView.js.map +1 -0
- package/build/dist/UI/Components/MoreMenu/Divider.js +6 -0
- package/build/dist/UI/Components/MoreMenu/Divider.js.map +1 -0
- package/build/dist/UI/Components/MoreMenu/MoreMenu.js +19 -0
- package/build/dist/UI/Components/MoreMenu/MoreMenu.js.map +1 -0
- package/build/dist/UI/Components/MoreMenu/MoreMenuItem.js +13 -0
- package/build/dist/UI/Components/MoreMenu/MoreMenuItem.js.map +1 -0
- package/build/dist/UI/Components/MoreMenu/MoreMenuSection.js +10 -0
- package/build/dist/UI/Components/MoreMenu/MoreMenuSection.js.map +1 -0
- package/build/dist/UI/Components/Toggle/Toggle.js +7 -1
- package/build/dist/UI/Components/Toggle/Toggle.js.map +1 -1
- package/package.json +2 -2
package/Server/Services/Index.ts
CHANGED
|
@@ -137,6 +137,18 @@ import ScheduledMaintenanceTemplateService from "./ScheduledMaintenanceTemplateS
|
|
|
137
137
|
import ScheduledMaintenanceTemplateOwnerTeamService from "./ScheduledMaintenanceTemplateOwnerTeamService";
|
|
138
138
|
import ScheduledMaintenanceTemplateOwnerUserService from "./ScheduledMaintenanceTemplateOwnerUserService";
|
|
139
139
|
|
|
140
|
+
// Alert Services
|
|
141
|
+
import AlertStateService from "./AlertStateService";
|
|
142
|
+
import AlertService from "./AlertService";
|
|
143
|
+
import AlertCustomFieldService from "./AlertCustomFieldService";
|
|
144
|
+
import AlertStateTimelineService from "./AlertStateTimelineService";
|
|
145
|
+
import AlertInternalNoteService from "./AlertInternalNoteService";
|
|
146
|
+
import AlertOwnerTeamService from "./AlertOwnerTeamService";
|
|
147
|
+
import AlertOwnerUserService from "./AlertOwnerUserService";
|
|
148
|
+
import AlertSeverityService from "./AlertSeverityService";
|
|
149
|
+
import AlertNoteTemplateService from "./AlertNoteTemplateService";
|
|
150
|
+
import TableViewService from "./TableViewService";
|
|
151
|
+
|
|
140
152
|
const services: Array<BaseService> = [
|
|
141
153
|
AcmeCertificateService,
|
|
142
154
|
PromoCodeService,
|
|
@@ -285,6 +297,17 @@ const services: Array<BaseService> = [
|
|
|
285
297
|
ScheduledMaintenanceTemplateService,
|
|
286
298
|
ScheduledMaintenanceTemplateOwnerTeamService,
|
|
287
299
|
ScheduledMaintenanceTemplateOwnerUserService,
|
|
300
|
+
|
|
301
|
+
AlertStateService,
|
|
302
|
+
AlertService,
|
|
303
|
+
AlertCustomFieldService,
|
|
304
|
+
AlertStateTimelineService,
|
|
305
|
+
AlertInternalNoteService,
|
|
306
|
+
AlertOwnerTeamService,
|
|
307
|
+
AlertOwnerUserService,
|
|
308
|
+
AlertSeverityService,
|
|
309
|
+
AlertNoteTemplateService,
|
|
310
|
+
TableViewService,
|
|
288
311
|
];
|
|
289
312
|
|
|
290
313
|
export const AnalyticsServices: Array<
|
|
@@ -14,11 +14,14 @@ import ObjectID from "../../Types/ObjectID";
|
|
|
14
14
|
import PositiveNumber from "../../Types/PositiveNumber";
|
|
15
15
|
import MonitorStatusTimeline from "Common/Models/DatabaseModels/MonitorStatusTimeline";
|
|
16
16
|
import User from "Common/Models/DatabaseModels/User";
|
|
17
|
+
import { IsBillingEnabled } from "../EnvironmentConfig";
|
|
17
18
|
|
|
18
19
|
export class Service extends DatabaseService<MonitorStatusTimeline> {
|
|
19
20
|
public constructor() {
|
|
20
21
|
super(MonitorStatusTimeline);
|
|
21
|
-
|
|
22
|
+
if (IsBillingEnabled) {
|
|
23
|
+
this.hardDeleteItemsOlderThanInDays("createdAt", 120);
|
|
24
|
+
}
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
protected override async onBeforeCreate(
|
|
@@ -6,11 +6,14 @@ import OnCallDutyPolicyStatus from "../../Types/OnCallDutyPolicy/OnCallDutyPolic
|
|
|
6
6
|
import UserNotificationEventType from "../../Types/UserNotification/UserNotificationEventType";
|
|
7
7
|
import OnCallDutyPolicyEscalationRule from "Common/Models/DatabaseModels/OnCallDutyPolicyEscalationRule";
|
|
8
8
|
import Model from "Common/Models/DatabaseModels/OnCallDutyPolicyExecutionLog";
|
|
9
|
+
import { IsBillingEnabled } from "../EnvironmentConfig";
|
|
9
10
|
|
|
10
11
|
export class Service extends DatabaseService<Model> {
|
|
11
12
|
public constructor() {
|
|
12
13
|
super(Model);
|
|
13
|
-
|
|
14
|
+
if (IsBillingEnabled) {
|
|
15
|
+
this.hardDeleteItemsOlderThanInDays("createdAt", 30);
|
|
16
|
+
}
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
protected override async onBeforeCreate(
|
|
@@ -16,6 +16,7 @@ export class Service extends DatabaseService<OnCallDutyPolicy> {
|
|
|
16
16
|
policyId: ObjectID,
|
|
17
17
|
options: {
|
|
18
18
|
triggeredByIncidentId?: ObjectID | undefined;
|
|
19
|
+
triggeredByAlertId?: ObjectID | undefined;
|
|
19
20
|
userNotificationEventType: UserNotificationEventType;
|
|
20
21
|
},
|
|
21
22
|
): Promise<void> {
|
|
@@ -31,6 +32,16 @@ export class Service extends DatabaseService<OnCallDutyPolicy> {
|
|
|
31
32
|
);
|
|
32
33
|
}
|
|
33
34
|
|
|
35
|
+
if (
|
|
36
|
+
UserNotificationEventType.AlertCreated ===
|
|
37
|
+
options.userNotificationEventType &&
|
|
38
|
+
!options.triggeredByAlertId
|
|
39
|
+
) {
|
|
40
|
+
throw new BadDataException(
|
|
41
|
+
"triggeredByAlertId is required when userNotificationEventType is IncidentCreated",
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
34
45
|
const policy: OnCallDutyPolicy | null = await this.findOneById({
|
|
35
46
|
id: policyId,
|
|
36
47
|
select: {
|
|
@@ -62,6 +73,10 @@ export class Service extends DatabaseService<OnCallDutyPolicy> {
|
|
|
62
73
|
log.triggeredByIncidentId = options.triggeredByIncidentId;
|
|
63
74
|
}
|
|
64
75
|
|
|
76
|
+
if (options.triggeredByAlertId) {
|
|
77
|
+
log.triggeredByAlertId = options.triggeredByAlertId;
|
|
78
|
+
}
|
|
79
|
+
|
|
65
80
|
await OnCallDutyPolicyExecutionLogService.create({
|
|
66
81
|
data: log,
|
|
67
82
|
props: {
|
|
@@ -28,7 +28,14 @@ import SubscriptionPlan, {
|
|
|
28
28
|
PlanType,
|
|
29
29
|
} from "../../Types/Billing/SubscriptionPlan";
|
|
30
30
|
import SubscriptionStatus from "../../Types/Billing/SubscriptionStatus";
|
|
31
|
-
import {
|
|
31
|
+
import {
|
|
32
|
+
Black,
|
|
33
|
+
Green,
|
|
34
|
+
Moroon500,
|
|
35
|
+
Red,
|
|
36
|
+
Yellow,
|
|
37
|
+
Yellow500,
|
|
38
|
+
} from "../../Types/BrandColors";
|
|
32
39
|
import Color from "../../Types/Color";
|
|
33
40
|
import LIMIT_MAX from "../../Types/Database/LimitMax";
|
|
34
41
|
import OneUptimeDate from "../../Types/Date";
|
|
@@ -50,6 +57,10 @@ import TeamPermission from "Common/Models/DatabaseModels/TeamPermission";
|
|
|
50
57
|
import User from "Common/Models/DatabaseModels/User";
|
|
51
58
|
import Select from "../Types/Database/Select";
|
|
52
59
|
import Query from "../Types/Database/Query";
|
|
60
|
+
import AlertSeverity from "../../Models/DatabaseModels/AlertSeverity";
|
|
61
|
+
import AlertSeverityService from "./AlertSeverityService";
|
|
62
|
+
import AlertState from "../../Models/DatabaseModels/AlertState";
|
|
63
|
+
import AlertStateService from "./AlertStateService";
|
|
53
64
|
|
|
54
65
|
export interface CurrentPlan {
|
|
55
66
|
plan: PlanType | null;
|
|
@@ -543,10 +554,12 @@ export class ProjectService extends DatabaseService<Model> {
|
|
|
543
554
|
}
|
|
544
555
|
|
|
545
556
|
createdItem = await this.addDefaultIncidentSeverity(createdItem);
|
|
557
|
+
createdItem = await this.addDefaultAlertSeverity(createdItem);
|
|
546
558
|
createdItem = await this.addDefaultProjectTeams(createdItem);
|
|
547
559
|
createdItem = await this.addDefaultMonitorStatus(createdItem);
|
|
548
560
|
createdItem = await this.addDefaultIncidentState(createdItem);
|
|
549
561
|
createdItem = await this.addDefaultScheduledMaintenanceState(createdItem);
|
|
562
|
+
createdItem = await this.addDefaultAlertState(createdItem);
|
|
550
563
|
|
|
551
564
|
return createdItem;
|
|
552
565
|
}
|
|
@@ -603,6 +616,91 @@ export class ProjectService extends DatabaseService<Model> {
|
|
|
603
616
|
return createdItem;
|
|
604
617
|
}
|
|
605
618
|
|
|
619
|
+
public async addDefaultAlertState(createdItem: Model): Promise<Model> {
|
|
620
|
+
let createdAlertState: AlertState = new AlertState();
|
|
621
|
+
createdAlertState.name = "Identified";
|
|
622
|
+
createdAlertState.description =
|
|
623
|
+
"When an alert is created, it belongs to this state";
|
|
624
|
+
createdAlertState.color = Red;
|
|
625
|
+
createdAlertState.isCreatedState = true;
|
|
626
|
+
createdAlertState.projectId = createdItem.id!;
|
|
627
|
+
createdAlertState.order = 1;
|
|
628
|
+
|
|
629
|
+
createdAlertState = await AlertStateService.create({
|
|
630
|
+
data: createdAlertState,
|
|
631
|
+
props: {
|
|
632
|
+
isRoot: true,
|
|
633
|
+
},
|
|
634
|
+
});
|
|
635
|
+
|
|
636
|
+
let acknowledgedAlertState: AlertState = new AlertState();
|
|
637
|
+
acknowledgedAlertState.name = "Acknowledged";
|
|
638
|
+
acknowledgedAlertState.description =
|
|
639
|
+
"When an alert is acknowledged, it belongs to this state.";
|
|
640
|
+
acknowledgedAlertState.color = Yellow;
|
|
641
|
+
acknowledgedAlertState.isAcknowledgedState = true;
|
|
642
|
+
acknowledgedAlertState.projectId = createdItem.id!;
|
|
643
|
+
acknowledgedAlertState.order = 2;
|
|
644
|
+
|
|
645
|
+
acknowledgedAlertState = await AlertStateService.create({
|
|
646
|
+
data: acknowledgedAlertState,
|
|
647
|
+
props: {
|
|
648
|
+
isRoot: true,
|
|
649
|
+
},
|
|
650
|
+
});
|
|
651
|
+
|
|
652
|
+
let resolvedAlertState: AlertState = new AlertState();
|
|
653
|
+
resolvedAlertState.name = "Resolved";
|
|
654
|
+
resolvedAlertState.description =
|
|
655
|
+
"When an incident is resolved, it belongs to this state.";
|
|
656
|
+
resolvedAlertState.color = Green;
|
|
657
|
+
resolvedAlertState.isResolvedState = true;
|
|
658
|
+
resolvedAlertState.projectId = createdItem.id!;
|
|
659
|
+
resolvedAlertState.order = 3;
|
|
660
|
+
|
|
661
|
+
resolvedAlertState = await AlertStateService.create({
|
|
662
|
+
data: resolvedAlertState,
|
|
663
|
+
props: {
|
|
664
|
+
isRoot: true,
|
|
665
|
+
},
|
|
666
|
+
});
|
|
667
|
+
|
|
668
|
+
return createdItem;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
public async addDefaultAlertSeverity(createdItem: Model): Promise<Model> {
|
|
672
|
+
let highSeverity: AlertSeverity = new AlertSeverity();
|
|
673
|
+
highSeverity.name = "High";
|
|
674
|
+
highSeverity.description =
|
|
675
|
+
"Issues causing very high impact to customers. Immediate attention is required.";
|
|
676
|
+
highSeverity.color = Moroon500;
|
|
677
|
+
highSeverity.projectId = createdItem.id!;
|
|
678
|
+
highSeverity.order = 1;
|
|
679
|
+
|
|
680
|
+
highSeverity = await AlertSeverityService.create({
|
|
681
|
+
data: highSeverity,
|
|
682
|
+
props: {
|
|
683
|
+
isRoot: true,
|
|
684
|
+
},
|
|
685
|
+
});
|
|
686
|
+
|
|
687
|
+
let lowSeverity: AlertSeverity = new AlertSeverity();
|
|
688
|
+
lowSeverity.name = "Low";
|
|
689
|
+
lowSeverity.description = "Issues causing low impact to customers.";
|
|
690
|
+
lowSeverity.color = Yellow500;
|
|
691
|
+
lowSeverity.projectId = createdItem.id!;
|
|
692
|
+
lowSeverity.order = 2;
|
|
693
|
+
|
|
694
|
+
lowSeverity = await AlertSeverityService.create({
|
|
695
|
+
data: lowSeverity,
|
|
696
|
+
props: {
|
|
697
|
+
isRoot: true,
|
|
698
|
+
},
|
|
699
|
+
});
|
|
700
|
+
|
|
701
|
+
return createdItem;
|
|
702
|
+
}
|
|
703
|
+
|
|
606
704
|
private async addDefaultIncidentSeverity(createdItem: Model): Promise<Model> {
|
|
607
705
|
let criticalIncident: IncidentSeverity = new IncidentSeverity();
|
|
608
706
|
criticalIncident.name = "Critical Incident";
|
|
@@ -45,11 +45,14 @@ import StatusPageResource from "Common/Models/DatabaseModels/StatusPageResource"
|
|
|
45
45
|
import StatusPageSubscriber from "Common/Models/DatabaseModels/StatusPageSubscriber";
|
|
46
46
|
import Hostname from "../../Types/API/Hostname";
|
|
47
47
|
import Protocol from "../../Types/API/Protocol";
|
|
48
|
+
import { IsBillingEnabled } from "../EnvironmentConfig";
|
|
48
49
|
|
|
49
50
|
export class Service extends DatabaseService<Model> {
|
|
50
51
|
public constructor() {
|
|
51
52
|
super(Model);
|
|
52
|
-
|
|
53
|
+
if (IsBillingEnabled) {
|
|
54
|
+
this.hardDeleteItemsOlderThanInDays("createdAt", 120);
|
|
55
|
+
}
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
public async notififySubscribersOnEventScheduled(
|
|
@@ -22,11 +22,14 @@ import ScheduledMaintenance from "Common/Models/DatabaseModels/ScheduledMaintena
|
|
|
22
22
|
import ScheduledMaintenancePublicNote from "Common/Models/DatabaseModels/ScheduledMaintenancePublicNote";
|
|
23
23
|
import ScheduledMaintenanceState from "Common/Models/DatabaseModels/ScheduledMaintenanceState";
|
|
24
24
|
import ScheduledMaintenanceStateTimeline from "Common/Models/DatabaseModels/ScheduledMaintenanceStateTimeline";
|
|
25
|
+
import { IsBillingEnabled } from "../EnvironmentConfig";
|
|
25
26
|
|
|
26
27
|
export class Service extends DatabaseService<ScheduledMaintenanceStateTimeline> {
|
|
27
28
|
public constructor() {
|
|
28
29
|
super(ScheduledMaintenanceStateTimeline);
|
|
29
|
-
|
|
30
|
+
if (IsBillingEnabled) {
|
|
31
|
+
this.hardDeleteItemsOlderThanInDays("createdAt", 120);
|
|
32
|
+
}
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
protected override async onBeforeCreate(
|
|
@@ -9,11 +9,14 @@ import Route from "../../Types/API/Route";
|
|
|
9
9
|
import URL from "../../Types/API/URL";
|
|
10
10
|
import Text from "../../Types/Text";
|
|
11
11
|
import Model from "Common/Models/DatabaseModels/ShortLink";
|
|
12
|
+
import { IsBillingEnabled } from "../EnvironmentConfig";
|
|
12
13
|
|
|
13
14
|
export class Service extends DatabaseService<Model> {
|
|
14
15
|
public constructor() {
|
|
15
16
|
super(Model);
|
|
16
|
-
|
|
17
|
+
if (IsBillingEnabled) {
|
|
18
|
+
this.hardDeleteItemsOlderThanInDays("createdAt", 3); //expire links in 3 days.
|
|
19
|
+
}
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
protected override async onBeforeCreate(
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import { IsBillingEnabled } from "../EnvironmentConfig";
|
|
1
2
|
import DatabaseService from "./DatabaseService";
|
|
2
3
|
import Model from "Common/Models/DatabaseModels/SmsLog";
|
|
3
4
|
|
|
4
5
|
export class Service extends DatabaseService<Model> {
|
|
5
6
|
public constructor() {
|
|
6
7
|
super(Model);
|
|
7
|
-
|
|
8
|
+
if (IsBillingEnabled) {
|
|
9
|
+
this.hardDeleteItemsOlderThanInDays("createdAt", 3);
|
|
10
|
+
}
|
|
8
11
|
}
|
|
9
12
|
}
|
|
10
13
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import DatabaseService from "./DatabaseService";
|
|
2
|
+
import TableView from "Common/Models/DatabaseModels/TableView";
|
|
3
|
+
|
|
4
|
+
export class Service extends DatabaseService<TableView> {
|
|
5
|
+
public constructor() {
|
|
6
|
+
super(TableView);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default new Service();
|
|
@@ -10,11 +10,14 @@ import BadDataException from "../../Types/Exception/BadDataException";
|
|
|
10
10
|
import ProductType from "../../Types/MeteredPlan/ProductType";
|
|
11
11
|
import ObjectID from "../../Types/ObjectID";
|
|
12
12
|
import Model from "Common/Models/DatabaseModels/TelemetryUsageBilling";
|
|
13
|
+
import { IsBillingEnabled } from "../EnvironmentConfig";
|
|
13
14
|
|
|
14
15
|
export class Service extends DatabaseService<Model> {
|
|
15
16
|
public constructor() {
|
|
16
17
|
super(Model);
|
|
17
|
-
|
|
18
|
+
if (IsBillingEnabled) {
|
|
19
|
+
this.hardDeleteItemsOlderThanInDays("createdAt", 120);
|
|
20
|
+
}
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
public async getUnreportedUsageBilling(data: {
|
|
@@ -282,6 +282,34 @@ export class Service extends DatabaseService<UserNotificationSetting> {
|
|
|
282
282
|
});
|
|
283
283
|
}
|
|
284
284
|
|
|
285
|
+
const alertCreatedNotificationEvent: PositiveNumber = await this.countBy({
|
|
286
|
+
query: {
|
|
287
|
+
userId,
|
|
288
|
+
projectId,
|
|
289
|
+
eventType:
|
|
290
|
+
NotificationSettingEventType.SEND_ALERT_CREATED_OWNER_NOTIFICATION,
|
|
291
|
+
},
|
|
292
|
+
props: {
|
|
293
|
+
isRoot: true,
|
|
294
|
+
},
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
if (alertCreatedNotificationEvent.toNumber() === 0) {
|
|
298
|
+
const item: UserNotificationSetting = new UserNotificationSetting();
|
|
299
|
+
item.userId = userId;
|
|
300
|
+
item.projectId = projectId;
|
|
301
|
+
item.eventType =
|
|
302
|
+
NotificationSettingEventType.SEND_ALERT_CREATED_OWNER_NOTIFICATION;
|
|
303
|
+
item.alertByEmail = true;
|
|
304
|
+
|
|
305
|
+
await this.create({
|
|
306
|
+
data: item,
|
|
307
|
+
props: {
|
|
308
|
+
isRoot: true,
|
|
309
|
+
},
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
|
|
285
313
|
// check monitor state changed notification
|
|
286
314
|
const monitorStateChangedNotificationEvent: PositiveNumber =
|
|
287
315
|
await this.countBy({
|
|
@@ -404,6 +432,36 @@ export class Service extends DatabaseService<UserNotificationSetting> {
|
|
|
404
432
|
},
|
|
405
433
|
});
|
|
406
434
|
}
|
|
435
|
+
|
|
436
|
+
// check alert state changed notification
|
|
437
|
+
const alertStateChangedNotificationEvent: PositiveNumber =
|
|
438
|
+
await this.countBy({
|
|
439
|
+
query: {
|
|
440
|
+
userId,
|
|
441
|
+
projectId,
|
|
442
|
+
eventType:
|
|
443
|
+
NotificationSettingEventType.SEND_ALERT_STATE_CHANGED_OWNER_NOTIFICATION,
|
|
444
|
+
},
|
|
445
|
+
props: {
|
|
446
|
+
isRoot: true,
|
|
447
|
+
},
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
if (alertStateChangedNotificationEvent.toNumber() === 0) {
|
|
451
|
+
const item: UserNotificationSetting = new UserNotificationSetting();
|
|
452
|
+
item.userId = userId;
|
|
453
|
+
item.projectId = projectId;
|
|
454
|
+
item.eventType =
|
|
455
|
+
NotificationSettingEventType.SEND_ALERT_STATE_CHANGED_OWNER_NOTIFICATION;
|
|
456
|
+
item.alertByEmail = true;
|
|
457
|
+
|
|
458
|
+
await this.create({
|
|
459
|
+
data: item,
|
|
460
|
+
props: {
|
|
461
|
+
isRoot: true,
|
|
462
|
+
},
|
|
463
|
+
});
|
|
464
|
+
}
|
|
407
465
|
}
|
|
408
466
|
|
|
409
467
|
protected override async onBeforeCreate(
|
|
@@ -15,11 +15,14 @@ import UserNotificationExecutionStatus from "../../Types/UserNotification/UserNo
|
|
|
15
15
|
import Incident from "Common/Models/DatabaseModels/Incident";
|
|
16
16
|
import UserNotificationRule from "Common/Models/DatabaseModels/UserNotificationRule";
|
|
17
17
|
import Model from "Common/Models/DatabaseModels/UserOnCallLog";
|
|
18
|
+
import { IsBillingEnabled } from "../EnvironmentConfig";
|
|
18
19
|
|
|
19
20
|
export class Service extends DatabaseService<Model> {
|
|
20
21
|
public constructor() {
|
|
21
22
|
super(Model);
|
|
22
|
-
|
|
23
|
+
if (IsBillingEnabled) {
|
|
24
|
+
this.hardDeleteItemsOlderThanInDays("createdAt", 30);
|
|
25
|
+
}
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
protected override async onBeforeCreate(
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import { IsBillingEnabled } from "../EnvironmentConfig";
|
|
1
2
|
import DatabaseService from "./DatabaseService";
|
|
2
3
|
import Model from "Common/Models/DatabaseModels/WorkflowLog";
|
|
3
4
|
|
|
4
5
|
export class Service extends DatabaseService<Model> {
|
|
5
6
|
public constructor() {
|
|
6
7
|
super(Model);
|
|
7
|
-
|
|
8
|
+
if (IsBillingEnabled) {
|
|
9
|
+
this.hardDeleteItemsOlderThanInDays("createdAt", 3);
|
|
10
|
+
}
|
|
8
11
|
}
|
|
9
12
|
}
|
|
10
13
|
export default new Service();
|
|
@@ -11,6 +11,7 @@ import ComponentMetadata, { Port } from "Common/Types/Workflow/Component";
|
|
|
11
11
|
import ComponentID from "Common/Types/Workflow/ComponentID";
|
|
12
12
|
import APIComponents from "Common/Types/Workflow/Components/API";
|
|
13
13
|
import API from "Common/Utils/API";
|
|
14
|
+
import logger from "../../../../Utils/Logger";
|
|
14
15
|
|
|
15
16
|
export default class ApiPost extends ComponentCode {
|
|
16
17
|
public constructor() {
|
|
@@ -38,6 +39,25 @@ export default class ApiPost extends ComponentCode {
|
|
|
38
39
|
|
|
39
40
|
let apiResult: HTTPResponse<JSONObject> | HTTPErrorResponse | null = null;
|
|
40
41
|
|
|
42
|
+
logger.debug("API Post Component is running.");
|
|
43
|
+
|
|
44
|
+
const url: URL = args["url"] as URL;
|
|
45
|
+
if (!url) {
|
|
46
|
+
throw options.onError(new BadDataException("URL is required"));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
logger.debug(`URL: ${url}`);
|
|
50
|
+
|
|
51
|
+
const requestBody: JSONObject = args["request-body"] as JSONObject;
|
|
52
|
+
|
|
53
|
+
logger.debug(`Request Body: ${JSON.stringify(requestBody)}`);
|
|
54
|
+
|
|
55
|
+
const requestHeaders: Dictionary<string> = args[
|
|
56
|
+
"request-headers"
|
|
57
|
+
] as Dictionary<string>;
|
|
58
|
+
|
|
59
|
+
logger.debug(`Request Headers: ${JSON.stringify(requestHeaders)}`);
|
|
60
|
+
|
|
41
61
|
try {
|
|
42
62
|
apiResult = await API.post(
|
|
43
63
|
args["url"] as URL,
|
|
@@ -45,6 +65,8 @@ export default class ApiPost extends ComponentCode {
|
|
|
45
65
|
args["request-headers"] as Dictionary<string>,
|
|
46
66
|
);
|
|
47
67
|
|
|
68
|
+
logger.debug("API Post Component is done.");
|
|
69
|
+
|
|
48
70
|
return Promise.resolve({
|
|
49
71
|
returnValues: ApiComponentUtils.getReturnValues(apiResult),
|
|
50
72
|
executePort: result.successPort,
|
|
@@ -64,6 +86,9 @@ export default class ApiPost extends ComponentCode {
|
|
|
64
86
|
});
|
|
65
87
|
}
|
|
66
88
|
|
|
89
|
+
logger.debug("API Post Component is done with error.");
|
|
90
|
+
logger.debug(err);
|
|
91
|
+
|
|
67
92
|
throw options.onError(new APIException("Something wrong happened."));
|
|
68
93
|
}
|
|
69
94
|
}
|