@oneuptime/common 14.0.93 → 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.
- package/Models/DatabaseModels/Alert.d.mts +2 -0
- package/Models/DatabaseModels/Alert.d.ts +2 -0
- package/Models/DatabaseModels/Alert.js +54 -0
- package/Models/DatabaseModels/CloudAccount.d.mts +29 -0
- package/Models/DatabaseModels/CloudAccount.d.ts +29 -0
- package/Models/DatabaseModels/CloudAccount.js +546 -0
- package/Models/DatabaseModels/CloudAccount.mjs +2 -0
- package/Models/DatabaseModels/CloudResource.d.mts +8 -0
- package/Models/DatabaseModels/CloudResource.d.ts +8 -0
- package/Models/DatabaseModels/CloudResource.js +169 -0
- package/Models/DatabaseModels/CloudResourceLabelRule.d.mts +1 -0
- package/Models/DatabaseModels/CloudResourceLabelRule.d.ts +1 -0
- package/Models/DatabaseModels/CloudResourceLabelRule.js +40 -0
- package/Models/DatabaseModels/CloudResourceOwnerRule.d.mts +1 -0
- package/Models/DatabaseModels/CloudResourceOwnerRule.d.ts +1 -0
- package/Models/DatabaseModels/CloudResourceOwnerRule.js +40 -0
- package/Models/DatabaseModels/Incident.d.mts +2 -0
- package/Models/DatabaseModels/Incident.d.ts +2 -0
- package/Models/DatabaseModels/Incident.js +54 -0
- package/Models/DatabaseModels/Index.js +2 -0
- package/Models/DatabaseModels/Monitor.d.mts +2 -0
- package/Models/DatabaseModels/Monitor.d.ts +2 -0
- package/Models/DatabaseModels/Monitor.js +54 -0
- package/Models/DatabaseModels/OpenSourceDeployment.d.mts +1 -0
- package/Models/DatabaseModels/OpenSourceDeployment.d.ts +1 -0
- package/Models/DatabaseModels/OpenSourceDeployment.js +25 -6
- package/Models/DatabaseModels/ScheduledMaintenance.d.mts +1 -0
- package/Models/DatabaseModels/ScheduledMaintenance.d.ts +1 -0
- package/Models/DatabaseModels/ScheduledMaintenance.js +50 -0
- package/Types/AI/AiAffectedResources.d.mts +40 -0
- package/Types/AI/AiAffectedResources.d.ts +40 -0
- package/Types/AI/AiAffectedResources.js +292 -0
- package/Types/AI/AiAffectedResources.mjs +10 -0
- package/Types/Cloud/CloudAccountSummary.d.mts +25 -0
- package/Types/Cloud/CloudAccountSummary.d.ts +25 -0
- package/Types/Cloud/CloudAccountSummary.js +114 -0
- package/Types/Cloud/CloudAccountSummary.mjs +5 -0
- package/Types/Cloud/CloudEndpointMatch.d.mts +26 -0
- package/Types/Cloud/CloudEndpointMatch.d.ts +26 -0
- package/Types/Cloud/CloudEndpointMatch.js +134 -0
- package/Types/Cloud/CloudEndpointMatch.mjs +5 -0
- package/Types/Cloud/CloudInventory.d.mts +34 -0
- package/Types/Cloud/CloudInventory.d.ts +34 -0
- package/Types/Cloud/CloudInventory.js +362 -0
- package/Types/Cloud/CloudInventory.mjs +22 -0
- package/Types/Cloud/CloudResourceCatalog.d.mts +2 -0
- package/Types/Cloud/CloudResourceCatalog.d.ts +2 -0
- package/Types/Cloud/CloudResourceCatalog.js +29 -1
- package/Types/Cloud/CloudResourceCatalog.mjs +2 -0
- package/Types/Cloud/CloudResourceIndex.d.mts +44 -0
- package/Types/Cloud/CloudResourceIndex.d.ts +44 -0
- package/Types/Cloud/CloudResourceIndex.js +191 -0
- package/Types/Cloud/CloudResourceIndex.mjs +4 -0
- package/Types/CloudConnection/CloudConnectionCatalog.d.mts +3 -0
- package/Types/CloudConnection/CloudConnectionCatalog.d.ts +3 -0
- package/Types/CloudConnection/CloudConnectionCatalog.js +70 -12
- package/Types/CloudConnection/CloudConnectionCatalog.mjs +2 -0
- package/Types/CloudConnection/CloudConnectionPaste.js +7 -1
- package/Types/CloudConnection/CloudConnectionSetupCommands.d.mts +43 -3
- package/Types/CloudConnection/CloudConnectionSetupCommands.d.ts +43 -3
- package/Types/CloudConnection/CloudConnectionSetupCommands.js +280 -30
- package/Types/CloudConnection/CloudConnectionSetupCommands.mjs +14 -0
- package/Types/CloudConnection/CloudConnectionTest.d.mts +1 -0
- package/Types/CloudConnection/CloudConnectionTest.d.ts +1 -0
- package/Types/CloudConnection/CloudConnectionTest.js +1 -0
- package/Types/Dashboard/DashboardComponents/DashboardTableComponent.d.mts +19 -0
- package/Types/Dashboard/DashboardComponents/DashboardTableComponent.d.ts +19 -0
- package/Types/Dashboard/DashboardComponents/DashboardTableComponent.js +27 -1
- package/Types/Dashboard/DashboardComponents/DashboardTableComponent.mjs +3 -0
- package/Types/Date.d.mts +1 -0
- package/Types/Date.d.ts +1 -0
- package/Types/Date.js +32 -6
- package/Types/DateLanguage.d.mts +2 -0
- package/Types/DateLanguage.d.ts +2 -0
- package/Types/DateLanguage.js +67 -12
- package/Types/DateLanguage.mjs +2 -0
- package/Types/Domain.d.mts +2 -0
- package/Types/Domain.d.ts +2 -0
- package/Types/Domain.js +27 -0
- package/Types/Email/EmailTemplateType.d.mts +1 -0
- package/Types/Email/EmailTemplateType.d.ts +1 -0
- package/Types/Email/EmailTemplateType.js +1 -0
- package/Types/Email.d.mts +1 -0
- package/Types/Email.d.ts +1 -0
- package/Types/Email.js +16 -0
- package/Types/Monitor/ExternalStatusPageMonitor/ExternalStatusPageMonitorResponse.d.mts +4 -0
- package/Types/Monitor/ExternalStatusPageMonitor/ExternalStatusPageMonitorResponse.d.ts +4 -0
- package/Types/Monitor/MonitorStepExternalStatusPageMonitor.d.mts +3 -0
- package/Types/Monitor/MonitorStepExternalStatusPageMonitor.d.ts +3 -0
- package/Types/Monitor/MonitorStepExternalStatusPageMonitor.js +35 -0
- package/Types/Monitor/MonitorTemplateSyncField.js +6 -1
- package/Types/Monitor/UptimeBarTooltipMaintenance.d.mts +15 -0
- package/Types/Monitor/UptimeBarTooltipMaintenance.d.ts +15 -0
- package/Types/Monitor/UptimeBarTooltipMaintenance.js +2 -0
- package/Types/Monitor/UptimeBarTooltipMaintenance.mjs +1 -0
- package/Types/Monitor/UptimeHistoryLabels.d.mts +5 -0
- package/Types/Monitor/UptimeHistoryLabels.d.ts +5 -0
- package/Types/Monitor/UptimeHistoryLabels.js +5 -0
- package/Types/ReadingDirection.d.mts +10 -0
- package/Types/ReadingDirection.d.ts +10 -0
- package/Types/ReadingDirection.js +171 -0
- package/Types/ReadingDirection.mjs +10 -0
- package/Types/Rules/RuleCriteriaFieldRegistry.js +2 -0
- package/Types/Runbook/HttpStepVariables.d.mts +8 -0
- package/Types/Runbook/HttpStepVariables.d.ts +8 -0
- package/Types/Runbook/HttpStepVariables.js +109 -0
- package/Types/Runbook/HttpStepVariables.mjs +5 -0
- package/Types/Runbook/RunbookStep.d.mts +1 -0
- package/Types/Runbook/RunbookStep.d.ts +1 -0
- package/Types/Runbook/RunnerFeatures.d.mts +1 -0
- package/Types/Runbook/RunnerFeatures.d.ts +1 -0
- package/Types/Runbook/RunnerFeatures.js +15 -3
- package/Types/Runbook/RunnerFeatures.mjs +1 -0
- package/Types/Runbook/SshHostKey.d.mts +22 -0
- package/Types/Runbook/SshHostKey.d.ts +22 -0
- package/Types/Runbook/SshHostKey.js +201 -0
- package/Types/Runbook/SshHostKey.mjs +10 -0
- package/Types/Runner/CodeRepositoryRunner.js +2 -3
- package/Types/Runner/GlobalAIAgentsGone.d.mts +1 -0
- package/Types/Runner/GlobalAIAgentsGone.d.ts +1 -0
- package/Types/Runner/GlobalAIAgentsGone.js +19 -0
- package/Types/Runner/GlobalAIAgentsGone.mjs +2 -0
- package/Types/Runner/GlobalRunnerWork.d.mts +1 -0
- package/Types/Runner/GlobalRunnerWork.d.ts +1 -0
- package/Types/Runner/GlobalRunnerWork.js +21 -1
- package/Types/Runner/GlobalRunnerWork.mjs +1 -0
- package/Types/SSO/SignInMethods.d.mts +31 -0
- package/Types/SSO/SignInMethods.d.ts +31 -0
- package/Types/SSO/SignInMethods.js +160 -0
- package/Types/SSO/SignInMethods.mjs +8 -0
- package/Types/ScheduledMaintenance/ScheduledMaintenancePublication.d.mts +24 -0
- package/Types/ScheduledMaintenance/ScheduledMaintenancePublication.d.ts +24 -0
- package/Types/ScheduledMaintenance/ScheduledMaintenancePublication.js +159 -0
- package/Types/ScheduledMaintenance/ScheduledMaintenancePublication.mjs +8 -0
- package/Types/StatusPage/StatusPageLanguage.d.mts +6 -0
- package/Types/StatusPage/StatusPageLanguage.d.ts +6 -0
- package/Types/StatusPage/StatusPageLanguage.js +17 -1
- package/Types/StatusPage/StatusPageLanguage.mjs +1 -0
- package/Types/Workflow/WorkflowPlan.d.mts +7 -0
- package/Types/Workflow/WorkflowPlan.d.ts +7 -0
- package/Types/Workflow/WorkflowPlan.js +39 -0
- package/Types/Workflow/WorkflowPlan.mjs +3 -0
- package/Types/Workspace/WorkspaceMessagePayload.d.mts +11 -0
- package/Types/Workspace/WorkspaceMessagePayload.d.ts +11 -0
- package/Utils/Dashboard/TableThresholds.d.mts +44 -0
- package/Utils/Dashboard/TableThresholds.d.ts +44 -0
- package/Utils/Dashboard/TableThresholds.js +288 -0
- package/Utils/Dashboard/TableThresholds.mjs +17 -0
- package/Utils/Dashboard/ValueWidgetSeries.d.mts +6 -0
- package/Utils/Dashboard/ValueWidgetSeries.d.ts +6 -0
- package/Utils/Dashboard/ValueWidgetSeries.js +70 -1
- package/Utils/Dashboard/ValueWidgetSeries.mjs +2 -0
- package/Utils/DeveloperDocs/ResourceProfiles.js +16 -0
- package/Utils/DeveloperDocs/TerraformSchema.d.mts +1 -0
- package/Utils/DeveloperDocs/TerraformSchema.d.ts +1 -0
- package/Utils/DeveloperDocs/TerraformSchema.js +17 -0
- package/Utils/DeveloperDocs/TerraformSchema.mjs +1 -0
- package/Utils/Monitor/ExternalStatusPageComponentNames.d.mts +17 -0
- package/Utils/Monitor/ExternalStatusPageComponentNames.d.ts +17 -0
- package/Utils/Monitor/ExternalStatusPageComponentNames.js +274 -0
- package/Utils/Monitor/ExternalStatusPageComponentNames.mjs +6 -0
- package/Utils/Monitor/ExternalStatusPageReading.d.mts +35 -0
- package/Utils/Monitor/ExternalStatusPageReading.d.ts +35 -0
- package/Utils/Monitor/ExternalStatusPageReading.js +380 -0
- package/Utils/Monitor/ExternalStatusPageReading.mjs +6 -0
- package/Utils/Monitor/ExternalStatusPageScope.d.mts +43 -0
- package/Utils/Monitor/ExternalStatusPageScope.d.ts +43 -0
- package/Utils/Monitor/ExternalStatusPageScope.js +213 -0
- package/Utils/Monitor/ExternalStatusPageScope.mjs +4 -0
- package/Utils/Runbook/SshHostKeyFingerprint.d.mts +8 -0
- package/Utils/Runbook/SshHostKeyFingerprint.d.ts +8 -0
- package/Utils/Runbook/SshHostKeyFingerprint.js +83 -0
- package/Utils/Runbook/SshHostKeyFingerprint.mjs +5 -0
- package/Utils/ScheduledMaintenanceStart.d.mts +6 -0
- package/Utils/ScheduledMaintenanceStart.d.ts +6 -0
- package/Utils/ScheduledMaintenanceStart.js +15 -0
- package/Utils/StatusPage/HistoryChartBarColors.d.mts +2 -0
- package/Utils/StatusPage/HistoryChartBarColors.d.ts +2 -0
- package/Utils/StatusPage/HistoryChartBarColors.js +12 -1
- package/Utils/StatusPage/HistoryChartBarColors.mjs +2 -0
- package/Utils/Telemetry/ChangeEventFields.d.mts +19 -1
- package/Utils/Telemetry/ChangeEventFields.d.ts +19 -1
- package/Utils/Telemetry/ChangeEventFields.js +52 -1
- package/Utils/Uptime/DayUptimeGraphUtil.d.mts +6 -0
- package/Utils/Uptime/DayUptimeGraphUtil.d.ts +6 -0
- package/Utils/Uptime/DayUptimeGraphUtil.js +37 -6
- package/Utils/Uptime/UptimeMaintenanceUtil.d.mts +60 -0
- package/Utils/Uptime/UptimeMaintenanceUtil.d.ts +60 -0
- package/Utils/Uptime/UptimeMaintenanceUtil.js +295 -0
- package/Utils/Uptime/UptimeMaintenanceUtil.mjs +3 -0
- 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;
|