@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.
- package/Models/DatabaseModels/Alert.d.mts +2 -0
- package/Models/DatabaseModels/Alert.d.ts +2 -0
- package/Models/DatabaseModels/Alert.js +62 -1
- package/Models/DatabaseModels/AlertEpisodeMember.d.mts +1 -0
- package/Models/DatabaseModels/AlertEpisodeMember.d.ts +1 -0
- package/Models/DatabaseModels/AlertEpisodeMember.js +50 -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/IncidentEpisodeMember.d.mts +1 -0
- package/Models/DatabaseModels/IncidentEpisodeMember.d.ts +1 -0
- package/Models/DatabaseModels/IncidentEpisodeMember.js +50 -0
- package/Models/DatabaseModels/IncomingCallPolicy.js +1 -1
- package/Models/DatabaseModels/Index.js +2 -0
- package/Models/DatabaseModels/LlmProvider.js +1 -1
- 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/MonitorTemplate.js +10 -4
- package/Models/DatabaseModels/NetworkDeviceDiscoveryScan.js +13 -13
- package/Models/DatabaseModels/OnCallDutyPolicy.js +1 -1
- 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/Models/DatabaseModels/ScheduledMaintenanceReminderRule.js +1 -1
- package/Models/DatabaseModels/StatusPage.d.mts +2 -0
- package/Models/DatabaseModels/StatusPage.d.ts +2 -0
- package/Models/DatabaseModels/StatusPage.js +100 -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/Database/BlankColumnValue.d.mts +6 -0
- package/Types/Database/BlankColumnValue.d.ts +6 -0
- package/Types/Database/BlankColumnValue.js +77 -0
- package/Types/Database/BlankColumnValue.mjs +4 -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 +2 -0
- package/Types/Email/EmailTemplateType.d.ts +2 -0
- package/Types/Email/EmailTemplateType.js +2 -0
- package/Types/Email.d.mts +1 -0
- package/Types/Email.d.ts +1 -0
- package/Types/Email.js +16 -0
- package/Types/IncomingCall/IncomingCallPolicyRepeat.d.mts +6 -0
- package/Types/IncomingCall/IncomingCallPolicyRepeat.d.ts +6 -0
- package/Types/IncomingCall/IncomingCallPolicyRepeat.js +41 -14
- package/Types/IncomingCall/IncomingCallPolicyRepeat.mjs +3 -0
- package/Types/Monitor/CriteriaFilter.d.mts +1 -0
- package/Types/Monitor/CriteriaFilter.d.ts +1 -0
- package/Types/Monitor/CriteriaFilter.js +9 -0
- package/Types/Monitor/DatabaseMetricCatalog.js +2 -2
- package/Types/Monitor/ExternalStatusPageMonitor/ExternalStatusPageMonitorResponse.d.mts +4 -0
- package/Types/Monitor/ExternalStatusPageMonitor/ExternalStatusPageMonitorResponse.d.ts +4 -0
- package/Types/Monitor/KubernetesEventAlertTemplates.d.mts +20 -0
- package/Types/Monitor/KubernetesEventAlertTemplates.d.ts +20 -0
- package/Types/Monitor/KubernetesEventAlertTemplates.js +232 -0
- package/Types/Monitor/KubernetesEventAlertTemplates.mjs +8 -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/MonitorType.js +12 -2
- package/Types/Monitor/Recommendation/MonitorRecommendationCatalog.js +27 -2
- package/Types/Monitor/Recommendation/MonitorRecommendationUtil.d.mts +1 -0
- package/Types/Monitor/Recommendation/MonitorRecommendationUtil.d.ts +1 -0
- package/Types/Monitor/Recommendation/MonitorRecommendationUtil.js +31 -1
- package/Types/Monitor/SnmpMonitor/NetworkDeviceAlertPack.d.mts +3 -1
- package/Types/Monitor/SnmpMonitor/NetworkDeviceAlertPack.d.ts +3 -1
- package/Types/Monitor/SnmpMonitor/NetworkDeviceAlertPack.js +3 -2
- package/Types/Monitor/SnmpMonitor/SnmpMonitorResponse.d.mts +1 -0
- package/Types/Monitor/SnmpMonitor/SnmpMonitorResponse.d.ts +1 -0
- 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/NotificationSetting/NotificationEmailRollupCategory.js +2 -0
- package/Types/NotificationSetting/NotificationEmailRollupPolicy.js +10 -3
- package/Types/NotificationSetting/NotificationSettingEventType.d.mts +1 -0
- package/Types/NotificationSetting/NotificationSettingEventType.d.ts +1 -0
- package/Types/NotificationSetting/NotificationSettingEventType.js +7 -0
- package/Types/OnCallDutyPolicy/OnCallDutyPolicyRepeat.d.mts +7 -0
- package/Types/OnCallDutyPolicy/OnCallDutyPolicyRepeat.d.ts +7 -0
- package/Types/OnCallDutyPolicy/OnCallDutyPolicyRepeat.js +51 -0
- package/Types/OnCallDutyPolicy/OnCallDutyPolicyRepeat.mjs +4 -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/Reminder/ScheduledMaintenanceReminderNeverReminds.d.mts +8 -0
- package/Types/Reminder/ScheduledMaintenanceReminderNeverReminds.d.ts +8 -0
- package/Types/Reminder/ScheduledMaintenanceReminderNeverReminds.js +55 -0
- package/Types/Reminder/ScheduledMaintenanceReminderNeverReminds.mjs +5 -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/Templates.js +2 -5
- 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/ColorContrast.d.mts +3 -0
- package/Utils/ColorContrast.d.ts +3 -0
- package/Utils/ColorContrast.js +41 -3
- package/Utils/ColorContrast.mjs +2 -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/Incident/WhoOpenedItRootCause.d.mts +2 -0
- package/Utils/Incident/WhoOpenedItRootCause.d.ts +2 -0
- package/Utils/Incident/WhoOpenedItRootCause.js +50 -0
- package/Utils/Incident/WhoOpenedItRootCause.mjs +3 -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/Monitor/SyntheticMonitorStepsUtil.d.mts +18 -0
- package/Utils/Monitor/SyntheticMonitorStepsUtil.d.ts +18 -0
- package/Utils/Monitor/SyntheticMonitorStepsUtil.js +129 -0
- package/Utils/Monitor/SyntheticMonitorStepsUtil.mjs +4 -0
- package/Utils/Rules/RuleRunSummary.d.mts +1 -0
- package/Utils/Rules/RuleRunSummary.d.ts +1 -0
- package/Utils/Rules/RuleRunSummary.js +19 -1
- package/Utils/Rules/RuleRunSummary.mjs +1 -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/Sms/Gsm7Text.js +9 -1
- package/Utils/Sms/OnCallPageSms.d.mts +2 -0
- package/Utils/Sms/OnCallPageSms.d.ts +2 -0
- package/Utils/Sms/OnCallPageSms.js +19 -2
- package/Utils/Sms/OnCallPageSms.mjs +1 -0
- package/Utils/Sms/SubscriberSms.d.mts +2 -0
- package/Utils/Sms/SubscriberSms.d.ts +2 -0
- package/Utils/Sms/SubscriberSms.js +35 -0
- package/Utils/Sms/SubscriberSms.mjs +3 -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
package/Utils/ColorContrast.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FILLED_TEXT_MINIMUM_CONTRAST = void 0;
|
|
3
4
|
exports.parseColor = parseColor;
|
|
4
5
|
exports.getRelativeLuminance = getRelativeLuminance;
|
|
5
6
|
exports.getContrastRatio = getContrastRatio;
|
|
6
7
|
exports.composite = composite;
|
|
7
8
|
exports.getReadableShade = getReadableShade;
|
|
9
|
+
exports.getReadableTextOnFill = getReadableTextOnFill;
|
|
8
10
|
exports.getAlphaForLuminance = getAlphaForLuminance;
|
|
9
11
|
// #rgb, #rrggbb, or #rrggbbaa (the alpha is ignored); the # is optional.
|
|
10
12
|
const HEX_PATTERN = /^#?([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/;
|
|
@@ -132,8 +134,8 @@ function hslToRgb(hsl) {
|
|
|
132
134
|
* The shade of `color` nearest to it that reaches `minimumContrast` against
|
|
133
135
|
* `background`: the colour itself when it already does, otherwise the same
|
|
134
136
|
* hue with only the lightness moved - toward black on a light background,
|
|
135
|
-
* toward white on a dark one
|
|
136
|
-
* binary search finds the boundary.
|
|
137
|
+
* toward white on a dark one, or the way `towards` says. Lightness moves
|
|
138
|
+
* luminance one way only, so a binary search finds the boundary.
|
|
137
139
|
*/
|
|
138
140
|
function getReadableShade(data) {
|
|
139
141
|
if (getContrastRatio(data.color, data.background) >= data.minimumContrast) {
|
|
@@ -150,7 +152,13 @@ function getReadableShade(data) {
|
|
|
150
152
|
}
|
|
151
153
|
// `low` never passes; `high` always does (black or white at the limit).
|
|
152
154
|
let low = hsl.lightness;
|
|
153
|
-
let high =
|
|
155
|
+
let high = data.towards
|
|
156
|
+
? data.towards === "light"
|
|
157
|
+
? 1
|
|
158
|
+
: 0
|
|
159
|
+
: getRelativeLuminance(data.background) < 0.5
|
|
160
|
+
? 1
|
|
161
|
+
: 0;
|
|
154
162
|
for (let step = 0; step < 24; step++) {
|
|
155
163
|
const middle = (low + high) / 2;
|
|
156
164
|
if (passes(middle)) {
|
|
@@ -162,6 +170,36 @@ function getReadableShade(data) {
|
|
|
162
170
|
}
|
|
163
171
|
return hslToRgb(Object.assign(Object.assign({}, hsl), { lightness: high }));
|
|
164
172
|
}
|
|
173
|
+
/*
|
|
174
|
+
* WCAG's minimum for text: what text written on a filled colour must reach.
|
|
175
|
+
*/
|
|
176
|
+
exports.FILLED_TEXT_MINIMUM_CONTRAST = 4.5;
|
|
177
|
+
const WHITE = { red: 255, green: 255, blue: 255 };
|
|
178
|
+
/*
|
|
179
|
+
* The colour of text written on a filled colour someone picked - a status
|
|
180
|
+
* page's banner in the colour its owner gave a monitor status: white when
|
|
181
|
+
* white reads on it at 4.5:1, otherwise the lightest shade of the fill's own
|
|
182
|
+
* colour that does, so the words keep its family - deep green on a green
|
|
183
|
+
* banner, deep amber on a yellow one - rather than turning grey.
|
|
184
|
+
*
|
|
185
|
+
* White on the default Operational green (#2ab57d) was 2.6:1, on Degraded's
|
|
186
|
+
* yellow (#ffbf53) 1.6:1. A shade toward black always reaches 4.5:1 where
|
|
187
|
+
* white does not (black reaches more than 4.6:1 on anything white fails
|
|
188
|
+
* on), so there always is one. The fill itself is never changed: it is the colour
|
|
189
|
+
* the owner chose, the same in the light theme and the dark one, and so is
|
|
190
|
+
* the text on it.
|
|
191
|
+
*/
|
|
192
|
+
function getReadableTextOnFill(fill) {
|
|
193
|
+
if (getContrastRatio(WHITE, fill) >= exports.FILLED_TEXT_MINIMUM_CONTRAST) {
|
|
194
|
+
return WHITE;
|
|
195
|
+
}
|
|
196
|
+
return getReadableShade({
|
|
197
|
+
color: fill,
|
|
198
|
+
background: fill,
|
|
199
|
+
minimumContrast: exports.FILLED_TEXT_MINIMUM_CONTRAST,
|
|
200
|
+
towards: "dark",
|
|
201
|
+
});
|
|
202
|
+
}
|
|
165
203
|
/*
|
|
166
204
|
* The opacity at which `color` over `surface` lands nearest to
|
|
167
205
|
* `targetLuminance`, kept inside `range`. More opacity only ever moves the
|
package/Utils/ColorContrast.mjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import commonJsModule from "./ColorContrast.js";
|
|
2
|
+
export const FILLED_TEXT_MINIMUM_CONTRAST = commonJsModule.FILLED_TEXT_MINIMUM_CONTRAST;
|
|
2
3
|
export const composite = commonJsModule.composite;
|
|
3
4
|
export const getAlphaForLuminance = commonJsModule.getAlphaForLuminance;
|
|
4
5
|
export const getContrastRatio = commonJsModule.getContrastRatio;
|
|
5
6
|
export const getReadableShade = commonJsModule.getReadableShade;
|
|
7
|
+
export const getReadableTextOnFill = commonJsModule.getReadableTextOnFill;
|
|
6
8
|
export const getRelativeLuminance = commonJsModule.getRelativeLuminance;
|
|
7
9
|
export const parseColor = commonJsModule.parseColor;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { TableColumnThresholds, TableThresholdDirection, TableThresholdLevel, TableThresholdStyle } from "../../Types/Dashboard/DashboardComponents/DashboardTableComponent.mjs";
|
|
2
|
+
export declare const TABLE_THRESHOLD_PERCENT_PRESET: Readonly<{
|
|
3
|
+
warning: number;
|
|
4
|
+
critical: number;
|
|
5
|
+
}>;
|
|
6
|
+
export declare const TABLE_THRESHOLD_PERCENT_LOWER_IS_WORSE_PRESET: Readonly<{
|
|
7
|
+
warning: number;
|
|
8
|
+
critical: number;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const readTableThresholdNumber: (value: unknown) => number | undefined;
|
|
11
|
+
export declare const readTableThresholdDirection: (value: unknown) => TableThresholdDirection;
|
|
12
|
+
export declare const readTableColumnThresholds: (value: unknown) => TableColumnThresholds | null;
|
|
13
|
+
export declare const readTableThresholdStyle: (value: unknown) => TableThresholdStyle;
|
|
14
|
+
export declare const getTableThresholdLevel: (data: {
|
|
15
|
+
value: number | null | undefined;
|
|
16
|
+
thresholds: TableColumnThresholds | null | undefined;
|
|
17
|
+
}) => TableThresholdLevel | null;
|
|
18
|
+
export declare const isTableThresholdOrderReversed: (thresholds: TableColumnThresholds | null | undefined) => boolean;
|
|
19
|
+
export interface TableColumnDisplay {
|
|
20
|
+
unit: string | undefined;
|
|
21
|
+
factor: number;
|
|
22
|
+
}
|
|
23
|
+
export declare const getTableColumnDisplay: (data: {
|
|
24
|
+
columnUnit?: string | undefined;
|
|
25
|
+
metricUnit?: string | undefined;
|
|
26
|
+
metricName?: string | undefined;
|
|
27
|
+
}) => TableColumnDisplay;
|
|
28
|
+
export declare const isTableColumnPercent: (display: TableColumnDisplay) => boolean;
|
|
29
|
+
export declare const getTableThresholdPreset: (display: TableColumnDisplay, direction?: TableThresholdDirection | undefined) => TableColumnThresholds;
|
|
30
|
+
export declare const isTableThresholdPreset: (data: {
|
|
31
|
+
thresholds: TableColumnThresholds | null | undefined;
|
|
32
|
+
display: TableColumnDisplay;
|
|
33
|
+
}) => boolean;
|
|
34
|
+
export declare const joinTableValueAndUnit: (formatted: string, unit: string | undefined) => string;
|
|
35
|
+
export declare const roundTableValue: (value: number, decimals: number) => number;
|
|
36
|
+
export declare const formatTableValue: (data: {
|
|
37
|
+
value: number;
|
|
38
|
+
decimals: number;
|
|
39
|
+
unit: string | undefined;
|
|
40
|
+
}) => string;
|
|
41
|
+
export declare const formatTableThreshold: (data: {
|
|
42
|
+
threshold: number;
|
|
43
|
+
unit: string | undefined;
|
|
44
|
+
}) => string;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { TableColumnThresholds, TableThresholdDirection, TableThresholdLevel, TableThresholdStyle } from "../../Types/Dashboard/DashboardComponents/DashboardTableComponent";
|
|
2
|
+
export declare const TABLE_THRESHOLD_PERCENT_PRESET: Readonly<{
|
|
3
|
+
warning: number;
|
|
4
|
+
critical: number;
|
|
5
|
+
}>;
|
|
6
|
+
export declare const TABLE_THRESHOLD_PERCENT_LOWER_IS_WORSE_PRESET: Readonly<{
|
|
7
|
+
warning: number;
|
|
8
|
+
critical: number;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const readTableThresholdNumber: (value: unknown) => number | undefined;
|
|
11
|
+
export declare const readTableThresholdDirection: (value: unknown) => TableThresholdDirection;
|
|
12
|
+
export declare const readTableColumnThresholds: (value: unknown) => TableColumnThresholds | null;
|
|
13
|
+
export declare const readTableThresholdStyle: (value: unknown) => TableThresholdStyle;
|
|
14
|
+
export declare const getTableThresholdLevel: (data: {
|
|
15
|
+
value: number | null | undefined;
|
|
16
|
+
thresholds: TableColumnThresholds | null | undefined;
|
|
17
|
+
}) => TableThresholdLevel | null;
|
|
18
|
+
export declare const isTableThresholdOrderReversed: (thresholds: TableColumnThresholds | null | undefined) => boolean;
|
|
19
|
+
export interface TableColumnDisplay {
|
|
20
|
+
unit: string | undefined;
|
|
21
|
+
factor: number;
|
|
22
|
+
}
|
|
23
|
+
export declare const getTableColumnDisplay: (data: {
|
|
24
|
+
columnUnit?: string | undefined;
|
|
25
|
+
metricUnit?: string | undefined;
|
|
26
|
+
metricName?: string | undefined;
|
|
27
|
+
}) => TableColumnDisplay;
|
|
28
|
+
export declare const isTableColumnPercent: (display: TableColumnDisplay) => boolean;
|
|
29
|
+
export declare const getTableThresholdPreset: (display: TableColumnDisplay, direction?: TableThresholdDirection | undefined) => TableColumnThresholds;
|
|
30
|
+
export declare const isTableThresholdPreset: (data: {
|
|
31
|
+
thresholds: TableColumnThresholds | null | undefined;
|
|
32
|
+
display: TableColumnDisplay;
|
|
33
|
+
}) => boolean;
|
|
34
|
+
export declare const joinTableValueAndUnit: (formatted: string, unit: string | undefined) => string;
|
|
35
|
+
export declare const roundTableValue: (value: number, decimals: number) => number;
|
|
36
|
+
export declare const formatTableValue: (data: {
|
|
37
|
+
value: number;
|
|
38
|
+
decimals: number;
|
|
39
|
+
unit: string | undefined;
|
|
40
|
+
}) => string;
|
|
41
|
+
export declare const formatTableThreshold: (data: {
|
|
42
|
+
threshold: number;
|
|
43
|
+
unit: string | undefined;
|
|
44
|
+
}) => string;
|
|
@@ -0,0 +1,288 @@
|
|
|
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.formatTableThreshold = exports.formatTableValue = exports.roundTableValue = exports.joinTableValueAndUnit = exports.isTableThresholdPreset = exports.getTableThresholdPreset = exports.isTableColumnPercent = exports.getTableColumnDisplay = exports.isTableThresholdOrderReversed = exports.getTableThresholdLevel = exports.readTableThresholdStyle = exports.readTableColumnThresholds = exports.readTableThresholdDirection = exports.readTableThresholdNumber = exports.TABLE_THRESHOLD_PERCENT_LOWER_IS_WORSE_PRESET = exports.TABLE_THRESHOLD_PERCENT_PRESET = void 0;
|
|
7
|
+
const DashboardTableComponent_1 = require("../../Types/Dashboard/DashboardComponents/DashboardTableComponent");
|
|
8
|
+
const ValueFormatter_1 = __importDefault(require("../ValueFormatter"));
|
|
9
|
+
/*
|
|
10
|
+
* A metric table's threshold colors (issue #5231): each value column may
|
|
11
|
+
* have a warning and a critical threshold, and a value at or past one is
|
|
12
|
+
* drawn amber or red. React-free, so the widget, its settings and the tests
|
|
13
|
+
* all read one copy of the rules:
|
|
14
|
+
*
|
|
15
|
+
* - What is stored is read leniently (readTableColumnThresholds): a
|
|
16
|
+
* dashboard's config is JSON that the API, Terraform or a hand edit
|
|
17
|
+
* may have written, so "80" is 80, and a threshold that is not a number
|
|
18
|
+
* is no threshold.
|
|
19
|
+
* - A value is compared as the cell shows it (getTableColumnDisplay,
|
|
20
|
+
* roundTableValue): a usage metric OpenTelemetry sends as a fraction
|
|
21
|
+
* of 1 - system.cpu.utilization at 0.93 - shows as 93% and is compared
|
|
22
|
+
* against 93, rounded to the column's decimals, so thresholds are typed
|
|
23
|
+
* as the table reads and a cell that says 80% is at a warning of 80.
|
|
24
|
+
* - A threshold is reached AT its value, as the Value and Gauge widgets'
|
|
25
|
+
* are: 90 is critical for "critical at 90", and 80 is a warning for
|
|
26
|
+
* "warning at 80". Lower-is-worse columns reach theirs at or below.
|
|
27
|
+
* - A value that is missing is never colored: the cell says "-".
|
|
28
|
+
*/
|
|
29
|
+
// The thresholds a percent column starts with when they are turned on.
|
|
30
|
+
exports.TABLE_THRESHOLD_PERCENT_PRESET = {
|
|
31
|
+
warning: 80,
|
|
32
|
+
critical: 90,
|
|
33
|
+
};
|
|
34
|
+
/*
|
|
35
|
+
* The same column's when lower is worse: free disk space or memory, the
|
|
36
|
+
* mirror of 80 and 90 in use. Picking Lower is worse on a percent column
|
|
37
|
+
* whose thresholds are still the preset moves them here, so the pick never
|
|
38
|
+
* leaves critical on the wrong side of warning.
|
|
39
|
+
*/
|
|
40
|
+
exports.TABLE_THRESHOLD_PERCENT_LOWER_IS_WORSE_PRESET = {
|
|
41
|
+
warning: 20,
|
|
42
|
+
critical: 10,
|
|
43
|
+
};
|
|
44
|
+
/*
|
|
45
|
+
* A stored threshold as a number: a finite number, or text that is one
|
|
46
|
+
* (" 90.5 "). Anything else - empty text, a word, NaN, Infinity - is no
|
|
47
|
+
* threshold at all.
|
|
48
|
+
*/
|
|
49
|
+
const readTableThresholdNumber = (value) => {
|
|
50
|
+
if (typeof value === "number") {
|
|
51
|
+
return Number.isFinite(value) ? value : undefined;
|
|
52
|
+
}
|
|
53
|
+
if (typeof value === "string") {
|
|
54
|
+
const trimmed = value.trim();
|
|
55
|
+
if (trimmed === "") {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
const parsed = Number(trimmed);
|
|
59
|
+
return Number.isFinite(parsed) ? parsed : undefined;
|
|
60
|
+
}
|
|
61
|
+
return undefined;
|
|
62
|
+
};
|
|
63
|
+
exports.readTableThresholdNumber = readTableThresholdNumber;
|
|
64
|
+
// A stored direction: lower is worse only when it says so.
|
|
65
|
+
const readTableThresholdDirection = (value) => {
|
|
66
|
+
return value === DashboardTableComponent_1.TableThresholdDirection.LowerIsWorse
|
|
67
|
+
? DashboardTableComponent_1.TableThresholdDirection.LowerIsWorse
|
|
68
|
+
: DashboardTableComponent_1.TableThresholdDirection.HigherIsWorse;
|
|
69
|
+
};
|
|
70
|
+
exports.readTableThresholdDirection = readTableThresholdDirection;
|
|
71
|
+
/*
|
|
72
|
+
* A column's stored thresholds, or null when it has none in force: not an
|
|
73
|
+
* object, or neither threshold a number. The direction is always set on
|
|
74
|
+
* what comes back.
|
|
75
|
+
*/
|
|
76
|
+
const readTableColumnThresholds = (value) => {
|
|
77
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
const stored = value;
|
|
81
|
+
const warning = (0, exports.readTableThresholdNumber)(stored["warning"]);
|
|
82
|
+
const critical = (0, exports.readTableThresholdNumber)(stored["critical"]);
|
|
83
|
+
if (warning === undefined && critical === undefined) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
const thresholds = {
|
|
87
|
+
direction: (0, exports.readTableThresholdDirection)(stored["direction"]),
|
|
88
|
+
};
|
|
89
|
+
if (warning !== undefined) {
|
|
90
|
+
thresholds.warning = warning;
|
|
91
|
+
}
|
|
92
|
+
if (critical !== undefined) {
|
|
93
|
+
thresholds.critical = critical;
|
|
94
|
+
}
|
|
95
|
+
return thresholds;
|
|
96
|
+
};
|
|
97
|
+
exports.readTableColumnThresholds = readTableColumnThresholds;
|
|
98
|
+
// How the table colors a value past a threshold: its number, unless it says the cell.
|
|
99
|
+
const readTableThresholdStyle = (value) => {
|
|
100
|
+
return value === DashboardTableComponent_1.TableThresholdStyle.Background
|
|
101
|
+
? DashboardTableComponent_1.TableThresholdStyle.Background
|
|
102
|
+
: DashboardTableComponent_1.TableThresholdStyle.Text;
|
|
103
|
+
};
|
|
104
|
+
exports.readTableThresholdStyle = readTableThresholdStyle;
|
|
105
|
+
/*
|
|
106
|
+
* Whether `value` has reached `threshold`, the way the column's values go
|
|
107
|
+
* bad: at or above it when higher is worse, at or below it when lower is.
|
|
108
|
+
*/
|
|
109
|
+
const hasReached = (value, threshold, direction) => {
|
|
110
|
+
if (threshold === undefined) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
return direction === DashboardTableComponent_1.TableThresholdDirection.LowerIsWorse
|
|
114
|
+
? value <= threshold
|
|
115
|
+
: value >= threshold;
|
|
116
|
+
};
|
|
117
|
+
/*
|
|
118
|
+
* The level a value has reached - Critical before Warning, so a critical
|
|
119
|
+
* threshold always wins - or null when it has reached neither, when the
|
|
120
|
+
* column has no thresholds, or when there is no value to compare.
|
|
121
|
+
* `value` is in the scale the cell shows (getTableColumnDisplay).
|
|
122
|
+
*/
|
|
123
|
+
const getTableThresholdLevel = (data) => {
|
|
124
|
+
const value = data.value;
|
|
125
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
const thresholds = (0, exports.readTableColumnThresholds)(data.thresholds);
|
|
129
|
+
if (!thresholds) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
const direction = (0, exports.readTableThresholdDirection)(thresholds.direction);
|
|
133
|
+
if (hasReached(value, thresholds.critical, direction)) {
|
|
134
|
+
return DashboardTableComponent_1.TableThresholdLevel.Critical;
|
|
135
|
+
}
|
|
136
|
+
if (hasReached(value, thresholds.warning, direction)) {
|
|
137
|
+
return DashboardTableComponent_1.TableThresholdLevel.Warning;
|
|
138
|
+
}
|
|
139
|
+
return null;
|
|
140
|
+
};
|
|
141
|
+
exports.getTableThresholdLevel = getTableThresholdLevel;
|
|
142
|
+
/*
|
|
143
|
+
* True when both thresholds are set and critical comes before warning - a
|
|
144
|
+
* critical of 80 under a warning of 90 when higher is worse. The values are
|
|
145
|
+
* still colored (critical wins from 80 up, so nothing is ever a warning);
|
|
146
|
+
* the settings say how to put them right.
|
|
147
|
+
*/
|
|
148
|
+
const isTableThresholdOrderReversed = (thresholds) => {
|
|
149
|
+
const read = (0, exports.readTableColumnThresholds)(thresholds);
|
|
150
|
+
if (!read ||
|
|
151
|
+
read.warning === undefined ||
|
|
152
|
+
read.critical === undefined ||
|
|
153
|
+
read.warning === read.critical) {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
return (0, exports.readTableThresholdDirection)(read.direction) ===
|
|
157
|
+
DashboardTableComponent_1.TableThresholdDirection.LowerIsWorse
|
|
158
|
+
? read.critical > read.warning
|
|
159
|
+
: read.critical < read.warning;
|
|
160
|
+
};
|
|
161
|
+
exports.isTableThresholdOrderReversed = isTableThresholdOrderReversed;
|
|
162
|
+
/*
|
|
163
|
+
* How a column shows its values, from what its Unit setting says (blank is
|
|
164
|
+
* Auto) and the metric it reads:
|
|
165
|
+
*
|
|
166
|
+
* - a usage metric sent as a fraction of 1 - unit "1" and a name such as
|
|
167
|
+
* system.cpu.utilization (ValueFormatter.isFractionMetric) - is shown
|
|
168
|
+
* as a percent, x100, when the Unit is Auto or a percent: 0.93 reads
|
|
169
|
+
* 93.00%, as the Value, Gauge and Chart widgets show it;
|
|
170
|
+
* - any other unit "1" means a plain number, and is not written;
|
|
171
|
+
* - otherwise the Unit as typed, or the metric's own unit when Auto.
|
|
172
|
+
*
|
|
173
|
+
* A formula column has no metric of its own: it shows its Unit as typed.
|
|
174
|
+
*/
|
|
175
|
+
const getTableColumnDisplay = (data) => {
|
|
176
|
+
const columnUnit = (data.columnUnit || "").trim();
|
|
177
|
+
const metricUnit = (data.metricUnit || "").trim();
|
|
178
|
+
const isFraction = metricUnit === "1" && ValueFormatter_1.default.isFractionMetric(data.metricName);
|
|
179
|
+
if (isFraction && columnUnit === "") {
|
|
180
|
+
return { unit: "%", factor: 100 };
|
|
181
|
+
}
|
|
182
|
+
if (isFraction && ValueFormatter_1.default.isPercentUnit(columnUnit)) {
|
|
183
|
+
return { unit: columnUnit, factor: 100 };
|
|
184
|
+
}
|
|
185
|
+
if (columnUnit !== "") {
|
|
186
|
+
return { unit: columnUnit, factor: 1 };
|
|
187
|
+
}
|
|
188
|
+
if (metricUnit === "" || metricUnit === "1") {
|
|
189
|
+
return { unit: undefined, factor: 1 };
|
|
190
|
+
}
|
|
191
|
+
return { unit: metricUnit, factor: 1 };
|
|
192
|
+
};
|
|
193
|
+
exports.getTableColumnDisplay = getTableColumnDisplay;
|
|
194
|
+
// Whether a column shows percents: its thresholds then start at 80 and 90.
|
|
195
|
+
const isTableColumnPercent = (display) => {
|
|
196
|
+
return ValueFormatter_1.default.isPercentUnit(display.unit);
|
|
197
|
+
};
|
|
198
|
+
exports.isTableColumnPercent = isTableColumnPercent;
|
|
199
|
+
/*
|
|
200
|
+
* The thresholds a column starts with when they are turned on: 80 and 90,
|
|
201
|
+
* higher is worse, for a percent column - CPU, memory and disk in use, what
|
|
202
|
+
* the High CPU Utilization alert template watches at 80 - and none yet for
|
|
203
|
+
* any other unit, whose scale only the person setting them knows. Asked
|
|
204
|
+
* for lower is worse, a percent column's are 20 and 10.
|
|
205
|
+
*/
|
|
206
|
+
const getTableThresholdPreset = (display, direction) => {
|
|
207
|
+
const presetDirection = (0, exports.readTableThresholdDirection)(direction);
|
|
208
|
+
if (!(0, exports.isTableColumnPercent)(display)) {
|
|
209
|
+
return { direction: presetDirection };
|
|
210
|
+
}
|
|
211
|
+
const preset = presetDirection === DashboardTableComponent_1.TableThresholdDirection.LowerIsWorse
|
|
212
|
+
? exports.TABLE_THRESHOLD_PERCENT_LOWER_IS_WORSE_PRESET
|
|
213
|
+
: exports.TABLE_THRESHOLD_PERCENT_PRESET;
|
|
214
|
+
return {
|
|
215
|
+
warning: preset.warning,
|
|
216
|
+
critical: preset.critical,
|
|
217
|
+
direction: presetDirection,
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
exports.getTableThresholdPreset = getTableThresholdPreset;
|
|
221
|
+
/*
|
|
222
|
+
* Whether a column's thresholds are still the preset of their own
|
|
223
|
+
* direction, as they were turned on: nothing typed over them. A column
|
|
224
|
+
* whose numbers someone typed - or cleared - is not.
|
|
225
|
+
*/
|
|
226
|
+
const isTableThresholdPreset = (data) => {
|
|
227
|
+
if (!data.thresholds) {
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
const stored = data.thresholds;
|
|
231
|
+
const preset = (0, exports.getTableThresholdPreset)(data.display, stored.direction);
|
|
232
|
+
return ((0, exports.readTableThresholdNumber)(stored.warning) === preset.warning &&
|
|
233
|
+
(0, exports.readTableThresholdNumber)(stored.critical) === preset.critical);
|
|
234
|
+
};
|
|
235
|
+
exports.isTableThresholdPreset = isTableThresholdPreset;
|
|
236
|
+
/*
|
|
237
|
+
* A number with its unit, as the table writes them: "93.00%", "12.5 ms".
|
|
238
|
+
* A percent, a degree or a per-mille sign follows the number with no space.
|
|
239
|
+
*/
|
|
240
|
+
const joinTableValueAndUnit = (formatted, unit) => {
|
|
241
|
+
if (!unit) {
|
|
242
|
+
return formatted;
|
|
243
|
+
}
|
|
244
|
+
const noSpace = unit === "%" || unit === "°" || unit === "‰";
|
|
245
|
+
return noSpace ? `${formatted}${unit}` : `${formatted} ${unit}`;
|
|
246
|
+
};
|
|
247
|
+
exports.joinTableValueAndUnit = joinTableValueAndUnit;
|
|
248
|
+
// A column's decimals as the table can write them: 0 to 20, whole.
|
|
249
|
+
const getSafeDecimals = (decimals) => {
|
|
250
|
+
if (!Number.isFinite(decimals)) {
|
|
251
|
+
return 0;
|
|
252
|
+
}
|
|
253
|
+
return Math.max(0, Math.min(20, Math.floor(decimals)));
|
|
254
|
+
};
|
|
255
|
+
/*
|
|
256
|
+
* A value rounded to the decimals its cell shows: what the cell writes, and
|
|
257
|
+
* what its thresholds are compared against. A threshold reads the number on
|
|
258
|
+
* screen - "80%" for 79.6 at no decimals is a warning at 80 - and a fraction
|
|
259
|
+
* shown as a percent loses the float noise of its x100 (0.29 x 100 is
|
|
260
|
+
* 28.999999999999996, shown and compared as 29).
|
|
261
|
+
*/
|
|
262
|
+
const roundTableValue = (value, decimals) => {
|
|
263
|
+
const factor = Math.pow(10, getSafeDecimals(decimals));
|
|
264
|
+
return Math.round(value * factor) / factor;
|
|
265
|
+
};
|
|
266
|
+
exports.roundTableValue = roundTableValue;
|
|
267
|
+
/*
|
|
268
|
+
* A cell's value as the table writes it: rounded to its decimals (never
|
|
269
|
+
* fewer than 0), grouped the browser's way, with its unit.
|
|
270
|
+
*/
|
|
271
|
+
const formatTableValue = (data) => {
|
|
272
|
+
const safeDecimals = getSafeDecimals(data.decimals);
|
|
273
|
+
const rounded = (0, exports.roundTableValue)(data.value, safeDecimals);
|
|
274
|
+
const formatted = rounded.toLocaleString(undefined, {
|
|
275
|
+
minimumFractionDigits: safeDecimals,
|
|
276
|
+
maximumFractionDigits: safeDecimals,
|
|
277
|
+
});
|
|
278
|
+
return (0, exports.joinTableValueAndUnit)(formatted, data.unit);
|
|
279
|
+
};
|
|
280
|
+
exports.formatTableValue = formatTableValue;
|
|
281
|
+
/*
|
|
282
|
+
* A threshold as the table writes it, in the column's unit: as typed, with
|
|
283
|
+
* no trailing zeros ("80%", "0.5 s", "99.95%"), grouped like the cells.
|
|
284
|
+
*/
|
|
285
|
+
const formatTableThreshold = (data) => {
|
|
286
|
+
return (0, exports.joinTableValueAndUnit)(data.threshold.toLocaleString(undefined, { maximumFractionDigits: 6 }), data.unit);
|
|
287
|
+
};
|
|
288
|
+
exports.formatTableThreshold = formatTableThreshold;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import commonJsModule from "./TableThresholds.js";
|
|
2
|
+
export const TABLE_THRESHOLD_PERCENT_LOWER_IS_WORSE_PRESET = commonJsModule.TABLE_THRESHOLD_PERCENT_LOWER_IS_WORSE_PRESET;
|
|
3
|
+
export const TABLE_THRESHOLD_PERCENT_PRESET = commonJsModule.TABLE_THRESHOLD_PERCENT_PRESET;
|
|
4
|
+
export const formatTableThreshold = commonJsModule.formatTableThreshold;
|
|
5
|
+
export const formatTableValue = commonJsModule.formatTableValue;
|
|
6
|
+
export const getTableColumnDisplay = commonJsModule.getTableColumnDisplay;
|
|
7
|
+
export const getTableThresholdLevel = commonJsModule.getTableThresholdLevel;
|
|
8
|
+
export const getTableThresholdPreset = commonJsModule.getTableThresholdPreset;
|
|
9
|
+
export const isTableColumnPercent = commonJsModule.isTableColumnPercent;
|
|
10
|
+
export const isTableThresholdOrderReversed = commonJsModule.isTableThresholdOrderReversed;
|
|
11
|
+
export const isTableThresholdPreset = commonJsModule.isTableThresholdPreset;
|
|
12
|
+
export const joinTableValueAndUnit = commonJsModule.joinTableValueAndUnit;
|
|
13
|
+
export const readTableColumnThresholds = commonJsModule.readTableColumnThresholds;
|
|
14
|
+
export const readTableThresholdDirection = commonJsModule.readTableThresholdDirection;
|
|
15
|
+
export const readTableThresholdNumber = commonJsModule.readTableThresholdNumber;
|
|
16
|
+
export const readTableThresholdStyle = commonJsModule.readTableThresholdStyle;
|
|
17
|
+
export const roundTableValue = commonJsModule.roundTableValue;
|
|
@@ -34,4 +34,10 @@ export interface GetValueWidgetTrendData {
|
|
|
34
34
|
windowEnd?: Date | undefined;
|
|
35
35
|
bucketWidthMs?: number | undefined;
|
|
36
36
|
}
|
|
37
|
+
export declare const VALUE_WIDGET_MAX_FILLED_POINTS: number;
|
|
38
|
+
export interface FillValueWidgetSeriesGapsData {
|
|
39
|
+
series: Array<ValueWidgetPoint>;
|
|
40
|
+
bucketWidthMs: number;
|
|
41
|
+
}
|
|
42
|
+
export declare const fillValueWidgetSeriesGaps: (data: FillValueWidgetSeriesGapsData) => Array<ValueWidgetPoint>;
|
|
37
43
|
export declare const getValueWidgetTrend: (data: GetValueWidgetTrendData) => ValueWidgetTrend | null;
|
|
@@ -34,4 +34,10 @@ export interface GetValueWidgetTrendData {
|
|
|
34
34
|
windowEnd?: Date | undefined;
|
|
35
35
|
bucketWidthMs?: number | undefined;
|
|
36
36
|
}
|
|
37
|
+
export declare const VALUE_WIDGET_MAX_FILLED_POINTS: number;
|
|
38
|
+
export interface FillValueWidgetSeriesGapsData {
|
|
39
|
+
series: Array<ValueWidgetPoint>;
|
|
40
|
+
bucketWidthMs: number;
|
|
41
|
+
}
|
|
42
|
+
export declare const fillValueWidgetSeriesGaps: (data: FillValueWidgetSeriesGapsData) => Array<ValueWidgetPoint>;
|
|
37
43
|
export declare const getValueWidgetTrend: (data: GetValueWidgetTrendData) => ValueWidgetTrend | null;
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* metric and Data Source hosts share one definition.
|
|
24
24
|
*/
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getValueWidgetTrend = exports.getValueWidgetBucketWidthMs = exports.getValueWidgetSeries = exports.getValueWidgetPointTime = exports.getMeanOfValues = exports.VALUE_WIDGET_FLAT_TREND_PERCENT = exports.ValueWidgetTrendDirection = void 0;
|
|
26
|
+
exports.getValueWidgetTrend = exports.fillValueWidgetSeriesGaps = exports.VALUE_WIDGET_MAX_FILLED_POINTS = exports.getValueWidgetBucketWidthMs = exports.getValueWidgetSeries = exports.getValueWidgetPointTime = exports.getMeanOfValues = exports.VALUE_WIDGET_FLAT_TREND_PERCENT = exports.ValueWidgetTrendDirection = void 0;
|
|
27
27
|
var ValueWidgetTrendDirection;
|
|
28
28
|
(function (ValueWidgetTrendDirection) {
|
|
29
29
|
ValueWidgetTrendDirection["Up"] = "Up";
|
|
@@ -149,6 +149,75 @@ exports.getValueWidgetBucketWidthMs = getValueWidgetBucketWidthMs;
|
|
|
149
149
|
const isUsableDate = (date) => {
|
|
150
150
|
return date instanceof Date && Number.isFinite(date.getTime());
|
|
151
151
|
};
|
|
152
|
+
/*
|
|
153
|
+
* The most points a filled sparkline draws. The metrics API buckets a window
|
|
154
|
+
* into a few hundred at most (AggregationIntervalUtil); a series spread
|
|
155
|
+
* wider than this was not bucketed the way the caller thinks, and is drawn
|
|
156
|
+
* as it came.
|
|
157
|
+
*/
|
|
158
|
+
exports.VALUE_WIDGET_MAX_FILLED_POINTS = 2000;
|
|
159
|
+
/*
|
|
160
|
+
* A sum's or a count's series with the empty buckets between its readings
|
|
161
|
+
* drawn as 0.
|
|
162
|
+
*
|
|
163
|
+
* The metrics API answers only the buckets that had a reading. A count of
|
|
164
|
+
* something that happens now and then - deploys, errors, sign-ups - comes
|
|
165
|
+
* back as a few buckets with hours between them, and a line through just
|
|
166
|
+
* those read flat ("4, then 4, then 4") while the arrow beside it, which
|
|
167
|
+
* compares totals per half of the range, said the count rose. For a sum or
|
|
168
|
+
* a count, a bucket with no reading counts nothing: it is a real 0. So each
|
|
169
|
+
* empty bucket between the first reading and the last is drawn at 0, and
|
|
170
|
+
* the spikes show as spikes.
|
|
171
|
+
*
|
|
172
|
+
* Only between readings: the newest bucket is often empty only because its
|
|
173
|
+
* readings have not landed yet, and a line that dropped to 0 at its right
|
|
174
|
+
* end on every refresh would read as an outage. Before the first reading
|
|
175
|
+
* there may be no metric yet at all. And only for a sum or a count: an
|
|
176
|
+
* average or a percentile of no readings is not 0 but unknown, and keeps
|
|
177
|
+
* its gaps. Nothing is filled when
|
|
178
|
+
*
|
|
179
|
+
* - a point does not sit on the bucket grid the caller names (a calendar
|
|
180
|
+
* month or year is not a fixed width, and a widget bucketed some other
|
|
181
|
+
* way must not get zeros between its real points);
|
|
182
|
+
* - the readings span more buckets than VALUE_WIDGET_MAX_FILLED_POINTS.
|
|
183
|
+
*/
|
|
184
|
+
const fillValueWidgetSeriesGaps = (data) => {
|
|
185
|
+
var _a;
|
|
186
|
+
const series = data.series;
|
|
187
|
+
const widthMs = data.bucketWidthMs;
|
|
188
|
+
if (series.length < 2 || !Number.isFinite(widthMs) || widthMs <= 0) {
|
|
189
|
+
return series;
|
|
190
|
+
}
|
|
191
|
+
const firstMs = series[0].timestamp.getTime();
|
|
192
|
+
const lastMs = series[series.length - 1].timestamp.getTime();
|
|
193
|
+
const valuesByTime = new Map();
|
|
194
|
+
for (const point of series) {
|
|
195
|
+
const timeMs = point.timestamp.getTime();
|
|
196
|
+
if ((timeMs - firstMs) % widthMs !== 0) {
|
|
197
|
+
return series;
|
|
198
|
+
}
|
|
199
|
+
valuesByTime.set(timeMs, point.value);
|
|
200
|
+
}
|
|
201
|
+
const slotCount = (lastMs - firstMs) / widthMs + 1;
|
|
202
|
+
if (!Number.isFinite(slotCount) ||
|
|
203
|
+
slotCount > exports.VALUE_WIDGET_MAX_FILLED_POINTS) {
|
|
204
|
+
return series;
|
|
205
|
+
}
|
|
206
|
+
if (slotCount === series.length) {
|
|
207
|
+
// No bucket between the readings is empty.
|
|
208
|
+
return series;
|
|
209
|
+
}
|
|
210
|
+
const filled = [];
|
|
211
|
+
for (let slot = 0; slot < slotCount; slot++) {
|
|
212
|
+
const slotMs = firstMs + slot * widthMs;
|
|
213
|
+
filled.push({
|
|
214
|
+
timestamp: new Date(slotMs),
|
|
215
|
+
value: (_a = valuesByTime.get(slotMs)) !== null && _a !== void 0 ? _a : 0,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
return filled;
|
|
219
|
+
};
|
|
220
|
+
exports.fillValueWidgetSeriesGaps = fillValueWidgetSeriesGaps;
|
|
152
221
|
/*
|
|
153
222
|
* How the widget's number moved across the time range: the second half of
|
|
154
223
|
* the range against the first, each reduced the way the widget reduces the
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import commonJsModule from "./ValueWidgetSeries.js";
|
|
2
2
|
export const VALUE_WIDGET_FLAT_TREND_PERCENT = commonJsModule.VALUE_WIDGET_FLAT_TREND_PERCENT;
|
|
3
|
+
export const VALUE_WIDGET_MAX_FILLED_POINTS = commonJsModule.VALUE_WIDGET_MAX_FILLED_POINTS;
|
|
3
4
|
export const ValueWidgetTrendDirection = commonJsModule.ValueWidgetTrendDirection;
|
|
5
|
+
export const fillValueWidgetSeriesGaps = commonJsModule.fillValueWidgetSeriesGaps;
|
|
4
6
|
export const getMeanOfValues = commonJsModule.getMeanOfValues;
|
|
5
7
|
export const getValueWidgetBucketWidthMs = commonJsModule.getValueWidgetBucketWidthMs;
|
|
6
8
|
export const getValueWidgetPointTime = commonJsModule.getValueWidgetPointTime;
|
|
@@ -1407,6 +1407,22 @@ exports.DEVELOPER_DOCS_PROFILES = {
|
|
|
1407
1407
|
"labels",
|
|
1408
1408
|
],
|
|
1409
1409
|
},
|
|
1410
|
+
/*
|
|
1411
|
+
* Its provider (aws, azure or gcp) is named like Terraform's own
|
|
1412
|
+
* provider meta-argument, so Terraform cannot set it: an account is
|
|
1413
|
+
* added by its connection, or with the API, and Terraform manages the
|
|
1414
|
+
* ones there are.
|
|
1415
|
+
*/
|
|
1416
|
+
CloudAccount: {
|
|
1417
|
+
createNote: "Cloud accounts are added when a cloud connection first reads them. Create one only to name and label it before it is connected: its provider is aws, azure or gcp.",
|
|
1418
|
+
terraformCannotCreate: "A cloud connection adds an account the first time it reads it, and Terraform cannot set an account's provider, a name Terraform keeps for itself. Terraform can still manage the accounts you have: bring them in below.",
|
|
1419
|
+
fields: [
|
|
1420
|
+
field("name", literal("Production")),
|
|
1421
|
+
field("accountId", literal("123456789012"), "Its id in that cloud: an AWS account, an Azure subscription or a Google Cloud project."),
|
|
1422
|
+
field("description", literal("The checkout stack's production account.")),
|
|
1423
|
+
"labels",
|
|
1424
|
+
],
|
|
1425
|
+
},
|
|
1410
1426
|
NetworkDevice: {
|
|
1411
1427
|
fields: [
|
|
1412
1428
|
field("name", literal("core-switch-1")),
|
|
@@ -51,5 +51,6 @@ export declare function getTerraformTypeName(modelType: DatabaseBaseModelType):
|
|
|
51
51
|
export declare function isServerManagedColumn(tableName: string, columnName: string): boolean;
|
|
52
52
|
export declare function getTerraformAttributes(modelType: DatabaseBaseModelType): Array<TerraformAttributeDescriptor>;
|
|
53
53
|
export declare function getTerraformAttribute(modelType: DatabaseBaseModelType, columnName: string): TerraformAttributeDescriptor | undefined;
|
|
54
|
+
export declare function getColumnsRequiredOnCreate(modelType: DatabaseBaseModelType): Array<string>;
|
|
54
55
|
export declare function canLookUpByName(modelType: DatabaseBaseModelType): boolean;
|
|
55
56
|
export declare function getNameColumn(modelType: DatabaseBaseModelType): string | null;
|
|
@@ -51,5 +51,6 @@ export declare function getTerraformTypeName(modelType: DatabaseBaseModelType):
|
|
|
51
51
|
export declare function isServerManagedColumn(tableName: string, columnName: string): boolean;
|
|
52
52
|
export declare function getTerraformAttributes(modelType: DatabaseBaseModelType): Array<TerraformAttributeDescriptor>;
|
|
53
53
|
export declare function getTerraformAttribute(modelType: DatabaseBaseModelType, columnName: string): TerraformAttributeDescriptor | undefined;
|
|
54
|
+
export declare function getColumnsRequiredOnCreate(modelType: DatabaseBaseModelType): Array<string>;
|
|
54
55
|
export declare function canLookUpByName(modelType: DatabaseBaseModelType): boolean;
|
|
55
56
|
export declare function getNameColumn(modelType: DatabaseBaseModelType): string | null;
|