@oneuptime/common 14.0.110 → 14.2.0

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 (527) hide show
  1. package/Models/DatabaseModels/AIRunRecording.d.mts +12 -0
  2. package/Models/DatabaseModels/AIRunRecording.d.ts +12 -0
  3. package/Models/DatabaseModels/AIRunRecording.js +181 -0
  4. package/Models/DatabaseModels/AIRunRecording.mjs +2 -0
  5. package/Models/DatabaseModels/Alert.d.mts +1 -0
  6. package/Models/DatabaseModels/Alert.d.ts +1 -0
  7. package/Models/DatabaseModels/Alert.js +52 -2
  8. package/Models/DatabaseModels/AutoRemediationSuggestion.d.mts +2 -0
  9. package/Models/DatabaseModels/AutoRemediationSuggestion.d.ts +2 -0
  10. package/Models/DatabaseModels/AutoRemediationSuggestion.js +62 -0
  11. package/Models/DatabaseModels/DataStore.js +9 -0
  12. package/Models/DatabaseModels/EmailLog.js +2 -2
  13. package/Models/DatabaseModels/Form.js +3 -3
  14. package/Models/DatabaseModels/FormSubmission.js +4 -4
  15. package/Models/DatabaseModels/GlobalConfig.js +46 -45
  16. package/Models/DatabaseModels/Incident.d.mts +1 -0
  17. package/Models/DatabaseModels/Incident.d.ts +1 -0
  18. package/Models/DatabaseModels/Incident.js +53 -2
  19. package/Models/DatabaseModels/IncidentPostmortemActionItem.d.mts +31 -0
  20. package/Models/DatabaseModels/IncidentPostmortemActionItem.d.ts +31 -0
  21. package/Models/DatabaseModels/IncidentPostmortemActionItem.js +591 -0
  22. package/Models/DatabaseModels/IncidentPostmortemActionItem.mjs +3 -0
  23. package/Models/DatabaseModels/IncidentSlaRule.js +2 -2
  24. package/Models/DatabaseModels/Index.js +6 -0
  25. package/Models/DatabaseModels/InventoryItem.js +11 -0
  26. package/Models/DatabaseModels/Monitor.js +51 -17
  27. package/Models/DatabaseModels/MonitorNetworkDevice.d.mts +11 -0
  28. package/Models/DatabaseModels/MonitorNetworkDevice.d.ts +11 -0
  29. package/Models/DatabaseModels/MonitorNetworkDevice.js +189 -0
  30. package/Models/DatabaseModels/MonitorNetworkDevice.mjs +2 -0
  31. package/Models/DatabaseModels/MonitorProbe.js +22 -5
  32. package/Models/DatabaseModels/NetworkDevice.js +23 -7
  33. package/Models/DatabaseModels/NetworkEndpoint.d.mts +1 -0
  34. package/Models/DatabaseModels/NetworkEndpoint.d.ts +1 -0
  35. package/Models/DatabaseModels/NetworkEndpoint.js +39 -7
  36. package/Models/DatabaseModels/NetworkInterface.js +5 -5
  37. package/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.js +19 -5
  38. package/Models/DatabaseModels/OnCallDutyPolicyFeed.d.mts +1 -0
  39. package/Models/DatabaseModels/OnCallDutyPolicyFeed.d.ts +1 -0
  40. package/Models/DatabaseModels/OnCallDutyPolicyFeed.js +2 -0
  41. package/Models/DatabaseModels/OnCallDutyPolicyUserOverride.js +35 -7
  42. package/Models/DatabaseModels/OpenStackCloudCheck.js +8 -1
  43. package/Models/DatabaseModels/Project.d.mts +1 -0
  44. package/Models/DatabaseModels/Project.d.ts +1 -0
  45. package/Models/DatabaseModels/Project.js +46 -3
  46. package/Models/DatabaseModels/ProjectCallSMSConfig.js +3 -1
  47. package/Models/DatabaseModels/ProjectSmtpConfig.js +2 -0
  48. package/Models/DatabaseModels/PublicNoteApprovalRequest.js +3 -3
  49. package/Models/DatabaseModels/PublicNoteApprovalStep.js +1 -1
  50. package/Models/DatabaseModels/RunbookExecution.js +2 -2
  51. package/Models/DatabaseModels/RunbookRule.js +6 -6
  52. package/Models/DatabaseModels/ScheduledMaintenance.js +3 -3
  53. package/Models/DatabaseModels/ScheduledMaintenanceCalendarFeed.js +1 -1
  54. package/Models/DatabaseModels/ScheduledMaintenanceLabelRule.js +1 -1
  55. package/Models/DatabaseModels/ScheduledMaintenanceMeasurement.js +7 -7
  56. package/Models/DatabaseModels/ScheduledMaintenanceMeasurementValue.js +1 -1
  57. package/Models/DatabaseModels/ScheduledMaintenanceOwnerRule.js +6 -6
  58. package/Models/DatabaseModels/ScheduledMaintenanceOwnerTeam.js +4 -4
  59. package/Models/DatabaseModels/ScheduledMaintenanceOwnerUser.js +4 -4
  60. package/Models/DatabaseModels/ScheduledMaintenancePublicNote.js +3 -3
  61. package/Models/DatabaseModels/ScheduledMaintenanceReminderRule.js +4 -4
  62. package/Models/DatabaseModels/ScheduledMaintenanceStateTimeline.js +3 -3
  63. package/Models/DatabaseModels/ScheduledMaintenanceTemplate.js +5 -5
  64. package/Models/DatabaseModels/TeamMember.js +10 -1
  65. package/Models/DatabaseModels/TelemetryIngestionKey.js +1 -1
  66. package/Models/DatabaseModels/WorkspaceNotificationRule.js +36 -1
  67. package/Models/DatabaseModels/WorkspaceNotificationSummary.js +1 -1
  68. package/Models/DatabaseModels/WorkspacePublicNoteApprovalMessage.js +3 -3
  69. package/Server/Services/DatabaseService.d.mts +4 -1
  70. package/Server/Services/DatabaseService.d.ts +4 -1
  71. package/Server/Types/Database/CountBy.d.mts +1 -0
  72. package/Server/Types/Database/CountBy.d.ts +1 -0
  73. package/Server/Types/Database/UpdateLimit.d.mts +6 -0
  74. package/Server/Types/Database/UpdateLimit.d.ts +6 -0
  75. package/Types/AI/AIActionWords.d.mts +28 -2
  76. package/Types/AI/AIActionWords.d.ts +28 -2
  77. package/Types/AI/AIActionWords.js +235 -3
  78. package/Types/AI/AIActionWords.mjs +8 -0
  79. package/Types/AI/AIChatTypes.d.mts +3 -1
  80. package/Types/AI/AIChatTypes.d.ts +3 -1
  81. package/Types/AI/AIReadTableWords.d.mts +192 -0
  82. package/Types/AI/AIReadTableWords.d.ts +192 -0
  83. package/Types/AI/AIReadTableWords.js +368 -0
  84. package/Types/AI/AIReadTableWords.mjs +18 -0
  85. package/Types/AI/AiOutcomes.d.mts +57 -0
  86. package/Types/AI/AiOutcomes.d.ts +57 -0
  87. package/Types/AI/AiOutcomes.js +67 -0
  88. package/Types/AI/AiOutcomes.mjs +10 -0
  89. package/Types/AI/AiRunRefusal.d.mts +48 -0
  90. package/Types/AI/AiRunRefusal.d.ts +48 -0
  91. package/Types/AI/AiRunRefusal.js +208 -0
  92. package/Types/AI/AiRunRefusal.mjs +12 -0
  93. package/Types/AI/InvestigationRecording.d.mts +46 -0
  94. package/Types/AI/InvestigationRecording.d.ts +46 -0
  95. package/Types/AI/InvestigationRecording.js +42 -0
  96. package/Types/AI/InvestigationRecording.mjs +7 -0
  97. package/Types/AI/ResourceAiAccessPermissions.js +7 -18
  98. package/Types/API/HTTPResponse.d.mts +3 -0
  99. package/Types/API/HTTPResponse.d.ts +3 -0
  100. package/Types/API/HTTPResponse.js +15 -0
  101. package/Types/AuditLog/AuditLogActionLabel.js +19 -9
  102. package/Types/BaseDatabase/AggregateBy.d.mts +16 -0
  103. package/Types/BaseDatabase/AggregateBy.d.ts +16 -0
  104. package/Types/BaseDatabase/AggregationIntervalUtil.d.mts +32 -1
  105. package/Types/BaseDatabase/AggregationIntervalUtil.d.ts +32 -1
  106. package/Types/BaseDatabase/AggregationIntervalUtil.js +199 -2
  107. package/Types/BaseDatabase/ListResult.d.mts +1 -0
  108. package/Types/BaseDatabase/ListResult.d.ts +1 -0
  109. package/Types/CallAndSMS/ServerTwilioEnvironment.d.mts +47 -0
  110. package/Types/CallAndSMS/ServerTwilioEnvironment.d.ts +47 -0
  111. package/Types/CallAndSMS/ServerTwilioEnvironment.js +282 -0
  112. package/Types/CallAndSMS/ServerTwilioEnvironment.mjs +7 -0
  113. package/Types/Cloud/CloudResourceHealth.d.mts +30 -1
  114. package/Types/Cloud/CloudResourceHealth.d.ts +30 -1
  115. package/Types/Cloud/CloudResourceHealth.js +405 -13
  116. package/Types/Cloud/CloudResourceHealth.mjs +28 -0
  117. package/Types/Dashboard/DashboardAutoRefresh.d.mts +1 -0
  118. package/Types/Dashboard/DashboardAutoRefresh.d.ts +1 -0
  119. package/Types/Dashboard/DashboardAutoRefresh.js +21 -0
  120. package/Types/Dashboard/DashboardAutoRefresh.mjs +1 -0
  121. package/Types/DataObservability/DataCheckRefusals.d.mts +32 -0
  122. package/Types/DataObservability/DataCheckRefusals.d.ts +32 -0
  123. package/Types/DataObservability/DataCheckRefusals.js +77 -0
  124. package/Types/DataObservability/DataCheckRefusals.mjs +8 -0
  125. package/Types/Database/AccessControl/PermissionScopeNarrowing.js +4 -0
  126. package/Types/Date.d.mts +8 -1
  127. package/Types/Date.d.ts +8 -1
  128. package/Types/Date.js +61 -7
  129. package/Types/Date.mjs +1 -0
  130. package/Types/DateLanguage.d.mts +2 -0
  131. package/Types/DateLanguage.d.ts +2 -0
  132. package/Types/DateLanguage.js +8 -5
  133. package/Types/Email/EmailTemplateType.d.mts +1 -0
  134. package/Types/Email/EmailTemplateType.d.ts +1 -0
  135. package/Types/Email/EmailTemplateType.js +2 -0
  136. package/Types/Email/ServerEmailEnvironment.d.mts +85 -0
  137. package/Types/Email/ServerEmailEnvironment.d.ts +85 -0
  138. package/Types/Email/ServerEmailEnvironment.js +793 -0
  139. package/Types/Email/ServerEmailEnvironment.mjs +14 -0
  140. package/Types/Exception/AiRunRefusalException.d.mts +6 -0
  141. package/Types/Exception/AiRunRefusalException.d.ts +6 -0
  142. package/Types/Exception/AiRunRefusalException.js +23 -0
  143. package/Types/Exception/AiRunRefusalException.mjs +2 -0
  144. package/Types/Exception/EgressGuardException.js +1 -1
  145. package/Types/Exception/ErrorMessageRule.d.mts +1 -0
  146. package/Types/Exception/ErrorMessageRule.d.ts +1 -0
  147. package/Types/Exception/ErrorMessageRule.js +67 -13
  148. package/Types/Exception/ErrorMessageRule.mjs +1 -0
  149. package/Types/Exception/ExceptionMessages.d.mts +2 -0
  150. package/Types/Exception/ExceptionMessages.d.ts +2 -0
  151. package/Types/Exception/ExceptionMessages.js +2 -0
  152. package/Types/Form/FormTargetCatalog.js +2 -2
  153. package/Types/Form/FormTargetType.js +2 -2
  154. package/Types/Incident/PostmortemActionItemStatus.d.mts +17 -0
  155. package/Types/Incident/PostmortemActionItemStatus.d.ts +17 -0
  156. package/Types/Incident/PostmortemActionItemStatus.js +74 -0
  157. package/Types/Incident/PostmortemActionItemStatus.mjs +5 -0
  158. package/Types/JSONFunctions.js +10 -3
  159. package/Types/Link.d.mts +1 -0
  160. package/Types/Link.d.ts +1 -0
  161. package/Types/ListData.d.mts +2 -0
  162. package/Types/ListData.d.ts +2 -0
  163. package/Types/ListData.js +4 -0
  164. package/Types/MeaningKeys.d.mts +4 -0
  165. package/Types/MeaningKeys.d.ts +4 -0
  166. package/Types/MeaningKeys.js +74 -0
  167. package/Types/MeaningKeys.mjs +5 -0
  168. package/Types/Monitor/MonitorCriteriaInstance.js +9 -0
  169. package/Types/Monitor/MonitorNotCheckedReason.d.mts +7 -0
  170. package/Types/Monitor/MonitorNotCheckedReason.d.ts +7 -0
  171. package/Types/Monitor/MonitorNotCheckedReason.js +36 -0
  172. package/Types/Monitor/MonitorNotCheckedReason.mjs +4 -0
  173. package/Types/Monitor/SnmpMonitor/NetworkTopology.d.mts +6 -0
  174. package/Types/Monitor/SnmpMonitor/NetworkTopology.d.ts +6 -0
  175. package/Types/Monitor/UptimeHistoryLabels.js +2 -2
  176. package/Types/Monitor/WhoIsTold.d.mts +3 -0
  177. package/Types/Monitor/WhoIsTold.d.ts +3 -0
  178. package/Types/Monitor/WhoIsTold.js +63 -13
  179. package/Types/NoBreakSpaces.d.mts +16 -0
  180. package/Types/NoBreakSpaces.d.ts +16 -0
  181. package/Types/NoBreakSpaces.js +419 -0
  182. package/Types/NoBreakSpaces.mjs +9 -0
  183. package/Types/NotificationRule/PagingLadder.d.mts +12 -0
  184. package/Types/NotificationRule/PagingLadder.d.ts +12 -0
  185. package/Types/NotificationRule/PagingLadder.js +159 -11
  186. package/Types/NotificationRule/PagingLadder.mjs +3 -0
  187. package/Types/OnCallDutyPolicy/GlobalUserOverrideAccess.d.mts +1 -0
  188. package/Types/OnCallDutyPolicy/GlobalUserOverrideAccess.d.ts +1 -0
  189. package/Types/OnCallDutyPolicy/GlobalUserOverrideAccess.js +12 -9
  190. package/Types/OnCallDutyPolicy/GlobalUserOverrideAccess.mjs +1 -0
  191. package/Types/OnCallDutyPolicy/OnCallAcknowledgePage.d.mts +3 -1
  192. package/Types/OnCallDutyPolicy/OnCallAcknowledgePage.d.ts +3 -1
  193. package/Types/OnCallDutyPolicy/OnCallAcknowledgePage.js +24 -6
  194. package/Types/OnCallDutyPolicy/OnCallAcknowledgePage.mjs +1 -0
  195. package/Types/OnCallDutyPolicy/OnCallPagePassOn.d.mts +1 -0
  196. package/Types/OnCallDutyPolicy/OnCallPagePassOn.d.ts +1 -0
  197. package/Types/OnCallDutyPolicy/OnCallPageRecordGone.d.mts +3 -0
  198. package/Types/OnCallDutyPolicy/OnCallPageRecordGone.d.ts +3 -0
  199. package/Types/OnCallDutyPolicy/OnCallPageRecordGone.js +42 -0
  200. package/Types/OnCallDutyPolicy/OnCallPageRecordGone.mjs +4 -0
  201. package/Types/OnCallDutyPolicy/OnCallPageWords.d.mts +6 -2
  202. package/Types/OnCallDutyPolicy/OnCallPageWords.d.ts +6 -2
  203. package/Types/OnCallDutyPolicy/OnCallPageWords.js +21 -20
  204. package/Types/OnCallDutyPolicy/OnCallPersonPage.d.mts +4 -0
  205. package/Types/OnCallDutyPolicy/OnCallPersonPage.d.ts +4 -0
  206. package/Types/OnCallDutyPolicy/OnCallPersonPage.js +125 -1
  207. package/Types/OnCallDutyPolicy/OnCallPersonPage.mjs +1 -0
  208. package/Types/OnCallDutyPolicy/OnCallPolicyStartedByHand.d.mts +12 -0
  209. package/Types/OnCallDutyPolicy/OnCallPolicyStartedByHand.d.ts +12 -0
  210. package/Types/OnCallDutyPolicy/OnCallPolicyStartedByHand.js +38 -0
  211. package/Types/OnCallDutyPolicy/OnCallPolicyStartedByHand.mjs +3 -0
  212. package/Types/OnCallDutyPolicy/OnCallTestPage.d.mts +2 -0
  213. package/Types/OnCallDutyPolicy/OnCallTestPage.d.ts +2 -0
  214. package/Types/OnCallDutyPolicy/OnCallTestPage.js +12 -0
  215. package/Types/OnCallDutyPolicy/OnCallTestPage.mjs +1 -0
  216. package/Types/OnCallDutyPolicy/ScheduleLayersSave.d.mts +92 -0
  217. package/Types/OnCallDutyPolicy/ScheduleLayersSave.d.ts +92 -0
  218. package/Types/OnCallDutyPolicy/ScheduleLayersSave.js +512 -0
  219. package/Types/OnCallDutyPolicy/ScheduleLayersSave.mjs +7 -0
  220. package/Types/OnCallDutyPolicy/UserOverrideEdit.d.mts +23 -0
  221. package/Types/OnCallDutyPolicy/UserOverrideEdit.d.ts +23 -0
  222. package/Types/OnCallDutyPolicy/UserOverrideEdit.js +105 -0
  223. package/Types/OnCallDutyPolicy/UserOverrideEdit.mjs +6 -0
  224. package/Types/OnCallDutyPolicy/UserOverrideOverlap.d.mts +64 -0
  225. package/Types/OnCallDutyPolicy/UserOverrideOverlap.d.ts +64 -0
  226. package/Types/OnCallDutyPolicy/UserOverrideOverlap.js +237 -0
  227. package/Types/OnCallDutyPolicy/UserOverrideOverlap.mjs +14 -0
  228. package/Types/OpenStack/OpenStackCapacity.js +12 -5
  229. package/Types/Permission.d.mts +4 -0
  230. package/Types/Permission.d.ts +4 -0
  231. package/Types/Permission.js +66 -10
  232. package/Types/Probe/ProbeCapability.d.mts +2 -1
  233. package/Types/Probe/ProbeCapability.d.ts +2 -1
  234. package/Types/Probe/ProbeCapability.js +10 -0
  235. package/Types/Product/ProductUsage.js +2 -1
  236. package/Types/Product/ProjectProductsAnswer.js +2 -1
  237. package/Types/ReaderLanguage.d.mts +1 -0
  238. package/Types/ReaderLanguage.d.ts +1 -0
  239. package/Types/ReaderLanguage.js +13 -1
  240. package/Types/ReaderLanguage.mjs +1 -0
  241. package/Types/ResourceAiAgent/AiResourceType.d.mts +1 -0
  242. package/Types/ResourceAiAgent/AiResourceType.d.ts +1 -0
  243. package/Types/ResourceAiAgent/AiResourceType.js +12 -0
  244. package/Types/Rules/RuleRun.js +2 -2
  245. package/Types/Rum/ProductAnalyticsEventReads.js +10 -1
  246. package/Types/Rum/ProductAnalyticsEvents.js +13 -1
  247. package/Types/Rum/SessionReplayCustomEvents.d.mts +4 -1
  248. package/Types/Rum/SessionReplayCustomEvents.d.ts +4 -1
  249. package/Types/Rum/SessionReplayCustomEvents.js +12 -0
  250. package/Types/Rum/SessionReplayCustomEvents.mjs +1 -0
  251. package/Types/ScheduledMaintenance/MaintenanceCalendar.js +1 -1
  252. package/Types/ServerSending/ServerSendingStatus.d.mts +7 -0
  253. package/Types/ServerSending/ServerSendingStatus.d.ts +7 -0
  254. package/Types/ServerSending/ServerSendingStatus.js +49 -2
  255. package/Types/ServerSetup/ServerSetupChecklist.js +3 -3
  256. package/Types/SetupHealth/SetupHealth.d.mts +1 -0
  257. package/Types/SetupHealth/SetupHealth.d.ts +1 -0
  258. package/Types/SetupHealth/SetupHealth.js +13 -5
  259. package/Types/StateTimeline/RowsKeptOnDelete.js +1 -1
  260. package/Types/StatusPage/DefaultStatusNames.d.mts +11 -3
  261. package/Types/StatusPage/DefaultStatusNames.d.ts +11 -3
  262. package/Types/StatusPage/DefaultStatusNames.js +74 -28
  263. package/Types/StatusPage/DefaultStatusNames.mjs +9 -2
  264. package/Types/StatusPage/NewIncidentSubscriberNotificationDefault.d.mts +8 -0
  265. package/Types/StatusPage/NewIncidentSubscriberNotificationDefault.d.ts +8 -0
  266. package/Types/StatusPage/NewIncidentSubscriberNotificationDefault.js +50 -0
  267. package/Types/StatusPage/NewIncidentSubscriberNotificationDefault.mjs +3 -0
  268. package/Types/StatusPage/PublicNoteSubscriberNotificationDefault.js +1 -1
  269. package/Types/StatusPage/StateChangeNoteMessage.d.mts +3 -2
  270. package/Types/StatusPage/StateChangeNoteMessage.d.ts +3 -2
  271. package/Types/StatusPage/StateChangeNoteMessage.js +16 -13
  272. package/Types/Telemetry/CompatibleIngest.d.mts +20 -0
  273. package/Types/Telemetry/CompatibleIngest.d.ts +20 -0
  274. package/Types/Telemetry/CompatibleIngest.js +123 -0
  275. package/Types/Telemetry/CompatibleIngest.mjs +21 -0
  276. package/Types/Telemetry/TelemetryIngestSurface.d.mts +5 -0
  277. package/Types/Telemetry/TelemetryIngestSurface.d.ts +5 -0
  278. package/Types/Telemetry/TelemetryIngestSurface.js +48 -7
  279. package/Types/Telemetry/TelemetryIngestionKeyType.js +7 -6
  280. package/Types/TimezoneAlias.d.mts +1 -0
  281. package/Types/TimezoneAlias.d.ts +1 -0
  282. package/Types/TimezoneAlias.js +13 -0
  283. package/Types/Translator.d.mts +1 -0
  284. package/Types/Translator.d.ts +1 -0
  285. package/Types/Translator.js +470 -63
  286. package/Types/Translator.mjs +1 -0
  287. package/Types/UserSession/SessionLength.d.mts +33 -0
  288. package/Types/UserSession/SessionLength.d.ts +33 -0
  289. package/Types/UserSession/SessionLength.js +134 -5
  290. package/Types/UserSession/SessionLength.mjs +5 -0
  291. package/Types/Workflow/RunRecord.js +1 -1
  292. package/Types/Workflow/Templates.js +2 -2
  293. package/Types/Workflow/WorkflowStatus.js +21 -10
  294. package/Types/Workspace/NotificationRules/BaseNotificationRule.d.mts +2 -0
  295. package/Types/Workspace/NotificationRules/BaseNotificationRule.d.ts +2 -0
  296. package/Types/Workspace/NotificationRules/NotificationRuleCondition.d.mts +26 -1
  297. package/Types/Workspace/NotificationRules/NotificationRuleCondition.d.ts +26 -1
  298. package/Types/Workspace/NotificationRules/NotificationRuleUpdates.d.mts +84 -0
  299. package/Types/Workspace/NotificationRules/NotificationRuleUpdates.d.ts +84 -0
  300. package/Types/Workspace/NotificationRules/NotificationRuleUpdates.js +456 -0
  301. package/Types/Workspace/NotificationRules/NotificationRuleUpdates.mjs +5 -0
  302. package/Utils/AI/InvestigationReport.js +2 -2
  303. package/Utils/API.d.mts +0 -11
  304. package/Utils/API.d.ts +0 -11
  305. package/Utils/API.js +0 -432
  306. package/Utils/AiRemediation/Resource/ResourceCommandPolicy.js +2 -2
  307. package/Utils/AiRemediation/VerifiedFixRunbook.d.mts +39 -0
  308. package/Utils/AiRemediation/VerifiedFixRunbook.d.ts +39 -0
  309. package/Utils/AiRemediation/VerifiedFixRunbook.js +231 -0
  310. package/Utils/AiRemediation/VerifiedFixRunbook.mjs +10 -0
  311. package/Utils/Dashboard/DashboardWidgetSorts.js +11 -2
  312. package/Utils/Dashboard/MonitorListWidgetFormat.d.mts +2 -1
  313. package/Utils/Dashboard/MonitorListWidgetFormat.d.ts +2 -1
  314. package/Utils/Dashboard/MonitorListWidgetFormat.js +5 -3
  315. package/Utils/Dashboard/ValueWidgetSeries.d.mts +2 -0
  316. package/Utils/Dashboard/ValueWidgetSeries.d.ts +2 -0
  317. package/Utils/Dashboard/ValueWidgetSeries.js +75 -0
  318. package/Utils/DefaultRecordNames.d.mts +6 -0
  319. package/Utils/DefaultRecordNames.d.ts +6 -0
  320. package/Utils/DefaultRecordNames.js +122 -0
  321. package/Utils/DefaultRecordNames.mjs +6 -0
  322. package/Utils/DeveloperDocs/ExampleBuilder.js +1 -1
  323. package/Utils/DeveloperDocs/ResourceProfiles.js +2 -2
  324. package/Utils/Grok/Grok.js +7 -4
  325. package/Utils/GuidedSetup/StatusPageRecords.d.mts +5 -0
  326. package/Utils/GuidedSetup/StatusPageRecords.d.ts +5 -0
  327. package/Utils/GuidedSetup/StatusPageRecords.js +27 -2
  328. package/Utils/GuidedSetup/StatusPageRecords.mjs +1 -0
  329. package/Utils/GuidedSetup/WebsiteMonitorRecords.js +6 -0
  330. package/Utils/HostAddressUtil.d.mts +1 -0
  331. package/Utils/HostAddressUtil.d.ts +1 -0
  332. package/Utils/HostAddressUtil.js +30 -0
  333. package/Utils/Incident/PostmortemActionItemCodeTask.d.mts +20 -0
  334. package/Utils/Incident/PostmortemActionItemCodeTask.d.ts +20 -0
  335. package/Utils/Incident/PostmortemActionItemCodeTask.js +107 -0
  336. package/Utils/Incident/PostmortemActionItemCodeTask.mjs +10 -0
  337. package/Utils/Incident/PostmortemActionItemMarkdown.d.mts +39 -0
  338. package/Utils/Incident/PostmortemActionItemMarkdown.d.ts +39 -0
  339. package/Utils/Incident/PostmortemActionItemMarkdown.js +118 -0
  340. package/Utils/Incident/PostmortemActionItemMarkdown.mjs +12 -0
  341. package/Utils/Incident/PostmortemNoteActionItems.d.mts +29 -0
  342. package/Utils/Incident/PostmortemNoteActionItems.d.ts +29 -0
  343. package/Utils/Incident/PostmortemNoteActionItems.js +544 -0
  344. package/Utils/Incident/PostmortemNoteActionItems.mjs +7 -0
  345. package/Utils/LinearRegExp/LinearRegExp.js +5 -1
  346. package/Utils/LookupTable.d.mts +3 -0
  347. package/Utils/LookupTable.d.ts +3 -0
  348. package/Utils/LookupTable.js +61 -0
  349. package/Utils/LookupTable.mjs +3 -0
  350. package/Utils/Markdown/LinkReferenceDefinitions.d.mts +2 -0
  351. package/Utils/Markdown/LinkReferenceDefinitions.d.ts +2 -0
  352. package/Utils/Markdown/LinkReferenceDefinitions.js +101 -1
  353. package/Utils/Markdown/LinkReferenceDefinitions.mjs +2 -0
  354. package/Utils/Markdown/OverLongText.js +296 -2
  355. package/Utils/Markdown/SlowMarkdown.d.mts +1 -0
  356. package/Utils/Markdown/SlowMarkdown.d.ts +1 -0
  357. package/Utils/Markdown/SlowMarkdown.js +354 -4
  358. package/Utils/Markdown/SlowMarkdown.mjs +1 -0
  359. package/Utils/Metrics/MetricFormulaEvaluator.js +10 -4
  360. package/Utils/Metrics/MetricSeriesFingerprint.js +13 -4
  361. package/Utils/Metrics/MetricSeriesScope.d.mts +5 -0
  362. package/Utils/Metrics/MetricSeriesScope.d.ts +5 -0
  363. package/Utils/Metrics/MetricSeriesScope.js +5 -1
  364. package/Utils/Milliseconds.d.mts +7 -0
  365. package/Utils/Milliseconds.d.ts +7 -0
  366. package/Utils/Milliseconds.js +60 -0
  367. package/Utils/Milliseconds.mjs +4 -0
  368. package/Utils/Monitor/EndpointAttachmentUtil.d.mts +8 -0
  369. package/Utils/Monitor/EndpointAttachmentUtil.d.ts +8 -0
  370. package/Utils/Monitor/EndpointAttachmentUtil.js +91 -21
  371. package/Utils/Monitor/EndpointAttachmentUtil.mjs +4 -0
  372. package/Utils/Monitor/InterfaceInventoryUtil.d.mts +40 -0
  373. package/Utils/Monitor/InterfaceInventoryUtil.d.ts +40 -0
  374. package/Utils/Monitor/InterfaceInventoryUtil.js +217 -5
  375. package/Utils/Monitor/InterfaceInventoryUtil.mjs +8 -0
  376. package/Utils/Monitor/MonitorOverviewPresentationUtil.js +63 -29
  377. package/Utils/Monitor/MonitorOverviewProbeUtil.js +13 -2
  378. package/Utils/Monitor/MonitorRootCauseWording.d.mts +5 -0
  379. package/Utils/Monitor/MonitorRootCauseWording.d.ts +5 -0
  380. package/Utils/Monitor/MonitorRootCauseWording.js +148 -5
  381. package/Utils/Monitor/MonitoringOff.d.mts +2 -0
  382. package/Utils/Monitor/MonitoringOff.d.ts +2 -0
  383. package/Utils/Monitor/MonitoringOff.js +21 -0
  384. package/Utils/Monitor/NetworkTopologyUtil.d.mts +2 -1
  385. package/Utils/Monitor/NetworkTopologyUtil.d.ts +2 -1
  386. package/Utils/Monitor/NetworkTopologyUtil.js +10 -0
  387. package/Utils/Monitor/NotOperationalMonitorQuery.d.mts +2 -1
  388. package/Utils/Monitor/NotOperationalMonitorQuery.d.ts +2 -1
  389. package/Utils/Monitor/NotOperationalMonitorQuery.js +23 -4
  390. package/Utils/Monitor/ProbeAgreementRule.d.mts +10 -0
  391. package/Utils/Monitor/ProbeAgreementRule.d.ts +10 -0
  392. package/Utils/Monitor/ProbeAgreementRule.js +58 -0
  393. package/Utils/Monitor/ProbeAgreementRule.mjs +3 -0
  394. package/Utils/Monitor/ProbeFailureReading.d.mts +18 -0
  395. package/Utils/Monitor/ProbeFailureReading.d.ts +18 -0
  396. package/Utils/Monitor/ProbeFailureReading.js +166 -0
  397. package/Utils/Monitor/ProbeFailureReading.mjs +8 -0
  398. package/Utils/Monitor/RequestFailureDescriptions.d.mts +61 -0
  399. package/Utils/Monitor/RequestFailureDescriptions.d.ts +61 -0
  400. package/Utils/Monitor/RequestFailureDescriptions.js +252 -0
  401. package/Utils/Monitor/RequestFailureDescriptions.mjs +6 -0
  402. package/Utils/NetworkDevice/BoundMonitorNotChecked.d.mts +9 -0
  403. package/Utils/NetworkDevice/BoundMonitorNotChecked.d.ts +9 -0
  404. package/Utils/NetworkDevice/BoundMonitorNotChecked.js +15 -0
  405. package/Utils/NetworkDevice/BoundMonitorNotChecked.mjs +2 -0
  406. package/Utils/Project/NextNumber.js +1 -1
  407. package/Utils/PromQL/PromQLAst.d.mts +159 -0
  408. package/Utils/PromQL/PromQLAst.d.ts +159 -0
  409. package/Utils/PromQL/PromQLAst.js +118 -0
  410. package/Utils/PromQL/PromQLAst.mjs +12 -0
  411. package/Utils/PromQL/PromQLDuration.d.mts +2 -0
  412. package/Utils/PromQL/PromQLDuration.d.ts +2 -0
  413. package/Utils/PromQL/PromQLDuration.js +78 -0
  414. package/Utils/PromQL/PromQLDuration.mjs +3 -0
  415. package/Utils/PromQL/PromQLEngine.d.mts +15 -0
  416. package/Utils/PromQL/PromQLEngine.d.ts +15 -0
  417. package/Utils/PromQL/PromQLEngine.js +974 -0
  418. package/Utils/PromQL/PromQLEngine.mjs +7 -0
  419. package/Utils/PromQL/PromQLEngineTypes.d.mts +84 -0
  420. package/Utils/PromQL/PromQLEngineTypes.d.ts +84 -0
  421. package/Utils/PromQL/PromQLEngineTypes.js +10 -0
  422. package/Utils/PromQL/PromQLEngineTypes.mjs +2 -0
  423. package/Utils/PromQL/PromQLError.d.mts +11 -0
  424. package/Utils/PromQL/PromQLError.d.ts +11 -0
  425. package/Utils/PromQL/PromQLError.js +27 -0
  426. package/Utils/PromQL/PromQLError.mjs +3 -0
  427. package/Utils/PromQL/PromQLFunctionEvaluators.d.mts +8 -0
  428. package/Utils/PromQL/PromQLFunctionEvaluators.d.ts +8 -0
  429. package/Utils/PromQL/PromQLFunctionEvaluators.js +829 -0
  430. package/Utils/PromQL/PromQLFunctionEvaluators.mjs +3 -0
  431. package/Utils/PromQL/PromQLFunctions.d.mts +10 -0
  432. package/Utils/PromQL/PromQLFunctions.d.ts +10 -0
  433. package/Utils/PromQL/PromQLFunctions.js +127 -0
  434. package/Utils/PromQL/PromQLFunctions.mjs +4 -0
  435. package/Utils/PromQL/PromQLLabelOrder.d.mts +8 -0
  436. package/Utils/PromQL/PromQLLabelOrder.d.ts +8 -0
  437. package/Utils/PromQL/PromQLLabelOrder.js +212 -0
  438. package/Utils/PromQL/PromQLLabelOrder.mjs +6 -0
  439. package/Utils/PromQL/PromQLLabels.d.mts +11 -0
  440. package/Utils/PromQL/PromQLLabels.d.ts +11 -0
  441. package/Utils/PromQL/PromQLLabels.js +219 -0
  442. package/Utils/PromQL/PromQLLabels.mjs +9 -0
  443. package/Utils/PromQL/PromQLLexer.d.mts +39 -0
  444. package/Utils/PromQL/PromQLLexer.d.ts +39 -0
  445. package/Utils/PromQL/PromQLLexer.js +391 -0
  446. package/Utils/PromQL/PromQLLexer.mjs +3 -0
  447. package/Utils/PromQL/PromQLMath.d.mts +19 -0
  448. package/Utils/PromQL/PromQLMath.d.ts +19 -0
  449. package/Utils/PromQL/PromQLMath.js +200 -0
  450. package/Utils/PromQL/PromQLMath.mjs +9 -0
  451. package/Utils/PromQL/PromQLMetricNames.d.mts +21 -0
  452. package/Utils/PromQL/PromQLMetricNames.d.ts +21 -0
  453. package/Utils/PromQL/PromQLMetricNames.js +205 -0
  454. package/Utils/PromQL/PromQLMetricNames.mjs +8 -0
  455. package/Utils/PromQL/PromQLParser.d.mts +4 -0
  456. package/Utils/PromQL/PromQLParser.d.ts +4 -0
  457. package/Utils/PromQL/PromQLParser.js +836 -0
  458. package/Utils/PromQL/PromQLParser.mjs +4 -0
  459. package/Utils/PromQL/PromQLRegex.d.mts +20 -0
  460. package/Utils/PromQL/PromQLRegex.d.ts +20 -0
  461. package/Utils/PromQL/PromQLRegex.js +1014 -0
  462. package/Utils/PromQL/PromQLRegex.mjs +5 -0
  463. package/Utils/PromQL/PrometheusResponse.d.mts +25 -0
  464. package/Utils/PromQL/PrometheusResponse.d.ts +25 -0
  465. package/Utils/PromQL/PrometheusResponse.js +92 -0
  466. package/Utils/PromQL/PrometheusResponse.mjs +3 -0
  467. package/Utils/PromQL/RE2CharacterClass.d.mts +24 -0
  468. package/Utils/PromQL/RE2CharacterClass.d.ts +24 -0
  469. package/Utils/PromQL/RE2CharacterClass.js +532 -0
  470. package/Utils/PromQL/RE2CharacterClass.mjs +16 -0
  471. package/Utils/RequestFailedDetailsUtil.d.mts +15 -0
  472. package/Utils/RequestFailedDetailsUtil.d.ts +15 -0
  473. package/Utils/RequestFailedDetailsUtil.js +452 -0
  474. package/Utils/RequestFailedDetailsUtil.mjs +2 -0
  475. package/Utils/Rum/PathInSentence.d.mts +5 -0
  476. package/Utils/Rum/PathInSentence.d.ts +5 -0
  477. package/Utils/Rum/PathInSentence.js +46 -0
  478. package/Utils/Rum/PathInSentence.mjs +6 -0
  479. package/Utils/Rum/UrlScrubber.d.mts +5 -1
  480. package/Utils/Rum/UrlScrubber.d.ts +5 -1
  481. package/Utils/Rum/UrlScrubber.js +153 -7
  482. package/Utils/Rum/UserFlow.d.mts +1 -1
  483. package/Utils/Rum/UserFlow.d.ts +1 -1
  484. package/Utils/Rum/UserFlow.js +202 -29
  485. package/Utils/Rum/UserFlow.mjs +1 -1
  486. package/Utils/Runbook/RunbookStepsSignature.d.mts +3 -0
  487. package/Utils/Runbook/RunbookStepsSignature.d.ts +3 -0
  488. package/Utils/Runbook/RunbookStepsSignature.js +30 -0
  489. package/Utils/Runbook/RunbookStepsSignature.mjs +3 -0
  490. package/Utils/Schema/TypeSchemas.js +6 -0
  491. package/Utils/SecurityCase/SecurityOverviewMetrics.d.mts +11 -1
  492. package/Utils/SecurityCase/SecurityOverviewMetrics.d.ts +11 -1
  493. package/Utils/SecurityCase/SecurityOverviewMetrics.js +99 -17
  494. package/Utils/SecurityCase/SecurityOverviewMetrics.mjs +3 -0
  495. package/Utils/Slo/SloDuration.d.mts +5 -2
  496. package/Utils/Slo/SloDuration.d.ts +5 -2
  497. package/Utils/Slo/SloDuration.js +11 -6
  498. package/Utils/Slo/SloHealth.js +1 -1
  499. package/Utils/Sms/OnCallPageSms.d.mts +2 -0
  500. package/Utils/Sms/OnCallPageSms.d.ts +2 -0
  501. package/Utils/Sms/OnCallPageSms.js +3 -1
  502. package/Utils/StateListType.d.mts +11 -0
  503. package/Utils/StateListType.d.ts +11 -0
  504. package/Utils/StateListType.js +21 -0
  505. package/Utils/StateListType.mjs +2 -0
  506. package/Utils/StateOrder.d.mts +8 -11
  507. package/Utils/StateOrder.d.ts +8 -11
  508. package/Utils/StateOrder.js +50 -88
  509. package/Utils/StateOrder.mjs +2 -0
  510. package/Utils/StateTimeline/StateTimelineRowDelete.js +1 -1
  511. package/Utils/Suggestions/ActionItemCodeTaskSuggestion.d.mts +9 -0
  512. package/Utils/Suggestions/ActionItemCodeTaskSuggestion.d.ts +9 -0
  513. package/Utils/Suggestions/ActionItemCodeTaskSuggestion.js +25 -0
  514. package/Utils/Suggestions/ActionItemCodeTaskSuggestion.mjs +2 -0
  515. package/Utils/Suggestions/VerifiedFixRunbookSuggestion.d.mts +5 -0
  516. package/Utils/Suggestions/VerifiedFixRunbookSuggestion.d.ts +5 -0
  517. package/Utils/Suggestions/VerifiedFixRunbookSuggestion.js +39 -0
  518. package/Utils/Suggestions/VerifiedFixRunbookSuggestion.mjs +2 -0
  519. package/Utils/Syslog/SyslogMessageParser.js +16 -6
  520. package/Utils/Telemetry/HeartbeatAvailability.d.mts +4 -0
  521. package/Utils/Telemetry/HeartbeatAvailability.d.ts +4 -0
  522. package/Utils/Telemetry/HeartbeatAvailability.js +113 -26
  523. package/Utils/Uptime/DayUptimeGraphUtil.js +2 -2
  524. package/Utils/ValueFormatter.d.mts +1 -0
  525. package/Utils/ValueFormatter.d.ts +1 -0
  526. package/Utils/ValueFormatter.js +258 -18
  527. package/package.json +1 -1
@@ -0,0 +1,793 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SERVER_EMAIL_COLUMNS = exports.SERVER_EMAIL_SET_BY_ENVIRONMENT_MESSAGE = exports.SERVER_EMAIL_ENVIRONMENT_ROUTE = exports.SERVER_EMAIL_MAILGUN_REGION_VALUES = exports.SERVER_EMAIL_AMAZON_SES_AUTHENTICATION_TYPE_VALUES = exports.SERVER_EMAIL_SMTP_OAUTH_PROVIDER_TYPE_VALUES = exports.SERVER_EMAIL_SMTP_AUTH_TYPE_VALUES = exports.SERVER_EMAIL_SMTP_TRANSPORT_VALUES = exports.SERVER_EMAIL_SERVER_TYPE_VALUES = exports.SERVER_EMAIL_SECRET_VARIABLES = exports.SERVER_EMAIL_ENVIRONMENT_VARIABLES = exports.ServerEmailEnvironmentVariable = void 0;
7
+ const GlobalConfig_1 = require("../../Models/DatabaseModels/GlobalConfig");
8
+ const AwsRegionCode_1 = require("../Cloud/AwsRegionCode");
9
+ const Email_1 = __importDefault(require("../Email"));
10
+ const Hostname_1 = __importDefault(require("../API/Hostname"));
11
+ const URL_1 = __importDefault(require("../API/URL"));
12
+ const Port_1 = __importDefault(require("../Port"));
13
+ const RefusedValue_1 = require("../../Utils/RefusedValue");
14
+ const AmazonSesAuthenticationType_1 = __importDefault(require("./AmazonSesAuthenticationType"));
15
+ const MailgunDomain_1 = require("./MailgunDomain");
16
+ const MailgunRegion_1 = __importDefault(require("./MailgunRegion"));
17
+ const MailTransportType_1 = __importDefault(require("./MailTransportType"));
18
+ const OAuthProviderType_1 = __importDefault(require("./OAuthProviderType"));
19
+ const SMTPAuthenticationType_1 = __importDefault(require("./SMTPAuthenticationType"));
20
+ /*
21
+ * THE SERVER'S OWN EMAIL SETTINGS, SET BY ENVIRONMENT VARIABLES (#7738).
22
+ *
23
+ * Admin Dashboard > Settings > Emails keeps how the server sends its own
24
+ * email in GlobalConfig: the Email Server Type, and that type's settings -
25
+ * a mail server (Custom SMTP, or Microsoft Graph), or SendGrid, Amazon SES,
26
+ * Mailgun, Postmark or Resend. An installation that keeps its configuration
27
+ * in code - Helm values, Terraform's helm_release, a config.env kept in git -
28
+ * sets them with these variables instead, as GLOBAL_TWILIO_ does for the
29
+ * server's Twilio account (Types/CallAndSMS/ServerTwilioEnvironment, #7515).
30
+ *
31
+ * Once GLOBAL_EMAIL_SERVER_TYPE is set, the server's email settings are the
32
+ * ones the variables describe: the senders read them (Server/Utils/
33
+ * ServerEmailSettings), the Admin Dashboard shows them without an Edit
34
+ * button, and the server refuses a write to the saved ones
35
+ * (GlobalConfigService). Unset, the saved settings apply again, as they
36
+ * were. Nothing is copied into the database, so a password or a key stays
37
+ * where it was given: a Kubernetes Secret, or config.env.
38
+ *
39
+ * All of the settings come from the variables, or none of them: a variable
40
+ * left unset is empty, never the saved value, so the variables are the
41
+ * whole of the settings and a value nobody wrote down cannot change what is
42
+ * sent.
43
+ *
44
+ * What is wrong with them is said by the variable's name, and never with a
45
+ * password or a key: when the server starts, on the Admin Dashboard's Email
46
+ * page, and in what the server's sending status says email is missing
47
+ * (ServerChannelSetup). Settings with something wrong send nothing, as
48
+ * settings that are not set up, rather than send through a server or from
49
+ * an address nobody meant. A variable the chosen settings do not read - an
50
+ * SMTP host with SendGrid picked - stops nothing: it is named, as ignored.
51
+ *
52
+ * The variables are new names. SMTP_HOST, SMTP_PORT, SMTP_USERNAME,
53
+ * SMTP_PASSWORD, SMTP_IS_SECURE, SMTP_FROM_EMAIL, SMTP_FROM_NAME and
54
+ * SENDGRID_API_KEY were read once, into a new installation's database, by
55
+ * the UpdateGlobalConfigFromEnv data migration, and an old config.env may
56
+ * still hold them: reading them again would put stale settings over the
57
+ * ones an admin has saved since.
58
+ */
59
+ var ServerEmailEnvironmentVariable;
60
+ (function (ServerEmailEnvironmentVariable) {
61
+ ServerEmailEnvironmentVariable["ServerType"] = "GLOBAL_EMAIL_SERVER_TYPE";
62
+ ServerEmailEnvironmentVariable["FromEmail"] = "GLOBAL_EMAIL_FROM_EMAIL";
63
+ ServerEmailEnvironmentVariable["FromName"] = "GLOBAL_EMAIL_FROM_NAME";
64
+ ServerEmailEnvironmentVariable["SmtpTransport"] = "GLOBAL_EMAIL_SMTP_TRANSPORT";
65
+ ServerEmailEnvironmentVariable["SmtpHost"] = "GLOBAL_EMAIL_SMTP_HOST";
66
+ ServerEmailEnvironmentVariable["SmtpPort"] = "GLOBAL_EMAIL_SMTP_PORT";
67
+ ServerEmailEnvironmentVariable["SmtpRequireTls"] = "GLOBAL_EMAIL_SMTP_REQUIRE_TLS";
68
+ ServerEmailEnvironmentVariable["SmtpAuthType"] = "GLOBAL_EMAIL_SMTP_AUTH_TYPE";
69
+ ServerEmailEnvironmentVariable["SmtpUsername"] = "GLOBAL_EMAIL_SMTP_USERNAME";
70
+ ServerEmailEnvironmentVariable["SmtpPassword"] = "GLOBAL_EMAIL_SMTP_PASSWORD";
71
+ ServerEmailEnvironmentVariable["SmtpOAuthProviderType"] = "GLOBAL_EMAIL_SMTP_OAUTH_PROVIDER_TYPE";
72
+ ServerEmailEnvironmentVariable["SmtpOAuthClientId"] = "GLOBAL_EMAIL_SMTP_OAUTH_CLIENT_ID";
73
+ ServerEmailEnvironmentVariable["SmtpOAuthClientSecret"] = "GLOBAL_EMAIL_SMTP_OAUTH_CLIENT_SECRET";
74
+ ServerEmailEnvironmentVariable["SmtpOAuthTokenUrl"] = "GLOBAL_EMAIL_SMTP_OAUTH_TOKEN_URL";
75
+ ServerEmailEnvironmentVariable["SmtpOAuthScope"] = "GLOBAL_EMAIL_SMTP_OAUTH_SCOPE";
76
+ ServerEmailEnvironmentVariable["SendgridApiKey"] = "GLOBAL_EMAIL_SENDGRID_API_KEY";
77
+ ServerEmailEnvironmentVariable["AmazonSesAuthenticationType"] = "GLOBAL_EMAIL_AMAZON_SES_AUTHENTICATION_TYPE";
78
+ ServerEmailEnvironmentVariable["AmazonSesAccessKeyId"] = "GLOBAL_EMAIL_AMAZON_SES_ACCESS_KEY_ID";
79
+ ServerEmailEnvironmentVariable["AmazonSesSecretAccessKey"] = "GLOBAL_EMAIL_AMAZON_SES_SECRET_ACCESS_KEY";
80
+ ServerEmailEnvironmentVariable["AmazonSesRegion"] = "GLOBAL_EMAIL_AMAZON_SES_REGION";
81
+ ServerEmailEnvironmentVariable["MailgunApiKey"] = "GLOBAL_EMAIL_MAILGUN_API_KEY";
82
+ ServerEmailEnvironmentVariable["MailgunDomain"] = "GLOBAL_EMAIL_MAILGUN_DOMAIN";
83
+ ServerEmailEnvironmentVariable["MailgunRegion"] = "GLOBAL_EMAIL_MAILGUN_REGION";
84
+ ServerEmailEnvironmentVariable["PostmarkServerToken"] = "GLOBAL_EMAIL_POSTMARK_SERVER_TOKEN";
85
+ ServerEmailEnvironmentVariable["ResendApiKey"] = "GLOBAL_EMAIL_RESEND_API_KEY";
86
+ })(ServerEmailEnvironmentVariable || (exports.ServerEmailEnvironmentVariable = ServerEmailEnvironmentVariable = {}));
87
+ // Every variable, the one that turns them on first: the order problems are said in.
88
+ exports.SERVER_EMAIL_ENVIRONMENT_VARIABLES = [
89
+ ServerEmailEnvironmentVariable.ServerType,
90
+ ServerEmailEnvironmentVariable.FromEmail,
91
+ ServerEmailEnvironmentVariable.FromName,
92
+ ServerEmailEnvironmentVariable.SmtpTransport,
93
+ ServerEmailEnvironmentVariable.SmtpHost,
94
+ ServerEmailEnvironmentVariable.SmtpPort,
95
+ ServerEmailEnvironmentVariable.SmtpRequireTls,
96
+ ServerEmailEnvironmentVariable.SmtpAuthType,
97
+ ServerEmailEnvironmentVariable.SmtpUsername,
98
+ ServerEmailEnvironmentVariable.SmtpPassword,
99
+ ServerEmailEnvironmentVariable.SmtpOAuthProviderType,
100
+ ServerEmailEnvironmentVariable.SmtpOAuthClientId,
101
+ ServerEmailEnvironmentVariable.SmtpOAuthClientSecret,
102
+ ServerEmailEnvironmentVariable.SmtpOAuthTokenUrl,
103
+ ServerEmailEnvironmentVariable.SmtpOAuthScope,
104
+ ServerEmailEnvironmentVariable.SendgridApiKey,
105
+ ServerEmailEnvironmentVariable.AmazonSesAuthenticationType,
106
+ ServerEmailEnvironmentVariable.AmazonSesAccessKeyId,
107
+ ServerEmailEnvironmentVariable.AmazonSesSecretAccessKey,
108
+ ServerEmailEnvironmentVariable.AmazonSesRegion,
109
+ ServerEmailEnvironmentVariable.MailgunApiKey,
110
+ ServerEmailEnvironmentVariable.MailgunDomain,
111
+ ServerEmailEnvironmentVariable.MailgunRegion,
112
+ ServerEmailEnvironmentVariable.PostmarkServerToken,
113
+ ServerEmailEnvironmentVariable.ResendApiKey,
114
+ ];
115
+ /*
116
+ * The variables that hold a password or a key: never repeated in a
117
+ * message, never sent to the Admin Dashboard - only whether they are set.
118
+ */
119
+ exports.SERVER_EMAIL_SECRET_VARIABLES = [
120
+ ServerEmailEnvironmentVariable.SmtpPassword,
121
+ ServerEmailEnvironmentVariable.SmtpOAuthClientSecret,
122
+ ServerEmailEnvironmentVariable.SendgridApiKey,
123
+ ServerEmailEnvironmentVariable.AmazonSesSecretAccessKey,
124
+ ServerEmailEnvironmentVariable.MailgunApiKey,
125
+ ServerEmailEnvironmentVariable.PostmarkServerToken,
126
+ ServerEmailEnvironmentVariable.ResendApiKey,
127
+ ];
128
+ /*
129
+ * What GLOBAL_EMAIL_SERVER_TYPE is written as for each Email Server Type,
130
+ * in the docs, the Helm chart and config.example.env. The Admin Dashboard's
131
+ * own words ("Amazon SES") are taken too, in any case and with spaces,
132
+ * hyphens or underscores (readChoice), and smtp for Custom SMTP.
133
+ */
134
+ exports.SERVER_EMAIL_SERVER_TYPE_VALUES = {
135
+ [GlobalConfig_1.EmailServerType.CustomSMTP]: "custom-smtp",
136
+ [GlobalConfig_1.EmailServerType.Sendgrid]: "sendgrid",
137
+ [GlobalConfig_1.EmailServerType.AmazonSES]: "amazon-ses",
138
+ [GlobalConfig_1.EmailServerType.Mailgun]: "mailgun",
139
+ [GlobalConfig_1.EmailServerType.Postmark]: "postmark",
140
+ [GlobalConfig_1.EmailServerType.Resend]: "resend",
141
+ };
142
+ exports.SERVER_EMAIL_SMTP_TRANSPORT_VALUES = {
143
+ [MailTransportType_1.default.SMTP]: "smtp",
144
+ [MailTransportType_1.default.MicrosoftGraph]: "microsoft-graph",
145
+ };
146
+ exports.SERVER_EMAIL_SMTP_AUTH_TYPE_VALUES = {
147
+ [SMTPAuthenticationType_1.default.UsernamePassword]: "username-and-password",
148
+ [SMTPAuthenticationType_1.default.OAuth]: "oauth",
149
+ [SMTPAuthenticationType_1.default.None]: "none",
150
+ };
151
+ exports.SERVER_EMAIL_SMTP_OAUTH_PROVIDER_TYPE_VALUES = {
152
+ [OAuthProviderType_1.default.ClientCredentials]: "client-credentials",
153
+ [OAuthProviderType_1.default.JWTBearer]: "jwt-bearer",
154
+ };
155
+ exports.SERVER_EMAIL_AMAZON_SES_AUTHENTICATION_TYPE_VALUES = {
156
+ [AmazonSesAuthenticationType_1.default.AccessKey]: "access-key",
157
+ [AmazonSesAuthenticationType_1.default.ServerIamRole]: "server-iam-role",
158
+ };
159
+ exports.SERVER_EMAIL_MAILGUN_REGION_VALUES = {
160
+ [MailgunRegion_1.default.US]: "us",
161
+ [MailgunRegion_1.default.EU]: "eu",
162
+ };
163
+ // Where the Admin Dashboard asks the server whether the variables set its email.
164
+ exports.SERVER_EMAIL_ENVIRONMENT_ROUTE = "/global-config/email-environment";
165
+ /*
166
+ * Said when someone tries to change settings the variables set: the server
167
+ * refuses the write (GlobalConfigService), and the docs and the Admin
168
+ * Dashboard say where the settings are changed instead.
169
+ */
170
+ exports.SERVER_EMAIL_SET_BY_ENVIRONMENT_MESSAGE = `This server's email settings are set by environment variables (${ServerEmailEnvironmentVariable.ServerType} and the other GLOBAL_EMAIL_ variables), so they cannot be changed in the Admin Dashboard. Change those variables - email in the Helm chart's values, or config.env with Docker Compose - and restart OneUptime.`;
171
+ exports.SERVER_EMAIL_COLUMNS = [
172
+ "emailServerType",
173
+ "isSMTPSecure",
174
+ "smtpTransportType",
175
+ "smtpAuthType",
176
+ "smtpHost",
177
+ "smtpPort",
178
+ "smtpUsername",
179
+ "smtpPassword",
180
+ "smtpFromEmail",
181
+ "smtpFromName",
182
+ "smtpClientId",
183
+ "smtpClientSecret",
184
+ "smtpTokenUrl",
185
+ "smtpScope",
186
+ "smtpOAuthProviderType",
187
+ "sendgridApiKey",
188
+ "sendgridFromEmail",
189
+ "sendgridFromName",
190
+ "amazonSesAuthenticationType",
191
+ "amazonSesAccessKeyId",
192
+ "amazonSesSecretAccessKey",
193
+ "amazonSesRegion",
194
+ "amazonSesFromEmail",
195
+ "amazonSesFromName",
196
+ "mailgunApiKey",
197
+ "mailgunDomain",
198
+ "mailgunRegion",
199
+ "mailgunFromEmail",
200
+ "mailgunFromName",
201
+ "postmarkServerToken",
202
+ "postmarkFromEmail",
203
+ "postmarkFromName",
204
+ "resendApiKey",
205
+ "resendFromEmail",
206
+ "resendFromName",
207
+ ];
208
+ // "amazonses" for "Amazon SES", "amazon-ses" and "AMAZON_SES".
209
+ const comparable = (value) => {
210
+ return value.toLowerCase().replace(/[^a-z]/g, "");
211
+ };
212
+ // "A", "A and B", "A, B and C".
213
+ const listed = (names) => {
214
+ if (names.length <= 1) {
215
+ return names.join("");
216
+ }
217
+ return `${names.slice(0, -1).join(", ")} and ${names[names.length - 1]}`;
218
+ };
219
+ // "A or B", "A, B or C".
220
+ const eitherOf = (names) => {
221
+ if (names.length <= 1) {
222
+ return names.join("");
223
+ }
224
+ return `${names.slice(0, -1).join(", ")} or ${names[names.length - 1]}`;
225
+ };
226
+ const NO_SETTINGS_ANSWER = {
227
+ isSetByEnvironment: false,
228
+ serverType: null,
229
+ fields: [],
230
+ problems: [],
231
+ ignored: [],
232
+ };
233
+ // An http or https URL's scheme and host, and any white space.
234
+ const HTTP_URL_START = /^https?:\/\/[^\s/]+/i;
235
+ const WHITE_SPACE = /\s/;
236
+ // A port as written: one to five digits.
237
+ const PORT_DIGITS = /^[0-9]{1,5}$/;
238
+ class ServerEmailEnvironment {
239
+ /*
240
+ * The choice a variable names: the documented value, or the Admin
241
+ * Dashboard's own words for it, in any case and with spaces, hyphens or
242
+ * underscores. The default when it is empty, or null when it names none.
243
+ */
244
+ static readChoice(value, values, defaultChoice, aliases = {}) {
245
+ const written = comparable((value || "").trim());
246
+ if (!written) {
247
+ return defaultChoice;
248
+ }
249
+ for (const choice of Object.keys(values)) {
250
+ if (comparable(choice) === written ||
251
+ comparable(values[choice]) === written) {
252
+ return choice;
253
+ }
254
+ }
255
+ for (const alias of Object.keys(aliases)) {
256
+ if (comparable(alias) === written) {
257
+ return aliases[alias];
258
+ }
259
+ }
260
+ return null;
261
+ }
262
+ // The Email Server Type GLOBAL_EMAIL_SERVER_TYPE names, or null.
263
+ static readServerType(value) {
264
+ return ServerEmailEnvironment.readChoice(value, exports.SERVER_EMAIL_SERVER_TYPE_VALUES, null, { smtp: GlobalConfig_1.EmailServerType.CustomSMTP });
265
+ }
266
+ static isSecret(variable) {
267
+ return exports.SERVER_EMAIL_SECRET_VARIABLES.includes(variable);
268
+ }
269
+ /*
270
+ * A mail server's host name or IP address alone, as the mail service
271
+ * connects to it: no port (GLOBAL_EMAIL_SMTP_PORT has it), no user name,
272
+ * no scheme or path.
273
+ */
274
+ static isBareHost(value) {
275
+ const host = value.trim();
276
+ if (!host ||
277
+ host.includes("@") ||
278
+ host.includes("/") ||
279
+ host.includes("[")) {
280
+ return false;
281
+ }
282
+ // One colon is a port; an IPv6 address has two or more.
283
+ if (host.split(":").length === 2) {
284
+ return false;
285
+ }
286
+ return Hostname_1.default.isValid(host);
287
+ }
288
+ // An OAuth token endpoint: an http or https URL the server can parse.
289
+ static isTokenUrl(value) {
290
+ const text = value.trim();
291
+ if (!HTTP_URL_START.test(text) || WHITE_SPACE.test(text)) {
292
+ return false;
293
+ }
294
+ try {
295
+ URL_1.default.fromString(text);
296
+ return true;
297
+ }
298
+ catch (_a) {
299
+ return false;
300
+ }
301
+ }
302
+ /*
303
+ * The server's email settings as the environment sets them - process.env
304
+ * on the server, read again on every call, so nothing it held goes stale.
305
+ * Each value is read without the whitespace around it: a key read from a
306
+ * file keeps its final newline (helm --set-file, Terraform's file()).
307
+ */
308
+ static read(environment) {
309
+ const value = (variable) => {
310
+ const written = environment[variable];
311
+ return typeof written === "string" ? written.trim() : "";
312
+ };
313
+ const setVariables = exports.SERVER_EMAIL_ENVIRONMENT_VARIABLES.filter((variable) => {
314
+ return Boolean(value(variable));
315
+ });
316
+ const values = {};
317
+ for (const variable of setVariables) {
318
+ values[variable] = value(variable);
319
+ }
320
+ const serverTypeText = value(ServerEmailEnvironmentVariable.ServerType);
321
+ if (!serverTypeText) {
322
+ return {
323
+ isSet: false,
324
+ serverType: null,
325
+ settings: null,
326
+ problems: setVariables.length > 0
327
+ ? [
328
+ `${listed(setVariables)} ${setVariables.length === 1 ? "is" : "are"} set, but ${ServerEmailEnvironmentVariable.ServerType} is not, so nothing reads ${setVariables.length === 1 ? "it" : "them"}: the email settings saved in the Admin Dashboard are used. Set ${ServerEmailEnvironmentVariable.ServerType} too, or remove ${setVariables.length === 1 ? "it" : "them"}.`,
329
+ ]
330
+ : [],
331
+ ignored: [],
332
+ values: values,
333
+ };
334
+ }
335
+ const serverType = ServerEmailEnvironment.readServerType(serverTypeText);
336
+ if (!serverType) {
337
+ return {
338
+ isSet: true,
339
+ serverType: null,
340
+ settings: null,
341
+ problems: [
342
+ `${ServerEmailEnvironmentVariable.ServerType} must be ${eitherOf(Object.values(exports.SERVER_EMAIL_SERVER_TYPE_VALUES))}, not "${(0, RefusedValue_1.refusedValue)(serverTypeText)}".`,
343
+ ],
344
+ ignored: [],
345
+ values: values,
346
+ };
347
+ }
348
+ const problems = [];
349
+ /*
350
+ * Only the columns the variables fill: one they leave empty is not
351
+ * there, and reads as empty - never as the saved value.
352
+ */
353
+ const settings = { emailServerType: serverType };
354
+ const put = (column, columnValue) => {
355
+ if (columnValue === undefined || columnValue === "") {
356
+ return;
357
+ }
358
+ settings[column] = columnValue;
359
+ };
360
+ // Each variable the chosen settings read, as they are read below.
361
+ const readVariables = new Set([
362
+ ServerEmailEnvironmentVariable.ServerType,
363
+ ]);
364
+ const take = (variable) => {
365
+ readVariables.add(variable);
366
+ return value(variable);
367
+ };
368
+ const notSet = (variable, why) => {
369
+ problems.push(`${variable} is not set: ${why}`);
370
+ };
371
+ // A choice the variable must name, or a problem that lists the ones it can.
372
+ const choice = (variable, values, defaultChoice) => {
373
+ const text = take(variable);
374
+ const picked = ServerEmailEnvironment.readChoice(text, values, defaultChoice);
375
+ if (picked === null) {
376
+ problems.push(`${variable} must be ${eitherOf(Object.values(values))}, not "${(0, RefusedValue_1.refusedValue)(text)}".`);
377
+ return defaultChoice;
378
+ }
379
+ return picked;
380
+ };
381
+ // Who the emails come from: every type needs the address.
382
+ const fromEmailText = take(ServerEmailEnvironmentVariable.FromEmail);
383
+ let fromEmail = undefined;
384
+ if (!fromEmailText) {
385
+ notSet(ServerEmailEnvironmentVariable.FromEmail, "every email needs the address it comes from.");
386
+ }
387
+ else if (!Email_1.default.isValid(fromEmailText)) {
388
+ problems.push(`${ServerEmailEnvironmentVariable.FromEmail}: "${(0, RefusedValue_1.refusedValue)(fromEmailText)}" is not an email address.`);
389
+ }
390
+ else {
391
+ fromEmail = new Email_1.default(fromEmailText);
392
+ }
393
+ const fromName = take(ServerEmailEnvironmentVariable.FromName);
394
+ /*
395
+ * Custom SMTP and SendGrid send with the name too, as the Admin
396
+ * Dashboard's forms ask for it; the providers with an HTTP API of their
397
+ * own send with the product's name when it is empty.
398
+ */
399
+ if (!fromName &&
400
+ (serverType === GlobalConfig_1.EmailServerType.CustomSMTP ||
401
+ serverType === GlobalConfig_1.EmailServerType.Sendgrid)) {
402
+ notSet(ServerEmailEnvironmentVariable.FromName, `${exports.SERVER_EMAIL_SERVER_TYPE_VALUES[serverType]} sends every email with the name it comes from.`);
403
+ }
404
+ // A value the chosen settings cannot send without, and why when it is empty.
405
+ const needed = (variable, why) => {
406
+ const text = take(variable);
407
+ if (!text) {
408
+ notSet(variable, why);
409
+ }
410
+ return text;
411
+ };
412
+ switch (serverType) {
413
+ case GlobalConfig_1.EmailServerType.CustomSMTP: {
414
+ const transport = choice(ServerEmailEnvironmentVariable.SmtpTransport, exports.SERVER_EMAIL_SMTP_TRANSPORT_VALUES, MailTransportType_1.default.SMTP);
415
+ put("smtpTransportType", transport);
416
+ put("smtpFromEmail", fromEmail);
417
+ put("smtpFromName", fromName);
418
+ let usesOAuth = transport === MailTransportType_1.default.MicrosoftGraph;
419
+ let usesJwtBearer = false;
420
+ if (transport === MailTransportType_1.default.SMTP) {
421
+ const hostText = take(ServerEmailEnvironmentVariable.SmtpHost);
422
+ if (!hostText) {
423
+ notSet(ServerEmailEnvironmentVariable.SmtpHost, "email goes out through that mail server, such as smtp.example.com.");
424
+ }
425
+ else if (!ServerEmailEnvironment.isBareHost(hostText)) {
426
+ problems.push(`${ServerEmailEnvironmentVariable.SmtpHost}: "${(0, RefusedValue_1.refusedValue)(hostText)}" is not a host name, such as smtp.example.com. The port goes in ${ServerEmailEnvironmentVariable.SmtpPort}.`);
427
+ }
428
+ else {
429
+ put("smtpHost", new Hostname_1.default(hostText));
430
+ }
431
+ const portText = take(ServerEmailEnvironmentVariable.SmtpPort);
432
+ if (!portText) {
433
+ notSet(ServerEmailEnvironmentVariable.SmtpPort, "most mail servers take 587.");
434
+ }
435
+ else if (!PORT_DIGITS.test(portText) ||
436
+ Number(portText) < 1 ||
437
+ Number(portText) > 65535) {
438
+ problems.push(`${ServerEmailEnvironmentVariable.SmtpPort}: "${(0, RefusedValue_1.refusedValue)(portText)}" is not a port, a number from 1 to 65535 such as 587.`);
439
+ }
440
+ else {
441
+ put("smtpPort", new Port_1.default(Number(portText)));
442
+ }
443
+ const requireTlsText = take(ServerEmailEnvironmentVariable.SmtpRequireTls).toLowerCase();
444
+ if (requireTlsText === "true") {
445
+ put("isSMTPSecure", true);
446
+ }
447
+ else if (!requireTlsText || requireTlsText === "false") {
448
+ put("isSMTPSecure", false);
449
+ }
450
+ else {
451
+ problems.push(`${ServerEmailEnvironmentVariable.SmtpRequireTls} must be true or false, not "${(0, RefusedValue_1.refusedValue)(requireTlsText)}".`);
452
+ }
453
+ const authType = choice(ServerEmailEnvironmentVariable.SmtpAuthType, exports.SERVER_EMAIL_SMTP_AUTH_TYPE_VALUES, SMTPAuthenticationType_1.default.UsernamePassword);
454
+ put("smtpAuthType", authType);
455
+ if (authType === SMTPAuthenticationType_1.default.UsernamePassword) {
456
+ /*
457
+ * Both or neither: the mail service signs in only with both, so
458
+ * one alone would send without signing in - most often a
459
+ * password that did not arrive from its Secret.
460
+ */
461
+ const username = take(ServerEmailEnvironmentVariable.SmtpUsername);
462
+ const password = take(ServerEmailEnvironmentVariable.SmtpPassword);
463
+ if (username && !password) {
464
+ notSet(ServerEmailEnvironmentVariable.SmtpPassword, `the mail server is signed in to with ${ServerEmailEnvironmentVariable.SmtpUsername} and a password. Set it, or set ${ServerEmailEnvironmentVariable.SmtpAuthType} to none to send without signing in.`);
465
+ }
466
+ else if (password && !username) {
467
+ notSet(ServerEmailEnvironmentVariable.SmtpUsername, `the mail server is signed in to with a username and ${ServerEmailEnvironmentVariable.SmtpPassword}.`);
468
+ }
469
+ put("smtpUsername", username);
470
+ put("smtpPassword", password);
471
+ }
472
+ else if (authType === SMTPAuthenticationType_1.default.OAuth) {
473
+ const providerType = choice(ServerEmailEnvironmentVariable.SmtpOAuthProviderType, exports.SERVER_EMAIL_SMTP_OAUTH_PROVIDER_TYPE_VALUES, OAuthProviderType_1.default.ClientCredentials);
474
+ // Left empty, as an admin who never picked it: Client Credentials.
475
+ put("smtpOAuthProviderType", value(ServerEmailEnvironmentVariable.SmtpOAuthProviderType)
476
+ ? providerType
477
+ : undefined);
478
+ usesJwtBearer = providerType === OAuthProviderType_1.default.JWTBearer;
479
+ /*
480
+ * The mailbox OAuth signs in as, with either grant: the user
481
+ * the mail server's XOAUTH2 sign-in names, and what JWT Bearer
482
+ * impersonates. MailService refuses every email without one,
483
+ * so the settings are not usable without it.
484
+ */
485
+ const username = take(ServerEmailEnvironmentVariable.SmtpUsername);
486
+ if (!username) {
487
+ notSet(ServerEmailEnvironmentVariable.SmtpUsername, `with ${ServerEmailEnvironmentVariable.SmtpAuthType} ${exports.SERVER_EMAIL_SMTP_AUTH_TYPE_VALUES[SMTPAuthenticationType_1.default.OAuth]}, the mail server is signed in to as that mailbox, such as alerts@example.com.`);
488
+ }
489
+ put("smtpUsername", username);
490
+ usesOAuth = true;
491
+ }
492
+ }
493
+ if (usesOAuth) {
494
+ const signsInWith = transport === MailTransportType_1.default.MicrosoftGraph
495
+ ? "Microsoft Graph sends with an OAuth app's client ID, client secret, token URL and scope."
496
+ : "the mail server is signed in to with an OAuth app's client ID, client secret, token URL and scope.";
497
+ put("smtpClientId", needed(ServerEmailEnvironmentVariable.SmtpOAuthClientId, signsInWith));
498
+ const clientSecret = needed(ServerEmailEnvironmentVariable.SmtpOAuthClientSecret, signsInWith);
499
+ /*
500
+ * JWT Bearer signs its request with a private key, given as the
501
+ * client secret: anything else could never sign in
502
+ * (SMTPOAuthService). Said without the value.
503
+ */
504
+ if (clientSecret &&
505
+ usesJwtBearer &&
506
+ !(clientSecret.includes("-----BEGIN") &&
507
+ clientSecret.includes("PRIVATE KEY"))) {
508
+ problems.push(`${ServerEmailEnvironmentVariable.SmtpOAuthClientSecret} is not a private key in PEM format (-----BEGIN PRIVATE KEY-----), which ${exports.SERVER_EMAIL_SMTP_OAUTH_PROVIDER_TYPE_VALUES[OAuthProviderType_1.default.JWTBearer]} signs in with.`);
509
+ }
510
+ put("smtpClientSecret", clientSecret);
511
+ const tokenUrlText = needed(ServerEmailEnvironmentVariable.SmtpOAuthTokenUrl, signsInWith);
512
+ if (tokenUrlText) {
513
+ if (ServerEmailEnvironment.isTokenUrl(tokenUrlText)) {
514
+ put("smtpTokenUrl", tokenUrlText);
515
+ }
516
+ else {
517
+ problems.push(`${ServerEmailEnvironmentVariable.SmtpOAuthTokenUrl}: "${(0, RefusedValue_1.refusedValue)(tokenUrlText)}" is not a URL, such as https://login.microsoftonline.com/<tenant>/oauth2/v2.0/token.`);
518
+ }
519
+ }
520
+ put("smtpScope", needed(ServerEmailEnvironmentVariable.SmtpOAuthScope, signsInWith));
521
+ }
522
+ break;
523
+ }
524
+ case GlobalConfig_1.EmailServerType.Sendgrid: {
525
+ put("sendgridApiKey", needed(ServerEmailEnvironmentVariable.SendgridApiKey, "SendGrid sends nothing without it."));
526
+ put("sendgridFromEmail", fromEmail);
527
+ put("sendgridFromName", fromName);
528
+ break;
529
+ }
530
+ case GlobalConfig_1.EmailServerType.AmazonSES: {
531
+ const authenticationType = choice(ServerEmailEnvironmentVariable.AmazonSesAuthenticationType, exports.SERVER_EMAIL_AMAZON_SES_AUTHENTICATION_TYPE_VALUES, AmazonSesAuthenticationType_1.default.AccessKey);
532
+ put("amazonSesAuthenticationType", authenticationType);
533
+ /*
534
+ * Signed in as the server's own IAM role (#7000), it needs no key:
535
+ * the credentials are the role's, fetched when the email goes.
536
+ */
537
+ if (authenticationType === AmazonSesAuthenticationType_1.default.AccessKey) {
538
+ const signsInWith = `Amazon SES is signed in to with an access key, unless ${ServerEmailEnvironmentVariable.AmazonSesAuthenticationType} is ${exports.SERVER_EMAIL_AMAZON_SES_AUTHENTICATION_TYPE_VALUES[AmazonSesAuthenticationType_1.default.ServerIamRole]}.`;
539
+ put("amazonSesAccessKeyId", needed(ServerEmailEnvironmentVariable.AmazonSesAccessKeyId, signsInWith));
540
+ put("amazonSesSecretAccessKey", needed(ServerEmailEnvironmentVariable.AmazonSesSecretAccessKey, signsInWith));
541
+ }
542
+ const regionText = take(ServerEmailEnvironmentVariable.AmazonSesRegion).toLowerCase();
543
+ if (!regionText) {
544
+ notSet(ServerEmailEnvironmentVariable.AmazonSesRegion, "Amazon SES sends from the Region your sender is verified in, such as us-east-1.");
545
+ }
546
+ else if (!(0, AwsRegionCode_1.isAwsRegion)(regionText)) {
547
+ problems.push(`${ServerEmailEnvironmentVariable.AmazonSesRegion}: "${(0, RefusedValue_1.refusedValue)(regionText)}" is not an AWS Region code, such as us-east-1.`);
548
+ }
549
+ else {
550
+ put("amazonSesRegion", regionText);
551
+ }
552
+ put("amazonSesFromEmail", fromEmail);
553
+ put("amazonSesFromName", fromName);
554
+ break;
555
+ }
556
+ case GlobalConfig_1.EmailServerType.Mailgun: {
557
+ put("mailgunApiKey", needed(ServerEmailEnvironmentVariable.MailgunApiKey, "Mailgun sends nothing without it."));
558
+ const domainText = take(ServerEmailEnvironmentVariable.MailgunDomain).toLowerCase();
559
+ if (!domainText) {
560
+ notSet(ServerEmailEnvironmentVariable.MailgunDomain, "Mailgun sends from that domain, such as mg.example.com.");
561
+ }
562
+ else if (!(0, MailgunDomain_1.isMailgunDomain)(domainText)) {
563
+ problems.push(`${ServerEmailEnvironmentVariable.MailgunDomain}: "${(0, RefusedValue_1.refusedValue)(domainText)}" is not a domain, such as mg.example.com.`);
564
+ }
565
+ else {
566
+ put("mailgunDomain", domainText);
567
+ }
568
+ put("mailgunRegion", choice(ServerEmailEnvironmentVariable.MailgunRegion, exports.SERVER_EMAIL_MAILGUN_REGION_VALUES, MailgunRegion_1.default.US));
569
+ put("mailgunFromEmail", fromEmail);
570
+ put("mailgunFromName", fromName);
571
+ break;
572
+ }
573
+ case GlobalConfig_1.EmailServerType.Postmark: {
574
+ put("postmarkServerToken", needed(ServerEmailEnvironmentVariable.PostmarkServerToken, "Postmark sends nothing without the server's API token."));
575
+ put("postmarkFromEmail", fromEmail);
576
+ put("postmarkFromName", fromName);
577
+ break;
578
+ }
579
+ case GlobalConfig_1.EmailServerType.Resend: {
580
+ put("resendApiKey", needed(ServerEmailEnvironmentVariable.ResendApiKey, "Resend sends nothing without it."));
581
+ put("resendFromEmail", fromEmail);
582
+ put("resendFromName", fromName);
583
+ break;
584
+ }
585
+ }
586
+ // In the variables' own order, whatever order they were read in.
587
+ const orderedProblems = [...problems].sort((a, b) => {
588
+ return (ServerEmailEnvironment.variableOrderOf(a) -
589
+ ServerEmailEnvironment.variableOrderOf(b));
590
+ });
591
+ return {
592
+ isSet: true,
593
+ serverType: serverType,
594
+ settings: settings,
595
+ problems: orderedProblems,
596
+ ignored: setVariables.filter((variable) => {
597
+ return !readVariables.has(variable);
598
+ }),
599
+ values: values,
600
+ };
601
+ }
602
+ // Where a problem's variable comes in SERVER_EMAIL_ENVIRONMENT_VARIABLES.
603
+ static variableOrderOf(problem) {
604
+ const index = exports.SERVER_EMAIL_ENVIRONMENT_VARIABLES.findIndex((variable) => {
605
+ return (problem.startsWith(`${variable} `) ||
606
+ problem.startsWith(`${variable}:`));
607
+ });
608
+ return index === -1 ? exports.SERVER_EMAIL_ENVIRONMENT_VARIABLES.length : index;
609
+ }
610
+ // Whether the settings the variables set can send: set, with nothing wrong.
611
+ static isUsable(reading) {
612
+ return (reading.isSet &&
613
+ reading.serverType !== null &&
614
+ reading.settings !== null &&
615
+ reading.problems.length === 0);
616
+ }
617
+ /*
618
+ * The variables the chosen settings read, in the order the Admin
619
+ * Dashboard lists them: the type, its own settings, then who the emails
620
+ * come from.
621
+ */
622
+ static getReadVariables(reading) {
623
+ if (!reading.isSet) {
624
+ return [];
625
+ }
626
+ // A type that is not one: only it, beside the problem that says so.
627
+ if (!reading.serverType || !reading.settings) {
628
+ return [ServerEmailEnvironmentVariable.ServerType];
629
+ }
630
+ const settings = reading.settings;
631
+ const own = [];
632
+ switch (reading.serverType) {
633
+ case GlobalConfig_1.EmailServerType.CustomSMTP: {
634
+ own.push(ServerEmailEnvironmentVariable.SmtpTransport);
635
+ const isGraph = settings.smtpTransportType === MailTransportType_1.default.MicrosoftGraph;
636
+ if (!isGraph) {
637
+ own.push(ServerEmailEnvironmentVariable.SmtpHost, ServerEmailEnvironmentVariable.SmtpPort, ServerEmailEnvironmentVariable.SmtpRequireTls, ServerEmailEnvironmentVariable.SmtpAuthType);
638
+ if (settings.smtpAuthType === SMTPAuthenticationType_1.default.UsernamePassword) {
639
+ own.push(ServerEmailEnvironmentVariable.SmtpUsername, ServerEmailEnvironmentVariable.SmtpPassword);
640
+ }
641
+ else if (settings.smtpAuthType === SMTPAuthenticationType_1.default.OAuth) {
642
+ own.push(ServerEmailEnvironmentVariable.SmtpUsername, ServerEmailEnvironmentVariable.SmtpOAuthProviderType);
643
+ }
644
+ }
645
+ if (isGraph || settings.smtpAuthType === SMTPAuthenticationType_1.default.OAuth) {
646
+ own.push(ServerEmailEnvironmentVariable.SmtpOAuthClientId, ServerEmailEnvironmentVariable.SmtpOAuthClientSecret, ServerEmailEnvironmentVariable.SmtpOAuthTokenUrl, ServerEmailEnvironmentVariable.SmtpOAuthScope);
647
+ }
648
+ break;
649
+ }
650
+ case GlobalConfig_1.EmailServerType.Sendgrid:
651
+ own.push(ServerEmailEnvironmentVariable.SendgridApiKey);
652
+ break;
653
+ case GlobalConfig_1.EmailServerType.AmazonSES:
654
+ own.push(ServerEmailEnvironmentVariable.AmazonSesAuthenticationType);
655
+ if (settings.amazonSesAuthenticationType !==
656
+ AmazonSesAuthenticationType_1.default.ServerIamRole) {
657
+ own.push(ServerEmailEnvironmentVariable.AmazonSesAccessKeyId, ServerEmailEnvironmentVariable.AmazonSesSecretAccessKey);
658
+ }
659
+ own.push(ServerEmailEnvironmentVariable.AmazonSesRegion);
660
+ break;
661
+ case GlobalConfig_1.EmailServerType.Mailgun:
662
+ own.push(ServerEmailEnvironmentVariable.MailgunApiKey, ServerEmailEnvironmentVariable.MailgunDomain, ServerEmailEnvironmentVariable.MailgunRegion);
663
+ break;
664
+ case GlobalConfig_1.EmailServerType.Postmark:
665
+ own.push(ServerEmailEnvironmentVariable.PostmarkServerToken);
666
+ break;
667
+ case GlobalConfig_1.EmailServerType.Resend:
668
+ own.push(ServerEmailEnvironmentVariable.ResendApiKey);
669
+ break;
670
+ }
671
+ return [
672
+ ServerEmailEnvironmentVariable.ServerType,
673
+ ...own,
674
+ ServerEmailEnvironmentVariable.FromEmail,
675
+ ServerEmailEnvironmentVariable.FromName,
676
+ ];
677
+ }
678
+ // What the Admin Dashboard is told: never a password or a key.
679
+ static toAnswer(reading) {
680
+ if (!reading.isSet) {
681
+ return Object.assign(Object.assign({}, NO_SETTINGS_ANSWER), { problems: [...reading.problems] });
682
+ }
683
+ const fields = ServerEmailEnvironment.getReadVariables(reading).map((variable) => {
684
+ const text = reading.values[variable] || "";
685
+ const isSecret = ServerEmailEnvironment.isSecret(variable);
686
+ return {
687
+ variable: variable,
688
+ value: isSecret || !text ? null : text,
689
+ isSecret: isSecret,
690
+ isSet: Boolean(text),
691
+ };
692
+ });
693
+ return {
694
+ isSetByEnvironment: true,
695
+ serverType: reading.serverType,
696
+ fields: fields,
697
+ problems: [...reading.problems],
698
+ ignored: [...reading.ignored],
699
+ };
700
+ }
701
+ /*
702
+ * The answer as the Admin Dashboard reads it back. Anything that is not
703
+ * the answer's shape reads as the variables not set, so the page shows
704
+ * the saved settings and their Edit buttons, and the server still refuses
705
+ * a write it must not take.
706
+ */
707
+ static answerFromJSON(json) {
708
+ if (!json || typeof json !== "object" || Array.isArray(json)) {
709
+ return Object.assign(Object.assign({}, NO_SETTINGS_ANSWER), { fields: [], problems: [], ignored: [] });
710
+ }
711
+ const data = json;
712
+ const isVariable = (variable) => {
713
+ return exports.SERVER_EMAIL_ENVIRONMENT_VARIABLES.includes(variable);
714
+ };
715
+ const texts = (key) => {
716
+ return Array.isArray(data[key])
717
+ ? data[key].filter((text) => {
718
+ return typeof text === "string" && text.length > 0;
719
+ })
720
+ : [];
721
+ };
722
+ const serverType = data["serverType"];
723
+ const fields = Array.isArray(data["fields"])
724
+ ? data["fields"].flatMap((field) => {
725
+ if (!field || typeof field !== "object" || Array.isArray(field)) {
726
+ return [];
727
+ }
728
+ const entry = field;
729
+ if (!isVariable(entry["variable"])) {
730
+ return [];
731
+ }
732
+ const variable = entry["variable"];
733
+ const isSecret = ServerEmailEnvironment.isSecret(variable);
734
+ const value = entry["value"];
735
+ return [
736
+ {
737
+ variable: variable,
738
+ // A secret's value is never shown, whatever came back.
739
+ value: !isSecret && typeof value === "string" && value.trim()
740
+ ? value
741
+ : null,
742
+ isSecret: isSecret,
743
+ isSet: entry["isSet"] === true,
744
+ },
745
+ ];
746
+ })
747
+ : [];
748
+ return {
749
+ isSetByEnvironment: data["isSetByEnvironment"] === true,
750
+ serverType: Object.values(GlobalConfig_1.EmailServerType).includes(serverType)
751
+ ? serverType
752
+ : null,
753
+ fields: fields,
754
+ problems: texts("problems"),
755
+ ignored: texts("ignored").filter(isVariable),
756
+ };
757
+ }
758
+ /*
759
+ * What the server says once as it starts, so nobody looks for the
760
+ * settings in the Admin Dashboard: the variables set them. Null when
761
+ * GLOBAL_EMAIL_SERVER_TYPE is not set.
762
+ */
763
+ static getStartupNotice(reading) {
764
+ if (!reading.isSet) {
765
+ return null;
766
+ }
767
+ return `The server's email settings are set by environment variables (${ServerEmailEnvironmentVariable.ServerType} and the other GLOBAL_EMAIL_ variables): the settings saved in the Admin Dashboard are not used.`;
768
+ }
769
+ /*
770
+ * The variables that hold a value nothing reads with the chosen settings,
771
+ * as the server and the Admin Dashboard say it. Null when there are none.
772
+ */
773
+ static getIgnoredMessage(reading) {
774
+ if (!reading.isSet || reading.ignored.length === 0) {
775
+ return null;
776
+ }
777
+ const count = reading.ignored.length;
778
+ return `${listed(reading.ignored)} ${count === 1 ? "is" : "are"} set, but the email settings the GLOBAL_EMAIL_ variables describe do not read ${count === 1 ? "it" : "them"}, so ${count === 1 ? "it changes" : "they change"} nothing. Remove ${count === 1 ? "it" : "them"}, or check ${ServerEmailEnvironmentVariable.ServerType} and the variables that pick how email is sent.`;
779
+ }
780
+ // What is wrong with the variables, as the server says it when it starts.
781
+ static getStartupWarning(reading) {
782
+ const ignored = ServerEmailEnvironment.getIgnoredMessage(reading);
783
+ if (reading.problems.length === 0) {
784
+ return ignored;
785
+ }
786
+ if (!reading.isSet) {
787
+ return reading.problems.join(" ");
788
+ }
789
+ const warning = `The email settings set by environment variables send no email until this is fixed: ${reading.problems.join(" ")}`;
790
+ return ignored ? `${warning} ${ignored}` : warning;
791
+ }
792
+ }
793
+ exports.default = ServerEmailEnvironment;