@oneuptime/common 12.0.18 → 12.0.19

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 (206) hide show
  1. package/Models/DatabaseModels/EnterpriseLicense.ts +23 -0
  2. package/Models/DatabaseModels/Index.ts +4 -2
  3. package/Models/DatabaseModels/Monitor.ts +39 -9
  4. package/Models/DatabaseModels/UserMicrosoftTeams.ts +344 -0
  5. package/Models/DatabaseModels/UserNotificationRule.ts +144 -8
  6. package/Models/DatabaseModels/UserNotificationSetting.ts +34 -0
  7. package/Models/DatabaseModels/UserOnCallLogTimeline.ts +95 -0
  8. package/Models/DatabaseModels/UserSlack.ts +341 -0
  9. package/Models/DatabaseModels/WorkspaceProjectAuthToken.ts +9 -0
  10. package/Server/API/UserMicrosoftTeamsAPI.ts +127 -0
  11. package/Server/API/UserSlackAPI.ts +125 -0
  12. package/Server/EnvironmentConfig.ts +12 -107
  13. package/Server/Infrastructure/Postgres/SchemaMigrations/1788700000000-RemoveMarketingConversionUploadState.ts +33 -0
  14. package/Server/Infrastructure/Postgres/SchemaMigrations/1788800000000-DropMarketingConversionAddEnterpriseLicenseEmail.ts +51 -0
  15. package/Server/Infrastructure/Postgres/SchemaMigrations/1788900000000-RedactStoredMonitorIngestSecrets.ts +117 -0
  16. package/Server/Infrastructure/Postgres/SchemaMigrations/1789000000000-AddUserSlackAndMicrosoftTeams.ts +197 -0
  17. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +8 -0
  18. package/Server/Infrastructure/Queue.ts +7 -0
  19. package/Server/Services/EnterpriseLicenseService.ts +60 -0
  20. package/Server/Services/Index.ts +6 -2
  21. package/Server/Services/LlmLogService.ts +25 -9
  22. package/Server/Services/OnCallReadinessService.ts +86 -2
  23. package/Server/Services/ProjectService.ts +67 -0
  24. package/Server/Services/UserMicrosoftTeamsService.ts +208 -0
  25. package/Server/Services/UserNotificationMethodAdminService.ts +167 -5
  26. package/Server/Services/UserNotificationRuleAdminService.ts +40 -6
  27. package/Server/Services/UserNotificationRuleService.ts +589 -11
  28. package/Server/Services/UserNotificationSettingService.ts +138 -0
  29. package/Server/Services/UserService.ts +28 -0
  30. package/Server/Services/UserSlackService.ts +218 -0
  31. package/Server/Services/WorkspaceProjectAuthTokenService.ts +67 -1
  32. package/Server/Services/WorkspaceUserAuthTokenService.ts +73 -0
  33. package/Server/Services/WorkspaceUserNotificationService.ts +190 -0
  34. package/Server/Utils/Marketing/MarketingEventUtil.ts +145 -0
  35. package/Server/Utils/Marketing/MarketingEventWebhook.ts +114 -0
  36. package/Server/Utils/Monitor/MonitorLogUtil.ts +14 -1
  37. package/Server/Utils/Monitor/MonitorPayloadRedaction.ts +321 -0
  38. package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +191 -4
  39. package/Tests/App/Dashboard/AdminNotificationRulesPage.test.tsx +22 -14
  40. package/Tests/App/Dashboard/AdminUserNotificationMethodsPage.test.tsx +22 -11
  41. package/Tests/App/Dashboard/OnCallPreventionGuards.test.tsx +37 -1
  42. package/Tests/App/Dashboard/OnCallRulesTable.test.tsx +18 -10
  43. package/Tests/Models/DatabaseModels/DomainRoleTierCoverage.test.ts +27 -1
  44. package/Tests/Models/DatabaseModels/MonitorSecretKeyColumnAccessControl.test.ts +214 -0
  45. package/Tests/Server/API/OnCallReadinessAPI.test.ts +145 -26
  46. package/Tests/Server/API/UserNotificationMethodAdminAPI.test.ts +2 -2
  47. package/Tests/Server/Services/AIServiceDailyBudget.test.ts +11 -1
  48. package/Tests/Server/Services/AdminRuleEditGuards.test.ts +22 -8
  49. package/Tests/Server/Services/DeliverNotificationForRuleExtraction.test.ts +18 -2
  50. package/Tests/Server/Services/EpisodeRuleSeverityRepair.test.ts +5 -1
  51. package/Tests/Server/Services/LlmLogServiceTokenAggregateParams.test.ts +640 -0
  52. package/Tests/Server/Services/NotificationChannelEventCoverage.test.ts +246 -22
  53. package/Tests/Server/Services/NotificationDeletionImpact.test.ts +136 -8
  54. package/Tests/Server/Services/OnCallNotificationFallback.test.ts +191 -8
  55. package/Tests/Server/Services/OnCallReadinessService.test.ts +343 -18
  56. package/Tests/Server/Services/SeverityRuleBackfill.test.ts +5 -1
  57. package/Tests/Server/Services/UserMicrosoftTeamsService.test.ts +343 -0
  58. package/Tests/Server/Services/UserNotificationMethodAdminService.test.ts +209 -8
  59. package/Tests/Server/Services/UserNotificationRuleAdminGuards.test.ts +22 -6
  60. package/Tests/Server/Services/UserNotificationRuleDefaultCreation.test.ts +12 -6
  61. package/Tests/Server/Services/UserNotificationRuleExecuteItem.test.ts +37 -3
  62. package/Tests/Server/Services/UserNotificationRuleWorkspaceDelivery.test.ts +669 -0
  63. package/Tests/Server/Services/UserNotificationSettingWorkspaceChannels.test.ts +410 -0
  64. package/Tests/Server/Services/UserSlackService.test.ts +407 -0
  65. package/Tests/Server/Services/WorkspaceProjectAuthTokenDisconnectCascade.test.ts +224 -0
  66. package/Tests/Server/Services/WorkspaceUserAuthTokenNotificationMethodCascade.test.ts +189 -0
  67. package/Tests/Server/Services/WorkspaceUserNotificationService.test.ts +496 -0
  68. package/Tests/Server/Types/Database/Permissions/AdminNotificationRuleAccess.test.ts +30 -17
  69. package/Tests/Server/Types/Database/Permissions/CreateOwnershipScoping.test.ts +8 -3
  70. package/Tests/Server/Types/Database/Permissions/OwnerOnlyColumns.test.ts +72 -3
  71. package/Tests/Server/Types/Database/Permissions/UserNotificationRuleScoping.test.ts +22 -18
  72. package/Tests/Server/Types/Database/Permissions/WorkspaceMethodStampedColumnCreate.test.ts +178 -0
  73. package/Tests/Server/Utils/Marketing/MarketingEventUtil.test.ts +259 -0
  74. package/Tests/Server/Utils/Marketing/MarketingEventWebhook.test.ts +257 -0
  75. package/Tests/Server/Utils/Monitor/MonitorLogUtilRedaction.test.ts +300 -0
  76. package/Tests/Server/Utils/Monitor/MonitorPayloadRedaction.test.ts +381 -0
  77. package/Tests/Server/Utils/Runbook/RunbookExecutePermission.test.ts +228 -0
  78. package/Tests/Server/Utils/SessionReplay/SessionReplayErasureTombstone.test.ts +189 -0
  79. package/Tests/Server/Utils/SessionReplay/SessionReplayUsage.test.ts +205 -0
  80. package/Tests/Server/Utils/Telemetry/AppMetrics.test.ts +275 -0
  81. package/Tests/Server/Utils/Telemetry/TelemetryContext.test.ts +279 -0
  82. package/Tests/Server/Utils/Workspace/MicrosoftTeamsDirectMessage.test.ts +454 -0
  83. package/Tests/UI/Utils/NotificationMethodUtil.test.ts +137 -9
  84. package/Tests/UI/Utils/PermissionGate.test.ts +105 -0
  85. package/Types/Marketing/MarketingEvent.ts +97 -0
  86. package/UI/Utils/NotificationMethodUtil.ts +41 -1
  87. package/UI/Utils/PermissionGate.ts +56 -0
  88. package/build/dist/Models/DatabaseModels/EnterpriseLicense.js +24 -0
  89. package/build/dist/Models/DatabaseModels/EnterpriseLicense.js.map +1 -1
  90. package/build/dist/Models/DatabaseModels/Index.js +4 -2
  91. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  92. package/build/dist/Models/DatabaseModels/Monitor.js +39 -9
  93. package/build/dist/Models/DatabaseModels/Monitor.js.map +1 -1
  94. package/build/dist/Models/DatabaseModels/UserMicrosoftTeams.js +363 -0
  95. package/build/dist/Models/DatabaseModels/UserMicrosoftTeams.js.map +1 -0
  96. package/build/dist/Models/DatabaseModels/UserNotificationRule.js +145 -8
  97. package/build/dist/Models/DatabaseModels/UserNotificationRule.js.map +1 -1
  98. package/build/dist/Models/DatabaseModels/UserNotificationSetting.js +38 -0
  99. package/build/dist/Models/DatabaseModels/UserNotificationSetting.js.map +1 -1
  100. package/build/dist/Models/DatabaseModels/UserOnCallLogTimeline.js +96 -0
  101. package/build/dist/Models/DatabaseModels/UserOnCallLogTimeline.js.map +1 -1
  102. package/build/dist/Models/DatabaseModels/UserSlack.js +361 -0
  103. package/build/dist/Models/DatabaseModels/UserSlack.js.map +1 -0
  104. package/build/dist/Models/DatabaseModels/WorkspaceProjectAuthToken.js.map +1 -1
  105. package/build/dist/Server/API/UserMicrosoftTeamsAPI.js +82 -0
  106. package/build/dist/Server/API/UserMicrosoftTeamsAPI.js.map +1 -0
  107. package/build/dist/Server/API/UserSlackAPI.js +81 -0
  108. package/build/dist/Server/API/UserSlackAPI.js.map +1 -0
  109. package/build/dist/Server/EnvironmentConfig.js +10 -70
  110. package/build/dist/Server/EnvironmentConfig.js.map +1 -1
  111. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788700000000-RemoveMarketingConversionUploadState.js +26 -0
  112. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788700000000-RemoveMarketingConversionUploadState.js.map +1 -0
  113. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788800000000-DropMarketingConversionAddEnterpriseLicenseEmail.js +37 -0
  114. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788800000000-DropMarketingConversionAddEnterpriseLicenseEmail.js.map +1 -0
  115. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788900000000-RedactStoredMonitorIngestSecrets.js +106 -0
  116. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788900000000-RedactStoredMonitorIngestSecrets.js.map +1 -0
  117. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1789000000000-AddUserSlackAndMicrosoftTeams.js +78 -0
  118. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1789000000000-AddUserSlackAndMicrosoftTeams.js.map +1 -0
  119. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +8 -0
  120. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  121. package/build/dist/Server/Infrastructure/Queue.js +7 -0
  122. package/build/dist/Server/Infrastructure/Queue.js.map +1 -1
  123. package/build/dist/Server/Services/EnterpriseLicenseService.js +65 -0
  124. package/build/dist/Server/Services/EnterpriseLicenseService.js.map +1 -1
  125. package/build/dist/Server/Services/Index.js +6 -2
  126. package/build/dist/Server/Services/Index.js.map +1 -1
  127. package/build/dist/Server/Services/LlmLogService.js +25 -9
  128. package/build/dist/Server/Services/LlmLogService.js.map +1 -1
  129. package/build/dist/Server/Services/OnCallReadinessService.js +74 -2
  130. package/build/dist/Server/Services/OnCallReadinessService.js.map +1 -1
  131. package/build/dist/Server/Services/ProjectService.js +56 -0
  132. package/build/dist/Server/Services/ProjectService.js.map +1 -1
  133. package/build/dist/Server/Services/UserMicrosoftTeamsService.js +183 -0
  134. package/build/dist/Server/Services/UserMicrosoftTeamsService.js.map +1 -0
  135. package/build/dist/Server/Services/UserNotificationMethodAdminService.js +138 -2
  136. package/build/dist/Server/Services/UserNotificationMethodAdminService.js.map +1 -1
  137. package/build/dist/Server/Services/UserNotificationRuleAdminService.js +32 -4
  138. package/build/dist/Server/Services/UserNotificationRuleAdminService.js.map +1 -1
  139. package/build/dist/Server/Services/UserNotificationRuleService.js +499 -67
  140. package/build/dist/Server/Services/UserNotificationRuleService.js.map +1 -1
  141. package/build/dist/Server/Services/UserNotificationSettingService.js +118 -0
  142. package/build/dist/Server/Services/UserNotificationSettingService.js.map +1 -1
  143. package/build/dist/Server/Services/UserService.js +26 -1
  144. package/build/dist/Server/Services/UserService.js.map +1 -1
  145. package/build/dist/Server/Services/UserSlackService.js +195 -0
  146. package/build/dist/Server/Services/UserSlackService.js.map +1 -0
  147. package/build/dist/Server/Services/WorkspaceProjectAuthTokenService.js +64 -1
  148. package/build/dist/Server/Services/WorkspaceProjectAuthTokenService.js.map +1 -1
  149. package/build/dist/Server/Services/WorkspaceUserAuthTokenService.js +70 -0
  150. package/build/dist/Server/Services/WorkspaceUserAuthTokenService.js.map +1 -1
  151. package/build/dist/Server/Services/WorkspaceUserNotificationService.js +129 -0
  152. package/build/dist/Server/Services/WorkspaceUserNotificationService.js.map +1 -0
  153. package/build/dist/Server/Utils/Marketing/MarketingEventUtil.js +94 -0
  154. package/build/dist/Server/Utils/Marketing/MarketingEventUtil.js.map +1 -0
  155. package/build/dist/Server/Utils/Marketing/MarketingEventWebhook.js +93 -0
  156. package/build/dist/Server/Utils/Marketing/MarketingEventWebhook.js.map +1 -0
  157. package/build/dist/Server/Utils/Monitor/MonitorLogUtil.js +12 -1
  158. package/build/dist/Server/Utils/Monitor/MonitorLogUtil.js.map +1 -1
  159. package/build/dist/Server/Utils/Monitor/MonitorPayloadRedaction.js +233 -0
  160. package/build/dist/Server/Utils/Monitor/MonitorPayloadRedaction.js.map +1 -0
  161. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js +141 -4
  162. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js.map +1 -1
  163. package/build/dist/Types/Marketing/MarketingEvent.js +43 -0
  164. package/build/dist/Types/Marketing/MarketingEvent.js.map +1 -0
  165. package/build/dist/UI/Utils/NotificationMethodUtil.js +33 -1
  166. package/build/dist/UI/Utils/NotificationMethodUtil.js.map +1 -1
  167. package/build/dist/UI/Utils/PermissionGate.js +32 -0
  168. package/build/dist/UI/Utils/PermissionGate.js.map +1 -1
  169. package/package.json +1 -1
  170. package/Models/DatabaseModels/MarketingConversion.ts +0 -410
  171. package/Server/Services/MarketingConversionService.ts +0 -10
  172. package/Server/Utils/Marketing/ConversionUploadProvider.ts +0 -215
  173. package/Server/Utils/Marketing/ConversionUploadProviders.ts +0 -22
  174. package/Server/Utils/Marketing/Providers/GoogleAds.ts +0 -333
  175. package/Server/Utils/Marketing/Providers/LinkedIn.ts +0 -185
  176. package/Server/Utils/Marketing/Providers/Meta.ts +0 -182
  177. package/Server/Utils/Marketing/Providers/MicrosoftAds.ts +0 -223
  178. package/Server/Utils/Marketing/Providers/Reddit.ts +0 -208
  179. package/Tests/Server/Utils/Marketing/AdUploadableConversionTypes.test.ts +0 -315
  180. package/Tests/Server/Utils/Marketing/ConversionUploadProvider.test.ts +0 -300
  181. package/Tests/Server/Utils/Marketing/GoogleAds.test.ts +0 -592
  182. package/Tests/Server/Utils/Marketing/LinkedIn.test.ts +0 -282
  183. package/Tests/Server/Utils/Marketing/Meta.test.ts +0 -304
  184. package/Tests/Server/Utils/Marketing/MicrosoftAds.test.ts +0 -263
  185. package/Tests/Server/Utils/Marketing/Reddit.test.ts +0 -259
  186. package/Types/Marketing/MarketingConversion.ts +0 -53
  187. package/build/dist/Models/DatabaseModels/MarketingConversion.js +0 -445
  188. package/build/dist/Models/DatabaseModels/MarketingConversion.js.map +0 -1
  189. package/build/dist/Server/Services/MarketingConversionService.js +0 -9
  190. package/build/dist/Server/Services/MarketingConversionService.js.map +0 -1
  191. package/build/dist/Server/Utils/Marketing/ConversionUploadProvider.js +0 -93
  192. package/build/dist/Server/Utils/Marketing/ConversionUploadProvider.js.map +0 -1
  193. package/build/dist/Server/Utils/Marketing/ConversionUploadProviders.js +0 -20
  194. package/build/dist/Server/Utils/Marketing/ConversionUploadProviders.js.map +0 -1
  195. package/build/dist/Server/Utils/Marketing/Providers/GoogleAds.js +0 -221
  196. package/build/dist/Server/Utils/Marketing/Providers/GoogleAds.js.map +0 -1
  197. package/build/dist/Server/Utils/Marketing/Providers/LinkedIn.js +0 -137
  198. package/build/dist/Server/Utils/Marketing/Providers/LinkedIn.js.map +0 -1
  199. package/build/dist/Server/Utils/Marketing/Providers/Meta.js +0 -133
  200. package/build/dist/Server/Utils/Marketing/Providers/Meta.js.map +0 -1
  201. package/build/dist/Server/Utils/Marketing/Providers/MicrosoftAds.js +0 -143
  202. package/build/dist/Server/Utils/Marketing/Providers/MicrosoftAds.js.map +0 -1
  203. package/build/dist/Server/Utils/Marketing/Providers/Reddit.js +0 -145
  204. package/build/dist/Server/Utils/Marketing/Providers/Reddit.js.map +0 -1
  205. package/build/dist/Types/Marketing/MarketingConversion.js +0 -52
  206. package/build/dist/Types/Marketing/MarketingConversion.js.map +0 -1
@@ -11,8 +11,10 @@ import UserNotificationRuleService, {
11
11
  } from "../../../Server/Services/UserNotificationRuleService";
12
12
  import UserOnCallLogService from "../../../Server/Services/UserOnCallLogService";
13
13
  import UserOnCallLogTimelineService from "../../../Server/Services/UserOnCallLogTimelineService";
14
+ import UserMicrosoftTeamsService from "../../../Server/Services/UserMicrosoftTeamsService";
14
15
  import UserPushService from "../../../Server/Services/UserPushService";
15
16
  import UserService from "../../../Server/Services/UserService";
17
+ import UserSlackService from "../../../Server/Services/UserSlackService";
16
18
  import UserSmsService from "../../../Server/Services/UserSmsService";
17
19
  import UserTelegramService from "../../../Server/Services/UserTelegramService";
18
20
  import UserWebhookService from "../../../Server/Services/UserWebhookService";
@@ -66,8 +68,8 @@ import { afterEach, beforeEach, describe, expect, test } from "@jest/globals";
66
68
  * R1 a target user id from ANOTHER project, presented by a caller who is a
67
69
  * legitimate administrator of THIS one.
68
70
  * R3 a method FK pointing at somebody else's row — on create, on update, in
69
- * the FK slot, in the relation slot, and on all seven channels, because
70
- * a guard covering six of seven covers none.
71
+ * the FK slot, in the relation slot, and on all nine channels, because
72
+ * a guard covering eight of nine covers none.
71
73
  * R3 on update specifically: a body that LIES about the rule's owner, to
72
74
  * check that the owner is re-read from the database rather than believed.
73
75
  * R6 an audit trail and an owner notification keyed on the server-resolved
@@ -111,7 +113,7 @@ const INCIDENT_ID: ObjectID = new ObjectID(
111
113
  );
112
114
 
113
115
  /*
114
- * The seven channels, each with the FK column a rule carries it in, the
116
+ * The nine channels, each with the FK column a rule carries it in, the
115
117
  * relation slot that is the same write spelled differently, the service the
116
118
  * guard must consult, and the word the rejection message has to contain.
117
119
  *
@@ -163,6 +165,20 @@ const CHANNELS: Array<ChannelFixture> = [
163
165
  service: UserTelegramService as unknown as ChannelFixture["service"],
164
166
  relationProperty: "userTelegram",
165
167
  },
168
+ {
169
+ idColumn: "userSlackId",
170
+ relationColumn: "userSlack",
171
+ label: "Slack",
172
+ service: UserSlackService as unknown as ChannelFixture["service"],
173
+ relationProperty: "userSlack",
174
+ },
175
+ {
176
+ idColumn: "userMicrosoftTeamsId",
177
+ relationColumn: "userMicrosoftTeams",
178
+ label: "Microsoft Teams",
179
+ service: UserMicrosoftTeamsService as unknown as ChannelFixture["service"],
180
+ relationProperty: "userMicrosoftTeams",
181
+ },
166
182
  {
167
183
  idColumn: "userPushId",
168
184
  relationColumn: "userPush",
@@ -644,7 +660,7 @@ describe("UserNotificationRule administrative write guards", () => {
644
660
  * R3 on create - the method a rule names must belong to the rule's owner.
645
661
  * ---------------------------------------------------------------------
646
662
  */
647
- describe("R3 on create - method ownership, all seven channels", () => {
663
+ describe("R3 on create - method ownership, all nine channels", () => {
648
664
  test.each(
649
665
  CHANNELS.map((channel: ChannelFixture): [string, ChannelFixture] => {
650
666
  return [channel.label, channel];
@@ -720,9 +736,9 @@ describe("UserNotificationRule administrative write guards", () => {
720
736
  },
721
737
  );
722
738
 
723
- test("the guard covers exactly the seven notification method columns the model has", () => {
739
+ test("the guard covers exactly the nine notification method columns the model has", () => {
724
740
  /*
725
- * The count is the assertion. An eighth channel added to the model
741
+ * The count is the assertion. A tenth channel added to the model
726
742
  * without an entry in the guard's table is a channel with no ownership
727
743
  * check at all, and the attacker only needs one.
728
744
  */
@@ -19,9 +19,11 @@ import { afterEach, beforeEach, describe, expect, test } from "@jest/globals";
19
19
  * The defaults a brand-new responder is given.
20
20
  *
21
21
  * Everything about "will this person actually be paged?" starts here. When a
22
- * user joins a project (TeamMemberService), or verifies a phone / push / e-mail
22
+ * user joins a project (TeamMemberService), verifies a phone / push / e-mail
23
23
  * / Telegram / WhatsApp / webhook identity (the UserXxxAPI verify endpoints),
24
- * UserNotificationRuleService seeds a set of notification rules for them. If the
24
+ * or links a Slack / Microsoft Teams account (born verified from the OAuth
25
+ * workspace link), UserNotificationRuleService seeds a set of notification
26
+ * rules for them. If the
25
27
  * seeding is wrong — a severity skipped, a rule type missed, a delay that is not
26
28
  * zero, or the method id written onto the wrong foreign key — the user is on an
27
29
  * on-call policy that pages nobody, and nothing tells them so.
@@ -93,13 +95,15 @@ const CREATED_EMAIL_ID: ObjectID = new ObjectID(
93
95
 
94
96
  const USER_EMAIL: Email = new Email("responder@company.com");
95
97
 
96
- /* The seven FK columns a NotificationMethodDescriptor can drive. */
98
+ /* The nine FK columns a NotificationMethodDescriptor can drive. */
97
99
  type ChannelColumn =
98
100
  | "userEmailId"
99
101
  | "userSmsId"
100
102
  | "userCallId"
101
103
  | "userWhatsAppId"
102
104
  | "userTelegramId"
105
+ | "userSlackId"
106
+ | "userMicrosoftTeamsId"
103
107
  | "userWebhookId"
104
108
  | "userPushId";
105
109
 
@@ -109,6 +113,8 @@ const ALL_CHANNELS: Array<ChannelColumn> = [
109
113
  "userCallId",
110
114
  "userWhatsAppId",
111
115
  "userTelegramId",
116
+ "userSlackId",
117
+ "userMicrosoftTeamsId",
112
118
  "userWebhookId",
113
119
  "userPushId",
114
120
  ];
@@ -587,9 +593,9 @@ describe("addDefaultNotificationRulesForVerifiedMethod - the method lands on the
587
593
  * KNOWN DEFECT, pinned as-is. With no id on the descriptor the duplicate
588
594
  * check degenerates to (projectId, userId, ruleType) and the created rows
589
595
  * carry no notification method at all - onBeforeCreate would reject them
590
- * with "Call, SMS, WhatsApp, Telegram, Webhook, Email, or Push notification
591
- * is required" against a real database. Nothing in this method guards
592
- * against being handed an empty descriptor.
596
+ * with "Call, SMS, WhatsApp, Telegram, Slack, Microsoft Teams, Webhook,
597
+ * Email, or Push notification is required" against a real database. Nothing
598
+ * in this method guards against being handed an empty descriptor.
593
599
  */
594
600
  await runForDescriptor({});
595
601
 
@@ -14,6 +14,7 @@ import TelegramService from "../../../Server/Services/TelegramService";
14
14
  import WebhookService from "../../../Server/Services/WebhookService";
15
15
  import PushNotificationService from "../../../Server/Services/PushNotificationService";
16
16
  import WorkspaceNotificationRuleService from "../../../Server/Services/WorkspaceNotificationRuleService";
17
+ import WorkspaceUserNotificationService from "../../../Server/Services/WorkspaceUserNotificationService";
17
18
  import logger from "../../../Server/Utils/Logger";
18
19
  import Incident from "../../../Models/DatabaseModels/Incident";
19
20
  import Alert from "../../../Models/DatabaseModels/Alert";
@@ -212,6 +213,7 @@ interface DeliverySpies {
212
213
  call: jest.SpyInstance;
213
214
  whatsApp: jest.SpyInstance;
214
215
  telegram: jest.SpyInstance;
216
+ workspaceMessage: jest.SpyInstance;
215
217
  webhook: jest.SpyInstance;
216
218
  push: jest.SpyInstance;
217
219
  emailTemplateForIncident: jest.SpyInstance;
@@ -294,6 +296,10 @@ describe("UserNotificationRuleService.executeNotificationRuleItem", () => {
294
296
  telegram: jest
295
297
  .spyOn(TelegramService, "sendTelegramMessage")
296
298
  .mockResolvedValue(undefined as never),
299
+ // Slack and Microsoft Teams both deliver through this one service.
300
+ workspaceMessage: jest
301
+ .spyOn(WorkspaceUserNotificationService, "sendDirectMessageToUser")
302
+ .mockResolvedValue(undefined as never),
297
303
  webhook: jest
298
304
  .spyOn(WebhookService, "sendWebhook")
299
305
  .mockResolvedValue(undefined as never),
@@ -320,6 +326,7 @@ describe("UserNotificationRuleService.executeNotificationRuleItem", () => {
320
326
  spies.call,
321
327
  spies.whatsApp,
322
328
  spies.telegram,
329
+ spies.workspaceMessage,
323
330
  spies.webhook,
324
331
  spies.push,
325
332
  ];
@@ -572,7 +579,7 @@ describe("UserNotificationRuleService.executeNotificationRuleItem", () => {
572
579
  * the loaded relation's userId against the rule's, and it can only report
573
580
  * a mismatch it can SEE - an unselected column arrives as `undefined` and
574
581
  * is deliberately read as "no evidence", so dropping any one of these
575
- * seven silently disables the backstop for that channel.
582
+ * nine silently disables the backstop for that channel.
576
583
  *
577
584
  * Kept as an exact-shape assertion on purpose. This test caught the
578
585
  * column being added, which is the whole argument for not relaxing it
@@ -603,6 +610,18 @@ describe("UserNotificationRuleService.executeNotificationRuleItem", () => {
603
610
  isVerified: true,
604
611
  userId: true,
605
612
  },
613
+ userSlack: {
614
+ slackUserId: true,
615
+ slackUserName: true,
616
+ isVerified: true,
617
+ userId: true,
618
+ },
619
+ userMicrosoftTeams: {
620
+ microsoftTeamsUserId: true,
621
+ microsoftTeamsUserName: true,
622
+ isVerified: true,
623
+ userId: true,
624
+ },
606
625
  userWebhook: {
607
626
  webhookUrl: true,
608
627
  name: true,
@@ -629,6 +648,8 @@ describe("UserNotificationRuleService.executeNotificationRuleItem", () => {
629
648
  ["userSms"],
630
649
  ["userWhatsApp"],
631
650
  ["userTelegram"],
651
+ ["userSlack"],
652
+ ["userMicrosoftTeams"],
632
653
  ["userEmail"],
633
654
  ["userPush"],
634
655
  ])(
@@ -647,6 +668,8 @@ describe("UserNotificationRuleService.executeNotificationRuleItem", () => {
647
668
  ["userSms", "phone"],
648
669
  ["userWhatsApp", "phone"],
649
670
  ["userTelegram", "telegramChatId"],
671
+ ["userSlack", "slackUserId"],
672
+ ["userMicrosoftTeams", "microsoftTeamsUserId"],
650
673
  ["userEmail", "email"],
651
674
  ["userPush", "deviceToken"],
652
675
  ])(
@@ -777,6 +800,16 @@ describe("UserNotificationRuleService.executeNotificationRuleItem", () => {
777
800
  telegramChatId: "123456",
778
801
  isVerified: false,
779
802
  },
803
+ userSlack: {
804
+ id: METHOD_ID,
805
+ slackUserId: "U0123456789",
806
+ isVerified: false,
807
+ },
808
+ userMicrosoftTeams: {
809
+ id: METHOD_ID,
810
+ microsoftTeamsUserId: "teams-user-1",
811
+ isVerified: false,
812
+ },
780
813
  userCall: {
781
814
  id: METHOD_ID,
782
815
  phone: new Phone("+11234567892"),
@@ -801,10 +834,11 @@ describe("UserNotificationRuleService.executeNotificationRuleItem", () => {
801
834
  expect(spies.call).not.toHaveBeenCalled();
802
835
  expect(spies.whatsApp).not.toHaveBeenCalled();
803
836
  expect(spies.telegram).not.toHaveBeenCalled();
837
+ expect(spies.workspaceMessage).not.toHaveBeenCalled();
804
838
  expect(spies.push).not.toHaveBeenCalled();
805
839
 
806
- // One "not verified" Error row per unverified channel: 6 in total.
807
- expect(timelineRows).toHaveLength(6);
840
+ // One "not verified" Error row per unverified channel: 8 in total.
841
+ expect(timelineRows).toHaveLength(8);
808
842
  for (const row of timelineRows) {
809
843
  expect(row.status).toBe(UserNotificationStatus.Error);
810
844
  expect(row.statusMessage).toContain("not verified");