@oneuptime/common 14.0.92 → 14.0.94

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 (271) hide show
  1. package/Models/DatabaseModels/Alert.d.mts +2 -0
  2. package/Models/DatabaseModels/Alert.d.ts +2 -0
  3. package/Models/DatabaseModels/Alert.js +62 -1
  4. package/Models/DatabaseModels/AlertEpisodeMember.d.mts +1 -0
  5. package/Models/DatabaseModels/AlertEpisodeMember.d.ts +1 -0
  6. package/Models/DatabaseModels/AlertEpisodeMember.js +50 -0
  7. package/Models/DatabaseModels/CloudAccount.d.mts +29 -0
  8. package/Models/DatabaseModels/CloudAccount.d.ts +29 -0
  9. package/Models/DatabaseModels/CloudAccount.js +546 -0
  10. package/Models/DatabaseModels/CloudAccount.mjs +2 -0
  11. package/Models/DatabaseModels/CloudResource.d.mts +8 -0
  12. package/Models/DatabaseModels/CloudResource.d.ts +8 -0
  13. package/Models/DatabaseModels/CloudResource.js +169 -0
  14. package/Models/DatabaseModels/CloudResourceLabelRule.d.mts +1 -0
  15. package/Models/DatabaseModels/CloudResourceLabelRule.d.ts +1 -0
  16. package/Models/DatabaseModels/CloudResourceLabelRule.js +40 -0
  17. package/Models/DatabaseModels/CloudResourceOwnerRule.d.mts +1 -0
  18. package/Models/DatabaseModels/CloudResourceOwnerRule.d.ts +1 -0
  19. package/Models/DatabaseModels/CloudResourceOwnerRule.js +40 -0
  20. package/Models/DatabaseModels/Incident.d.mts +2 -0
  21. package/Models/DatabaseModels/Incident.d.ts +2 -0
  22. package/Models/DatabaseModels/Incident.js +54 -0
  23. package/Models/DatabaseModels/IncidentEpisodeMember.d.mts +1 -0
  24. package/Models/DatabaseModels/IncidentEpisodeMember.d.ts +1 -0
  25. package/Models/DatabaseModels/IncidentEpisodeMember.js +50 -0
  26. package/Models/DatabaseModels/IncomingCallPolicy.js +1 -1
  27. package/Models/DatabaseModels/Index.js +2 -0
  28. package/Models/DatabaseModels/LlmProvider.js +1 -1
  29. package/Models/DatabaseModels/Monitor.d.mts +2 -0
  30. package/Models/DatabaseModels/Monitor.d.ts +2 -0
  31. package/Models/DatabaseModels/Monitor.js +54 -0
  32. package/Models/DatabaseModels/MonitorTemplate.js +10 -4
  33. package/Models/DatabaseModels/NetworkDeviceDiscoveryScan.js +13 -13
  34. package/Models/DatabaseModels/OnCallDutyPolicy.js +1 -1
  35. package/Models/DatabaseModels/OpenSourceDeployment.d.mts +1 -0
  36. package/Models/DatabaseModels/OpenSourceDeployment.d.ts +1 -0
  37. package/Models/DatabaseModels/OpenSourceDeployment.js +25 -6
  38. package/Models/DatabaseModels/ScheduledMaintenance.d.mts +1 -0
  39. package/Models/DatabaseModels/ScheduledMaintenance.d.ts +1 -0
  40. package/Models/DatabaseModels/ScheduledMaintenance.js +50 -0
  41. package/Models/DatabaseModels/ScheduledMaintenanceReminderRule.js +1 -1
  42. package/Models/DatabaseModels/StatusPage.d.mts +2 -0
  43. package/Models/DatabaseModels/StatusPage.d.ts +2 -0
  44. package/Models/DatabaseModels/StatusPage.js +100 -0
  45. package/Types/AI/AiAffectedResources.d.mts +40 -0
  46. package/Types/AI/AiAffectedResources.d.ts +40 -0
  47. package/Types/AI/AiAffectedResources.js +292 -0
  48. package/Types/AI/AiAffectedResources.mjs +10 -0
  49. package/Types/Cloud/CloudAccountSummary.d.mts +25 -0
  50. package/Types/Cloud/CloudAccountSummary.d.ts +25 -0
  51. package/Types/Cloud/CloudAccountSummary.js +114 -0
  52. package/Types/Cloud/CloudAccountSummary.mjs +5 -0
  53. package/Types/Cloud/CloudEndpointMatch.d.mts +26 -0
  54. package/Types/Cloud/CloudEndpointMatch.d.ts +26 -0
  55. package/Types/Cloud/CloudEndpointMatch.js +134 -0
  56. package/Types/Cloud/CloudEndpointMatch.mjs +5 -0
  57. package/Types/Cloud/CloudInventory.d.mts +34 -0
  58. package/Types/Cloud/CloudInventory.d.ts +34 -0
  59. package/Types/Cloud/CloudInventory.js +362 -0
  60. package/Types/Cloud/CloudInventory.mjs +22 -0
  61. package/Types/Cloud/CloudResourceCatalog.d.mts +2 -0
  62. package/Types/Cloud/CloudResourceCatalog.d.ts +2 -0
  63. package/Types/Cloud/CloudResourceCatalog.js +29 -1
  64. package/Types/Cloud/CloudResourceCatalog.mjs +2 -0
  65. package/Types/Cloud/CloudResourceIndex.d.mts +44 -0
  66. package/Types/Cloud/CloudResourceIndex.d.ts +44 -0
  67. package/Types/Cloud/CloudResourceIndex.js +191 -0
  68. package/Types/Cloud/CloudResourceIndex.mjs +4 -0
  69. package/Types/CloudConnection/CloudConnectionCatalog.d.mts +3 -0
  70. package/Types/CloudConnection/CloudConnectionCatalog.d.ts +3 -0
  71. package/Types/CloudConnection/CloudConnectionCatalog.js +70 -12
  72. package/Types/CloudConnection/CloudConnectionCatalog.mjs +2 -0
  73. package/Types/CloudConnection/CloudConnectionPaste.js +7 -1
  74. package/Types/CloudConnection/CloudConnectionSetupCommands.d.mts +43 -3
  75. package/Types/CloudConnection/CloudConnectionSetupCommands.d.ts +43 -3
  76. package/Types/CloudConnection/CloudConnectionSetupCommands.js +280 -30
  77. package/Types/CloudConnection/CloudConnectionSetupCommands.mjs +14 -0
  78. package/Types/CloudConnection/CloudConnectionTest.d.mts +1 -0
  79. package/Types/CloudConnection/CloudConnectionTest.d.ts +1 -0
  80. package/Types/CloudConnection/CloudConnectionTest.js +1 -0
  81. package/Types/Dashboard/DashboardComponents/DashboardTableComponent.d.mts +19 -0
  82. package/Types/Dashboard/DashboardComponents/DashboardTableComponent.d.ts +19 -0
  83. package/Types/Dashboard/DashboardComponents/DashboardTableComponent.js +27 -1
  84. package/Types/Dashboard/DashboardComponents/DashboardTableComponent.mjs +3 -0
  85. package/Types/Database/BlankColumnValue.d.mts +6 -0
  86. package/Types/Database/BlankColumnValue.d.ts +6 -0
  87. package/Types/Database/BlankColumnValue.js +77 -0
  88. package/Types/Database/BlankColumnValue.mjs +4 -0
  89. package/Types/Date.d.mts +1 -0
  90. package/Types/Date.d.ts +1 -0
  91. package/Types/Date.js +32 -6
  92. package/Types/DateLanguage.d.mts +2 -0
  93. package/Types/DateLanguage.d.ts +2 -0
  94. package/Types/DateLanguage.js +67 -12
  95. package/Types/DateLanguage.mjs +2 -0
  96. package/Types/Domain.d.mts +2 -0
  97. package/Types/Domain.d.ts +2 -0
  98. package/Types/Domain.js +27 -0
  99. package/Types/Email/EmailTemplateType.d.mts +2 -0
  100. package/Types/Email/EmailTemplateType.d.ts +2 -0
  101. package/Types/Email/EmailTemplateType.js +2 -0
  102. package/Types/Email.d.mts +1 -0
  103. package/Types/Email.d.ts +1 -0
  104. package/Types/Email.js +16 -0
  105. package/Types/IncomingCall/IncomingCallPolicyRepeat.d.mts +6 -0
  106. package/Types/IncomingCall/IncomingCallPolicyRepeat.d.ts +6 -0
  107. package/Types/IncomingCall/IncomingCallPolicyRepeat.js +41 -14
  108. package/Types/IncomingCall/IncomingCallPolicyRepeat.mjs +3 -0
  109. package/Types/Monitor/CriteriaFilter.d.mts +1 -0
  110. package/Types/Monitor/CriteriaFilter.d.ts +1 -0
  111. package/Types/Monitor/CriteriaFilter.js +9 -0
  112. package/Types/Monitor/DatabaseMetricCatalog.js +2 -2
  113. package/Types/Monitor/ExternalStatusPageMonitor/ExternalStatusPageMonitorResponse.d.mts +4 -0
  114. package/Types/Monitor/ExternalStatusPageMonitor/ExternalStatusPageMonitorResponse.d.ts +4 -0
  115. package/Types/Monitor/KubernetesEventAlertTemplates.d.mts +20 -0
  116. package/Types/Monitor/KubernetesEventAlertTemplates.d.ts +20 -0
  117. package/Types/Monitor/KubernetesEventAlertTemplates.js +232 -0
  118. package/Types/Monitor/KubernetesEventAlertTemplates.mjs +8 -0
  119. package/Types/Monitor/MonitorStepExternalStatusPageMonitor.d.mts +3 -0
  120. package/Types/Monitor/MonitorStepExternalStatusPageMonitor.d.ts +3 -0
  121. package/Types/Monitor/MonitorStepExternalStatusPageMonitor.js +35 -0
  122. package/Types/Monitor/MonitorTemplateSyncField.js +6 -1
  123. package/Types/Monitor/MonitorType.js +12 -2
  124. package/Types/Monitor/Recommendation/MonitorRecommendationCatalog.js +27 -2
  125. package/Types/Monitor/Recommendation/MonitorRecommendationUtil.d.mts +1 -0
  126. package/Types/Monitor/Recommendation/MonitorRecommendationUtil.d.ts +1 -0
  127. package/Types/Monitor/Recommendation/MonitorRecommendationUtil.js +31 -1
  128. package/Types/Monitor/SnmpMonitor/NetworkDeviceAlertPack.d.mts +3 -1
  129. package/Types/Monitor/SnmpMonitor/NetworkDeviceAlertPack.d.ts +3 -1
  130. package/Types/Monitor/SnmpMonitor/NetworkDeviceAlertPack.js +3 -2
  131. package/Types/Monitor/SnmpMonitor/SnmpMonitorResponse.d.mts +1 -0
  132. package/Types/Monitor/SnmpMonitor/SnmpMonitorResponse.d.ts +1 -0
  133. package/Types/Monitor/UptimeBarTooltipMaintenance.d.mts +15 -0
  134. package/Types/Monitor/UptimeBarTooltipMaintenance.d.ts +15 -0
  135. package/Types/Monitor/UptimeBarTooltipMaintenance.js +2 -0
  136. package/Types/Monitor/UptimeBarTooltipMaintenance.mjs +1 -0
  137. package/Types/Monitor/UptimeHistoryLabels.d.mts +5 -0
  138. package/Types/Monitor/UptimeHistoryLabels.d.ts +5 -0
  139. package/Types/Monitor/UptimeHistoryLabels.js +5 -0
  140. package/Types/NotificationSetting/NotificationEmailRollupCategory.js +2 -0
  141. package/Types/NotificationSetting/NotificationEmailRollupPolicy.js +10 -3
  142. package/Types/NotificationSetting/NotificationSettingEventType.d.mts +1 -0
  143. package/Types/NotificationSetting/NotificationSettingEventType.d.ts +1 -0
  144. package/Types/NotificationSetting/NotificationSettingEventType.js +7 -0
  145. package/Types/OnCallDutyPolicy/OnCallDutyPolicyRepeat.d.mts +7 -0
  146. package/Types/OnCallDutyPolicy/OnCallDutyPolicyRepeat.d.ts +7 -0
  147. package/Types/OnCallDutyPolicy/OnCallDutyPolicyRepeat.js +51 -0
  148. package/Types/OnCallDutyPolicy/OnCallDutyPolicyRepeat.mjs +4 -0
  149. package/Types/ReadingDirection.d.mts +10 -0
  150. package/Types/ReadingDirection.d.ts +10 -0
  151. package/Types/ReadingDirection.js +171 -0
  152. package/Types/ReadingDirection.mjs +10 -0
  153. package/Types/Reminder/ScheduledMaintenanceReminderNeverReminds.d.mts +8 -0
  154. package/Types/Reminder/ScheduledMaintenanceReminderNeverReminds.d.ts +8 -0
  155. package/Types/Reminder/ScheduledMaintenanceReminderNeverReminds.js +55 -0
  156. package/Types/Reminder/ScheduledMaintenanceReminderNeverReminds.mjs +5 -0
  157. package/Types/Rules/RuleCriteriaFieldRegistry.js +2 -0
  158. package/Types/Runbook/HttpStepVariables.d.mts +8 -0
  159. package/Types/Runbook/HttpStepVariables.d.ts +8 -0
  160. package/Types/Runbook/HttpStepVariables.js +109 -0
  161. package/Types/Runbook/HttpStepVariables.mjs +5 -0
  162. package/Types/Runbook/RunbookStep.d.mts +1 -0
  163. package/Types/Runbook/RunbookStep.d.ts +1 -0
  164. package/Types/Runbook/RunnerFeatures.d.mts +1 -0
  165. package/Types/Runbook/RunnerFeatures.d.ts +1 -0
  166. package/Types/Runbook/RunnerFeatures.js +15 -3
  167. package/Types/Runbook/RunnerFeatures.mjs +1 -0
  168. package/Types/Runbook/SshHostKey.d.mts +22 -0
  169. package/Types/Runbook/SshHostKey.d.ts +22 -0
  170. package/Types/Runbook/SshHostKey.js +201 -0
  171. package/Types/Runbook/SshHostKey.mjs +10 -0
  172. package/Types/Runner/CodeRepositoryRunner.js +2 -3
  173. package/Types/Runner/GlobalAIAgentsGone.d.mts +1 -0
  174. package/Types/Runner/GlobalAIAgentsGone.d.ts +1 -0
  175. package/Types/Runner/GlobalAIAgentsGone.js +19 -0
  176. package/Types/Runner/GlobalAIAgentsGone.mjs +2 -0
  177. package/Types/Runner/GlobalRunnerWork.d.mts +1 -0
  178. package/Types/Runner/GlobalRunnerWork.d.ts +1 -0
  179. package/Types/Runner/GlobalRunnerWork.js +21 -1
  180. package/Types/Runner/GlobalRunnerWork.mjs +1 -0
  181. package/Types/SSO/SignInMethods.d.mts +31 -0
  182. package/Types/SSO/SignInMethods.d.ts +31 -0
  183. package/Types/SSO/SignInMethods.js +160 -0
  184. package/Types/SSO/SignInMethods.mjs +8 -0
  185. package/Types/ScheduledMaintenance/ScheduledMaintenancePublication.d.mts +24 -0
  186. package/Types/ScheduledMaintenance/ScheduledMaintenancePublication.d.ts +24 -0
  187. package/Types/ScheduledMaintenance/ScheduledMaintenancePublication.js +159 -0
  188. package/Types/ScheduledMaintenance/ScheduledMaintenancePublication.mjs +8 -0
  189. package/Types/StatusPage/StatusPageLanguage.d.mts +6 -0
  190. package/Types/StatusPage/StatusPageLanguage.d.ts +6 -0
  191. package/Types/StatusPage/StatusPageLanguage.js +17 -1
  192. package/Types/StatusPage/StatusPageLanguage.mjs +1 -0
  193. package/Types/Workflow/Templates.js +2 -5
  194. package/Types/Workflow/WorkflowPlan.d.mts +7 -0
  195. package/Types/Workflow/WorkflowPlan.d.ts +7 -0
  196. package/Types/Workflow/WorkflowPlan.js +39 -0
  197. package/Types/Workflow/WorkflowPlan.mjs +3 -0
  198. package/Types/Workspace/WorkspaceMessagePayload.d.mts +11 -0
  199. package/Types/Workspace/WorkspaceMessagePayload.d.ts +11 -0
  200. package/Utils/ColorContrast.d.mts +3 -0
  201. package/Utils/ColorContrast.d.ts +3 -0
  202. package/Utils/ColorContrast.js +41 -3
  203. package/Utils/ColorContrast.mjs +2 -0
  204. package/Utils/Dashboard/TableThresholds.d.mts +44 -0
  205. package/Utils/Dashboard/TableThresholds.d.ts +44 -0
  206. package/Utils/Dashboard/TableThresholds.js +288 -0
  207. package/Utils/Dashboard/TableThresholds.mjs +17 -0
  208. package/Utils/Dashboard/ValueWidgetSeries.d.mts +6 -0
  209. package/Utils/Dashboard/ValueWidgetSeries.d.ts +6 -0
  210. package/Utils/Dashboard/ValueWidgetSeries.js +70 -1
  211. package/Utils/Dashboard/ValueWidgetSeries.mjs +2 -0
  212. package/Utils/DeveloperDocs/ResourceProfiles.js +16 -0
  213. package/Utils/DeveloperDocs/TerraformSchema.d.mts +1 -0
  214. package/Utils/DeveloperDocs/TerraformSchema.d.ts +1 -0
  215. package/Utils/DeveloperDocs/TerraformSchema.js +17 -0
  216. package/Utils/DeveloperDocs/TerraformSchema.mjs +1 -0
  217. package/Utils/Incident/WhoOpenedItRootCause.d.mts +2 -0
  218. package/Utils/Incident/WhoOpenedItRootCause.d.ts +2 -0
  219. package/Utils/Incident/WhoOpenedItRootCause.js +50 -0
  220. package/Utils/Incident/WhoOpenedItRootCause.mjs +3 -0
  221. package/Utils/Monitor/ExternalStatusPageComponentNames.d.mts +17 -0
  222. package/Utils/Monitor/ExternalStatusPageComponentNames.d.ts +17 -0
  223. package/Utils/Monitor/ExternalStatusPageComponentNames.js +274 -0
  224. package/Utils/Monitor/ExternalStatusPageComponentNames.mjs +6 -0
  225. package/Utils/Monitor/ExternalStatusPageReading.d.mts +35 -0
  226. package/Utils/Monitor/ExternalStatusPageReading.d.ts +35 -0
  227. package/Utils/Monitor/ExternalStatusPageReading.js +380 -0
  228. package/Utils/Monitor/ExternalStatusPageReading.mjs +6 -0
  229. package/Utils/Monitor/ExternalStatusPageScope.d.mts +43 -0
  230. package/Utils/Monitor/ExternalStatusPageScope.d.ts +43 -0
  231. package/Utils/Monitor/ExternalStatusPageScope.js +213 -0
  232. package/Utils/Monitor/ExternalStatusPageScope.mjs +4 -0
  233. package/Utils/Monitor/SyntheticMonitorStepsUtil.d.mts +18 -0
  234. package/Utils/Monitor/SyntheticMonitorStepsUtil.d.ts +18 -0
  235. package/Utils/Monitor/SyntheticMonitorStepsUtil.js +129 -0
  236. package/Utils/Monitor/SyntheticMonitorStepsUtil.mjs +4 -0
  237. package/Utils/Rules/RuleRunSummary.d.mts +1 -0
  238. package/Utils/Rules/RuleRunSummary.d.ts +1 -0
  239. package/Utils/Rules/RuleRunSummary.js +19 -1
  240. package/Utils/Rules/RuleRunSummary.mjs +1 -0
  241. package/Utils/Runbook/SshHostKeyFingerprint.d.mts +8 -0
  242. package/Utils/Runbook/SshHostKeyFingerprint.d.ts +8 -0
  243. package/Utils/Runbook/SshHostKeyFingerprint.js +83 -0
  244. package/Utils/Runbook/SshHostKeyFingerprint.mjs +5 -0
  245. package/Utils/ScheduledMaintenanceStart.d.mts +6 -0
  246. package/Utils/ScheduledMaintenanceStart.d.ts +6 -0
  247. package/Utils/ScheduledMaintenanceStart.js +15 -0
  248. package/Utils/Sms/Gsm7Text.js +9 -1
  249. package/Utils/Sms/OnCallPageSms.d.mts +2 -0
  250. package/Utils/Sms/OnCallPageSms.d.ts +2 -0
  251. package/Utils/Sms/OnCallPageSms.js +19 -2
  252. package/Utils/Sms/OnCallPageSms.mjs +1 -0
  253. package/Utils/Sms/SubscriberSms.d.mts +2 -0
  254. package/Utils/Sms/SubscriberSms.d.ts +2 -0
  255. package/Utils/Sms/SubscriberSms.js +35 -0
  256. package/Utils/Sms/SubscriberSms.mjs +3 -0
  257. package/Utils/StatusPage/HistoryChartBarColors.d.mts +2 -0
  258. package/Utils/StatusPage/HistoryChartBarColors.d.ts +2 -0
  259. package/Utils/StatusPage/HistoryChartBarColors.js +12 -1
  260. package/Utils/StatusPage/HistoryChartBarColors.mjs +2 -0
  261. package/Utils/Telemetry/ChangeEventFields.d.mts +19 -1
  262. package/Utils/Telemetry/ChangeEventFields.d.ts +19 -1
  263. package/Utils/Telemetry/ChangeEventFields.js +52 -1
  264. package/Utils/Uptime/DayUptimeGraphUtil.d.mts +6 -0
  265. package/Utils/Uptime/DayUptimeGraphUtil.d.ts +6 -0
  266. package/Utils/Uptime/DayUptimeGraphUtil.js +37 -6
  267. package/Utils/Uptime/UptimeMaintenanceUtil.d.mts +60 -0
  268. package/Utils/Uptime/UptimeMaintenanceUtil.d.ts +60 -0
  269. package/Utils/Uptime/UptimeMaintenanceUtil.js +295 -0
  270. package/Utils/Uptime/UptimeMaintenanceUtil.mjs +3 -0
  271. package/package.json +1 -1
@@ -0,0 +1,380 @@
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.EXTERNAL_STATUS_PAGE_ONEUPTIME_STATUS_NOT_SHOWN = exports.EXTERNAL_STATUS_PAGE_UNNAMED_INCIDENT = exports.EXTERNAL_STATUS_PAGE_MAX_INCIDENTS = exports.EXTERNAL_STATUS_PAGE_MAX_COMPONENTS = void 0;
7
+ const ExternalStatusPageComponentStatusUtil_1 = __importDefault(require("./ExternalStatusPageComponentStatusUtil"));
8
+ const TrailingRuns_1 = require("../TrailingRuns");
9
+ /*
10
+ * WHAT A STATUS PAGE SAYS, READ FROM ITS ANSWERS.
11
+ *
12
+ * The probe's External Status Page monitor and the Dashboard's component
13
+ * picker read a page the same way, so a component a person picks in the
14
+ * form is the component the probe watches, by the same name and in the
15
+ * same group:
16
+ *
17
+ * - Atlassian Statuspage: /api/v2/status.json (the page's own status),
18
+ * /api/v2/components.json (its components; a component that is a group
19
+ * header names a group) and /api/v2/incidents/unresolved.json (its
20
+ * active incidents, each naming the components it affects);
21
+ * - incident.io: the proxy the page's own front end reads, keyed by its
22
+ * host, with the components, their groups (its structure), the
23
+ * components affected now and the ongoing incidents;
24
+ * - a OneUptime status page: its summary (Types/StatusPage/
25
+ * StatusPageSummary), each resource a component and each active
26
+ * incident naming the resources it affects.
27
+ *
28
+ * Every answer is outside text: anything that is not the shape documented
29
+ * is skipped, never trusted, and a page lists at most
30
+ * EXTERNAL_STATUS_PAGE_MAX_COMPONENTS components and
31
+ * EXTERNAL_STATUS_PAGE_MAX_INCIDENTS incidents.
32
+ */
33
+ exports.EXTERNAL_STATUS_PAGE_MAX_COMPONENTS = 5000;
34
+ exports.EXTERNAL_STATUS_PAGE_MAX_INCIDENTS = 1000;
35
+ // The name an incident goes by when the page gives it none.
36
+ exports.EXTERNAL_STATUS_PAGE_UNNAMED_INCIDENT = "Unknown incident";
37
+ // A OneUptime page's component's description when the page does not show its status.
38
+ exports.EXTERNAL_STATUS_PAGE_ONEUPTIME_STATUS_NOT_SHOWN = "The status page does not show this resource's status.";
39
+ const isRecord = (value) => {
40
+ return typeof value === "object" && value !== null && !Array.isArray(value);
41
+ };
42
+ const readText = (value) => {
43
+ return typeof value === "string" && value.trim() ? value : undefined;
44
+ };
45
+ const readArray = (value) => {
46
+ return Array.isArray(value) ? value : [];
47
+ };
48
+ class ExternalStatusPageReading {
49
+ // Atlassian Statuspage's API, under the page's own address.
50
+ static getAtlassianUrls(statusPageUrl) {
51
+ const baseUrl = (0, TrailingRuns_1.withoutTrailingSlashes)(statusPageUrl);
52
+ return {
53
+ status: `${baseUrl}/api/v2/status.json`,
54
+ components: `${baseUrl}/api/v2/components.json`,
55
+ unresolvedIncidents: `${baseUrl}/api/v2/incidents/unresolved.json`,
56
+ };
57
+ }
58
+ /*
59
+ * incident.io's proxy for a page: on the page's own origin, keyed by its
60
+ * host. Null for an address that is not a URL.
61
+ */
62
+ static getIncidentIoUrl(statusPageUrl) {
63
+ const rawUrl = statusPageUrl.startsWith("http")
64
+ ? statusPageUrl
65
+ : `https://${statusPageUrl}`;
66
+ let parsedUrl;
67
+ try {
68
+ parsedUrl = new URL(rawUrl);
69
+ }
70
+ catch (_a) {
71
+ return null;
72
+ }
73
+ const host = parsedUrl.hostname;
74
+ const origin = `${parsedUrl.protocol}//${parsedUrl.host}`;
75
+ // incident.io status pages expose their data via a proxy endpoint keyed by host.
76
+ const apiUrl = `${origin}/proxy/${host}`;
77
+ return apiUrl;
78
+ }
79
+ /*
80
+ * An Atlassian Statuspage's own status, from /api/v2/status.json: its
81
+ * description ("All Systems Operational"), else its indicator. Null when
82
+ * the answer has no indicator: then it is not a Statuspage.
83
+ */
84
+ static readAtlassianPageStatus(json) {
85
+ const status = isRecord(json) ? json["status"] : undefined;
86
+ if (!isRecord(status) || !readText(status["indicator"])) {
87
+ return null;
88
+ }
89
+ return (readText(status["description"]) || readText(status["indicator"]) || "");
90
+ }
91
+ /*
92
+ * An Atlassian Statuspage's components, from /api/v2/components.json: a
93
+ * component marked as a group names the group its members name by
94
+ * group_id, and is not a component itself. Null when the answer has no
95
+ * list of components.
96
+ */
97
+ static readAtlassianComponents(json) {
98
+ const list = isRecord(json) ? json["components"] : undefined;
99
+ if (!Array.isArray(list)) {
100
+ return null;
101
+ }
102
+ // First pass: map group id -> group name (a "group" is a component with group === true).
103
+ const groupIdToName = new Map();
104
+ for (const item of list) {
105
+ if (!isRecord(item) || item["group"] !== true) {
106
+ continue;
107
+ }
108
+ const id = readText(item["id"]);
109
+ const name = readText(item["name"]);
110
+ if (id && name) {
111
+ groupIdToName.set(id, name);
112
+ }
113
+ }
114
+ // Second pass: collect leaf components (skip group headers).
115
+ const components = [];
116
+ for (const item of list) {
117
+ if (!isRecord(item) || item["group"] === true) {
118
+ continue;
119
+ }
120
+ const name = readText(item["name"]);
121
+ const status = readText(item["status"]);
122
+ if (!name || !status) {
123
+ continue;
124
+ }
125
+ const groupId = readText(item["group_id"]);
126
+ components.push({
127
+ name: name,
128
+ status: status,
129
+ description: readText(item["description"]),
130
+ groupName: groupId ? groupIdToName.get(groupId) : undefined,
131
+ key: readText(item["id"]),
132
+ });
133
+ if (components.length >= exports.EXTERNAL_STATUS_PAGE_MAX_COMPONENTS) {
134
+ break;
135
+ }
136
+ }
137
+ return components;
138
+ }
139
+ /*
140
+ * An Atlassian Statuspage's active incidents, from
141
+ * /api/v2/incidents/unresolved.json: each with the components it names.
142
+ */
143
+ static readAtlassianIncidents(json) {
144
+ const incidents = [];
145
+ for (const item of readArray(isRecord(json) ? json["incidents"] : undefined)) {
146
+ if (!isRecord(item)) {
147
+ continue;
148
+ }
149
+ const names = [];
150
+ const keys = [];
151
+ for (const component of readArray(item["components"])) {
152
+ if (!isRecord(component)) {
153
+ continue;
154
+ }
155
+ const name = readText(component["name"]);
156
+ const key = readText(component["id"]);
157
+ if (name) {
158
+ names.push(name);
159
+ }
160
+ if (key) {
161
+ keys.push(key);
162
+ }
163
+ }
164
+ incidents.push({
165
+ name: readText(item["name"]) || exports.EXTERNAL_STATUS_PAGE_UNNAMED_INCIDENT,
166
+ affectedComponentNames: names,
167
+ affectedComponentKeys: keys.length > 0 ? keys : undefined,
168
+ });
169
+ if (incidents.length >= exports.EXTERNAL_STATUS_PAGE_MAX_INCIDENTS) {
170
+ break;
171
+ }
172
+ }
173
+ return incidents;
174
+ }
175
+ /*
176
+ * An incident.io status page, from its proxy's answer: the components of
177
+ * its summary and its structure (a group's components name the group),
178
+ * each with the status the page gives it now (operational unless it is
179
+ * among the affected components), and its ongoing incidents. The proxy
180
+ * nests everything under `summary`, and a flattened shape is read too.
181
+ * Null when the answer does not look like an incident.io page.
182
+ */
183
+ static readIncidentIo(json) {
184
+ var _a;
185
+ if (!isRecord(json)) {
186
+ return null;
187
+ }
188
+ const summary = isRecord(json["summary"])
189
+ ? json["summary"]
190
+ : {};
191
+ const structure = isRecord(json["structure"])
192
+ ? json["structure"]
193
+ : summary["structure"];
194
+ const structureItems = readArray(isRecord(structure) ? structure["items"] : undefined);
195
+ // Verify this actually looks like an incident.io status page.
196
+ const looksLikeIncidentIo = structureItems.length > 0 ||
197
+ Array.isArray(summary["components"]) ||
198
+ Array.isArray(json["ongoing_incidents"]) ||
199
+ Array.isArray(summary["ongoing_incidents"]);
200
+ if (!looksLikeIncidentIo) {
201
+ return null;
202
+ }
203
+ // Build a component_id -> { name, groupName, status } map.
204
+ const componentMap = new Map();
205
+ const ensureComponent = (id, name) => {
206
+ const componentId = readText(id);
207
+ if (!componentId) {
208
+ return null;
209
+ }
210
+ const componentName = readText(name);
211
+ let entry = componentMap.get(componentId);
212
+ if (!entry) {
213
+ if (componentMap.size >= exports.EXTERNAL_STATUS_PAGE_MAX_COMPONENTS) {
214
+ return null;
215
+ }
216
+ entry = {
217
+ name: componentName || componentId,
218
+ status: "operational",
219
+ groupName: undefined,
220
+ key: componentId,
221
+ };
222
+ componentMap.set(componentId, entry);
223
+ }
224
+ else if (componentName && entry.name === componentId) {
225
+ entry.name = componentName;
226
+ }
227
+ return entry;
228
+ };
229
+ // Flat component list from the summary.
230
+ for (const component of readArray(summary["components"])) {
231
+ if (isRecord(component)) {
232
+ ensureComponent(component["id"], component["name"]);
233
+ }
234
+ }
235
+ // Group membership + any components only present in the structure.
236
+ for (const item of structureItems) {
237
+ if (!isRecord(item)) {
238
+ continue;
239
+ }
240
+ const group = item["group"];
241
+ if (isRecord(group) && Array.isArray(group["components"])) {
242
+ const groupName = readText(group["name"]);
243
+ for (const ref of group["components"]) {
244
+ if (!isRecord(ref)) {
245
+ continue;
246
+ }
247
+ const entry = ensureComponent(ref["component_id"], ref["name"]);
248
+ if (entry) {
249
+ entry.groupName = groupName;
250
+ }
251
+ }
252
+ }
253
+ else if (isRecord(item["component"])) {
254
+ const component = item["component"];
255
+ ensureComponent(component["component_id"], component["name"]);
256
+ }
257
+ }
258
+ // Apply current non-operational statuses.
259
+ const affectedComponents = Array.isArray(json["affected_components"])
260
+ ? json["affected_components"]
261
+ : readArray(summary["affected_components"]);
262
+ for (const affected of affectedComponents) {
263
+ if (!isRecord(affected)) {
264
+ continue;
265
+ }
266
+ const entry = ensureComponent(affected["component_id"]);
267
+ const status = readText(affected["status"]);
268
+ if (entry && status) {
269
+ entry.status = status;
270
+ }
271
+ }
272
+ // Active incidents.
273
+ const ongoingIncidents = Array.isArray(json["ongoing_incidents"])
274
+ ? json["ongoing_incidents"]
275
+ : readArray(summary["ongoing_incidents"]);
276
+ const incidents = [];
277
+ for (const incident of ongoingIncidents) {
278
+ if (!isRecord(incident)) {
279
+ continue;
280
+ }
281
+ const names = [];
282
+ const keys = [];
283
+ for (const affected of readArray(incident["affected_components"])) {
284
+ const componentId = isRecord(affected)
285
+ ? readText(affected["component_id"])
286
+ : undefined;
287
+ if (!componentId) {
288
+ continue;
289
+ }
290
+ keys.push(componentId);
291
+ const name = (_a = componentMap.get(componentId)) === null || _a === void 0 ? void 0 : _a.name;
292
+ if (name) {
293
+ names.push(name);
294
+ }
295
+ }
296
+ incidents.push({
297
+ name: readText(incident["name"]) || exports.EXTERNAL_STATUS_PAGE_UNNAMED_INCIDENT,
298
+ affectedComponentNames: names,
299
+ affectedComponentKeys: keys.length > 0 ? keys : undefined,
300
+ });
301
+ if (incidents.length >= exports.EXTERNAL_STATUS_PAGE_MAX_INCIDENTS) {
302
+ break;
303
+ }
304
+ }
305
+ return {
306
+ components: Array.from(componentMap.values()),
307
+ incidents: incidents,
308
+ };
309
+ }
310
+ /*
311
+ * A OneUptime status page's summary: each resource the page shows is a
312
+ * component, by the name the page gives it, in the page's group; its
313
+ * status is the value the page's status stands for
314
+ * (ExternalStatusPageComponentStatusUtil) - under maintenance while a
315
+ * scheduled maintenance event in progress affects it, whatever its
316
+ * monitors' status. Each active incident affects the resources it names,
317
+ * by their ids.
318
+ */
319
+ static readOneUptimeSummary(summary) {
320
+ const maintenanceTitles = new Map();
321
+ for (const event of summary.ongoingScheduledMaintenance) {
322
+ for (const resourceId of event.affectedResourceIds) {
323
+ const titles = maintenanceTitles.get(resourceId) || [];
324
+ if (event.title && !titles.includes(event.title)) {
325
+ titles.push(event.title);
326
+ }
327
+ maintenanceTitles.set(resourceId, titles);
328
+ }
329
+ }
330
+ const components = summary.resources
331
+ .slice(0, exports.EXTERNAL_STATUS_PAGE_MAX_COMPONENTS)
332
+ .map((resource) => {
333
+ const titles = maintenanceTitles.get(resource.id) || [];
334
+ let description;
335
+ if (resource.isUnderMaintenance) {
336
+ description =
337
+ titles.length > 0
338
+ ? `Under maintenance: ${titles.join(", ")}`
339
+ : "Under maintenance";
340
+ }
341
+ else if (!resource.currentStatus) {
342
+ description = exports.EXTERNAL_STATUS_PAGE_ONEUPTIME_STATUS_NOT_SHOWN;
343
+ }
344
+ else {
345
+ description = resource.currentStatus.name;
346
+ }
347
+ return {
348
+ key: resource.id,
349
+ name: resource.name,
350
+ groupName: resource.groupName || undefined,
351
+ status: ExternalStatusPageComponentStatusUtil_1.default.fromStatusPageStatus({
352
+ status: resource.currentStatus,
353
+ isUnderMaintenance: resource.isUnderMaintenance,
354
+ }),
355
+ description: description,
356
+ };
357
+ });
358
+ const namesById = new Map();
359
+ for (const resource of summary.resources) {
360
+ namesById.set(resource.id, resource.name);
361
+ }
362
+ const incidents = summary.activeIncidents
363
+ .slice(0, exports.EXTERNAL_STATUS_PAGE_MAX_INCIDENTS)
364
+ .map((incident) => {
365
+ return {
366
+ name: incident.title || exports.EXTERNAL_STATUS_PAGE_UNNAMED_INCIDENT,
367
+ affectedComponentNames: incident.affectedResourceIds
368
+ .map((resourceId) => {
369
+ return namesById.get(resourceId) || "";
370
+ })
371
+ .filter((name) => {
372
+ return Boolean(name);
373
+ }),
374
+ affectedComponentKeys: [...incident.affectedResourceIds],
375
+ };
376
+ });
377
+ return { components: components, incidents: incidents };
378
+ }
379
+ }
380
+ exports.default = ExternalStatusPageReading;
@@ -0,0 +1,6 @@
1
+ import commonJsModule from "./ExternalStatusPageReading.js";
2
+ export default commonJsModule.default;
3
+ export const EXTERNAL_STATUS_PAGE_MAX_COMPONENTS = commonJsModule.EXTERNAL_STATUS_PAGE_MAX_COMPONENTS;
4
+ export const EXTERNAL_STATUS_PAGE_MAX_INCIDENTS = commonJsModule.EXTERNAL_STATUS_PAGE_MAX_INCIDENTS;
5
+ export const EXTERNAL_STATUS_PAGE_ONEUPTIME_STATUS_NOT_SHOWN = commonJsModule.EXTERNAL_STATUS_PAGE_ONEUPTIME_STATUS_NOT_SHOWN;
6
+ export const EXTERNAL_STATUS_PAGE_UNNAMED_INCIDENT = commonJsModule.EXTERNAL_STATUS_PAGE_UNNAMED_INCIDENT;
@@ -0,0 +1,43 @@
1
+ import { ExternalStatusPageComponentStatus } from "../../Types/Monitor/ExternalStatusPageMonitor/ExternalStatusPageMonitorResponse.mjs";
2
+ import { ExternalStatusPageComponent, ExternalStatusPageIncident } from "./ExternalStatusPageReading.mjs";
3
+ export declare const EXTERNAL_STATUS_PAGE_MAX_REPORTED_INCIDENT_NAMES: number;
4
+ export declare const EXTERNAL_STATUS_PAGE_MAX_REPORTED_INCIDENT_NAME_LENGTH: number;
5
+ export interface ExternalStatusPageScopeInput {
6
+ components: Array<ExternalStatusPageComponent>;
7
+ incidents: Array<ExternalStatusPageIncident>;
8
+ componentGroupName?: string | undefined;
9
+ componentNames: Array<string>;
10
+ pageOverallStatus?: string | undefined;
11
+ }
12
+ export interface ExternalStatusPageScopeResult {
13
+ componentStatuses: Array<ExternalStatusPageComponentStatus>;
14
+ overallStatus: string;
15
+ activeIncidentCount: number;
16
+ activeIncidentNames: Array<string>;
17
+ incidentsOutsideScopeCount: number;
18
+ unmatchedComponentNames: Array<string>;
19
+ }
20
+ export default class ExternalStatusPageScope {
21
+ static getStatusRank(status: string): number;
22
+ static isInGroup(groupName: string | undefined, componentGroupName: string | undefined): boolean;
23
+ static getComponentsInScope(data: {
24
+ components: Array<ExternalStatusPageComponent>;
25
+ componentGroupName?: string | undefined;
26
+ componentNames: Array<string>;
27
+ }): Array<ExternalStatusPageComponent>;
28
+ static getUnmatchedNames(data: {
29
+ components: Array<ExternalStatusPageComponent>;
30
+ componentGroupName?: string | undefined;
31
+ componentNames: Array<string>;
32
+ }): Array<string>;
33
+ static deriveOverallStatus(components: Array<ExternalStatusPageComponent>, scopedIncidentCount: number): string;
34
+ static apply(input: ExternalStatusPageScopeInput): ExternalStatusPageScopeResult;
35
+ static getIncidentsInScope(data: {
36
+ components: Array<ExternalStatusPageComponent>;
37
+ targeted: Array<ExternalStatusPageComponent>;
38
+ incidents: Array<ExternalStatusPageIncident>;
39
+ }): Array<ExternalStatusPageIncident>;
40
+ static getReportedNames(incidents: Array<{
41
+ name: string;
42
+ }>): Array<string>;
43
+ }
@@ -0,0 +1,43 @@
1
+ import { ExternalStatusPageComponentStatus } from "../../Types/Monitor/ExternalStatusPageMonitor/ExternalStatusPageMonitorResponse";
2
+ import { ExternalStatusPageComponent, ExternalStatusPageIncident } from "./ExternalStatusPageReading";
3
+ export declare const EXTERNAL_STATUS_PAGE_MAX_REPORTED_INCIDENT_NAMES: number;
4
+ export declare const EXTERNAL_STATUS_PAGE_MAX_REPORTED_INCIDENT_NAME_LENGTH: number;
5
+ export interface ExternalStatusPageScopeInput {
6
+ components: Array<ExternalStatusPageComponent>;
7
+ incidents: Array<ExternalStatusPageIncident>;
8
+ componentGroupName?: string | undefined;
9
+ componentNames: Array<string>;
10
+ pageOverallStatus?: string | undefined;
11
+ }
12
+ export interface ExternalStatusPageScopeResult {
13
+ componentStatuses: Array<ExternalStatusPageComponentStatus>;
14
+ overallStatus: string;
15
+ activeIncidentCount: number;
16
+ activeIncidentNames: Array<string>;
17
+ incidentsOutsideScopeCount: number;
18
+ unmatchedComponentNames: Array<string>;
19
+ }
20
+ export default class ExternalStatusPageScope {
21
+ static getStatusRank(status: string): number;
22
+ static isInGroup(groupName: string | undefined, componentGroupName: string | undefined): boolean;
23
+ static getComponentsInScope(data: {
24
+ components: Array<ExternalStatusPageComponent>;
25
+ componentGroupName?: string | undefined;
26
+ componentNames: Array<string>;
27
+ }): Array<ExternalStatusPageComponent>;
28
+ static getUnmatchedNames(data: {
29
+ components: Array<ExternalStatusPageComponent>;
30
+ componentGroupName?: string | undefined;
31
+ componentNames: Array<string>;
32
+ }): Array<string>;
33
+ static deriveOverallStatus(components: Array<ExternalStatusPageComponent>, scopedIncidentCount: number): string;
34
+ static apply(input: ExternalStatusPageScopeInput): ExternalStatusPageScopeResult;
35
+ static getIncidentsInScope(data: {
36
+ components: Array<ExternalStatusPageComponent>;
37
+ targeted: Array<ExternalStatusPageComponent>;
38
+ incidents: Array<ExternalStatusPageIncident>;
39
+ }): Array<ExternalStatusPageIncident>;
40
+ static getReportedNames(incidents: Array<{
41
+ name: string;
42
+ }>): Array<string>;
43
+ }
@@ -0,0 +1,213 @@
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.EXTERNAL_STATUS_PAGE_MAX_REPORTED_INCIDENT_NAME_LENGTH = exports.EXTERNAL_STATUS_PAGE_MAX_REPORTED_INCIDENT_NAMES = void 0;
7
+ const ExternalStatusPageComponentNames_1 = __importDefault(require("./ExternalStatusPageComponentNames"));
8
+ /*
9
+ * WHAT ON A STATUS PAGE AN EXTERNAL STATUS PAGE MONITOR WATCHES.
10
+ *
11
+ * A monitor watches the whole page, one group of it (componentGroupName,
12
+ * matched as the group's name contains it), the components it chose by
13
+ * name (componentNames, ExternalStatusPageComponentNames), or the chosen
14
+ * components of one group. Its criteria then see only those:
15
+ *
16
+ * - Component Status compares each component in scope;
17
+ * - Active Incidents counts the incidents that affect at least one of
18
+ * them. An incident that names no component is not counted while the
19
+ * monitor watches part of the page: nothing says it affects that part.
20
+ * Watching the whole page, every incident counts;
21
+ * - the overall status is the page's own while it watches the whole page,
22
+ * and otherwise the worst status of the components in scope (degraded
23
+ * when one of their incidents is open while they all say operational).
24
+ *
25
+ * What it leaves out is said too, so the person can tell a quiet monitor
26
+ * from one that watches nothing: the chosen names no component on the
27
+ * page has (unmatchedComponentNames), and the active incidents elsewhere
28
+ * on the page (incidentsOutsideScopeCount).
29
+ */
30
+ // The most incident names a check reports, for the criteria's message.
31
+ exports.EXTERNAL_STATUS_PAGE_MAX_REPORTED_INCIDENT_NAMES = 20;
32
+ // The longest incident name a check reports.
33
+ exports.EXTERNAL_STATUS_PAGE_MAX_REPORTED_INCIDENT_NAME_LENGTH = 200;
34
+ class ExternalStatusPageScope {
35
+ /*
36
+ * Ranking of status vocabulary (higher = worse). Covers both Atlassian Statuspage
37
+ * and incident.io component status strings.
38
+ */
39
+ static getStatusRank(status) {
40
+ switch ((status || "").toLowerCase()) {
41
+ case "operational":
42
+ return 0;
43
+ case "under_maintenance":
44
+ case "maintenance":
45
+ return 1;
46
+ case "degraded_performance":
47
+ case "degraded":
48
+ return 2;
49
+ case "partial_outage":
50
+ return 3;
51
+ case "major_outage":
52
+ case "full_outage":
53
+ case "critical":
54
+ return 4;
55
+ default:
56
+ // Any unknown, non-operational status is treated as a degradation.
57
+ return 2;
58
+ }
59
+ }
60
+ /*
61
+ * Whether a component's group is the monitor's group: its name contains
62
+ * the group the monitor names, ignoring case. No group named: every
63
+ * component's group is.
64
+ */
65
+ static isInGroup(groupName, componentGroupName) {
66
+ if (!componentGroupName) {
67
+ return true; // no filter -> everything matches
68
+ }
69
+ if (!groupName) {
70
+ return false;
71
+ }
72
+ return groupName.toLowerCase().includes(componentGroupName.toLowerCase());
73
+ }
74
+ /*
75
+ * The components of a page in a monitor's scope: those of its group,
76
+ * and of them the ones its names pick (all of them, with no names).
77
+ */
78
+ static getComponentsInScope(data) {
79
+ const isPicked = ExternalStatusPageComponentNames_1.default.picker(data.componentNames);
80
+ return data.components.filter((component) => {
81
+ return (ExternalStatusPageScope.isInGroup(component.groupName, data.componentGroupName) &&
82
+ (data.componentNames.length === 0 || isPicked(component.name)));
83
+ });
84
+ }
85
+ /*
86
+ * The chosen names that pick no component of the monitor's group: a
87
+ * typo, a component the page renamed or removed, or one of another group.
88
+ */
89
+ static getUnmatchedNames(data) {
90
+ return ExternalStatusPageComponentNames_1.default.unmatched(data.componentNames, data.components
91
+ .filter((component) => {
92
+ return ExternalStatusPageScope.isInGroup(component.groupName, data.componentGroupName);
93
+ })
94
+ .map((component) => {
95
+ return component.name;
96
+ }));
97
+ }
98
+ /*
99
+ * Derives an overall status from the (already scoped) component list. Returns a
100
+ * standard status string (e.g. "operational", "degraded_performance",
101
+ * "major_outage") so it is comparable in monitor criteria.
102
+ */
103
+ static deriveOverallStatus(components, scopedIncidentCount) {
104
+ let worstStatus = "operational";
105
+ let worstRank = 0;
106
+ for (const component of components) {
107
+ const rank = ExternalStatusPageScope.getStatusRank(component.status);
108
+ if (rank > worstRank) {
109
+ worstRank = rank;
110
+ worstStatus = component.status;
111
+ }
112
+ }
113
+ if (worstRank === 0 && scopedIncidentCount > 0) {
114
+ // No component is explicitly degraded, but there is an active incident in scope.
115
+ return "degraded_performance";
116
+ }
117
+ return worstStatus;
118
+ }
119
+ /*
120
+ * What a check of a structured page (Atlassian Statuspage, incident.io, a
121
+ * OneUptime status page) reports for a monitor's scope.
122
+ */
123
+ static apply(input) {
124
+ const componentNames = ExternalStatusPageComponentNames_1.default.normalize(input.componentNames);
125
+ const isScoped = Boolean(input.componentGroupName) || componentNames.length > 0;
126
+ const targeted = ExternalStatusPageScope.getComponentsInScope({
127
+ components: input.components,
128
+ componentGroupName: input.componentGroupName,
129
+ componentNames: componentNames,
130
+ });
131
+ const counted = isScoped
132
+ ? ExternalStatusPageScope.getIncidentsInScope({
133
+ components: input.components,
134
+ targeted: targeted,
135
+ incidents: input.incidents,
136
+ })
137
+ : input.incidents;
138
+ const componentStatuses = targeted.map((component) => {
139
+ return {
140
+ name: component.name,
141
+ status: component.status,
142
+ description: component.description,
143
+ groupName: component.groupName,
144
+ };
145
+ });
146
+ let overallStatus;
147
+ if (!isScoped && input.pageOverallStatus) {
148
+ // Unscoped: prefer the provider's own page-level status when available.
149
+ overallStatus = input.pageOverallStatus;
150
+ }
151
+ else {
152
+ overallStatus = ExternalStatusPageScope.deriveOverallStatus(targeted, counted.length);
153
+ }
154
+ return {
155
+ componentStatuses: componentStatuses,
156
+ overallStatus: overallStatus,
157
+ activeIncidentCount: counted.length,
158
+ activeIncidentNames: ExternalStatusPageScope.getReportedNames(counted),
159
+ incidentsOutsideScopeCount: isScoped
160
+ ? input.incidents.length - counted.length
161
+ : 0,
162
+ unmatchedComponentNames: ExternalStatusPageScope.getUnmatchedNames({
163
+ components: input.components,
164
+ componentGroupName: input.componentGroupName,
165
+ componentNames: componentNames,
166
+ }),
167
+ };
168
+ }
169
+ /*
170
+ * The incidents that affect a component in scope. By the components'
171
+ * keys when the incident and the page both have them - two components of
172
+ * one name in two groups are then told apart - and by name otherwise.
173
+ */
174
+ static getIncidentsInScope(data) {
175
+ const pageHasKeys = data.components.some((component) => {
176
+ return Boolean(component.key);
177
+ });
178
+ const targetedKeys = new Set();
179
+ const targetedNames = new Set();
180
+ for (const component of data.targeted) {
181
+ if (component.key) {
182
+ targetedKeys.add(component.key);
183
+ }
184
+ targetedNames.add(ExternalStatusPageComponentNames_1.default.comparable(component.name));
185
+ }
186
+ return data.incidents.filter((incident) => {
187
+ if (incident.affectedComponentKeys && pageHasKeys) {
188
+ return incident.affectedComponentKeys.some((key) => {
189
+ return targetedKeys.has(key);
190
+ });
191
+ }
192
+ return incident.affectedComponentNames.some((name) => {
193
+ return targetedNames.has(ExternalStatusPageComponentNames_1.default.comparable(name));
194
+ });
195
+ });
196
+ }
197
+ // The names of incidents a check reports: the first few, each cut short.
198
+ static getReportedNames(incidents) {
199
+ return incidents
200
+ .slice(0, exports.EXTERNAL_STATUS_PAGE_MAX_REPORTED_INCIDENT_NAMES)
201
+ .map((incident) => {
202
+ const name = incident.name.trim();
203
+ return name.length >
204
+ exports.EXTERNAL_STATUS_PAGE_MAX_REPORTED_INCIDENT_NAME_LENGTH
205
+ ? `${name.slice(0, exports.EXTERNAL_STATUS_PAGE_MAX_REPORTED_INCIDENT_NAME_LENGTH - 1)}…`
206
+ : name;
207
+ })
208
+ .filter((name) => {
209
+ return Boolean(name);
210
+ });
211
+ }
212
+ }
213
+ exports.default = ExternalStatusPageScope;