@oneuptime/common 8.0.5239 → 8.0.5283

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 (359) hide show
  1. package/Models/DatabaseModels/Index.ts +4 -2
  2. package/Models/DatabaseModels/OnCallDutyPolicyUserOverride.ts +5 -3
  3. package/Models/DatabaseModels/Project.ts +4 -2
  4. package/Models/DatabaseModels/ProjectSmtpConfig.ts +4 -2
  5. package/Models/DatabaseModels/StatusPageDomain.ts +6 -4
  6. package/Models/DatabaseModels/User.ts +0 -46
  7. package/Models/DatabaseModels/{UserTwoFactorAuth.ts → UserTotpAuth.ts} +16 -16
  8. package/Models/DatabaseModels/UserWebAuthn.ts +244 -0
  9. package/Models/DatabaseModels/WorkspaceProjectAuthToken.ts +21 -0
  10. package/Server/API/BaseAPI.ts +4 -2
  11. package/Server/API/GlobalConfigAPI.ts +16 -12
  12. package/Server/API/MicrosoftTeamsAPI.ts +1240 -0
  13. package/Server/API/ProjectAPI.ts +4 -2
  14. package/Server/API/ResellerPlanAPI.ts +4 -2
  15. package/Server/API/SlackAPI.ts +54 -48
  16. package/Server/API/StatusPageAPI.ts +5 -3
  17. package/Server/API/UserOnCallLogTimelineAPI.ts +5 -3
  18. package/Server/API/{UserTwoFactorAuthAPI.ts → UserTotpAuthAPI.ts} +20 -20
  19. package/Server/API/UserWebAuthnAPI.ts +103 -0
  20. package/Server/EnvironmentConfig.ts +6 -0
  21. package/Server/Images/MicrosoftTeams/color.png +0 -0
  22. package/Server/Images/MicrosoftTeams/outline.png +0 -0
  23. package/Server/Infrastructure/Postgres/SchemaMigrations/1753131488925-AddEnableCustomSubscriberEmailNotificationFooterText.ts +4 -2
  24. package/Server/Infrastructure/Postgres/SchemaMigrations/1759175457008-MigrationName.ts +27 -0
  25. package/Server/Infrastructure/Postgres/SchemaMigrations/1759232954703-MigrationName.ts +25 -0
  26. package/Server/Infrastructure/Postgres/SchemaMigrations/1759234532998-MigrationName.ts +15 -0
  27. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +6 -0
  28. package/Server/Infrastructure/Queue.ts +4 -2
  29. package/Server/Infrastructure/SocketIO.ts +4 -2
  30. package/Server/Middleware/ProjectAuthorization.ts +5 -3
  31. package/Server/Middleware/SlackAuthorization.ts +2 -2
  32. package/Server/Middleware/TelemetryIngest.ts +12 -6
  33. package/Server/Services/AlertStateTimelineService.ts +34 -18
  34. package/Server/Services/BillingInvoiceService.ts +8 -4
  35. package/Server/Services/BillingService.ts +13 -9
  36. package/Server/Services/DatabaseService.ts +42 -30
  37. package/Server/Services/IncidentService.ts +5 -3
  38. package/Server/Services/IncidentStateTimelineService.ts +34 -18
  39. package/Server/Services/Index.ts +4 -2
  40. package/Server/Services/MonitorStatusTimelineService.ts +34 -18
  41. package/Server/Services/OnCallDutyPolicyScheduleService.ts +4 -2
  42. package/Server/Services/ProjectService.ts +6 -4
  43. package/Server/Services/ScheduledMaintenanceStateTimelineService.ts +26 -14
  44. package/Server/Services/StatusPageService.ts +4 -2
  45. package/Server/Services/UserService.ts +21 -5
  46. package/Server/Services/{UserTwoFactorAuthService.ts → UserTotpAuthService.ts} +26 -7
  47. package/Server/Services/UserWebAuthnService.ts +419 -0
  48. package/Server/Services/WorkspaceNotificationRuleService.ts +257 -77
  49. package/Server/Services/WorkspaceProjectAuthTokenService.ts +2 -2
  50. package/Server/Types/AnalyticsDatabase/ModelPermission.ts +9 -5
  51. package/Server/Types/Database/Permissions/BasePermission.ts +4 -2
  52. package/Server/Types/Database/Permissions/TenantPermission.ts +5 -3
  53. package/Server/Types/Database/QueryHelper.ts +4 -2
  54. package/Server/Types/Markdown.ts +6 -4
  55. package/Server/Types/Workflow/ComponentCode.ts +4 -2
  56. package/Server/Types/Workflow/Components/Conditions/IfElse.ts +5 -3
  57. package/Server/Types/Workflow/Components/JavaScript.ts +5 -3
  58. package/Server/Types/Workflow/TriggerCode.ts +4 -2
  59. package/Server/Utils/AnalyticsDatabase/Statement.ts +4 -2
  60. package/Server/Utils/AnalyticsDatabase/StatementGenerator.ts +21 -11
  61. package/Server/Utils/Browser.ts +6 -4
  62. package/Server/Utils/CodeRepository/GitHub/GitHub.ts +4 -2
  63. package/Server/Utils/LocalFile.ts +14 -0
  64. package/Server/Utils/Monitor/MonitorResource.ts +17 -9
  65. package/Server/Utils/Realtime.ts +4 -2
  66. package/Server/Utils/StartServer.ts +1 -1
  67. package/Server/Utils/Telemetry.ts +15 -9
  68. package/Server/Utils/{TwoFactorAuth.ts → TotpAuth.ts} +2 -2
  69. package/Server/Utils/Workspace/MicrosoftTeams/Actions/ActionTypes.ts +75 -16
  70. package/Server/Utils/Workspace/MicrosoftTeams/Actions/Alert.ts +649 -0
  71. package/Server/Utils/Workspace/MicrosoftTeams/Actions/Auth.ts +237 -0
  72. package/Server/Utils/Workspace/MicrosoftTeams/Actions/Incident.ts +1321 -0
  73. package/Server/Utils/Workspace/MicrosoftTeams/Actions/Monitor.ts +155 -0
  74. package/Server/Utils/Workspace/MicrosoftTeams/Actions/OnCallDutyPolicy.ts +119 -0
  75. package/Server/Utils/Workspace/MicrosoftTeams/Actions/ScheduledMaintenance.ts +959 -0
  76. package/Server/Utils/Workspace/MicrosoftTeams/Messages/Alert.ts +16 -14
  77. package/Server/Utils/Workspace/MicrosoftTeams/Messages/Incident.ts +17 -14
  78. package/Server/Utils/Workspace/MicrosoftTeams/Messages/ScheduledMaintenance.ts +18 -13
  79. package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +2547 -14
  80. package/Server/Utils/Workspace/Slack/Actions/Alert.ts +4 -2
  81. package/Server/Utils/Workspace/Slack/Actions/Auth.ts +4 -2
  82. package/Server/Utils/Workspace/Slack/Actions/Incident.ts +14 -10
  83. package/Server/Utils/Workspace/Slack/Actions/Monitor.ts +4 -2
  84. package/Server/Utils/Workspace/Slack/Actions/OnCallDutyPolicy.ts +4 -2
  85. package/Server/Utils/Workspace/Slack/Actions/ScheduledMaintenance.ts +14 -10
  86. package/Server/Utils/Workspace/Slack/Messages/Alert.ts +9 -7
  87. package/Server/Utils/Workspace/Slack/Messages/Incident.ts +9 -7
  88. package/Server/Utils/Workspace/Slack/Messages/Monitor.ts +9 -7
  89. package/Server/Utils/Workspace/Slack/Messages/ScheduledMaintenance.ts +9 -7
  90. package/Server/Utils/Workspace/Slack/Slack.ts +6 -0
  91. package/Server/Utils/Workspace/Workspace.ts +13 -10
  92. package/Server/Utils/Workspace/WorkspaceBase.ts +9 -0
  93. package/Tests/Server/API/BaseAPI.test.ts +64 -52
  94. package/Tests/Server/Services/BillingService.test.ts +4 -4
  95. package/Tests/Server/Services/TeamMemberService.test.ts +20 -12
  96. package/Tests/Server/TestingUtils/Services/BillingServiceHelper.ts +2 -2
  97. package/Tests/Types/OnCallDutyPolicy/LayerUtil.test.ts +8 -4
  98. package/Tests/UI/Components/DictionaryOfStrings.test.tsx +4 -2
  99. package/Tests/UI/Components/FilePicker.test.tsx +2 -2
  100. package/Tests/Utils/API.test.ts +9 -8
  101. package/Types/BaseDatabase/DatabaseCommonInteractionPropsUtil.ts +5 -3
  102. package/Types/Html.ts +5 -3
  103. package/Types/JSONFunctions.ts +5 -5
  104. package/Types/Metrics/MetricsQuery.ts +6 -4
  105. package/Types/Monitor/MonitorType.ts +8 -6
  106. package/Types/OnCallDutyPolicy/Layer.ts +29 -17
  107. package/Types/Phone.ts +5 -3
  108. package/Types/Workspace/NotificationRules/BaseNotificationRule.ts +1 -0
  109. package/Types/Workspace/NotificationRules/CreateChannelNotificationRule.ts +5 -2
  110. package/Types/Workspace/WorkspaceMessagePayload.ts +1 -0
  111. package/Types/Workspace/WorkspaceType.ts +13 -0
  112. package/UI/Components/Charts/Utils/DataPoint.ts +8 -6
  113. package/UI/Components/Detail/Detail.tsx +4 -1
  114. package/UI/Components/FilePicker/FilePicker.tsx +1 -1
  115. package/UI/Components/Forms/Types/Field.ts +4 -2
  116. package/UI/Components/Image/Image.tsx +1 -1
  117. package/UI/Components/JSONTable/JSONTable.tsx +4 -2
  118. package/UI/Components/ModelTable/BaseModelTable.tsx +5 -3
  119. package/UI/Components/SideMenu/SideMenu.tsx +4 -2
  120. package/UI/Components/SideMenu/SideMenuItem.tsx +69 -45
  121. package/UI/Config.ts +3 -0
  122. package/UI/Utils/API/API.ts +5 -3
  123. package/UI/Utils/Countries.ts +5 -3
  124. package/UI/Utils/Login.ts +6 -1
  125. package/Utils/Base64.ts +13 -0
  126. package/Utils/Schema/ModelSchema.ts +4 -2
  127. package/build/dist/Models/DatabaseModels/Index.js +4 -2
  128. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  129. package/build/dist/Models/DatabaseModels/OnCallDutyPolicyUserOverride.js +5 -3
  130. package/build/dist/Models/DatabaseModels/OnCallDutyPolicyUserOverride.js.map +1 -1
  131. package/build/dist/Models/DatabaseModels/Project.js +4 -2
  132. package/build/dist/Models/DatabaseModels/Project.js.map +1 -1
  133. package/build/dist/Models/DatabaseModels/ProjectSmtpConfig.js +4 -2
  134. package/build/dist/Models/DatabaseModels/ProjectSmtpConfig.js.map +1 -1
  135. package/build/dist/Models/DatabaseModels/StatusPageDomain.js +6 -4
  136. package/build/dist/Models/DatabaseModels/StatusPageDomain.js.map +1 -1
  137. package/build/dist/Models/DatabaseModels/User.js +0 -49
  138. package/build/dist/Models/DatabaseModels/User.js.map +1 -1
  139. package/build/dist/Models/DatabaseModels/{UserTwoFactorAuth.js → UserTotpAuth.js} +27 -27
  140. package/build/dist/Models/DatabaseModels/UserTotpAuth.js.map +1 -0
  141. package/build/dist/Models/DatabaseModels/UserWebAuthn.js +270 -0
  142. package/build/dist/Models/DatabaseModels/UserWebAuthn.js.map +1 -0
  143. package/build/dist/Models/DatabaseModels/WorkspaceProjectAuthToken.js.map +1 -1
  144. package/build/dist/Server/API/BaseAPI.js +4 -2
  145. package/build/dist/Server/API/BaseAPI.js.map +1 -1
  146. package/build/dist/Server/API/GlobalConfigAPI.js +16 -12
  147. package/build/dist/Server/API/GlobalConfigAPI.js.map +1 -1
  148. package/build/dist/Server/API/MicrosoftTeamsAPI.js +771 -0
  149. package/build/dist/Server/API/MicrosoftTeamsAPI.js.map +1 -0
  150. package/build/dist/Server/API/ProjectAPI.js +4 -2
  151. package/build/dist/Server/API/ProjectAPI.js.map +1 -1
  152. package/build/dist/Server/API/ResellerPlanAPI.js +4 -2
  153. package/build/dist/Server/API/ResellerPlanAPI.js.map +1 -1
  154. package/build/dist/Server/API/SlackAPI.js +53 -47
  155. package/build/dist/Server/API/SlackAPI.js.map +1 -1
  156. package/build/dist/Server/API/StatusPageAPI.js +5 -3
  157. package/build/dist/Server/API/StatusPageAPI.js.map +1 -1
  158. package/build/dist/Server/API/UserOnCallLogTimelineAPI.js +5 -3
  159. package/build/dist/Server/API/UserOnCallLogTimelineAPI.js.map +1 -1
  160. package/build/dist/Server/API/{UserTwoFactorAuthAPI.js → UserTotpAuthAPI.js} +16 -16
  161. package/build/dist/Server/API/UserTotpAuthAPI.js.map +1 -0
  162. package/build/dist/Server/API/UserWebAuthnAPI.js +65 -0
  163. package/build/dist/Server/API/UserWebAuthnAPI.js.map +1 -0
  164. package/build/dist/Server/EnvironmentConfig.js +3 -0
  165. package/build/dist/Server/EnvironmentConfig.js.map +1 -1
  166. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1753131488925-AddEnableCustomSubscriberEmailNotificationFooterText.js +4 -2
  167. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1753131488925-AddEnableCustomSubscriberEmailNotificationFooterText.js.map +1 -1
  168. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1759175457008-MigrationName.js +16 -0
  169. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1759175457008-MigrationName.js.map +1 -0
  170. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1759232954703-MigrationName.js +16 -0
  171. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1759232954703-MigrationName.js.map +1 -0
  172. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1759234532998-MigrationName.js +12 -0
  173. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1759234532998-MigrationName.js.map +1 -0
  174. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +6 -0
  175. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  176. package/build/dist/Server/Infrastructure/Queue.js +4 -2
  177. package/build/dist/Server/Infrastructure/Queue.js.map +1 -1
  178. package/build/dist/Server/Infrastructure/SocketIO.js +4 -2
  179. package/build/dist/Server/Infrastructure/SocketIO.js.map +1 -1
  180. package/build/dist/Server/Middleware/ProjectAuthorization.js +5 -3
  181. package/build/dist/Server/Middleware/ProjectAuthorization.js.map +1 -1
  182. package/build/dist/Server/Middleware/SlackAuthorization.js.map +1 -1
  183. package/build/dist/Server/Middleware/TelemetryIngest.js +12 -6
  184. package/build/dist/Server/Middleware/TelemetryIngest.js.map +1 -1
  185. package/build/dist/Server/Services/AlertStateTimelineService.js +34 -18
  186. package/build/dist/Server/Services/AlertStateTimelineService.js.map +1 -1
  187. package/build/dist/Server/Services/BillingInvoiceService.js +8 -4
  188. package/build/dist/Server/Services/BillingInvoiceService.js.map +1 -1
  189. package/build/dist/Server/Services/BillingService.js +13 -9
  190. package/build/dist/Server/Services/BillingService.js.map +1 -1
  191. package/build/dist/Server/Services/DatabaseService.js +40 -28
  192. package/build/dist/Server/Services/DatabaseService.js.map +1 -1
  193. package/build/dist/Server/Services/IncidentService.js +5 -3
  194. package/build/dist/Server/Services/IncidentService.js.map +1 -1
  195. package/build/dist/Server/Services/IncidentStateTimelineService.js +34 -18
  196. package/build/dist/Server/Services/IncidentStateTimelineService.js.map +1 -1
  197. package/build/dist/Server/Services/Index.js +4 -2
  198. package/build/dist/Server/Services/Index.js.map +1 -1
  199. package/build/dist/Server/Services/MonitorStatusTimelineService.js +34 -18
  200. package/build/dist/Server/Services/MonitorStatusTimelineService.js.map +1 -1
  201. package/build/dist/Server/Services/OnCallDutyPolicyScheduleService.js +4 -2
  202. package/build/dist/Server/Services/OnCallDutyPolicyScheduleService.js.map +1 -1
  203. package/build/dist/Server/Services/ProjectService.js +6 -4
  204. package/build/dist/Server/Services/ProjectService.js.map +1 -1
  205. package/build/dist/Server/Services/ScheduledMaintenanceStateTimelineService.js +26 -14
  206. package/build/dist/Server/Services/ScheduledMaintenanceStateTimelineService.js.map +1 -1
  207. package/build/dist/Server/Services/StatusPageService.js +4 -2
  208. package/build/dist/Server/Services/StatusPageService.js.map +1 -1
  209. package/build/dist/Server/Services/UserService.js +16 -3
  210. package/build/dist/Server/Services/UserService.js.map +1 -1
  211. package/build/dist/Server/Services/{UserTwoFactorAuthService.js → UserTotpAuthService.js} +22 -8
  212. package/build/dist/Server/Services/UserTotpAuthService.js.map +1 -0
  213. package/build/dist/Server/Services/UserWebAuthnService.js +365 -0
  214. package/build/dist/Server/Services/UserWebAuthnService.js.map +1 -0
  215. package/build/dist/Server/Services/WorkspaceNotificationRuleService.js +142 -51
  216. package/build/dist/Server/Services/WorkspaceNotificationRuleService.js.map +1 -1
  217. package/build/dist/Server/Types/AnalyticsDatabase/ModelPermission.js +9 -5
  218. package/build/dist/Server/Types/AnalyticsDatabase/ModelPermission.js.map +1 -1
  219. package/build/dist/Server/Types/Database/Permissions/BasePermission.js +4 -2
  220. package/build/dist/Server/Types/Database/Permissions/BasePermission.js.map +1 -1
  221. package/build/dist/Server/Types/Database/Permissions/TenantPermission.js +5 -3
  222. package/build/dist/Server/Types/Database/Permissions/TenantPermission.js.map +1 -1
  223. package/build/dist/Server/Types/Database/QueryHelper.js +4 -2
  224. package/build/dist/Server/Types/Database/QueryHelper.js.map +1 -1
  225. package/build/dist/Server/Types/Markdown.js +6 -4
  226. package/build/dist/Server/Types/Markdown.js.map +1 -1
  227. package/build/dist/Server/Types/Workflow/ComponentCode.js +4 -2
  228. package/build/dist/Server/Types/Workflow/ComponentCode.js.map +1 -1
  229. package/build/dist/Server/Types/Workflow/Components/Conditions/IfElse.js +5 -3
  230. package/build/dist/Server/Types/Workflow/Components/Conditions/IfElse.js.map +1 -1
  231. package/build/dist/Server/Types/Workflow/Components/JavaScript.js +5 -3
  232. package/build/dist/Server/Types/Workflow/Components/JavaScript.js.map +1 -1
  233. package/build/dist/Server/Types/Workflow/TriggerCode.js.map +1 -1
  234. package/build/dist/Server/Utils/AnalyticsDatabase/Statement.js +4 -2
  235. package/build/dist/Server/Utils/AnalyticsDatabase/Statement.js.map +1 -1
  236. package/build/dist/Server/Utils/AnalyticsDatabase/StatementGenerator.js +21 -11
  237. package/build/dist/Server/Utils/AnalyticsDatabase/StatementGenerator.js.map +1 -1
  238. package/build/dist/Server/Utils/Browser.js +6 -4
  239. package/build/dist/Server/Utils/Browser.js.map +1 -1
  240. package/build/dist/Server/Utils/CodeRepository/GitHub/GitHub.js +4 -2
  241. package/build/dist/Server/Utils/CodeRepository/GitHub/GitHub.js.map +1 -1
  242. package/build/dist/Server/Utils/LocalFile.js +16 -0
  243. package/build/dist/Server/Utils/LocalFile.js.map +1 -1
  244. package/build/dist/Server/Utils/Monitor/MonitorResource.js +17 -9
  245. package/build/dist/Server/Utils/Monitor/MonitorResource.js.map +1 -1
  246. package/build/dist/Server/Utils/Realtime.js +4 -2
  247. package/build/dist/Server/Utils/Realtime.js.map +1 -1
  248. package/build/dist/Server/Utils/StartServer.js.map +1 -1
  249. package/build/dist/Server/Utils/Telemetry.js +6 -4
  250. package/build/dist/Server/Utils/Telemetry.js.map +1 -1
  251. package/build/dist/Server/Utils/{TwoFactorAuth.js → TotpAuth.js} +8 -8
  252. package/build/dist/Server/Utils/TotpAuth.js.map +1 -0
  253. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/ActionTypes.js +86 -36
  254. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/ActionTypes.js.map +1 -1
  255. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Alert.js +531 -0
  256. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Alert.js.map +1 -0
  257. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Auth.js +206 -0
  258. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Auth.js.map +1 -0
  259. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Incident.js +1102 -0
  260. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Incident.js.map +1 -0
  261. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Monitor.js +136 -0
  262. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Monitor.js.map +1 -0
  263. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/OnCallDutyPolicy.js +107 -0
  264. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/OnCallDutyPolicy.js.map +1 -0
  265. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/ScheduledMaintenance.js +795 -0
  266. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/ScheduledMaintenance.js.map +1 -0
  267. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Messages/Alert.js +16 -14
  268. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Messages/Alert.js.map +1 -1
  269. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Messages/Incident.js +16 -14
  270. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Messages/Incident.js.map +1 -1
  271. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Messages/ScheduledMaintenance.js +15 -13
  272. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Messages/ScheduledMaintenance.js.map +1 -1
  273. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js +1982 -13
  274. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js.map +1 -1
  275. package/build/dist/Server/Utils/Workspace/Slack/Actions/Alert.js +4 -2
  276. package/build/dist/Server/Utils/Workspace/Slack/Actions/Alert.js.map +1 -1
  277. package/build/dist/Server/Utils/Workspace/Slack/Actions/Auth.js +4 -2
  278. package/build/dist/Server/Utils/Workspace/Slack/Actions/Auth.js.map +1 -1
  279. package/build/dist/Server/Utils/Workspace/Slack/Actions/Incident.js +14 -10
  280. package/build/dist/Server/Utils/Workspace/Slack/Actions/Incident.js.map +1 -1
  281. package/build/dist/Server/Utils/Workspace/Slack/Actions/Monitor.js +4 -2
  282. package/build/dist/Server/Utils/Workspace/Slack/Actions/Monitor.js.map +1 -1
  283. package/build/dist/Server/Utils/Workspace/Slack/Actions/OnCallDutyPolicy.js +4 -2
  284. package/build/dist/Server/Utils/Workspace/Slack/Actions/OnCallDutyPolicy.js.map +1 -1
  285. package/build/dist/Server/Utils/Workspace/Slack/Actions/ScheduledMaintenance.js +14 -10
  286. package/build/dist/Server/Utils/Workspace/Slack/Actions/ScheduledMaintenance.js.map +1 -1
  287. package/build/dist/Server/Utils/Workspace/Slack/Messages/Alert.js +9 -7
  288. package/build/dist/Server/Utils/Workspace/Slack/Messages/Alert.js.map +1 -1
  289. package/build/dist/Server/Utils/Workspace/Slack/Messages/Incident.js +9 -7
  290. package/build/dist/Server/Utils/Workspace/Slack/Messages/Incident.js.map +1 -1
  291. package/build/dist/Server/Utils/Workspace/Slack/Messages/Monitor.js +9 -7
  292. package/build/dist/Server/Utils/Workspace/Slack/Messages/Monitor.js.map +1 -1
  293. package/build/dist/Server/Utils/Workspace/Slack/Messages/ScheduledMaintenance.js +9 -7
  294. package/build/dist/Server/Utils/Workspace/Slack/Messages/ScheduledMaintenance.js.map +1 -1
  295. package/build/dist/Server/Utils/Workspace/Slack/Slack.js +5 -0
  296. package/build/dist/Server/Utils/Workspace/Slack/Slack.js.map +1 -1
  297. package/build/dist/Server/Utils/Workspace/Workspace.js +12 -10
  298. package/build/dist/Server/Utils/Workspace/Workspace.js.map +1 -1
  299. package/build/dist/Server/Utils/Workspace/WorkspaceBase.js.map +1 -1
  300. package/build/dist/Tests/Server/API/BaseAPI.test.js +59 -47
  301. package/build/dist/Tests/Server/API/BaseAPI.test.js.map +1 -1
  302. package/build/dist/Tests/Server/Services/BillingService.test.js +4 -4
  303. package/build/dist/Tests/Server/Services/BillingService.test.js.map +1 -1
  304. package/build/dist/Tests/Server/Services/TeamMemberService.test.js +20 -12
  305. package/build/dist/Tests/Server/Services/TeamMemberService.test.js.map +1 -1
  306. package/build/dist/Tests/Server/TestingUtils/Services/BillingServiceHelper.js +2 -2
  307. package/build/dist/Tests/Server/TestingUtils/Services/BillingServiceHelper.js.map +1 -1
  308. package/build/dist/Tests/Types/OnCallDutyPolicy/LayerUtil.test.js +8 -4
  309. package/build/dist/Tests/Types/OnCallDutyPolicy/LayerUtil.test.js.map +1 -1
  310. package/build/dist/Tests/UI/Components/DictionaryOfStrings.test.js +4 -2
  311. package/build/dist/Tests/UI/Components/DictionaryOfStrings.test.js.map +1 -1
  312. package/build/dist/Tests/UI/Components/FilePicker.test.js +2 -2
  313. package/build/dist/Tests/UI/Components/FilePicker.test.js.map +1 -1
  314. package/build/dist/Tests/Utils/API.test.js +8 -7
  315. package/build/dist/Tests/Utils/API.test.js.map +1 -1
  316. package/build/dist/Types/BaseDatabase/DatabaseCommonInteractionPropsUtil.js +5 -3
  317. package/build/dist/Types/BaseDatabase/DatabaseCommonInteractionPropsUtil.js.map +1 -1
  318. package/build/dist/Types/Html.js +5 -3
  319. package/build/dist/Types/Html.js.map +1 -1
  320. package/build/dist/Types/JSONFunctions.js +5 -5
  321. package/build/dist/Types/JSONFunctions.js.map +1 -1
  322. package/build/dist/Types/Monitor/MonitorType.js +8 -6
  323. package/build/dist/Types/Monitor/MonitorType.js.map +1 -1
  324. package/build/dist/Types/OnCallDutyPolicy/Layer.js +29 -17
  325. package/build/dist/Types/OnCallDutyPolicy/Layer.js.map +1 -1
  326. package/build/dist/Types/Phone.js +5 -3
  327. package/build/dist/Types/Phone.js.map +1 -1
  328. package/build/dist/Types/Workspace/WorkspaceType.js +9 -0
  329. package/build/dist/Types/Workspace/WorkspaceType.js.map +1 -1
  330. package/build/dist/UI/Components/Charts/Utils/DataPoint.js +8 -6
  331. package/build/dist/UI/Components/Charts/Utils/DataPoint.js.map +1 -1
  332. package/build/dist/UI/Components/Detail/Detail.js +4 -1
  333. package/build/dist/UI/Components/Detail/Detail.js.map +1 -1
  334. package/build/dist/UI/Components/FilePicker/FilePicker.js +1 -1
  335. package/build/dist/UI/Components/FilePicker/FilePicker.js.map +1 -1
  336. package/build/dist/UI/Components/Image/Image.js +1 -1
  337. package/build/dist/UI/Components/Image/Image.js.map +1 -1
  338. package/build/dist/UI/Components/JSONTable/JSONTable.js.map +1 -1
  339. package/build/dist/UI/Components/ModelTable/BaseModelTable.js.map +1 -1
  340. package/build/dist/UI/Components/SideMenu/SideMenu.js +4 -2
  341. package/build/dist/UI/Components/SideMenu/SideMenu.js.map +1 -1
  342. package/build/dist/UI/Components/SideMenu/SideMenuItem.js +62 -38
  343. package/build/dist/UI/Components/SideMenu/SideMenuItem.js.map +1 -1
  344. package/build/dist/UI/Config.js +1 -0
  345. package/build/dist/UI/Config.js.map +1 -1
  346. package/build/dist/UI/Utils/API/API.js +5 -3
  347. package/build/dist/UI/Utils/API/API.js.map +1 -1
  348. package/build/dist/UI/Utils/Countries.js.map +1 -1
  349. package/build/dist/UI/Utils/Login.js +6 -1
  350. package/build/dist/UI/Utils/Login.js.map +1 -1
  351. package/build/dist/Utils/Base64.js +12 -0
  352. package/build/dist/Utils/Base64.js.map +1 -0
  353. package/build/dist/Utils/Schema/ModelSchema.js +4 -2
  354. package/build/dist/Utils/Schema/ModelSchema.js.map +1 -1
  355. package/package.json +5 -1
  356. package/build/dist/Models/DatabaseModels/UserTwoFactorAuth.js.map +0 -1
  357. package/build/dist/Server/API/UserTwoFactorAuthAPI.js.map +0 -1
  358. package/build/dist/Server/Services/UserTwoFactorAuthService.js.map +0 -1
  359. package/build/dist/Server/Utils/TwoFactorAuth.js.map +0 -1
@@ -0,0 +1,649 @@
1
+ import { ExpressRequest, ExpressResponse } from "../../../Express";
2
+ import Response from "../../../Response";
3
+ import MicrosoftTeamsAuthAction, {
4
+ MicrosoftTeamsAction,
5
+ MicrosoftTeamsRequest,
6
+ } from "./Auth";
7
+ import { MicrosoftTeamsAlertActionType } from "./ActionTypes";
8
+ import logger from "../../../Logger";
9
+ import ObjectID from "../../../../../Types/ObjectID";
10
+ import AlertService from "../../../../Services/AlertService";
11
+ import Alert from "../../../../../Models/DatabaseModels/Alert";
12
+ import CaptureSpan from "../../../Telemetry/CaptureSpan";
13
+ import { TurnContext } from "botbuilder";
14
+ import { JSONObject, JSONValue } from "../../../../../Types/JSON";
15
+ import AlertInternalNoteService from "../../../../Services/AlertInternalNoteService";
16
+ import OnCallDutyPolicyService from "../../../../Services/OnCallDutyPolicyService";
17
+ import AlertStateService from "../../../../Services/AlertStateService";
18
+ import UserNotificationEventType from "../../../../../Types/UserNotification/UserNotificationEventType";
19
+ import OnCallDutyPolicy from "../../../../../Models/DatabaseModels/OnCallDutyPolicy";
20
+ import AlertState from "../../../../../Models/DatabaseModels/AlertState";
21
+
22
+ export default class MicrosoftTeamsAlertActions {
23
+ @CaptureSpan()
24
+ public static isAlertAction(data: { actionType: string }): boolean {
25
+ return (
26
+ data.actionType.includes("alert") ||
27
+ data.actionType === MicrosoftTeamsAlertActionType.AckAlert ||
28
+ data.actionType === MicrosoftTeamsAlertActionType.ResolveAlert ||
29
+ data.actionType === MicrosoftTeamsAlertActionType.ViewAlert ||
30
+ data.actionType === MicrosoftTeamsAlertActionType.AlertCreated ||
31
+ data.actionType === MicrosoftTeamsAlertActionType.AlertStateChanged ||
32
+ data.actionType === MicrosoftTeamsAlertActionType.ViewAddAlertNote ||
33
+ data.actionType === MicrosoftTeamsAlertActionType.SubmitAlertNote ||
34
+ data.actionType ===
35
+ MicrosoftTeamsAlertActionType.ViewExecuteAlertOnCallPolicy ||
36
+ data.actionType ===
37
+ MicrosoftTeamsAlertActionType.SubmitExecuteAlertOnCallPolicy ||
38
+ data.actionType === MicrosoftTeamsAlertActionType.ViewChangeAlertState ||
39
+ data.actionType === MicrosoftTeamsAlertActionType.SubmitChangeAlertState
40
+ );
41
+ }
42
+
43
+ @CaptureSpan()
44
+ public static async handleAlertAction(data: {
45
+ teamsRequest: MicrosoftTeamsRequest;
46
+ action: MicrosoftTeamsAction;
47
+ req: ExpressRequest;
48
+ res: ExpressResponse;
49
+ }): Promise<void> {
50
+ const { teamsRequest, action } = data;
51
+
52
+ logger.debug("Handling Microsoft Teams alert action:");
53
+ logger.debug(action);
54
+
55
+ try {
56
+ switch (action.actionType) {
57
+ case MicrosoftTeamsAlertActionType.AckAlert:
58
+ await this.acknowledgeAlert({
59
+ teamsRequest,
60
+ action,
61
+ });
62
+ break;
63
+
64
+ case MicrosoftTeamsAlertActionType.ResolveAlert:
65
+ await this.resolveAlert({
66
+ teamsRequest,
67
+ action,
68
+ });
69
+ break;
70
+
71
+ case MicrosoftTeamsAlertActionType.ViewAlert:
72
+ // This is handled by opening the URL directly
73
+ break;
74
+
75
+ default:
76
+ logger.debug("Unhandled alert action: " + action.actionType);
77
+ break;
78
+ }
79
+ } catch (error) {
80
+ logger.error("Error handling Microsoft Teams alert action:");
81
+ logger.error(error);
82
+ }
83
+
84
+ Response.sendTextResponse(data.req, data.res, "");
85
+ }
86
+
87
+ @CaptureSpan()
88
+ private static async acknowledgeAlert(data: {
89
+ teamsRequest: MicrosoftTeamsRequest;
90
+ action: MicrosoftTeamsAction;
91
+ }): Promise<void> {
92
+ const alertId: string = data.action.actionValue || "";
93
+
94
+ if (!alertId) {
95
+ logger.error("No alert ID provided for acknowledge action");
96
+ return;
97
+ }
98
+
99
+ logger.debug("Acknowledging alert: " + alertId);
100
+
101
+ try {
102
+ const alert: Alert | null = await AlertService.findOneBy({
103
+ query: {
104
+ _id: alertId,
105
+ projectId: data.teamsRequest.projectId,
106
+ },
107
+ select: {
108
+ _id: true,
109
+ projectId: true,
110
+ currentAlertState: {
111
+ _id: true,
112
+ name: true,
113
+ isAcknowledgedState: true,
114
+ },
115
+ },
116
+ props: {
117
+ isRoot: true,
118
+ },
119
+ });
120
+
121
+ if (!alert) {
122
+ logger.error("Alert not found: " + alertId);
123
+ return;
124
+ }
125
+
126
+ if (alert.currentAlertState?.isAcknowledgedState) {
127
+ logger.debug("Alert is already acknowledged");
128
+ return;
129
+ }
130
+
131
+ const oneUptimeUserId: ObjectID =
132
+ await MicrosoftTeamsAuthAction.getOneUptimeUserIdFromTeamsUserId({
133
+ teamsUserId: data.teamsRequest.userId || "",
134
+ projectId: data.teamsRequest.projectId,
135
+ });
136
+
137
+ await AlertService.acknowledgeAlert(
138
+ new ObjectID(alertId),
139
+ oneUptimeUserId,
140
+ );
141
+
142
+ logger.debug("Alert acknowledged successfully");
143
+ } catch (error) {
144
+ logger.error("Error acknowledging alert:");
145
+ logger.error(error);
146
+ }
147
+ }
148
+
149
+ @CaptureSpan()
150
+ private static async resolveAlert(data: {
151
+ teamsRequest: MicrosoftTeamsRequest;
152
+ action: MicrosoftTeamsAction;
153
+ }): Promise<void> {
154
+ const alertId: string = data.action.actionValue || "";
155
+
156
+ if (!alertId) {
157
+ logger.error("No alert ID provided for resolve action");
158
+ return;
159
+ }
160
+
161
+ logger.debug("Resolving alert: " + alertId);
162
+
163
+ try {
164
+ const alert: Alert | null = await AlertService.findOneBy({
165
+ query: {
166
+ _id: alertId,
167
+ projectId: data.teamsRequest.projectId,
168
+ },
169
+ select: {
170
+ _id: true,
171
+ projectId: true,
172
+ currentAlertState: {
173
+ _id: true,
174
+ name: true,
175
+ isResolvedState: true,
176
+ },
177
+ },
178
+ props: {
179
+ isRoot: true,
180
+ },
181
+ });
182
+
183
+ if (!alert) {
184
+ logger.error("Alert not found: " + alertId);
185
+ return;
186
+ }
187
+
188
+ if (alert.currentAlertState?.isResolvedState) {
189
+ logger.debug("Alert is already resolved");
190
+ return;
191
+ }
192
+
193
+ const oneUptimeUserId: ObjectID =
194
+ await MicrosoftTeamsAuthAction.getOneUptimeUserIdFromTeamsUserId({
195
+ teamsUserId: data.teamsRequest.userId || "",
196
+ projectId: data.teamsRequest.projectId,
197
+ });
198
+
199
+ await AlertService.resolveAlert(new ObjectID(alertId), oneUptimeUserId);
200
+
201
+ logger.debug("Alert resolved successfully");
202
+ } catch (error) {
203
+ logger.error("Error resolving alert:");
204
+ logger.error(error);
205
+ }
206
+ }
207
+
208
+ @CaptureSpan()
209
+ public static async handleBotAlertAction(data: {
210
+ actionType: string;
211
+ actionValue: string;
212
+ value: JSONObject;
213
+ projectId: ObjectID;
214
+ oneUptimeUserId: ObjectID;
215
+ turnContext: TurnContext;
216
+ }): Promise<void> {
217
+ const {
218
+ actionType,
219
+ actionValue,
220
+ value,
221
+ projectId,
222
+ oneUptimeUserId,
223
+ turnContext,
224
+ } = data;
225
+
226
+ if (actionType === MicrosoftTeamsAlertActionType.AckAlert) {
227
+ if (!actionValue) {
228
+ await turnContext.sendActivity(
229
+ "Unable to acknowledge: missing alert id.",
230
+ );
231
+ return;
232
+ }
233
+
234
+ await AlertService.acknowledgeAlert(
235
+ new ObjectID(actionValue),
236
+ oneUptimeUserId,
237
+ );
238
+ await turnContext.sendActivity("✅ Alert acknowledged.");
239
+ return;
240
+ }
241
+
242
+ if (actionType === MicrosoftTeamsAlertActionType.ResolveAlert) {
243
+ if (!actionValue) {
244
+ await turnContext.sendActivity("Unable to resolve: missing alert id.");
245
+ return;
246
+ }
247
+
248
+ await AlertService.resolveAlert(
249
+ new ObjectID(actionValue),
250
+ oneUptimeUserId,
251
+ );
252
+ await turnContext.sendActivity("✅ Alert resolved.");
253
+ return;
254
+ }
255
+
256
+ if (actionType === MicrosoftTeamsAlertActionType.ViewAlert) {
257
+ if (!actionValue) {
258
+ await turnContext.sendActivity(
259
+ "Unable to view alert: missing alert id.",
260
+ );
261
+ return;
262
+ }
263
+
264
+ const alert: Alert | null = await AlertService.findOneBy({
265
+ query: {
266
+ _id: actionValue,
267
+ projectId: projectId,
268
+ },
269
+ select: {
270
+ _id: true,
271
+ title: true,
272
+ description: true,
273
+ currentAlertState: {
274
+ name: true,
275
+ },
276
+ alertSeverity: {
277
+ name: true,
278
+ },
279
+ createdAt: true,
280
+ },
281
+ props: {
282
+ isRoot: true,
283
+ },
284
+ });
285
+
286
+ if (!alert) {
287
+ await turnContext.sendActivity("Alert not found.");
288
+ return;
289
+ }
290
+
291
+ const message: string = `**Alert Details**\n\n**Title:** ${alert.title}\n**Description:** ${alert.description || "No description"}\n**State:** ${alert.currentAlertState?.name || "Unknown"}\n**Severity:** ${alert.alertSeverity?.name || "Unknown"}\n**Created At:** ${alert.createdAt ? new Date(alert.createdAt).toLocaleString() : "Unknown"}`;
292
+
293
+ await turnContext.sendActivity(message);
294
+ return;
295
+ }
296
+
297
+ if (actionType === MicrosoftTeamsAlertActionType.ViewAddAlertNote) {
298
+ if (!actionValue) {
299
+ await turnContext.sendActivity("Unable to add note: missing alert id.");
300
+ return;
301
+ }
302
+
303
+ // Send the input card
304
+ const card: JSONObject = this.buildAddAlertNoteCard(actionValue);
305
+ await turnContext.sendActivity({
306
+ attachments: [
307
+ {
308
+ contentType: "application/vnd.microsoft.card.adaptive",
309
+ content: card,
310
+ },
311
+ ],
312
+ });
313
+ return;
314
+ }
315
+
316
+ if (actionType === MicrosoftTeamsAlertActionType.SubmitAlertNote) {
317
+ if (!actionValue) {
318
+ await turnContext.sendActivity("Unable to add note: missing alert id.");
319
+ return;
320
+ }
321
+
322
+ // Check if form data is provided
323
+ const note: JSONValue = value["note"];
324
+
325
+ if (note) {
326
+ // Submit the note
327
+ const alertId: ObjectID = new ObjectID(actionValue);
328
+
329
+ await AlertInternalNoteService.addNote({
330
+ alertId: alertId,
331
+ note: note.toString(),
332
+ projectId: projectId,
333
+ userId: oneUptimeUserId,
334
+ });
335
+
336
+ await turnContext.sendActivity("✅ Note added successfully.");
337
+
338
+ // Hide the form card by deleting it
339
+ if (turnContext.activity.replyToId) {
340
+ await turnContext.deleteActivity(turnContext.activity.replyToId);
341
+ }
342
+
343
+ return;
344
+ }
345
+ await turnContext.sendActivity("Unable to add note: missing note data.");
346
+ return;
347
+ }
348
+
349
+ if (
350
+ actionType === MicrosoftTeamsAlertActionType.ViewExecuteAlertOnCallPolicy
351
+ ) {
352
+ if (!actionValue) {
353
+ await turnContext.sendActivity(
354
+ "Unable to execute on-call policy: missing alert id.",
355
+ );
356
+ return;
357
+ }
358
+
359
+ // Send the input card
360
+ const card: JSONObject | null =
361
+ await this.buildExecuteAlertOnCallPolicyCard(actionValue, projectId);
362
+ if (!card) {
363
+ await turnContext.sendActivity(
364
+ "No on-call policies found in the project",
365
+ );
366
+ return;
367
+ }
368
+ await turnContext.sendActivity({
369
+ attachments: [
370
+ {
371
+ contentType: "application/vnd.microsoft.card.adaptive",
372
+ content: card,
373
+ },
374
+ ],
375
+ });
376
+ return;
377
+ }
378
+
379
+ if (
380
+ actionType ===
381
+ MicrosoftTeamsAlertActionType.SubmitExecuteAlertOnCallPolicy
382
+ ) {
383
+ if (!actionValue) {
384
+ await turnContext.sendActivity(
385
+ "Unable to execute on-call policy: missing alert id.",
386
+ );
387
+ return;
388
+ }
389
+
390
+ // Check if form data is provided
391
+ const onCallPolicyId: JSONValue = value["onCallPolicy"];
392
+
393
+ if (onCallPolicyId) {
394
+ // Execute the policy
395
+ const alertId: ObjectID = new ObjectID(actionValue);
396
+
397
+ await OnCallDutyPolicyService.executePolicy(
398
+ new ObjectID(onCallPolicyId.toString()),
399
+ {
400
+ triggeredByAlertId: alertId,
401
+ userNotificationEventType: UserNotificationEventType.AlertCreated,
402
+ },
403
+ );
404
+
405
+ await turnContext.sendActivity(
406
+ "✅ On-call policy executed successfully.",
407
+ );
408
+
409
+ // Hide the form card by deleting it
410
+ if (turnContext.activity.replyToId) {
411
+ await turnContext.deleteActivity(turnContext.activity.replyToId);
412
+ }
413
+
414
+ return;
415
+ }
416
+ await turnContext.sendActivity(
417
+ "Unable to execute on-call policy: missing policy id.",
418
+ );
419
+ return;
420
+ }
421
+
422
+ if (actionType === MicrosoftTeamsAlertActionType.ViewChangeAlertState) {
423
+ if (!actionValue) {
424
+ await turnContext.sendActivity(
425
+ "Unable to change alert state: missing alert id.",
426
+ );
427
+ return;
428
+ }
429
+
430
+ // Send the input card
431
+ const card: JSONObject = await this.buildChangeAlertStateCard(
432
+ actionValue,
433
+ projectId,
434
+ );
435
+ await turnContext.sendActivity({
436
+ attachments: [
437
+ {
438
+ contentType: "application/vnd.microsoft.card.adaptive",
439
+ content: card,
440
+ },
441
+ ],
442
+ });
443
+ return;
444
+ }
445
+
446
+ if (actionType === MicrosoftTeamsAlertActionType.SubmitChangeAlertState) {
447
+ if (!actionValue) {
448
+ await turnContext.sendActivity(
449
+ "Unable to change alert state: missing alert id.",
450
+ );
451
+ return;
452
+ }
453
+
454
+ // Check if form data is provided
455
+ const alertStateId: JSONValue = value["alertState"];
456
+
457
+ if (alertStateId) {
458
+ // Update the state
459
+ const alertId: ObjectID = new ObjectID(actionValue);
460
+
461
+ await AlertService.updateOneById({
462
+ id: alertId,
463
+ data: {
464
+ currentAlertStateId: new ObjectID(alertStateId.toString()),
465
+ },
466
+ props: {
467
+ isRoot: true,
468
+ },
469
+ });
470
+
471
+ await turnContext.sendActivity("✅ Alert state changed successfully.");
472
+
473
+ // Hide the form card by deleting it
474
+ if (turnContext.activity.replyToId) {
475
+ await turnContext.deleteActivity(turnContext.activity.replyToId);
476
+ }
477
+
478
+ return;
479
+ }
480
+ await turnContext.sendActivity(
481
+ "Unable to change alert state: missing state id.",
482
+ );
483
+ return;
484
+ }
485
+
486
+ // Default fallback for unimplemented actions
487
+ await turnContext.sendActivity(
488
+ "Sorry, but the action " +
489
+ actionType +
490
+ " you requested is not implemented yet.",
491
+ );
492
+ }
493
+
494
+ private static buildAddAlertNoteCard(alertId: string): JSONObject {
495
+ return {
496
+ type: "AdaptiveCard",
497
+ $schema: "http://adaptivecards.io/schemas/adaptive-card.json",
498
+ version: "1.5",
499
+ body: [
500
+ {
501
+ type: "TextBlock",
502
+ text: "Add Alert Note",
503
+ size: "Large",
504
+ weight: "Bolder",
505
+ },
506
+ {
507
+ type: "Input.Text",
508
+ id: "note",
509
+ label: "Note",
510
+ isMultiline: true,
511
+ placeholder: "Please type in plain text or markdown.",
512
+ },
513
+ ],
514
+ actions: [
515
+ {
516
+ type: "Action.Submit",
517
+ title: "Submit",
518
+ data: {
519
+ action: MicrosoftTeamsAlertActionType.SubmitAlertNote,
520
+ actionValue: alertId,
521
+ },
522
+ },
523
+ ],
524
+ };
525
+ }
526
+
527
+ private static async buildExecuteAlertOnCallPolicyCard(
528
+ alertId: string,
529
+ projectId: ObjectID,
530
+ ): Promise<JSONObject | null> {
531
+ const onCallPolicies: Array<OnCallDutyPolicy> =
532
+ await OnCallDutyPolicyService.findBy({
533
+ query: {
534
+ projectId: projectId,
535
+ },
536
+ select: {
537
+ name: true,
538
+ _id: true,
539
+ },
540
+ props: {
541
+ isRoot: true,
542
+ },
543
+ limit: 50,
544
+ skip: 0,
545
+ });
546
+
547
+ const choices: Array<{ title: string; value: string }> = onCallPolicies
548
+ .map((policy: OnCallDutyPolicy) => {
549
+ return {
550
+ title: policy.name || "",
551
+ value: policy._id?.toString() || "",
552
+ };
553
+ })
554
+ .filter((choice: { title: string; value: string }) => {
555
+ return choice.title && choice.value;
556
+ });
557
+
558
+ if (choices.length === 0) {
559
+ return null;
560
+ }
561
+
562
+ return {
563
+ type: "AdaptiveCard",
564
+ $schema: "http://adaptivecards.io/schemas/adaptive-card.json",
565
+ version: "1.5",
566
+ body: [
567
+ {
568
+ type: "TextBlock",
569
+ text: "Execute On-Call Policy",
570
+ size: "Large",
571
+ weight: "Bolder",
572
+ },
573
+ {
574
+ type: "Input.ChoiceSet",
575
+ id: "onCallPolicy",
576
+ label: "On-Call Policy",
577
+ style: "compact",
578
+ choices: choices,
579
+ },
580
+ ],
581
+ actions: [
582
+ {
583
+ type: "Action.Submit",
584
+ title: "Execute",
585
+ data: {
586
+ action:
587
+ MicrosoftTeamsAlertActionType.SubmitExecuteAlertOnCallPolicy,
588
+ actionValue: alertId,
589
+ },
590
+ },
591
+ ],
592
+ };
593
+ }
594
+
595
+ private static async buildChangeAlertStateCard(
596
+ alertId: string,
597
+ projectId: ObjectID,
598
+ ): Promise<JSONObject> {
599
+ const alertStates: Array<AlertState> =
600
+ await AlertStateService.getAllAlertStates({
601
+ projectId: projectId,
602
+ props: {
603
+ isRoot: true,
604
+ },
605
+ });
606
+
607
+ const choices: Array<{ title: string; value: string }> = alertStates
608
+ .map((state: AlertState) => {
609
+ return {
610
+ title: state.name || "",
611
+ value: state._id?.toString() || "",
612
+ };
613
+ })
614
+ .filter((choice: { title: string; value: string }) => {
615
+ return choice.title && choice.value;
616
+ });
617
+
618
+ return {
619
+ type: "AdaptiveCard",
620
+ $schema: "http://adaptivecards.io/schemas/adaptive-card.json",
621
+ version: "1.5",
622
+ body: [
623
+ {
624
+ type: "TextBlock",
625
+ text: "Change Alert State",
626
+ size: "Large",
627
+ weight: "Bolder",
628
+ },
629
+ {
630
+ type: "Input.ChoiceSet",
631
+ id: "alertState",
632
+ label: "Alert State",
633
+ style: "compact",
634
+ choices: choices,
635
+ },
636
+ ],
637
+ actions: [
638
+ {
639
+ type: "Action.Submit",
640
+ title: "Change",
641
+ data: {
642
+ action: MicrosoftTeamsAlertActionType.SubmitChangeAlertState,
643
+ actionValue: alertId,
644
+ },
645
+ },
646
+ ],
647
+ };
648
+ }
649
+ }