@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,1102 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import Response from "../../../Response";
11
+ import MicrosoftTeamsAuthAction from "./Auth";
12
+ import { MicrosoftTeamsIncidentActionType } from "./ActionTypes";
13
+ import logger from "../../../Logger";
14
+ import ObjectID from "../../../../../Types/ObjectID";
15
+ import IncidentService from "../../../../Services/IncidentService";
16
+ import Incident from "../../../../../Models/DatabaseModels/Incident";
17
+ import CaptureSpan from "../../../Telemetry/CaptureSpan";
18
+ import IncidentPublicNoteService from "../../../../Services/IncidentPublicNoteService";
19
+ import IncidentInternalNoteService from "../../../../Services/IncidentInternalNoteService";
20
+ import OnCallDutyPolicyService from "../../../../Services/OnCallDutyPolicyService";
21
+ import IncidentStateService from "../../../../Services/IncidentStateService";
22
+ import UserNotificationEventType from "../../../../../Types/UserNotification/UserNotificationEventType";
23
+ import OnCallDutyPolicy from "../../../../../Models/DatabaseModels/OnCallDutyPolicy";
24
+ import IncidentSeverityService from "../../../../Services/IncidentSeverityService";
25
+ import MonitorService from "../../../../Services/MonitorService";
26
+ import Monitor from "../../../../../Models/DatabaseModels/Monitor";
27
+ import MonitorStatusService from "../../../../Services/MonitorStatusService";
28
+ import LabelService from "../../../../Services/LabelService";
29
+ import Label from "../../../../../Models/DatabaseModels/Label";
30
+ import SortOrder from "../../../../../Types/BaseDatabase/SortOrder";
31
+ import { LIMIT_PER_PROJECT } from "../../../../../Types/Database/LimitMax";
32
+ import BadDataException from "../../../../../Types/Exception/BadDataException";
33
+ export default class MicrosoftTeamsIncidentActions {
34
+ static isIncidentAction(data) {
35
+ // Check if the action is related to incidents
36
+ return (data.actionType === MicrosoftTeamsIncidentActionType.AckIncident ||
37
+ data.actionType === MicrosoftTeamsIncidentActionType.ResolveIncident ||
38
+ data.actionType === MicrosoftTeamsIncidentActionType.ViewIncident ||
39
+ data.actionType === MicrosoftTeamsIncidentActionType.IncidentCreated ||
40
+ data.actionType ===
41
+ MicrosoftTeamsIncidentActionType.IncidentStateChanged ||
42
+ data.actionType ===
43
+ MicrosoftTeamsIncidentActionType.ViewAddIncidentNote ||
44
+ data.actionType === MicrosoftTeamsIncidentActionType.SubmitIncidentNote ||
45
+ data.actionType ===
46
+ MicrosoftTeamsIncidentActionType.ExecuteIncidentOnCallPolicy ||
47
+ data.actionType ===
48
+ MicrosoftTeamsIncidentActionType.ViewExecuteIncidentOnCallPolicy ||
49
+ data.actionType ===
50
+ MicrosoftTeamsIncidentActionType.SubmitExecuteIncidentOnCallPolicy ||
51
+ data.actionType ===
52
+ MicrosoftTeamsIncidentActionType.ViewChangeIncidentState ||
53
+ data.actionType ===
54
+ MicrosoftTeamsIncidentActionType.SubmitChangeIncidentState ||
55
+ data.actionType === MicrosoftTeamsIncidentActionType.NewIncident ||
56
+ data.actionType === MicrosoftTeamsIncidentActionType.SubmitNewIncident);
57
+ }
58
+ static async handleIncidentAction(data) {
59
+ const { teamsRequest, action } = data;
60
+ logger.debug("Handling Microsoft Teams incident action:");
61
+ logger.debug(action);
62
+ try {
63
+ switch (action.actionType) {
64
+ case MicrosoftTeamsIncidentActionType.AckIncident:
65
+ await this.acknowledgeIncident({
66
+ teamsRequest,
67
+ action,
68
+ });
69
+ break;
70
+ case MicrosoftTeamsIncidentActionType.ResolveIncident:
71
+ await this.resolveIncident({
72
+ teamsRequest,
73
+ action,
74
+ });
75
+ break;
76
+ case MicrosoftTeamsIncidentActionType.ViewIncident:
77
+ // This is handled by opening the URL directly
78
+ break;
79
+ case MicrosoftTeamsIncidentActionType.NewIncident:
80
+ return await this.showNewIncidentCard(data);
81
+ case MicrosoftTeamsIncidentActionType.SubmitNewIncident:
82
+ /*
83
+ * This is handled by handleBotIncidentAction through bot framework
84
+ * Don't process it here to avoid duplicate messages
85
+ */
86
+ break;
87
+ default:
88
+ logger.debug("Unhandled incident action: " + action.actionType);
89
+ break;
90
+ }
91
+ }
92
+ catch (error) {
93
+ logger.error("Error handling Microsoft Teams incident action:");
94
+ logger.error(error);
95
+ }
96
+ // Send empty response to Teams
97
+ Response.sendTextResponse(data.req, data.res, "");
98
+ }
99
+ static async acknowledgeIncident(data) {
100
+ var _a;
101
+ const incidentId = data.action.actionValue || "";
102
+ if (!incidentId) {
103
+ logger.error("No incident ID provided for acknowledge action");
104
+ return;
105
+ }
106
+ logger.debug("Acknowledging incident: " + incidentId);
107
+ try {
108
+ // Get the incident
109
+ const incident = await IncidentService.findOneBy({
110
+ query: {
111
+ _id: incidentId,
112
+ projectId: data.teamsRequest.projectId,
113
+ },
114
+ select: {
115
+ _id: true,
116
+ projectId: true,
117
+ currentIncidentState: {
118
+ _id: true,
119
+ name: true,
120
+ isAcknowledgedState: true,
121
+ },
122
+ },
123
+ props: {
124
+ isRoot: true,
125
+ },
126
+ });
127
+ if (!incident) {
128
+ logger.error("Incident not found: " + incidentId);
129
+ return;
130
+ }
131
+ // Check if already acknowledged
132
+ if ((_a = incident.currentIncidentState) === null || _a === void 0 ? void 0 : _a.isAcknowledgedState) {
133
+ logger.debug("Incident is already acknowledged");
134
+ return;
135
+ }
136
+ // Acknowledge the incident
137
+ const oneUptimeUserId = await MicrosoftTeamsAuthAction.getOneUptimeUserIdFromTeamsUserId({
138
+ teamsUserId: data.teamsRequest.userId || "",
139
+ projectId: data.teamsRequest.projectId,
140
+ });
141
+ await IncidentService.acknowledgeIncident(new ObjectID(incidentId), oneUptimeUserId);
142
+ logger.debug("Incident acknowledged successfully");
143
+ }
144
+ catch (error) {
145
+ logger.error("Error acknowledging incident:");
146
+ logger.error(error);
147
+ }
148
+ }
149
+ static async resolveIncident(data) {
150
+ var _a;
151
+ const incidentId = data.action.actionValue || "";
152
+ if (!incidentId) {
153
+ logger.error("No incident ID provided for resolve action");
154
+ return;
155
+ }
156
+ logger.debug("Resolving incident: " + incidentId);
157
+ try {
158
+ // Get the incident
159
+ const incident = await IncidentService.findOneBy({
160
+ query: {
161
+ _id: incidentId,
162
+ projectId: data.teamsRequest.projectId,
163
+ },
164
+ select: {
165
+ _id: true,
166
+ projectId: true,
167
+ currentIncidentState: {
168
+ _id: true,
169
+ name: true,
170
+ isResolvedState: true,
171
+ },
172
+ },
173
+ props: {
174
+ isRoot: true,
175
+ },
176
+ });
177
+ if (!incident) {
178
+ logger.error("Incident not found: " + incidentId);
179
+ return;
180
+ }
181
+ // Check if already resolved
182
+ if ((_a = incident.currentIncidentState) === null || _a === void 0 ? void 0 : _a.isResolvedState) {
183
+ logger.debug("Incident is already resolved");
184
+ return;
185
+ }
186
+ // Resolve the incident
187
+ const oneUptimeUserId = await MicrosoftTeamsAuthAction.getOneUptimeUserIdFromTeamsUserId({
188
+ teamsUserId: data.teamsRequest.userId || "",
189
+ projectId: data.teamsRequest.projectId,
190
+ });
191
+ await IncidentService.resolveIncident(new ObjectID(incidentId), oneUptimeUserId);
192
+ logger.debug("Incident resolved successfully");
193
+ }
194
+ catch (error) {
195
+ logger.error("Error resolving incident:");
196
+ logger.error(error);
197
+ }
198
+ }
199
+ static async handleBotIncidentAction(data) {
200
+ var _a, _b, _c;
201
+ const { actionType, actionValue, value, projectId, oneUptimeUserId, turnContext, } = data;
202
+ if (actionType === MicrosoftTeamsIncidentActionType.AckIncident) {
203
+ if (!actionValue) {
204
+ await turnContext.sendActivity("Unable to acknowledge: missing incident id.");
205
+ return;
206
+ }
207
+ await IncidentService.acknowledgeIncident(new ObjectID(actionValue), oneUptimeUserId);
208
+ await turnContext.sendActivity("✅ Incident acknowledged.");
209
+ return;
210
+ }
211
+ if (actionType === MicrosoftTeamsIncidentActionType.ResolveIncident) {
212
+ if (!actionValue) {
213
+ await turnContext.sendActivity("Unable to resolve: missing incident id.");
214
+ return;
215
+ }
216
+ await IncidentService.resolveIncident(new ObjectID(actionValue), oneUptimeUserId);
217
+ await turnContext.sendActivity("✅ Incident resolved.");
218
+ return;
219
+ }
220
+ if (actionType === MicrosoftTeamsIncidentActionType.ViewIncident) {
221
+ if (!actionValue) {
222
+ await turnContext.sendActivity("Unable to view incident: missing incident id.");
223
+ return;
224
+ }
225
+ const incident = await IncidentService.findOneBy({
226
+ query: {
227
+ _id: actionValue,
228
+ projectId: projectId,
229
+ },
230
+ select: {
231
+ _id: true,
232
+ title: true,
233
+ description: true,
234
+ currentIncidentState: {
235
+ name: true,
236
+ },
237
+ incidentSeverity: {
238
+ name: true,
239
+ },
240
+ createdAt: true,
241
+ },
242
+ props: {
243
+ isRoot: true,
244
+ },
245
+ });
246
+ if (!incident) {
247
+ await turnContext.sendActivity("Incident not found.");
248
+ return;
249
+ }
250
+ const message = `**Incident Details**\n\n**Title:** ${incident.title}\n**Description:** ${incident.description || "No description"}\n**State:** ${((_a = incident.currentIncidentState) === null || _a === void 0 ? void 0 : _a.name) || "Unknown"}\n**Severity:** ${((_b = incident.incidentSeverity) === null || _b === void 0 ? void 0 : _b.name) || "Unknown"}\n**Created At:** ${incident.createdAt ? new Date(incident.createdAt).toLocaleString() : "Unknown"}`;
251
+ await turnContext.sendActivity(message);
252
+ return;
253
+ }
254
+ if (actionType === MicrosoftTeamsIncidentActionType.ViewAddIncidentNote) {
255
+ if (!actionValue) {
256
+ await turnContext.sendActivity("Unable to add note: missing incident id.");
257
+ return;
258
+ }
259
+ // Send the input card
260
+ const card = this.buildAddIncidentNoteCard(actionValue);
261
+ await turnContext.sendActivity({
262
+ attachments: [
263
+ {
264
+ contentType: "application/vnd.microsoft.card.adaptive",
265
+ content: card,
266
+ },
267
+ ],
268
+ });
269
+ return;
270
+ }
271
+ if (actionType === MicrosoftTeamsIncidentActionType.SubmitIncidentNote) {
272
+ if (!actionValue) {
273
+ await turnContext.sendActivity("Unable to add note: missing incident id.");
274
+ return;
275
+ }
276
+ // Check if form data is provided
277
+ const noteType = value["noteType"];
278
+ const note = value["note"];
279
+ if (noteType && note) {
280
+ // Submit the note
281
+ const incidentId = new ObjectID(actionValue);
282
+ if (noteType === "public") {
283
+ await IncidentPublicNoteService.addNote({
284
+ incidentId: incidentId,
285
+ note: note.toString(),
286
+ projectId: projectId,
287
+ userId: oneUptimeUserId,
288
+ });
289
+ }
290
+ else if (noteType === "private") {
291
+ await IncidentInternalNoteService.addNote({
292
+ incidentId: incidentId,
293
+ note: note.toString(),
294
+ projectId: projectId,
295
+ userId: oneUptimeUserId,
296
+ });
297
+ }
298
+ await turnContext.sendActivity("✅ Note added successfully.");
299
+ // Hide the form card by deleting it
300
+ if (turnContext.activity.replyToId) {
301
+ await turnContext.deleteActivity(turnContext.activity.replyToId);
302
+ }
303
+ return;
304
+ }
305
+ await turnContext.sendActivity("Unable to add note: missing note data.");
306
+ return;
307
+ }
308
+ if (actionType ===
309
+ MicrosoftTeamsIncidentActionType.ViewExecuteIncidentOnCallPolicy) {
310
+ if (!actionValue) {
311
+ await turnContext.sendActivity("Unable to execute on-call policy: missing incident id.");
312
+ return;
313
+ }
314
+ // Send the input card
315
+ const card = await this.buildExecuteOnCallPolicyCard(actionValue, projectId);
316
+ if (!card) {
317
+ await turnContext.sendActivity("No on-call policies found in the project");
318
+ return;
319
+ }
320
+ await turnContext.sendActivity({
321
+ attachments: [
322
+ {
323
+ contentType: "application/vnd.microsoft.card.adaptive",
324
+ content: card,
325
+ },
326
+ ],
327
+ });
328
+ return;
329
+ }
330
+ if (actionType ===
331
+ MicrosoftTeamsIncidentActionType.SubmitExecuteIncidentOnCallPolicy) {
332
+ if (!actionValue) {
333
+ await turnContext.sendActivity("Unable to execute on-call policy: missing incident id.");
334
+ return;
335
+ }
336
+ // Check if form data is provided
337
+ const onCallPolicyId = value["onCallPolicy"];
338
+ if (onCallPolicyId) {
339
+ // Execute the policy
340
+ const incidentId = new ObjectID(actionValue);
341
+ await OnCallDutyPolicyService.executePolicy(new ObjectID(onCallPolicyId.toString()), {
342
+ triggeredByIncidentId: incidentId,
343
+ userNotificationEventType: UserNotificationEventType.IncidentCreated,
344
+ });
345
+ await turnContext.sendActivity("✅ On-call policy executed successfully.");
346
+ // Hide the form card by deleting it
347
+ if (turnContext.activity.replyToId) {
348
+ await turnContext.deleteActivity(turnContext.activity.replyToId);
349
+ }
350
+ return;
351
+ }
352
+ await turnContext.sendActivity("Unable to execute on-call policy: missing policy id.");
353
+ return;
354
+ }
355
+ if (actionType === MicrosoftTeamsIncidentActionType.ViewChangeIncidentState) {
356
+ if (!actionValue) {
357
+ await turnContext.sendActivity("Unable to change incident state: missing incident id.");
358
+ return;
359
+ }
360
+ // Send the input card
361
+ const card = await this.buildChangeIncidentStateCard(actionValue, projectId);
362
+ await turnContext.sendActivity({
363
+ attachments: [
364
+ {
365
+ contentType: "application/vnd.microsoft.card.adaptive",
366
+ content: card,
367
+ },
368
+ ],
369
+ });
370
+ return;
371
+ }
372
+ if (actionType === MicrosoftTeamsIncidentActionType.SubmitChangeIncidentState) {
373
+ if (!actionValue) {
374
+ await turnContext.sendActivity("Unable to change incident state: missing incident id.");
375
+ return;
376
+ }
377
+ // Check if form data is provided
378
+ const incidentStateId = value["incidentState"];
379
+ if (incidentStateId) {
380
+ // Update the state
381
+ const incidentId = new ObjectID(actionValue);
382
+ await IncidentService.updateOneById({
383
+ id: incidentId,
384
+ data: {
385
+ currentIncidentStateId: new ObjectID(incidentStateId.toString()),
386
+ },
387
+ props: {
388
+ isRoot: true,
389
+ },
390
+ });
391
+ await turnContext.sendActivity("✅ Incident state changed successfully.");
392
+ // Hide the form card by deleting it
393
+ if (turnContext.activity.replyToId) {
394
+ await turnContext.deleteActivity(turnContext.activity.replyToId);
395
+ }
396
+ return;
397
+ }
398
+ await turnContext.sendActivity("Unable to change incident state: missing state id.");
399
+ return;
400
+ }
401
+ if (actionType === MicrosoftTeamsIncidentActionType.SubmitNewIncident) {
402
+ // Handle new incident submission
403
+ const title = value["incidentTitle"] || "";
404
+ const description = value["incidentDescription"] || "";
405
+ const severityId = value["incidentSeverity"] || "";
406
+ const monitorIds = value["incidentMonitors"] || "";
407
+ const monitorStatusId = value["monitorStatus"] || "";
408
+ const labelIds = value["labels"] || "";
409
+ const onCallPolicyIds = value["onCallDutyPolicies"] || "";
410
+ if (!title || !description || !severityId) {
411
+ await turnContext.sendActivity("Unable to create incident: missing required fields (title, description, or severity).");
412
+ return;
413
+ }
414
+ try {
415
+ // Create the incident
416
+ const incident = new Incident();
417
+ incident.title = title;
418
+ incident.description = description;
419
+ incident.projectId = projectId;
420
+ incident.createdByUserId = oneUptimeUserId;
421
+ incident.incidentSeverityId = new ObjectID(severityId);
422
+ incident.rootCause = `Incident created via Microsoft Teams`;
423
+ // Parse monitors
424
+ if (monitorIds) {
425
+ const monitorIdArray = monitorIds
426
+ .split(",")
427
+ .map((id) => {
428
+ return id.trim();
429
+ })
430
+ .filter((id) => {
431
+ return id;
432
+ });
433
+ if (monitorIdArray.length > 0) {
434
+ incident.monitors = monitorIdArray.map((id) => {
435
+ const monitor = new Monitor();
436
+ monitor.id = new ObjectID(id);
437
+ return monitor;
438
+ });
439
+ }
440
+ }
441
+ // Parse labels
442
+ if (labelIds) {
443
+ const labelIdArray = labelIds
444
+ .split(",")
445
+ .map((id) => {
446
+ return id.trim();
447
+ })
448
+ .filter((id) => {
449
+ return id;
450
+ });
451
+ if (labelIdArray.length > 0) {
452
+ incident.labels = labelIdArray.map((id) => {
453
+ const label = new Label();
454
+ label.id = new ObjectID(id);
455
+ return label;
456
+ });
457
+ }
458
+ }
459
+ // Parse on-call policies
460
+ if (onCallPolicyIds) {
461
+ const policyIdArray = onCallPolicyIds
462
+ .split(",")
463
+ .map((id) => {
464
+ return id.trim();
465
+ })
466
+ .filter((id) => {
467
+ return id;
468
+ });
469
+ if (policyIdArray.length > 0) {
470
+ incident.onCallDutyPolicies = policyIdArray.map((id) => {
471
+ const policy = new OnCallDutyPolicy();
472
+ policy.id = new ObjectID(id);
473
+ return policy;
474
+ });
475
+ }
476
+ }
477
+ // Save the incident
478
+ const createdIncident = await IncidentService.create({
479
+ data: incident,
480
+ props: {
481
+ isRoot: true,
482
+ },
483
+ });
484
+ logger.debug("Incident created successfully: " + ((_c = createdIncident.id) === null || _c === void 0 ? void 0 : _c.toString()));
485
+ // Update monitor status if specified
486
+ if (monitorStatusId && monitorIds) {
487
+ const monitorIdArray = monitorIds
488
+ .split(",")
489
+ .map((id) => {
490
+ return id.trim();
491
+ })
492
+ .filter((id) => {
493
+ return id;
494
+ });
495
+ for (const monitorId of monitorIdArray) {
496
+ await MonitorService.updateOneById({
497
+ id: new ObjectID(monitorId),
498
+ data: {
499
+ currentMonitorStatusId: new ObjectID(monitorStatusId),
500
+ },
501
+ props: {
502
+ isRoot: true,
503
+ },
504
+ });
505
+ }
506
+ }
507
+ // Hide the form card by deleting it first
508
+ if (turnContext.activity.replyToId) {
509
+ await turnContext.deleteActivity(turnContext.activity.replyToId);
510
+ }
511
+ // Get the incident link
512
+ const incidentLink = await IncidentService.getIncidentLinkInDashboard(projectId, createdIncident.id);
513
+ // Send confirmation message as a new message in the thread
514
+ await turnContext.sendActivity(`✅ Incident created successfully!\n\nView incident: ${incidentLink.toString()}`);
515
+ return;
516
+ }
517
+ catch (error) {
518
+ logger.error("Error creating incident from Microsoft Teams:");
519
+ logger.error(error);
520
+ await turnContext.sendActivity("❌ Failed to create incident. Please try again.");
521
+ return;
522
+ }
523
+ }
524
+ // Default fallback for unimplemented actions
525
+ await turnContext.sendActivity("Sorry, but the action " +
526
+ actionType +
527
+ " you requested is not implemented yet.");
528
+ }
529
+ static buildAddIncidentNoteCard(incidentId) {
530
+ return {
531
+ type: "AdaptiveCard",
532
+ $schema: "http://adaptivecards.io/schemas/adaptive-card.json",
533
+ version: "1.5",
534
+ body: [
535
+ {
536
+ type: "TextBlock",
537
+ text: "Add Incident Note",
538
+ size: "Large",
539
+ weight: "Bolder",
540
+ },
541
+ {
542
+ type: "Input.ChoiceSet",
543
+ id: "noteType",
544
+ label: "Note Type",
545
+ style: "compact",
546
+ value: "public",
547
+ choices: [
548
+ {
549
+ title: "Public Note (Will be posted on Status Page)",
550
+ value: "public",
551
+ },
552
+ {
553
+ title: "Private Note (Only visible to team members)",
554
+ value: "private",
555
+ },
556
+ ],
557
+ },
558
+ {
559
+ type: "Input.Text",
560
+ id: "note",
561
+ label: "Note",
562
+ isMultiline: true,
563
+ placeholder: "Please type in plain text or markdown.",
564
+ },
565
+ ],
566
+ actions: [
567
+ {
568
+ type: "Action.Submit",
569
+ title: "Submit",
570
+ data: {
571
+ action: MicrosoftTeamsIncidentActionType.SubmitIncidentNote,
572
+ actionValue: incidentId,
573
+ },
574
+ },
575
+ ],
576
+ };
577
+ }
578
+ static async buildExecuteOnCallPolicyCard(incidentId, projectId) {
579
+ const onCallPolicies = await OnCallDutyPolicyService.findBy({
580
+ query: {
581
+ projectId: projectId,
582
+ },
583
+ select: {
584
+ name: true,
585
+ _id: true,
586
+ },
587
+ props: {
588
+ isRoot: true,
589
+ },
590
+ limit: 50,
591
+ skip: 0,
592
+ });
593
+ const choices = onCallPolicies
594
+ .map((policy) => {
595
+ var _a;
596
+ return {
597
+ title: policy.name || "",
598
+ value: ((_a = policy._id) === null || _a === void 0 ? void 0 : _a.toString()) || "",
599
+ };
600
+ })
601
+ .filter((choice) => {
602
+ return choice.title && choice.value;
603
+ });
604
+ if (choices.length === 0) {
605
+ return null;
606
+ }
607
+ return {
608
+ type: "AdaptiveCard",
609
+ $schema: "http://adaptivecards.io/schemas/adaptive-card.json",
610
+ version: "1.5",
611
+ body: [
612
+ {
613
+ type: "TextBlock",
614
+ text: "Execute On-Call Policy",
615
+ size: "Large",
616
+ weight: "Bolder",
617
+ },
618
+ {
619
+ type: "Input.ChoiceSet",
620
+ id: "onCallPolicy",
621
+ label: "On-Call Policy",
622
+ style: "compact",
623
+ choices: choices,
624
+ },
625
+ ],
626
+ actions: [
627
+ {
628
+ type: "Action.Submit",
629
+ title: "Execute",
630
+ data: {
631
+ action: MicrosoftTeamsIncidentActionType.SubmitExecuteIncidentOnCallPolicy,
632
+ actionValue: incidentId,
633
+ },
634
+ },
635
+ ],
636
+ };
637
+ }
638
+ static async buildChangeIncidentStateCard(incidentId, projectId) {
639
+ const incidentStates = await IncidentStateService.getAllIncidentStates({
640
+ projectId: projectId,
641
+ props: {
642
+ isRoot: true,
643
+ },
644
+ });
645
+ const choices = incidentStates
646
+ .map((state) => {
647
+ var _a;
648
+ return {
649
+ title: state.name || "",
650
+ value: ((_a = state._id) === null || _a === void 0 ? void 0 : _a.toString()) || "",
651
+ };
652
+ })
653
+ .filter((choice) => {
654
+ return choice.title && choice.value;
655
+ });
656
+ return {
657
+ type: "AdaptiveCard",
658
+ $schema: "http://adaptivecards.io/schemas/adaptive-card.json",
659
+ version: "1.5",
660
+ body: [
661
+ {
662
+ type: "TextBlock",
663
+ text: "Change Incident State",
664
+ size: "Large",
665
+ weight: "Bolder",
666
+ },
667
+ {
668
+ type: "Input.ChoiceSet",
669
+ id: "incidentState",
670
+ label: "Incident State",
671
+ style: "compact",
672
+ choices: choices,
673
+ },
674
+ ],
675
+ actions: [
676
+ {
677
+ type: "Action.Submit",
678
+ title: "Change",
679
+ data: {
680
+ action: MicrosoftTeamsIncidentActionType.SubmitChangeIncidentState,
681
+ actionValue: incidentId,
682
+ },
683
+ },
684
+ ],
685
+ };
686
+ }
687
+ static async showNewIncidentCard(data) {
688
+ const { teamsRequest, req, res } = data;
689
+ logger.debug("Showing new incident card for Microsoft Teams");
690
+ // Send empty response first
691
+ Response.sendTextResponse(req, res, "");
692
+ if (!teamsRequest.projectId) {
693
+ logger.error("Project ID not found in Teams request");
694
+ return;
695
+ }
696
+ // Build the adaptive card with form fields
697
+ const card = await this.buildNewIncidentCard(teamsRequest.projectId);
698
+ /*
699
+ * Send card as a message (note: in real Teams bot, this would be sent via TurnContext)
700
+ * For now, we'll just log it. The actual sending will be done through the bot framework
701
+ */
702
+ logger.debug("New incident card built:");
703
+ logger.debug(JSON.stringify(card, null, 2));
704
+ }
705
+ static async submitNewIncident(data) {
706
+ var _a;
707
+ const { teamsRequest, req, res } = data;
708
+ const { userId, projectId } = teamsRequest;
709
+ logger.debug("Submitting new incident from Microsoft Teams");
710
+ if (!projectId) {
711
+ return Response.sendErrorResponse(req, res, new BadDataException("Invalid Project ID"));
712
+ }
713
+ if (!userId) {
714
+ return Response.sendErrorResponse(req, res, new BadDataException("Invalid User ID"));
715
+ }
716
+ // Send early response
717
+ Response.sendTextResponse(req, res, "");
718
+ // Extract form data from the payload
719
+ const payload = teamsRequest.payload || {};
720
+ const value = payload["value"] || {};
721
+ const title = value["incidentTitle"] || "";
722
+ const description = value["incidentDescription"] || "";
723
+ const severityId = value["incidentSeverity"] || "";
724
+ const monitorIds = value["incidentMonitors"] || "";
725
+ const monitorStatusId = value["monitorStatus"] || "";
726
+ const labelIds = value["labels"] || "";
727
+ const onCallPolicyIds = value["onCallDutyPolicies"] || "";
728
+ if (!title || !description || !severityId) {
729
+ logger.error("Missing required fields for incident creation");
730
+ return;
731
+ }
732
+ try {
733
+ // Get OneUptime user ID
734
+ const oneUptimeUserId = await MicrosoftTeamsAuthAction.getOneUptimeUserIdFromTeamsUserId({
735
+ teamsUserId: userId,
736
+ projectId: projectId,
737
+ });
738
+ // Create the incident
739
+ const incident = new Incident();
740
+ incident.title = title;
741
+ incident.description = description;
742
+ incident.projectId = projectId;
743
+ incident.createdByUserId = oneUptimeUserId;
744
+ incident.incidentSeverityId = new ObjectID(severityId);
745
+ incident.rootCause = `Incident created via Microsoft Teams`;
746
+ // Parse monitors
747
+ if (monitorIds) {
748
+ const monitorIdArray = monitorIds
749
+ .split(",")
750
+ .map((id) => {
751
+ return id.trim();
752
+ })
753
+ .filter((id) => {
754
+ return id;
755
+ });
756
+ if (monitorIdArray.length > 0) {
757
+ incident.monitors = monitorIdArray.map((id) => {
758
+ const monitor = new Monitor();
759
+ monitor.id = new ObjectID(id);
760
+ return monitor;
761
+ });
762
+ }
763
+ }
764
+ // Parse labels
765
+ if (labelIds) {
766
+ const labelIdArray = labelIds
767
+ .split(",")
768
+ .map((id) => {
769
+ return id.trim();
770
+ })
771
+ .filter((id) => {
772
+ return id;
773
+ });
774
+ if (labelIdArray.length > 0) {
775
+ incident.labels = labelIdArray.map((id) => {
776
+ const label = new Label();
777
+ label.id = new ObjectID(id);
778
+ return label;
779
+ });
780
+ }
781
+ }
782
+ // Parse on-call policies
783
+ if (onCallPolicyIds) {
784
+ const policyIdArray = onCallPolicyIds
785
+ .split(",")
786
+ .map((id) => {
787
+ return id.trim();
788
+ })
789
+ .filter((id) => {
790
+ return id;
791
+ });
792
+ if (policyIdArray.length > 0) {
793
+ incident.onCallDutyPolicies = policyIdArray.map((id) => {
794
+ const policy = new OnCallDutyPolicy();
795
+ policy.id = new ObjectID(id);
796
+ return policy;
797
+ });
798
+ }
799
+ }
800
+ // Save the incident
801
+ const createdIncident = await IncidentService.create({
802
+ data: incident,
803
+ props: {
804
+ isRoot: true,
805
+ },
806
+ });
807
+ logger.debug("Incident created successfully: " + ((_a = createdIncident.id) === null || _a === void 0 ? void 0 : _a.toString()));
808
+ // Update monitor status if specified
809
+ if (monitorStatusId && monitorIds) {
810
+ const monitorIdArray = monitorIds
811
+ .split(",")
812
+ .map((id) => {
813
+ return id.trim();
814
+ })
815
+ .filter((id) => {
816
+ return id;
817
+ });
818
+ for (const monitorId of monitorIdArray) {
819
+ await MonitorService.updateOneById({
820
+ id: new ObjectID(monitorId),
821
+ data: {
822
+ currentMonitorStatusId: new ObjectID(monitorStatusId),
823
+ },
824
+ props: {
825
+ isRoot: true,
826
+ },
827
+ });
828
+ }
829
+ }
830
+ logger.debug("New incident created from Microsoft Teams successfully");
831
+ }
832
+ catch (error) {
833
+ logger.error("Error creating incident from Microsoft Teams:");
834
+ logger.error(error);
835
+ }
836
+ }
837
+ static async buildNewIncidentCard(projectId) {
838
+ // Fetch severities
839
+ const severities = await IncidentSeverityService.findBy({
840
+ query: {
841
+ projectId: projectId,
842
+ },
843
+ sort: {
844
+ order: SortOrder.Ascending,
845
+ },
846
+ skip: 0,
847
+ limit: LIMIT_PER_PROJECT,
848
+ select: {
849
+ name: true,
850
+ },
851
+ props: {
852
+ isRoot: true,
853
+ },
854
+ });
855
+ const severityChoices = severities.map((severity) => {
856
+ var _a;
857
+ return {
858
+ title: severity.name || "",
859
+ value: ((_a = severity._id) === null || _a === void 0 ? void 0 : _a.toString()) || "",
860
+ };
861
+ });
862
+ // Fetch monitors
863
+ const monitors = await MonitorService.findBy({
864
+ query: {
865
+ projectId: projectId,
866
+ },
867
+ select: {
868
+ name: true,
869
+ },
870
+ props: {
871
+ isRoot: true,
872
+ },
873
+ limit: LIMIT_PER_PROJECT,
874
+ skip: 0,
875
+ });
876
+ const monitorChoices = monitors
877
+ .map((monitor) => {
878
+ var _a;
879
+ return {
880
+ title: monitor.name || "",
881
+ value: ((_a = monitor._id) === null || _a === void 0 ? void 0 : _a.toString()) || "",
882
+ };
883
+ })
884
+ .filter((choice) => {
885
+ return choice.title && choice.value;
886
+ });
887
+ // Fetch monitor statuses
888
+ const monitorStatuses = await MonitorStatusService.findBy({
889
+ query: {
890
+ projectId: projectId,
891
+ },
892
+ select: {
893
+ name: true,
894
+ },
895
+ props: {
896
+ isRoot: true,
897
+ },
898
+ sort: {
899
+ priority: SortOrder.Ascending,
900
+ },
901
+ limit: LIMIT_PER_PROJECT,
902
+ skip: 0,
903
+ });
904
+ const monitorStatusChoices = monitorStatuses
905
+ .map((status) => {
906
+ var _a;
907
+ return {
908
+ title: status.name || "",
909
+ value: ((_a = status._id) === null || _a === void 0 ? void 0 : _a.toString()) || "",
910
+ };
911
+ })
912
+ .filter((choice) => {
913
+ return choice.title && choice.value;
914
+ });
915
+ // Fetch labels
916
+ const labels = await LabelService.findBy({
917
+ query: {
918
+ projectId: projectId,
919
+ },
920
+ select: {
921
+ name: true,
922
+ },
923
+ props: {
924
+ isRoot: true,
925
+ },
926
+ limit: LIMIT_PER_PROJECT,
927
+ skip: 0,
928
+ });
929
+ const labelChoices = labels
930
+ .map((label) => {
931
+ var _a;
932
+ return {
933
+ title: label.name || "",
934
+ value: ((_a = label._id) === null || _a === void 0 ? void 0 : _a.toString()) || "",
935
+ };
936
+ })
937
+ .filter((choice) => {
938
+ return choice.title && choice.value;
939
+ });
940
+ // Fetch on-call policies
941
+ const onCallPolicies = await OnCallDutyPolicyService.findBy({
942
+ query: {
943
+ projectId: projectId,
944
+ },
945
+ select: {
946
+ name: true,
947
+ },
948
+ props: {
949
+ isRoot: true,
950
+ },
951
+ limit: LIMIT_PER_PROJECT,
952
+ skip: 0,
953
+ });
954
+ const onCallPolicyChoices = onCallPolicies
955
+ .map((policy) => {
956
+ var _a;
957
+ return {
958
+ title: policy.name || "",
959
+ value: ((_a = policy._id) === null || _a === void 0 ? void 0 : _a.toString()) || "",
960
+ };
961
+ })
962
+ .filter((choice) => {
963
+ return choice.title && choice.value;
964
+ });
965
+ // Build the card
966
+ const bodyElements = [
967
+ {
968
+ type: "TextBlock",
969
+ text: "Create New Incident",
970
+ size: "Large",
971
+ weight: "Bolder",
972
+ },
973
+ {
974
+ type: "Input.Text",
975
+ id: "incidentTitle",
976
+ label: "Incident Title",
977
+ placeholder: "Enter incident title",
978
+ isRequired: true,
979
+ },
980
+ {
981
+ type: "Input.Text",
982
+ id: "incidentDescription",
983
+ label: "Incident Description",
984
+ placeholder: "Enter incident description",
985
+ isMultiline: true,
986
+ isRequired: true,
987
+ },
988
+ ];
989
+ // Add severity dropdown if we have severities
990
+ if (severityChoices.length > 0) {
991
+ bodyElements.push({
992
+ type: "Input.ChoiceSet",
993
+ id: "incidentSeverity",
994
+ label: "Incident Severity",
995
+ style: "compact",
996
+ isRequired: true,
997
+ choices: severityChoices,
998
+ });
999
+ }
1000
+ // Add monitor multi-select if we have monitors
1001
+ if (monitorChoices.length > 0) {
1002
+ bodyElements.push({
1003
+ type: "Input.ChoiceSet",
1004
+ id: "incidentMonitors",
1005
+ label: "Affected Monitors (Optional)",
1006
+ style: "compact",
1007
+ isMultiSelect: true,
1008
+ choices: monitorChoices,
1009
+ });
1010
+ }
1011
+ // Add monitor status dropdown if we have statuses and monitors
1012
+ if (monitorStatusChoices.length > 0 && monitorChoices.length > 0) {
1013
+ bodyElements.push({
1014
+ type: "Input.ChoiceSet",
1015
+ id: "monitorStatus",
1016
+ label: "Change Monitor Status To (Optional)",
1017
+ style: "compact",
1018
+ choices: monitorStatusChoices,
1019
+ });
1020
+ }
1021
+ // Add on-call policy multi-select if we have policies
1022
+ if (onCallPolicyChoices.length > 0) {
1023
+ bodyElements.push({
1024
+ type: "Input.ChoiceSet",
1025
+ id: "onCallDutyPolicies",
1026
+ label: "Execute On-Call Policies (Optional)",
1027
+ style: "compact",
1028
+ isMultiSelect: true,
1029
+ choices: onCallPolicyChoices,
1030
+ });
1031
+ }
1032
+ // Add labels multi-select if we have labels
1033
+ if (labelChoices.length > 0) {
1034
+ bodyElements.push({
1035
+ type: "Input.ChoiceSet",
1036
+ id: "labels",
1037
+ label: "Labels (Optional)",
1038
+ style: "compact",
1039
+ isMultiSelect: true,
1040
+ choices: labelChoices,
1041
+ });
1042
+ }
1043
+ return {
1044
+ type: "AdaptiveCard",
1045
+ $schema: "http://adaptivecards.io/schemas/adaptive-card.json",
1046
+ version: "1.5",
1047
+ body: bodyElements,
1048
+ actions: [
1049
+ {
1050
+ type: "Action.Submit",
1051
+ title: "Create Incident",
1052
+ data: {
1053
+ action: MicrosoftTeamsIncidentActionType.SubmitNewIncident,
1054
+ },
1055
+ },
1056
+ ],
1057
+ };
1058
+ }
1059
+ }
1060
+ __decorate([
1061
+ CaptureSpan(),
1062
+ __metadata("design:type", Function),
1063
+ __metadata("design:paramtypes", [Object]),
1064
+ __metadata("design:returntype", Boolean)
1065
+ ], MicrosoftTeamsIncidentActions, "isIncidentAction", null);
1066
+ __decorate([
1067
+ CaptureSpan(),
1068
+ __metadata("design:type", Function),
1069
+ __metadata("design:paramtypes", [Object]),
1070
+ __metadata("design:returntype", Promise)
1071
+ ], MicrosoftTeamsIncidentActions, "handleIncidentAction", null);
1072
+ __decorate([
1073
+ CaptureSpan(),
1074
+ __metadata("design:type", Function),
1075
+ __metadata("design:paramtypes", [Object]),
1076
+ __metadata("design:returntype", Promise)
1077
+ ], MicrosoftTeamsIncidentActions, "acknowledgeIncident", null);
1078
+ __decorate([
1079
+ CaptureSpan(),
1080
+ __metadata("design:type", Function),
1081
+ __metadata("design:paramtypes", [Object]),
1082
+ __metadata("design:returntype", Promise)
1083
+ ], MicrosoftTeamsIncidentActions, "resolveIncident", null);
1084
+ __decorate([
1085
+ CaptureSpan(),
1086
+ __metadata("design:type", Function),
1087
+ __metadata("design:paramtypes", [Object]),
1088
+ __metadata("design:returntype", Promise)
1089
+ ], MicrosoftTeamsIncidentActions, "handleBotIncidentAction", null);
1090
+ __decorate([
1091
+ CaptureSpan(),
1092
+ __metadata("design:type", Function),
1093
+ __metadata("design:paramtypes", [Object]),
1094
+ __metadata("design:returntype", Promise)
1095
+ ], MicrosoftTeamsIncidentActions, "showNewIncidentCard", null);
1096
+ __decorate([
1097
+ CaptureSpan(),
1098
+ __metadata("design:type", Function),
1099
+ __metadata("design:paramtypes", [Object]),
1100
+ __metadata("design:returntype", Promise)
1101
+ ], MicrosoftTeamsIncidentActions, "submitNewIncident", null);
1102
+ //# sourceMappingURL=Incident.js.map