@oneuptime/common 9.4.7 → 9.4.9

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.
Files changed (342) hide show
  1. package/Models/DatabaseModels/Alert.ts +76 -0
  2. package/Models/DatabaseModels/AlertEpisode.ts +1201 -0
  3. package/Models/DatabaseModels/AlertEpisodeFeed.ts +529 -0
  4. package/Models/DatabaseModels/AlertEpisodeInternalNote.ts +455 -0
  5. package/Models/DatabaseModels/AlertEpisodeMember.ts +586 -0
  6. package/Models/DatabaseModels/AlertEpisodeOwnerTeam.ts +421 -0
  7. package/Models/DatabaseModels/AlertEpisodeOwnerUser.ts +419 -0
  8. package/Models/DatabaseModels/AlertEpisodeStateTimeline.ts +523 -0
  9. package/Models/DatabaseModels/AlertFeed.ts +1 -0
  10. package/Models/DatabaseModels/AlertGroupingRule.ts +1432 -0
  11. package/Models/DatabaseModels/Index.ts +18 -0
  12. package/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.ts +70 -0
  13. package/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.ts +59 -0
  14. package/Models/DatabaseModels/StatusPageDomain.ts +2 -0
  15. package/Models/DatabaseModels/UserOnCallLog.ts +48 -0
  16. package/Models/DatabaseModels/UserOnCallLogTimeline.ts +49 -0
  17. package/Models/DatabaseModels/WorkspaceNotificationLog.ts +57 -0
  18. package/Server/API/SlackAPI.ts +21 -0
  19. package/Server/API/UserOnCallLogTimelineAPI.ts +65 -25
  20. package/Server/Infrastructure/Postgres/SchemaMigrations/1768938069147-MigrationName.ts +751 -0
  21. package/Server/Infrastructure/Postgres/SchemaMigrations/1769125561322-MigrationName.ts +41 -0
  22. package/Server/Infrastructure/Postgres/SchemaMigrations/1769170578688-MigrationName.ts +29 -0
  23. package/Server/Infrastructure/Postgres/SchemaMigrations/1769172358833-MigrationName.ts +177 -0
  24. package/Server/Infrastructure/Postgres/SchemaMigrations/1769176450526-MigrationName.ts +71 -0
  25. package/Server/Infrastructure/Postgres/SchemaMigrations/1769190495840-MigrationName.ts +35 -0
  26. package/Server/Infrastructure/Postgres/SchemaMigrations/1769199303656-MigrationName.ts +29 -0
  27. package/Server/Infrastructure/Postgres/SchemaMigrations/1769202898645-MigrationName.ts +29 -0
  28. package/Server/Infrastructure/Postgres/SchemaMigrations/1769428619414-MigrationName.ts +35 -0
  29. package/Server/Infrastructure/Postgres/SchemaMigrations/1769428821686-MigrationName.ts +47 -0
  30. package/Server/Infrastructure/Postgres/SchemaMigrations/1769469813786-MigrationName.ts +71 -0
  31. package/Server/Infrastructure/Postgres/SchemaMigrations/1769517677937-RenameNotificationRuleTypes.ts +67 -0
  32. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +24 -0
  33. package/Server/Services/AlertEpisodeFeedService.ts +94 -0
  34. package/Server/Services/AlertEpisodeInternalNoteService.ts +71 -0
  35. package/Server/Services/AlertEpisodeMemberService.ts +267 -0
  36. package/Server/Services/AlertEpisodeOwnerTeamService.ts +10 -0
  37. package/Server/Services/AlertEpisodeOwnerUserService.ts +10 -0
  38. package/Server/Services/AlertEpisodeService.ts +1096 -0
  39. package/Server/Services/AlertEpisodeStateTimelineService.ts +557 -0
  40. package/Server/Services/AlertGroupingEngineService.ts +1120 -0
  41. package/Server/Services/AlertGroupingRuleService.ts +14 -0
  42. package/Server/Services/AlertService.ts +12 -0
  43. package/Server/Services/CallService.ts +2 -0
  44. package/Server/Services/Index.ts +21 -0
  45. package/Server/Services/MailService.ts +5 -0
  46. package/Server/Services/OnCallDutyPolicyEscalationRuleService.ts +18 -1
  47. package/Server/Services/OnCallDutyPolicyExecutionLogService.ts +64 -2
  48. package/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.ts +27 -1
  49. package/Server/Services/OnCallDutyPolicyService.ts +16 -1
  50. package/Server/Services/PushNotificationService.ts +1 -0
  51. package/Server/Services/SmsService.ts +2 -0
  52. package/Server/Services/UserNotificationRuleService.ts +641 -10
  53. package/Server/Services/UserNotificationSettingService.ts +23 -0
  54. package/Server/Services/UserOnCallLogService.ts +58 -14
  55. package/Server/Services/WhatsAppService.ts +5 -0
  56. package/Server/Services/WorkspaceNotificationRuleService.ts +26 -0
  57. package/Server/Utils/AnalyticsDatabase/Statement.ts +6 -2
  58. package/Server/Utils/PushNotificationUtil.ts +75 -16
  59. package/Server/Utils/WhatsAppTemplateUtil.ts +13 -0
  60. package/Server/Utils/Workspace/MicrosoftTeams/Actions/ActionTypes.ts +18 -0
  61. package/Server/Utils/Workspace/MicrosoftTeams/Actions/AlertEpisode.ts +689 -0
  62. package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +16 -0
  63. package/Server/Utils/Workspace/Slack/Actions/ActionTypes.ts +11 -0
  64. package/Server/Utils/Workspace/Slack/Actions/AlertEpisode.ts +915 -0
  65. package/Server/Utils/Workspace/Slack/Messages/AlertEpisode.ts +120 -0
  66. package/Server/Utils/Workspace/WorkspaceMessages/AlertEpisode.ts +74 -0
  67. package/Tests/Server/Services/AlertEpisodeMemberService.test.ts +200 -0
  68. package/Tests/Server/Services/AlertEpisodeService.test.ts +240 -0
  69. package/Tests/Server/Services/AlertGroupingEngineService.test.ts +542 -0
  70. package/Tests/Server/Services/AlertGroupingRuleService.test.ts +383 -0
  71. package/Tests/Server/Utils/AnalyticsDatabase/StatementGenerator.test.ts +1 -1
  72. package/Tests/UI/Components/Input.test.tsx +1 -1
  73. package/Tests/UI/Components/TextArea.test.tsx +2 -2
  74. package/Types/BaseDatabase/SortOrder.ts +9 -0
  75. package/Types/Email/EmailTemplateType.ts +6 -0
  76. package/Types/NotificationRule/NotificationRuleType.ts +3 -1
  77. package/Types/NotificationSetting/NotificationSettingEventType.ts +7 -0
  78. package/Types/Permission.ts +309 -0
  79. package/Types/UserNotification/UserNotificationEventType.ts +1 -0
  80. package/Types/WhatsApp/WhatsAppTemplates.ts +24 -0
  81. package/Types/Workspace/NotificationRules/EventType.ts +1 -0
  82. package/Types/Workspace/NotificationRules/NotificationRuleCondition.ts +32 -3
  83. package/UI/Components/Accordion/Accordion.tsx +20 -2
  84. package/UI/Components/Alerts/Alert.tsx +1 -0
  85. package/UI/Components/Button/Button.tsx +29 -0
  86. package/UI/Components/CardSelect/CardSelect.tsx +5 -1
  87. package/UI/Components/Checkbox/Checkbox.tsx +7 -3
  88. package/UI/Components/ColorCircle/ColorCircle.tsx +2 -0
  89. package/UI/Components/ColorViewer/ColorViewer.tsx +19 -3
  90. package/UI/Components/CopyableButton/CopyableButton.tsx +22 -5
  91. package/UI/Components/Detail/Detail.tsx +1 -1
  92. package/UI/Components/Dropdown/Dropdown.tsx +14 -1
  93. package/UI/Components/Forms/Fields/FormField.tsx +28 -0
  94. package/UI/Components/FullPageModal/FullPageModal.tsx +35 -4
  95. package/UI/Components/Input/Input.tsx +14 -2
  96. package/UI/Components/Link/Link.tsx +1 -0
  97. package/UI/Components/Loader/Loader.tsx +8 -2
  98. package/UI/Components/Markdown.tsx/MarkdownViewer.tsx +76 -1
  99. package/UI/Components/Modal/Modal.tsx +47 -3
  100. package/UI/Components/ModelTable/BaseModelTable.tsx +42 -1
  101. package/UI/Components/MoreMenu/MoreMenu.tsx +84 -2
  102. package/UI/Components/OrderedStatesList/OrderedStatesList.tsx +30 -8
  103. package/UI/Components/Pagination/Pagination.tsx +113 -8
  104. package/UI/Components/ProgressBar/ProgressBar.tsx +12 -2
  105. package/UI/Components/Radio/Radio.tsx +21 -3
  106. package/UI/Components/SideMenu/CountModelSideMenuItem.tsx +54 -27
  107. package/UI/Components/StatusBubble/StatusBubble.tsx +7 -2
  108. package/UI/Components/Table/TableHeader.tsx +20 -3
  109. package/UI/Components/Tabs/Tab.tsx +16 -1
  110. package/UI/Components/Tabs/Tabs.tsx +12 -1
  111. package/UI/Components/TextArea/TextArea.tsx +12 -2
  112. package/UI/Components/Toggle/Toggle.tsx +14 -3
  113. package/UI/Components/Tooltip/Tooltip.tsx +11 -1
  114. package/UI/Components/TopAlert/TopAlert.tsx +2 -0
  115. package/build/dist/Models/DatabaseModels/Alert.js +77 -0
  116. package/build/dist/Models/DatabaseModels/Alert.js.map +1 -1
  117. package/build/dist/Models/DatabaseModels/AlertEpisode.js +1225 -0
  118. package/build/dist/Models/DatabaseModels/AlertEpisode.js.map +1 -0
  119. package/build/dist/Models/DatabaseModels/AlertEpisodeFeed.js +553 -0
  120. package/build/dist/Models/DatabaseModels/AlertEpisodeFeed.js.map +1 -0
  121. package/build/dist/Models/DatabaseModels/AlertEpisodeInternalNote.js +467 -0
  122. package/build/dist/Models/DatabaseModels/AlertEpisodeInternalNote.js.map +1 -0
  123. package/build/dist/Models/DatabaseModels/AlertEpisodeMember.js +607 -0
  124. package/build/dist/Models/DatabaseModels/AlertEpisodeMember.js.map +1 -0
  125. package/build/dist/Models/DatabaseModels/AlertEpisodeOwnerTeam.js +437 -0
  126. package/build/dist/Models/DatabaseModels/AlertEpisodeOwnerTeam.js.map +1 -0
  127. package/build/dist/Models/DatabaseModels/AlertEpisodeOwnerUser.js +436 -0
  128. package/build/dist/Models/DatabaseModels/AlertEpisodeOwnerUser.js.map +1 -0
  129. package/build/dist/Models/DatabaseModels/AlertEpisodeStateTimeline.js +546 -0
  130. package/build/dist/Models/DatabaseModels/AlertEpisodeStateTimeline.js.map +1 -0
  131. package/build/dist/Models/DatabaseModels/AlertFeed.js +1 -0
  132. package/build/dist/Models/DatabaseModels/AlertFeed.js.map +1 -1
  133. package/build/dist/Models/DatabaseModels/AlertGroupingRule.js +1437 -0
  134. package/build/dist/Models/DatabaseModels/AlertGroupingRule.js.map +1 -0
  135. package/build/dist/Models/DatabaseModels/Index.js +16 -0
  136. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  137. package/build/dist/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.js +69 -0
  138. package/build/dist/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.js.map +1 -1
  139. package/build/dist/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.js +58 -0
  140. package/build/dist/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.js.map +1 -1
  141. package/build/dist/Models/DatabaseModels/StatusPageDomain.js +2 -0
  142. package/build/dist/Models/DatabaseModels/StatusPageDomain.js.map +1 -1
  143. package/build/dist/Models/DatabaseModels/UserOnCallLog.js +47 -0
  144. package/build/dist/Models/DatabaseModels/UserOnCallLog.js.map +1 -1
  145. package/build/dist/Models/DatabaseModels/UserOnCallLogTimeline.js +48 -0
  146. package/build/dist/Models/DatabaseModels/UserOnCallLogTimeline.js.map +1 -1
  147. package/build/dist/Models/DatabaseModels/WorkspaceNotificationLog.js +58 -0
  148. package/build/dist/Models/DatabaseModels/WorkspaceNotificationLog.js.map +1 -1
  149. package/build/dist/Server/API/SlackAPI.js +18 -0
  150. package/build/dist/Server/API/SlackAPI.js.map +1 -1
  151. package/build/dist/Server/API/UserOnCallLogTimelineAPI.js +55 -15
  152. package/build/dist/Server/API/UserOnCallLogTimelineAPI.js.map +1 -1
  153. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1768938069147-MigrationName.js +266 -0
  154. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1768938069147-MigrationName.js.map +1 -0
  155. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769125561322-MigrationName.js +20 -0
  156. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769125561322-MigrationName.js.map +1 -0
  157. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769170578688-MigrationName.js +16 -0
  158. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769170578688-MigrationName.js.map +1 -0
  159. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769172358833-MigrationName.js +68 -0
  160. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769172358833-MigrationName.js.map +1 -0
  161. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769176450526-MigrationName.js +30 -0
  162. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769176450526-MigrationName.js.map +1 -0
  163. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769190495840-MigrationName.js +18 -0
  164. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769190495840-MigrationName.js.map +1 -0
  165. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769199303656-MigrationName.js +16 -0
  166. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769199303656-MigrationName.js.map +1 -0
  167. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769202898645-MigrationName.js +16 -0
  168. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769202898645-MigrationName.js.map +1 -0
  169. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769428619414-MigrationName.js +18 -0
  170. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769428619414-MigrationName.js.map +1 -0
  171. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769428821686-MigrationName.js +22 -0
  172. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769428821686-MigrationName.js.map +1 -0
  173. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769469813786-MigrationName.js +30 -0
  174. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769469813786-MigrationName.js.map +1 -0
  175. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769517677937-RenameNotificationRuleTypes.js +67 -0
  176. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769517677937-RenameNotificationRuleTypes.js.map +1 -0
  177. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +24 -0
  178. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  179. package/build/dist/Server/Services/AlertEpisodeFeedService.js +83 -0
  180. package/build/dist/Server/Services/AlertEpisodeFeedService.js.map +1 -0
  181. package/build/dist/Server/Services/AlertEpisodeInternalNoteService.js +70 -0
  182. package/build/dist/Server/Services/AlertEpisodeInternalNoteService.js.map +1 -0
  183. package/build/dist/Server/Services/AlertEpisodeMemberService.js +256 -0
  184. package/build/dist/Server/Services/AlertEpisodeMemberService.js.map +1 -0
  185. package/build/dist/Server/Services/AlertEpisodeOwnerTeamService.js +9 -0
  186. package/build/dist/Server/Services/AlertEpisodeOwnerTeamService.js.map +1 -0
  187. package/build/dist/Server/Services/AlertEpisodeOwnerUserService.js +9 -0
  188. package/build/dist/Server/Services/AlertEpisodeOwnerUserService.js.map +1 -0
  189. package/build/dist/Server/Services/AlertEpisodeService.js +973 -0
  190. package/build/dist/Server/Services/AlertEpisodeService.js.map +1 -0
  191. package/build/dist/Server/Services/AlertEpisodeStateTimelineService.js +494 -0
  192. package/build/dist/Server/Services/AlertEpisodeStateTimelineService.js.map +1 -0
  193. package/build/dist/Server/Services/AlertGroupingEngineService.js +893 -0
  194. package/build/dist/Server/Services/AlertGroupingEngineService.js.map +1 -0
  195. package/build/dist/Server/Services/AlertGroupingRuleService.js +13 -0
  196. package/build/dist/Server/Services/AlertGroupingRuleService.js.map +1 -0
  197. package/build/dist/Server/Services/AlertService.js +11 -0
  198. package/build/dist/Server/Services/AlertService.js.map +1 -1
  199. package/build/dist/Server/Services/CallService.js +11 -10
  200. package/build/dist/Server/Services/CallService.js.map +1 -1
  201. package/build/dist/Server/Services/Index.js +18 -0
  202. package/build/dist/Server/Services/Index.js.map +1 -1
  203. package/build/dist/Server/Services/MailService.js +3 -0
  204. package/build/dist/Server/Services/MailService.js.map +1 -1
  205. package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js +10 -1
  206. package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js.map +1 -1
  207. package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogService.js +49 -2
  208. package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogService.js.map +1 -1
  209. package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.js +21 -1
  210. package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.js.map +1 -1
  211. package/build/dist/Server/Services/OnCallDutyPolicyService.js +9 -1
  212. package/build/dist/Server/Services/OnCallDutyPolicyService.js.map +1 -1
  213. package/build/dist/Server/Services/PushNotificationService.js.map +1 -1
  214. package/build/dist/Server/Services/SmsService.js +11 -10
  215. package/build/dist/Server/Services/SmsService.js.map +1 -1
  216. package/build/dist/Server/Services/UserNotificationRuleService.js +521 -43
  217. package/build/dist/Server/Services/UserNotificationRuleService.js.map +1 -1
  218. package/build/dist/Server/Services/UserNotificationSettingService.js +9 -0
  219. package/build/dist/Server/Services/UserNotificationSettingService.js.map +1 -1
  220. package/build/dist/Server/Services/UserOnCallLogService.js +48 -12
  221. package/build/dist/Server/Services/UserOnCallLogService.js.map +1 -1
  222. package/build/dist/Server/Services/WhatsAppService.js +3 -0
  223. package/build/dist/Server/Services/WhatsAppService.js.map +1 -1
  224. package/build/dist/Server/Services/WorkspaceNotificationRuleService.js +25 -0
  225. package/build/dist/Server/Services/WorkspaceNotificationRuleService.js.map +1 -1
  226. package/build/dist/Server/Utils/AnalyticsDatabase/Statement.js +4 -2
  227. package/build/dist/Server/Utils/AnalyticsDatabase/Statement.js.map +1 -1
  228. package/build/dist/Server/Utils/PushNotificationUtil.js +51 -16
  229. package/build/dist/Server/Utils/PushNotificationUtil.js.map +1 -1
  230. package/build/dist/Server/Utils/WhatsAppTemplateUtil.js +8 -0
  231. package/build/dist/Server/Utils/WhatsAppTemplateUtil.js.map +1 -1
  232. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/ActionTypes.js +17 -0
  233. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/ActionTypes.js.map +1 -1
  234. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/AlertEpisode.js +545 -0
  235. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/AlertEpisode.js.map +1 -0
  236. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js +13 -0
  237. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js.map +1 -1
  238. package/build/dist/Server/Utils/Workspace/Slack/Actions/ActionTypes.js +10 -0
  239. package/build/dist/Server/Utils/Workspace/Slack/Actions/ActionTypes.js.map +1 -1
  240. package/build/dist/Server/Utils/Workspace/Slack/Actions/AlertEpisode.js +651 -0
  241. package/build/dist/Server/Utils/Workspace/Slack/Actions/AlertEpisode.js.map +1 -0
  242. package/build/dist/Server/Utils/Workspace/Slack/Messages/AlertEpisode.js +100 -0
  243. package/build/dist/Server/Utils/Workspace/Slack/Messages/AlertEpisode.js.map +1 -0
  244. package/build/dist/Server/Utils/Workspace/WorkspaceMessages/AlertEpisode.js +70 -0
  245. package/build/dist/Server/Utils/Workspace/WorkspaceMessages/AlertEpisode.js.map +1 -0
  246. package/build/dist/Tests/Server/Services/AlertEpisodeMemberService.test.js +165 -0
  247. package/build/dist/Tests/Server/Services/AlertEpisodeMemberService.test.js.map +1 -0
  248. package/build/dist/Tests/Server/Services/AlertEpisodeService.test.js +193 -0
  249. package/build/dist/Tests/Server/Services/AlertEpisodeService.test.js.map +1 -0
  250. package/build/dist/Tests/Server/Services/AlertGroupingEngineService.test.js +412 -0
  251. package/build/dist/Tests/Server/Services/AlertGroupingEngineService.test.js.map +1 -0
  252. package/build/dist/Tests/Server/Services/AlertGroupingRuleService.test.js +308 -0
  253. package/build/dist/Tests/Server/Services/AlertGroupingRuleService.test.js.map +1 -0
  254. package/build/dist/Tests/Server/Utils/AnalyticsDatabase/StatementGenerator.test.js +1 -1
  255. package/build/dist/Tests/Server/Utils/AnalyticsDatabase/StatementGenerator.test.js.map +1 -1
  256. package/build/dist/Tests/UI/Components/Input.test.js +1 -1
  257. package/build/dist/Tests/UI/Components/Input.test.js.map +1 -1
  258. package/build/dist/Tests/UI/Components/TextArea.test.js +2 -2
  259. package/build/dist/Tests/UI/Components/TextArea.test.js.map +1 -1
  260. package/build/dist/Types/BaseDatabase/SortOrder.js +5 -0
  261. package/build/dist/Types/BaseDatabase/SortOrder.js.map +1 -1
  262. package/build/dist/Types/Email/EmailTemplateType.js +5 -0
  263. package/build/dist/Types/Email/EmailTemplateType.js.map +1 -1
  264. package/build/dist/Types/NotificationRule/NotificationRuleType.js +3 -1
  265. package/build/dist/Types/NotificationRule/NotificationRuleType.js.map +1 -1
  266. package/build/dist/Types/NotificationSetting/NotificationSettingEventType.js +5 -0
  267. package/build/dist/Types/NotificationSetting/NotificationSettingEventType.js.map +1 -1
  268. package/build/dist/Types/Permission.js +264 -0
  269. package/build/dist/Types/Permission.js.map +1 -1
  270. package/build/dist/Types/UserNotification/UserNotificationEventType.js +1 -0
  271. package/build/dist/Types/UserNotification/UserNotificationEventType.js.map +1 -1
  272. package/build/dist/Types/WhatsApp/WhatsAppTemplates.js +15 -0
  273. package/build/dist/Types/WhatsApp/WhatsAppTemplates.js.map +1 -1
  274. package/build/dist/Types/Workspace/NotificationRules/EventType.js +1 -0
  275. package/build/dist/Types/Workspace/NotificationRules/EventType.js.map +1 -1
  276. package/build/dist/Types/Workspace/NotificationRules/NotificationRuleCondition.js +28 -3
  277. package/build/dist/Types/Workspace/NotificationRules/NotificationRuleCondition.js.map +1 -1
  278. package/build/dist/UI/Components/Accordion/Accordion.js +10 -3
  279. package/build/dist/UI/Components/Accordion/Accordion.js.map +1 -1
  280. package/build/dist/UI/Components/Alerts/Alert.js +1 -1
  281. package/build/dist/UI/Components/Alerts/Alert.js.map +1 -1
  282. package/build/dist/UI/Components/Button/Button.js +8 -2
  283. package/build/dist/UI/Components/Button/Button.js.map +1 -1
  284. package/build/dist/UI/Components/CardSelect/CardSelect.js +1 -1
  285. package/build/dist/UI/Components/CardSelect/CardSelect.js.map +1 -1
  286. package/build/dist/UI/Components/Checkbox/Checkbox.js +2 -2
  287. package/build/dist/UI/Components/Checkbox/Checkbox.js.map +1 -1
  288. package/build/dist/UI/Components/ColorCircle/ColorCircle.js +1 -1
  289. package/build/dist/UI/Components/ColorCircle/ColorCircle.js.map +1 -1
  290. package/build/dist/UI/Components/ColorViewer/ColorViewer.js +12 -3
  291. package/build/dist/UI/Components/ColorViewer/ColorViewer.js.map +1 -1
  292. package/build/dist/UI/Components/CopyableButton/CopyableButton.js +12 -5
  293. package/build/dist/UI/Components/CopyableButton/CopyableButton.js.map +1 -1
  294. package/build/dist/UI/Components/Detail/Detail.js +1 -1
  295. package/build/dist/UI/Components/Detail/Detail.js.map +1 -1
  296. package/build/dist/UI/Components/Dropdown/Dropdown.js +5 -3
  297. package/build/dist/UI/Components/Dropdown/Dropdown.js.map +1 -1
  298. package/build/dist/UI/Components/Forms/Fields/FormField.js +19 -1
  299. package/build/dist/UI/Components/Forms/Fields/FormField.js.map +1 -1
  300. package/build/dist/UI/Components/FullPageModal/FullPageModal.js +24 -5
  301. package/build/dist/UI/Components/FullPageModal/FullPageModal.js.map +1 -1
  302. package/build/dist/UI/Components/Input/Input.js +3 -3
  303. package/build/dist/UI/Components/Input/Input.js.map +1 -1
  304. package/build/dist/UI/Components/Link/Link.js +1 -1
  305. package/build/dist/UI/Components/Link/Link.js.map +1 -1
  306. package/build/dist/UI/Components/Loader/Loader.js +6 -4
  307. package/build/dist/UI/Components/Loader/Loader.js.map +1 -1
  308. package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js +56 -3
  309. package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js.map +1 -1
  310. package/build/dist/UI/Components/Modal/Modal.js +28 -3
  311. package/build/dist/UI/Components/Modal/Modal.js.map +1 -1
  312. package/build/dist/UI/Components/ModelTable/BaseModelTable.js +23 -1
  313. package/build/dist/UI/Components/ModelTable/BaseModelTable.js.map +1 -1
  314. package/build/dist/UI/Components/MoreMenu/MoreMenu.js +67 -6
  315. package/build/dist/UI/Components/MoreMenu/MoreMenu.js.map +1 -1
  316. package/build/dist/UI/Components/OrderedStatesList/OrderedStatesList.js +14 -3
  317. package/build/dist/UI/Components/OrderedStatesList/OrderedStatesList.js.map +1 -1
  318. package/build/dist/UI/Components/Pagination/Pagination.js +69 -13
  319. package/build/dist/UI/Components/Pagination/Pagination.js.map +1 -1
  320. package/build/dist/UI/Components/ProgressBar/ProgressBar.js +2 -2
  321. package/build/dist/UI/Components/ProgressBar/ProgressBar.js.map +1 -1
  322. package/build/dist/UI/Components/Radio/Radio.js +8 -5
  323. package/build/dist/UI/Components/Radio/Radio.js.map +1 -1
  324. package/build/dist/UI/Components/SideMenu/CountModelSideMenuItem.js +23 -4
  325. package/build/dist/UI/Components/SideMenu/CountModelSideMenuItem.js.map +1 -1
  326. package/build/dist/UI/Components/StatusBubble/StatusBubble.js +2 -2
  327. package/build/dist/UI/Components/StatusBubble/StatusBubble.js.map +1 -1
  328. package/build/dist/UI/Components/Table/TableHeader.js +12 -4
  329. package/build/dist/UI/Components/Table/TableHeader.js.map +1 -1
  330. package/build/dist/UI/Components/Tabs/Tab.js +8 -1
  331. package/build/dist/UI/Components/Tabs/Tab.js.map +1 -1
  332. package/build/dist/UI/Components/Tabs/Tabs.js +4 -3
  333. package/build/dist/UI/Components/Tabs/Tabs.js.map +1 -1
  334. package/build/dist/UI/Components/TextArea/TextArea.js +3 -3
  335. package/build/dist/UI/Components/TextArea/TextArea.js.map +1 -1
  336. package/build/dist/UI/Components/Toggle/Toggle.js +7 -4
  337. package/build/dist/UI/Components/Toggle/Toggle.js.map +1 -1
  338. package/build/dist/UI/Components/Tooltip/Tooltip.js +4 -1
  339. package/build/dist/UI/Components/Tooltip/Tooltip.js.map +1 -1
  340. package/build/dist/UI/Components/TopAlert/TopAlert.js +1 -1
  341. package/build/dist/UI/Components/TopAlert/TopAlert.js.map +1 -1
  342. package/package.json +2 -1
@@ -43,6 +43,9 @@ import UserOnCallLogTimeline from "../../Models/DatabaseModels/UserOnCallLogTime
43
43
  import Alert from "../../Models/DatabaseModels/Alert";
44
44
  import AlertService from "./AlertService";
45
45
  import AlertSeverityService from "./AlertSeverityService";
46
+ import AlertEpisode from "../../Models/DatabaseModels/AlertEpisode";
47
+ import AlertEpisodeService from "./AlertEpisodeService";
48
+ import AlertEpisodeMemberService from "./AlertEpisodeMemberService";
46
49
  import WorkspaceNotificationRuleService from "./WorkspaceNotificationRuleService";
47
50
  import PushNotificationService from "./PushNotificationService";
48
51
  import NotificationRuleEventType from "../../Types/Workspace/NotificationRules/EventType";
@@ -55,7 +58,7 @@ export class Service extends DatabaseService {
55
58
  }
56
59
  async executeNotificationRuleItem(userNotificationRuleId, options) {
57
60
  // get user notification log and see if this rule has already been executed. If so then skip.
58
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13;
61
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20;
59
62
  const userOnCallLog = await UserOnCallLogService.findOneById({
60
63
  id: options.userNotificationLogId,
61
64
  props: {
@@ -150,6 +153,10 @@ export class Service extends DatabaseService {
150
153
  if (options.triggeredByAlertId) {
151
154
  logTimelineItem.triggeredByAlertId = options.triggeredByAlertId;
152
155
  }
156
+ if (options.triggeredByAlertEpisodeId) {
157
+ logTimelineItem.triggeredByAlertEpisodeId =
158
+ options.triggeredByAlertEpisodeId;
159
+ }
153
160
  if (options.onCallDutyPolicyExecutionLogTimelineId) {
154
161
  logTimelineItem.onCallDutyPolicyExecutionLogTimelineId =
155
162
  options.onCallDutyPolicyExecutionLogTimelineId;
@@ -157,6 +164,7 @@ export class Service extends DatabaseService {
157
164
  // add status and status message and save.
158
165
  let incident = null;
159
166
  let alert = null;
167
+ let alertEpisode = null;
160
168
  if (options.userNotificationEventType ===
161
169
  UserNotificationEventType.IncidentCreated &&
162
170
  options.triggeredByIncidentId) {
@@ -210,8 +218,35 @@ export class Service extends DatabaseService {
210
218
  },
211
219
  });
212
220
  }
213
- if (!incident && !alert) {
214
- throw new BadDataException("Incident or Alert not found.");
221
+ if (options.userNotificationEventType ===
222
+ UserNotificationEventType.AlertEpisodeCreated &&
223
+ options.triggeredByAlertEpisodeId) {
224
+ alertEpisode = await AlertEpisodeService.findOneById({
225
+ id: options.triggeredByAlertEpisodeId,
226
+ props: {
227
+ isRoot: true,
228
+ },
229
+ select: {
230
+ _id: true,
231
+ title: true,
232
+ description: true,
233
+ projectId: true,
234
+ project: {
235
+ name: true,
236
+ },
237
+ currentAlertState: {
238
+ name: true,
239
+ },
240
+ alertSeverity: {
241
+ name: true,
242
+ },
243
+ episodeNumber: true,
244
+ rootCause: true,
245
+ },
246
+ });
247
+ }
248
+ if (!incident && !alert && !alertEpisode) {
249
+ throw new BadDataException("Incident, Alert, or Alert Episode not found.");
215
250
  }
216
251
  if (((_a = notificationRuleItem.userEmail) === null || _a === void 0 ? void 0 : _a.email) &&
217
252
  ((_b = notificationRuleItem.userEmail) === null || _b === void 0 ? void 0 : _b.isVerified)) {
@@ -293,13 +328,50 @@ export class Service extends DatabaseService {
293
328
  });
294
329
  });
295
330
  }
331
+ // send email for alert episode
332
+ if (options.userNotificationEventType ===
333
+ UserNotificationEventType.AlertEpisodeCreated &&
334
+ alertEpisode) {
335
+ logTimelineItem.status = UserNotificationStatus.Sending;
336
+ logTimelineItem.statusMessage = `Sending email to ${(_g = notificationRuleItem.userEmail) === null || _g === void 0 ? void 0 : _g.email.toString()}`;
337
+ logTimelineItem.userEmailId = notificationRuleItem.userEmail.id;
338
+ const updatedLog = await UserOnCallLogTimelineService.create({
339
+ data: logTimelineItem,
340
+ props: {
341
+ isRoot: true,
342
+ },
343
+ });
344
+ const emailMessage = await this.generateEmailTemplateForAlertEpisodeCreated((_h = notificationRuleItem.userEmail) === null || _h === void 0 ? void 0 : _h.email, alertEpisode, updatedLog.id);
345
+ MailService.sendMail(emailMessage, {
346
+ userOnCallLogTimelineId: updatedLog.id,
347
+ projectId: options.projectId,
348
+ alertEpisodeId: alertEpisode.id,
349
+ userId: notificationRuleItem.userId,
350
+ onCallPolicyId: options.onCallPolicyId,
351
+ onCallPolicyEscalationRuleId: options.onCallPolicyEscalationRuleId,
352
+ teamId: options.userBelongsToTeamId,
353
+ onCallDutyPolicyExecutionLogTimelineId: options.onCallDutyPolicyExecutionLogTimelineId,
354
+ onCallScheduleId: options.onCallScheduleId,
355
+ }).catch(async (err) => {
356
+ await UserOnCallLogTimelineService.updateOneById({
357
+ id: updatedLog.id,
358
+ data: {
359
+ status: UserNotificationStatus.Error,
360
+ statusMessage: err.message || "Error sending email.",
361
+ },
362
+ props: {
363
+ isRoot: true,
364
+ },
365
+ });
366
+ });
367
+ }
296
368
  }
297
369
  // if you have an email but is not verified, then create a log.
298
- if (((_g = notificationRuleItem.userEmail) === null || _g === void 0 ? void 0 : _g.email) &&
299
- !((_h = notificationRuleItem.userEmail) === null || _h === void 0 ? void 0 : _h.isVerified)) {
370
+ if (((_j = notificationRuleItem.userEmail) === null || _j === void 0 ? void 0 : _j.email) &&
371
+ !((_k = notificationRuleItem.userEmail) === null || _k === void 0 ? void 0 : _k.isVerified)) {
300
372
  // create an error log.
301
373
  logTimelineItem.status = UserNotificationStatus.Error;
302
- logTimelineItem.statusMessage = `Email notification not sent because email ${(_j = notificationRuleItem.userEmail) === null || _j === void 0 ? void 0 : _j.email.toString()} is not verified.`;
374
+ logTimelineItem.statusMessage = `Email notification not sent because email ${(_l = notificationRuleItem.userEmail) === null || _l === void 0 ? void 0 : _l.email.toString()} is not verified.`;
303
375
  await UserOnCallLogTimelineService.create({
304
376
  data: logTimelineItem,
305
377
  props: {
@@ -308,15 +380,15 @@ export class Service extends DatabaseService {
308
380
  });
309
381
  }
310
382
  // send sms.
311
- if (((_k = notificationRuleItem.userSms) === null || _k === void 0 ? void 0 : _k.phone) &&
312
- ((_l = notificationRuleItem.userSms) === null || _l === void 0 ? void 0 : _l.isVerified)) {
383
+ if (((_m = notificationRuleItem.userSms) === null || _m === void 0 ? void 0 : _m.phone) &&
384
+ ((_o = notificationRuleItem.userSms) === null || _o === void 0 ? void 0 : _o.isVerified)) {
313
385
  //send sms for alert
314
386
  if (options.userNotificationEventType ===
315
387
  UserNotificationEventType.AlertCreated &&
316
388
  alert) {
317
389
  // create an error log.
318
390
  logTimelineItem.status = UserNotificationStatus.Sending;
319
- logTimelineItem.statusMessage = `Sending SMS to ${(_m = notificationRuleItem.userSms) === null || _m === void 0 ? void 0 : _m.phone.toString()}.`;
391
+ logTimelineItem.statusMessage = `Sending SMS to ${(_p = notificationRuleItem.userSms) === null || _p === void 0 ? void 0 : _p.phone.toString()}.`;
320
392
  logTimelineItem.userSmsId = notificationRuleItem.userSms.id;
321
393
  const updatedLog = await UserOnCallLogTimelineService.create({
322
394
  data: logTimelineItem,
@@ -355,7 +427,7 @@ export class Service extends DatabaseService {
355
427
  incident) {
356
428
  // create an error log.
357
429
  logTimelineItem.status = UserNotificationStatus.Sending;
358
- logTimelineItem.statusMessage = `Sending SMS to ${(_o = notificationRuleItem.userSms) === null || _o === void 0 ? void 0 : _o.phone.toString()}.`;
430
+ logTimelineItem.statusMessage = `Sending SMS to ${(_q = notificationRuleItem.userSms) === null || _q === void 0 ? void 0 : _q.phone.toString()}.`;
359
431
  logTimelineItem.userSmsId = notificationRuleItem.userSms.id;
360
432
  const updatedLog = await UserOnCallLogTimelineService.create({
361
433
  data: logTimelineItem,
@@ -388,12 +460,49 @@ export class Service extends DatabaseService {
388
460
  });
389
461
  });
390
462
  }
463
+ // send sms for alert episode
464
+ if (options.userNotificationEventType ===
465
+ UserNotificationEventType.AlertEpisodeCreated &&
466
+ alertEpisode) {
467
+ logTimelineItem.status = UserNotificationStatus.Sending;
468
+ logTimelineItem.statusMessage = `Sending SMS to ${(_r = notificationRuleItem.userSms) === null || _r === void 0 ? void 0 : _r.phone.toString()}.`;
469
+ logTimelineItem.userSmsId = notificationRuleItem.userSms.id;
470
+ const updatedLog = await UserOnCallLogTimelineService.create({
471
+ data: logTimelineItem,
472
+ props: {
473
+ isRoot: true,
474
+ },
475
+ });
476
+ const smsMessage = await this.generateSmsTemplateForAlertEpisodeCreated(notificationRuleItem.userSms.phone, alertEpisode, updatedLog.id);
477
+ SmsService.sendSms(smsMessage, {
478
+ projectId: alertEpisode.projectId,
479
+ userOnCallLogTimelineId: updatedLog.id,
480
+ alertEpisodeId: alertEpisode.id,
481
+ userId: notificationRuleItem.userId,
482
+ onCallPolicyId: options.onCallPolicyId,
483
+ onCallPolicyEscalationRuleId: options.onCallPolicyEscalationRuleId,
484
+ teamId: options.userBelongsToTeamId,
485
+ onCallDutyPolicyExecutionLogTimelineId: options.onCallDutyPolicyExecutionLogTimelineId,
486
+ onCallScheduleId: options.onCallScheduleId,
487
+ }).catch(async (err) => {
488
+ await UserOnCallLogTimelineService.updateOneById({
489
+ id: updatedLog.id,
490
+ data: {
491
+ status: UserNotificationStatus.Error,
492
+ statusMessage: err.message || "Error sending SMS.",
493
+ },
494
+ props: {
495
+ isRoot: true,
496
+ },
497
+ });
498
+ });
499
+ }
391
500
  }
392
- if (((_p = notificationRuleItem.userSms) === null || _p === void 0 ? void 0 : _p.phone) &&
393
- !((_q = notificationRuleItem.userSms) === null || _q === void 0 ? void 0 : _q.isVerified)) {
501
+ if (((_s = notificationRuleItem.userSms) === null || _s === void 0 ? void 0 : _s.phone) &&
502
+ !((_t = notificationRuleItem.userSms) === null || _t === void 0 ? void 0 : _t.isVerified)) {
394
503
  // create a log.
395
504
  logTimelineItem.status = UserNotificationStatus.Error;
396
- logTimelineItem.statusMessage = `SMS not sent because phone ${(_r = notificationRuleItem.userSms) === null || _r === void 0 ? void 0 : _r.phone.toString()} is not verified.`;
505
+ logTimelineItem.statusMessage = `SMS not sent because phone ${(_u = notificationRuleItem.userSms) === null || _u === void 0 ? void 0 : _u.phone.toString()} is not verified.`;
397
506
  await UserOnCallLogTimelineService.create({
398
507
  data: logTimelineItem,
399
508
  props: {
@@ -401,13 +510,13 @@ export class Service extends DatabaseService {
401
510
  },
402
511
  });
403
512
  }
404
- if (((_s = notificationRuleItem.userWhatsApp) === null || _s === void 0 ? void 0 : _s.phone) &&
405
- ((_t = notificationRuleItem.userWhatsApp) === null || _t === void 0 ? void 0 : _t.isVerified)) {
513
+ if (((_v = notificationRuleItem.userWhatsApp) === null || _v === void 0 ? void 0 : _v.phone) &&
514
+ ((_w = notificationRuleItem.userWhatsApp) === null || _w === void 0 ? void 0 : _w.isVerified)) {
406
515
  if (options.userNotificationEventType ===
407
516
  UserNotificationEventType.AlertCreated &&
408
517
  alert) {
409
518
  logTimelineItem.status = UserNotificationStatus.Sending;
410
- logTimelineItem.statusMessage = `Sending WhatsApp message to ${(_u = notificationRuleItem.userWhatsApp) === null || _u === void 0 ? void 0 : _u.phone.toString()}.`;
519
+ logTimelineItem.statusMessage = `Sending WhatsApp message to ${(_x = notificationRuleItem.userWhatsApp) === null || _x === void 0 ? void 0 : _x.phone.toString()}.`;
411
520
  logTimelineItem.userWhatsAppId = notificationRuleItem.userWhatsApp.id;
412
521
  const updatedLog = await UserOnCallLogTimelineService.create({
413
522
  data: logTimelineItem,
@@ -443,7 +552,7 @@ export class Service extends DatabaseService {
443
552
  UserNotificationEventType.IncidentCreated &&
444
553
  incident) {
445
554
  logTimelineItem.status = UserNotificationStatus.Sending;
446
- logTimelineItem.statusMessage = `Sending WhatsApp message to ${(_v = notificationRuleItem.userWhatsApp) === null || _v === void 0 ? void 0 : _v.phone.toString()}.`;
555
+ logTimelineItem.statusMessage = `Sending WhatsApp message to ${(_y = notificationRuleItem.userWhatsApp) === null || _y === void 0 ? void 0 : _y.phone.toString()}.`;
447
556
  logTimelineItem.userWhatsAppId = notificationRuleItem.userWhatsApp.id;
448
557
  const updatedLog = await UserOnCallLogTimelineService.create({
449
558
  data: logTimelineItem,
@@ -475,11 +584,48 @@ export class Service extends DatabaseService {
475
584
  });
476
585
  });
477
586
  }
587
+ // send WhatsApp for alert episode
588
+ if (options.userNotificationEventType ===
589
+ UserNotificationEventType.AlertEpisodeCreated &&
590
+ alertEpisode) {
591
+ logTimelineItem.status = UserNotificationStatus.Sending;
592
+ logTimelineItem.statusMessage = `Sending WhatsApp message to ${(_z = notificationRuleItem.userWhatsApp) === null || _z === void 0 ? void 0 : _z.phone.toString()}.`;
593
+ logTimelineItem.userWhatsAppId = notificationRuleItem.userWhatsApp.id;
594
+ const updatedLog = await UserOnCallLogTimelineService.create({
595
+ data: logTimelineItem,
596
+ props: {
597
+ isRoot: true,
598
+ },
599
+ });
600
+ const whatsAppMessage = await this.generateWhatsAppTemplateForAlertEpisodeCreated(notificationRuleItem.userWhatsApp.phone, alertEpisode, updatedLog.id);
601
+ WhatsAppService.sendWhatsAppMessage(whatsAppMessage, {
602
+ projectId: alertEpisode.projectId,
603
+ alertEpisodeId: alertEpisode.id,
604
+ userOnCallLogTimelineId: updatedLog.id,
605
+ userId: notificationRuleItem.userId,
606
+ onCallPolicyId: options.onCallPolicyId,
607
+ onCallPolicyEscalationRuleId: options.onCallPolicyEscalationRuleId,
608
+ teamId: options.userBelongsToTeamId,
609
+ onCallDutyPolicyExecutionLogTimelineId: options.onCallDutyPolicyExecutionLogTimelineId,
610
+ onCallScheduleId: options.onCallScheduleId,
611
+ }).catch(async (err) => {
612
+ await UserOnCallLogTimelineService.updateOneById({
613
+ id: updatedLog.id,
614
+ data: {
615
+ status: UserNotificationStatus.Error,
616
+ statusMessage: err.message || "Error sending WhatsApp message.",
617
+ },
618
+ props: {
619
+ isRoot: true,
620
+ },
621
+ });
622
+ });
623
+ }
478
624
  }
479
- if (((_w = notificationRuleItem.userWhatsApp) === null || _w === void 0 ? void 0 : _w.phone) &&
480
- !((_x = notificationRuleItem.userWhatsApp) === null || _x === void 0 ? void 0 : _x.isVerified)) {
625
+ if (((_0 = notificationRuleItem.userWhatsApp) === null || _0 === void 0 ? void 0 : _0.phone) &&
626
+ !((_1 = notificationRuleItem.userWhatsApp) === null || _1 === void 0 ? void 0 : _1.isVerified)) {
481
627
  logTimelineItem.status = UserNotificationStatus.Error;
482
- logTimelineItem.statusMessage = `WhatsApp message not sent because phone ${(_y = notificationRuleItem.userWhatsApp) === null || _y === void 0 ? void 0 : _y.phone.toString()} is not verified.`;
628
+ logTimelineItem.statusMessage = `WhatsApp message not sent because phone ${(_2 = notificationRuleItem.userWhatsApp) === null || _2 === void 0 ? void 0 : _2.phone.toString()} is not verified.`;
483
629
  logTimelineItem.userWhatsAppId = notificationRuleItem.userWhatsApp.id;
484
630
  await UserOnCallLogTimelineService.create({
485
631
  data: logTimelineItem,
@@ -489,15 +635,15 @@ export class Service extends DatabaseService {
489
635
  });
490
636
  }
491
637
  // send call.
492
- if (((_z = notificationRuleItem.userCall) === null || _z === void 0 ? void 0 : _z.phone) &&
493
- ((_0 = notificationRuleItem.userCall) === null || _0 === void 0 ? void 0 : _0.isVerified)) {
638
+ if (((_3 = notificationRuleItem.userCall) === null || _3 === void 0 ? void 0 : _3.phone) &&
639
+ ((_4 = notificationRuleItem.userCall) === null || _4 === void 0 ? void 0 : _4.isVerified)) {
494
640
  // send call for alert
495
641
  if (options.userNotificationEventType ===
496
642
  UserNotificationEventType.AlertCreated &&
497
643
  alert) {
498
644
  // create an error log.
499
645
  logTimelineItem.status = UserNotificationStatus.Sending;
500
- logTimelineItem.statusMessage = `Making a call to ${(_1 = notificationRuleItem.userCall) === null || _1 === void 0 ? void 0 : _1.phone.toString()}.`;
646
+ logTimelineItem.statusMessage = `Making a call to ${(_5 = notificationRuleItem.userCall) === null || _5 === void 0 ? void 0 : _5.phone.toString()}.`;
501
647
  logTimelineItem.userCallId = notificationRuleItem.userCall.id;
502
648
  const updatedLog = await UserOnCallLogTimelineService.create({
503
649
  data: logTimelineItem,
@@ -505,7 +651,7 @@ export class Service extends DatabaseService {
505
651
  isRoot: true,
506
652
  },
507
653
  });
508
- const callRequest = await this.generateCallTemplateForAlertCreated((_2 = notificationRuleItem.userCall) === null || _2 === void 0 ? void 0 : _2.phone, alert, updatedLog.id);
654
+ const callRequest = await this.generateCallTemplateForAlertCreated((_6 = notificationRuleItem.userCall) === null || _6 === void 0 ? void 0 : _6.phone, alert, updatedLog.id);
509
655
  // send call.
510
656
  CallService.makeCall(callRequest, {
511
657
  projectId: alert.projectId,
@@ -535,7 +681,7 @@ export class Service extends DatabaseService {
535
681
  incident) {
536
682
  // send call for incident
537
683
  logTimelineItem.status = UserNotificationStatus.Sending;
538
- logTimelineItem.statusMessage = `Making a call to ${(_3 = notificationRuleItem.userCall) === null || _3 === void 0 ? void 0 : _3.phone.toString()}.`;
684
+ logTimelineItem.statusMessage = `Making a call to ${(_7 = notificationRuleItem.userCall) === null || _7 === void 0 ? void 0 : _7.phone.toString()}.`;
539
685
  logTimelineItem.userCallId = notificationRuleItem.userCall.id;
540
686
  const updatedLog = await UserOnCallLogTimelineService.create({
541
687
  data: logTimelineItem,
@@ -543,7 +689,7 @@ export class Service extends DatabaseService {
543
689
  isRoot: true,
544
690
  },
545
691
  });
546
- const callRequest = await this.generateCallTemplateForIncidentCreated((_4 = notificationRuleItem.userCall) === null || _4 === void 0 ? void 0 : _4.phone, incident, updatedLog.id);
692
+ const callRequest = await this.generateCallTemplateForIncidentCreated((_8 = notificationRuleItem.userCall) === null || _8 === void 0 ? void 0 : _8.phone, incident, updatedLog.id);
547
693
  // send call.
548
694
  CallService.makeCall(callRequest, {
549
695
  projectId: incident.projectId,
@@ -568,12 +714,49 @@ export class Service extends DatabaseService {
568
714
  });
569
715
  });
570
716
  }
717
+ // send call for alert episode
718
+ if (options.userNotificationEventType ===
719
+ UserNotificationEventType.AlertEpisodeCreated &&
720
+ alertEpisode) {
721
+ logTimelineItem.status = UserNotificationStatus.Sending;
722
+ logTimelineItem.statusMessage = `Making a call to ${(_9 = notificationRuleItem.userCall) === null || _9 === void 0 ? void 0 : _9.phone.toString()}.`;
723
+ logTimelineItem.userCallId = notificationRuleItem.userCall.id;
724
+ const updatedLog = await UserOnCallLogTimelineService.create({
725
+ data: logTimelineItem,
726
+ props: {
727
+ isRoot: true,
728
+ },
729
+ });
730
+ const callRequest = await this.generateCallTemplateForAlertEpisodeCreated((_10 = notificationRuleItem.userCall) === null || _10 === void 0 ? void 0 : _10.phone, alertEpisode, updatedLog.id);
731
+ CallService.makeCall(callRequest, {
732
+ projectId: alertEpisode.projectId,
733
+ userOnCallLogTimelineId: updatedLog.id,
734
+ alertEpisodeId: alertEpisode.id,
735
+ userId: notificationRuleItem.userId,
736
+ onCallPolicyId: options.onCallPolicyId,
737
+ onCallPolicyEscalationRuleId: options.onCallPolicyEscalationRuleId,
738
+ teamId: options.userBelongsToTeamId,
739
+ onCallDutyPolicyExecutionLogTimelineId: options.onCallDutyPolicyExecutionLogTimelineId,
740
+ onCallScheduleId: options.onCallScheduleId,
741
+ }).catch(async (err) => {
742
+ await UserOnCallLogTimelineService.updateOneById({
743
+ id: updatedLog.id,
744
+ data: {
745
+ status: UserNotificationStatus.Error,
746
+ statusMessage: err.message || "Error making call.",
747
+ },
748
+ props: {
749
+ isRoot: true,
750
+ },
751
+ });
752
+ });
753
+ }
571
754
  }
572
- if (((_5 = notificationRuleItem.userCall) === null || _5 === void 0 ? void 0 : _5.phone) &&
573
- !((_6 = notificationRuleItem.userCall) === null || _6 === void 0 ? void 0 : _6.isVerified)) {
755
+ if (((_11 = notificationRuleItem.userCall) === null || _11 === void 0 ? void 0 : _11.phone) &&
756
+ !((_12 = notificationRuleItem.userCall) === null || _12 === void 0 ? void 0 : _12.isVerified)) {
574
757
  // create a log.
575
758
  logTimelineItem.status = UserNotificationStatus.Error;
576
- logTimelineItem.statusMessage = `Call not sent because phone ${(_7 = notificationRuleItem.userCall) === null || _7 === void 0 ? void 0 : _7.phone.toString()} is not verified.`;
759
+ logTimelineItem.statusMessage = `Call not sent because phone ${(_13 = notificationRuleItem.userCall) === null || _13 === void 0 ? void 0 : _13.phone.toString()} is not verified.`;
577
760
  await UserOnCallLogTimelineService.create({
578
761
  data: logTimelineItem,
579
762
  props: {
@@ -582,8 +765,8 @@ export class Service extends DatabaseService {
582
765
  });
583
766
  }
584
767
  // send push notification.
585
- if (((_8 = notificationRuleItem.userPush) === null || _8 === void 0 ? void 0 : _8.deviceToken) &&
586
- ((_9 = notificationRuleItem.userPush) === null || _9 === void 0 ? void 0 : _9.isVerified)) {
768
+ if (((_14 = notificationRuleItem.userPush) === null || _14 === void 0 ? void 0 : _14.deviceToken) &&
769
+ ((_15 = notificationRuleItem.userPush) === null || _15 === void 0 ? void 0 : _15.isVerified)) {
587
770
  // send push notification for alert
588
771
  if (options.userNotificationEventType ===
589
772
  UserNotificationEventType.AlertCreated &&
@@ -600,8 +783,9 @@ export class Service extends DatabaseService {
600
783
  });
601
784
  const pushMessage = PushNotificationUtil.createAlertCreatedNotification({
602
785
  alertTitle: alert.title,
603
- projectName: ((_10 = alert.project) === null || _10 === void 0 ? void 0 : _10.name) || "OneUptime",
786
+ projectName: ((_16 = alert.project) === null || _16 === void 0 ? void 0 : _16.name) || "OneUptime",
604
787
  alertViewLink: (await AlertService.getAlertLinkInDashboard(alert.projectId, alert.id)).toString(),
788
+ alertNumber: alert.alertNumber,
605
789
  });
606
790
  // send push notification.
607
791
  PushNotificationService.sendPushNotification({
@@ -651,8 +835,9 @@ export class Service extends DatabaseService {
651
835
  });
652
836
  const pushMessage = PushNotificationUtil.createIncidentCreatedNotification({
653
837
  incidentTitle: incident.title,
654
- projectName: ((_11 = incident.project) === null || _11 === void 0 ? void 0 : _11.name) || "OneUptime",
838
+ projectName: ((_17 = incident.project) === null || _17 === void 0 ? void 0 : _17.name) || "OneUptime",
655
839
  incidentViewLink: (await IncidentService.getIncidentLinkInDashboard(incident.projectId, incident.id)).toString(),
840
+ incidentNumber: incident.incidentNumber,
656
841
  });
657
842
  // send push notification.
658
843
  PushNotificationService.sendPushNotification({
@@ -686,9 +871,59 @@ export class Service extends DatabaseService {
686
871
  });
687
872
  });
688
873
  }
874
+ // send push notification for alert episode
875
+ if (options.userNotificationEventType ===
876
+ UserNotificationEventType.AlertEpisodeCreated &&
877
+ alertEpisode) {
878
+ logTimelineItem.status = UserNotificationStatus.Sending;
879
+ logTimelineItem.statusMessage = `Sending push notification to device.`;
880
+ logTimelineItem.userPushId = notificationRuleItem.userPush.id;
881
+ const updatedLog = await UserOnCallLogTimelineService.create({
882
+ data: logTimelineItem,
883
+ props: {
884
+ isRoot: true,
885
+ },
886
+ });
887
+ const pushMessage = PushNotificationUtil.createAlertEpisodeCreatedNotification({
888
+ alertEpisodeTitle: alertEpisode.title,
889
+ projectName: ((_18 = alertEpisode.project) === null || _18 === void 0 ? void 0 : _18.name) || "OneUptime",
890
+ alertEpisodeViewLink: (await AlertEpisodeService.getEpisodeLinkInDashboard(alertEpisode.projectId, alertEpisode.id)).toString(),
891
+ episodeNumber: alertEpisode.episodeNumber,
892
+ });
893
+ PushNotificationService.sendPushNotification({
894
+ devices: [
895
+ Object.assign({ token: notificationRuleItem.userPush.deviceToken }, (notificationRuleItem.userPush.deviceName && {
896
+ name: notificationRuleItem.userPush.deviceName,
897
+ })),
898
+ ],
899
+ message: pushMessage,
900
+ deviceType: notificationRuleItem.userPush.deviceType,
901
+ }, {
902
+ projectId: options.projectId,
903
+ userOnCallLogTimelineId: updatedLog.id,
904
+ alertEpisodeId: alertEpisode.id,
905
+ userId: notificationRuleItem.userId,
906
+ onCallPolicyId: options.onCallPolicyId,
907
+ onCallPolicyEscalationRuleId: options.onCallPolicyEscalationRuleId,
908
+ teamId: options.userBelongsToTeamId,
909
+ onCallDutyPolicyExecutionLogTimelineId: options.onCallDutyPolicyExecutionLogTimelineId,
910
+ onCallScheduleId: options.onCallScheduleId,
911
+ }).catch(async (err) => {
912
+ await UserOnCallLogTimelineService.updateOneById({
913
+ id: updatedLog.id,
914
+ data: {
915
+ status: UserNotificationStatus.Error,
916
+ statusMessage: err.message || "Error sending push notification.",
917
+ },
918
+ props: {
919
+ isRoot: true,
920
+ },
921
+ });
922
+ });
923
+ }
689
924
  }
690
- if (((_12 = notificationRuleItem.userPush) === null || _12 === void 0 ? void 0 : _12.deviceToken) &&
691
- !((_13 = notificationRuleItem.userPush) === null || _13 === void 0 ? void 0 : _13.isVerified)) {
925
+ if (((_19 = notificationRuleItem.userPush) === null || _19 === void 0 ? void 0 : _19.deviceToken) &&
926
+ !((_20 = notificationRuleItem.userPush) === null || _20 === void 0 ? void 0 : _20.isVerified)) {
692
927
  // create a log.
693
928
  logTimelineItem.status = UserNotificationStatus.Error;
694
929
  logTimelineItem.statusMessage = `Push notification not sent because device is not verified.`;
@@ -703,6 +938,9 @@ export class Service extends DatabaseService {
703
938
  async generateCallTemplateForAlertCreated(to, alert, userOnCallLogTimelineId) {
704
939
  const host = await DatabaseConfig.getHost();
705
940
  const httpProtocol = await DatabaseConfig.getHttpProtocol();
941
+ const alertIdentifier = alert.alertNumber !== undefined
942
+ ? `Alert number ${alert.alertNumber}, ${alert.title || "Alert"}`
943
+ : alert.title || "Alert";
706
944
  const callRequest = {
707
945
  to: to,
708
946
  data: [
@@ -713,7 +951,7 @@ export class Service extends DatabaseService {
713
951
  sayMessage: "A new alert has been created",
714
952
  },
715
953
  {
716
- sayMessage: alert.title,
954
+ sayMessage: alertIdentifier,
717
955
  },
718
956
  {
719
957
  introMessage: "To acknowledge this alert press 1",
@@ -739,6 +977,9 @@ export class Service extends DatabaseService {
739
977
  async generateCallTemplateForIncidentCreated(to, incident, userOnCallLogTimelineId) {
740
978
  const host = await DatabaseConfig.getHost();
741
979
  const httpProtocol = await DatabaseConfig.getHttpProtocol();
980
+ const incidentIdentifier = incident.incidentNumber !== undefined
981
+ ? `Incident number ${incident.incidentNumber}, ${incident.title || "Incident"}`
982
+ : incident.title || "Incident";
742
983
  const callRequest = {
743
984
  to: to,
744
985
  data: [
@@ -749,7 +990,7 @@ export class Service extends DatabaseService {
749
990
  sayMessage: "A new incident has been created",
750
991
  },
751
992
  {
752
- sayMessage: incident.title,
993
+ sayMessage: incidentIdentifier,
753
994
  },
754
995
  {
755
996
  introMessage: "To acknowledge this incident press 1",
@@ -772,6 +1013,45 @@ export class Service extends DatabaseService {
772
1013
  };
773
1014
  return callRequest;
774
1015
  }
1016
+ async generateCallTemplateForAlertEpisodeCreated(to, alertEpisode, userOnCallLogTimelineId) {
1017
+ const host = await DatabaseConfig.getHost();
1018
+ const httpProtocol = await DatabaseConfig.getHttpProtocol();
1019
+ const episodeIdentifier = alertEpisode.episodeNumber !== undefined
1020
+ ? `Alert episode number ${alertEpisode.episodeNumber}, ${alertEpisode.title || "Alert Episode"}`
1021
+ : alertEpisode.title || "Alert Episode";
1022
+ const callRequest = {
1023
+ to: to,
1024
+ data: [
1025
+ {
1026
+ sayMessage: "This is a call from OneUptime",
1027
+ },
1028
+ {
1029
+ sayMessage: "A new alert episode has been created",
1030
+ },
1031
+ {
1032
+ sayMessage: episodeIdentifier,
1033
+ },
1034
+ {
1035
+ introMessage: "To acknowledge this alert episode press 1",
1036
+ numDigits: 1,
1037
+ timeoutInSeconds: 10,
1038
+ noInputMessage: "You have not entered any input. Good bye",
1039
+ onInputCallRequest: {
1040
+ "1": {
1041
+ sayMessage: "You have acknowledged this alert episode. Good bye",
1042
+ },
1043
+ default: {
1044
+ sayMessage: "Invalid input. Good bye",
1045
+ },
1046
+ },
1047
+ responseUrl: new URL(httpProtocol, host, new Route(AppApiRoute.toString())
1048
+ .addRoute(new UserOnCallLogTimeline().crudApiPath)
1049
+ .addRoute("/call/gather-input/" + userOnCallLogTimelineId.toString())),
1050
+ },
1051
+ ],
1052
+ };
1053
+ return callRequest;
1054
+ }
775
1055
  async generateSmsTemplateForAlertCreated(to, alert, userOnCallLogTimelineId) {
776
1056
  const host = await DatabaseConfig.getHost();
777
1057
  const httpProtocol = await DatabaseConfig.getHttpProtocol();
@@ -804,6 +1084,22 @@ export class Service extends DatabaseService {
804
1084
  };
805
1085
  return sms;
806
1086
  }
1087
+ async generateSmsTemplateForAlertEpisodeCreated(to, alertEpisode, userOnCallLogTimelineId) {
1088
+ const host = await DatabaseConfig.getHost();
1089
+ const httpProtocol = await DatabaseConfig.getHttpProtocol();
1090
+ const shortUrl = await ShortLinkService.saveShortLinkFor(new URL(httpProtocol, host, new Route(AppApiRoute.toString())
1091
+ .addRoute(new UserOnCallLogTimeline().crudApiPath)
1092
+ .addRoute("/acknowledge-page/" + userOnCallLogTimelineId.toString())));
1093
+ const url = await ShortLinkService.getShortenedUrl(shortUrl);
1094
+ const episodeIdentifier = alertEpisode.episodeNumber !== undefined
1095
+ ? `#${alertEpisode.episodeNumber} (${alertEpisode.title || "Alert Episode"})`
1096
+ : alertEpisode.title || "Alert Episode";
1097
+ const sms = {
1098
+ to,
1099
+ message: `This is a message from OneUptime. A new alert episode has been created: ${episodeIdentifier}. To acknowledge this alert episode, please click on the following link ${url.toString()}`,
1100
+ };
1101
+ return sms;
1102
+ }
807
1103
  async generateWhatsAppTemplateForAlertCreated(to, alert, userOnCallLogTimelineId) {
808
1104
  var _a;
809
1105
  const host = await DatabaseConfig.getHost();
@@ -862,11 +1158,45 @@ export class Service extends DatabaseService {
862
1158
  templateLanguageCode: WhatsAppTemplateLanguage[templateKey],
863
1159
  };
864
1160
  }
1161
+ async generateWhatsAppTemplateForAlertEpisodeCreated(to, alertEpisode, userOnCallLogTimelineId) {
1162
+ var _a;
1163
+ const host = await DatabaseConfig.getHost();
1164
+ const httpProtocol = await DatabaseConfig.getHttpProtocol();
1165
+ const acknowledgeShortLink = await ShortLinkService.saveShortLinkFor(new URL(httpProtocol, host, new Route(AppApiRoute.toString())
1166
+ .addRoute(new UserOnCallLogTimeline().crudApiPath)
1167
+ .addRoute("/acknowledge-page/" + userOnCallLogTimelineId.toString())));
1168
+ const acknowledgeUrl = await ShortLinkService.getShortenedUrl(acknowledgeShortLink);
1169
+ const episodeLinkOnDashboard = alertEpisode.projectId && alertEpisode.id
1170
+ ? (await AlertEpisodeService.getEpisodeLinkInDashboard(alertEpisode.projectId, alertEpisode.id)).toString()
1171
+ : acknowledgeUrl.toString();
1172
+ const templateKey = WhatsAppTemplateIds.AlertEpisodeCreated;
1173
+ const templateVariables = {
1174
+ project_name: ((_a = alertEpisode.project) === null || _a === void 0 ? void 0 : _a.name) || "OneUptime",
1175
+ episode_title: alertEpisode.title || "",
1176
+ acknowledge_url: acknowledgeUrl.toString(),
1177
+ episode_number: alertEpisode.episodeNumber !== undefined
1178
+ ? alertEpisode.episodeNumber.toString()
1179
+ : "",
1180
+ episode_link: episodeLinkOnDashboard,
1181
+ };
1182
+ const body = renderWhatsAppTemplate(templateKey, templateVariables);
1183
+ return {
1184
+ to,
1185
+ body,
1186
+ templateKey,
1187
+ templateVariables,
1188
+ templateLanguageCode: WhatsAppTemplateLanguage[templateKey],
1189
+ };
1190
+ }
865
1191
  async generateEmailTemplateForAlertCreated(to, alert, userOnCallLogTimelineId) {
866
1192
  const host = await DatabaseConfig.getHost();
867
1193
  const httpProtocol = await DatabaseConfig.getHttpProtocol();
1194
+ const alertNumber = alert.alertNumber
1195
+ ? `#${alert.alertNumber}`
1196
+ : "";
868
1197
  const vars = {
869
1198
  alertTitle: alert.title,
1199
+ alertNumber: alertNumber,
870
1200
  projectName: alert.project.name,
871
1201
  currentState: alert.currentAlertState.name,
872
1202
  alertDescription: await Markdown.convertToHTML(alert.description || "", MarkdownContentType.Email),
@@ -880,15 +1210,19 @@ export class Service extends DatabaseService {
880
1210
  toEmail: to,
881
1211
  templateType: EmailTemplateType.AcknowledgeAlert,
882
1212
  vars: vars,
883
- subject: "ACTION REQUIRED: Alert created - " + alert.title,
1213
+ subject: `ACTION REQUIRED: Alert ${alertNumber} created - ${alert.title}`,
884
1214
  };
885
1215
  return emailMessage;
886
1216
  }
887
1217
  async generateEmailTemplateForIncidentCreated(to, incident, userOnCallLogTimelineId) {
888
1218
  const host = await DatabaseConfig.getHost();
889
1219
  const httpProtocol = await DatabaseConfig.getHttpProtocol();
1220
+ const incidentNumber = incident.incidentNumber
1221
+ ? `#${incident.incidentNumber}`
1222
+ : "";
890
1223
  const vars = {
891
1224
  incidentTitle: incident.title,
1225
+ incidentNumber: incidentNumber,
892
1226
  projectName: incident.project.name,
893
1227
  currentState: incident.currentIncidentState.name,
894
1228
  incidentDescription: await Markdown.convertToHTML(incident.description || "", MarkdownContentType.Email),
@@ -903,7 +1237,114 @@ export class Service extends DatabaseService {
903
1237
  toEmail: to,
904
1238
  templateType: EmailTemplateType.AcknowledgeIncident,
905
1239
  vars: vars,
906
- subject: "ACTION REQUIRED: Incident created - " + incident.title,
1240
+ subject: `ACTION REQUIRED: Incident ${incidentNumber} created - ${incident.title}`,
1241
+ };
1242
+ return emailMessage;
1243
+ }
1244
+ async generateEmailTemplateForAlertEpisodeCreated(to, alertEpisode, userOnCallLogTimelineId) {
1245
+ var _a, _b, _c;
1246
+ const host = await DatabaseConfig.getHost();
1247
+ const httpProtocol = await DatabaseConfig.getHttpProtocol();
1248
+ // Fetch alerts that are members of this episode
1249
+ const episodeMembers = await AlertEpisodeMemberService.findBy({
1250
+ query: {
1251
+ alertEpisodeId: alertEpisode.id,
1252
+ },
1253
+ select: {
1254
+ alertId: true,
1255
+ alert: {
1256
+ _id: true,
1257
+ title: true,
1258
+ alertNumber: true,
1259
+ monitor: {
1260
+ _id: true,
1261
+ name: true,
1262
+ },
1263
+ },
1264
+ },
1265
+ props: {
1266
+ isRoot: true,
1267
+ },
1268
+ limit: LIMIT_PER_PROJECT,
1269
+ skip: 0,
1270
+ });
1271
+ // Get unique monitors (resources affected)
1272
+ const monitorNames = new Set();
1273
+ for (const member of episodeMembers) {
1274
+ if ((_b = (_a = member.alert) === null || _a === void 0 ? void 0 : _a.monitor) === null || _b === void 0 ? void 0 : _b.name) {
1275
+ monitorNames.add(member.alert.monitor.name);
1276
+ }
1277
+ }
1278
+ const resourcesAffected = monitorNames.size > 0
1279
+ ? Array.from(monitorNames).join(", ")
1280
+ : "No resources identified";
1281
+ // Build alerts list HTML with proper email styling
1282
+ let alertsListHtml = "";
1283
+ if (episodeMembers.length > 0) {
1284
+ const alertRows = [];
1285
+ for (const member of episodeMembers) {
1286
+ if (member.alert) {
1287
+ const alertTitle = member.alert.title || "Untitled Alert";
1288
+ const alertNumber = member.alert.alertNumber
1289
+ ? `#${member.alert.alertNumber}`
1290
+ : "";
1291
+ const alertLink = (await AlertService.getAlertLinkInDashboard(alertEpisode.projectId, new ObjectID(member.alert._id))).toString();
1292
+ const monitorName = ((_c = member.alert.monitor) === null || _c === void 0 ? void 0 : _c.name) || "";
1293
+ alertRows.push(`
1294
+ <tr>
1295
+ <td style="padding: 12px 16px; border-bottom: 1px solid #e2e8f0;">
1296
+ <table cellpadding="0" cellspacing="0" width="100%">
1297
+ <tr>
1298
+ <td style="vertical-align: middle;">
1299
+ <span style="display: inline-block; background-color: #dbeafe; color: #1e40af; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 4px; margin-right: 8px;">${alertNumber}</span>
1300
+ <a href="${alertLink}" style="color: #2563eb; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size: 14px; font-weight: 500; text-decoration: none;">${alertTitle}</a>
1301
+ ${monitorName ? `<span style="display: block; color: #64748b; font-size: 12px; margin-top: 4px;">Monitor: ${monitorName}</span>` : ""}
1302
+ </td>
1303
+ <td style="text-align: right; vertical-align: middle;">
1304
+ <a href="${alertLink}" style="color: #2563eb; font-size: 12px; text-decoration: none;">View →</a>
1305
+ </td>
1306
+ </tr>
1307
+ </table>
1308
+ </td>
1309
+ </tr>
1310
+ `);
1311
+ }
1312
+ }
1313
+ if (alertRows.length > 0) {
1314
+ alertsListHtml = `
1315
+ <table cellpadding="0" cellspacing="0" width="100%" style="background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%); border-radius: 8px; border: 1px solid #e2e8f0; margin: 8px 0 16px 0;">
1316
+ <tbody>
1317
+ ${alertRows.join("")}
1318
+ </tbody>
1319
+ </table>
1320
+ `;
1321
+ }
1322
+ }
1323
+ const episodeNumber = alertEpisode.episodeNumber
1324
+ ? `#${alertEpisode.episodeNumber}`
1325
+ : "";
1326
+ const vars = {
1327
+ alertEpisodeTitle: alertEpisode.title,
1328
+ episodeNumber: episodeNumber,
1329
+ projectName: alertEpisode.project.name,
1330
+ currentState: alertEpisode.currentAlertState.name,
1331
+ alertEpisodeDescription: await Markdown.convertToHTML(alertEpisode.description || "", MarkdownContentType.Email),
1332
+ alertEpisodeSeverity: alertEpisode.alertSeverity.name,
1333
+ resourcesAffected: resourcesAffected,
1334
+ rootCause: alertEpisode.rootCause ||
1335
+ "No root cause identified for this alert episode",
1336
+ alertsList: alertsListHtml,
1337
+ alertsCount: episodeMembers.length.toString(),
1338
+ alertEpisodeViewLink: (await AlertEpisodeService.getEpisodeLinkInDashboard(alertEpisode.projectId, alertEpisode.id)).toString(),
1339
+ acknowledgeAlertEpisodeLink: new URL(httpProtocol, host, new Route(AppApiRoute.toString())
1340
+ .addRoute(new UserOnCallLogTimeline().crudApiPath)
1341
+ .addRoute("/acknowledge-page/" + userOnCallLogTimelineId.toString())).toString(),
1342
+ };
1343
+ const emailMessage = {
1344
+ toEmail: to,
1345
+ templateType: EmailTemplateType.AcknowledgeAlertEpisode,
1346
+ vars: vars,
1347
+ subject: `ACTION REQUIRED: Alert Episode ${episodeNumber} created - ${alertEpisode.title}`,
907
1348
  };
908
1349
  return emailMessage;
909
1350
  }
@@ -918,6 +1359,10 @@ export class Service extends DatabaseService {
918
1359
  if (options.triggeredByAlertId) {
919
1360
  userOnCallLog.triggeredByAlertId = options.triggeredByAlertId;
920
1361
  }
1362
+ if (options.triggeredByAlertEpisodeId) {
1363
+ userOnCallLog.triggeredByAlertEpisodeId =
1364
+ options.triggeredByAlertEpisodeId;
1365
+ }
921
1366
  userOnCallLog.userNotificationEventType = options.userNotificationEventType;
922
1367
  if (options.onCallPolicyExecutionLogId) {
923
1368
  userOnCallLog.onCallDutyPolicyExecutionLogId =
@@ -1043,7 +1488,7 @@ export class Service extends DatabaseService {
1043
1488
  userId,
1044
1489
  userEmailId: userEmail.id,
1045
1490
  incidentSeverityId: incidentSeverity.id,
1046
- ruleType: NotificationRuleType.ON_CALL_EXECUTED,
1491
+ ruleType: NotificationRuleType.ON_CALL_EXECUTED_INCIDENT,
1047
1492
  },
1048
1493
  props: {
1049
1494
  isRoot: true,
@@ -1058,7 +1503,8 @@ export class Service extends DatabaseService {
1058
1503
  notificationRule.userEmailId = userEmail.id;
1059
1504
  notificationRule.incidentSeverityId = incidentSeverity.id;
1060
1505
  notificationRule.notifyAfterMinutes = 0;
1061
- notificationRule.ruleType = NotificationRuleType.ON_CALL_EXECUTED;
1506
+ notificationRule.ruleType =
1507
+ NotificationRuleType.ON_CALL_EXECUTED_INCIDENT;
1062
1508
  await this.create({
1063
1509
  data: notificationRule,
1064
1510
  props: {
@@ -1091,7 +1537,7 @@ export class Service extends DatabaseService {
1091
1537
  userId,
1092
1538
  userEmailId: userEmail.id,
1093
1539
  alertSeverityId: alertSeverity.id,
1094
- ruleType: NotificationRuleType.ON_CALL_EXECUTED,
1540
+ ruleType: NotificationRuleType.ON_CALL_EXECUTED_ALERT,
1095
1541
  },
1096
1542
  props: {
1097
1543
  isRoot: true,
@@ -1106,7 +1552,7 @@ export class Service extends DatabaseService {
1106
1552
  notificationRule.userEmailId = userEmail.id;
1107
1553
  notificationRule.alertSeverityId = alertSeverity.id;
1108
1554
  notificationRule.notifyAfterMinutes = 0;
1109
- notificationRule.ruleType = NotificationRuleType.ON_CALL_EXECUTED;
1555
+ notificationRule.ruleType = NotificationRuleType.ON_CALL_EXECUTED_ALERT;
1110
1556
  await this.create({
1111
1557
  data: notificationRule,
1112
1558
  props: {
@@ -1229,6 +1675,14 @@ __decorate([
1229
1675
  ObjectID]),
1230
1676
  __metadata("design:returntype", Promise)
1231
1677
  ], Service.prototype, "generateCallTemplateForIncidentCreated", null);
1678
+ __decorate([
1679
+ CaptureSpan(),
1680
+ __metadata("design:type", Function),
1681
+ __metadata("design:paramtypes", [Phone,
1682
+ AlertEpisode,
1683
+ ObjectID]),
1684
+ __metadata("design:returntype", Promise)
1685
+ ], Service.prototype, "generateCallTemplateForAlertEpisodeCreated", null);
1232
1686
  __decorate([
1233
1687
  CaptureSpan(),
1234
1688
  __metadata("design:type", Function),
@@ -1245,6 +1699,14 @@ __decorate([
1245
1699
  ObjectID]),
1246
1700
  __metadata("design:returntype", Promise)
1247
1701
  ], Service.prototype, "generateSmsTemplateForIncidentCreated", null);
1702
+ __decorate([
1703
+ CaptureSpan(),
1704
+ __metadata("design:type", Function),
1705
+ __metadata("design:paramtypes", [Phone,
1706
+ AlertEpisode,
1707
+ ObjectID]),
1708
+ __metadata("design:returntype", Promise)
1709
+ ], Service.prototype, "generateSmsTemplateForAlertEpisodeCreated", null);
1248
1710
  __decorate([
1249
1711
  CaptureSpan(),
1250
1712
  __metadata("design:type", Function),
@@ -1261,6 +1723,14 @@ __decorate([
1261
1723
  ObjectID]),
1262
1724
  __metadata("design:returntype", Promise)
1263
1725
  ], Service.prototype, "generateWhatsAppTemplateForIncidentCreated", null);
1726
+ __decorate([
1727
+ CaptureSpan(),
1728
+ __metadata("design:type", Function),
1729
+ __metadata("design:paramtypes", [Phone,
1730
+ AlertEpisode,
1731
+ ObjectID]),
1732
+ __metadata("design:returntype", Promise)
1733
+ ], Service.prototype, "generateWhatsAppTemplateForAlertEpisodeCreated", null);
1264
1734
  __decorate([
1265
1735
  CaptureSpan(),
1266
1736
  __metadata("design:type", Function),
@@ -1277,6 +1747,14 @@ __decorate([
1277
1747
  ObjectID]),
1278
1748
  __metadata("design:returntype", Promise)
1279
1749
  ], Service.prototype, "generateEmailTemplateForIncidentCreated", null);
1750
+ __decorate([
1751
+ CaptureSpan(),
1752
+ __metadata("design:type", Function),
1753
+ __metadata("design:paramtypes", [Email,
1754
+ AlertEpisode,
1755
+ ObjectID]),
1756
+ __metadata("design:returntype", Promise)
1757
+ ], Service.prototype, "generateEmailTemplateForAlertEpisodeCreated", null);
1280
1758
  __decorate([
1281
1759
  CaptureSpan(),
1282
1760
  __metadata("design:type", Function),