@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
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
BillingPrivateKey,
|
|
3
|
+
BillingWebhookSecret,
|
|
4
|
+
IsBillingEnabled,
|
|
5
|
+
DashboardClientUrl,
|
|
6
|
+
} from "../EnvironmentConfig";
|
|
7
|
+
import Project from "../../Models/DatabaseModels/Project";
|
|
2
8
|
import ServerMeteredPlan from "../Types/Billing/MeteredPlan/ServerMeteredPlan";
|
|
3
9
|
import Errors from "../Utils/Errors";
|
|
4
10
|
import logger from "../Utils/Logger";
|
|
5
11
|
import BaseService from "./BaseService";
|
|
12
|
+
import MailService from "./MailService";
|
|
13
|
+
import ProjectService from "./ProjectService";
|
|
6
14
|
import SubscriptionPlan from "../../Types/Billing/SubscriptionPlan";
|
|
7
15
|
import SubscriptionStatus, {
|
|
8
16
|
SubscriptionStatusUtil,
|
|
@@ -10,6 +18,7 @@ import SubscriptionStatus, {
|
|
|
10
18
|
import OneUptimeDate from "../../Types/Date";
|
|
11
19
|
import Dictionary from "../../Types/Dictionary";
|
|
12
20
|
import Email from "../../Types/Email";
|
|
21
|
+
import EmailTemplateType from "../../Types/Email/EmailTemplateType";
|
|
13
22
|
import APIException from "../../Types/Exception/ApiException";
|
|
14
23
|
import BadDataException from "../../Types/Exception/BadDataException";
|
|
15
24
|
import ProductType from "../../Types/MeteredPlan/ProductType";
|
|
@@ -86,8 +95,16 @@ export class BillingService extends BaseService {
|
|
|
86
95
|
businessDetails: string,
|
|
87
96
|
countryCode?: string | null,
|
|
88
97
|
financeAccountingEmail?: string | null,
|
|
98
|
+
sendInvoicesByEmail?: boolean | null,
|
|
89
99
|
): Promise<void> {
|
|
100
|
+
logger.debug(
|
|
101
|
+
`[Invoice Email] updateCustomerBusinessDetails called - customerId: ${id}, sendInvoicesByEmail: ${sendInvoicesByEmail}`,
|
|
102
|
+
);
|
|
103
|
+
|
|
90
104
|
if (!this.isBillingEnabled()) {
|
|
105
|
+
logger.debug(
|
|
106
|
+
`[Invoice Email] Billing not enabled, skipping updateCustomerBusinessDetails for customer ${id}`,
|
|
107
|
+
);
|
|
91
108
|
throw new BadDataException(Errors.BillingService.BILLING_NOT_ENABLED);
|
|
92
109
|
}
|
|
93
110
|
/*
|
|
@@ -133,6 +150,14 @@ export class BillingService extends BaseService {
|
|
|
133
150
|
// Remove if cleared
|
|
134
151
|
metadata["finance_accounting_email"] = "";
|
|
135
152
|
}
|
|
153
|
+
if (sendInvoicesByEmail !== undefined && sendInvoicesByEmail !== null) {
|
|
154
|
+
metadata["send_invoices_by_email"] = sendInvoicesByEmail
|
|
155
|
+
? "true"
|
|
156
|
+
: "false";
|
|
157
|
+
logger.debug(
|
|
158
|
+
`[Invoice Email] Setting send_invoices_by_email metadata to "${metadata["send_invoices_by_email"]}" for customer ${id}`,
|
|
159
|
+
);
|
|
160
|
+
}
|
|
136
161
|
|
|
137
162
|
const updateParams: Stripe.CustomerUpdateParams = {
|
|
138
163
|
metadata,
|
|
@@ -169,7 +194,11 @@ export class BillingService extends BaseService {
|
|
|
169
194
|
} as any;
|
|
170
195
|
}
|
|
171
196
|
|
|
197
|
+
logger.debug(
|
|
198
|
+
`[Invoice Email] Updating Stripe customer ${id} with metadata: ${JSON.stringify(metadata)}`,
|
|
199
|
+
);
|
|
172
200
|
await this.stripe.customers.update(id, updateParams);
|
|
201
|
+
logger.debug(`[Invoice Email] Successfully updated Stripe customer ${id}`);
|
|
173
202
|
}
|
|
174
203
|
|
|
175
204
|
@CaptureSpan()
|
|
@@ -924,12 +953,169 @@ export class BillingService extends BaseService {
|
|
|
924
953
|
return billingInvoices;
|
|
925
954
|
}
|
|
926
955
|
|
|
956
|
+
@CaptureSpan()
|
|
957
|
+
public async sendInvoiceByEmail(
|
|
958
|
+
invoiceId: string,
|
|
959
|
+
recipientEmail?: Email,
|
|
960
|
+
projectId?: ObjectID,
|
|
961
|
+
): Promise<void> {
|
|
962
|
+
logger.debug(
|
|
963
|
+
`[Invoice Email] sendInvoiceByEmail called for invoice: ${invoiceId}, recipientEmail: ${recipientEmail?.toString()}`,
|
|
964
|
+
);
|
|
965
|
+
|
|
966
|
+
if (!this.isBillingEnabled()) {
|
|
967
|
+
logger.debug(
|
|
968
|
+
`[Invoice Email] Billing not enabled, skipping send for invoice: ${invoiceId}`,
|
|
969
|
+
);
|
|
970
|
+
throw new BadDataException(Errors.BillingService.BILLING_NOT_ENABLED);
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
try {
|
|
974
|
+
// Fetch invoice details from Stripe
|
|
975
|
+
logger.debug(
|
|
976
|
+
`[Invoice Email] Fetching invoice ${invoiceId} details from Stripe`,
|
|
977
|
+
);
|
|
978
|
+
const stripeInvoice: Stripe.Invoice =
|
|
979
|
+
await this.stripe.invoices.retrieve(invoiceId);
|
|
980
|
+
|
|
981
|
+
if (!stripeInvoice) {
|
|
982
|
+
logger.error(
|
|
983
|
+
`[Invoice Email] Invoice ${invoiceId} not found in Stripe`,
|
|
984
|
+
);
|
|
985
|
+
return;
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
// Determine recipient email
|
|
989
|
+
let toEmail: Email | undefined = recipientEmail;
|
|
990
|
+
if (!toEmail && stripeInvoice.customer_email) {
|
|
991
|
+
toEmail = new Email(stripeInvoice.customer_email);
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
if (!toEmail) {
|
|
995
|
+
logger.error(
|
|
996
|
+
`[Invoice Email] No recipient email found for invoice ${invoiceId}`,
|
|
997
|
+
);
|
|
998
|
+
return;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
// Format invoice data for email
|
|
1002
|
+
const invoiceNumber: string = stripeInvoice.number || invoiceId;
|
|
1003
|
+
const invoiceDate: string = stripeInvoice.created
|
|
1004
|
+
? OneUptimeDate.getDateAsFormattedString(
|
|
1005
|
+
new Date(stripeInvoice.created * 1000),
|
|
1006
|
+
)
|
|
1007
|
+
: OneUptimeDate.getDateAsFormattedString(
|
|
1008
|
+
OneUptimeDate.getCurrentDate(),
|
|
1009
|
+
);
|
|
1010
|
+
const amount: string = `${(stripeInvoice.amount_due / 100).toFixed(2)} ${stripeInvoice.currency?.toUpperCase() || "USD"}`;
|
|
1011
|
+
const invoicePdfUrl: string | undefined =
|
|
1012
|
+
stripeInvoice.invoice_pdf || undefined;
|
|
1013
|
+
const description: string | undefined =
|
|
1014
|
+
stripeInvoice.description || undefined;
|
|
1015
|
+
|
|
1016
|
+
// Build dashboard link
|
|
1017
|
+
let dashboardLink: string | undefined = undefined;
|
|
1018
|
+
if (projectId && DashboardClientUrl) {
|
|
1019
|
+
dashboardLink = `${DashboardClientUrl.toString()}/dashboard/${projectId.toString()}/settings/billing`;
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
logger.debug(
|
|
1023
|
+
`[Invoice Email] Sending invoice email to ${toEmail.toString()} - Invoice #${invoiceNumber}, Amount: ${amount}`,
|
|
1024
|
+
);
|
|
1025
|
+
|
|
1026
|
+
// Send email via OneUptime MailService
|
|
1027
|
+
await MailService.sendMail(
|
|
1028
|
+
{
|
|
1029
|
+
toEmail: toEmail,
|
|
1030
|
+
templateType: EmailTemplateType.Invoice,
|
|
1031
|
+
vars: {
|
|
1032
|
+
invoiceNumber: invoiceNumber,
|
|
1033
|
+
invoiceDate: invoiceDate,
|
|
1034
|
+
amount: amount,
|
|
1035
|
+
description: description || "",
|
|
1036
|
+
invoicePdfUrl: invoicePdfUrl || "",
|
|
1037
|
+
dashboardLink: dashboardLink || "",
|
|
1038
|
+
},
|
|
1039
|
+
subject: `Invoice #${invoiceNumber} from OneUptime`,
|
|
1040
|
+
},
|
|
1041
|
+
{
|
|
1042
|
+
projectId: projectId,
|
|
1043
|
+
},
|
|
1044
|
+
);
|
|
1045
|
+
|
|
1046
|
+
logger.debug(
|
|
1047
|
+
`[Invoice Email] Successfully sent invoice ${invoiceId} email to ${toEmail.toString()}`,
|
|
1048
|
+
);
|
|
1049
|
+
} catch (err) {
|
|
1050
|
+
logger.error(
|
|
1051
|
+
`[Invoice Email] Failed to send invoice ${invoiceId} by email: ${err}`,
|
|
1052
|
+
);
|
|
1053
|
+
// Don't throw - sending email is not critical
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
@CaptureSpan()
|
|
1058
|
+
public async shouldSendInvoicesByEmail(customerId: string): Promise<boolean> {
|
|
1059
|
+
logger.debug(
|
|
1060
|
+
`[Invoice Email] shouldSendInvoicesByEmail called for customer: ${customerId}`,
|
|
1061
|
+
);
|
|
1062
|
+
|
|
1063
|
+
if (!this.isBillingEnabled()) {
|
|
1064
|
+
logger.debug(
|
|
1065
|
+
`[Invoice Email] Billing not enabled, returning false for customer: ${customerId}`,
|
|
1066
|
+
);
|
|
1067
|
+
return false;
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
try {
|
|
1071
|
+
logger.debug(
|
|
1072
|
+
`[Invoice Email] Retrieving customer ${customerId} from Stripe to check preference`,
|
|
1073
|
+
);
|
|
1074
|
+
const customer: Stripe.Response<
|
|
1075
|
+
Stripe.Customer | Stripe.DeletedCustomer
|
|
1076
|
+
> = await this.stripe.customers.retrieve(customerId);
|
|
1077
|
+
|
|
1078
|
+
if (!customer || customer.deleted) {
|
|
1079
|
+
logger.debug(
|
|
1080
|
+
`[Invoice Email] Customer ${customerId} not found or deleted, returning false`,
|
|
1081
|
+
);
|
|
1082
|
+
return false;
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
const metadata: Stripe.Metadata = (customer as Stripe.Customer).metadata;
|
|
1086
|
+
const sendInvoicesByEmail: boolean =
|
|
1087
|
+
metadata?.["send_invoices_by_email"] === "true";
|
|
1088
|
+
logger.debug(
|
|
1089
|
+
`[Invoice Email] Customer ${customerId} metadata.send_invoices_by_email = "${metadata?.["send_invoices_by_email"]}", result: ${sendInvoicesByEmail}`,
|
|
1090
|
+
);
|
|
1091
|
+
return sendInvoicesByEmail;
|
|
1092
|
+
} catch (err) {
|
|
1093
|
+
logger.error(
|
|
1094
|
+
`[Invoice Email] Failed to check invoice email preference for customer ${customerId}: ${err}`,
|
|
1095
|
+
);
|
|
1096
|
+
return false;
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
|
|
927
1100
|
@CaptureSpan()
|
|
928
1101
|
public async generateInvoiceAndChargeCustomer(
|
|
929
1102
|
customerId: string,
|
|
930
1103
|
itemText: string,
|
|
931
1104
|
amountInUsd: number,
|
|
1105
|
+
options?: {
|
|
1106
|
+
sendInvoiceByEmail?: boolean | undefined;
|
|
1107
|
+
recipientEmail?: Email | undefined;
|
|
1108
|
+
projectId?: ObjectID | undefined;
|
|
1109
|
+
},
|
|
932
1110
|
): Promise<void> {
|
|
1111
|
+
const sendInvoiceByEmail: boolean = options?.sendInvoiceByEmail || false;
|
|
1112
|
+
const recipientEmail: Email | undefined = options?.recipientEmail;
|
|
1113
|
+
const projectId: ObjectID | undefined = options?.projectId;
|
|
1114
|
+
|
|
1115
|
+
logger.debug(
|
|
1116
|
+
`[Invoice Email] generateInvoiceAndChargeCustomer called - customer: ${customerId}, amount: $${amountInUsd}, sendInvoiceByEmail: ${sendInvoiceByEmail}, recipientEmail: ${recipientEmail?.toString()}, projectId: ${projectId?.toString()}`,
|
|
1117
|
+
);
|
|
1118
|
+
|
|
933
1119
|
const invoice: Stripe.Invoice = await this.stripe.invoices.create({
|
|
934
1120
|
customer: customerId,
|
|
935
1121
|
auto_advance: true, // do not automatically charge.
|
|
@@ -937,9 +1123,16 @@ export class BillingService extends BaseService {
|
|
|
937
1123
|
});
|
|
938
1124
|
|
|
939
1125
|
if (!invoice || !invoice.id) {
|
|
1126
|
+
logger.error(
|
|
1127
|
+
`[Invoice Email] Failed to create invoice for customer ${customerId}`,
|
|
1128
|
+
);
|
|
940
1129
|
throw new APIException(Errors.BillingService.INVOICE_NOT_GENERATED);
|
|
941
1130
|
}
|
|
942
1131
|
|
|
1132
|
+
logger.debug(
|
|
1133
|
+
`[Invoice Email] Created invoice ${invoice.id} for customer ${customerId}`,
|
|
1134
|
+
);
|
|
1135
|
+
|
|
943
1136
|
await this.stripe.invoiceItems.create({
|
|
944
1137
|
invoice: invoice.id,
|
|
945
1138
|
amount: amountInUsd * 100,
|
|
@@ -947,11 +1140,32 @@ export class BillingService extends BaseService {
|
|
|
947
1140
|
customer: customerId,
|
|
948
1141
|
});
|
|
949
1142
|
|
|
1143
|
+
logger.debug(
|
|
1144
|
+
`[Invoice Email] Added invoice item to invoice ${invoice.id}: ${itemText}, $${amountInUsd}`,
|
|
1145
|
+
);
|
|
1146
|
+
|
|
950
1147
|
await this.stripe.invoices.finalizeInvoice(invoice.id!);
|
|
1148
|
+
logger.debug(`[Invoice Email] Finalized invoice ${invoice.id}`);
|
|
951
1149
|
|
|
952
1150
|
try {
|
|
953
1151
|
await this.payInvoice(customerId, invoice.id!);
|
|
1152
|
+
logger.debug(`[Invoice Email] Paid invoice ${invoice.id}`);
|
|
1153
|
+
|
|
1154
|
+
// Send invoice by email if requested
|
|
1155
|
+
if (sendInvoiceByEmail) {
|
|
1156
|
+
logger.debug(
|
|
1157
|
+
`[Invoice Email] sendInvoiceByEmail is true, sending invoice ${invoice.id} by email`,
|
|
1158
|
+
);
|
|
1159
|
+
await this.sendInvoiceByEmail(invoice.id!, recipientEmail, projectId);
|
|
1160
|
+
} else {
|
|
1161
|
+
logger.debug(
|
|
1162
|
+
`[Invoice Email] sendInvoiceByEmail is false, skipping email for invoice ${invoice.id}`,
|
|
1163
|
+
);
|
|
1164
|
+
}
|
|
954
1165
|
} catch (err) {
|
|
1166
|
+
logger.error(
|
|
1167
|
+
`[Invoice Email] Failed to pay invoice ${invoice.id}, voiding: ${err}`,
|
|
1168
|
+
);
|
|
955
1169
|
// mark invoice as failed and do not collect payment.
|
|
956
1170
|
await this.voidInvoice(invoice.id!);
|
|
957
1171
|
throw err;
|
|
@@ -1035,6 +1249,140 @@ export class BillingService extends BaseService {
|
|
|
1035
1249
|
"Plan with productType " + productType + " not found",
|
|
1036
1250
|
);
|
|
1037
1251
|
}
|
|
1252
|
+
|
|
1253
|
+
@CaptureSpan()
|
|
1254
|
+
public verifyWebhookSignature(
|
|
1255
|
+
payload: string | Buffer,
|
|
1256
|
+
signature: string,
|
|
1257
|
+
): Stripe.Event {
|
|
1258
|
+
logger.debug(`[Invoice Email] verifyWebhookSignature called`);
|
|
1259
|
+
|
|
1260
|
+
if (!BillingWebhookSecret) {
|
|
1261
|
+
logger.error(`[Invoice Email] Billing webhook secret is not configured`);
|
|
1262
|
+
throw new BadDataException("Billing webhook secret is not configured");
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
logger.debug(
|
|
1266
|
+
`[Invoice Email] Verifying webhook signature with secret (length: ${BillingWebhookSecret.length})`,
|
|
1267
|
+
);
|
|
1268
|
+
const event: Stripe.Event = this.stripe.webhooks.constructEvent(
|
|
1269
|
+
payload,
|
|
1270
|
+
signature,
|
|
1271
|
+
BillingWebhookSecret,
|
|
1272
|
+
);
|
|
1273
|
+
logger.debug(
|
|
1274
|
+
`[Invoice Email] Webhook signature verified, event type: ${event.type}, event id: ${event.id}`,
|
|
1275
|
+
);
|
|
1276
|
+
return event;
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
@CaptureSpan()
|
|
1280
|
+
public async handleWebhookEvent(event: Stripe.Event): Promise<void> {
|
|
1281
|
+
logger.debug(
|
|
1282
|
+
`[Invoice Email] handleWebhookEvent called - event type: ${event.type}, event id: ${event.id}`,
|
|
1283
|
+
);
|
|
1284
|
+
|
|
1285
|
+
if (!this.isBillingEnabled()) {
|
|
1286
|
+
logger.debug(
|
|
1287
|
+
`[Invoice Email] Billing not enabled, ignoring webhook event ${event.id}`,
|
|
1288
|
+
);
|
|
1289
|
+
return;
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
// Handle invoice.finalized event to send invoice by email if customer has opted in
|
|
1293
|
+
if (event.type === "invoice.finalized") {
|
|
1294
|
+
logger.debug(
|
|
1295
|
+
`[Invoice Email] Processing invoice.finalized event ${event.id}`,
|
|
1296
|
+
);
|
|
1297
|
+
const invoice: Stripe.Invoice = event.data.object as Stripe.Invoice;
|
|
1298
|
+
|
|
1299
|
+
logger.debug(
|
|
1300
|
+
`[Invoice Email] Invoice details - id: ${invoice.id}, number: ${invoice.number}, customer: ${invoice.customer}, status: ${invoice.status}`,
|
|
1301
|
+
);
|
|
1302
|
+
|
|
1303
|
+
if (!invoice.customer) {
|
|
1304
|
+
logger.debug(
|
|
1305
|
+
`[Invoice Email] No customer on invoice ${invoice.id}, skipping`,
|
|
1306
|
+
);
|
|
1307
|
+
return;
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
const customerId: string =
|
|
1311
|
+
typeof invoice.customer === "string"
|
|
1312
|
+
? invoice.customer
|
|
1313
|
+
: invoice.customer.id;
|
|
1314
|
+
|
|
1315
|
+
logger.debug(
|
|
1316
|
+
`[Invoice Email] Extracted customer ID: ${customerId} from invoice ${invoice.id}`,
|
|
1317
|
+
);
|
|
1318
|
+
|
|
1319
|
+
try {
|
|
1320
|
+
logger.debug(
|
|
1321
|
+
`[Invoice Email] Checking if customer ${customerId} has invoice emails enabled`,
|
|
1322
|
+
);
|
|
1323
|
+
const shouldSend: boolean =
|
|
1324
|
+
await this.shouldSendInvoicesByEmail(customerId);
|
|
1325
|
+
|
|
1326
|
+
if (shouldSend && invoice.id) {
|
|
1327
|
+
logger.debug(
|
|
1328
|
+
`[Invoice Email] Customer ${customerId} has invoice emails enabled, looking up project`,
|
|
1329
|
+
);
|
|
1330
|
+
|
|
1331
|
+
// Find the project by Stripe customer ID
|
|
1332
|
+
const project: Project | null = await ProjectService.findOneBy({
|
|
1333
|
+
query: {
|
|
1334
|
+
paymentProviderCustomerId: customerId,
|
|
1335
|
+
},
|
|
1336
|
+
select: {
|
|
1337
|
+
_id: true,
|
|
1338
|
+
financeAccountingEmail: true,
|
|
1339
|
+
},
|
|
1340
|
+
props: {
|
|
1341
|
+
isRoot: true,
|
|
1342
|
+
},
|
|
1343
|
+
});
|
|
1344
|
+
|
|
1345
|
+
let recipientEmail: Email | undefined = undefined;
|
|
1346
|
+
let projectId: ObjectID | undefined = undefined;
|
|
1347
|
+
|
|
1348
|
+
if (project) {
|
|
1349
|
+
projectId = project.id || undefined;
|
|
1350
|
+
if (project.financeAccountingEmail) {
|
|
1351
|
+
recipientEmail = new Email(project.financeAccountingEmail);
|
|
1352
|
+
}
|
|
1353
|
+
logger.debug(
|
|
1354
|
+
`[Invoice Email] Found project ${projectId?.toString()}, financeAccountingEmail: ${recipientEmail?.toString()}`,
|
|
1355
|
+
);
|
|
1356
|
+
} else {
|
|
1357
|
+
logger.debug(
|
|
1358
|
+
`[Invoice Email] No project found for customer ${customerId}, will use Stripe customer email`,
|
|
1359
|
+
);
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
logger.debug(
|
|
1363
|
+
`[Invoice Email] Sending invoice ${invoice.id} by email`,
|
|
1364
|
+
);
|
|
1365
|
+
await this.sendInvoiceByEmail(invoice.id, recipientEmail, projectId);
|
|
1366
|
+
logger.debug(
|
|
1367
|
+
`[Invoice Email] Successfully processed invoice.finalized - sent invoice ${invoice.id} by email`,
|
|
1368
|
+
);
|
|
1369
|
+
} else {
|
|
1370
|
+
logger.debug(
|
|
1371
|
+
`[Invoice Email] Customer ${customerId} has invoice emails disabled (shouldSend: ${shouldSend}), skipping email for invoice ${invoice.id}`,
|
|
1372
|
+
);
|
|
1373
|
+
}
|
|
1374
|
+
} catch (err) {
|
|
1375
|
+
logger.error(
|
|
1376
|
+
`[Invoice Email] Failed to send invoice by email for invoice ${invoice.id}: ${err}`,
|
|
1377
|
+
);
|
|
1378
|
+
// Don't throw - webhook should still return success
|
|
1379
|
+
}
|
|
1380
|
+
} else {
|
|
1381
|
+
logger.debug(
|
|
1382
|
+
`[Invoice Email] Ignoring event type ${event.type}, not invoice.finalized`,
|
|
1383
|
+
);
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1038
1386
|
}
|
|
1039
1387
|
|
|
1040
1388
|
export default new BillingService();
|
|
@@ -29,6 +29,7 @@ export class CallService extends BaseService {
|
|
|
29
29
|
incidentId?: ObjectID | undefined;
|
|
30
30
|
alertId?: ObjectID | undefined;
|
|
31
31
|
alertEpisodeId?: ObjectID | undefined;
|
|
32
|
+
incidentEpisodeId?: ObjectID | undefined;
|
|
32
33
|
scheduledMaintenanceId?: ObjectID | undefined;
|
|
33
34
|
statusPageId?: ObjectID | undefined;
|
|
34
35
|
statusPageAnnouncementId?: ObjectID | undefined;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { Blue500 } from "../../Types/BrandColors";
|
|
2
|
+
import Color from "../../Types/Color";
|
|
3
|
+
import OneUptimeDate from "../../Types/Date";
|
|
4
|
+
import BadDataException from "../../Types/Exception/BadDataException";
|
|
5
|
+
import ObjectID from "../../Types/ObjectID";
|
|
6
|
+
import { IsBillingEnabled } from "../EnvironmentConfig";
|
|
7
|
+
import logger from "../Utils/Logger";
|
|
8
|
+
import DatabaseService from "./DatabaseService";
|
|
9
|
+
import Model, {
|
|
10
|
+
IncidentEpisodeFeedEventType,
|
|
11
|
+
} from "../../Models/DatabaseModels/IncidentEpisodeFeed";
|
|
12
|
+
import CaptureSpan from "../Utils/Telemetry/CaptureSpan";
|
|
13
|
+
|
|
14
|
+
export class Service extends DatabaseService<Model> {
|
|
15
|
+
public constructor() {
|
|
16
|
+
super(Model);
|
|
17
|
+
|
|
18
|
+
if (IsBillingEnabled) {
|
|
19
|
+
this.hardDeleteItemsOlderThanInDays("createdAt", 3 * 365); // 3 years
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@CaptureSpan()
|
|
24
|
+
public async createIncidentEpisodeFeedItem(data: {
|
|
25
|
+
incidentEpisodeId: ObjectID;
|
|
26
|
+
feedInfoInMarkdown: string;
|
|
27
|
+
incidentEpisodeFeedEventType: IncidentEpisodeFeedEventType;
|
|
28
|
+
projectId: ObjectID;
|
|
29
|
+
moreInformationInMarkdown?: string | undefined;
|
|
30
|
+
displayColor?: Color | undefined;
|
|
31
|
+
userId?: ObjectID | undefined;
|
|
32
|
+
postedAt?: Date | undefined;
|
|
33
|
+
}): Promise<void> {
|
|
34
|
+
try {
|
|
35
|
+
if (!data.incidentEpisodeId) {
|
|
36
|
+
throw new BadDataException("Incident Episode ID is required");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!data.feedInfoInMarkdown) {
|
|
40
|
+
throw new BadDataException("Log in markdown is required");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (!data.incidentEpisodeFeedEventType) {
|
|
44
|
+
throw new BadDataException("Incident episode log event is required");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (!data.projectId) {
|
|
48
|
+
throw new BadDataException("Project ID is required");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const incidentEpisodeFeed: Model = new Model();
|
|
52
|
+
|
|
53
|
+
if (!data.displayColor) {
|
|
54
|
+
data.displayColor = Blue500;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (data.userId) {
|
|
58
|
+
incidentEpisodeFeed.userId = data.userId;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
incidentEpisodeFeed.displayColor = data.displayColor;
|
|
62
|
+
|
|
63
|
+
incidentEpisodeFeed.incidentEpisodeId = data.incidentEpisodeId;
|
|
64
|
+
incidentEpisodeFeed.feedInfoInMarkdown = data.feedInfoInMarkdown;
|
|
65
|
+
incidentEpisodeFeed.incidentEpisodeFeedEventType =
|
|
66
|
+
data.incidentEpisodeFeedEventType;
|
|
67
|
+
incidentEpisodeFeed.projectId = data.projectId;
|
|
68
|
+
|
|
69
|
+
if (!data.postedAt) {
|
|
70
|
+
incidentEpisodeFeed.postedAt = OneUptimeDate.getCurrentDate();
|
|
71
|
+
} else {
|
|
72
|
+
incidentEpisodeFeed.postedAt = data.postedAt;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (data.moreInformationInMarkdown) {
|
|
76
|
+
incidentEpisodeFeed.moreInformationInMarkdown =
|
|
77
|
+
data.moreInformationInMarkdown;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
await this.create({
|
|
81
|
+
data: incidentEpisodeFeed,
|
|
82
|
+
props: {
|
|
83
|
+
isRoot: true,
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
} catch (error) {
|
|
87
|
+
logger.error("IncidentEpisodeFeedService.createIncidentEpisodeFeedItem");
|
|
88
|
+
logger.error(error);
|
|
89
|
+
// we dont want to throw the error here, as this is a non-critical operation
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export default new Service();
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import ObjectID from "../../Types/ObjectID";
|
|
2
|
+
import DatabaseService from "./DatabaseService";
|
|
3
|
+
import Model from "../../Models/DatabaseModels/IncidentEpisodeInternalNote";
|
|
4
|
+
import CaptureSpan from "../Utils/Telemetry/CaptureSpan";
|
|
5
|
+
import File from "../../Models/DatabaseModels/File";
|
|
6
|
+
|
|
7
|
+
export class Service extends DatabaseService<Model> {
|
|
8
|
+
public constructor() {
|
|
9
|
+
super(Model);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@CaptureSpan()
|
|
13
|
+
public async addNote(data: {
|
|
14
|
+
userId: ObjectID;
|
|
15
|
+
incidentEpisodeId: ObjectID;
|
|
16
|
+
projectId: ObjectID;
|
|
17
|
+
note: string;
|
|
18
|
+
attachmentFileIds?: Array<ObjectID>;
|
|
19
|
+
postedFromSlackMessageId?: string;
|
|
20
|
+
}): Promise<Model> {
|
|
21
|
+
const internalNote: Model = new Model();
|
|
22
|
+
internalNote.createdByUserId = data.userId;
|
|
23
|
+
internalNote.incidentEpisodeId = data.incidentEpisodeId;
|
|
24
|
+
internalNote.projectId = data.projectId;
|
|
25
|
+
internalNote.note = data.note;
|
|
26
|
+
|
|
27
|
+
if (data.postedFromSlackMessageId) {
|
|
28
|
+
internalNote.postedFromSlackMessageId = data.postedFromSlackMessageId;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (data.attachmentFileIds && data.attachmentFileIds.length > 0) {
|
|
32
|
+
internalNote.attachments = data.attachmentFileIds.map(
|
|
33
|
+
(fileId: ObjectID) => {
|
|
34
|
+
const file: File = new File();
|
|
35
|
+
file.id = fileId;
|
|
36
|
+
return file;
|
|
37
|
+
},
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return this.create({
|
|
42
|
+
data: internalNote,
|
|
43
|
+
props: {
|
|
44
|
+
isRoot: true,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@CaptureSpan()
|
|
50
|
+
public async hasNoteFromSlackMessage(data: {
|
|
51
|
+
incidentEpisodeId: ObjectID;
|
|
52
|
+
postedFromSlackMessageId: string;
|
|
53
|
+
}): Promise<boolean> {
|
|
54
|
+
const existingNote: Model | null = await this.findOneBy({
|
|
55
|
+
query: {
|
|
56
|
+
incidentEpisodeId: data.incidentEpisodeId,
|
|
57
|
+
postedFromSlackMessageId: data.postedFromSlackMessageId,
|
|
58
|
+
},
|
|
59
|
+
select: {
|
|
60
|
+
_id: true,
|
|
61
|
+
},
|
|
62
|
+
props: {
|
|
63
|
+
isRoot: true,
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
return existingNote !== null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export default new Service();
|