@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
|
@@ -0,0 +1,292 @@
|
|
|
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.MAX_AI_AFFECTED_RESOURCES = exports.AI_RESOURCE_TYPES_NOT_LINKABLE = exports.AI_AFFECTED_RESOURCE_KINDS = exports.AiAffectedResourceKind = void 0;
|
|
7
|
+
exports.getAiAffectedResourceKindInfo = getAiAffectedResourceKindInfo;
|
|
8
|
+
exports.isAiAffectedResourceKind = isAiAffectedResourceKind;
|
|
9
|
+
exports.readAiAffectedResourceKind = readAiAffectedResourceKind;
|
|
10
|
+
exports.getPageAffectedResource = getPageAffectedResource;
|
|
11
|
+
exports.readAiAffectedResourceArgument = readAiAffectedResourceArgument;
|
|
12
|
+
const AIChatPageContext_1 = __importDefault(require("./AIChatPageContext"));
|
|
13
|
+
const AIResourceContext_1 = require("./AIResourceContext");
|
|
14
|
+
/*
|
|
15
|
+
* WHAT ONEUPTIME AI LINKS AN INCIDENT OR ALERT TO.
|
|
16
|
+
*
|
|
17
|
+
* Issue #5293: on a host's page, Ask AI declared an incident ("high memory
|
|
18
|
+
* usage") and the incident was linked to nothing. Its investigation never
|
|
19
|
+
* reached the host, and auto-remediation said "This incident is not linked
|
|
20
|
+
* to a Kubernetes cluster or an infrastructure resource, so OneUptime AI had
|
|
21
|
+
* nothing it could fix", although the conversation was about that host from
|
|
22
|
+
* its first word. create_incident took a title, a description and a
|
|
23
|
+
* severity, and nothing else.
|
|
24
|
+
*
|
|
25
|
+
* The resources an incident or alert is linked to are what everything after
|
|
26
|
+
* its creation reads: its investigation reaches them through their AI
|
|
27
|
+
* agents, auto-remediation fixes them, their owners and labels pass on to
|
|
28
|
+
* it, and their pages list it. So OneUptime AI links what it declares:
|
|
29
|
+
*
|
|
30
|
+
* - declared from a resource's page (a host, a cluster, a database, a
|
|
31
|
+
* service, ...), the incident is linked to that resource, as Declare
|
|
32
|
+
* Incident on the resource's own Incidents tab links it
|
|
33
|
+
* (CreateFromRecord);
|
|
34
|
+
* - and to the resources the model names (affectedResources), found with
|
|
35
|
+
* the person's own reads - query_telemetry_resources, lookup_context.
|
|
36
|
+
*
|
|
37
|
+
* This module is the vocabulary both use: the kinds of resource that can be
|
|
38
|
+
* linked, the incident's and the alert's list each one goes in (the two
|
|
39
|
+
* models declare the same lists), how a tool argument names them, and the
|
|
40
|
+
* resource a page is about. React-free and server-free, so the dashboard
|
|
41
|
+
* and any test read the same rules.
|
|
42
|
+
*
|
|
43
|
+
* Monitors are deliberately not here. A monitor linked to an incident a
|
|
44
|
+
* person declares stops its own checks until the incident is resolved
|
|
45
|
+
* (IncidentService.disableActiveMonitoringIfManualIncident), so linking
|
|
46
|
+
* one is the person's choice on the Declare Incident form, never a side
|
|
47
|
+
* effect of a conversation.
|
|
48
|
+
*/
|
|
49
|
+
// The kinds of resource OneUptime AI may link an incident or alert to.
|
|
50
|
+
var AiAffectedResourceKind;
|
|
51
|
+
(function (AiAffectedResourceKind) {
|
|
52
|
+
AiAffectedResourceKind["Host"] = "Host";
|
|
53
|
+
AiAffectedResourceKind["DockerHost"] = "DockerHost";
|
|
54
|
+
AiAffectedResourceKind["PodmanHost"] = "PodmanHost";
|
|
55
|
+
AiAffectedResourceKind["KubernetesCluster"] = "KubernetesCluster";
|
|
56
|
+
AiAffectedResourceKind["DockerSwarmCluster"] = "DockerSwarmCluster";
|
|
57
|
+
AiAffectedResourceKind["ProxmoxCluster"] = "ProxmoxCluster";
|
|
58
|
+
AiAffectedResourceKind["VMwareVCenter"] = "VMwareVCenter";
|
|
59
|
+
AiAffectedResourceKind["CephCluster"] = "CephCluster";
|
|
60
|
+
AiAffectedResourceKind["StorageArray"] = "StorageArray";
|
|
61
|
+
AiAffectedResourceKind["IoTFleet"] = "IoTFleet";
|
|
62
|
+
AiAffectedResourceKind["DatabaseServer"] = "DatabaseServer";
|
|
63
|
+
// A resource a cloud connection lists (an AWS, Azure or Google Cloud one).
|
|
64
|
+
AiAffectedResourceKind["CloudResource"] = "CloudResource";
|
|
65
|
+
// A telemetry service (lookup_context's services).
|
|
66
|
+
AiAffectedResourceKind["Service"] = "Service";
|
|
67
|
+
})(AiAffectedResourceKind || (exports.AiAffectedResourceKind = AiAffectedResourceKind = {}));
|
|
68
|
+
/*
|
|
69
|
+
* Every kind, in the order the incident's Affected Resources card lists
|
|
70
|
+
* them (AffectedResourceNames), each with the list it goes in.
|
|
71
|
+
*/
|
|
72
|
+
exports.AI_AFFECTED_RESOURCE_KINDS = [
|
|
73
|
+
{
|
|
74
|
+
kind: AiAffectedResourceKind.Host,
|
|
75
|
+
relation: "hosts",
|
|
76
|
+
noun: "host",
|
|
77
|
+
isFixedByOneUptimeAi: true,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
kind: AiAffectedResourceKind.KubernetesCluster,
|
|
81
|
+
relation: "kubernetesClusters",
|
|
82
|
+
noun: "Kubernetes cluster",
|
|
83
|
+
isFixedByOneUptimeAi: true,
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
kind: AiAffectedResourceKind.DockerHost,
|
|
87
|
+
relation: "dockerHosts",
|
|
88
|
+
noun: "Docker host",
|
|
89
|
+
isFixedByOneUptimeAi: true,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
kind: AiAffectedResourceKind.PodmanHost,
|
|
93
|
+
relation: "podmanHosts",
|
|
94
|
+
noun: "Podman host",
|
|
95
|
+
isFixedByOneUptimeAi: true,
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
kind: AiAffectedResourceKind.ProxmoxCluster,
|
|
99
|
+
relation: "proxmoxClusters",
|
|
100
|
+
noun: "Proxmox cluster",
|
|
101
|
+
isFixedByOneUptimeAi: true,
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
kind: AiAffectedResourceKind.VMwareVCenter,
|
|
105
|
+
relation: "vmwareVCenters",
|
|
106
|
+
noun: "VMware vCenter",
|
|
107
|
+
isFixedByOneUptimeAi: true,
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
kind: AiAffectedResourceKind.CephCluster,
|
|
111
|
+
relation: "cephClusters",
|
|
112
|
+
noun: "Ceph cluster",
|
|
113
|
+
isFixedByOneUptimeAi: true,
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
kind: AiAffectedResourceKind.StorageArray,
|
|
117
|
+
relation: "storageArrays",
|
|
118
|
+
noun: "storage array",
|
|
119
|
+
isFixedByOneUptimeAi: false,
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
kind: AiAffectedResourceKind.DockerSwarmCluster,
|
|
123
|
+
relation: "dockerSwarmClusters",
|
|
124
|
+
noun: "Docker Swarm cluster",
|
|
125
|
+
isFixedByOneUptimeAi: true,
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
kind: AiAffectedResourceKind.IoTFleet,
|
|
129
|
+
relation: "iotFleets",
|
|
130
|
+
noun: "IoT fleet",
|
|
131
|
+
isFixedByOneUptimeAi: false,
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
kind: AiAffectedResourceKind.DatabaseServer,
|
|
135
|
+
relation: "databaseServers",
|
|
136
|
+
noun: "database server",
|
|
137
|
+
isFixedByOneUptimeAi: true,
|
|
138
|
+
},
|
|
139
|
+
/*
|
|
140
|
+
* Linked for its changes, its metrics and its page's Incidents tab: no
|
|
141
|
+
* AI agent acts on a cloud account yet.
|
|
142
|
+
*/
|
|
143
|
+
{
|
|
144
|
+
kind: AiAffectedResourceKind.CloudResource,
|
|
145
|
+
relation: "cloudResources",
|
|
146
|
+
noun: "cloud resource",
|
|
147
|
+
isFixedByOneUptimeAi: false,
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
kind: AiAffectedResourceKind.Service,
|
|
151
|
+
relation: "services",
|
|
152
|
+
noun: "service",
|
|
153
|
+
isFixedByOneUptimeAi: false,
|
|
154
|
+
},
|
|
155
|
+
];
|
|
156
|
+
/*
|
|
157
|
+
* The resource pages Ask AI opens on whose resource an incident or alert
|
|
158
|
+
* cannot be linked to yet - it has no list of them - and so is never linked
|
|
159
|
+
* from there. Each says why; the model is told the same, and
|
|
160
|
+
* Tests/Types/AI/AiAffectedResources.test.ts holds every other page's
|
|
161
|
+
* resource to a list of both models. A model that gains the list moves its
|
|
162
|
+
* kind above.
|
|
163
|
+
*/
|
|
164
|
+
exports.AI_RESOURCE_TYPES_NOT_LINKABLE = {
|
|
165
|
+
[AIResourceContext_1.AIResourceType.ServerlessFunction]: "An incident or alert has no list of serverless functions.",
|
|
166
|
+
[AIResourceContext_1.AIResourceType.NetworkDevice]: "An incident or alert has no list of network devices.",
|
|
167
|
+
};
|
|
168
|
+
// The most resources one call links: the most an investigation reaches.
|
|
169
|
+
exports.MAX_AI_AFFECTED_RESOURCES = 10;
|
|
170
|
+
const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
171
|
+
function getAiAffectedResourceKindInfo(kind) {
|
|
172
|
+
const info = exports.AI_AFFECTED_RESOURCE_KINDS.find((item) => {
|
|
173
|
+
return item.kind === kind;
|
|
174
|
+
});
|
|
175
|
+
if (!info) {
|
|
176
|
+
throw new Error(`Unknown kind of affected resource: ${kind}`);
|
|
177
|
+
}
|
|
178
|
+
return info;
|
|
179
|
+
}
|
|
180
|
+
function isAiAffectedResourceKind(value) {
|
|
181
|
+
return exports.AI_AFFECTED_RESOURCE_KINDS.some((item) => {
|
|
182
|
+
return item.kind === value;
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
/*
|
|
186
|
+
* A kind as a model may spell it - "host", "kubernetescluster",
|
|
187
|
+
* "TelemetryService" - or undefined for anything else. Matched without
|
|
188
|
+
* regard to case, spaces, "-" or "_", since the value comes from a model.
|
|
189
|
+
*/
|
|
190
|
+
function readAiAffectedResourceKind(value) {
|
|
191
|
+
if (typeof value !== "string") {
|
|
192
|
+
return undefined;
|
|
193
|
+
}
|
|
194
|
+
let spelled = "";
|
|
195
|
+
for (const character of value) {
|
|
196
|
+
if (character === " " || character === "-" || character === "_") {
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
spelled += character.toLowerCase();
|
|
200
|
+
}
|
|
201
|
+
if (spelled === "telemetryservice") {
|
|
202
|
+
return AiAffectedResourceKind.Service;
|
|
203
|
+
}
|
|
204
|
+
const info = exports.AI_AFFECTED_RESOURCE_KINDS.find((item) => {
|
|
205
|
+
return item.kind.toLowerCase() === spelled;
|
|
206
|
+
});
|
|
207
|
+
return info === null || info === void 0 ? void 0 : info.kind;
|
|
208
|
+
}
|
|
209
|
+
/*
|
|
210
|
+
* The resource of the page Ask AI was asked from, when an incident or alert
|
|
211
|
+
* can be linked to it: a resource's page (or one of its child pages - a
|
|
212
|
+
* pod's page is about its cluster) or a telemetry service's page. Null for
|
|
213
|
+
* every other page, and for a resource whose kind cannot be linked.
|
|
214
|
+
*/
|
|
215
|
+
function getPageAffectedResource(pageContext) {
|
|
216
|
+
if (!(pageContext === null || pageContext === void 0 ? void 0 : pageContext.entityId) || !UUID_PATTERN.test(pageContext.entityId)) {
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
const id = pageContext.entityId.toLowerCase();
|
|
220
|
+
if (pageContext.type === AIChatPageContext_1.default.TelemetryService) {
|
|
221
|
+
return { kind: AiAffectedResourceKind.Service, id };
|
|
222
|
+
}
|
|
223
|
+
if (pageContext.type === AIChatPageContext_1.default.Resource &&
|
|
224
|
+
isAiAffectedResourceKind(pageContext.resourceType)) {
|
|
225
|
+
return {
|
|
226
|
+
kind: pageContext.resourceType,
|
|
227
|
+
id,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
/*
|
|
233
|
+
* A tool's affectedResources argument: a list of { resourceType,
|
|
234
|
+
* resourceId }. Undefined when the call left the argument out - the tool
|
|
235
|
+
* then decides (create_incident links the page's resource) - and a list,
|
|
236
|
+
* possibly empty, when it named one: an empty list links nothing. Entries
|
|
237
|
+
* that name no kind, or no UUID, are left out with a problem each;
|
|
238
|
+
* repeated entries are kept once; past MAX_AI_AFFECTED_RESOURCES the rest
|
|
239
|
+
* are left out, and the problem says how many.
|
|
240
|
+
*/
|
|
241
|
+
function readAiAffectedResourceArgument(value) {
|
|
242
|
+
var _a;
|
|
243
|
+
if (value === undefined || value === null) {
|
|
244
|
+
return undefined;
|
|
245
|
+
}
|
|
246
|
+
if (!Array.isArray(value)) {
|
|
247
|
+
return {
|
|
248
|
+
refs: [],
|
|
249
|
+
problems: [
|
|
250
|
+
"affectedResources must be a list of { resourceType, resourceId }.",
|
|
251
|
+
],
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
const refs = [];
|
|
255
|
+
const problems = [];
|
|
256
|
+
const seen = new Set();
|
|
257
|
+
let leftOverCap = 0;
|
|
258
|
+
for (const item of value) {
|
|
259
|
+
if (!item || typeof item !== "object" || Array.isArray(item)) {
|
|
260
|
+
problems.push("An entry of affectedResources is not a { resourceType, resourceId } object.");
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
const entry = item;
|
|
264
|
+
const kind = readAiAffectedResourceKind(entry["resourceType"]);
|
|
265
|
+
const rawId = entry["resourceId"];
|
|
266
|
+
const id = typeof rawId === "string" ? rawId.trim() : "";
|
|
267
|
+
if (!kind) {
|
|
268
|
+
problems.push(`resourceType ${JSON.stringify((_a = entry["resourceType"]) !== null && _a !== void 0 ? _a : null).substring(0, 60)} cannot be linked. Use one of: ${exports.AI_AFFECTED_RESOURCE_KINDS.map((info) => {
|
|
269
|
+
return info.kind;
|
|
270
|
+
}).join(", ")}.`);
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
if (!UUID_PATTERN.test(id)) {
|
|
274
|
+
problems.push(`resourceId of a ${getAiAffectedResourceKindInfo(kind).noun} must be its OneUptime ID (a UUID).`);
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
const key = `${kind}:${id.toLowerCase()}`;
|
|
278
|
+
if (seen.has(key)) {
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
seen.add(key);
|
|
282
|
+
if (refs.length >= exports.MAX_AI_AFFECTED_RESOURCES) {
|
|
283
|
+
leftOverCap++;
|
|
284
|
+
continue;
|
|
285
|
+
}
|
|
286
|
+
refs.push({ kind, id: id.toLowerCase() });
|
|
287
|
+
}
|
|
288
|
+
if (leftOverCap > 0) {
|
|
289
|
+
problems.push(`Only ${exports.MAX_AI_AFFECTED_RESOURCES} resources are linked at once; ${leftOverCap} more were left out.`);
|
|
290
|
+
}
|
|
291
|
+
return { refs, problems };
|
|
292
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import commonJsModule from "./AiAffectedResources.js";
|
|
2
|
+
export const AI_AFFECTED_RESOURCE_KINDS = commonJsModule.AI_AFFECTED_RESOURCE_KINDS;
|
|
3
|
+
export const AI_RESOURCE_TYPES_NOT_LINKABLE = commonJsModule.AI_RESOURCE_TYPES_NOT_LINKABLE;
|
|
4
|
+
export const AiAffectedResourceKind = commonJsModule.AiAffectedResourceKind;
|
|
5
|
+
export const MAX_AI_AFFECTED_RESOURCES = commonJsModule.MAX_AI_AFFECTED_RESOURCES;
|
|
6
|
+
export const getAiAffectedResourceKindInfo = commonJsModule.getAiAffectedResourceKindInfo;
|
|
7
|
+
export const getPageAffectedResource = commonJsModule.getPageAffectedResource;
|
|
8
|
+
export const isAiAffectedResourceKind = commonJsModule.isAiAffectedResourceKind;
|
|
9
|
+
export const readAiAffectedResourceArgument = commonJsModule.readAiAffectedResourceArgument;
|
|
10
|
+
export const readAiAffectedResourceKind = commonJsModule.readAiAffectedResourceKind;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface CloudAccountTypeCount {
|
|
2
|
+
type: string;
|
|
3
|
+
count: number;
|
|
4
|
+
}
|
|
5
|
+
export interface CloudAccountRegionCount {
|
|
6
|
+
region: string;
|
|
7
|
+
count: number;
|
|
8
|
+
}
|
|
9
|
+
export interface CloudAccountResourceSummary {
|
|
10
|
+
resourceCount: number;
|
|
11
|
+
types: Array<CloudAccountTypeCount>;
|
|
12
|
+
regions: Array<CloudAccountRegionCount>;
|
|
13
|
+
}
|
|
14
|
+
export declare const CLOUD_ACCOUNT_SUMMARY_MAX_ENTRIES: number;
|
|
15
|
+
export declare function summarizeCloudAccountResources(resources: Array<{
|
|
16
|
+
type: string;
|
|
17
|
+
region: string;
|
|
18
|
+
}>): CloudAccountResourceSummary;
|
|
19
|
+
export interface CloudAccountResourceCount {
|
|
20
|
+
type: string;
|
|
21
|
+
region: string;
|
|
22
|
+
count: number;
|
|
23
|
+
}
|
|
24
|
+
export declare function summarizeCloudAccountResourceCounts(counts: Array<CloudAccountResourceCount>): CloudAccountResourceSummary;
|
|
25
|
+
export declare function readCloudAccountResourceSummary(value: unknown): CloudAccountResourceSummary;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface CloudAccountTypeCount {
|
|
2
|
+
type: string;
|
|
3
|
+
count: number;
|
|
4
|
+
}
|
|
5
|
+
export interface CloudAccountRegionCount {
|
|
6
|
+
region: string;
|
|
7
|
+
count: number;
|
|
8
|
+
}
|
|
9
|
+
export interface CloudAccountResourceSummary {
|
|
10
|
+
resourceCount: number;
|
|
11
|
+
types: Array<CloudAccountTypeCount>;
|
|
12
|
+
regions: Array<CloudAccountRegionCount>;
|
|
13
|
+
}
|
|
14
|
+
export declare const CLOUD_ACCOUNT_SUMMARY_MAX_ENTRIES: number;
|
|
15
|
+
export declare function summarizeCloudAccountResources(resources: Array<{
|
|
16
|
+
type: string;
|
|
17
|
+
region: string;
|
|
18
|
+
}>): CloudAccountResourceSummary;
|
|
19
|
+
export interface CloudAccountResourceCount {
|
|
20
|
+
type: string;
|
|
21
|
+
region: string;
|
|
22
|
+
count: number;
|
|
23
|
+
}
|
|
24
|
+
export declare function summarizeCloudAccountResourceCounts(counts: Array<CloudAccountResourceCount>): CloudAccountResourceSummary;
|
|
25
|
+
export declare function readCloudAccountResourceSummary(value: unknown): CloudAccountResourceSummary;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* A cloud account's resources at a glance (CloudAccount.resourceSummary):
|
|
4
|
+
* how many it has, by type and by region, most first. Written by the
|
|
5
|
+
* server whenever the account's resources change, read by its pages.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.CLOUD_ACCOUNT_SUMMARY_MAX_ENTRIES = void 0;
|
|
9
|
+
exports.summarizeCloudAccountResources = summarizeCloudAccountResources;
|
|
10
|
+
exports.summarizeCloudAccountResourceCounts = summarizeCloudAccountResourceCounts;
|
|
11
|
+
exports.readCloudAccountResourceSummary = readCloudAccountResourceSummary;
|
|
12
|
+
// The most entries of each list kept: the rest are counted, not named.
|
|
13
|
+
exports.CLOUD_ACCOUNT_SUMMARY_MAX_ENTRIES = 50;
|
|
14
|
+
function summarizeCloudAccountResources(resources) {
|
|
15
|
+
return summarizeCloudAccountResourceCounts(resources.map((resource) => {
|
|
16
|
+
return { type: resource.type, region: resource.region, count: 1 };
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
/*
|
|
20
|
+
* The summary from counts by type and Region (CloudAccountService counts
|
|
21
|
+
* them in the database, so an account of any size is one small read).
|
|
22
|
+
*/
|
|
23
|
+
function summarizeCloudAccountResourceCounts(counts) {
|
|
24
|
+
const byType = new Map();
|
|
25
|
+
const byRegion = new Map();
|
|
26
|
+
let total = 0;
|
|
27
|
+
for (const entry of counts) {
|
|
28
|
+
const count = Number.isFinite(entry.count) && entry.count > 0
|
|
29
|
+
? Math.floor(entry.count)
|
|
30
|
+
: 0;
|
|
31
|
+
if (count === 0) {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
total += count;
|
|
35
|
+
const type = entry.type.trim();
|
|
36
|
+
const region = entry.region.trim();
|
|
37
|
+
if (type) {
|
|
38
|
+
byType.set(type, (byType.get(type) || 0) + count);
|
|
39
|
+
}
|
|
40
|
+
if (region) {
|
|
41
|
+
byRegion.set(region, (byRegion.get(region) || 0) + count);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
resourceCount: total,
|
|
46
|
+
types: sortCounts(byType)
|
|
47
|
+
.slice(0, exports.CLOUD_ACCOUNT_SUMMARY_MAX_ENTRIES)
|
|
48
|
+
.map((entry) => {
|
|
49
|
+
return { type: entry.value, count: entry.count };
|
|
50
|
+
}),
|
|
51
|
+
regions: sortCounts(byRegion)
|
|
52
|
+
.slice(0, exports.CLOUD_ACCOUNT_SUMMARY_MAX_ENTRIES)
|
|
53
|
+
.map((entry) => {
|
|
54
|
+
return { region: entry.value, count: entry.count };
|
|
55
|
+
}),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function sortCounts(counts) {
|
|
59
|
+
return Array.from(counts.entries())
|
|
60
|
+
.map(([value, count]) => {
|
|
61
|
+
return { value, count };
|
|
62
|
+
})
|
|
63
|
+
.sort((a, b) => {
|
|
64
|
+
return b.count - a.count || a.value.localeCompare(b.value);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
// A stored summary, read back: anything malformed reads as empty.
|
|
68
|
+
function readCloudAccountResourceSummary(value) {
|
|
69
|
+
const empty = {
|
|
70
|
+
resourceCount: 0,
|
|
71
|
+
types: [],
|
|
72
|
+
regions: [],
|
|
73
|
+
};
|
|
74
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
75
|
+
return empty;
|
|
76
|
+
}
|
|
77
|
+
const record = value;
|
|
78
|
+
const count = Number(record["resourceCount"]);
|
|
79
|
+
const types = Array.isArray(record["types"])
|
|
80
|
+
? record["types"]
|
|
81
|
+
.map((entry) => {
|
|
82
|
+
const item = entry && typeof entry === "object"
|
|
83
|
+
? entry
|
|
84
|
+
: {};
|
|
85
|
+
return typeof item["type"] === "string" &&
|
|
86
|
+
Number.isFinite(Number(item["count"]))
|
|
87
|
+
? { type: item["type"], count: Number(item["count"]) }
|
|
88
|
+
: null;
|
|
89
|
+
})
|
|
90
|
+
.filter((entry) => {
|
|
91
|
+
return entry !== null;
|
|
92
|
+
})
|
|
93
|
+
: [];
|
|
94
|
+
const regions = Array.isArray(record["regions"])
|
|
95
|
+
? record["regions"]
|
|
96
|
+
.map((entry) => {
|
|
97
|
+
const item = entry && typeof entry === "object"
|
|
98
|
+
? entry
|
|
99
|
+
: {};
|
|
100
|
+
return typeof item["region"] === "string" &&
|
|
101
|
+
Number.isFinite(Number(item["count"]))
|
|
102
|
+
? { region: item["region"], count: Number(item["count"]) }
|
|
103
|
+
: null;
|
|
104
|
+
})
|
|
105
|
+
.filter((entry) => {
|
|
106
|
+
return entry !== null;
|
|
107
|
+
})
|
|
108
|
+
: [];
|
|
109
|
+
return {
|
|
110
|
+
resourceCount: Number.isFinite(count) && count > 0 ? count : 0,
|
|
111
|
+
types,
|
|
112
|
+
regions,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import commonJsModule from "./CloudAccountSummary.js";
|
|
2
|
+
export const CLOUD_ACCOUNT_SUMMARY_MAX_ENTRIES = commonJsModule.CLOUD_ACCOUNT_SUMMARY_MAX_ENTRIES;
|
|
3
|
+
export const readCloudAccountResourceSummary = commonJsModule.readCloudAccountResourceSummary;
|
|
4
|
+
export const summarizeCloudAccountResourceCounts = commonJsModule.summarizeCloudAccountResourceCounts;
|
|
5
|
+
export const summarizeCloudAccountResources = commonJsModule.summarizeCloudAccountResources;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const CLOUD_ENDPOINT_MAX_MONITOR_HOSTS: number;
|
|
2
|
+
export interface CloudEndpointName {
|
|
3
|
+
name: string;
|
|
4
|
+
via: string;
|
|
5
|
+
}
|
|
6
|
+
export interface CloudEndpointCandidate {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
type: string;
|
|
10
|
+
provider: string;
|
|
11
|
+
endpoints: unknown;
|
|
12
|
+
}
|
|
13
|
+
export interface CloudEndpointSuggestion {
|
|
14
|
+
cloudResourceId: string;
|
|
15
|
+
name: string;
|
|
16
|
+
type: string;
|
|
17
|
+
provider: string;
|
|
18
|
+
endpoint: string;
|
|
19
|
+
via: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function getCloudEndpointComparisonNames(name: string): Array<string>;
|
|
22
|
+
export declare function getMonitorDestinationHosts(monitorSteps: unknown): Array<string>;
|
|
23
|
+
export declare function matchCloudEndpoints(data: {
|
|
24
|
+
names: Array<CloudEndpointName>;
|
|
25
|
+
candidates: Array<CloudEndpointCandidate>;
|
|
26
|
+
}): Array<CloudEndpointSuggestion>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const CLOUD_ENDPOINT_MAX_MONITOR_HOSTS: number;
|
|
2
|
+
export interface CloudEndpointName {
|
|
3
|
+
name: string;
|
|
4
|
+
via: string;
|
|
5
|
+
}
|
|
6
|
+
export interface CloudEndpointCandidate {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
type: string;
|
|
10
|
+
provider: string;
|
|
11
|
+
endpoints: unknown;
|
|
12
|
+
}
|
|
13
|
+
export interface CloudEndpointSuggestion {
|
|
14
|
+
cloudResourceId: string;
|
|
15
|
+
name: string;
|
|
16
|
+
type: string;
|
|
17
|
+
provider: string;
|
|
18
|
+
endpoint: string;
|
|
19
|
+
via: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function getCloudEndpointComparisonNames(name: string): Array<string>;
|
|
22
|
+
export declare function getMonitorDestinationHosts(monitorSteps: unknown): Array<string>;
|
|
23
|
+
export declare function matchCloudEndpoints(data: {
|
|
24
|
+
names: Array<CloudEndpointName>;
|
|
25
|
+
candidates: Array<CloudEndpointCandidate>;
|
|
26
|
+
}): Array<CloudEndpointSuggestion>;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CLOUD_ENDPOINT_MAX_MONITOR_HOSTS = void 0;
|
|
4
|
+
exports.getCloudEndpointComparisonNames = getCloudEndpointComparisonNames;
|
|
5
|
+
exports.getMonitorDestinationHosts = getMonitorDestinationHosts;
|
|
6
|
+
exports.matchCloudEndpoints = matchCloudEndpoints;
|
|
7
|
+
const CloudInventory_1 = require("./CloudInventory");
|
|
8
|
+
/*
|
|
9
|
+
* WHICH CLOUD RESOURCE A MONITOR CHECKS, BY THE HOST IT CHECKS.
|
|
10
|
+
*
|
|
11
|
+
* A website, API, SSL, ping or port monitor names a host; a cloud
|
|
12
|
+
* account's inventory says which host names and addresses each resource
|
|
13
|
+
* answers on (CloudResource.cloudEndpoints): a load balancer's DNS name, a
|
|
14
|
+
* CloudFront distribution's, an API Gateway stage's, an App Service's, a
|
|
15
|
+
* Cloud Run service's, an instance's public address. The monitor's host is
|
|
16
|
+
* rarely one of those itself - "shop.example.com" is a CNAME to the load
|
|
17
|
+
* balancer - so the server follows the host's CNAME chain and resolves its
|
|
18
|
+
* addresses (CloudEndpointSuggestions), and every name met on the way is
|
|
19
|
+
* compared here.
|
|
20
|
+
*
|
|
21
|
+
* A match is a suggestion, never a link: the monitor's Linked Resources
|
|
22
|
+
* card offers it, and a person links it.
|
|
23
|
+
*/
|
|
24
|
+
// The hosts of a monitor read, at most: a monitor has a few steps.
|
|
25
|
+
exports.CLOUD_ENDPOINT_MAX_MONITOR_HOSTS = 10;
|
|
26
|
+
/*
|
|
27
|
+
* How AWS writes a load balancer's name in an alias or a CNAME:
|
|
28
|
+
* "dualstack." before the name the load balancer itself reports.
|
|
29
|
+
*/
|
|
30
|
+
const DUALSTACK_PREFIX = "dualstack.";
|
|
31
|
+
// The spellings a name is compared under: as written, and without "dualstack.".
|
|
32
|
+
function getCloudEndpointComparisonNames(name) {
|
|
33
|
+
const host = (0, CloudInventory_1.normalizeCloudHost)(name);
|
|
34
|
+
if (!host) {
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
return host.startsWith(DUALSTACK_PREFIX) &&
|
|
38
|
+
host.length > DUALSTACK_PREFIX.length
|
|
39
|
+
? [host, host.slice(DUALSTACK_PREFIX.length)]
|
|
40
|
+
: [host];
|
|
41
|
+
}
|
|
42
|
+
// A destination as written: a string, or a URL, Hostname or IP (or their JSON).
|
|
43
|
+
function destinationText(destination) {
|
|
44
|
+
if (typeof destination === "string") {
|
|
45
|
+
return destination;
|
|
46
|
+
}
|
|
47
|
+
if (!destination || typeof destination !== "object") {
|
|
48
|
+
return "";
|
|
49
|
+
}
|
|
50
|
+
const record = destination;
|
|
51
|
+
// The JSON form: { _type: "URL", value: "https://..." }.
|
|
52
|
+
if (typeof record["value"] === "string") {
|
|
53
|
+
return record["value"];
|
|
54
|
+
}
|
|
55
|
+
const text = String(destination);
|
|
56
|
+
return text === "[object Object]" ? "" : text;
|
|
57
|
+
}
|
|
58
|
+
// The steps of a monitor's monitorSteps, in either its class or its JSON form.
|
|
59
|
+
function readSteps(monitorSteps) {
|
|
60
|
+
if (!monitorSteps || typeof monitorSteps !== "object") {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
const record = monitorSteps;
|
|
64
|
+
const holder = record["data"] || record["value"];
|
|
65
|
+
const steps = holder && typeof holder === "object"
|
|
66
|
+
? holder["monitorStepsInstanceArray"]
|
|
67
|
+
: undefined;
|
|
68
|
+
return Array.isArray(steps) ? steps : [];
|
|
69
|
+
}
|
|
70
|
+
/*
|
|
71
|
+
* The hosts a monitor checks: each step's destination, normalized (a URL's
|
|
72
|
+
* host, a host name, an address), without repeats, at most
|
|
73
|
+
* CLOUD_ENDPOINT_MAX_MONITOR_HOSTS.
|
|
74
|
+
*/
|
|
75
|
+
function getMonitorDestinationHosts(monitorSteps) {
|
|
76
|
+
const hosts = [];
|
|
77
|
+
for (const step of readSteps(monitorSteps)) {
|
|
78
|
+
if (hosts.length >= exports.CLOUD_ENDPOINT_MAX_MONITOR_HOSTS) {
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
if (!step || typeof step !== "object") {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
const stepRecord = step;
|
|
85
|
+
const data = stepRecord["data"] || stepRecord["value"];
|
|
86
|
+
if (!data || typeof data !== "object") {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const host = (0, CloudInventory_1.normalizeCloudHost)(destinationText(data["monitorDestination"]));
|
|
90
|
+
if (host && !hosts.includes(host)) {
|
|
91
|
+
hosts.push(host);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return hosts;
|
|
95
|
+
}
|
|
96
|
+
/*
|
|
97
|
+
* The resources that answer on one of the names, each once, by the first
|
|
98
|
+
* name that matches (the monitor's own host before its CNAMEs, those
|
|
99
|
+
* before its addresses), sorted by name.
|
|
100
|
+
*/
|
|
101
|
+
function matchCloudEndpoints(data) {
|
|
102
|
+
const suggestions = [];
|
|
103
|
+
const seen = new Set();
|
|
104
|
+
for (const candidate of data.candidates) {
|
|
105
|
+
if (!candidate.id || seen.has(candidate.id)) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const endpoints = new Set((0, CloudInventory_1.readCloudEndpoints)(candidate.endpoints).flatMap((endpoint) => {
|
|
109
|
+
return getCloudEndpointComparisonNames(endpoint);
|
|
110
|
+
}));
|
|
111
|
+
for (const name of data.names) {
|
|
112
|
+
const matched = getCloudEndpointComparisonNames(name.name).find((spelling) => {
|
|
113
|
+
return endpoints.has(spelling);
|
|
114
|
+
});
|
|
115
|
+
if (!matched) {
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
seen.add(candidate.id);
|
|
119
|
+
suggestions.push({
|
|
120
|
+
cloudResourceId: candidate.id,
|
|
121
|
+
name: candidate.name,
|
|
122
|
+
type: candidate.type,
|
|
123
|
+
provider: candidate.provider,
|
|
124
|
+
endpoint: matched,
|
|
125
|
+
via: name.via,
|
|
126
|
+
});
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return suggestions.sort((a, b) => {
|
|
131
|
+
return (a.name.localeCompare(b.name) ||
|
|
132
|
+
a.cloudResourceId.localeCompare(b.cloudResourceId));
|
|
133
|
+
});
|
|
134
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import commonJsModule from "./CloudEndpointMatch.js";
|
|
2
|
+
export const CLOUD_ENDPOINT_MAX_MONITOR_HOSTS = commonJsModule.CLOUD_ENDPOINT_MAX_MONITOR_HOSTS;
|
|
3
|
+
export const getCloudEndpointComparisonNames = commonJsModule.getCloudEndpointComparisonNames;
|
|
4
|
+
export const getMonitorDestinationHosts = commonJsModule.getMonitorDestinationHosts;
|
|
5
|
+
export const matchCloudEndpoints = commonJsModule.matchCloudEndpoints;
|