@oneuptime/common 9.4.11 → 9.4.13
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/Incident.ts +77 -0
- package/Models/DatabaseModels/IncidentEpisode.ts +1223 -0
- package/Models/DatabaseModels/IncidentEpisodeFeed.ts +533 -0
- package/Models/DatabaseModels/IncidentEpisodeInternalNote.ts +456 -0
- package/Models/DatabaseModels/IncidentEpisodeMember.ts +587 -0
- package/Models/DatabaseModels/IncidentEpisodeOwnerTeam.ts +421 -0
- package/Models/DatabaseModels/IncidentEpisodeOwnerUser.ts +419 -0
- package/Models/DatabaseModels/IncidentEpisodeStateTimeline.ts +524 -0
- package/Models/DatabaseModels/IncidentGroupingRule.ts +1430 -0
- package/Models/DatabaseModels/Index.ts +18 -0
- package/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.ts +70 -0
- package/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.ts +59 -0
- package/Models/DatabaseModels/Project.ts +29 -0
- package/Models/DatabaseModels/UserOnCallLog.ts +48 -0
- package/Models/DatabaseModels/UserOnCallLogTimeline.ts +49 -0
- package/Models/DatabaseModels/WorkspaceNotificationLog.ts +57 -0
- package/Server/API/BillingAPI.ts +78 -1
- package/Server/API/IncidentEpisodeAPI.ts +150 -0
- package/Server/API/SlackAPI.ts +23 -0
- package/Server/API/UserOnCallLogTimelineAPI.ts +24 -4
- package/Server/BillingConfig.ts +3 -0
- package/Server/EnvironmentConfig.ts +1 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1769599843642-MigrationName.ts +29 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1769626069479-MigrationName.ts +729 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1769629928240-MigrationName.ts +261 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1769676117342-RenameEvaluateOverTimeInCriteriaFilter.ts +28 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +8 -0
- package/Server/Services/AIBillingService.ts +10 -0
- package/Server/Services/BillingService.ts +349 -1
- package/Server/Services/CallService.ts +1 -0
- package/Server/Services/IncidentEpisodeFeedService.ts +94 -0
- package/Server/Services/IncidentEpisodeInternalNoteService.ts +71 -0
- package/Server/Services/IncidentEpisodeMemberService.ts +321 -0
- package/Server/Services/IncidentEpisodeOwnerTeamService.ts +10 -0
- package/Server/Services/IncidentEpisodeOwnerUserService.ts +10 -0
- package/Server/Services/IncidentEpisodeService.ts +1045 -0
- package/Server/Services/IncidentEpisodeStateTimelineService.ts +566 -0
- package/Server/Services/IncidentGroupingEngineService.ts +1047 -0
- package/Server/Services/IncidentGroupingRuleService.ts +14 -0
- package/Server/Services/IncidentService.ts +11 -0
- package/Server/Services/Index.ts +18 -0
- package/Server/Services/MailService.ts +1 -0
- package/Server/Services/MonitorService.ts +9 -0
- package/Server/Services/NotificationService.ts +10 -0
- package/Server/Services/OnCallDutyPolicyEscalationRuleService.ts +18 -0
- package/Server/Services/OnCallDutyPolicyExecutionLogService.ts +64 -2
- package/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.ts +26 -1
- package/Server/Services/OnCallDutyPolicyService.ts +15 -0
- package/Server/Services/ProjectService.ts +33 -2
- package/Server/Services/SmsService.ts +1 -0
- package/Server/Services/UserNotificationRuleService.ts +48 -2
- package/Server/Services/UserNotificationSettingService.ts +23 -0
- package/Server/Services/UserOnCallLogService.ts +41 -4
- package/Server/Services/UserService.ts +45 -1
- package/Server/Services/WhatsAppService.ts +1 -0
- package/Server/Services/WorkspaceNotificationLogService.ts +16 -0
- package/Server/Services/WorkspaceNotificationRuleService.ts +116 -0
- package/Server/Types/Database/Permissions/TenantPermission.ts +20 -0
- package/Server/Utils/AI/IncidentEpisodeAIContextBuilder.ts +490 -0
- package/Server/Utils/Monitor/Criteria/APIRequestCriteria.ts +1 -1
- package/Server/Utils/Monitor/Criteria/CompareCriteria.ts +1 -1
- package/Server/Utils/Monitor/Criteria/IncomingRequestCriteria.ts +1 -1
- package/Server/Utils/Monitor/Criteria/SSLMonitorCriteria.ts +1 -1
- package/Server/Utils/Monitor/Criteria/ServerMonitorCriteria.ts +2 -2
- package/Server/Utils/Monitor/Criteria/SnmpMonitorCriteria.ts +182 -0
- package/Server/Utils/Monitor/MonitorCriteriaEvaluator.ts +13 -0
- package/Server/Utils/Monitor/MonitorCriteriaExpectationBuilder.ts +1 -1
- package/Server/Utils/Monitor/MonitorTemplateUtil.ts +37 -0
- package/Server/Utils/PushNotificationUtil.ts +31 -0
- package/Server/Utils/WhatsAppTemplateUtil.ts +14 -0
- package/Server/Utils/Workspace/MicrosoftTeams/Actions/ActionTypes.ts +18 -0
- package/Server/Utils/Workspace/MicrosoftTeams/Actions/IncidentEpisode.ts +702 -0
- package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +20 -0
- package/Server/Utils/Workspace/Slack/Actions/ActionTypes.ts +11 -0
- package/Server/Utils/Workspace/Slack/Actions/IncidentEpisode.ts +918 -0
- package/Server/Utils/Workspace/Slack/Messages/IncidentEpisode.ts +120 -0
- package/Server/Utils/Workspace/WorkspaceMessages/IncidentEpisode.ts +74 -0
- package/Types/Email/EmailTemplateType.ts +7 -0
- package/Types/Monitor/CriteriaFilter.ts +24 -4
- package/Types/Monitor/MonitorCriteriaInstance.ts +67 -0
- package/Types/Monitor/MonitorStep.ts +37 -0
- package/Types/Monitor/MonitorStepSnmpMonitor.ts +102 -0
- package/Types/Monitor/MonitorType.ts +15 -2
- package/Types/Monitor/SnmpMonitor/SnmpAuthProtocol.ts +8 -0
- package/Types/Monitor/SnmpMonitor/SnmpDataType.ts +21 -0
- package/Types/Monitor/SnmpMonitor/SnmpMonitorResponse.ts +16 -0
- package/Types/Monitor/SnmpMonitor/SnmpOid.ts +60 -0
- package/Types/Monitor/SnmpMonitor/SnmpPrivProtocol.ts +7 -0
- package/Types/Monitor/SnmpMonitor/SnmpSecurityLevel.ts +7 -0
- package/Types/Monitor/SnmpMonitor/SnmpV3Auth.ts +12 -0
- package/Types/Monitor/SnmpMonitor/SnmpVersion.ts +7 -0
- package/Types/NotificationSetting/NotificationSettingEventType.ts +7 -0
- package/Types/Permission.ts +311 -0
- package/Types/Probe/ProbeMonitorResponse.ts +2 -0
- package/Types/UserNotification/UserNotificationEventType.ts +1 -0
- package/Types/WhatsApp/WhatsAppTemplates.ts +24 -0
- package/Types/Workspace/NotificationRules/EventType.ts +1 -0
- package/Types/Workspace/NotificationRules/NotificationRuleCondition.ts +38 -1
- package/Utils/Monitor/MonitorMetricType.ts +2 -1
- package/build/dist/Models/DatabaseModels/Incident.js +78 -0
- package/build/dist/Models/DatabaseModels/Incident.js.map +1 -1
- package/build/dist/Models/DatabaseModels/IncidentEpisode.js +1250 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisode.js.map +1 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeFeed.js +555 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeFeed.js.map +1 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeInternalNote.js +467 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeInternalNote.js.map +1 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeMember.js +607 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeMember.js.map +1 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeOwnerTeam.js +437 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeOwnerTeam.js.map +1 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeOwnerUser.js +436 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeOwnerUser.js.map +1 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeStateTimeline.js +546 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeStateTimeline.js.map +1 -0
- package/build/dist/Models/DatabaseModels/IncidentGroupingRule.js +1437 -0
- package/build/dist/Models/DatabaseModels/IncidentGroupingRule.js.map +1 -0
- package/build/dist/Models/DatabaseModels/Index.js +16 -0
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.js +69 -0
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.js.map +1 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.js +58 -0
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Project.js +30 -0
- package/build/dist/Models/DatabaseModels/Project.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserOnCallLog.js +47 -0
- package/build/dist/Models/DatabaseModels/UserOnCallLog.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserOnCallLogTimeline.js +48 -0
- package/build/dist/Models/DatabaseModels/UserOnCallLogTimeline.js.map +1 -1
- package/build/dist/Models/DatabaseModels/WorkspaceNotificationLog.js +58 -0
- package/build/dist/Models/DatabaseModels/WorkspaceNotificationLog.js.map +1 -1
- package/build/dist/Server/API/BillingAPI.js +44 -1
- package/build/dist/Server/API/BillingAPI.js.map +1 -1
- package/build/dist/Server/API/IncidentEpisodeAPI.js +97 -0
- package/build/dist/Server/API/IncidentEpisodeAPI.js.map +1 -0
- package/build/dist/Server/API/SlackAPI.js +18 -0
- package/build/dist/Server/API/SlackAPI.js.map +1 -1
- package/build/dist/Server/API/UserOnCallLogTimelineAPI.js +30 -10
- package/build/dist/Server/API/UserOnCallLogTimelineAPI.js.map +1 -1
- package/build/dist/Server/BillingConfig.js +2 -0
- package/build/dist/Server/BillingConfig.js.map +1 -1
- package/build/dist/Server/EnvironmentConfig.js +1 -0
- package/build/dist/Server/EnvironmentConfig.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769599843642-MigrationName.js +16 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769599843642-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769626069479-MigrationName.js +256 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769626069479-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769629928240-MigrationName.js +96 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769629928240-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769676117342-RenameEvaluateOverTimeInCriteriaFilter.js +25 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769676117342-RenameEvaluateOverTimeInCriteriaFilter.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +8 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Services/AIBillingService.js +10 -1
- package/build/dist/Server/Services/AIBillingService.js.map +1 -1
- package/build/dist/Server/Services/BillingService.js +224 -5
- package/build/dist/Server/Services/BillingService.js.map +1 -1
- package/build/dist/Server/Services/CallService.js.map +1 -1
- package/build/dist/Server/Services/IncidentEpisodeFeedService.js +83 -0
- package/build/dist/Server/Services/IncidentEpisodeFeedService.js.map +1 -0
- package/build/dist/Server/Services/IncidentEpisodeInternalNoteService.js +70 -0
- package/build/dist/Server/Services/IncidentEpisodeInternalNoteService.js.map +1 -0
- package/build/dist/Server/Services/IncidentEpisodeMemberService.js +298 -0
- package/build/dist/Server/Services/IncidentEpisodeMemberService.js.map +1 -0
- package/build/dist/Server/Services/IncidentEpisodeOwnerTeamService.js +9 -0
- package/build/dist/Server/Services/IncidentEpisodeOwnerTeamService.js.map +1 -0
- package/build/dist/Server/Services/IncidentEpisodeOwnerUserService.js +9 -0
- package/build/dist/Server/Services/IncidentEpisodeOwnerUserService.js.map +1 -0
- package/build/dist/Server/Services/IncidentEpisodeService.js +933 -0
- package/build/dist/Server/Services/IncidentEpisodeService.js.map +1 -0
- package/build/dist/Server/Services/IncidentEpisodeStateTimelineService.js +498 -0
- package/build/dist/Server/Services/IncidentEpisodeStateTimelineService.js.map +1 -0
- package/build/dist/Server/Services/IncidentGroupingEngineService.js +799 -0
- package/build/dist/Server/Services/IncidentGroupingEngineService.js.map +1 -0
- package/build/dist/Server/Services/IncidentGroupingRuleService.js +13 -0
- package/build/dist/Server/Services/IncidentGroupingRuleService.js.map +1 -0
- package/build/dist/Server/Services/IncidentService.js +10 -0
- package/build/dist/Server/Services/IncidentService.js.map +1 -1
- package/build/dist/Server/Services/Index.js +16 -0
- package/build/dist/Server/Services/Index.js.map +1 -1
- package/build/dist/Server/Services/MailService.js.map +1 -1
- package/build/dist/Server/Services/MonitorService.js +9 -1
- package/build/dist/Server/Services/MonitorService.js.map +1 -1
- package/build/dist/Server/Services/NotificationService.js +10 -1
- package/build/dist/Server/Services/NotificationService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js +10 -0
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogService.js +48 -2
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.js +20 -1
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.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 +16 -3
- package/build/dist/Server/Services/ProjectService.js.map +1 -1
- package/build/dist/Server/Services/SmsService.js.map +1 -1
- package/build/dist/Server/Services/UserNotificationRuleService.js +39 -2
- package/build/dist/Server/Services/UserNotificationRuleService.js.map +1 -1
- package/build/dist/Server/Services/UserNotificationSettingService.js +9 -0
- package/build/dist/Server/Services/UserNotificationSettingService.js.map +1 -1
- package/build/dist/Server/Services/UserOnCallLogService.js +35 -3
- package/build/dist/Server/Services/UserOnCallLogService.js.map +1 -1
- package/build/dist/Server/Services/UserService.js +40 -0
- package/build/dist/Server/Services/UserService.js.map +1 -1
- package/build/dist/Server/Services/WhatsAppService.js.map +1 -1
- package/build/dist/Server/Services/WorkspaceNotificationLogService.js +12 -0
- package/build/dist/Server/Services/WorkspaceNotificationLogService.js.map +1 -1
- package/build/dist/Server/Services/WorkspaceNotificationRuleService.js +95 -1
- package/build/dist/Server/Services/WorkspaceNotificationRuleService.js.map +1 -1
- package/build/dist/Server/Types/Database/Permissions/TenantPermission.js +17 -0
- package/build/dist/Server/Types/Database/Permissions/TenantPermission.js.map +1 -1
- package/build/dist/Server/Utils/AI/IncidentEpisodeAIContextBuilder.js +402 -0
- package/build/dist/Server/Utils/AI/IncidentEpisodeAIContextBuilder.js.map +1 -0
- package/build/dist/Server/Utils/Monitor/Criteria/APIRequestCriteria.js +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/CompareCriteria.js +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/IncomingRequestCriteria.js +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/SSLMonitorCriteria.js +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/ServerMonitorCriteria.js +2 -2
- package/build/dist/Server/Utils/Monitor/Criteria/SnmpMonitorCriteria.js +135 -0
- package/build/dist/Server/Utils/Monitor/Criteria/SnmpMonitorCriteria.js.map +1 -0
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js +10 -0
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaExpectationBuilder.js +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorTemplateUtil.js +26 -0
- package/build/dist/Server/Utils/Monitor/MonitorTemplateUtil.js.map +1 -1
- package/build/dist/Server/Utils/PushNotificationUtil.js +20 -0
- package/build/dist/Server/Utils/PushNotificationUtil.js.map +1 -1
- package/build/dist/Server/Utils/WhatsAppTemplateUtil.js +8 -0
- package/build/dist/Server/Utils/WhatsAppTemplateUtil.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/ActionTypes.js +17 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/ActionTypes.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/IncidentEpisode.js +547 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/IncidentEpisode.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js +15 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/Slack/Actions/ActionTypes.js +10 -0
- package/build/dist/Server/Utils/Workspace/Slack/Actions/ActionTypes.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/Slack/Actions/IncidentEpisode.js +651 -0
- package/build/dist/Server/Utils/Workspace/Slack/Actions/IncidentEpisode.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/Slack/Messages/IncidentEpisode.js +100 -0
- package/build/dist/Server/Utils/Workspace/Slack/Messages/IncidentEpisode.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/WorkspaceMessages/IncidentEpisode.js +70 -0
- package/build/dist/Server/Utils/Workspace/WorkspaceMessages/IncidentEpisode.js.map +1 -0
- package/build/dist/Types/Email/EmailTemplateType.js +6 -0
- package/build/dist/Types/Email/EmailTemplateType.js.map +1 -1
- package/build/dist/Types/Monitor/CriteriaFilter.js +16 -3
- package/build/dist/Types/Monitor/CriteriaFilter.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorCriteriaInstance.js +62 -0
- package/build/dist/Types/Monitor/MonitorCriteriaInstance.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorStep.js +26 -0
- package/build/dist/Types/Monitor/MonitorStep.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorStepSnmpMonitor.js +77 -0
- package/build/dist/Types/Monitor/MonitorStepSnmpMonitor.js.map +1 -0
- package/build/dist/Types/Monitor/MonitorType.js +13 -2
- package/build/dist/Types/Monitor/MonitorType.js.map +1 -1
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpAuthProtocol.js +9 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpAuthProtocol.js.map +1 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpDataType.js +22 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpDataType.js.map +1 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpMonitorResponse.js +2 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpMonitorResponse.js.map +1 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpOid.js +55 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpOid.js.map +1 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpPrivProtocol.js +8 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpPrivProtocol.js.map +1 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpSecurityLevel.js +8 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpSecurityLevel.js.map +1 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpV3Auth.js +2 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpV3Auth.js.map +1 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpVersion.js +8 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpVersion.js.map +1 -0
- 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 +264 -0
- package/build/dist/Types/Permission.js.map +1 -1
- package/build/dist/Types/UserNotification/UserNotificationEventType.js +1 -0
- package/build/dist/Types/UserNotification/UserNotificationEventType.js.map +1 -1
- package/build/dist/Types/WhatsApp/WhatsAppTemplates.js +15 -0
- package/build/dist/Types/WhatsApp/WhatsAppTemplates.js.map +1 -1
- package/build/dist/Types/Workspace/NotificationRules/EventType.js +1 -0
- package/build/dist/Types/Workspace/NotificationRules/EventType.js.map +1 -1
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleCondition.js +33 -1
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleCondition.js.map +1 -1
- package/build/dist/Utils/Monitor/MonitorMetricType.js +2 -1
- package/build/dist/Utils/Monitor/MonitorMetricType.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,702 @@
|
|
|
1
|
+
import { ExpressRequest, ExpressResponse } from "../../../Express";
|
|
2
|
+
import Response from "../../../Response";
|
|
3
|
+
import MicrosoftTeamsAuthAction, {
|
|
4
|
+
MicrosoftTeamsAction,
|
|
5
|
+
MicrosoftTeamsRequest,
|
|
6
|
+
} from "./Auth";
|
|
7
|
+
import { MicrosoftTeamsIncidentEpisodeActionType } from "./ActionTypes";
|
|
8
|
+
import logger from "../../../Logger";
|
|
9
|
+
import ObjectID from "../../../../../Types/ObjectID";
|
|
10
|
+
import IncidentEpisodeService from "../../../../Services/IncidentEpisodeService";
|
|
11
|
+
import IncidentEpisode from "../../../../../Models/DatabaseModels/IncidentEpisode";
|
|
12
|
+
import CaptureSpan from "../../../Telemetry/CaptureSpan";
|
|
13
|
+
import { TurnContext } from "botbuilder";
|
|
14
|
+
import { JSONObject, JSONValue } from "../../../../../Types/JSON";
|
|
15
|
+
import IncidentEpisodeInternalNoteService from "../../../../Services/IncidentEpisodeInternalNoteService";
|
|
16
|
+
import OnCallDutyPolicyService from "../../../../Services/OnCallDutyPolicyService";
|
|
17
|
+
import IncidentStateService from "../../../../Services/IncidentStateService";
|
|
18
|
+
import UserNotificationEventType from "../../../../../Types/UserNotification/UserNotificationEventType";
|
|
19
|
+
import OnCallDutyPolicy from "../../../../../Models/DatabaseModels/OnCallDutyPolicy";
|
|
20
|
+
import IncidentState from "../../../../../Models/DatabaseModels/IncidentState";
|
|
21
|
+
|
|
22
|
+
export default class MicrosoftTeamsIncidentEpisodeActions {
|
|
23
|
+
@CaptureSpan()
|
|
24
|
+
public static isIncidentEpisodeAction(data: { actionType: string }): boolean {
|
|
25
|
+
return (
|
|
26
|
+
data.actionType.includes("IncidentEpisode") ||
|
|
27
|
+
data.actionType ===
|
|
28
|
+
MicrosoftTeamsIncidentEpisodeActionType.AckIncidentEpisode ||
|
|
29
|
+
data.actionType ===
|
|
30
|
+
MicrosoftTeamsIncidentEpisodeActionType.ResolveIncidentEpisode ||
|
|
31
|
+
data.actionType ===
|
|
32
|
+
MicrosoftTeamsIncidentEpisodeActionType.ViewIncidentEpisode ||
|
|
33
|
+
data.actionType ===
|
|
34
|
+
MicrosoftTeamsIncidentEpisodeActionType.IncidentEpisodeCreated ||
|
|
35
|
+
data.actionType ===
|
|
36
|
+
MicrosoftTeamsIncidentEpisodeActionType.IncidentEpisodeStateChanged ||
|
|
37
|
+
data.actionType ===
|
|
38
|
+
MicrosoftTeamsIncidentEpisodeActionType.ViewAddIncidentEpisodeNote ||
|
|
39
|
+
data.actionType ===
|
|
40
|
+
MicrosoftTeamsIncidentEpisodeActionType.SubmitIncidentEpisodeNote ||
|
|
41
|
+
data.actionType ===
|
|
42
|
+
MicrosoftTeamsIncidentEpisodeActionType.ViewExecuteIncidentEpisodeOnCallPolicy ||
|
|
43
|
+
data.actionType ===
|
|
44
|
+
MicrosoftTeamsIncidentEpisodeActionType.SubmitExecuteIncidentEpisodeOnCallPolicy ||
|
|
45
|
+
data.actionType ===
|
|
46
|
+
MicrosoftTeamsIncidentEpisodeActionType.ViewChangeIncidentEpisodeState ||
|
|
47
|
+
data.actionType ===
|
|
48
|
+
MicrosoftTeamsIncidentEpisodeActionType.SubmitChangeIncidentEpisodeState
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@CaptureSpan()
|
|
53
|
+
public static async handleIncidentEpisodeAction(data: {
|
|
54
|
+
teamsRequest: MicrosoftTeamsRequest;
|
|
55
|
+
action: MicrosoftTeamsAction;
|
|
56
|
+
req: ExpressRequest;
|
|
57
|
+
res: ExpressResponse;
|
|
58
|
+
}): Promise<void> {
|
|
59
|
+
const { teamsRequest, action } = data;
|
|
60
|
+
|
|
61
|
+
logger.debug("Handling Microsoft Teams incident episode action:");
|
|
62
|
+
logger.debug(action);
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
switch (action.actionType) {
|
|
66
|
+
case MicrosoftTeamsIncidentEpisodeActionType.AckIncidentEpisode:
|
|
67
|
+
await this.acknowledgeIncidentEpisode({
|
|
68
|
+
teamsRequest,
|
|
69
|
+
action,
|
|
70
|
+
});
|
|
71
|
+
break;
|
|
72
|
+
|
|
73
|
+
case MicrosoftTeamsIncidentEpisodeActionType.ResolveIncidentEpisode:
|
|
74
|
+
await this.resolveIncidentEpisode({
|
|
75
|
+
teamsRequest,
|
|
76
|
+
action,
|
|
77
|
+
});
|
|
78
|
+
break;
|
|
79
|
+
|
|
80
|
+
case MicrosoftTeamsIncidentEpisodeActionType.ViewIncidentEpisode:
|
|
81
|
+
// This is handled by opening the URL directly
|
|
82
|
+
break;
|
|
83
|
+
|
|
84
|
+
default:
|
|
85
|
+
logger.debug(
|
|
86
|
+
"Unhandled incident episode action: " + action.actionType,
|
|
87
|
+
);
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
} catch (error) {
|
|
91
|
+
logger.error("Error handling Microsoft Teams incident episode action:");
|
|
92
|
+
logger.error(error);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
Response.sendTextResponse(data.req, data.res, "");
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@CaptureSpan()
|
|
99
|
+
private static async acknowledgeIncidentEpisode(data: {
|
|
100
|
+
teamsRequest: MicrosoftTeamsRequest;
|
|
101
|
+
action: MicrosoftTeamsAction;
|
|
102
|
+
}): Promise<void> {
|
|
103
|
+
const episodeId: string = data.action.actionValue || "";
|
|
104
|
+
|
|
105
|
+
if (!episodeId) {
|
|
106
|
+
logger.error("No episode ID provided for acknowledge action");
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
logger.debug("Acknowledging incident episode: " + episodeId);
|
|
111
|
+
|
|
112
|
+
try {
|
|
113
|
+
const episode: IncidentEpisode | null =
|
|
114
|
+
await IncidentEpisodeService.findOneBy({
|
|
115
|
+
query: {
|
|
116
|
+
_id: episodeId,
|
|
117
|
+
projectId: data.teamsRequest.projectId,
|
|
118
|
+
},
|
|
119
|
+
select: {
|
|
120
|
+
_id: true,
|
|
121
|
+
projectId: true,
|
|
122
|
+
currentIncidentState: {
|
|
123
|
+
_id: true,
|
|
124
|
+
name: true,
|
|
125
|
+
isAcknowledgedState: true,
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
props: {
|
|
129
|
+
isRoot: true,
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
if (!episode) {
|
|
134
|
+
logger.error("Incident episode not found: " + episodeId);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (episode.currentIncidentState?.isAcknowledgedState) {
|
|
139
|
+
logger.debug("Incident episode is already acknowledged");
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const oneUptimeUserId: ObjectID =
|
|
144
|
+
await MicrosoftTeamsAuthAction.getOneUptimeUserIdFromTeamsUserId({
|
|
145
|
+
teamsUserId: data.teamsRequest.userId || "",
|
|
146
|
+
projectId: data.teamsRequest.projectId,
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
await IncidentEpisodeService.acknowledgeEpisode(
|
|
150
|
+
new ObjectID(episodeId),
|
|
151
|
+
oneUptimeUserId,
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
logger.debug("Incident episode acknowledged successfully");
|
|
155
|
+
} catch (error) {
|
|
156
|
+
logger.error("Error acknowledging incident episode:");
|
|
157
|
+
logger.error(error);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
@CaptureSpan()
|
|
162
|
+
private static async resolveIncidentEpisode(data: {
|
|
163
|
+
teamsRequest: MicrosoftTeamsRequest;
|
|
164
|
+
action: MicrosoftTeamsAction;
|
|
165
|
+
}): Promise<void> {
|
|
166
|
+
const episodeId: string = data.action.actionValue || "";
|
|
167
|
+
|
|
168
|
+
if (!episodeId) {
|
|
169
|
+
logger.error("No episode ID provided for resolve action");
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
logger.debug("Resolving incident episode: " + episodeId);
|
|
174
|
+
|
|
175
|
+
try {
|
|
176
|
+
const episode: IncidentEpisode | null =
|
|
177
|
+
await IncidentEpisodeService.findOneBy({
|
|
178
|
+
query: {
|
|
179
|
+
_id: episodeId,
|
|
180
|
+
projectId: data.teamsRequest.projectId,
|
|
181
|
+
},
|
|
182
|
+
select: {
|
|
183
|
+
_id: true,
|
|
184
|
+
projectId: true,
|
|
185
|
+
currentIncidentState: {
|
|
186
|
+
_id: true,
|
|
187
|
+
name: true,
|
|
188
|
+
isResolvedState: true,
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
props: {
|
|
192
|
+
isRoot: true,
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
if (!episode) {
|
|
197
|
+
logger.error("Incident episode not found: " + episodeId);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (episode.currentIncidentState?.isResolvedState) {
|
|
202
|
+
logger.debug("Incident episode is already resolved");
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const oneUptimeUserId: ObjectID =
|
|
207
|
+
await MicrosoftTeamsAuthAction.getOneUptimeUserIdFromTeamsUserId({
|
|
208
|
+
teamsUserId: data.teamsRequest.userId || "",
|
|
209
|
+
projectId: data.teamsRequest.projectId,
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
await IncidentEpisodeService.resolveEpisode(
|
|
213
|
+
new ObjectID(episodeId),
|
|
214
|
+
oneUptimeUserId,
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
logger.debug("Incident episode resolved successfully");
|
|
218
|
+
} catch (error) {
|
|
219
|
+
logger.error("Error resolving incident episode:");
|
|
220
|
+
logger.error(error);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
@CaptureSpan()
|
|
225
|
+
public static async handleBotIncidentEpisodeAction(data: {
|
|
226
|
+
actionType: string;
|
|
227
|
+
actionValue: string;
|
|
228
|
+
value: JSONObject;
|
|
229
|
+
projectId: ObjectID;
|
|
230
|
+
oneUptimeUserId: ObjectID;
|
|
231
|
+
turnContext: TurnContext;
|
|
232
|
+
}): Promise<void> {
|
|
233
|
+
const {
|
|
234
|
+
actionType,
|
|
235
|
+
actionValue,
|
|
236
|
+
value,
|
|
237
|
+
projectId,
|
|
238
|
+
oneUptimeUserId,
|
|
239
|
+
turnContext,
|
|
240
|
+
} = data;
|
|
241
|
+
|
|
242
|
+
if (
|
|
243
|
+
actionType === MicrosoftTeamsIncidentEpisodeActionType.AckIncidentEpisode
|
|
244
|
+
) {
|
|
245
|
+
if (!actionValue) {
|
|
246
|
+
await turnContext.sendActivity(
|
|
247
|
+
"Unable to acknowledge: missing incident episode id.",
|
|
248
|
+
);
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
await IncidentEpisodeService.acknowledgeEpisode(
|
|
253
|
+
new ObjectID(actionValue),
|
|
254
|
+
oneUptimeUserId,
|
|
255
|
+
);
|
|
256
|
+
await turnContext.sendActivity("Incident episode acknowledged.");
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (
|
|
261
|
+
actionType ===
|
|
262
|
+
MicrosoftTeamsIncidentEpisodeActionType.ResolveIncidentEpisode
|
|
263
|
+
) {
|
|
264
|
+
if (!actionValue) {
|
|
265
|
+
await turnContext.sendActivity(
|
|
266
|
+
"Unable to resolve: missing incident episode id.",
|
|
267
|
+
);
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
await IncidentEpisodeService.resolveEpisode(
|
|
272
|
+
new ObjectID(actionValue),
|
|
273
|
+
oneUptimeUserId,
|
|
274
|
+
);
|
|
275
|
+
await turnContext.sendActivity("Incident episode resolved.");
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
if (
|
|
280
|
+
actionType === MicrosoftTeamsIncidentEpisodeActionType.ViewIncidentEpisode
|
|
281
|
+
) {
|
|
282
|
+
if (!actionValue) {
|
|
283
|
+
await turnContext.sendActivity(
|
|
284
|
+
"Unable to view incident episode: missing episode id.",
|
|
285
|
+
);
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
const episode: IncidentEpisode | null =
|
|
290
|
+
await IncidentEpisodeService.findOneBy({
|
|
291
|
+
query: {
|
|
292
|
+
_id: actionValue,
|
|
293
|
+
projectId: projectId,
|
|
294
|
+
},
|
|
295
|
+
select: {
|
|
296
|
+
_id: true,
|
|
297
|
+
title: true,
|
|
298
|
+
description: true,
|
|
299
|
+
currentIncidentState: {
|
|
300
|
+
name: true,
|
|
301
|
+
},
|
|
302
|
+
incidentSeverity: {
|
|
303
|
+
name: true,
|
|
304
|
+
},
|
|
305
|
+
createdAt: true,
|
|
306
|
+
incidentCount: true,
|
|
307
|
+
},
|
|
308
|
+
props: {
|
|
309
|
+
isRoot: true,
|
|
310
|
+
},
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
if (!episode) {
|
|
314
|
+
await turnContext.sendActivity("Incident episode not found.");
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
const message: string = `**Incident Episode Details**\n\n**Title:** ${episode.title}\n**Description:** ${episode.description || "No description"}\n**State:** ${episode.currentIncidentState?.name || "Unknown"}\n**Severity:** ${episode.incidentSeverity?.name || "Unknown"}\n**Incident Count:** ${episode.incidentCount || 0}\n**Created At:** ${episode.createdAt ? new Date(episode.createdAt).toLocaleString() : "Unknown"}`;
|
|
319
|
+
|
|
320
|
+
await turnContext.sendActivity(message);
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
if (
|
|
325
|
+
actionType ===
|
|
326
|
+
MicrosoftTeamsIncidentEpisodeActionType.ViewAddIncidentEpisodeNote
|
|
327
|
+
) {
|
|
328
|
+
if (!actionValue) {
|
|
329
|
+
await turnContext.sendActivity(
|
|
330
|
+
"Unable to add note: missing episode id.",
|
|
331
|
+
);
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// Send the input card
|
|
336
|
+
const card: JSONObject =
|
|
337
|
+
this.buildAddIncidentEpisodeNoteCard(actionValue);
|
|
338
|
+
await turnContext.sendActivity({
|
|
339
|
+
attachments: [
|
|
340
|
+
{
|
|
341
|
+
contentType: "application/vnd.microsoft.card.adaptive",
|
|
342
|
+
content: card,
|
|
343
|
+
},
|
|
344
|
+
],
|
|
345
|
+
});
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
if (
|
|
350
|
+
actionType ===
|
|
351
|
+
MicrosoftTeamsIncidentEpisodeActionType.SubmitIncidentEpisodeNote
|
|
352
|
+
) {
|
|
353
|
+
if (!actionValue) {
|
|
354
|
+
await turnContext.sendActivity(
|
|
355
|
+
"Unable to add note: missing episode id.",
|
|
356
|
+
);
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// Check if form data is provided
|
|
361
|
+
const note: JSONValue = value["note"];
|
|
362
|
+
|
|
363
|
+
if (note) {
|
|
364
|
+
// Submit the note
|
|
365
|
+
const episodeId: ObjectID = new ObjectID(actionValue);
|
|
366
|
+
|
|
367
|
+
await IncidentEpisodeInternalNoteService.addNote({
|
|
368
|
+
incidentEpisodeId: episodeId,
|
|
369
|
+
note: note.toString(),
|
|
370
|
+
projectId: projectId,
|
|
371
|
+
userId: oneUptimeUserId,
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
await turnContext.sendActivity("Note added successfully.");
|
|
375
|
+
|
|
376
|
+
// Hide the form card by deleting it
|
|
377
|
+
if (turnContext.activity.replyToId) {
|
|
378
|
+
await turnContext.deleteActivity(turnContext.activity.replyToId);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
await turnContext.sendActivity("Unable to add note: missing note data.");
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
if (
|
|
388
|
+
actionType ===
|
|
389
|
+
MicrosoftTeamsIncidentEpisodeActionType.ViewExecuteIncidentEpisodeOnCallPolicy
|
|
390
|
+
) {
|
|
391
|
+
if (!actionValue) {
|
|
392
|
+
await turnContext.sendActivity(
|
|
393
|
+
"Unable to execute on-call policy: missing episode id.",
|
|
394
|
+
);
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// Send the input card
|
|
399
|
+
const card: JSONObject | null =
|
|
400
|
+
await this.buildExecuteIncidentEpisodeOnCallPolicyCard(
|
|
401
|
+
actionValue,
|
|
402
|
+
projectId,
|
|
403
|
+
);
|
|
404
|
+
if (!card) {
|
|
405
|
+
await turnContext.sendActivity(
|
|
406
|
+
"No on-call policies found in the project",
|
|
407
|
+
);
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
await turnContext.sendActivity({
|
|
411
|
+
attachments: [
|
|
412
|
+
{
|
|
413
|
+
contentType: "application/vnd.microsoft.card.adaptive",
|
|
414
|
+
content: card,
|
|
415
|
+
},
|
|
416
|
+
],
|
|
417
|
+
});
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
if (
|
|
422
|
+
actionType ===
|
|
423
|
+
MicrosoftTeamsIncidentEpisodeActionType.SubmitExecuteIncidentEpisodeOnCallPolicy
|
|
424
|
+
) {
|
|
425
|
+
if (!actionValue) {
|
|
426
|
+
await turnContext.sendActivity(
|
|
427
|
+
"Unable to execute on-call policy: missing episode id.",
|
|
428
|
+
);
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// Check if form data is provided
|
|
433
|
+
const onCallPolicyId: JSONValue = value["onCallPolicy"];
|
|
434
|
+
|
|
435
|
+
if (onCallPolicyId) {
|
|
436
|
+
// Execute the policy
|
|
437
|
+
const episodeId: ObjectID = new ObjectID(actionValue);
|
|
438
|
+
|
|
439
|
+
await OnCallDutyPolicyService.executePolicy(
|
|
440
|
+
new ObjectID(onCallPolicyId.toString()),
|
|
441
|
+
{
|
|
442
|
+
triggeredByIncidentEpisodeId: episodeId,
|
|
443
|
+
userNotificationEventType:
|
|
444
|
+
UserNotificationEventType.IncidentEpisodeCreated,
|
|
445
|
+
},
|
|
446
|
+
);
|
|
447
|
+
|
|
448
|
+
await turnContext.sendActivity("On-call policy executed successfully.");
|
|
449
|
+
|
|
450
|
+
// Hide the form card by deleting it
|
|
451
|
+
if (turnContext.activity.replyToId) {
|
|
452
|
+
await turnContext.deleteActivity(turnContext.activity.replyToId);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
await turnContext.sendActivity(
|
|
458
|
+
"Unable to execute on-call policy: missing policy id.",
|
|
459
|
+
);
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
if (
|
|
464
|
+
actionType ===
|
|
465
|
+
MicrosoftTeamsIncidentEpisodeActionType.ViewChangeIncidentEpisodeState
|
|
466
|
+
) {
|
|
467
|
+
if (!actionValue) {
|
|
468
|
+
await turnContext.sendActivity(
|
|
469
|
+
"Unable to change episode state: missing episode id.",
|
|
470
|
+
);
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
// Send the input card
|
|
475
|
+
const card: JSONObject = await this.buildChangeIncidentEpisodeStateCard(
|
|
476
|
+
actionValue,
|
|
477
|
+
projectId,
|
|
478
|
+
);
|
|
479
|
+
await turnContext.sendActivity({
|
|
480
|
+
attachments: [
|
|
481
|
+
{
|
|
482
|
+
contentType: "application/vnd.microsoft.card.adaptive",
|
|
483
|
+
content: card,
|
|
484
|
+
},
|
|
485
|
+
],
|
|
486
|
+
});
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
if (
|
|
491
|
+
actionType ===
|
|
492
|
+
MicrosoftTeamsIncidentEpisodeActionType.SubmitChangeIncidentEpisodeState
|
|
493
|
+
) {
|
|
494
|
+
if (!actionValue) {
|
|
495
|
+
await turnContext.sendActivity(
|
|
496
|
+
"Unable to change episode state: missing episode id.",
|
|
497
|
+
);
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
// Check if form data is provided
|
|
502
|
+
const incidentStateId: JSONValue = value["incidentState"];
|
|
503
|
+
|
|
504
|
+
if (incidentStateId) {
|
|
505
|
+
// Update the state
|
|
506
|
+
const episodeId: ObjectID = new ObjectID(actionValue);
|
|
507
|
+
|
|
508
|
+
await IncidentEpisodeService.updateOneById({
|
|
509
|
+
id: episodeId,
|
|
510
|
+
data: {
|
|
511
|
+
currentIncidentStateId: new ObjectID(incidentStateId.toString()),
|
|
512
|
+
},
|
|
513
|
+
props: {
|
|
514
|
+
isRoot: true,
|
|
515
|
+
},
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
await turnContext.sendActivity(
|
|
519
|
+
"Incident episode state changed successfully.",
|
|
520
|
+
);
|
|
521
|
+
|
|
522
|
+
// Hide the form card by deleting it
|
|
523
|
+
if (turnContext.activity.replyToId) {
|
|
524
|
+
await turnContext.deleteActivity(turnContext.activity.replyToId);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
await turnContext.sendActivity(
|
|
530
|
+
"Unable to change episode state: missing state id.",
|
|
531
|
+
);
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
// Default fallback for unimplemented actions
|
|
536
|
+
await turnContext.sendActivity(
|
|
537
|
+
"Sorry, but the action " +
|
|
538
|
+
actionType +
|
|
539
|
+
" you requested is not implemented yet.",
|
|
540
|
+
);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
private static buildAddIncidentEpisodeNoteCard(
|
|
544
|
+
episodeId: string,
|
|
545
|
+
): JSONObject {
|
|
546
|
+
return {
|
|
547
|
+
type: "AdaptiveCard",
|
|
548
|
+
$schema: "http://adaptivecards.io/schemas/adaptive-card.json",
|
|
549
|
+
version: "1.5",
|
|
550
|
+
body: [
|
|
551
|
+
{
|
|
552
|
+
type: "TextBlock",
|
|
553
|
+
text: "Add Incident Episode Note",
|
|
554
|
+
size: "Large",
|
|
555
|
+
weight: "Bolder",
|
|
556
|
+
},
|
|
557
|
+
{
|
|
558
|
+
type: "Input.Text",
|
|
559
|
+
id: "note",
|
|
560
|
+
label: "Note",
|
|
561
|
+
isMultiline: true,
|
|
562
|
+
placeholder: "Please type in plain text or markdown.",
|
|
563
|
+
},
|
|
564
|
+
],
|
|
565
|
+
actions: [
|
|
566
|
+
{
|
|
567
|
+
type: "Action.Submit",
|
|
568
|
+
title: "Submit",
|
|
569
|
+
data: {
|
|
570
|
+
action:
|
|
571
|
+
MicrosoftTeamsIncidentEpisodeActionType.SubmitIncidentEpisodeNote,
|
|
572
|
+
actionValue: episodeId,
|
|
573
|
+
},
|
|
574
|
+
},
|
|
575
|
+
],
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
private static async buildExecuteIncidentEpisodeOnCallPolicyCard(
|
|
580
|
+
episodeId: string,
|
|
581
|
+
projectId: ObjectID,
|
|
582
|
+
): Promise<JSONObject | null> {
|
|
583
|
+
const onCallPolicies: Array<OnCallDutyPolicy> =
|
|
584
|
+
await OnCallDutyPolicyService.findBy({
|
|
585
|
+
query: {
|
|
586
|
+
projectId: projectId,
|
|
587
|
+
},
|
|
588
|
+
select: {
|
|
589
|
+
name: true,
|
|
590
|
+
_id: true,
|
|
591
|
+
},
|
|
592
|
+
props: {
|
|
593
|
+
isRoot: true,
|
|
594
|
+
},
|
|
595
|
+
limit: 50,
|
|
596
|
+
skip: 0,
|
|
597
|
+
});
|
|
598
|
+
|
|
599
|
+
const choices: Array<{ title: string; value: string }> = onCallPolicies
|
|
600
|
+
.map((policy: OnCallDutyPolicy) => {
|
|
601
|
+
return {
|
|
602
|
+
title: policy.name || "",
|
|
603
|
+
value: policy._id?.toString() || "",
|
|
604
|
+
};
|
|
605
|
+
})
|
|
606
|
+
.filter((choice: { title: string; value: string }) => {
|
|
607
|
+
return choice.title && choice.value;
|
|
608
|
+
});
|
|
609
|
+
|
|
610
|
+
if (choices.length === 0) {
|
|
611
|
+
return null;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
return {
|
|
615
|
+
type: "AdaptiveCard",
|
|
616
|
+
$schema: "http://adaptivecards.io/schemas/adaptive-card.json",
|
|
617
|
+
version: "1.5",
|
|
618
|
+
body: [
|
|
619
|
+
{
|
|
620
|
+
type: "TextBlock",
|
|
621
|
+
text: "Execute On-Call Policy",
|
|
622
|
+
size: "Large",
|
|
623
|
+
weight: "Bolder",
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
type: "Input.ChoiceSet",
|
|
627
|
+
id: "onCallPolicy",
|
|
628
|
+
label: "On-Call Policy",
|
|
629
|
+
style: "compact",
|
|
630
|
+
choices: choices,
|
|
631
|
+
},
|
|
632
|
+
],
|
|
633
|
+
actions: [
|
|
634
|
+
{
|
|
635
|
+
type: "Action.Submit",
|
|
636
|
+
title: "Execute",
|
|
637
|
+
data: {
|
|
638
|
+
action:
|
|
639
|
+
MicrosoftTeamsIncidentEpisodeActionType.SubmitExecuteIncidentEpisodeOnCallPolicy,
|
|
640
|
+
actionValue: episodeId,
|
|
641
|
+
},
|
|
642
|
+
},
|
|
643
|
+
],
|
|
644
|
+
};
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
private static async buildChangeIncidentEpisodeStateCard(
|
|
648
|
+
episodeId: string,
|
|
649
|
+
projectId: ObjectID,
|
|
650
|
+
): Promise<JSONObject> {
|
|
651
|
+
const incidentStates: Array<IncidentState> =
|
|
652
|
+
await IncidentStateService.getAllIncidentStates({
|
|
653
|
+
projectId: projectId,
|
|
654
|
+
props: {
|
|
655
|
+
isRoot: true,
|
|
656
|
+
},
|
|
657
|
+
});
|
|
658
|
+
|
|
659
|
+
const choices: Array<{ title: string; value: string }> = incidentStates
|
|
660
|
+
.map((state: IncidentState) => {
|
|
661
|
+
return {
|
|
662
|
+
title: state.name || "",
|
|
663
|
+
value: state._id?.toString() || "",
|
|
664
|
+
};
|
|
665
|
+
})
|
|
666
|
+
.filter((choice: { title: string; value: string }) => {
|
|
667
|
+
return choice.title && choice.value;
|
|
668
|
+
});
|
|
669
|
+
|
|
670
|
+
return {
|
|
671
|
+
type: "AdaptiveCard",
|
|
672
|
+
$schema: "http://adaptivecards.io/schemas/adaptive-card.json",
|
|
673
|
+
version: "1.5",
|
|
674
|
+
body: [
|
|
675
|
+
{
|
|
676
|
+
type: "TextBlock",
|
|
677
|
+
text: "Change Incident Episode State",
|
|
678
|
+
size: "Large",
|
|
679
|
+
weight: "Bolder",
|
|
680
|
+
},
|
|
681
|
+
{
|
|
682
|
+
type: "Input.ChoiceSet",
|
|
683
|
+
id: "incidentState",
|
|
684
|
+
label: "Incident State",
|
|
685
|
+
style: "compact",
|
|
686
|
+
choices: choices,
|
|
687
|
+
},
|
|
688
|
+
],
|
|
689
|
+
actions: [
|
|
690
|
+
{
|
|
691
|
+
type: "Action.Submit",
|
|
692
|
+
title: "Change",
|
|
693
|
+
data: {
|
|
694
|
+
action:
|
|
695
|
+
MicrosoftTeamsIncidentEpisodeActionType.SubmitChangeIncidentEpisodeState,
|
|
696
|
+
actionValue: episodeId,
|
|
697
|
+
},
|
|
698
|
+
},
|
|
699
|
+
],
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
}
|