@oneuptime/common 13.0.0 → 13.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (734) hide show
  1. package/Models/DatabaseModels/Alert.ts +55 -0
  2. package/Models/DatabaseModels/CloudResource.ts +45 -7
  3. package/Models/DatabaseModels/CodeRepository.ts +85 -0
  4. package/Models/DatabaseModels/GoogleSecOpsConnection.ts +57 -7
  5. package/Models/DatabaseModels/GoogleSecOpsConnectionRun.ts +263 -0
  6. package/Models/DatabaseModels/Incident.ts +55 -0
  7. package/Models/DatabaseModels/Index.ts +16 -0
  8. package/Models/DatabaseModels/ScheduledMaintenance.ts +55 -0
  9. package/Models/DatabaseModels/User.ts +51 -2
  10. package/Models/DatabaseModels/UserNotificationEmailRollupItem.ts +43 -2
  11. package/Models/DatabaseModels/UserWebAuthn.ts +17 -0
  12. package/Models/DatabaseModels/VMwareResource.ts +1149 -0
  13. package/Models/DatabaseModels/VMwareVCenter.ts +1122 -0
  14. package/Models/DatabaseModels/VMwareVCenterFeed.ts +625 -0
  15. package/Models/DatabaseModels/VMwareVCenterLabelRule.ts +514 -0
  16. package/Models/DatabaseModels/VMwareVCenterOwnerRule.ts +596 -0
  17. package/Models/DatabaseModels/VMwareVCenterOwnerTeam.ts +485 -0
  18. package/Models/DatabaseModels/VMwareVCenterOwnerUser.ts +484 -0
  19. package/Models/DatabaseModels/WorkflowVariable.ts +22 -1
  20. package/Server/API/AIAgentDataAPI.ts +79 -4
  21. package/Server/API/AIAgentGitHubAPI.ts +523 -0
  22. package/Server/API/AIChatAPI.ts +20 -1
  23. package/Server/API/BillingAPI.ts +33 -0
  24. package/Server/API/DashboardAPI.ts +10 -0
  25. package/Server/API/GitHubAPI.ts +47 -5
  26. package/Server/API/GoogleSecOpsConnectionAPI.ts +79 -0
  27. package/Server/API/UserWebAuthnAPI.ts +21 -1
  28. package/Server/API/VMwareResourceAPI.ts +143 -0
  29. package/Server/Infrastructure/Postgres/SchemaMigrations/1791800000000-SplitWebAuthnChallengeByPurpose.ts +68 -0
  30. package/Server/Infrastructure/Postgres/SchemaMigrations/1791900000000-AddSeverityAndStateToNotificationEmailRollup.ts +26 -0
  31. package/Server/Infrastructure/Postgres/SchemaMigrations/1792000000000-AddVMwareTables.ts +636 -0
  32. package/Server/Infrastructure/Postgres/SchemaMigrations/1792100000000-AddGitHubCommandSettingsToCodeRepository.ts +47 -0
  33. package/Server/Infrastructure/Postgres/SchemaMigrations/1792200000000-AddUserWebAuthnPurpose.ts +17 -0
  34. package/Server/Infrastructure/Postgres/SchemaMigrations/1792300000000-AddGoogleSecOpsDiagnostics.ts +83 -0
  35. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +12 -0
  36. package/Server/Middleware/IdentityRateLimit.ts +101 -0
  37. package/Server/Services/AIRunService.ts +13 -0
  38. package/Server/Services/BillingPaymentMethodService.ts +99 -28
  39. package/Server/Services/BillingService.ts +287 -20
  40. package/Server/Services/CloudResourceInstanceService.ts +70 -0
  41. package/Server/Services/ExceptionAggregationService.ts +1 -0
  42. package/Server/Services/GoogleSecOpsConnectionRunService.ts +10 -0
  43. package/Server/Services/GoogleSecOpsConnectionService.ts +12 -0
  44. package/Server/Services/Index.ts +16 -0
  45. package/Server/Services/LogAggregationService.ts +1 -0
  46. package/Server/Services/MetricAggregationService.ts +1 -0
  47. package/Server/Services/MobilePasskeyLoginService.ts +216 -0
  48. package/Server/Services/MonitorService.ts +51 -1
  49. package/Server/Services/MonitorTemplateService.ts +91 -29
  50. package/Server/Services/NetworkDeviceAutoImportRuleEngineService.ts +132 -1
  51. package/Server/Services/NetworkDeviceAutoImportRuleService.ts +176 -2
  52. package/Server/Services/OpenTelemetryIngestService.ts +17 -0
  53. package/Server/Services/PayAsYouGoBillingService.ts +446 -0
  54. package/Server/Services/ProjectService.ts +46 -2
  55. package/Server/Services/ServerlessFunctionInstanceService.ts +71 -0
  56. package/Server/Services/TeamMemberService.ts +96 -36
  57. package/Server/Services/TelemetryIngestionKeyService.ts +80 -10
  58. package/Server/Services/TelemetryUsageBillingService.ts +95 -5
  59. package/Server/Services/TraceAggregationService.ts +5 -4
  60. package/Server/Services/UserWebAuthnService.ts +592 -133
  61. package/Server/Services/VMwareResourceService.ts +648 -0
  62. package/Server/Services/VMwareVCenterFeedService.ts +99 -0
  63. package/Server/Services/VMwareVCenterLabelRuleEngineService.ts +240 -0
  64. package/Server/Services/VMwareVCenterLabelRuleService.ts +14 -0
  65. package/Server/Services/VMwareVCenterOwnerRuleEngineService.ts +252 -0
  66. package/Server/Services/VMwareVCenterOwnerRuleService.ts +14 -0
  67. package/Server/Services/VMwareVCenterOwnerTeamService.ts +139 -0
  68. package/Server/Services/VMwareVCenterOwnerUserService.ts +133 -0
  69. package/Server/Services/VMwareVCenterService.ts +629 -0
  70. package/Server/Services/WorkflowVariableService.ts +203 -0
  71. package/Server/Types/Billing/MeteredPlan/ActiveMonitoringMeteredPlan.ts +17 -0
  72. package/Server/Types/Billing/MeteredPlan/TelemetryMeteredPlan.ts +31 -1
  73. package/Server/Utils/CodeRepository/GitHub/GitHub.ts +7 -0
  74. package/Server/Utils/CodeRepository/GitHub/GitHubAgentTaskTrigger.ts +341 -0
  75. package/Server/Utils/CodeRepository/GitHub/GitHubCommandAuthorizer.ts +274 -0
  76. package/Server/Utils/CodeRepository/GitHub/GitHubCommandParser.ts +375 -0
  77. package/Server/Utils/CodeRepository/GitHub/GitHubConversation.ts +846 -0
  78. package/Server/Utils/CodeRepository/GitHub/GitHubReplyComposer.ts +360 -0
  79. package/Server/Utils/CodeRepository/GitHub/GitHubRunReply.ts +421 -0
  80. package/Server/Utils/CodeRepository/GitHub/GitHubWebhookEvents.ts +140 -0
  81. package/Server/Utils/CodeRepository/GitHub/GitHubWebhookHandler.ts +906 -0
  82. package/Server/Utils/Dashboard/PublicDashboardResourceListPolicy.ts +143 -0
  83. package/Server/Utils/DataSource/EgressGuard.ts +160 -15
  84. package/Server/Utils/Database/TruncateColumnValue.ts +1 -1
  85. package/Server/Utils/EmailRollup/EmailRollupFlushRunner.ts +2 -0
  86. package/Server/Utils/EmailRollup/EmailRollupRenderer.ts +33 -0
  87. package/Server/Utils/EmailRollup/EmailRollupWriter.ts +44 -0
  88. package/Server/Utils/LogRedaction.ts +2 -1
  89. package/Server/Utils/Monitor/MonitorAlert.ts +1 -1
  90. package/Server/Utils/Monitor/MonitorCriteriaEvaluator.ts +302 -3
  91. package/Server/Utils/Monitor/MonitorMaintenanceSuppression.ts +26 -4
  92. package/Server/Utils/Monitor/MonitorResourceContext.ts +5 -3
  93. package/Server/Utils/Monitor/MonitorStepResourceIdentity.ts +14 -0
  94. package/Server/Utils/Monitor/MonitorTemplateUtil.ts +1 -0
  95. package/Server/Utils/Monitor/SeriesResourceLabels.ts +26 -0
  96. package/Server/Utils/Monitor/SeriesResourceLinker.ts +28 -5
  97. package/Server/Utils/ResourceFeed/ResourceFeedUtil.ts +3 -3
  98. package/Server/Utils/SecurityEvent/ConnectorErrorMessage.ts +14 -9
  99. package/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsClient.ts +116 -84
  100. package/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsPoller.ts +594 -195
  101. package/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsRunExecutor.ts +466 -0
  102. package/Server/Utils/Telemetry/EntityRegistry.ts +5 -0
  103. package/Server/Utils/Telemetry/ResourceHeartbeat.ts +2 -1
  104. package/Server/Utils/Telemetry/TelemetryEntity.ts +181 -1
  105. package/Server/Utils/Telemetry/VMwareSnapshotScan.ts +1352 -0
  106. package/Tests/App/Accounts/LoginPasskey.test.tsx +529 -0
  107. package/Tests/App/Accounts/MobilePasskey.test.tsx +620 -0
  108. package/Tests/App/Accounts/PasswordRequirements.test.tsx +254 -0
  109. package/Tests/App/Accounts/RegisterPassword.test.tsx +553 -0
  110. package/Tests/App/Dashboard/AskAiAvailability.test.ts +224 -0
  111. package/Tests/App/Dashboard/AskAiDisabled.test.tsx +432 -0
  112. package/Tests/App/Dashboard/BackupCodes.test.tsx +414 -0
  113. package/Tests/App/Dashboard/BillingPaidUsageFlow.test.tsx +530 -0
  114. package/Tests/App/Dashboard/BillingPaymentMethodForm.test.tsx +195 -0
  115. package/Tests/App/Dashboard/BreadcrumbCoverage.test.tsx +199 -0
  116. package/Tests/App/Dashboard/CloudDocumentationCard.test.tsx +198 -0
  117. package/Tests/App/Dashboard/CloudDocumentationMarkdown.test.ts +215 -0
  118. package/Tests/App/Dashboard/CloudFleetSummary.test.ts +183 -0
  119. package/Tests/App/Dashboard/CloudFleetSummaryComponent.test.tsx +248 -0
  120. package/Tests/App/Dashboard/CloudResourceTelemetryScope.test.ts +215 -0
  121. package/Tests/App/Dashboard/CriteriaFilterDefaults.test.ts +3 -0
  122. package/Tests/App/Dashboard/DashboardHeaderRequests.test.tsx +441 -0
  123. package/Tests/App/Dashboard/DashboardLazyPages.test.tsx +458 -0
  124. package/Tests/App/Dashboard/DashboardToolbarPopupLayering.test.tsx +566 -0
  125. package/Tests/App/Dashboard/DiscoveryScanLivePage.test.tsx +376 -0
  126. package/Tests/App/Dashboard/DiscoveryScanLiveUpdates.test.tsx +642 -0
  127. package/Tests/App/Dashboard/DiscoveryScanProgress.test.tsx +267 -0
  128. package/Tests/App/Dashboard/DiscoveryScanWizardValidation.test.tsx +69 -231
  129. package/Tests/App/Dashboard/GoogleSecOpsConnectionsErrors.test.tsx +244 -0
  130. package/Tests/App/Dashboard/GoogleSecOpsDiagnostics.test.tsx +724 -0
  131. package/Tests/App/Dashboard/MonitorTemplateSyncFields.test.tsx +539 -0
  132. package/Tests/App/Dashboard/OnCallLayerCardOverrides.test.tsx +24 -7
  133. package/Tests/App/Dashboard/OnCallOverridePresentation.test.ts +496 -0
  134. package/Tests/App/Dashboard/OnCallScheduleOverrideClarity.test.tsx +677 -0
  135. package/Tests/App/Dashboard/OnCallSchedulePreviewOverrides.test.tsx +31 -3
  136. package/Tests/App/Dashboard/PaidUsageConsent.test.tsx +180 -0
  137. package/Tests/App/Dashboard/PasskeySettings.test.tsx +1220 -0
  138. package/Tests/App/Dashboard/PayAsYouGoConsentGate.test.tsx +176 -275
  139. package/Tests/App/Dashboard/PayAsYouGoNotices.test.tsx +380 -233
  140. package/Tests/App/Dashboard/ProductMenuBreadcrumbs.test.tsx +3 -23
  141. package/Tests/App/Dashboard/ResourceFeed.test.tsx +1 -0
  142. package/Tests/App/Dashboard/ResourceFeedPageWiring.test.ts +8 -1
  143. package/Tests/App/Dashboard/TwoFactorStatus.test.tsx +260 -0
  144. package/Tests/App/Dashboard/VMwareDashboardWidgets.test.ts +573 -0
  145. package/Tests/App/Dashboard/WidgetCatalog.test.ts +2 -0
  146. package/Tests/App/Dashboard/WorkflowVariablesTable.test.tsx +768 -0
  147. package/Tests/App/StatusPage/StatusPageOverviewLiveAndSearch.test.tsx +532 -40
  148. package/Tests/App/StatusPage/StatusPageResourceSearchBox.test.tsx +19 -2
  149. package/Tests/Fixtures/MobilePasskeyUser.json +8 -0
  150. package/Tests/Models/DatabaseModels/ResourceFeedModels.test.ts +25 -6
  151. package/Tests/Models/DatabaseModels/VMwareModels.test.ts +1134 -0
  152. package/Tests/Models/RunnerVersionLabel.test.ts +4 -2
  153. package/Tests/Server/API/AIChatProvidersAIEnabled.test.ts +259 -0
  154. package/Tests/Server/API/AIChatRouteAuthorization.test.ts +31 -2
  155. package/Tests/Server/API/BillingPayAsYouGoStatus.test.ts +116 -0
  156. package/Tests/Server/API/DashboardPublicResourceListAPI.test.ts +29 -1
  157. package/Tests/Server/API/EnterpriseLicenseReportUserCount.test.ts +13 -2
  158. package/Tests/Server/API/GitHubWebhookSignature.test.ts +368 -0
  159. package/Tests/Server/API/GoogleSecOpsConnectionAPI.test.ts +248 -0
  160. package/Tests/Server/API/UserWebAuthnAuthenticationOptionsRoute.test.ts +330 -0
  161. package/Tests/Server/API/UserWebAuthnPasskeyAPI.test.ts +172 -0
  162. package/Tests/Server/API/VMwareResourceAPI.test.ts +546 -0
  163. package/Tests/Server/Infrastructure/Postgres/UserNotificationEmailRollupMetadataMigration.test.ts +85 -0
  164. package/Tests/Server/Infrastructure/Postgres/UserNotificationEmailRollupTableMigration.test.ts +34 -3
  165. package/Tests/Server/Middleware/PasskeyRateLimit.test.ts +141 -0
  166. package/Tests/Server/Services/AutoImportRuleRearmRecentScans.test.ts +343 -0
  167. package/Tests/Server/Services/AutoImportRuleWriteRearmsScans.test.ts +381 -0
  168. package/Tests/Server/Services/BillingPaymentMethodServiceSync.test.ts +175 -0
  169. package/Tests/Server/Services/BillingService.test.ts +26 -11
  170. package/Tests/Server/Services/BillingServiceMeteredPaymentAuthorization.test.ts +245 -0
  171. package/Tests/Server/Services/BillingServicePaymentMethodReads.test.ts +362 -0
  172. package/Tests/Server/Services/CloudResourceInstanceStalePrune.test.ts +188 -0
  173. package/Tests/Server/Services/DiscoveryScanClaimHookFreeSafety.test.ts +16 -2
  174. package/Tests/Server/Services/GoogleSecOpsDiagnosticsModel.test.ts +153 -0
  175. package/Tests/Server/Services/HookFreeWriteLengthClamp.test.ts +13 -0
  176. package/Tests/Server/Services/InventoryItemPromotionGate.test.ts +5 -0
  177. package/Tests/Server/Services/InventoryUpsertSchemaParity.test.ts +36 -0
  178. package/Tests/Server/Services/InventoryUpsertTruncationGuard.test.ts +151 -0
  179. package/Tests/Server/Services/MobilePasskeyLoginIntegration.test.ts +231 -0
  180. package/Tests/Server/Services/MobilePasskeyLoginService.test.ts +315 -0
  181. package/Tests/Server/Services/MonitorPayAsYouGoBilling.test.ts +302 -0
  182. package/Tests/Server/Services/MonitorTemplateServiceFieldSync.test.ts +994 -0
  183. package/Tests/Server/Services/NetworkDeviceAutoImportRuleService.test.ts +22 -0
  184. package/Tests/Server/Services/OpenTelemetryResourceRetentionMemo.test.ts +7 -1
  185. package/Tests/Server/Services/PayAsYouGoBillingService.test.ts +857 -0
  186. package/Tests/Server/Services/PayAsYouGoStripeRateLimitBudget.test.ts +379 -0
  187. package/Tests/Server/Services/ProjectServiceExtendTrial.test.ts +99 -1
  188. package/Tests/Server/Services/ProjectServiceSubscriptionSeats.test.ts +134 -0
  189. package/Tests/Server/Services/ResourceFeedServices.test.ts +3 -2
  190. package/Tests/Server/Services/ResourceUpdateLastSeenLivenessFallback.test.ts +32 -6
  191. package/Tests/Server/Services/SecurityEventLastErrorColumnWidth.test.ts +363 -175
  192. package/Tests/Server/Services/ServerlessFunctionInstanceStalePrune.test.ts +200 -0
  193. package/Tests/Server/Services/TeamMemberAutoAcceptInvitation.test.ts +3 -0
  194. package/Tests/Server/Services/TeamMemberBillingSeatSync.test.ts +762 -0
  195. package/Tests/Server/Services/TeamMemberInviteRegistrationToken.test.ts +3 -0
  196. package/Tests/Server/Services/TelemetryIngestionKeyPolicyResolution.test.ts +72 -0
  197. package/Tests/Server/Services/TelemetryIngestionKeyValidation.test.ts +17 -4
  198. package/Tests/Server/Services/TelemetryPayAsYouGoBilling.test.ts +355 -0
  199. package/Tests/Server/Services/TraceAnalyticsResourceDisplayNames.test.ts +41 -4
  200. package/Tests/Server/Services/UserNotificationEmailRollupModels.test.ts +37 -0
  201. package/Tests/Server/Services/UserWebAuthnPasskeyIntegration.test.ts +401 -0
  202. package/Tests/Server/Services/UserWebAuthnPasskeyService.test.ts +769 -0
  203. package/Tests/Server/Services/UserWebAuthnUserVerification.test.ts +649 -0
  204. package/Tests/Server/Services/VMwareResourceService.test.ts +945 -0
  205. package/Tests/Server/Services/VMwareVCenterService.test.ts +722 -0
  206. package/Tests/Server/Services/WorkflowVariableRenameUniqueness.test.ts +842 -0
  207. package/Tests/Server/TestingUtils/PasskeyHttpIntegration.ts +102 -0
  208. package/Tests/Server/TestingUtils/SecurityKey.ts +464 -0
  209. package/Tests/Server/TestingUtils/WebAuthnServiceMocks.ts +60 -0
  210. package/Tests/Server/Types/Billing/PayAsYouGoMeteredAuthorization.test.ts +573 -0
  211. package/Tests/Server/Types/Database/Permissions/ProjectCustomerSupportAccessColumn.test.ts +261 -0
  212. package/Tests/Server/Types/Database/Permissions/WorkflowVariableColumnPermission.test.ts +95 -0
  213. package/Tests/Server/Utils/CodeRepository/GitHubAgentTaskTrigger.test.ts +2101 -0
  214. package/Tests/Server/Utils/CodeRepository/GitHubCommandAuthorizer.test.ts +883 -0
  215. package/Tests/Server/Utils/CodeRepository/GitHubCommandParser.test.ts +1474 -0
  216. package/Tests/Server/Utils/CodeRepository/GitHubConversation.test.ts +1526 -0
  217. package/Tests/Server/Utils/CodeRepository/GitHubReplyComposer.test.ts +1389 -0
  218. package/Tests/Server/Utils/CodeRepository/GitHubRunReply.test.ts +1707 -0
  219. package/Tests/Server/Utils/CodeRepository/GitHubWebhookHandler.test.ts +2202 -0
  220. package/Tests/Server/Utils/Dashboard/PublicDashboardResourceListPolicy.test.ts +345 -0
  221. package/Tests/Server/Utils/DataSource/EgressGuard.test.ts +896 -0
  222. package/Tests/Server/Utils/EmailRollup/EmailRollupMetadataIntegration.test.ts +246 -0
  223. package/Tests/Server/Utils/EmailRollup/EmailRollupRenderer.test.ts +299 -1
  224. package/Tests/Server/Utils/EmailRollup/EmailRollupTestHarness.ts +6 -0
  225. package/Tests/Server/Utils/EmailRollup/EmailRollupWriter.test.ts +185 -0
  226. package/Tests/Server/Utils/LogRedaction.test.ts +33 -0
  227. package/Tests/Server/Utils/Monitor/CapturedMetricAttributeUtil.test.ts +2 -1
  228. package/Tests/Server/Utils/Monitor/Criteria/TelemetryStepMetricAlias.test.ts +10 -0
  229. package/Tests/Server/Utils/Monitor/MonitorAlertResourceLinking.test.ts +66 -1
  230. package/Tests/Server/Utils/Monitor/MonitorCriteriaEvaluator.test.ts +362 -0
  231. package/Tests/Server/Utils/Monitor/MonitorDependencySuppressionCreatorSkip.test.ts +1 -0
  232. package/Tests/Server/Utils/Monitor/MonitorIncidentResourceLinking.test.ts +60 -1
  233. package/Tests/Server/Utils/Monitor/MonitorMaintenanceSuppression.test.ts +60 -0
  234. package/Tests/Server/Utils/Monitor/MonitorRootCauseTargetResolution.test.ts +423 -0
  235. package/Tests/Server/Utils/Monitor/MonitorStepResourceIdentity.test.ts +6 -0
  236. package/Tests/Server/Utils/Monitor/MonitorSummaryPersistence.test.ts +1 -0
  237. package/Tests/Server/Utils/Monitor/PerSeriesSecondEntityAlerting.test.ts +1 -0
  238. package/Tests/Server/Utils/Monitor/SeriesResourceLinker.test.ts +46 -2
  239. package/Tests/Server/Utils/SecurityEvent/ConnectorErrorMessage.test.ts +81 -45
  240. package/Tests/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsRunExecutor.test.ts +711 -0
  241. package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsClickhouseIntegration.test.ts +223 -0
  242. package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsClient.test.ts +69 -1
  243. package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsDiagnostics.test.ts +838 -0
  244. package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsErrorHandling.test.ts +241 -28
  245. package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsHttpIntegration.test.ts +651 -0
  246. package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsPoller.test.ts +11 -0
  247. package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsPollerFailureTaxonomy.test.ts +13 -12
  248. package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsPollerHardening.test.ts +112 -127
  249. package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsRequestContract.test.ts +12 -18
  250. package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsResponseParsing.test.ts +43 -0
  251. package/Tests/Server/Utils/Telemetry/TelemetryEntity.test.ts +580 -0
  252. package/Tests/Server/Utils/Telemetry/VMwareSnapshotScan.test.ts +1748 -0
  253. package/Tests/Types/Cloud/CloudPlatform.test.ts +574 -0
  254. package/Tests/Types/Monitor/MetricAndProfileDefaultCriteria.test.ts +2 -0
  255. package/Tests/Types/Monitor/MonitorCriteriaMetricVariables.test.ts +9 -0
  256. package/Tests/Types/Monitor/MonitorStepDefaultTelemetryConfig.test.ts +1 -0
  257. package/Tests/Types/Monitor/MonitorStepInfraMonitorUtils.test.ts +53 -8
  258. package/Tests/Types/Monitor/MonitorStepInfrastructureMonitors.test.ts +97 -0
  259. package/Tests/Types/Monitor/MonitorStepMetricViewConfigUtil.test.ts +1 -0
  260. package/Tests/Types/Monitor/MonitorStepTemplateSyncFields.test.ts +107 -0
  261. package/Tests/Types/Monitor/MonitorTemplateSyncField.test.ts +172 -0
  262. package/Tests/Types/Monitor/MonitorType.test.ts +1 -0
  263. package/Tests/Types/Monitor/MonitorTypeKeywords.test.ts +2 -0
  264. package/Tests/Types/Monitor/Recommendation/MonitorRecommendationAlertDebuggability.test.ts +1 -0
  265. package/Tests/Types/Monitor/Recommendation/MonitorRecommendationCatalog.test.ts +9 -0
  266. package/Tests/Types/Monitor/Recommendation/MonitorRecommendationCoverage.test.ts +1 -1
  267. package/Tests/Types/Monitor/Recommendation/MonitorRecommendationNotificationMode.test.ts +1 -1
  268. package/Tests/Types/Monitor/SeriesContext/SeriesDebugHints.test.ts +131 -0
  269. package/Tests/Types/Monitor/SeriesContext/SeriesLabelDisplay.test.ts +10 -0
  270. package/Tests/Types/Monitor/VMwareAlertTemplates.test.ts +1608 -0
  271. package/Tests/Types/Monitor/VMwareMetricCatalog.test.ts +488 -0
  272. package/Tests/Types/OnCallDutyPolicy/OverrideProvenance.test.ts +295 -0
  273. package/Tests/Types/Runner/RunnerLiveStatus.test.ts +2 -2
  274. package/Tests/Types/SignupPassword.test.ts +205 -0
  275. package/Tests/Types/StatusPage/StatusPageLanguage.test.ts +44 -0
  276. package/Tests/Types/SupportedLanguages.test.ts +119 -0
  277. package/Tests/Types/Telemetry/EntityTypeGroups.test.ts +19 -0
  278. package/Tests/UI/ColorPickerBuild.test.ts +86 -0
  279. package/Tests/UI/Components/Breadcrumbs.test.tsx +32 -0
  280. package/Tests/UI/Components/Forms/ModelFormPreservesUserInput.test.tsx +937 -0
  281. package/Tests/UI/Components/Forms/ModelFormWriteOnlyColumnSelect.test.tsx +230 -0
  282. package/Tests/UI/Components/Forms/ValidationFormSteps.test.ts +3 -4
  283. package/Tests/UI/Components/LabelRuleImportExport.test.tsx +907 -0
  284. package/Tests/UI/Components/ModelTable/ModelTableCreateAfterEdit.test.tsx +514 -0
  285. package/Tests/UI/Components/MonitorGraphs/Uptime.test.tsx +301 -0
  286. package/Tests/UI/Components/MonitorTemplateVariables/TemplateVariablesCatalog.test.ts +2 -1
  287. package/Tests/UI/Components/TooltipLazyContent.test.tsx +373 -0
  288. package/Tests/UI/MicrosoftTeams/MicrosoftTeamsMessagingEndpointGuidance.test.tsx +43 -12
  289. package/Tests/UI/ReactDomBuild.test.ts +104 -0
  290. package/Tests/UI/ReactRouterSingletonBuild.test.ts +11 -1
  291. package/Tests/UI/Utils/Breadcrumb/fixtures/RealBreadcrumbTrails.ts +148 -0
  292. package/Tests/UI/Utils/Breadcrumb/fixtures/RealRoutePatterns.ts +29 -0
  293. package/Tests/UI/Utils/DashboardStackingLayers.test.ts +197 -0
  294. package/Tests/UI/Utils/LabelRuleImportExport.test.ts +546 -0
  295. package/Tests/UI/Utils/ModelAPITenantHeader.test.ts +109 -2
  296. package/Tests/UI/Utils/UseDashboardGridDnd.test.tsx +7 -2
  297. package/Tests/UI/Utils/UserEmailRegistrationStatus.test.tsx +295 -0
  298. package/Tests/UI/Utils/WebAuthn.test.ts +265 -0
  299. package/Tests/Utils/Dashboard/Components/DashboardComponentDefaults.test.ts +5 -0
  300. package/Tests/Utils/Dashboard/Components/DashboardVMwareListComponents.test.ts +548 -0
  301. package/Tests/Utils/Dashboard/DashboardResourceListSharedArgs.test.ts +17 -3
  302. package/Tests/Utils/LabelRuleImportExport.test.ts +583 -0
  303. package/Tests/Utils/Monitor/MonitorSummarySnapshotUtil.test.ts +1 -0
  304. package/Tests/Utils/Monitor/MonitorTemplateSyncUtil.test.ts +590 -0
  305. package/Tests/Utils/RequestFailedDetails.test.ts +325 -0
  306. package/Tests/Utils/Telemetry/CloudInstanceIdentity.test.ts +255 -0
  307. package/Tests/Utils/Telemetry/EntityRelationship.test.ts +167 -0
  308. package/Tests/Utils/WebAuthnTestUtil.ts +79 -0
  309. package/Tests/__mocks__/simplewebauthn.js +33 -4
  310. package/Types/AI/CodeFixTaskContext.ts +122 -0
  311. package/Types/AI/CodeFixTaskType.ts +62 -0
  312. package/Types/Accounts/AccountsLanguage.ts +1 -0
  313. package/Types/AdminDashboard/AdminDashboardLanguage.ts +1 -0
  314. package/Types/Calendar/CalendarEvent.ts +16 -0
  315. package/Types/Cloud/CloudPlatform.ts +372 -0
  316. package/Types/CodeRepository/GitHubCommand.ts +69 -0
  317. package/Types/Dashboard/DashboardComponentType.ts +2 -0
  318. package/Types/Dashboard/DashboardComponents/ComponentArgument.ts +1 -0
  319. package/Types/Dashboard/DashboardComponents/DashboardVMwareHostListComponent.ts +23 -0
  320. package/Types/Dashboard/DashboardComponents/DashboardVMwareVirtualMachineListComponent.ts +30 -0
  321. package/Types/Dashboard/DashboardLanguage.ts +1 -0
  322. package/Types/Dashboard/DashboardTemplates.ts +314 -0
  323. package/Types/Docs/DocsLanguage.ts +1 -0
  324. package/Types/Exception/EgressGuardException.ts +65 -0
  325. package/Types/Icon/IconProp.ts +1 -0
  326. package/Types/Monitor/MetricMonitor/MetricMonitorResponse.ts +36 -0
  327. package/Types/Monitor/MonitorCriteriaInstance.ts +1 -0
  328. package/Types/Monitor/MonitorStep.ts +78 -17
  329. package/Types/Monitor/MonitorStepMetricViewConfigUtil.ts +1 -0
  330. package/Types/Monitor/MonitorStepVMwareMonitor.ts +127 -0
  331. package/Types/Monitor/MonitorTemplateSyncField.ts +291 -0
  332. package/Types/Monitor/MonitorType.ts +24 -0
  333. package/Types/Monitor/Recommendation/MonitorRecommendationCatalog.ts +33 -0
  334. package/Types/Monitor/Recommendation/MonitorRecommendationTypes.ts +2 -0
  335. package/Types/Monitor/Recommendation/MonitorRecommendationUtil.ts +3 -0
  336. package/Types/Monitor/SeriesContext/SeriesDebugHints.ts +158 -0
  337. package/Types/Monitor/SeriesContext/SeriesLabelDisplay.ts +61 -0
  338. package/Types/Monitor/VMwareAlertTemplates.ts +1070 -0
  339. package/Types/Monitor/VMwareMetricCatalog.ts +914 -0
  340. package/Types/OnCallDutyPolicy/ScheduleShiftUtil.ts +29 -0
  341. package/Types/OnCallDutyPolicy/UserOverrideUtil.ts +16 -0
  342. package/Types/Password.ts +84 -5
  343. package/Types/Permission.ts +265 -0
  344. package/Types/Probe/RequestFailedDetails.ts +7 -0
  345. package/Types/Runner/RunnerLiveStatus.ts +1 -1
  346. package/Types/SecurityEvent/GoogleSecOpsDiagnostics.ts +56 -0
  347. package/Types/StatusPage/StatusPageLanguage.ts +1 -0
  348. package/Types/Telemetry/EntityType.ts +21 -0
  349. package/Types/Telemetry/ServiceType.ts +1 -0
  350. package/Typings/Index.d.ts +63 -0
  351. package/UI/Components/Breadcrumbs/Breadcrumbs.tsx +2 -2
  352. package/UI/Components/Calendar/Calendar.css +78 -0
  353. package/UI/Components/Calendar/Calendar.tsx +28 -3
  354. package/UI/Components/Forms/BasicForm.tsx +44 -2
  355. package/UI/Components/Forms/Fields/ColorPicker.tsx +2 -1
  356. package/UI/Components/Forms/Fields/FormField.tsx +16 -3
  357. package/UI/Components/Forms/ModelForm.tsx +159 -5
  358. package/UI/Components/Forms/Types/Field.ts +8 -1
  359. package/UI/Components/Graphs/DayUptimeGraph.tsx +8 -10
  360. package/UI/Components/Icon/Icon.tsx +16 -0
  361. package/UI/Components/Input/Input.tsx +42 -7
  362. package/UI/Components/LabelRule/ImportLabelRulesModal.tsx +441 -0
  363. package/UI/Components/LabelRule/LabelRuleTable.tsx +142 -0
  364. package/UI/Components/ModelTable/BaseModelTable.tsx +22 -5
  365. package/UI/Components/ModelTable/ModelTable.tsx +14 -6
  366. package/UI/Components/MonitorGraphs/Uptime.tsx +17 -27
  367. package/UI/Components/MonitorTemplateVariables/TemplateVariablesCatalog.ts +3 -1
  368. package/UI/Components/Tooltip/Tooltip.tsx +52 -6
  369. package/UI/Utils/DashboardStackingLayers.ts +85 -0
  370. package/UI/Utils/LabelRuleImportExport.ts +310 -0
  371. package/UI/Utils/ModelAPI/ModelAPI.ts +4 -3
  372. package/UI/Utils/TelemetryService.ts +4 -3
  373. package/UI/Utils/UseDashboardGridDnd.ts +4 -1
  374. package/UI/Utils/UserEmailRegistrationStatus.ts +33 -5
  375. package/UI/Utils/WebAuthn.ts +220 -0
  376. package/UI/esbuild-config.js +4 -0
  377. package/Utils/API.ts +34 -0
  378. package/Utils/Dashboard/Components/DashboardVMwareHostListComponent.ts +38 -0
  379. package/Utils/Dashboard/Components/DashboardVMwareResourceListShared.ts +70 -0
  380. package/Utils/Dashboard/Components/DashboardVMwareVirtualMachineListComponent.ts +76 -0
  381. package/Utils/Dashboard/Components/Index.ts +16 -0
  382. package/Utils/LabelRuleImportExport.ts +496 -0
  383. package/Utils/Monitor/MonitorTemplateSyncUtil.ts +164 -0
  384. package/Utils/NetworkDiscovery/DiscoveryScanStatus.ts +8 -0
  385. package/Utils/Telemetry/CloudInstanceIdentity.ts +94 -0
  386. package/Utils/Telemetry/EntityKey.ts +19 -0
  387. package/Utils/Telemetry/EntityRelationship.ts +19 -0
  388. package/build/dist/Models/DatabaseModels/Alert.js +54 -0
  389. package/build/dist/Models/DatabaseModels/Alert.js.map +1 -1
  390. package/build/dist/Models/DatabaseModels/CloudResource.js +44 -7
  391. package/build/dist/Models/DatabaseModels/CloudResource.js.map +1 -1
  392. package/build/dist/Models/DatabaseModels/CodeRepository.js +87 -0
  393. package/build/dist/Models/DatabaseModels/CodeRepository.js.map +1 -1
  394. package/build/dist/Models/DatabaseModels/GoogleSecOpsConnection.js +60 -7
  395. package/build/dist/Models/DatabaseModels/GoogleSecOpsConnection.js.map +1 -1
  396. package/build/dist/Models/DatabaseModels/GoogleSecOpsConnectionRun.js +287 -0
  397. package/build/dist/Models/DatabaseModels/GoogleSecOpsConnectionRun.js.map +1 -0
  398. package/build/dist/Models/DatabaseModels/Incident.js +54 -0
  399. package/build/dist/Models/DatabaseModels/Incident.js.map +1 -1
  400. package/build/dist/Models/DatabaseModels/Index.js +16 -0
  401. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  402. package/build/dist/Models/DatabaseModels/ScheduledMaintenance.js +54 -0
  403. package/build/dist/Models/DatabaseModels/ScheduledMaintenance.js.map +1 -1
  404. package/build/dist/Models/DatabaseModels/User.js +57 -4
  405. package/build/dist/Models/DatabaseModels/User.js.map +1 -1
  406. package/build/dist/Models/DatabaseModels/UserNotificationEmailRollupItem.js +47 -2
  407. package/build/dist/Models/DatabaseModels/UserNotificationEmailRollupItem.js.map +1 -1
  408. package/build/dist/Models/DatabaseModels/UserWebAuthn.js +18 -0
  409. package/build/dist/Models/DatabaseModels/UserWebAuthn.js.map +1 -1
  410. package/build/dist/Models/DatabaseModels/VMwareResource.js +1201 -0
  411. package/build/dist/Models/DatabaseModels/VMwareResource.js.map +1 -0
  412. package/build/dist/Models/DatabaseModels/VMwareVCenter.js +1149 -0
  413. package/build/dist/Models/DatabaseModels/VMwareVCenter.js.map +1 -0
  414. package/build/dist/Models/DatabaseModels/VMwareVCenterFeed.js +648 -0
  415. package/build/dist/Models/DatabaseModels/VMwareVCenterFeed.js.map +1 -0
  416. package/build/dist/Models/DatabaseModels/VMwareVCenterLabelRule.js +522 -0
  417. package/build/dist/Models/DatabaseModels/VMwareVCenterLabelRule.js.map +1 -0
  418. package/build/dist/Models/DatabaseModels/VMwareVCenterOwnerRule.js +603 -0
  419. package/build/dist/Models/DatabaseModels/VMwareVCenterOwnerRule.js.map +1 -0
  420. package/build/dist/Models/DatabaseModels/VMwareVCenterOwnerTeam.js +503 -0
  421. package/build/dist/Models/DatabaseModels/VMwareVCenterOwnerTeam.js.map +1 -0
  422. package/build/dist/Models/DatabaseModels/VMwareVCenterOwnerUser.js +502 -0
  423. package/build/dist/Models/DatabaseModels/VMwareVCenterOwnerUser.js.map +1 -0
  424. package/build/dist/Models/DatabaseModels/WorkflowVariable.js +22 -1
  425. package/build/dist/Models/DatabaseModels/WorkflowVariable.js.map +1 -1
  426. package/build/dist/Server/API/AIAgentDataAPI.js +63 -3
  427. package/build/dist/Server/API/AIAgentDataAPI.js.map +1 -1
  428. package/build/dist/Server/API/AIAgentGitHubAPI.js +363 -0
  429. package/build/dist/Server/API/AIAgentGitHubAPI.js.map +1 -0
  430. package/build/dist/Server/API/AIChatAPI.js +19 -1
  431. package/build/dist/Server/API/AIChatAPI.js.map +1 -1
  432. package/build/dist/Server/API/BillingAPI.js +22 -0
  433. package/build/dist/Server/API/BillingAPI.js.map +1 -1
  434. package/build/dist/Server/API/DashboardAPI.js +10 -0
  435. package/build/dist/Server/API/DashboardAPI.js.map +1 -1
  436. package/build/dist/Server/API/GitHubAPI.js +33 -5
  437. package/build/dist/Server/API/GitHubAPI.js.map +1 -1
  438. package/build/dist/Server/API/GoogleSecOpsConnectionAPI.js +56 -0
  439. package/build/dist/Server/API/GoogleSecOpsConnectionAPI.js.map +1 -0
  440. package/build/dist/Server/API/UserWebAuthnAPI.js +17 -1
  441. package/build/dist/Server/API/UserWebAuthnAPI.js.map +1 -1
  442. package/build/dist/Server/API/VMwareResourceAPI.js +106 -0
  443. package/build/dist/Server/API/VMwareResourceAPI.js.map +1 -0
  444. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1791800000000-SplitWebAuthnChallengeByPurpose.js +41 -0
  445. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1791800000000-SplitWebAuthnChallengeByPurpose.js.map +1 -0
  446. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1791900000000-AddSeverityAndStateToNotificationEmailRollup.js +14 -0
  447. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1791900000000-AddSeverityAndStateToNotificationEmailRollup.js.map +1 -0
  448. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1792000000000-AddVMwareTables.js +241 -0
  449. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1792000000000-AddVMwareTables.js.map +1 -0
  450. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1792100000000-AddGitHubCommandSettingsToCodeRepository.js +36 -0
  451. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1792100000000-AddGitHubCommandSettingsToCodeRepository.js.map +1 -0
  452. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1792200000000-AddUserWebAuthnPurpose.js +12 -0
  453. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1792200000000-AddUserWebAuthnPurpose.js.map +1 -0
  454. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1792300000000-AddGoogleSecOpsDiagnostics.js +34 -0
  455. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1792300000000-AddGoogleSecOpsDiagnostics.js.map +1 -0
  456. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +12 -0
  457. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  458. package/build/dist/Server/Middleware/IdentityRateLimit.js +80 -0
  459. package/build/dist/Server/Middleware/IdentityRateLimit.js.map +1 -1
  460. package/build/dist/Server/Services/AIRunService.js +14 -1
  461. package/build/dist/Server/Services/AIRunService.js.map +1 -1
  462. package/build/dist/Server/Services/BillingPaymentMethodService.js +71 -21
  463. package/build/dist/Server/Services/BillingPaymentMethodService.js.map +1 -1
  464. package/build/dist/Server/Services/BillingService.js +210 -22
  465. package/build/dist/Server/Services/BillingService.js.map +1 -1
  466. package/build/dist/Server/Services/CloudResourceInstanceService.js +66 -0
  467. package/build/dist/Server/Services/CloudResourceInstanceService.js.map +1 -1
  468. package/build/dist/Server/Services/ExceptionAggregationService.js +1 -0
  469. package/build/dist/Server/Services/ExceptionAggregationService.js.map +1 -1
  470. package/build/dist/Server/Services/GoogleSecOpsConnectionRunService.js +9 -0
  471. package/build/dist/Server/Services/GoogleSecOpsConnectionRunService.js.map +1 -0
  472. package/build/dist/Server/Services/GoogleSecOpsConnectionService.js +7 -0
  473. package/build/dist/Server/Services/GoogleSecOpsConnectionService.js.map +1 -1
  474. package/build/dist/Server/Services/Index.js +16 -0
  475. package/build/dist/Server/Services/Index.js.map +1 -1
  476. package/build/dist/Server/Services/LogAggregationService.js +1 -0
  477. package/build/dist/Server/Services/LogAggregationService.js.map +1 -1
  478. package/build/dist/Server/Services/MetricAggregationService.js +1 -0
  479. package/build/dist/Server/Services/MetricAggregationService.js.map +1 -1
  480. package/build/dist/Server/Services/MobilePasskeyLoginService.js +137 -0
  481. package/build/dist/Server/Services/MobilePasskeyLoginService.js.map +1 -0
  482. package/build/dist/Server/Services/MonitorService.js +34 -1
  483. package/build/dist/Server/Services/MonitorService.js.map +1 -1
  484. package/build/dist/Server/Services/MonitorTemplateService.js +64 -26
  485. package/build/dist/Server/Services/MonitorTemplateService.js.map +1 -1
  486. package/build/dist/Server/Services/NetworkDeviceAutoImportRuleEngineService.js +124 -1
  487. package/build/dist/Server/Services/NetworkDeviceAutoImportRuleEngineService.js.map +1 -1
  488. package/build/dist/Server/Services/NetworkDeviceAutoImportRuleService.js +142 -2
  489. package/build/dist/Server/Services/NetworkDeviceAutoImportRuleService.js.map +1 -1
  490. package/build/dist/Server/Services/OpenTelemetryIngestService.js +28 -13
  491. package/build/dist/Server/Services/OpenTelemetryIngestService.js.map +1 -1
  492. package/build/dist/Server/Services/PayAsYouGoBillingService.js +297 -0
  493. package/build/dist/Server/Services/PayAsYouGoBillingService.js.map +1 -0
  494. package/build/dist/Server/Services/ProjectService.js +38 -2
  495. package/build/dist/Server/Services/ProjectService.js.map +1 -1
  496. package/build/dist/Server/Services/ServerlessFunctionInstanceService.js +66 -0
  497. package/build/dist/Server/Services/ServerlessFunctionInstanceService.js.map +1 -1
  498. package/build/dist/Server/Services/TeamMemberService.js +85 -28
  499. package/build/dist/Server/Services/TeamMemberService.js.map +1 -1
  500. package/build/dist/Server/Services/TelemetryIngestionKeyService.js +61 -10
  501. package/build/dist/Server/Services/TelemetryIngestionKeyService.js.map +1 -1
  502. package/build/dist/Server/Services/TelemetryUsageBillingService.js +62 -5
  503. package/build/dist/Server/Services/TelemetryUsageBillingService.js.map +1 -1
  504. package/build/dist/Server/Services/TraceAggregationService.js +5 -4
  505. package/build/dist/Server/Services/TraceAggregationService.js.map +1 -1
  506. package/build/dist/Server/Services/UserWebAuthnService.js +345 -113
  507. package/build/dist/Server/Services/UserWebAuthnService.js.map +1 -1
  508. package/build/dist/Server/Services/VMwareResourceService.js +395 -0
  509. package/build/dist/Server/Services/VMwareResourceService.js.map +1 -0
  510. package/build/dist/Server/Services/VMwareVCenterFeedService.js +89 -0
  511. package/build/dist/Server/Services/VMwareVCenterFeedService.js.map +1 -0
  512. package/build/dist/Server/Services/VMwareVCenterLabelRuleEngineService.js +197 -0
  513. package/build/dist/Server/Services/VMwareVCenterLabelRuleEngineService.js.map +1 -0
  514. package/build/dist/Server/Services/VMwareVCenterLabelRuleService.js +13 -0
  515. package/build/dist/Server/Services/VMwareVCenterLabelRuleService.js.map +1 -0
  516. package/build/dist/Server/Services/VMwareVCenterOwnerRuleEngineService.js +214 -0
  517. package/build/dist/Server/Services/VMwareVCenterOwnerRuleEngineService.js.map +1 -0
  518. package/build/dist/Server/Services/VMwareVCenterOwnerRuleService.js +13 -0
  519. package/build/dist/Server/Services/VMwareVCenterOwnerRuleService.js.map +1 -0
  520. package/build/dist/Server/Services/VMwareVCenterOwnerTeamService.js +129 -0
  521. package/build/dist/Server/Services/VMwareVCenterOwnerTeamService.js.map +1 -0
  522. package/build/dist/Server/Services/VMwareVCenterOwnerUserService.js +122 -0
  523. package/build/dist/Server/Services/VMwareVCenterOwnerUserService.js.map +1 -0
  524. package/build/dist/Server/Services/VMwareVCenterService.js +533 -0
  525. package/build/dist/Server/Services/VMwareVCenterService.js.map +1 -0
  526. package/build/dist/Server/Services/WorkflowVariableService.js +169 -0
  527. package/build/dist/Server/Services/WorkflowVariableService.js.map +1 -1
  528. package/build/dist/Server/Types/Billing/MeteredPlan/ActiveMonitoringMeteredPlan.js +12 -1
  529. package/build/dist/Server/Types/Billing/MeteredPlan/ActiveMonitoringMeteredPlan.js.map +1 -1
  530. package/build/dist/Server/Types/Billing/MeteredPlan/TelemetryMeteredPlan.js +25 -2
  531. package/build/dist/Server/Types/Billing/MeteredPlan/TelemetryMeteredPlan.js.map +1 -1
  532. package/build/dist/Server/Utils/CodeRepository/GitHub/GitHub.js.map +1 -1
  533. package/build/dist/Server/Utils/CodeRepository/GitHub/GitHubAgentTaskTrigger.js +275 -0
  534. package/build/dist/Server/Utils/CodeRepository/GitHub/GitHubAgentTaskTrigger.js.map +1 -0
  535. package/build/dist/Server/Utils/CodeRepository/GitHub/GitHubCommandAuthorizer.js +226 -0
  536. package/build/dist/Server/Utils/CodeRepository/GitHub/GitHubCommandAuthorizer.js.map +1 -0
  537. package/build/dist/Server/Utils/CodeRepository/GitHub/GitHubCommandParser.js +297 -0
  538. package/build/dist/Server/Utils/CodeRepository/GitHub/GitHubCommandParser.js.map +1 -0
  539. package/build/dist/Server/Utils/CodeRepository/GitHub/GitHubConversation.js +582 -0
  540. package/build/dist/Server/Utils/CodeRepository/GitHub/GitHubConversation.js.map +1 -0
  541. package/build/dist/Server/Utils/CodeRepository/GitHub/GitHubReplyComposer.js +275 -0
  542. package/build/dist/Server/Utils/CodeRepository/GitHub/GitHubReplyComposer.js.map +1 -0
  543. package/build/dist/Server/Utils/CodeRepository/GitHub/GitHubRunReply.js +365 -0
  544. package/build/dist/Server/Utils/CodeRepository/GitHub/GitHubRunReply.js.map +1 -0
  545. package/build/dist/Server/Utils/CodeRepository/GitHub/GitHubWebhookEvents.js +103 -0
  546. package/build/dist/Server/Utils/CodeRepository/GitHub/GitHubWebhookEvents.js.map +1 -0
  547. package/build/dist/Server/Utils/CodeRepository/GitHub/GitHubWebhookHandler.js +661 -0
  548. package/build/dist/Server/Utils/CodeRepository/GitHub/GitHubWebhookHandler.js.map +1 -0
  549. package/build/dist/Server/Utils/Dashboard/PublicDashboardResourceListPolicy.js +113 -0
  550. package/build/dist/Server/Utils/Dashboard/PublicDashboardResourceListPolicy.js.map +1 -1
  551. package/build/dist/Server/Utils/DataSource/EgressGuard.js +99 -15
  552. package/build/dist/Server/Utils/DataSource/EgressGuard.js.map +1 -1
  553. package/build/dist/Server/Utils/EmailRollup/EmailRollupFlushRunner.js +2 -0
  554. package/build/dist/Server/Utils/EmailRollup/EmailRollupFlushRunner.js.map +1 -1
  555. package/build/dist/Server/Utils/EmailRollup/EmailRollupRenderer.js +18 -0
  556. package/build/dist/Server/Utils/EmailRollup/EmailRollupRenderer.js.map +1 -1
  557. package/build/dist/Server/Utils/EmailRollup/EmailRollupWriter.js +31 -2
  558. package/build/dist/Server/Utils/EmailRollup/EmailRollupWriter.js.map +1 -1
  559. package/build/dist/Server/Utils/LogRedaction.js +2 -1
  560. package/build/dist/Server/Utils/LogRedaction.js.map +1 -1
  561. package/build/dist/Server/Utils/Monitor/MonitorAlert.js +1 -1
  562. package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js +219 -4
  563. package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js.map +1 -1
  564. package/build/dist/Server/Utils/Monitor/MonitorMaintenanceSuppression.js +12 -4
  565. package/build/dist/Server/Utils/Monitor/MonitorMaintenanceSuppression.js.map +1 -1
  566. package/build/dist/Server/Utils/Monitor/MonitorResourceContext.js +5 -3
  567. package/build/dist/Server/Utils/Monitor/MonitorResourceContext.js.map +1 -1
  568. package/build/dist/Server/Utils/Monitor/MonitorStepResourceIdentity.js +22 -9
  569. package/build/dist/Server/Utils/Monitor/MonitorStepResourceIdentity.js.map +1 -1
  570. package/build/dist/Server/Utils/Monitor/MonitorTemplateUtil.js +1 -0
  571. package/build/dist/Server/Utils/Monitor/MonitorTemplateUtil.js.map +1 -1
  572. package/build/dist/Server/Utils/Monitor/SeriesResourceLabels.js +21 -0
  573. package/build/dist/Server/Utils/Monitor/SeriesResourceLabels.js.map +1 -1
  574. package/build/dist/Server/Utils/Monitor/SeriesResourceLinker.js +21 -6
  575. package/build/dist/Server/Utils/Monitor/SeriesResourceLinker.js.map +1 -1
  576. package/build/dist/Server/Utils/ResourceFeed/ResourceFeedUtil.js +3 -3
  577. package/build/dist/Server/Utils/SecurityEvent/ConnectorErrorMessage.js +9 -9
  578. package/build/dist/Server/Utils/SecurityEvent/ConnectorErrorMessage.js.map +1 -1
  579. package/build/dist/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsClient.js +92 -71
  580. package/build/dist/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsClient.js.map +1 -1
  581. package/build/dist/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsPoller.js +428 -143
  582. package/build/dist/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsPoller.js.map +1 -1
  583. package/build/dist/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsRunExecutor.js +376 -0
  584. package/build/dist/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsRunExecutor.js.map +1 -0
  585. package/build/dist/Server/Utils/Telemetry/EntityRegistry.js +5 -0
  586. package/build/dist/Server/Utils/Telemetry/EntityRegistry.js.map +1 -1
  587. package/build/dist/Server/Utils/Telemetry/ResourceHeartbeat.js.map +1 -1
  588. package/build/dist/Server/Utils/Telemetry/TelemetryEntity.js +136 -1
  589. package/build/dist/Server/Utils/Telemetry/TelemetryEntity.js.map +1 -1
  590. package/build/dist/Server/Utils/Telemetry/VMwareSnapshotScan.js +933 -0
  591. package/build/dist/Server/Utils/Telemetry/VMwareSnapshotScan.js.map +1 -0
  592. package/build/dist/Types/AI/CodeFixTaskContext.js +40 -0
  593. package/build/dist/Types/AI/CodeFixTaskContext.js.map +1 -1
  594. package/build/dist/Types/AI/CodeFixTaskType.js +57 -0
  595. package/build/dist/Types/AI/CodeFixTaskType.js.map +1 -1
  596. package/build/dist/Types/Accounts/AccountsLanguage.js +1 -0
  597. package/build/dist/Types/Accounts/AccountsLanguage.js.map +1 -1
  598. package/build/dist/Types/AdminDashboard/AdminDashboardLanguage.js +1 -0
  599. package/build/dist/Types/AdminDashboard/AdminDashboardLanguage.js.map +1 -1
  600. package/build/dist/Types/Cloud/CloudPlatform.js +277 -0
  601. package/build/dist/Types/Cloud/CloudPlatform.js.map +1 -0
  602. package/build/dist/Types/CodeRepository/GitHubCommand.js +52 -0
  603. package/build/dist/Types/CodeRepository/GitHubCommand.js.map +1 -0
  604. package/build/dist/Types/Dashboard/DashboardComponentType.js +2 -0
  605. package/build/dist/Types/Dashboard/DashboardComponentType.js.map +1 -1
  606. package/build/dist/Types/Dashboard/DashboardComponents/ComponentArgument.js +1 -0
  607. package/build/dist/Types/Dashboard/DashboardComponents/ComponentArgument.js.map +1 -1
  608. package/build/dist/Types/Dashboard/DashboardComponents/DashboardVMwareHostListComponent.js +2 -0
  609. package/build/dist/Types/Dashboard/DashboardComponents/DashboardVMwareHostListComponent.js.map +1 -0
  610. package/build/dist/Types/Dashboard/DashboardComponents/DashboardVMwareVirtualMachineListComponent.js +2 -0
  611. package/build/dist/Types/Dashboard/DashboardComponents/DashboardVMwareVirtualMachineListComponent.js.map +1 -0
  612. package/build/dist/Types/Dashboard/DashboardLanguage.js +1 -0
  613. package/build/dist/Types/Dashboard/DashboardLanguage.js.map +1 -1
  614. package/build/dist/Types/Dashboard/DashboardTemplates.js +286 -0
  615. package/build/dist/Types/Dashboard/DashboardTemplates.js.map +1 -1
  616. package/build/dist/Types/Docs/DocsLanguage.js +1 -0
  617. package/build/dist/Types/Docs/DocsLanguage.js.map +1 -1
  618. package/build/dist/Types/Exception/EgressGuardException.js +59 -0
  619. package/build/dist/Types/Exception/EgressGuardException.js.map +1 -0
  620. package/build/dist/Types/Icon/IconProp.js +1 -0
  621. package/build/dist/Types/Icon/IconProp.js.map +1 -1
  622. package/build/dist/Types/Monitor/MonitorCriteriaInstance.js +1 -0
  623. package/build/dist/Types/Monitor/MonitorCriteriaInstance.js.map +1 -1
  624. package/build/dist/Types/Monitor/MonitorStep.js +61 -18
  625. package/build/dist/Types/Monitor/MonitorStep.js.map +1 -1
  626. package/build/dist/Types/Monitor/MonitorStepMetricViewConfigUtil.js +1 -0
  627. package/build/dist/Types/Monitor/MonitorStepMetricViewConfigUtil.js.map +1 -1
  628. package/build/dist/Types/Monitor/MonitorStepVMwareMonitor.js +71 -0
  629. package/build/dist/Types/Monitor/MonitorStepVMwareMonitor.js.map +1 -0
  630. package/build/dist/Types/Monitor/MonitorTemplateSyncField.js +211 -0
  631. package/build/dist/Types/Monitor/MonitorTemplateSyncField.js.map +1 -0
  632. package/build/dist/Types/Monitor/MonitorType.js +23 -0
  633. package/build/dist/Types/Monitor/MonitorType.js.map +1 -1
  634. package/build/dist/Types/Monitor/Recommendation/MonitorRecommendationCatalog.js +28 -0
  635. package/build/dist/Types/Monitor/Recommendation/MonitorRecommendationCatalog.js.map +1 -1
  636. package/build/dist/Types/Monitor/Recommendation/MonitorRecommendationTypes.js +1 -0
  637. package/build/dist/Types/Monitor/Recommendation/MonitorRecommendationTypes.js.map +1 -1
  638. package/build/dist/Types/Monitor/Recommendation/MonitorRecommendationUtil.js +2 -0
  639. package/build/dist/Types/Monitor/Recommendation/MonitorRecommendationUtil.js.map +1 -1
  640. package/build/dist/Types/Monitor/SeriesContext/SeriesDebugHints.js +120 -0
  641. package/build/dist/Types/Monitor/SeriesContext/SeriesDebugHints.js.map +1 -1
  642. package/build/dist/Types/Monitor/SeriesContext/SeriesLabelDisplay.js +60 -0
  643. package/build/dist/Types/Monitor/SeriesContext/SeriesLabelDisplay.js.map +1 -1
  644. package/build/dist/Types/Monitor/VMwareAlertTemplates.js +775 -0
  645. package/build/dist/Types/Monitor/VMwareAlertTemplates.js.map +1 -0
  646. package/build/dist/Types/Monitor/VMwareMetricCatalog.js +799 -0
  647. package/build/dist/Types/Monitor/VMwareMetricCatalog.js.map +1 -0
  648. package/build/dist/Types/OnCallDutyPolicy/ScheduleShiftUtil.js +25 -0
  649. package/build/dist/Types/OnCallDutyPolicy/ScheduleShiftUtil.js.map +1 -1
  650. package/build/dist/Types/OnCallDutyPolicy/UserOverrideUtil.js +5 -0
  651. package/build/dist/Types/OnCallDutyPolicy/UserOverrideUtil.js.map +1 -1
  652. package/build/dist/Types/Password.js +63 -5
  653. package/build/dist/Types/Password.js.map +1 -1
  654. package/build/dist/Types/Permission.js +234 -0
  655. package/build/dist/Types/Permission.js.map +1 -1
  656. package/build/dist/Types/Probe/RequestFailedDetails.js +7 -0
  657. package/build/dist/Types/Probe/RequestFailedDetails.js.map +1 -1
  658. package/build/dist/Types/SecurityEvent/GoogleSecOpsDiagnostics.js +2 -0
  659. package/build/dist/Types/SecurityEvent/GoogleSecOpsDiagnostics.js.map +1 -0
  660. package/build/dist/Types/StatusPage/StatusPageLanguage.js +1 -0
  661. package/build/dist/Types/StatusPage/StatusPageLanguage.js.map +1 -1
  662. package/build/dist/Types/Telemetry/EntityType.js +21 -0
  663. package/build/dist/Types/Telemetry/EntityType.js.map +1 -1
  664. package/build/dist/Types/Telemetry/ServiceType.js +1 -0
  665. package/build/dist/Types/Telemetry/ServiceType.js.map +1 -1
  666. package/build/dist/UI/Components/Breadcrumbs/Breadcrumbs.js +2 -2
  667. package/build/dist/UI/Components/Breadcrumbs/Breadcrumbs.js.map +1 -1
  668. package/build/dist/UI/Components/Calendar/Calendar.js +24 -4
  669. package/build/dist/UI/Components/Calendar/Calendar.js.map +1 -1
  670. package/build/dist/UI/Components/Forms/BasicForm.js +28 -3
  671. package/build/dist/UI/Components/Forms/BasicForm.js.map +1 -1
  672. package/build/dist/UI/Components/Forms/Fields/ColorPicker.js +1 -1
  673. package/build/dist/UI/Components/Forms/Fields/ColorPicker.js.map +1 -1
  674. package/build/dist/UI/Components/Forms/Fields/FormField.js +10 -3
  675. package/build/dist/UI/Components/Forms/Fields/FormField.js.map +1 -1
  676. package/build/dist/UI/Components/Forms/ModelForm.js +89 -6
  677. package/build/dist/UI/Components/Forms/ModelForm.js.map +1 -1
  678. package/build/dist/UI/Components/Graphs/DayUptimeGraph.js +5 -6
  679. package/build/dist/UI/Components/Graphs/DayUptimeGraph.js.map +1 -1
  680. package/build/dist/UI/Components/Icon/Icon.js +14 -0
  681. package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
  682. package/build/dist/UI/Components/Input/Input.js +37 -8
  683. package/build/dist/UI/Components/Input/Input.js.map +1 -1
  684. package/build/dist/UI/Components/LabelRule/ImportLabelRulesModal.js +228 -0
  685. package/build/dist/UI/Components/LabelRule/ImportLabelRulesModal.js.map +1 -0
  686. package/build/dist/UI/Components/LabelRule/LabelRuleTable.js +102 -0
  687. package/build/dist/UI/Components/LabelRule/LabelRuleTable.js.map +1 -0
  688. package/build/dist/UI/Components/ModelTable/BaseModelTable.js +15 -2
  689. package/build/dist/UI/Components/ModelTable/BaseModelTable.js.map +1 -1
  690. package/build/dist/UI/Components/ModelTable/ModelTable.js +13 -5
  691. package/build/dist/UI/Components/ModelTable/ModelTable.js.map +1 -1
  692. package/build/dist/UI/Components/MonitorGraphs/Uptime.js +14 -15
  693. package/build/dist/UI/Components/MonitorGraphs/Uptime.js.map +1 -1
  694. package/build/dist/UI/Components/MonitorTemplateVariables/TemplateVariablesCatalog.js +2 -0
  695. package/build/dist/UI/Components/MonitorTemplateVariables/TemplateVariablesCatalog.js.map +1 -1
  696. package/build/dist/UI/Components/Tooltip/Tooltip.js +33 -4
  697. package/build/dist/UI/Components/Tooltip/Tooltip.js.map +1 -1
  698. package/build/dist/UI/Utils/DashboardStackingLayers.js +44 -0
  699. package/build/dist/UI/Utils/DashboardStackingLayers.js.map +1 -0
  700. package/build/dist/UI/Utils/LabelRuleImportExport.js +195 -0
  701. package/build/dist/UI/Utils/LabelRuleImportExport.js.map +1 -0
  702. package/build/dist/UI/Utils/ModelAPI/ModelAPI.js +4 -4
  703. package/build/dist/UI/Utils/ModelAPI/ModelAPI.js.map +1 -1
  704. package/build/dist/UI/Utils/TelemetryService.js +3 -2
  705. package/build/dist/UI/Utils/TelemetryService.js.map +1 -1
  706. package/build/dist/UI/Utils/UseDashboardGridDnd.js +2 -1
  707. package/build/dist/UI/Utils/UseDashboardGridDnd.js.map +1 -1
  708. package/build/dist/UI/Utils/UserEmailRegistrationStatus.js +21 -4
  709. package/build/dist/UI/Utils/UserEmailRegistrationStatus.js.map +1 -1
  710. package/build/dist/UI/Utils/WebAuthn.js +121 -0
  711. package/build/dist/UI/Utils/WebAuthn.js.map +1 -0
  712. package/build/dist/Utils/API.js +29 -0
  713. package/build/dist/Utils/API.js.map +1 -1
  714. package/build/dist/Utils/Dashboard/Components/DashboardVMwareHostListComponent.js +33 -0
  715. package/build/dist/Utils/Dashboard/Components/DashboardVMwareHostListComponent.js.map +1 -0
  716. package/build/dist/Utils/Dashboard/Components/DashboardVMwareResourceListShared.js +54 -0
  717. package/build/dist/Utils/Dashboard/Components/DashboardVMwareResourceListShared.js.map +1 -0
  718. package/build/dist/Utils/Dashboard/Components/DashboardVMwareVirtualMachineListComponent.js +60 -0
  719. package/build/dist/Utils/Dashboard/Components/DashboardVMwareVirtualMachineListComponent.js.map +1 -0
  720. package/build/dist/Utils/Dashboard/Components/Index.js +8 -0
  721. package/build/dist/Utils/Dashboard/Components/Index.js.map +1 -1
  722. package/build/dist/Utils/LabelRuleImportExport.js +356 -0
  723. package/build/dist/Utils/LabelRuleImportExport.js.map +1 -0
  724. package/build/dist/Utils/Monitor/MonitorTemplateSyncUtil.js +110 -0
  725. package/build/dist/Utils/Monitor/MonitorTemplateSyncUtil.js.map +1 -0
  726. package/build/dist/Utils/NetworkDiscovery/DiscoveryScanStatus.js +6 -0
  727. package/build/dist/Utils/NetworkDiscovery/DiscoveryScanStatus.js.map +1 -1
  728. package/build/dist/Utils/Telemetry/CloudInstanceIdentity.js +88 -0
  729. package/build/dist/Utils/Telemetry/CloudInstanceIdentity.js.map +1 -0
  730. package/build/dist/Utils/Telemetry/EntityKey.js +15 -0
  731. package/build/dist/Utils/Telemetry/EntityKey.js.map +1 -1
  732. package/build/dist/Utils/Telemetry/EntityRelationship.js +13 -0
  733. package/build/dist/Utils/Telemetry/EntityRelationship.js.map +1 -1
  734. package/package.json +1 -1
@@ -0,0 +1,1748 @@
1
+ import {
2
+ VMWARE_SNAPSHOT_METRIC_NAMES,
3
+ VMwareResourceBufferEntry,
4
+ VMwareResourceIdentity,
5
+ VMwareResourceLatestMetricSnapshot,
6
+ VMwareVCenterSnapshotBufferEntry,
7
+ VMwareVCenterSnapshotExtras,
8
+ boundVMwareExternalId,
9
+ bufferVMwareSnapshotMetric,
10
+ computeVMwareIsPoweredOn,
11
+ deriveVMwareResourceLatestMetric,
12
+ deriveVMwareVCenterSnapshotExtras,
13
+ getOrCreateVMwareVCenterSnapshot,
14
+ resolveVMwareResourceIdentity,
15
+ toVMwareResourceAttributeMap,
16
+ } from "../../../../Server/Utils/Telemetry/VMwareSnapshotScan";
17
+ import ColumnLength from "../../../../Types/Database/ColumnLength";
18
+ import { JSONArray, JSONObject } from "../../../../Types/JSON";
19
+ import { VMwareResourceKind } from "../../../../Types/Monitor/MonitorStepVMwareMonitor";
20
+ import crypto from "crypto";
21
+
22
+ /*
23
+ * The VMware snapshot scan, fed with synthetic OTLP datapoints in the
24
+ * exact JSON shape the vcenter receiver emits through the OTLP decode
25
+ * (asInt/asDouble + timeUnixNano + a key/value attribute array whose
26
+ * values are stringValue / boolValue) plus the RESOURCE attribute map
27
+ * the ingest service resolves per resource block. Locks in:
28
+ *
29
+ * - the kind-resolution order and the externalId scheme for every
30
+ * kind (VMs, templates, vApp members, cluster and standalone-host
31
+ * resource pools),
32
+ * - identity first-non-null-wins / metric newest-observedAt-wins,
33
+ * - the summed-count fold across attribute fan-out (newer timestamp
34
+ * resets, equal adds, older ignored),
35
+ * - the unit conversions (MiBy → bytes, used + available, derived
36
+ * memory capacity fallbacks),
37
+ * - powered-on inference from the presence of vcenter.vm.cpu.*,
38
+ * - the never-zero-a-count-on-a-partial-batch contract for the
39
+ * vCenter extras,
40
+ * - the 100-char externalId bound (prefix + "~" + 16-hex sha1 of the
41
+ * full id) that keeps two long inventory paths from ever clamping
42
+ * to the same unique-index key downstream,
43
+ * - non-allow-listed / non-finite / kind-mismatched points never
44
+ * reaching the inventory fold.
45
+ */
46
+
47
+ const VCENTER: string = "0a1b2c3d-0000-0000-0000-000000000001";
48
+
49
+ // 2023-11-14T22:13:20.000Z — an arbitrary fixed collection instant.
50
+ const BASE_MS: number = 1700000000000;
51
+
52
+ const MIB: number = 1024 * 1024;
53
+
54
+ type LabelMap = Record<string, string | boolean>;
55
+
56
+ function toNano(ms: number): string {
57
+ return `${ms}000000`;
58
+ }
59
+
60
+ function datapoint(data: {
61
+ value: number;
62
+ atMs?: number;
63
+ labels?: LabelMap;
64
+ asDouble?: boolean;
65
+ }): JSONObject {
66
+ const attributes: Array<JSONObject> = Object.entries(data.labels || {}).map(
67
+ ([key, value]: [string, string | boolean]) => {
68
+ return {
69
+ key,
70
+ value:
71
+ typeof value === "boolean"
72
+ ? { boolValue: value }
73
+ : { stringValue: value },
74
+ };
75
+ },
76
+ );
77
+ return {
78
+ ...(data.asDouble ? { asDouble: data.value } : { asInt: data.value }),
79
+ timeUnixNano: toNano(data.atMs ?? BASE_MS),
80
+ attributes,
81
+ };
82
+ }
83
+
84
+ // The resource attribute shapes the vcenter receiver emits per object.
85
+ const DC: Record<string, string> = { "vcenter.datacenter.name": "DC1" };
86
+ const CLUSTER: Record<string, string> = {
87
+ ...DC,
88
+ "vcenter.cluster.name": "Prod-Cluster",
89
+ };
90
+ const HOST: Record<string, string> = {
91
+ ...CLUSTER,
92
+ "vcenter.host.name": "esx01.example.com",
93
+ };
94
+ const STANDALONE_HOST: Record<string, string> = {
95
+ ...DC,
96
+ "vcenter.host.name": "esx-edge.example.com",
97
+ };
98
+ const VM_ON: Record<string, string> = {
99
+ ...HOST,
100
+ "vcenter.vm.name": "web-01",
101
+ "vcenter.vm.id": "5030a1b2-0000-4000-8000-000000000001",
102
+ "vcenter.resource_pool.name": "Web",
103
+ "vcenter.resource_pool.inventory_path":
104
+ "/DC1/host/Prod-Cluster/Resources/Web",
105
+ };
106
+ const VM_OFF: Record<string, string> = {
107
+ ...HOST,
108
+ "vcenter.vm.name": "batch-02",
109
+ "vcenter.vm.id": "5030a1b2-0000-4000-8000-000000000002",
110
+ "vcenter.virtual_app.name": "Batch vApp",
111
+ "vcenter.virtual_app.inventory_path":
112
+ "/DC1/host/Prod-Cluster/Resources/Batch vApp",
113
+ };
114
+ const TEMPLATE: Record<string, string> = {
115
+ ...HOST,
116
+ "vcenter.vm_template.name": "ubuntu-22.04-template",
117
+ "vcenter.vm_template.id": "5030a1b2-0000-4000-8000-0000000000aa",
118
+ };
119
+ const DATASTORE: Record<string, string> = {
120
+ ...DC,
121
+ "vcenter.datastore.name": "vsanDatastore",
122
+ };
123
+ const RESOURCE_POOL: Record<string, string> = {
124
+ ...CLUSTER,
125
+ "vcenter.resource_pool.name": "Web",
126
+ "vcenter.resource_pool.inventory_path":
127
+ "/DC1/host/Prod-Cluster/Resources/Web",
128
+ };
129
+ const STANDALONE_RESOURCE_POOL: Record<string, string> = {
130
+ ...STANDALONE_HOST,
131
+ "vcenter.resource_pool.name": "Resources",
132
+ "vcenter.resource_pool.inventory_path":
133
+ "/DC1/host/esx-edge.example.com/Resources",
134
+ };
135
+
136
+ interface Buffers {
137
+ resourceBuffer: Map<string, Map<string, VMwareResourceBufferEntry>>;
138
+ vcenterBuffer: Map<string, VMwareVCenterSnapshotBufferEntry>;
139
+ }
140
+
141
+ function buffers(): Buffers {
142
+ return { resourceBuffer: new Map(), vcenterBuffer: new Map() };
143
+ }
144
+
145
+ function feed(
146
+ b: Buffers,
147
+ resourceAttributes: Record<string, unknown>,
148
+ metricName: string,
149
+ dp: JSONObject,
150
+ ): void {
151
+ bufferVMwareSnapshotMetric({
152
+ vcenterIdStr: VCENTER,
153
+ metricName,
154
+ resourceAttributes,
155
+ datapoint: dp,
156
+ resourceBuffer: b.resourceBuffer,
157
+ vcenterBuffer: b.vcenterBuffer,
158
+ });
159
+ }
160
+
161
+ function entries(b: Buffers): Array<VMwareResourceBufferEntry> {
162
+ return Array.from(b.resourceBuffer.get(VCENTER)?.values() || []);
163
+ }
164
+
165
+ function entry(
166
+ b: Buffers,
167
+ kind: string,
168
+ externalId: string,
169
+ ): VMwareResourceBufferEntry {
170
+ const found: VMwareResourceBufferEntry | undefined = b.resourceBuffer
171
+ .get(VCENTER)
172
+ ?.get(`${kind}|${externalId}`);
173
+ if (!found) {
174
+ throw new Error(`expected buffered entry ${kind}|${externalId}`);
175
+ }
176
+ return found;
177
+ }
178
+
179
+ function extras(b: Buffers): VMwareVCenterSnapshotExtras {
180
+ return deriveVMwareVCenterSnapshotExtras(
181
+ entries(b),
182
+ b.vcenterBuffer.get(VCENTER),
183
+ );
184
+ }
185
+
186
+ // Feed the whole §3 column table: one resource of each kind.
187
+ function feedFullCollection(b: Buffers, atMs: number = BASE_MS): void {
188
+ // Datacenter
189
+ feed(
190
+ b,
191
+ DC,
192
+ "vcenter.datacenter.cpu.limit",
193
+ datapoint({ value: 96000, atMs }),
194
+ );
195
+ feed(
196
+ b,
197
+ DC,
198
+ "vcenter.datacenter.memory.limit",
199
+ datapoint({ value: 512 * 1024 * MIB, atMs }),
200
+ );
201
+ feed(
202
+ b,
203
+ DC,
204
+ "vcenter.datacenter.disk.space",
205
+ datapoint({ value: 30 * 1024 * MIB, atMs, labels: { disk_state: "used" } }),
206
+ );
207
+ feed(
208
+ b,
209
+ DC,
210
+ "vcenter.datacenter.disk.space",
211
+ datapoint({
212
+ value: 70 * 1024 * MIB,
213
+ atMs,
214
+ labels: { disk_state: "available" },
215
+ }),
216
+ );
217
+ feed(
218
+ b,
219
+ DC,
220
+ "vcenter.datacenter.host.count",
221
+ datapoint({
222
+ value: 3,
223
+ atMs,
224
+ labels: { status: "green", power_state: "on" },
225
+ }),
226
+ );
227
+ feed(
228
+ b,
229
+ DC,
230
+ "vcenter.datacenter.host.count",
231
+ datapoint({
232
+ value: 1,
233
+ atMs,
234
+ labels: { status: "gray", power_state: "off" },
235
+ }),
236
+ );
237
+ feed(
238
+ b,
239
+ DC,
240
+ "vcenter.datacenter.vm.count",
241
+ datapoint({
242
+ value: 40,
243
+ atMs,
244
+ labels: { status: "green", power_state: "on" },
245
+ }),
246
+ );
247
+ feed(
248
+ b,
249
+ DC,
250
+ "vcenter.datacenter.vm.count",
251
+ datapoint({
252
+ value: 5,
253
+ atMs,
254
+ labels: { status: "green", power_state: "off" },
255
+ }),
256
+ );
257
+ feed(
258
+ b,
259
+ DC,
260
+ "vcenter.datacenter.cluster.count",
261
+ datapoint({ value: 1, atMs, labels: { status: "green" } }),
262
+ );
263
+ feed(
264
+ b,
265
+ DC,
266
+ "vcenter.datacenter.cluster.count",
267
+ datapoint({ value: 1, atMs, labels: { status: "yellow" } }),
268
+ );
269
+ feed(
270
+ b,
271
+ DC,
272
+ "vcenter.datacenter.datastore.count",
273
+ datapoint({ value: 4, atMs }),
274
+ );
275
+
276
+ // Cluster
277
+ feed(
278
+ b,
279
+ CLUSTER,
280
+ "vcenter.cluster.cpu.limit",
281
+ datapoint({ value: 64000, atMs }),
282
+ );
283
+ feed(
284
+ b,
285
+ CLUSTER,
286
+ "vcenter.cluster.cpu.effective",
287
+ datapoint({ value: 60000, atMs }),
288
+ );
289
+ feed(
290
+ b,
291
+ CLUSTER,
292
+ "vcenter.cluster.memory.limit",
293
+ datapoint({ value: 256 * 1024 * MIB, atMs }),
294
+ );
295
+ feed(
296
+ b,
297
+ CLUSTER,
298
+ "vcenter.cluster.memory.effective",
299
+ datapoint({ value: 240 * 1024 * MIB, atMs }),
300
+ );
301
+ feed(
302
+ b,
303
+ CLUSTER,
304
+ "vcenter.cluster.host.count",
305
+ datapoint({ value: 2, atMs, labels: { effective: true } }),
306
+ );
307
+ feed(
308
+ b,
309
+ CLUSTER,
310
+ "vcenter.cluster.host.count",
311
+ datapoint({ value: 1, atMs, labels: { effective: false } }),
312
+ );
313
+ feed(
314
+ b,
315
+ CLUSTER,
316
+ "vcenter.cluster.vm.count",
317
+ datapoint({ value: 30, atMs, labels: { power_state: "on" } }),
318
+ );
319
+ feed(
320
+ b,
321
+ CLUSTER,
322
+ "vcenter.cluster.vm.count",
323
+ datapoint({ value: 4, atMs, labels: { power_state: "off" } }),
324
+ );
325
+ feed(
326
+ b,
327
+ CLUSTER,
328
+ "vcenter.cluster.vm.count",
329
+ datapoint({ value: 1, atMs, labels: { power_state: "suspended" } }),
330
+ );
331
+ feed(
332
+ b,
333
+ CLUSTER,
334
+ "vcenter.cluster.vm_template.count",
335
+ datapoint({ value: 2, atMs }),
336
+ );
337
+
338
+ // Host
339
+ feed(
340
+ b,
341
+ HOST,
342
+ "vcenter.host.cpu.utilization",
343
+ datapoint({ value: 42.5, atMs, asDouble: true }),
344
+ );
345
+ feed(b, HOST, "vcenter.host.cpu.usage", datapoint({ value: 13600, atMs }));
346
+ feed(b, HOST, "vcenter.host.cpu.capacity", datapoint({ value: 32000, atMs }));
347
+ feed(b, HOST, "vcenter.host.memory.usage", datapoint({ value: 65536, atMs }));
348
+ feed(
349
+ b,
350
+ HOST,
351
+ "vcenter.host.memory.capacity",
352
+ datapoint({ value: 131072, atMs }),
353
+ );
354
+ feed(
355
+ b,
356
+ HOST,
357
+ "vcenter.host.memory.utilization",
358
+ datapoint({ value: 50, atMs, asDouble: true }),
359
+ );
360
+
361
+ // Powered-on VM
362
+ feed(
363
+ b,
364
+ VM_ON,
365
+ "vcenter.vm.cpu.utilization",
366
+ datapoint({ value: 12.5, atMs, asDouble: true }),
367
+ );
368
+ feed(b, VM_ON, "vcenter.vm.cpu.usage", datapoint({ value: 800, atMs }));
369
+ feed(
370
+ b,
371
+ VM_ON,
372
+ "vcenter.vm.cpu.readiness",
373
+ datapoint({ value: 1.5, atMs, asDouble: true }),
374
+ );
375
+ feed(b, VM_ON, "vcenter.vm.memory.usage", datapoint({ value: 2048, atMs }));
376
+ feed(
377
+ b,
378
+ VM_ON,
379
+ "vcenter.vm.memory.utilization",
380
+ datapoint({ value: 25, atMs, asDouble: true }),
381
+ );
382
+ feed(b, VM_ON, "vcenter.vm.memory.ballooned", datapoint({ value: 0, atMs }));
383
+ feed(b, VM_ON, "vcenter.vm.memory.swapped", datapoint({ value: 0, atMs }));
384
+ feed(
385
+ b,
386
+ VM_ON,
387
+ "vcenter.vm.disk.usage",
388
+ datapoint({ value: 20 * 1024 * MIB, atMs, labels: { disk_state: "used" } }),
389
+ );
390
+ feed(
391
+ b,
392
+ VM_ON,
393
+ "vcenter.vm.disk.usage",
394
+ datapoint({
395
+ value: 80 * 1024 * MIB,
396
+ atMs,
397
+ labels: { disk_state: "available" },
398
+ }),
399
+ );
400
+ feed(
401
+ b,
402
+ VM_ON,
403
+ "vcenter.vm.disk.utilization",
404
+ datapoint({ value: 20, atMs, asDouble: true }),
405
+ );
406
+
407
+ // Powered-off VM (no vcenter.vm.cpu.* points)
408
+ feed(b, VM_OFF, "vcenter.vm.memory.usage", datapoint({ value: 0, atMs }));
409
+ feed(
410
+ b,
411
+ VM_OFF,
412
+ "vcenter.vm.disk.usage",
413
+ datapoint({ value: 10 * 1024 * MIB, atMs, labels: { disk_state: "used" } }),
414
+ );
415
+ feed(
416
+ b,
417
+ VM_OFF,
418
+ "vcenter.vm.disk.usage",
419
+ datapoint({
420
+ value: 30 * 1024 * MIB,
421
+ atMs,
422
+ labels: { disk_state: "available" },
423
+ }),
424
+ );
425
+
426
+ // Template (disk usage only)
427
+ feed(
428
+ b,
429
+ TEMPLATE,
430
+ "vcenter.vm.disk.usage",
431
+ datapoint({ value: 5 * 1024 * MIB, atMs, labels: { disk_state: "used" } }),
432
+ );
433
+
434
+ // Datastore
435
+ feed(
436
+ b,
437
+ DATASTORE,
438
+ "vcenter.datastore.disk.usage",
439
+ datapoint({
440
+ value: 30 * 1024 * MIB,
441
+ atMs,
442
+ labels: { disk_state: "used" },
443
+ }),
444
+ );
445
+ feed(
446
+ b,
447
+ DATASTORE,
448
+ "vcenter.datastore.disk.usage",
449
+ datapoint({
450
+ value: 70 * 1024 * MIB,
451
+ atMs,
452
+ labels: { disk_state: "available" },
453
+ }),
454
+ );
455
+ feed(
456
+ b,
457
+ DATASTORE,
458
+ "vcenter.datastore.disk.utilization",
459
+ datapoint({ value: 30, atMs, asDouble: true }),
460
+ );
461
+
462
+ // Resource pool
463
+ feed(
464
+ b,
465
+ RESOURCE_POOL,
466
+ "vcenter.resource_pool.cpu.usage",
467
+ datapoint({ value: 1200, atMs }),
468
+ );
469
+ feed(
470
+ b,
471
+ RESOURCE_POOL,
472
+ "vcenter.resource_pool.memory.usage",
473
+ datapoint({ value: 4096, atMs, labels: { type: "guest" } }),
474
+ );
475
+ feed(
476
+ b,
477
+ RESOURCE_POOL,
478
+ "vcenter.resource_pool.memory.usage",
479
+ datapoint({ value: 999999, atMs, labels: { type: "host" } }),
480
+ );
481
+ feed(
482
+ b,
483
+ RESOURCE_POOL,
484
+ "vcenter.resource_pool.memory.ballooned",
485
+ datapoint({ value: 16, atMs }),
486
+ );
487
+ feed(
488
+ b,
489
+ RESOURCE_POOL,
490
+ "vcenter.resource_pool.memory.swapped",
491
+ datapoint({ value: 8, atMs }),
492
+ );
493
+ }
494
+
495
+ describe("VMwareSnapshotScan - metric allow-list", () => {
496
+ test("every §3 column source is allow-listed", () => {
497
+ for (const name of [
498
+ "vcenter.host.cpu.utilization",
499
+ "vcenter.host.memory.capacity",
500
+ "vcenter.vm.cpu.readiness",
501
+ "vcenter.vm.disk.usage",
502
+ "vcenter.datastore.disk.utilization",
503
+ "vcenter.cluster.host.count",
504
+ "vcenter.cluster.vm_template.count",
505
+ "vcenter.datacenter.disk.space",
506
+ "vcenter.datacenter.cluster.count",
507
+ "vcenter.resource_pool.memory.swapped",
508
+ ]) {
509
+ expect(VMWARE_SNAPSHOT_METRIC_NAMES.has(name)).toBe(true);
510
+ }
511
+ expect(VMWARE_SNAPSHOT_METRIC_NAMES.size).toBe(35);
512
+ });
513
+
514
+ test("perf-only series are not allow-listed (the ingest gate)", () => {
515
+ // Latency / throughput / packet / vSAN series go to ClickHouse only.
516
+ for (const name of [
517
+ "vcenter.host.disk.latency.max",
518
+ "vcenter.host.network.packet.error.rate",
519
+ "vcenter.vm.network.throughput",
520
+ "vcenter.cluster.vsan.latency.avg",
521
+ "vcenter.host.vsan.congestions",
522
+ "vcenter.resource_pool.cpu.shares",
523
+ "vcenter.vm.memory.granted",
524
+ ]) {
525
+ expect(VMWARE_SNAPSHOT_METRIC_NAMES.has(name)).toBe(false);
526
+ }
527
+ });
528
+
529
+ test("a non-allow-listed metric name never creates an inventory row", () => {
530
+ const b: Buffers = buffers();
531
+ /*
532
+ * Defense in depth: even if the Set gate were bypassed, the fold's
533
+ * metric-name switch drops unknown names.
534
+ */
535
+ feed(b, HOST, "vcenter.host.network.usage", datapoint({ value: 1234 }));
536
+ expect(entries(b)).toHaveLength(0);
537
+ expect(b.vcenterBuffer.size).toBe(0);
538
+ });
539
+
540
+ test("a metric folded onto a resource of the wrong kind is dropped", () => {
541
+ const b: Buffers = buffers();
542
+ // A VM resource also carries vcenter.host.name — host series stay off it.
543
+ feed(b, VM_ON, "vcenter.host.cpu.usage", datapoint({ value: 100 }));
544
+ expect(entries(b)).toHaveLength(0);
545
+ });
546
+ });
547
+
548
+ describe("VMwareSnapshotScan - identity resolution", () => {
549
+ test("toVMwareResourceAttributeMap flattens scalars and drops nested values", () => {
550
+ const attributes: JSONArray = [
551
+ { key: "vcenter.datacenter.name", value: { stringValue: " DC1 " } },
552
+ { key: "effective", value: { boolValue: true } },
553
+ { key: "count", value: { intValue: "7" } },
554
+ { key: "ratio", value: { doubleValue: 0.5 } },
555
+ { key: "nested", value: { kvlistValue: { values: [] } } },
556
+ { key: "", value: { stringValue: "ignored" } },
557
+ { key: "blank", value: { stringValue: " " } },
558
+ ];
559
+ expect(toVMwareResourceAttributeMap(attributes)).toEqual({
560
+ "vcenter.datacenter.name": "DC1",
561
+ effective: "true",
562
+ count: "7",
563
+ ratio: "0.5",
564
+ });
565
+ expect(toVMwareResourceAttributeMap(undefined)).toEqual({});
566
+ });
567
+
568
+ test("a VM resolves first, with the instance UUID as its externalId", () => {
569
+ const identity: VMwareResourceIdentity | null =
570
+ resolveVMwareResourceIdentity(VM_ON);
571
+ expect(identity).toEqual({
572
+ kind: "VirtualMachine",
573
+ externalId: "vm/5030a1b2-0000-4000-8000-000000000001",
574
+ name: "web-01",
575
+ datacenterName: "DC1",
576
+ clusterName: "Prod-Cluster",
577
+ hostName: "esx01.example.com",
578
+ resourcePoolName: "Web",
579
+ resourcePoolPath: "/DC1/host/Prod-Cluster/Resources/Web",
580
+ virtualAppName: null,
581
+ vmInstanceUuid: "5030a1b2-0000-4000-8000-000000000001",
582
+ isTemplate: false,
583
+ });
584
+ });
585
+
586
+ test("a vApp member VM carries the vApp name and its inventory path", () => {
587
+ const identity: VMwareResourceIdentity | null =
588
+ resolveVMwareResourceIdentity(VM_OFF);
589
+ expect(identity?.kind).toBe("VirtualMachine");
590
+ expect(identity?.virtualAppName).toBe("Batch vApp");
591
+ expect(identity?.resourcePoolPath).toBe(
592
+ "/DC1/host/Prod-Cluster/Resources/Batch vApp",
593
+ );
594
+ expect(identity?.resourcePoolName).toBeNull();
595
+ });
596
+
597
+ test("a VM without an instance UUID falls back to vm/<dc>/<host>/<name>", () => {
598
+ const identity: VMwareResourceIdentity | null =
599
+ resolveVMwareResourceIdentity({
600
+ ...HOST,
601
+ "vcenter.vm.name": "legacy-vm",
602
+ });
603
+ expect(identity?.externalId).toBe("vm/DC1/esx01.example.com/legacy-vm");
604
+ expect(identity?.vmInstanceUuid).toBeNull();
605
+ expect(identity?.isTemplate).toBe(false);
606
+ });
607
+
608
+ test("a VM template resolves as a VirtualMachine row with isTemplate=true", () => {
609
+ const identity: VMwareResourceIdentity | null =
610
+ resolveVMwareResourceIdentity(TEMPLATE);
611
+ expect(identity).toMatchObject({
612
+ kind: "VirtualMachine",
613
+ externalId: "vm/5030a1b2-0000-4000-8000-0000000000aa",
614
+ name: "ubuntu-22.04-template",
615
+ hostName: "esx01.example.com",
616
+ vmInstanceUuid: "5030a1b2-0000-4000-8000-0000000000aa",
617
+ isTemplate: true,
618
+ });
619
+ });
620
+
621
+ test("a resource pool resolves before the host it lives on (cluster and standalone)", () => {
622
+ const clusterPool: VMwareResourceIdentity | null =
623
+ resolveVMwareResourceIdentity(RESOURCE_POOL);
624
+ expect(clusterPool).toMatchObject({
625
+ kind: "ResourcePool",
626
+ externalId: "resourcepool//DC1/host/Prod-Cluster/Resources/Web",
627
+ name: "Web",
628
+ clusterName: "Prod-Cluster",
629
+ hostName: null,
630
+ resourcePoolPath: "/DC1/host/Prod-Cluster/Resources/Web",
631
+ isTemplate: null,
632
+ });
633
+
634
+ const standalonePool: VMwareResourceIdentity | null =
635
+ resolveVMwareResourceIdentity(STANDALONE_RESOURCE_POOL);
636
+ expect(standalonePool).toMatchObject({
637
+ kind: "ResourcePool",
638
+ externalId: "resourcepool//DC1/host/esx-edge.example.com/Resources",
639
+ clusterName: null,
640
+ hostName: "esx-edge.example.com",
641
+ });
642
+ });
643
+
644
+ test("hosts resolve in and out of a cluster", () => {
645
+ expect(resolveVMwareResourceIdentity(HOST)).toMatchObject({
646
+ kind: "Host",
647
+ externalId: "host/DC1/esx01.example.com",
648
+ name: "esx01.example.com",
649
+ clusterName: "Prod-Cluster",
650
+ });
651
+ expect(resolveVMwareResourceIdentity(STANDALONE_HOST)).toMatchObject({
652
+ kind: "Host",
653
+ externalId: "host/DC1/esx-edge.example.com",
654
+ clusterName: null,
655
+ });
656
+ });
657
+
658
+ test("datastore, cluster and datacenter resolve by their own name", () => {
659
+ expect(resolveVMwareResourceIdentity(DATASTORE)).toMatchObject({
660
+ kind: "Datastore",
661
+ externalId: "datastore/DC1/vsanDatastore",
662
+ name: "vsanDatastore",
663
+ });
664
+ expect(resolveVMwareResourceIdentity(CLUSTER)).toMatchObject({
665
+ kind: "Cluster",
666
+ externalId: "cluster/DC1/Prod-Cluster",
667
+ name: "Prod-Cluster",
668
+ });
669
+ expect(resolveVMwareResourceIdentity(DC)).toMatchObject({
670
+ kind: "Datacenter",
671
+ externalId: "datacenter/DC1",
672
+ name: "DC1",
673
+ });
674
+ });
675
+
676
+ test("a resource with no vcenter identity is not an inventory row", () => {
677
+ expect(resolveVMwareResourceIdentity({})).toBeNull();
678
+ expect(
679
+ resolveVMwareResourceIdentity({ "vmware.vcenter.name": "vcsa-prod" }),
680
+ ).toBeNull();
681
+ expect(
682
+ resolveVMwareResourceIdentity({ "vcenter.datacenter.name": " " }),
683
+ ).toBeNull();
684
+ });
685
+
686
+ test("the resource.-prefixed spelling resolves identically", () => {
687
+ const prefixed: Record<string, unknown> = {};
688
+ for (const [key, value] of Object.entries(VM_ON)) {
689
+ prefixed[`resource.${key}`] = value;
690
+ }
691
+ expect(resolveVMwareResourceIdentity(prefixed)).toEqual(
692
+ resolveVMwareResourceIdentity(VM_ON),
693
+ );
694
+ });
695
+
696
+ test("a missing path component is dropped rather than left as an empty segment", () => {
697
+ expect(
698
+ resolveVMwareResourceIdentity({
699
+ "vcenter.host.name": "esx-orphan",
700
+ })?.externalId,
701
+ ).toBe("host/esx-orphan");
702
+ });
703
+
704
+ test("externalIds are unique across every kind of one vCenter", () => {
705
+ const ids: Array<string> = [
706
+ DC,
707
+ CLUSTER,
708
+ HOST,
709
+ STANDALONE_HOST,
710
+ VM_ON,
711
+ VM_OFF,
712
+ TEMPLATE,
713
+ DATASTORE,
714
+ RESOURCE_POOL,
715
+ STANDALONE_RESOURCE_POOL,
716
+ ].map((attrs: Record<string, string>) => {
717
+ const identity: VMwareResourceIdentity | null =
718
+ resolveVMwareResourceIdentity(attrs);
719
+ return `${identity?.kind}|${identity?.externalId}`;
720
+ });
721
+ expect(new Set(ids).size).toBe(ids.length);
722
+ });
723
+ });
724
+
725
+ describe("VMwareSnapshotScan - externalId length bound", () => {
726
+ /*
727
+ * vSphere allows 80-char datacenter / cluster / resource-pool names,
728
+ * so a two-level nested pool path easily exceeds the 100-char
729
+ * VMwareResource.externalId column. Two sibling sub-pools under such
730
+ * a path share their first 100 chars — a plain clamp would merge them
731
+ * into one row (or fail the INSERT chunk with Postgres 21000 when
732
+ * both land in the same statement).
733
+ */
734
+ const LONG_DC: string = "Datacenter-Frankfurt-Production";
735
+ const LONG_CLUSTER: string = "Production-Cluster-Tier1";
736
+ const LONG_POOL_PARENT: string = `/${LONG_DC}/host/${LONG_CLUSTER}/Resources/Business-Critical-Workloads`;
737
+ const SIBLING_A_PATH: string = `${LONG_POOL_PARENT}/SAP-HANA`;
738
+ const SIBLING_B_PATH: string = `${LONG_POOL_PARENT}/SAP-APP`;
739
+
740
+ const SIBLING_A: Record<string, string> = {
741
+ "vcenter.datacenter.name": LONG_DC,
742
+ "vcenter.cluster.name": LONG_CLUSTER,
743
+ "vcenter.resource_pool.name": "SAP-HANA",
744
+ "vcenter.resource_pool.inventory_path": SIBLING_A_PATH,
745
+ };
746
+ const SIBLING_B: Record<string, string> = {
747
+ ...SIBLING_A,
748
+ "vcenter.resource_pool.name": "SAP-APP",
749
+ "vcenter.resource_pool.inventory_path": SIBLING_B_PATH,
750
+ };
751
+
752
+ function sha1Prefix(id: string): string {
753
+ return crypto.createHash("sha1").update(id).digest("hex").substring(0, 16);
754
+ }
755
+
756
+ test("the fixture really is the failure case: raw ids exceed 100 chars and share their first 100", () => {
757
+ const rawA: string = `resourcepool/${SIBLING_A_PATH}`;
758
+ const rawB: string = `resourcepool/${SIBLING_B_PATH}`;
759
+ expect(rawA.length).toBeGreaterThan(ColumnLength.ShortText);
760
+ expect(rawB.length).toBeGreaterThan(ColumnLength.ShortText);
761
+ expect(rawA.substring(0, ColumnLength.ShortText)).toBe(
762
+ rawB.substring(0, ColumnLength.ShortText),
763
+ );
764
+ });
765
+
766
+ test("boundVMwareExternalId leaves ids of <= 100 chars untouched", () => {
767
+ expect(
768
+ boundVMwareExternalId("vm/5030a1b2-0000-4000-8000-000000000001"),
769
+ ).toBe("vm/5030a1b2-0000-4000-8000-000000000001");
770
+ expect(
771
+ boundVMwareExternalId(
772
+ "resourcepool//DC1/host/Prod-Cluster/Resources/Web",
773
+ ),
774
+ ).toBe("resourcepool//DC1/host/Prod-Cluster/Resources/Web");
775
+ expect(boundVMwareExternalId("")).toBe("");
776
+
777
+ // Exactly at the bound is still "fits" — no hashing.
778
+ const exactly100: string = "x".repeat(ColumnLength.ShortText);
779
+ expect(boundVMwareExternalId(exactly100)).toBe(exactly100);
780
+ });
781
+
782
+ test("boundVMwareExternalId shortens a long id to <prefix>~<16-hex sha1 of the full id>, exactly 100 chars", () => {
783
+ const raw: string = `resourcepool/${SIBLING_A_PATH}`;
784
+ const bound: string = boundVMwareExternalId(raw);
785
+
786
+ expect(bound).toHaveLength(ColumnLength.ShortText);
787
+ expect(bound).toBe(
788
+ `${raw.substring(0, ColumnLength.ShortText - 1 - 16)}~${sha1Prefix(raw)}`,
789
+ );
790
+ expect(bound).toMatch(/~[0-9a-f]{16}$/);
791
+ // The readable prefix is preserved so the id still says what it is.
792
+ expect(
793
+ bound.startsWith("resourcepool//Datacenter-Frankfurt-Production/host/"),
794
+ ).toBe(true);
795
+ // The hash covers the FULL id, not the clamped prefix.
796
+ expect(
797
+ bound.endsWith(sha1Prefix(raw.substring(0, ColumnLength.ShortText))),
798
+ ).toBe(false);
799
+ });
800
+
801
+ test("the bound id is stable across calls", () => {
802
+ const raw: string = `resourcepool/${SIBLING_A_PATH}`;
803
+ const first: string = boundVMwareExternalId(raw);
804
+ for (let i: number = 0; i < 5; i++) {
805
+ expect(boundVMwareExternalId(raw)).toBe(first);
806
+ }
807
+ // ...and the whole resolver is deterministic for the same attributes.
808
+ expect(resolveVMwareResourceIdentity(SIBLING_A)?.externalId).toBe(first);
809
+ expect(resolveVMwareResourceIdentity({ ...SIBLING_A })?.externalId).toBe(
810
+ first,
811
+ );
812
+ });
813
+
814
+ test("two sibling sub-pools sharing their first 100 chars resolve to distinct <= 100-char ids", () => {
815
+ const a: VMwareResourceIdentity | null =
816
+ resolveVMwareResourceIdentity(SIBLING_A);
817
+ const b: VMwareResourceIdentity | null =
818
+ resolveVMwareResourceIdentity(SIBLING_B);
819
+
820
+ expect(a?.kind).toBe("ResourcePool");
821
+ expect(b?.kind).toBe("ResourcePool");
822
+ expect(a?.externalId.length).toBeLessThanOrEqual(ColumnLength.ShortText);
823
+ expect(b?.externalId.length).toBeLessThanOrEqual(ColumnLength.ShortText);
824
+ expect(a?.externalId).not.toBe(b?.externalId);
825
+ // The same 83-char readable prefix, different hash suffixes.
826
+ expect(a?.externalId.substring(0, 83)).toBe(b?.externalId.substring(0, 83));
827
+
828
+ // The full path is still carried for display in the LongText column.
829
+ expect(a?.resourcePoolPath).toBe(SIBLING_A_PATH);
830
+ expect(b?.resourcePoolPath).toBe(SIBLING_B_PATH);
831
+ expect(a?.name).toBe("SAP-HANA");
832
+ expect(b?.name).toBe("SAP-APP");
833
+ });
834
+
835
+ test("every kind is bound, not just resource pools (host, datastore, cluster, datacenter, VM fallback)", () => {
836
+ const dc: string = "D".repeat(80);
837
+ const long: string = "N".repeat(80);
838
+ const cases: Array<[Record<string, string>, string, string]> = [
839
+ [{ "vcenter.datacenter.name": dc }, "Datacenter", `datacenter/${dc}`],
840
+ [
841
+ { "vcenter.datacenter.name": dc, "vcenter.cluster.name": long },
842
+ "Cluster",
843
+ `cluster/${dc}/${long}`,
844
+ ],
845
+ [
846
+ { "vcenter.datacenter.name": dc, "vcenter.host.name": long },
847
+ "Host",
848
+ `host/${dc}/${long}`,
849
+ ],
850
+ [
851
+ { "vcenter.datacenter.name": dc, "vcenter.datastore.name": long },
852
+ "Datastore",
853
+ `datastore/${dc}/${long}`,
854
+ ],
855
+ [
856
+ {
857
+ "vcenter.datacenter.name": dc,
858
+ "vcenter.host.name": long,
859
+ "vcenter.vm.name": "legacy-vm",
860
+ },
861
+ "VirtualMachine",
862
+ `vm/${dc}/${long}/legacy-vm`,
863
+ ],
864
+ [
865
+ {
866
+ "vcenter.datacenter.name": dc,
867
+ "vcenter.host.name": long,
868
+ "vcenter.vm_template.name": "legacy-template",
869
+ },
870
+ "VirtualMachine",
871
+ `vm/${dc}/${long}/legacy-template`,
872
+ ],
873
+ ];
874
+
875
+ for (const [attrs, kind, raw] of cases) {
876
+ const identity: VMwareResourceIdentity | null =
877
+ resolveVMwareResourceIdentity(attrs);
878
+ expect(identity?.kind).toBe(kind);
879
+ if (raw.length <= ColumnLength.ShortText) {
880
+ expect(identity?.externalId).toBe(raw);
881
+ } else {
882
+ expect(identity?.externalId).toBe(boundVMwareExternalId(raw));
883
+ expect(identity?.externalId).toHaveLength(ColumnLength.ShortText);
884
+ }
885
+ }
886
+
887
+ // A datacenter name alone (80 chars) fits: 11 + 80 = 91 — untouched.
888
+ expect(
889
+ resolveVMwareResourceIdentity({ "vcenter.datacenter.name": dc })
890
+ ?.externalId,
891
+ ).toBe(`datacenter/${dc}`);
892
+ });
893
+
894
+ test("a VM with an instance UUID is never hashed — the UUID form always fits", () => {
895
+ const identity: VMwareResourceIdentity | null =
896
+ resolveVMwareResourceIdentity({
897
+ "vcenter.datacenter.name": "D".repeat(80),
898
+ "vcenter.host.name": "H".repeat(80),
899
+ "vcenter.vm.name": "V".repeat(80),
900
+ "vcenter.vm.id": "5030a1b2-0000-4000-8000-000000000001",
901
+ });
902
+ expect(identity?.externalId).toBe(
903
+ "vm/5030a1b2-0000-4000-8000-000000000001",
904
+ );
905
+ });
906
+
907
+ test("two long sibling pools fold into two buffer rows, and the extras count matches the row count", () => {
908
+ const b: Buffers = buffers();
909
+ feed(
910
+ b,
911
+ SIBLING_A,
912
+ "vcenter.resource_pool.cpu.usage",
913
+ datapoint({ value: 1200 }),
914
+ );
915
+ feed(
916
+ b,
917
+ SIBLING_B,
918
+ "vcenter.resource_pool.cpu.usage",
919
+ datapoint({ value: 300 }),
920
+ );
921
+ // Feed A again so a second point lands on the SAME bound key.
922
+ feed(
923
+ b,
924
+ SIBLING_A,
925
+ "vcenter.resource_pool.memory.usage",
926
+ datapoint({ value: 4096, labels: { type: "guest" } }),
927
+ );
928
+
929
+ const rows: Array<VMwareResourceBufferEntry> = entries(b);
930
+ expect(rows).toHaveLength(2);
931
+ for (const row of rows) {
932
+ expect(row.externalId.length).toBeLessThanOrEqual(ColumnLength.ShortText);
933
+ }
934
+ const ids: Set<string> = new Set(
935
+ rows.map((row: VMwareResourceBufferEntry) => {
936
+ return row.externalId;
937
+ }),
938
+ );
939
+ expect(ids.size).toBe(2);
940
+
941
+ // Each pool kept its own metrics — nothing flip-flopped between them.
942
+ const a: VMwareResourceBufferEntry = entry(
943
+ b,
944
+ "ResourcePool",
945
+ boundVMwareExternalId(`resourcepool/${SIBLING_A_PATH}`),
946
+ );
947
+ const bRow: VMwareResourceBufferEntry = entry(
948
+ b,
949
+ "ResourcePool",
950
+ boundVMwareExternalId(`resourcepool/${SIBLING_B_PATH}`),
951
+ );
952
+ expect(a.latestCpuMhz).toBe(1200);
953
+ expect(a.latestMemoryBytes).toBe(4096 * MIB);
954
+ expect(a.resourcePoolPath).toBe(SIBLING_A_PATH);
955
+ expect(bRow.latestCpuMhz).toBe(300);
956
+ expect(bRow.latestMemoryBytes).toBeNull();
957
+ expect(bRow.resourcePoolPath).toBe(SIBLING_B_PATH);
958
+
959
+ // The vCenter tile and the inventory table now agree: 2 == 2.
960
+ expect(extras(b)).toEqual({ resourcePoolCount: 2 });
961
+ });
962
+ });
963
+
964
+ describe("VMwareSnapshotScan - full-collection fold", () => {
965
+ test("one resource of every kind folds with identity, metrics and counts", () => {
966
+ const b: Buffers = buffers();
967
+ feedFullCollection(b);
968
+
969
+ expect(entries(b)).toHaveLength(8);
970
+
971
+ const dc: VMwareResourceBufferEntry = entry(
972
+ b,
973
+ "Datacenter",
974
+ "datacenter/DC1",
975
+ );
976
+ expect(dc.cpuCapacityMhz).toBe(96000);
977
+ expect(dc.maxMemoryBytes).toBe(512 * 1024 * MIB);
978
+ expect(dc.diskUsedBytes).toBe(30 * 1024 * MIB);
979
+ expect(dc.diskAvailableBytes).toBe(70 * 1024 * MIB);
980
+ expect(dc.hostCount?.value).toBe(4);
981
+ expect(dc.poweredOnHostCount?.value).toBe(3);
982
+ expect(dc.vmCount?.value).toBe(45);
983
+ expect(dc.poweredOnVmCount?.value).toBe(40);
984
+ expect(dc.clusterCount?.value).toBe(2);
985
+ expect(dc.datastoreCount?.value).toBe(4);
986
+
987
+ const cluster: VMwareResourceBufferEntry = entry(
988
+ b,
989
+ "Cluster",
990
+ "cluster/DC1/Prod-Cluster",
991
+ );
992
+ expect(cluster.cpuCapacityMhz).toBe(64000);
993
+ expect(cluster.cpuEffectiveMhz).toBe(60000);
994
+ expect(cluster.maxMemoryBytes).toBe(256 * 1024 * MIB);
995
+ expect(cluster.memoryEffectiveBytes).toBe(240 * 1024 * MIB);
996
+ expect(cluster.hostCount?.value).toBe(3);
997
+ expect(cluster.effectiveHostCount?.value).toBe(2);
998
+ expect(cluster.vmCount?.value).toBe(35);
999
+ expect(cluster.poweredOnVmCount?.value).toBe(30);
1000
+ expect(cluster.vmTemplateCount?.value).toBe(2);
1001
+
1002
+ const host: VMwareResourceBufferEntry = entry(
1003
+ b,
1004
+ "Host",
1005
+ "host/DC1/esx01.example.com",
1006
+ );
1007
+ expect(host.name).toBe("esx01.example.com");
1008
+ expect(host.clusterName).toBe("Prod-Cluster");
1009
+ expect(host.latestCpuPercent).toBe(42.5);
1010
+ expect(host.latestCpuMhz).toBe(13600);
1011
+ expect(host.cpuCapacityMhz).toBe(32000);
1012
+ expect(host.latestMemoryBytes).toBe(65536 * MIB);
1013
+ expect(host.maxMemoryBytes).toBe(131072 * MIB);
1014
+ expect(host.latestMemoryPercent).toBe(50);
1015
+
1016
+ const vmOn: VMwareResourceBufferEntry = entry(
1017
+ b,
1018
+ "VirtualMachine",
1019
+ "vm/5030a1b2-0000-4000-8000-000000000001",
1020
+ );
1021
+ expect(vmOn.name).toBe("web-01");
1022
+ expect(vmOn.hostName).toBe("esx01.example.com");
1023
+ expect(vmOn.resourcePoolName).toBe("Web");
1024
+ expect(vmOn.latestCpuPercent).toBe(12.5);
1025
+ expect(vmOn.latestCpuMhz).toBe(800);
1026
+ expect(vmOn.cpuReadinessPercent).toBe(1.5);
1027
+ expect(vmOn.latestMemoryBytes).toBe(2048 * MIB);
1028
+ expect(vmOn.latestMemoryPercent).toBe(25);
1029
+ expect(vmOn.memoryBalloonedBytes).toBe(0);
1030
+ expect(vmOn.memorySwappedBytes).toBe(0);
1031
+ expect(vmOn.diskUsedBytes).toBe(20 * 1024 * MIB);
1032
+ expect(vmOn.diskAvailableBytes).toBe(80 * 1024 * MIB);
1033
+ expect(vmOn.latestDiskPercent).toBe(20);
1034
+ expect(vmOn.sawCpuMetric).toBe(true);
1035
+ expect(vmOn.sawNonCpuMetric).toBe(true);
1036
+
1037
+ const vmOff: VMwareResourceBufferEntry = entry(
1038
+ b,
1039
+ "VirtualMachine",
1040
+ "vm/5030a1b2-0000-4000-8000-000000000002",
1041
+ );
1042
+ expect(vmOff.virtualAppName).toBe("Batch vApp");
1043
+ expect(vmOff.sawCpuMetric).toBe(false);
1044
+ expect(vmOff.sawNonCpuMetric).toBe(true);
1045
+ expect(vmOff.latestCpuPercent).toBeNull();
1046
+
1047
+ const template: VMwareResourceBufferEntry = entry(
1048
+ b,
1049
+ "VirtualMachine",
1050
+ "vm/5030a1b2-0000-4000-8000-0000000000aa",
1051
+ );
1052
+ expect(template.isTemplate).toBe(true);
1053
+ expect(template.diskUsedBytes).toBe(5 * 1024 * MIB);
1054
+ expect(template.diskAvailableBytes).toBeNull();
1055
+
1056
+ const datastore: VMwareResourceBufferEntry = entry(
1057
+ b,
1058
+ "Datastore",
1059
+ "datastore/DC1/vsanDatastore",
1060
+ );
1061
+ expect(datastore.diskUsedBytes).toBe(30 * 1024 * MIB);
1062
+ expect(datastore.diskAvailableBytes).toBe(70 * 1024 * MIB);
1063
+ expect(datastore.latestDiskPercent).toBe(30);
1064
+
1065
+ const pool: VMwareResourceBufferEntry = entry(
1066
+ b,
1067
+ "ResourcePool",
1068
+ "resourcepool//DC1/host/Prod-Cluster/Resources/Web",
1069
+ );
1070
+ expect(pool.latestCpuMhz).toBe(1200);
1071
+ // type=host is not the pool's guest consumption — ignored.
1072
+ expect(pool.latestMemoryBytes).toBe(4096 * MIB);
1073
+ expect(pool.memoryBalloonedBytes).toBe(16 * MIB);
1074
+ expect(pool.memorySwappedBytes).toBe(8 * MIB);
1075
+
1076
+ const snap: VMwareVCenterSnapshotBufferEntry | undefined =
1077
+ b.vcenterBuffer.get(VCENTER);
1078
+ expect(snap).toEqual({
1079
+ sawDatacenter: true,
1080
+ sawCluster: true,
1081
+ sawHost: true,
1082
+ sawVirtualMachine: true,
1083
+ sawDatastore: true,
1084
+ sawResourcePool: true,
1085
+ });
1086
+ });
1087
+
1088
+ test("identity attributes are first-non-null-wins; a later attribute-less patch never blanks them", () => {
1089
+ const b: Buffers = buffers();
1090
+ feed(
1091
+ b,
1092
+ VM_ON,
1093
+ "vcenter.vm.memory.usage",
1094
+ datapoint({ value: 2048, atMs: BASE_MS }),
1095
+ );
1096
+ // A NEWER point from a receiver build that omitted the pool attributes.
1097
+ const bare: Record<string, string> = {
1098
+ ...HOST,
1099
+ "vcenter.vm.name": "web-01",
1100
+ "vcenter.vm.id": "5030a1b2-0000-4000-8000-000000000001",
1101
+ };
1102
+ feed(
1103
+ b,
1104
+ bare,
1105
+ "vcenter.vm.memory.usage",
1106
+ datapoint({ value: 4096, atMs: BASE_MS + 60_000 }),
1107
+ );
1108
+
1109
+ const vm: VMwareResourceBufferEntry = entry(
1110
+ b,
1111
+ "VirtualMachine",
1112
+ "vm/5030a1b2-0000-4000-8000-000000000001",
1113
+ );
1114
+ expect(vm.resourcePoolName).toBe("Web");
1115
+ expect(vm.resourcePoolPath).toBe("/DC1/host/Prod-Cluster/Resources/Web");
1116
+ expect(vm.latestMemoryBytes).toBe(4096 * MIB);
1117
+ expect(vm.observedAt).toEqual(new Date(BASE_MS + 60_000));
1118
+ });
1119
+
1120
+ test("metric fields are newest-observedAt-wins regardless of arrival order", () => {
1121
+ const b: Buffers = buffers();
1122
+ // Newest point arrives FIRST, then a stale point.
1123
+ feed(
1124
+ b,
1125
+ HOST,
1126
+ "vcenter.host.cpu.utilization",
1127
+ datapoint({ value: 80, atMs: BASE_MS + 60_000, asDouble: true }),
1128
+ );
1129
+ feed(
1130
+ b,
1131
+ HOST,
1132
+ "vcenter.host.cpu.utilization",
1133
+ datapoint({ value: 20, atMs: BASE_MS, asDouble: true }),
1134
+ );
1135
+
1136
+ const host: VMwareResourceBufferEntry = entry(
1137
+ b,
1138
+ "Host",
1139
+ "host/DC1/esx01.example.com",
1140
+ );
1141
+ expect(host.latestCpuPercent).toBe(80);
1142
+ expect(host.observedAt).toEqual(new Date(BASE_MS + 60_000));
1143
+ });
1144
+
1145
+ test("a stale metric point never blanks a field it does not carry", () => {
1146
+ const b: Buffers = buffers();
1147
+ feed(
1148
+ b,
1149
+ HOST,
1150
+ "vcenter.host.cpu.usage",
1151
+ datapoint({ value: 5000, atMs: BASE_MS + 60_000 }),
1152
+ );
1153
+ feed(
1154
+ b,
1155
+ HOST,
1156
+ "vcenter.host.memory.usage",
1157
+ datapoint({ value: 1024, atMs: BASE_MS }),
1158
+ );
1159
+ const host: VMwareResourceBufferEntry = entry(
1160
+ b,
1161
+ "Host",
1162
+ "host/DC1/esx01.example.com",
1163
+ );
1164
+ expect(host.latestCpuMhz).toBe(5000);
1165
+ // Older point → its own field is not taken; nothing else is touched.
1166
+ expect(host.latestMemoryBytes).toBeNull();
1167
+ });
1168
+
1169
+ test("non-finite and missing values are dropped before folding", () => {
1170
+ const b: Buffers = buffers();
1171
+ feed(b, HOST, "vcenter.host.cpu.usage", {
1172
+ asDouble: "Infinity",
1173
+ timeUnixNano: toNano(BASE_MS),
1174
+ attributes: [],
1175
+ } as JSONObject);
1176
+ feed(b, HOST, "vcenter.host.cpu.usage", {
1177
+ asDouble: "NaN",
1178
+ timeUnixNano: toNano(BASE_MS),
1179
+ attributes: [],
1180
+ } as JSONObject);
1181
+ feed(b, HOST, "vcenter.host.cpu.usage", {
1182
+ timeUnixNano: toNano(BASE_MS),
1183
+ attributes: [],
1184
+ } as JSONObject);
1185
+ expect(entries(b)).toHaveLength(0);
1186
+ expect(b.vcenterBuffer.size).toBe(0);
1187
+ });
1188
+
1189
+ test("asInt is read when asDouble is absent, and int64 strings parse", () => {
1190
+ const b: Buffers = buffers();
1191
+ feed(b, HOST, "vcenter.host.cpu.usage", {
1192
+ asInt: "13600",
1193
+ timeUnixNano: toNano(BASE_MS),
1194
+ attributes: [],
1195
+ } as JSONObject);
1196
+ expect(entry(b, "Host", "host/DC1/esx01.example.com").latestCpuMhz).toBe(
1197
+ 13600,
1198
+ );
1199
+ });
1200
+
1201
+ test("MiBy memory series convert to bytes with truncation, never rounding up", () => {
1202
+ const b: Buffers = buffers();
1203
+ feed(
1204
+ b,
1205
+ VM_ON,
1206
+ "vcenter.vm.memory.usage",
1207
+ datapoint({ value: 1.5, asDouble: true }),
1208
+ );
1209
+ feed(
1210
+ b,
1211
+ VM_ON,
1212
+ "vcenter.vm.memory.ballooned",
1213
+ datapoint({ value: 0.0000001, asDouble: true }),
1214
+ );
1215
+ feed(b, VM_ON, "vcenter.vm.memory.swapped", datapoint({ value: -5 }));
1216
+ const vm: VMwareResourceBufferEntry = entry(
1217
+ b,
1218
+ "VirtualMachine",
1219
+ "vm/5030a1b2-0000-4000-8000-000000000001",
1220
+ );
1221
+ expect(vm.latestMemoryBytes).toBe(Math.trunc(1.5 * MIB));
1222
+ expect(vm.memoryBalloonedBytes).toBe(0);
1223
+ expect(vm.memorySwappedBytes).toBe(0);
1224
+ });
1225
+
1226
+ test("a disk_state the receiver does not emit carries no signal", () => {
1227
+ const b: Buffers = buffers();
1228
+ feed(
1229
+ b,
1230
+ DATASTORE,
1231
+ "vcenter.datastore.disk.usage",
1232
+ datapoint({ value: 1, labels: { disk_state: "reserved" } }),
1233
+ );
1234
+ feed(b, DATASTORE, "vcenter.datastore.disk.usage", datapoint({ value: 1 }));
1235
+ expect(entries(b)).toHaveLength(0);
1236
+ });
1237
+
1238
+ test("two vCenters are folded into disjoint buffers", () => {
1239
+ const b: Buffers = buffers();
1240
+ feed(b, HOST, "vcenter.host.cpu.usage", datapoint({ value: 1 }));
1241
+ bufferVMwareSnapshotMetric({
1242
+ vcenterIdStr: "other-vcenter",
1243
+ metricName: "vcenter.host.cpu.usage",
1244
+ resourceAttributes: HOST,
1245
+ datapoint: datapoint({ value: 2 }),
1246
+ resourceBuffer: b.resourceBuffer,
1247
+ vcenterBuffer: b.vcenterBuffer,
1248
+ });
1249
+ expect(entries(b)).toHaveLength(1);
1250
+ expect(
1251
+ b.resourceBuffer
1252
+ .get("other-vcenter")
1253
+ ?.get("Host|host/DC1/esx01.example.com")?.latestCpuMhz,
1254
+ ).toBe(2);
1255
+ expect(
1256
+ getOrCreateVMwareVCenterSnapshot(b.vcenterBuffer, "other-vcenter"),
1257
+ ).toMatchObject({
1258
+ sawHost: true,
1259
+ });
1260
+ });
1261
+ });
1262
+
1263
+ describe("VMwareSnapshotScan - summed counts", () => {
1264
+ test("a count that fans out over attribute values is SUMMED, never newest-wins", () => {
1265
+ const b: Buffers = buffers();
1266
+ feed(
1267
+ b,
1268
+ CLUSTER,
1269
+ "vcenter.cluster.vm.count",
1270
+ datapoint({ value: 30, labels: { power_state: "on" } }),
1271
+ );
1272
+ feed(
1273
+ b,
1274
+ CLUSTER,
1275
+ "vcenter.cluster.vm.count",
1276
+ datapoint({ value: 4, labels: { power_state: "off" } }),
1277
+ );
1278
+ feed(
1279
+ b,
1280
+ CLUSTER,
1281
+ "vcenter.cluster.vm.count",
1282
+ datapoint({ value: 1, labels: { power_state: "suspended" } }),
1283
+ );
1284
+ feed(
1285
+ b,
1286
+ CLUSTER,
1287
+ "vcenter.cluster.vm.count",
1288
+ datapoint({ value: 0, labels: { power_state: "unknown" } }),
1289
+ );
1290
+ const cluster: VMwareResourceBufferEntry = entry(
1291
+ b,
1292
+ "Cluster",
1293
+ "cluster/DC1/Prod-Cluster",
1294
+ );
1295
+ expect(cluster.vmCount?.value).toBe(35);
1296
+ expect(cluster.poweredOnVmCount?.value).toBe(30);
1297
+ });
1298
+
1299
+ test("a newer timestamp resets the sum; an older one is ignored", () => {
1300
+ const b: Buffers = buffers();
1301
+ // Collection 1
1302
+ feed(
1303
+ b,
1304
+ DC,
1305
+ "vcenter.datacenter.host.count",
1306
+ datapoint({ value: 3, atMs: BASE_MS, labels: { power_state: "on" } }),
1307
+ );
1308
+ feed(
1309
+ b,
1310
+ DC,
1311
+ "vcenter.datacenter.host.count",
1312
+ datapoint({ value: 1, atMs: BASE_MS, labels: { power_state: "off" } }),
1313
+ );
1314
+ // Collection 2 (one host powered on since) — arrives in the same batch.
1315
+ feed(
1316
+ b,
1317
+ DC,
1318
+ "vcenter.datacenter.host.count",
1319
+ datapoint({
1320
+ value: 4,
1321
+ atMs: BASE_MS + 120_000,
1322
+ labels: { power_state: "on" },
1323
+ }),
1324
+ );
1325
+ // A straggler from collection 1 arriving last must not add to collection 2.
1326
+ feed(
1327
+ b,
1328
+ DC,
1329
+ "vcenter.datacenter.host.count",
1330
+ datapoint({
1331
+ value: 1,
1332
+ atMs: BASE_MS,
1333
+ labels: { power_state: "standby" },
1334
+ }),
1335
+ );
1336
+ const dc: VMwareResourceBufferEntry = entry(
1337
+ b,
1338
+ "Datacenter",
1339
+ "datacenter/DC1",
1340
+ );
1341
+ expect(dc.hostCount).toEqual({
1342
+ value: 4,
1343
+ observedAt: new Date(BASE_MS + 120_000),
1344
+ });
1345
+ expect(dc.poweredOnHostCount?.value).toBe(4);
1346
+ });
1347
+
1348
+ test("a filtered count resets to 0 when the newest collection has no matching datapoint", () => {
1349
+ const b: Buffers = buffers();
1350
+ feed(
1351
+ b,
1352
+ CLUSTER,
1353
+ "vcenter.cluster.host.count",
1354
+ datapoint({ value: 2, atMs: BASE_MS, labels: { effective: true } }),
1355
+ );
1356
+ // Next collection: every host went into maintenance mode.
1357
+ feed(
1358
+ b,
1359
+ CLUSTER,
1360
+ "vcenter.cluster.host.count",
1361
+ datapoint({
1362
+ value: 2,
1363
+ atMs: BASE_MS + 120_000,
1364
+ labels: { effective: false },
1365
+ }),
1366
+ );
1367
+ const cluster: VMwareResourceBufferEntry = entry(
1368
+ b,
1369
+ "Cluster",
1370
+ "cluster/DC1/Prod-Cluster",
1371
+ );
1372
+ expect(cluster.hostCount?.value).toBe(2);
1373
+ expect(cluster.effectiveHostCount?.value).toBe(0);
1374
+ });
1375
+
1376
+ test("the boolean `effective` dimension is read from boolValue and from its string form", () => {
1377
+ for (const effective of [true, "true"] as Array<boolean | string>) {
1378
+ const b: Buffers = buffers();
1379
+ feed(
1380
+ b,
1381
+ CLUSTER,
1382
+ "vcenter.cluster.host.count",
1383
+ datapoint({ value: 3, labels: { effective } }),
1384
+ );
1385
+ expect(
1386
+ entry(b, "Cluster", "cluster/DC1/Prod-Cluster").effectiveHostCount
1387
+ ?.value,
1388
+ ).toBe(3);
1389
+ }
1390
+ });
1391
+
1392
+ test("fractional or negative count values are clamped to whole non-negative numbers", () => {
1393
+ const b: Buffers = buffers();
1394
+ feed(
1395
+ b,
1396
+ DC,
1397
+ "vcenter.datacenter.datastore.count",
1398
+ datapoint({ value: 3.9, asDouble: true }),
1399
+ );
1400
+ feed(b, DC, "vcenter.datacenter.cluster.count", datapoint({ value: -1 }));
1401
+ const dc: VMwareResourceBufferEntry = entry(
1402
+ b,
1403
+ "Datacenter",
1404
+ "datacenter/DC1",
1405
+ );
1406
+ expect(dc.datastoreCount?.value).toBe(3);
1407
+ expect(dc.clusterCount?.value).toBe(0);
1408
+ });
1409
+ });
1410
+
1411
+ describe("VMwareSnapshotScan - powered-on inference", () => {
1412
+ test("a VM with any vcenter.vm.cpu.* point is powered on", () => {
1413
+ const b: Buffers = buffers();
1414
+ feed(b, VM_ON, "vcenter.vm.cpu.readiness", datapoint({ value: 0 }));
1415
+ expect(
1416
+ computeVMwareIsPoweredOn(
1417
+ entry(b, "VirtualMachine", "vm/5030a1b2-0000-4000-8000-000000000001"),
1418
+ ),
1419
+ ).toBe(true);
1420
+ });
1421
+
1422
+ test("a VM with memory/disk points but no CPU point is powered off", () => {
1423
+ const b: Buffers = buffers();
1424
+ feed(b, VM_OFF, "vcenter.vm.memory.usage", datapoint({ value: 0 }));
1425
+ expect(
1426
+ computeVMwareIsPoweredOn(
1427
+ entry(b, "VirtualMachine", "vm/5030a1b2-0000-4000-8000-000000000002"),
1428
+ ),
1429
+ ).toBe(false);
1430
+ });
1431
+
1432
+ test("CPU evidence is sticky within the batch regardless of point order", () => {
1433
+ const b: Buffers = buffers();
1434
+ feed(b, VM_ON, "vcenter.vm.memory.usage", datapoint({ value: 1 }));
1435
+ feed(b, VM_ON, "vcenter.vm.cpu.usage", datapoint({ value: 1 }));
1436
+ feed(b, VM_ON, "vcenter.vm.disk.utilization", datapoint({ value: 1 }));
1437
+ expect(
1438
+ computeVMwareIsPoweredOn(
1439
+ entry(b, "VirtualMachine", "vm/5030a1b2-0000-4000-8000-000000000001"),
1440
+ ),
1441
+ ).toBe(true);
1442
+ });
1443
+
1444
+ test("a template never gets a power state", () => {
1445
+ const b: Buffers = buffers();
1446
+ feed(
1447
+ b,
1448
+ TEMPLATE,
1449
+ "vcenter.vm.disk.usage",
1450
+ datapoint({ value: 1, labels: { disk_state: "used" } }),
1451
+ );
1452
+ const template: VMwareResourceBufferEntry = entry(
1453
+ b,
1454
+ "VirtualMachine",
1455
+ "vm/5030a1b2-0000-4000-8000-0000000000aa",
1456
+ );
1457
+ expect(template.sawNonCpuMetric).toBe(true);
1458
+ expect(computeVMwareIsPoweredOn(template)).toBeNull();
1459
+ });
1460
+
1461
+ test("non-VM rows never get a power state", () => {
1462
+ const b: Buffers = buffers();
1463
+ feed(b, HOST, "vcenter.host.cpu.usage", datapoint({ value: 1 }));
1464
+ expect(
1465
+ computeVMwareIsPoweredOn(entry(b, "Host", "host/DC1/esx01.example.com")),
1466
+ ).toBeNull();
1467
+ });
1468
+ });
1469
+
1470
+ describe("VMwareSnapshotScan - latest-metric derive", () => {
1471
+ test("maxDiskBytes = used + available and datacenter disk percent is derived", () => {
1472
+ const b: Buffers = buffers();
1473
+ feedFullCollection(b);
1474
+
1475
+ const dc: VMwareResourceLatestMetricSnapshot =
1476
+ deriveVMwareResourceLatestMetric(
1477
+ entry(b, "Datacenter", "datacenter/DC1"),
1478
+ );
1479
+ expect(dc.diskBytes).toBe(30 * 1024 * MIB);
1480
+ expect(dc.maxDiskBytes).toBe(100 * 1024 * MIB);
1481
+ expect(dc.diskPercent).toBeCloseTo(30, 9);
1482
+ expect(dc.hostCount).toBe(4);
1483
+ expect(dc.poweredOnHostCount).toBe(3);
1484
+ expect(dc.vmCount).toBe(45);
1485
+ expect(dc.poweredOnVmCount).toBe(40);
1486
+ expect(dc.clusterCount).toBe(2);
1487
+ expect(dc.datastoreCount).toBe(4);
1488
+ expect(dc.effectiveHostCount).toBeNull();
1489
+ expect(dc.vmTemplateCount).toBeNull();
1490
+
1491
+ const datastore: VMwareResourceLatestMetricSnapshot =
1492
+ deriveVMwareResourceLatestMetric(
1493
+ entry(b, "Datastore", "datastore/DC1/vsanDatastore"),
1494
+ );
1495
+ expect(datastore.maxDiskBytes).toBe(100 * 1024 * MIB);
1496
+ // The receiver's own utilization wins over a derivation.
1497
+ expect(datastore.diskPercent).toBe(30);
1498
+
1499
+ // A template with only `used` has no capacity.
1500
+ const template: VMwareResourceLatestMetricSnapshot =
1501
+ deriveVMwareResourceLatestMetric(
1502
+ entry(b, "VirtualMachine", "vm/5030a1b2-0000-4000-8000-0000000000aa"),
1503
+ );
1504
+ expect(template.diskBytes).toBe(5 * 1024 * MIB);
1505
+ expect(template.maxDiskBytes).toBeNull();
1506
+ });
1507
+
1508
+ test("a reported host memory capacity is used as-is", () => {
1509
+ const b: Buffers = buffers();
1510
+ feedFullCollection(b);
1511
+ const host: VMwareResourceLatestMetricSnapshot =
1512
+ deriveVMwareResourceLatestMetric(
1513
+ entry(b, "Host", "host/DC1/esx01.example.com"),
1514
+ );
1515
+ expect(host.maxMemoryBytes).toBe(131072 * MIB);
1516
+ expect(host.memoryBytes).toBe(65536 * MIB);
1517
+ expect(host.memoryPercent).toBe(50);
1518
+ expect(host.cpuMhz).toBe(13600);
1519
+ expect(host.cpuCapacityMhz).toBe(32000);
1520
+ });
1521
+
1522
+ test("host memory capacity falls back to usage × 100 ÷ utilization when the capacity metric is disabled", () => {
1523
+ const b: Buffers = buffers();
1524
+ feed(b, HOST, "vcenter.host.memory.usage", datapoint({ value: 65536 }));
1525
+ feed(
1526
+ b,
1527
+ HOST,
1528
+ "vcenter.host.memory.utilization",
1529
+ datapoint({ value: 25, asDouble: true }),
1530
+ );
1531
+ const host: VMwareResourceLatestMetricSnapshot =
1532
+ deriveVMwareResourceLatestMetric(
1533
+ entry(b, "Host", "host/DC1/esx01.example.com"),
1534
+ );
1535
+ expect(host.maxMemoryBytes).toBe(65536 * 4 * MIB);
1536
+ });
1537
+
1538
+ test("VM memory capacity is always derived, and stays null when utilization is 0 or absent", () => {
1539
+ const b: Buffers = buffers();
1540
+ feedFullCollection(b);
1541
+ const vmOn: VMwareResourceLatestMetricSnapshot =
1542
+ deriveVMwareResourceLatestMetric(
1543
+ entry(b, "VirtualMachine", "vm/5030a1b2-0000-4000-8000-000000000001"),
1544
+ );
1545
+ expect(vmOn.maxMemoryBytes).toBe(2048 * 4 * MIB);
1546
+ expect(vmOn.cpuReadinessPercent).toBe(1.5);
1547
+ expect(vmOn.memoryBalloonedBytes).toBe(0);
1548
+ expect(vmOn.diskBytes).toBe(20 * 1024 * MIB);
1549
+ expect(vmOn.maxDiskBytes).toBe(100 * 1024 * MIB);
1550
+
1551
+ // Powered-off VM: usage 0 and no utilization → no derivation.
1552
+ const vmOff: VMwareResourceLatestMetricSnapshot =
1553
+ deriveVMwareResourceLatestMetric(
1554
+ entry(b, "VirtualMachine", "vm/5030a1b2-0000-4000-8000-000000000002"),
1555
+ );
1556
+ expect(vmOff.memoryBytes).toBe(0);
1557
+ expect(vmOff.maxMemoryBytes).toBeNull();
1558
+ expect(vmOff.cpuPercent).toBeNull();
1559
+
1560
+ const c: Buffers = buffers();
1561
+ feed(c, VM_ON, "vcenter.vm.memory.usage", datapoint({ value: 100 }));
1562
+ feed(
1563
+ c,
1564
+ VM_ON,
1565
+ "vcenter.vm.memory.utilization",
1566
+ datapoint({ value: 0, asDouble: true }),
1567
+ );
1568
+ expect(
1569
+ deriveVMwareResourceLatestMetric(
1570
+ entry(c, "VirtualMachine", "vm/5030a1b2-0000-4000-8000-000000000001"),
1571
+ ).maxMemoryBytes,
1572
+ ).toBeNull();
1573
+ });
1574
+
1575
+ test("cluster and resource-pool rows map their own columns and leave the rest null", () => {
1576
+ const b: Buffers = buffers();
1577
+ feedFullCollection(b);
1578
+ const cluster: VMwareResourceLatestMetricSnapshot =
1579
+ deriveVMwareResourceLatestMetric(
1580
+ entry(b, "Cluster", "cluster/DC1/Prod-Cluster"),
1581
+ );
1582
+ expect(cluster).toMatchObject({
1583
+ kind: "Cluster",
1584
+ cpuCapacityMhz: 64000,
1585
+ cpuEffectiveMhz: 60000,
1586
+ maxMemoryBytes: 256 * 1024 * MIB,
1587
+ memoryEffectiveBytes: 240 * 1024 * MIB,
1588
+ hostCount: 3,
1589
+ effectiveHostCount: 2,
1590
+ vmCount: 35,
1591
+ poweredOnVmCount: 30,
1592
+ vmTemplateCount: 2,
1593
+ cpuPercent: null,
1594
+ memoryBytes: null,
1595
+ diskBytes: null,
1596
+ poweredOnHostCount: null,
1597
+ clusterCount: null,
1598
+ datastoreCount: null,
1599
+ });
1600
+ // A cluster never derives a memory fallback — its limit IS the capacity.
1601
+ expect(cluster.memoryPercent).toBeNull();
1602
+
1603
+ const pool: VMwareResourceLatestMetricSnapshot =
1604
+ deriveVMwareResourceLatestMetric(
1605
+ entry(
1606
+ b,
1607
+ "ResourcePool",
1608
+ "resourcepool//DC1/host/Prod-Cluster/Resources/Web",
1609
+ ),
1610
+ );
1611
+ expect(pool).toMatchObject({
1612
+ cpuMhz: 1200,
1613
+ memoryBytes: 4096 * MIB,
1614
+ memoryBalloonedBytes: 16 * MIB,
1615
+ memorySwappedBytes: 8 * MIB,
1616
+ maxMemoryBytes: null,
1617
+ cpuPercent: null,
1618
+ });
1619
+ expect(pool.observedAt).toEqual(new Date(BASE_MS));
1620
+ });
1621
+ });
1622
+
1623
+ describe("VMwareSnapshotScan - vCenter extras derive", () => {
1624
+ test("a full collection derives every count from the same folded buffer", () => {
1625
+ const b: Buffers = buffers();
1626
+ feedFullCollection(b);
1627
+ expect(extras(b)).toEqual({
1628
+ datacenterCount: 1,
1629
+ clusterCount: 1,
1630
+ hostCount: 1,
1631
+ // Two VMs; the template is not a VM.
1632
+ vmCount: 2,
1633
+ poweredOnVmCount: 1,
1634
+ datastoreCount: 1,
1635
+ resourcePoolCount: 1,
1636
+ datastoreCapacityBytes: 100 * 1024 * MIB,
1637
+ datastoreUsedBytes: 30 * 1024 * MIB,
1638
+ });
1639
+ });
1640
+
1641
+ test("a partial batch never zeroes a count (no resource of that kind ⇒ key absent)", () => {
1642
+ const b: Buffers = buffers();
1643
+ // Only one host's resource block made it into this batch.
1644
+ feed(b, HOST, "vcenter.host.cpu.usage", datapoint({ value: 100 }));
1645
+ expect(extras(b)).toEqual({ hostCount: 1 });
1646
+ expect(Object.keys(extras(b))).not.toContain("vmCount");
1647
+ expect(Object.keys(extras(b))).not.toContain("datastoreCount");
1648
+ });
1649
+
1650
+ test("an empty buffer derives nothing", () => {
1651
+ const b: Buffers = buffers();
1652
+ expect(extras(b)).toEqual({});
1653
+ expect(deriveVMwareVCenterSnapshotExtras([], undefined)).toEqual({});
1654
+ });
1655
+
1656
+ test("a template-only batch writes vmCount = 0 and poweredOnVmCount = 0 (templates are not VMs)", () => {
1657
+ const b: Buffers = buffers();
1658
+ feed(
1659
+ b,
1660
+ TEMPLATE,
1661
+ "vcenter.vm.disk.usage",
1662
+ datapoint({ value: 1, labels: { disk_state: "used" } }),
1663
+ );
1664
+ expect(extras(b)).toEqual({ vmCount: 0, poweredOnVmCount: 0 });
1665
+ });
1666
+
1667
+ test("all VMs powered off is a legitimate 0, distinct from 'not seen'", () => {
1668
+ const b: Buffers = buffers();
1669
+ feed(b, VM_OFF, "vcenter.vm.memory.usage", datapoint({ value: 0 }));
1670
+ expect(extras(b)).toEqual({ vmCount: 1, poweredOnVmCount: 0 });
1671
+ });
1672
+
1673
+ test("datastore capacity / used totals sum every datastore and are skipped when no datastore carried a disk_state series", () => {
1674
+ const b: Buffers = buffers();
1675
+ feed(
1676
+ b,
1677
+ DATASTORE,
1678
+ "vcenter.datastore.disk.usage",
1679
+ datapoint({ value: 100, labels: { disk_state: "used" } }),
1680
+ );
1681
+ feed(
1682
+ b,
1683
+ DATASTORE,
1684
+ "vcenter.datastore.disk.usage",
1685
+ datapoint({ value: 900, labels: { disk_state: "available" } }),
1686
+ );
1687
+ const second: Record<string, string> = {
1688
+ ...DC,
1689
+ "vcenter.datastore.name": "nfs-backup",
1690
+ };
1691
+ feed(
1692
+ b,
1693
+ second,
1694
+ "vcenter.datastore.disk.usage",
1695
+ datapoint({ value: 50, labels: { disk_state: "used" } }),
1696
+ );
1697
+ feed(
1698
+ b,
1699
+ second,
1700
+ "vcenter.datastore.disk.usage",
1701
+ datapoint({ value: 50, labels: { disk_state: "available" } }),
1702
+ );
1703
+ expect(extras(b)).toEqual({
1704
+ datastoreCount: 2,
1705
+ datastoreCapacityBytes: 1100,
1706
+ datastoreUsedBytes: 150,
1707
+ });
1708
+
1709
+ // Utilization-only datastore points: count yes, byte totals no.
1710
+ const c: Buffers = buffers();
1711
+ feed(
1712
+ c,
1713
+ DATASTORE,
1714
+ "vcenter.datastore.disk.utilization",
1715
+ datapoint({ value: 30, asDouble: true }),
1716
+ );
1717
+ expect(extras(c)).toEqual({ datastoreCount: 1 });
1718
+ });
1719
+
1720
+ test("the extras shape is exactly the VMwareVCenter snapshot columns", () => {
1721
+ const b: Buffers = buffers();
1722
+ feedFullCollection(b);
1723
+ expect(Object.keys(extras(b)).sort()).toEqual(
1724
+ [
1725
+ "clusterCount",
1726
+ "datacenterCount",
1727
+ "datastoreCapacityBytes",
1728
+ "datastoreCount",
1729
+ "datastoreUsedBytes",
1730
+ "hostCount",
1731
+ "poweredOnVmCount",
1732
+ "resourcePoolCount",
1733
+ "vmCount",
1734
+ ].sort(),
1735
+ );
1736
+ });
1737
+
1738
+ test("the kind literals match VMwareResourceKind", () => {
1739
+ const b: Buffers = buffers();
1740
+ feedFullCollection(b);
1741
+ const kinds: Set<string> = new Set(
1742
+ entries(b).map((e: VMwareResourceBufferEntry) => {
1743
+ return e.kind;
1744
+ }),
1745
+ );
1746
+ expect(kinds).toEqual(new Set(Object.values(VMwareResourceKind)));
1747
+ });
1748
+ });