@oneuptime/common 12.0.1 → 12.0.3

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 (385) hide show
  1. package/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel.ts +14 -0
  2. package/Models/DatabaseModels/Host.ts +12 -4
  3. package/Models/DatabaseModels/Index.ts +2 -0
  4. package/Models/DatabaseModels/KubernetesContainer.ts +5 -4
  5. package/Models/DatabaseModels/KubernetesResource.ts +8 -7
  6. package/Models/DatabaseModels/LogDropFilter.ts +9 -20
  7. package/Models/DatabaseModels/PodmanResource.ts +6 -6
  8. package/Models/DatabaseModels/ServiceLevelObjective.ts +91 -0
  9. package/Models/DatabaseModels/StatusPage.ts +95 -0
  10. package/Models/DatabaseModels/StatusPageMonitorRule.ts +911 -0
  11. package/Models/DatabaseModels/StatusPageResource.ts +73 -0
  12. package/Models/DatabaseModels/TraceDropFilter.ts +9 -20
  13. package/Server/API/BaseAPI.ts +13 -2
  14. package/Server/API/DashboardAPI.ts +39 -0
  15. package/Server/API/TeamMemberAPI.ts +85 -0
  16. package/Server/EnvironmentConfig.ts +31 -1
  17. package/Server/Infrastructure/GlobalCache.ts +115 -0
  18. package/Server/Infrastructure/Postgres/DataSourceOptions.ts +16 -0
  19. package/Server/Infrastructure/Postgres/SchemaMigrations/1785900000000-AddSloMonitorLabelRule.ts +84 -0
  20. package/Server/Infrastructure/Postgres/SchemaMigrations/1785915638551-IncreaseHostIpAddressesLength.ts +40 -0
  21. package/Server/Infrastructure/Postgres/SchemaMigrations/1785930000000-WidenInventoryResourceNameColumns.ts +131 -0
  22. package/Server/Infrastructure/Postgres/SchemaMigrations/1785930709405-AddStatusPageReportPeriod.ts +25 -0
  23. package/Server/Infrastructure/Postgres/SchemaMigrations/1786005052769-AddStatusPageMonitorRule.ts +123 -0
  24. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +10 -0
  25. package/Server/Middleware/ProjectAuthorization.ts +66 -4
  26. package/Server/Services/AlertStateTimelineService.ts +20 -0
  27. package/Server/Services/BillingService.ts +600 -51
  28. package/Server/Services/CephClusterService.ts +27 -45
  29. package/Server/Services/CephResourceService.ts +43 -4
  30. package/Server/Services/CloudResourceService.ts +24 -42
  31. package/Server/Services/DatabaseService.ts +198 -6
  32. package/Server/Services/DockerHostService.ts +20 -38
  33. package/Server/Services/DockerResourceService.ts +62 -8
  34. package/Server/Services/DockerSwarmClusterService.ts +28 -46
  35. package/Server/Services/DockerSwarmResourceService.ts +53 -4
  36. package/Server/Services/HostService.ts +47 -57
  37. package/Server/Services/IncidentStateTimelineService.ts +20 -0
  38. package/Server/Services/Index.ts +2 -0
  39. package/Server/Services/IoTDeviceService.ts +1 -17
  40. package/Server/Services/IoTFleetService.ts +20 -38
  41. package/Server/Services/KubernetesClusterService.ts +18 -36
  42. package/Server/Services/KubernetesContainerService.ts +50 -9
  43. package/Server/Services/KubernetesResourceService.ts +53 -7
  44. package/Server/Services/LabelService.ts +153 -1
  45. package/Server/Services/MetricTypeService.ts +84 -0
  46. package/Server/Services/MonitorService.ts +146 -14
  47. package/Server/Services/MonitorStatusTimelineService.ts +29 -0
  48. package/Server/Services/MonitorTemplateService.ts +65 -0
  49. package/Server/Services/PodmanHostService.ts +20 -38
  50. package/Server/Services/PodmanResourceService.ts +62 -8
  51. package/Server/Services/ProjectService.ts +165 -35
  52. package/Server/Services/ProxmoxClusterService.ts +24 -42
  53. package/Server/Services/ProxmoxResourceService.ts +43 -4
  54. package/Server/Services/RumApplicationService.ts +20 -38
  55. package/Server/Services/ScheduledMaintenanceStateTimelineService.ts +21 -0
  56. package/Server/Services/ServerlessFunctionService.ts +25 -43
  57. package/Server/Services/ServiceLevelObjectiveMonitorRuleEngineService.ts +426 -0
  58. package/Server/Services/ServiceLevelObjectiveService.ts +39 -0
  59. package/Server/Services/ServiceService.ts +299 -73
  60. package/Server/Services/StatusPageMonitorRuleEngineService.ts +752 -0
  61. package/Server/Services/StatusPageMonitorRuleService.ts +471 -0
  62. package/Server/Services/StatusPageService.ts +95 -36
  63. package/Server/Services/StatusPageSubscriberNotificationTemplateService.ts +18 -1
  64. package/Server/Services/StatusPageSubscriberService.ts +3 -0
  65. package/Server/Services/TelemetryEntityRelationshipService.ts +1 -0
  66. package/Server/Services/TelemetryEntityService.ts +1 -0
  67. package/Server/Types/Database/JSONColumnQuery.ts +621 -0
  68. package/Server/Types/Database/Permissions/PublicPermission.ts +9 -2
  69. package/Server/Types/Database/QueryHelper.ts +17 -32
  70. package/Server/Utils/Database/ProjectScopedReferenceValidator.ts +170 -39
  71. package/Server/Utils/Database/TruncateColumnValue.ts +84 -0
  72. package/Server/Utils/Monitor/MonitorResource.ts +63 -36
  73. package/Server/Utils/Monitor/MonitorStatusTimeline.ts +36 -0
  74. package/Server/Utils/Monitor/MonitorStepsProjectValidator.ts +148 -127
  75. package/Server/Utils/Monitor/MonitorStepsReferenceExtractor.ts +434 -0
  76. package/Server/Utils/SingleFlight.ts +83 -0
  77. package/Server/Utils/StatusPage/MonitorRulePatternValidator.ts +46 -0
  78. package/Server/Utils/Telemetry/EntityRegistry.ts +107 -26
  79. package/Server/Utils/Telemetry/ResourceHeartbeat.ts +314 -0
  80. package/Server/Utils/Telemetry/Telemetry.ts +351 -122
  81. package/Tests/App/Dashboard/UsersTableGroupsByPerson.test.tsx +448 -0
  82. package/Tests/App/Dashboard/WidgetCatalog.test.ts +2 -0
  83. package/Tests/Models/DatabaseModels/ColumnTransformerInvariants.test.ts +306 -0
  84. package/Tests/Models/DatabaseModels/NumberColumnDeserialization.test.ts +333 -0
  85. package/Tests/Models/DatabaseModels/StatusPageMonitorRuleModel.test.ts +190 -0
  86. package/Tests/Server/API/BaseAPIApiKeyAuth.test.ts +704 -0
  87. package/Tests/Server/API/DashboardPublicResourceListAPI.test.ts +26 -0
  88. package/Tests/Server/API/TeamMemberRemoveUserFromProjectAPI.test.ts +303 -0
  89. package/Tests/Server/Infrastructure/GlobalCache.test.ts +226 -0
  90. package/Tests/Server/Infrastructure/PostgresLockTimeoutOptions.test.ts +181 -0
  91. package/Tests/Server/Middleware/MasterAdminAuthorization.test.ts +350 -0
  92. package/Tests/Server/Middleware/ProjectAuthorizationApiKeyHeader.test.ts +362 -0
  93. package/Tests/Server/Middleware/ProjectAuthorizationApiKeyMiddleware.test.ts +687 -0
  94. package/Tests/Server/Services/BillingService.test.ts +78 -3
  95. package/Tests/Server/Services/BillingServiceChangePlanCancel.test.ts +645 -0
  96. package/Tests/Server/Services/BillingServiceTrialPlanChange.test.ts +1005 -0
  97. package/Tests/Server/Services/DatabaseServiceUpdateColumnsIfUnlocked.test.ts +342 -0
  98. package/Tests/Server/Services/DropFilterSaveValidation.test.ts +245 -0
  99. package/Tests/Server/Services/HookFreeWriteLengthClamp.test.ts +503 -0
  100. package/Tests/Server/Services/HostIpAddressesColumnWidth.test.ts +198 -0
  101. package/Tests/Server/Services/HostServiceUpdateLastSeen.test.ts +658 -0
  102. package/Tests/Server/Services/InventoryResourceNameColumnWidth.test.ts +500 -0
  103. package/Tests/Server/Services/InventoryUpsertSchemaParity.test.ts +586 -0
  104. package/Tests/Server/Services/InventoryUpsertTruncationGuard.test.ts +1242 -0
  105. package/Tests/Server/Services/MetricTypeAttachServices.test.ts +222 -0
  106. package/Tests/Server/Services/MissingReferenceWriteGuard.test.ts +614 -0
  107. package/Tests/Server/Services/MonitorStatusTimelineFastPath.test.ts +23 -0
  108. package/Tests/Server/Services/ProjectServiceChangePlan.test.ts +650 -0
  109. package/Tests/Server/Services/ProjectServiceExtendTrial.test.ts +1 -0
  110. package/Tests/Server/Services/ResourceUpdateLastSeenLivenessFallback.test.ts +636 -0
  111. package/Tests/Server/Services/ServiceLevelObjectiveMonitorRuleEngineService.test.ts +770 -0
  112. package/Tests/Server/Services/ServiceLevelObjectiveService.test.ts +130 -0
  113. package/Tests/Server/Services/ServiceUpdateLastSeenSplitGates.test.ts +705 -0
  114. package/Tests/Server/Services/SloMonitorLabelRuleHooks.test.ts +352 -0
  115. package/Tests/Server/Services/StatusPageMonitorRuleEngineService.test.ts +1719 -0
  116. package/Tests/Server/Services/StatusPageMonitorRuleHooks.test.ts +1212 -0
  117. package/Tests/Server/Services/StatusPageMonitorRuleMonitorCreateHook.test.ts +228 -0
  118. package/Tests/Server/Services/StatusPageSubscriberReport.test.ts +29 -13
  119. package/Tests/Server/TestingUtils/Services/BillingServiceHelper.ts +69 -8
  120. package/Tests/Server/Types/Database/JSONColumnQuery.test.ts +593 -0
  121. package/Tests/Server/Types/Database/Permissions/PublicPermission.test.ts +495 -0
  122. package/Tests/Server/Types/Database/QueryUtil.test.ts +113 -0
  123. package/Tests/Server/Utils/APIKey/AccessPermission.test.ts +267 -0
  124. package/Tests/Server/Utils/Database/ProjectScopedReferenceValidator.test.ts +260 -13
  125. package/Tests/Server/Utils/Database/TruncateColumnValue.test.ts +179 -0
  126. package/Tests/Server/Utils/EntityRegistryRowFence.test.ts +302 -0
  127. package/Tests/Server/Utils/MetricTypeIndexConvergence.test.ts +598 -0
  128. package/Tests/Server/Utils/Monitor/MonitorStatusTimelineUnusableStatus.test.ts +154 -0
  129. package/Tests/Server/Utils/Monitor/MonitorStepsProjectValidator.test.ts +638 -92
  130. package/Tests/Server/Utils/Monitor/MonitorStepsReferenceExtractor.test.ts +724 -0
  131. package/Tests/Server/Utils/SingleFlight.test.ts +221 -0
  132. package/Tests/Types/Dashboard/NetworkDashboardTemplate.test.ts +793 -0
  133. package/Tests/Types/Database/BigIntColumnTransformer.test.ts +147 -0
  134. package/Tests/Types/Database/DatabasePropertyTransformer.test.ts +140 -0
  135. package/Tests/Types/Database/NumericColumnValue.test.ts +127 -0
  136. package/Tests/Types/Decimal.test.ts +37 -0
  137. package/Tests/Types/Events/Recurring.test.ts +157 -0
  138. package/Tests/Types/Monitor/SnmpVersionParsing.test.ts +152 -0
  139. package/Tests/Types/Port.test.ts +38 -0
  140. package/Tests/UI/Components/LogsHistogram.test.tsx +276 -0
  141. package/Tests/UI/Components/ModelTable/ModelTableGroupsProjectUsers.test.tsx +375 -0
  142. package/Tests/UI/Components/ModelTable/useCustomFieldColumns.test.tsx +196 -0
  143. package/Tests/UI/Components/UseLiveLogsRefresh.test.tsx +489 -0
  144. package/Tests/UI/Components/UseLogsHistogram.test.tsx +500 -0
  145. package/Tests/UI/Utils/ProjectUsersModelAPI.test.ts +739 -0
  146. package/Tests/UI/Utils/TeamMembersByUser.test.ts +633 -0
  147. package/Tests/Utils/Dashboard/Components/DashboardComponentsUtil.test.ts +120 -0
  148. package/Tests/Utils/Dashboard/DashboardNetworkMapComponent.test.ts +327 -0
  149. package/Tests/Utils/StatusPage/ReportPeriod.test.ts +218 -0
  150. package/Tests/Utils/Telemetry/HostIpAddresses.test.ts +291 -0
  151. package/Types/CustomField/CustomFieldDefinition.ts +24 -0
  152. package/Types/Dashboard/DashboardComponentType.ts +1 -0
  153. package/Types/Dashboard/DashboardComponents/ComponentArgument.ts +1 -0
  154. package/Types/Dashboard/DashboardComponents/DashboardNetworkMapComponent.ts +40 -0
  155. package/Types/Dashboard/DashboardTemplates.ts +397 -0
  156. package/Types/Database/BigIntColumnTransformer.ts +74 -0
  157. package/Types/Database/DatabaseProperty.ts +26 -0
  158. package/Types/Database/NumericColumnValue.ts +128 -0
  159. package/Types/Date.ts +112 -0
  160. package/Types/Decimal.ts +16 -4
  161. package/Types/Events/Recurring.ts +99 -1
  162. package/Types/Permission.ts +48 -0
  163. package/Types/Port.ts +16 -4
  164. package/Types/StatusPage/StatusPageReport.ts +11 -0
  165. package/Types/StatusPage/StatusPageReportPeriodType.ts +21 -0
  166. package/UI/Components/LogsViewer/useLiveLogsRefresh.ts +86 -0
  167. package/UI/Components/LogsViewer/useLogsHistogram.ts +113 -0
  168. package/UI/Components/ModelTable/CustomFieldColumns.tsx +2 -6
  169. package/UI/Components/ModelTable/useCustomFieldColumns.ts +21 -2
  170. package/UI/Utils/ModelAPI/ProjectUsersModelAPI.ts +305 -0
  171. package/UI/Utils/TeamMembersByUser.ts +302 -0
  172. package/Utils/Dashboard/Components/DashboardNetworkMapComponent.ts +136 -0
  173. package/Utils/Dashboard/Components/Index.ts +7 -0
  174. package/Utils/StatusPage/ReportPeriod.ts +236 -0
  175. package/Utils/Telemetry/HostIpAddresses.ts +98 -0
  176. package/build/dist/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel.js +12 -0
  177. package/build/dist/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel.js.map +1 -1
  178. package/build/dist/Models/DatabaseModels/Host.js +12 -4
  179. package/build/dist/Models/DatabaseModels/Host.js.map +1 -1
  180. package/build/dist/Models/DatabaseModels/Index.js +2 -0
  181. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  182. package/build/dist/Models/DatabaseModels/KubernetesContainer.js +4 -4
  183. package/build/dist/Models/DatabaseModels/KubernetesContainer.js.map +1 -1
  184. package/build/dist/Models/DatabaseModels/KubernetesResource.js +7 -7
  185. package/build/dist/Models/DatabaseModels/KubernetesResource.js.map +1 -1
  186. package/build/dist/Models/DatabaseModels/LogDropFilter.js +9 -20
  187. package/build/dist/Models/DatabaseModels/LogDropFilter.js.map +1 -1
  188. package/build/dist/Models/DatabaseModels/PodmanResource.js +6 -6
  189. package/build/dist/Models/DatabaseModels/PodmanResource.js.map +1 -1
  190. package/build/dist/Models/DatabaseModels/ServiceLevelObjective.js +87 -0
  191. package/build/dist/Models/DatabaseModels/ServiceLevelObjective.js.map +1 -1
  192. package/build/dist/Models/DatabaseModels/StatusPage.js +98 -0
  193. package/build/dist/Models/DatabaseModels/StatusPage.js.map +1 -1
  194. package/build/dist/Models/DatabaseModels/StatusPageMonitorRule.js +925 -0
  195. package/build/dist/Models/DatabaseModels/StatusPageMonitorRule.js.map +1 -0
  196. package/build/dist/Models/DatabaseModels/StatusPageResource.js +72 -0
  197. package/build/dist/Models/DatabaseModels/StatusPageResource.js.map +1 -1
  198. package/build/dist/Models/DatabaseModels/TraceDropFilter.js +9 -20
  199. package/build/dist/Models/DatabaseModels/TraceDropFilter.js.map +1 -1
  200. package/build/dist/Server/API/BaseAPI.js +11 -1
  201. package/build/dist/Server/API/BaseAPI.js.map +1 -1
  202. package/build/dist/Server/API/DashboardAPI.js +39 -0
  203. package/build/dist/Server/API/DashboardAPI.js.map +1 -1
  204. package/build/dist/Server/API/TeamMemberAPI.js +57 -2
  205. package/build/dist/Server/API/TeamMemberAPI.js.map +1 -1
  206. package/build/dist/Server/EnvironmentConfig.js +27 -1
  207. package/build/dist/Server/EnvironmentConfig.js.map +1 -1
  208. package/build/dist/Server/Infrastructure/GlobalCache.js +91 -0
  209. package/build/dist/Server/Infrastructure/GlobalCache.js.map +1 -1
  210. package/build/dist/Server/Infrastructure/Postgres/DataSourceOptions.js +5 -3
  211. package/build/dist/Server/Infrastructure/Postgres/DataSourceOptions.js.map +1 -1
  212. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1785900000000-AddSloMonitorLabelRule.js +45 -0
  213. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1785900000000-AddSloMonitorLabelRule.js.map +1 -0
  214. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1785915638551-IncreaseHostIpAddressesLength.js +31 -0
  215. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1785915638551-IncreaseHostIpAddressesLength.js.map +1 -0
  216. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1785930000000-WidenInventoryResourceNameColumns.js +90 -0
  217. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1785930000000-WidenInventoryResourceNameColumns.js.map +1 -0
  218. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1785930709405-AddStatusPageReportPeriod.js +14 -0
  219. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1785930709405-AddStatusPageReportPeriod.js.map +1 -0
  220. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1786005052769-AddStatusPageMonitorRule.js +48 -0
  221. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1786005052769-AddStatusPageMonitorRule.js.map +1 -0
  222. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +10 -0
  223. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  224. package/build/dist/Server/Middleware/ProjectAuthorization.js +59 -4
  225. package/build/dist/Server/Middleware/ProjectAuthorization.js.map +1 -1
  226. package/build/dist/Server/Services/AlertStateTimelineService.js +19 -0
  227. package/build/dist/Server/Services/AlertStateTimelineService.js.map +1 -1
  228. package/build/dist/Server/Services/BillingService.js +466 -36
  229. package/build/dist/Server/Services/BillingService.js.map +1 -1
  230. package/build/dist/Server/Services/CephClusterService.js +26 -39
  231. package/build/dist/Server/Services/CephClusterService.js.map +1 -1
  232. package/build/dist/Server/Services/CephResourceService.js +28 -3
  233. package/build/dist/Server/Services/CephResourceService.js.map +1 -1
  234. package/build/dist/Server/Services/CloudResourceService.js +23 -36
  235. package/build/dist/Server/Services/CloudResourceService.js.map +1 -1
  236. package/build/dist/Server/Services/DatabaseService.js +155 -2
  237. package/build/dist/Server/Services/DatabaseService.js.map +1 -1
  238. package/build/dist/Server/Services/DockerHostService.js +19 -32
  239. package/build/dist/Server/Services/DockerHostService.js.map +1 -1
  240. package/build/dist/Server/Services/DockerResourceService.js +34 -4
  241. package/build/dist/Server/Services/DockerResourceService.js.map +1 -1
  242. package/build/dist/Server/Services/DockerSwarmClusterService.js +27 -40
  243. package/build/dist/Server/Services/DockerSwarmClusterService.js.map +1 -1
  244. package/build/dist/Server/Services/DockerSwarmResourceService.js +28 -3
  245. package/build/dist/Server/Services/DockerSwarmResourceService.js.map +1 -1
  246. package/build/dist/Server/Services/HostService.js +58 -64
  247. package/build/dist/Server/Services/HostService.js.map +1 -1
  248. package/build/dist/Server/Services/IncidentStateTimelineService.js +19 -0
  249. package/build/dist/Server/Services/IncidentStateTimelineService.js.map +1 -1
  250. package/build/dist/Server/Services/Index.js +2 -0
  251. package/build/dist/Server/Services/Index.js.map +1 -1
  252. package/build/dist/Server/Services/IoTDeviceService.js +1 -8
  253. package/build/dist/Server/Services/IoTDeviceService.js.map +1 -1
  254. package/build/dist/Server/Services/IoTFleetService.js +19 -32
  255. package/build/dist/Server/Services/IoTFleetService.js.map +1 -1
  256. package/build/dist/Server/Services/KubernetesClusterService.js +17 -30
  257. package/build/dist/Server/Services/KubernetesClusterService.js.map +1 -1
  258. package/build/dist/Server/Services/KubernetesContainerService.js +29 -3
  259. package/build/dist/Server/Services/KubernetesContainerService.js.map +1 -1
  260. package/build/dist/Server/Services/KubernetesResourceService.js +32 -4
  261. package/build/dist/Server/Services/KubernetesResourceService.js.map +1 -1
  262. package/build/dist/Server/Services/LabelService.js +127 -0
  263. package/build/dist/Server/Services/LabelService.js.map +1 -1
  264. package/build/dist/Server/Services/MetricTypeService.js +74 -0
  265. package/build/dist/Server/Services/MetricTypeService.js.map +1 -1
  266. package/build/dist/Server/Services/MonitorService.js +128 -9
  267. package/build/dist/Server/Services/MonitorService.js.map +1 -1
  268. package/build/dist/Server/Services/MonitorStatusTimelineService.js +28 -0
  269. package/build/dist/Server/Services/MonitorStatusTimelineService.js.map +1 -1
  270. package/build/dist/Server/Services/MonitorTemplateService.js +60 -0
  271. package/build/dist/Server/Services/MonitorTemplateService.js.map +1 -1
  272. package/build/dist/Server/Services/PodmanHostService.js +19 -32
  273. package/build/dist/Server/Services/PodmanHostService.js.map +1 -1
  274. package/build/dist/Server/Services/PodmanResourceService.js +34 -4
  275. package/build/dist/Server/Services/PodmanResourceService.js.map +1 -1
  276. package/build/dist/Server/Services/ProjectService.js +135 -21
  277. package/build/dist/Server/Services/ProjectService.js.map +1 -1
  278. package/build/dist/Server/Services/ProxmoxClusterService.js +23 -36
  279. package/build/dist/Server/Services/ProxmoxClusterService.js.map +1 -1
  280. package/build/dist/Server/Services/ProxmoxResourceService.js +28 -3
  281. package/build/dist/Server/Services/ProxmoxResourceService.js.map +1 -1
  282. package/build/dist/Server/Services/RumApplicationService.js +19 -32
  283. package/build/dist/Server/Services/RumApplicationService.js.map +1 -1
  284. package/build/dist/Server/Services/ScheduledMaintenanceStateTimelineService.js +20 -0
  285. package/build/dist/Server/Services/ScheduledMaintenanceStateTimelineService.js.map +1 -1
  286. package/build/dist/Server/Services/ServerlessFunctionService.js +24 -37
  287. package/build/dist/Server/Services/ServerlessFunctionService.js.map +1 -1
  288. package/build/dist/Server/Services/ServiceLevelObjectiveMonitorRuleEngineService.js +347 -0
  289. package/build/dist/Server/Services/ServiceLevelObjectiveMonitorRuleEngineService.js.map +1 -0
  290. package/build/dist/Server/Services/ServiceLevelObjectiveService.js +33 -1
  291. package/build/dist/Server/Services/ServiceLevelObjectiveService.js.map +1 -1
  292. package/build/dist/Server/Services/ServiceService.js +236 -61
  293. package/build/dist/Server/Services/ServiceService.js.map +1 -1
  294. package/build/dist/Server/Services/StatusPageMonitorRuleEngineService.js +603 -0
  295. package/build/dist/Server/Services/StatusPageMonitorRuleEngineService.js.map +1 -0
  296. package/build/dist/Server/Services/StatusPageMonitorRuleService.js +401 -0
  297. package/build/dist/Server/Services/StatusPageMonitorRuleService.js.map +1 -0
  298. package/build/dist/Server/Services/StatusPageService.js +69 -46
  299. package/build/dist/Server/Services/StatusPageService.js.map +1 -1
  300. package/build/dist/Server/Services/StatusPageSubscriberNotificationTemplateService.js +17 -1
  301. package/build/dist/Server/Services/StatusPageSubscriberNotificationTemplateService.js.map +1 -1
  302. package/build/dist/Server/Services/StatusPageSubscriberService.js +3 -0
  303. package/build/dist/Server/Services/StatusPageSubscriberService.js.map +1 -1
  304. package/build/dist/Server/Services/TelemetryEntityRelationshipService.js +1 -0
  305. package/build/dist/Server/Services/TelemetryEntityRelationshipService.js.map +1 -1
  306. package/build/dist/Server/Services/TelemetryEntityService.js +1 -0
  307. package/build/dist/Server/Services/TelemetryEntityService.js.map +1 -1
  308. package/build/dist/Server/Types/Database/JSONColumnQuery.js +402 -0
  309. package/build/dist/Server/Types/Database/JSONColumnQuery.js.map +1 -0
  310. package/build/dist/Server/Types/Database/Permissions/PublicPermission.js +9 -2
  311. package/build/dist/Server/Types/Database/Permissions/PublicPermission.js.map +1 -1
  312. package/build/dist/Server/Types/Database/QueryHelper.js +17 -27
  313. package/build/dist/Server/Types/Database/QueryHelper.js.map +1 -1
  314. package/build/dist/Server/Utils/Database/ProjectScopedReferenceValidator.js +105 -29
  315. package/build/dist/Server/Utils/Database/ProjectScopedReferenceValidator.js.map +1 -1
  316. package/build/dist/Server/Utils/Database/TruncateColumnValue.js +32 -0
  317. package/build/dist/Server/Utils/Database/TruncateColumnValue.js.map +1 -0
  318. package/build/dist/Server/Utils/Monitor/MonitorResource.js +56 -32
  319. package/build/dist/Server/Utils/Monitor/MonitorResource.js.map +1 -1
  320. package/build/dist/Server/Utils/Monitor/MonitorStatusTimeline.js +30 -3
  321. package/build/dist/Server/Utils/Monitor/MonitorStatusTimeline.js.map +1 -1
  322. package/build/dist/Server/Utils/Monitor/MonitorStepsProjectValidator.js +110 -98
  323. package/build/dist/Server/Utils/Monitor/MonitorStepsProjectValidator.js.map +1 -1
  324. package/build/dist/Server/Utils/Monitor/MonitorStepsReferenceExtractor.js +312 -0
  325. package/build/dist/Server/Utils/Monitor/MonitorStepsReferenceExtractor.js.map +1 -0
  326. package/build/dist/Server/Utils/SingleFlight.js +76 -0
  327. package/build/dist/Server/Utils/SingleFlight.js.map +1 -0
  328. package/build/dist/Server/Utils/StatusPage/MonitorRulePatternValidator.js +29 -0
  329. package/build/dist/Server/Utils/StatusPage/MonitorRulePatternValidator.js.map +1 -0
  330. package/build/dist/Server/Utils/Telemetry/EntityRegistry.js +78 -19
  331. package/build/dist/Server/Utils/Telemetry/EntityRegistry.js.map +1 -1
  332. package/build/dist/Server/Utils/Telemetry/ResourceHeartbeat.js +160 -0
  333. package/build/dist/Server/Utils/Telemetry/ResourceHeartbeat.js.map +1 -0
  334. package/build/dist/Server/Utils/Telemetry/Telemetry.js +279 -104
  335. package/build/dist/Server/Utils/Telemetry/Telemetry.js.map +1 -1
  336. package/build/dist/Types/CustomField/CustomFieldDefinition.js +2 -0
  337. package/build/dist/Types/CustomField/CustomFieldDefinition.js.map +1 -0
  338. package/build/dist/Types/Dashboard/DashboardComponentType.js +1 -0
  339. package/build/dist/Types/Dashboard/DashboardComponentType.js.map +1 -1
  340. package/build/dist/Types/Dashboard/DashboardComponents/ComponentArgument.js +1 -0
  341. package/build/dist/Types/Dashboard/DashboardComponents/ComponentArgument.js.map +1 -1
  342. package/build/dist/Types/Dashboard/DashboardComponents/DashboardNetworkMapComponent.js +2 -0
  343. package/build/dist/Types/Dashboard/DashboardComponents/DashboardNetworkMapComponent.js.map +1 -0
  344. package/build/dist/Types/Dashboard/DashboardTemplates.js +368 -0
  345. package/build/dist/Types/Dashboard/DashboardTemplates.js.map +1 -1
  346. package/build/dist/Types/Database/BigIntColumnTransformer.js +66 -0
  347. package/build/dist/Types/Database/BigIntColumnTransformer.js.map +1 -0
  348. package/build/dist/Types/Database/DatabaseProperty.js +25 -0
  349. package/build/dist/Types/Database/DatabaseProperty.js.map +1 -1
  350. package/build/dist/Types/Database/NumericColumnValue.js +97 -0
  351. package/build/dist/Types/Database/NumericColumnValue.js.map +1 -0
  352. package/build/dist/Types/Date.js +68 -0
  353. package/build/dist/Types/Date.js.map +1 -1
  354. package/build/dist/Types/Decimal.js +14 -3
  355. package/build/dist/Types/Decimal.js.map +1 -1
  356. package/build/dist/Types/Events/Recurring.js +63 -0
  357. package/build/dist/Types/Events/Recurring.js.map +1 -1
  358. package/build/dist/Types/Permission.js +42 -0
  359. package/build/dist/Types/Permission.js.map +1 -1
  360. package/build/dist/Types/Port.js +15 -5
  361. package/build/dist/Types/Port.js.map +1 -1
  362. package/build/dist/Types/StatusPage/StatusPageReportPeriodType.js +22 -0
  363. package/build/dist/Types/StatusPage/StatusPageReportPeriodType.js.map +1 -0
  364. package/build/dist/UI/Components/LogsViewer/useLiveLogsRefresh.js +44 -0
  365. package/build/dist/UI/Components/LogsViewer/useLiveLogsRefresh.js.map +1 -0
  366. package/build/dist/UI/Components/LogsViewer/useLogsHistogram.js +75 -0
  367. package/build/dist/UI/Components/LogsViewer/useLogsHistogram.js.map +1 -0
  368. package/build/dist/UI/Components/ModelTable/CustomFieldColumns.js.map +1 -1
  369. package/build/dist/UI/Components/ModelTable/useCustomFieldColumns.js +18 -2
  370. package/build/dist/UI/Components/ModelTable/useCustomFieldColumns.js.map +1 -1
  371. package/build/dist/UI/Utils/ModelAPI/ProjectUsersModelAPI.js +213 -0
  372. package/build/dist/UI/Utils/ModelAPI/ProjectUsersModelAPI.js.map +1 -0
  373. package/build/dist/UI/Utils/TeamMembersByUser.js +195 -0
  374. package/build/dist/UI/Utils/TeamMembersByUser.js.map +1 -0
  375. package/build/dist/Utils/Dashboard/Components/DashboardNetworkMapComponent.js +114 -0
  376. package/build/dist/Utils/Dashboard/Components/DashboardNetworkMapComponent.js.map +1 -0
  377. package/build/dist/Utils/Dashboard/Components/Index.js +4 -0
  378. package/build/dist/Utils/Dashboard/Components/Index.js.map +1 -1
  379. package/build/dist/Utils/StatusPage/ReportPeriod.js +131 -0
  380. package/build/dist/Utils/StatusPage/ReportPeriod.js.map +1 -0
  381. package/build/dist/Utils/Telemetry/HostIpAddresses.js +82 -0
  382. package/build/dist/Utils/Telemetry/HostIpAddresses.js.map +1 -0
  383. package/jest.config.json +2 -0
  384. package/package.json +1 -1
  385. package/tsconfig.json +12 -1
@@ -606,6 +606,7 @@ export class ProjectService extends DatabaseService<Model> {
606
606
  subscriptionId: string;
607
607
  meteredSubscriptionId: string;
608
608
  trialEndsAt?: Date | undefined;
609
+ subscriptionIdsPendingCancellation: Array<string>;
609
610
  } = await BillingService.changePlan({
610
611
  projectId: project.id!,
611
612
  subscriptionId: project.paymentProviderSubscriptionId,
@@ -617,36 +618,51 @@ export class ProjectService extends DatabaseService<Model> {
617
618
  endTrialAt: endTrialAt,
618
619
  });
619
620
 
620
- const subscriptionState: SubscriptionStatus =
621
- await BillingService.getSubscriptionStatus(subscription.subscriptionId);
621
+ const subscriptionState: SubscriptionStatus | null =
622
+ await this.findSubscriptionStatus(subscription.subscriptionId);
622
623
 
623
- const meteredSubscriptionState: SubscriptionStatus =
624
- await BillingService.getSubscriptionStatus(
625
- subscription.meteredSubscriptionId,
626
- );
624
+ const meteredSubscriptionState: SubscriptionStatus | null =
625
+ await this.findSubscriptionStatus(subscription.meteredSubscriptionId);
626
+
627
+ const updateData: QueryDeepPartialEntity<Model> = {
628
+ paymentProviderPlanId: params.paymentProviderPlanId,
629
+ paymentProviderSubscriptionId: subscription.subscriptionId,
630
+ paymentProviderMeteredSubscriptionId: subscription.meteredSubscriptionId,
631
+ paymentProviderSubscriptionSeats: seats,
632
+ trialEndsAt: subscription.trialEndsAt || endTrialAt || new Date(),
633
+ planName: SubscriptionPlan.getPlanType(
634
+ params.paymentProviderPlanId,
635
+ getAllEnvVars(),
636
+ ),
637
+ };
638
+
639
+ if (meteredSubscriptionState) {
640
+ updateData.paymentProviderMeteredSubscriptionStatus =
641
+ meteredSubscriptionState;
642
+ }
643
+
644
+ if (subscriptionState) {
645
+ updateData.paymentProviderSubscriptionStatus = subscriptionState;
646
+ }
627
647
 
628
648
  await this.updateOneById({
629
649
  id: project.id!,
630
- data: {
631
- paymentProviderPlanId: params.paymentProviderPlanId,
632
- paymentProviderSubscriptionId: subscription.subscriptionId,
633
- paymentProviderMeteredSubscriptionId:
634
- subscription.meteredSubscriptionId,
635
- paymentProviderSubscriptionSeats: seats,
636
- trialEndsAt: subscription.trialEndsAt || endTrialAt || new Date(),
637
- planName: SubscriptionPlan.getPlanType(
638
- params.paymentProviderPlanId,
639
- getAllEnvVars(),
640
- ),
641
- paymentProviderMeteredSubscriptionStatus: meteredSubscriptionState,
642
- paymentProviderSubscriptionStatus: subscriptionState,
643
- },
650
+ data: updateData,
644
651
  props: {
645
652
  isRoot: true,
646
653
  ignoreHooks: true,
647
654
  },
648
655
  });
649
656
 
657
+ /*
658
+ * Raised after the row is written, because the row is what makes these ids
659
+ * unreachable: it now carries the replacements.
660
+ */
661
+ this.alertOnSubscriptionsPendingCancellation({
662
+ projectId: project.id!,
663
+ subscriptionIds: subscription.subscriptionIdsPendingCancellation,
664
+ });
665
+
650
666
  this.capturePlanChangeAnalytics({
651
667
  project: project,
652
668
  newPlan: plan,
@@ -657,6 +673,103 @@ export class ProjectService extends DatabaseService<Model> {
657
673
  await this.sendSubscriptionChangeWebhookSlackNotification(project.id!);
658
674
  }
659
675
 
676
+ /*
677
+ * Reads a subscription's status back, and gives up rather than throwing.
678
+ *
679
+ * This sits between a plan change returning and the project row being
680
+ * written, and that write is what records the subscription ids the plan
681
+ * change produced. A replacement already exists at the payment provider and
682
+ * is already billing by this point, and the row is the only thing in
683
+ * OneUptime that will ever point at it - so a rate limit or a dropped
684
+ * connection reading a status back must not be what stops it being written
685
+ * down. Worse than the missing status: reactivation is retried from
686
+ * BillingInvoiceService whenever the customer's invoices look settled, so a
687
+ * row left pointing at the old id mints another live subscription every
688
+ * time it runs.
689
+ *
690
+ * The status columns are refreshed daily by
691
+ * PaymentProvider:CheckSubscriptionStatus, so leaving one behind costs a
692
+ * day of staleness. Losing the id costs a subscription nobody can find.
693
+ */
694
+ private async findSubscriptionStatus(
695
+ subscriptionId: string,
696
+ ): Promise<SubscriptionStatus | null> {
697
+ try {
698
+ return await BillingService.getSubscriptionStatus(subscriptionId);
699
+ } catch (err) {
700
+ logger.error(err, { subscriptionId } as LogAttributes);
701
+ return null;
702
+ }
703
+ }
704
+
705
+ /*
706
+ * Raises the subscriptions a plan change replaced but could not cancel.
707
+ *
708
+ * The project row now carries the replacement ids, so these ones exist
709
+ * nowhere in OneUptime any more. They were not billing when the plan change
710
+ * read them and the cancel has already been retried, so this is a loose end
711
+ * rather than a double charge - but it is one nobody will find on their own,
712
+ * which is why the ids travel with the alert instead of only reaching a log
713
+ * line. The replacements also carry them in their payment-provider metadata,
714
+ * as replacedSubscriptionId.
715
+ *
716
+ * Called once the plan change has already been applied and written down, so
717
+ * nothing in here is allowed to throw, and nothing in here is allowed to
718
+ * hold the response open either: failing - or being slow - to raise a loose
719
+ * end must not turn a plan change that worked into one the caller is told
720
+ * failed, or one that never comes back.
721
+ */
722
+ private alertOnSubscriptionsPendingCancellation(data: {
723
+ projectId: ObjectID;
724
+ subscriptionIds: Array<string>;
725
+ }): void {
726
+ if (!data.subscriptionIds || data.subscriptionIds.length === 0) {
727
+ return;
728
+ }
729
+
730
+ logger.error(
731
+ `Could not cancel subscriptions replaced by a plan change for project ${data.projectId.toString()}. They are still open at the payment provider and have to be cancelled by hand: ${data.subscriptionIds.join(
732
+ ", ",
733
+ )}`,
734
+ {
735
+ projectId: data.projectId.toString(),
736
+ } as LogAttributes,
737
+ );
738
+
739
+ if (!NotificationSlackWebhookOnSubscriptionUpdate) {
740
+ return;
741
+ }
742
+
743
+ const slackMessage: string = `*Subscriptions could not be cancelled after a plan change:*
744
+ *Project ID:* ${data.projectId.toString()}
745
+ *Subscriptions still open at the payment provider:* ${data.subscriptionIds.join(", ")}
746
+ These are no longer recorded against the project and have to be cancelled by hand.
747
+ `;
748
+
749
+ /*
750
+ * Delivery is deliberately not awaited, and neither is reading the
751
+ * configured webhook. SlackUtil retries three times with exponential
752
+ * backoff and sets no HTTP timeout, so awaiting it would let a webhook
753
+ * that hangs hold the plan-change response open with it - for a message
754
+ * whose contents are already on the error log above. Same shape as
755
+ * sendSubscriptionChangeWebhookSlackNotification below.
756
+ */
757
+ try {
758
+ SlackUtil.sendMessageToChannelViaIncomingWebhook({
759
+ url: URL.fromString(NotificationSlackWebhookOnSubscriptionUpdate),
760
+ text: slackMessage,
761
+ }).catch((error: Error) => {
762
+ logger.error("Error sending slack message: " + error, {
763
+ projectId: data.projectId.toString(),
764
+ } as LogAttributes);
765
+ });
766
+ } catch (error) {
767
+ logger.error("Error sending slack message: " + error, {
768
+ projectId: data.projectId.toString(),
769
+ } as LogAttributes);
770
+ }
771
+ }
772
+
660
773
  /*
661
774
  * Pushes a project's trial end date out to a new date, in the payment
662
775
  * provider first and then on the project row.
@@ -2224,11 +2337,13 @@ export class ProjectService extends DatabaseService<Model> {
2224
2337
  }
2225
2338
 
2226
2339
  /*
2227
- * Reactivating goes through changePlan, which cancels both subscriptions
2228
- * and creates new ones - so a trial the project still has to run has to be
2229
- * carried onto the replacements explicitly. Otherwise a customer whose
2230
- * trial a master admin extended as a goodwill gesture loses the extension
2231
- * the moment their subscription is reactivated, and is billed right away.
2340
+ * Reactivating goes through changePlan, and it is the one caller that
2341
+ * genuinely lands on its recreate path: the subscriptions being reactivated
2342
+ * are not live, so there is nothing to update and new ones are created. A
2343
+ * trial the project still has to run therefore has to be carried onto the
2344
+ * replacements explicitly. Otherwise a customer whose trial a master admin
2345
+ * extended as a goodwill gesture loses the extension the moment their
2346
+ * subscription is reactivated, and is billed right away.
2232
2347
  *
2233
2348
  * A trial that has already lapsed is not revived: reactivation is not the
2234
2349
  * place to hand out free service.
@@ -2242,6 +2357,7 @@ export class ProjectService extends DatabaseService<Model> {
2242
2357
  subscriptionId: string;
2243
2358
  meteredSubscriptionId: string;
2244
2359
  trialEndsAt?: Date | undefined;
2360
+ subscriptionIdsPendingCancellation: Array<string>;
2245
2361
  } = await BillingService.changePlan({
2246
2362
  projectId: project.id as ObjectID,
2247
2363
  subscriptionId: project.paymentProviderSubscriptionId,
@@ -2254,25 +2370,34 @@ export class ProjectService extends DatabaseService<Model> {
2254
2370
  });
2255
2371
 
2256
2372
  // refresh subscription status.
2257
- const subscriptionState: SubscriptionStatus =
2258
- await BillingService.getSubscriptionStatus(
2259
- result.subscriptionId as string,
2260
- );
2373
+ const subscriptionState: SubscriptionStatus | null =
2374
+ await this.findSubscriptionStatus(result.subscriptionId as string);
2261
2375
 
2262
- const meteredSubscriptionState: SubscriptionStatus =
2263
- await BillingService.getSubscriptionStatus(
2264
- project.paymentProviderMeteredSubscriptionId as string,
2265
- );
2376
+ /*
2377
+ * The metered subscription changePlan returns, not the one the project row
2378
+ * still points at. When changePlan replaced the subscriptions the old id
2379
+ * names a cancelled subscription, and its status would be persisted against
2380
+ * the new one.
2381
+ */
2382
+ const meteredSubscriptionState: SubscriptionStatus | null =
2383
+ await this.findSubscriptionStatus(result.meteredSubscriptionId as string);
2266
2384
 
2267
2385
  // now update project with new subscription id.
2268
2386
 
2269
2387
  const updateData: QueryDeepPartialEntity<Model> = {
2270
2388
  paymentProviderSubscriptionId: result.subscriptionId,
2271
2389
  paymentProviderMeteredSubscriptionId: result.meteredSubscriptionId,
2272
- paymentProviderSubscriptionStatus: subscriptionState,
2273
- paymentProviderMeteredSubscriptionStatus: meteredSubscriptionState,
2274
2390
  };
2275
2391
 
2392
+ if (subscriptionState) {
2393
+ updateData.paymentProviderSubscriptionStatus = subscriptionState;
2394
+ }
2395
+
2396
+ if (meteredSubscriptionState) {
2397
+ updateData.paymentProviderMeteredSubscriptionStatus =
2398
+ meteredSubscriptionState;
2399
+ }
2400
+
2276
2401
  /*
2277
2402
  * The payment provider is the source of truth for the trial the new
2278
2403
  * subscriptions were created with, so its date wins over the one sent.
@@ -2293,6 +2418,11 @@ export class ProjectService extends DatabaseService<Model> {
2293
2418
  },
2294
2419
  });
2295
2420
 
2421
+ this.alertOnSubscriptionsPendingCancellation({
2422
+ projectId: project.id!,
2423
+ subscriptionIds: result.subscriptionIdsPendingCancellation,
2424
+ });
2425
+
2296
2426
  // send slack message on plan change.
2297
2427
  await this.sendSubscriptionChangeWebhookSlackNotification(projectId);
2298
2428
  }
@@ -5,6 +5,7 @@ import Model from "../../Models/DatabaseModels/ProxmoxCluster";
5
5
  import Label from "../../Models/DatabaseModels/Label";
6
6
  import { OnCreate } from "../Types/Database/Hooks";
7
7
  import CaptureSpan from "../Utils/Telemetry/CaptureSpan";
8
+ import ResourceHeartbeat from "../Utils/Telemetry/ResourceHeartbeat";
8
9
  import ObjectID from "../../Types/ObjectID";
9
10
  import QueryHelper from "../Types/Database/QueryHelper";
10
11
  import OneUptimeDate from "../../Types/Date";
@@ -177,7 +178,6 @@ export class Service extends DatabaseService<Model> {
177
178
  guestsWithoutBackupCount?: number | undefined;
178
179
  },
179
180
  ): Promise<void> {
180
- const cacheKey: string = clusterId.toString();
181
181
  const extrasFingerprint: string = crypto
182
182
  .createHash("sha1")
183
183
  .update(
@@ -193,71 +193,53 @@ export class Service extends DatabaseService<Model> {
193
193
  )
194
194
  .digest("hex");
195
195
 
196
- let cached: string | null = null;
197
- try {
198
- cached = await GlobalCache.getString(LAST_SEEN_CACHE_NAMESPACE, cacheKey);
199
- } catch {
200
- /*
201
- * Cache unavailable — fail open and refresh lastSeenAt anyway. A
202
- * cache error must never skip the DB write below, otherwise the
203
- * resource is wrongly marked "disconnected" while telemetry is
204
- * still flowing. Mirrors shouldRunMaintenance's fail-open stance.
205
- */
206
- cached = null;
207
- }
208
-
209
- if (cached === extrasFingerprint) {
210
- return; // same data was written recently
211
- }
212
-
213
- try {
214
- await GlobalCache.setString(
215
- LAST_SEEN_CACHE_NAMESPACE,
216
- cacheKey,
217
- extrasFingerprint,
218
- { expiresInSeconds: LAST_SEEN_THROTTLE_SECONDS },
219
- );
220
- } catch {
221
- // Best-effort throttle write; proceed with the DB update regardless.
222
- }
223
-
224
196
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
225
- const data: any = {
197
+ const liveness: any = {
226
198
  lastSeenAt: OneUptimeDate.getCurrentDate(),
227
199
  otelCollectorStatus: "connected",
228
200
  };
229
201
 
202
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
203
+ const metadata: any = {};
204
+
230
205
  if (extra?.pveVersion) {
231
- data.pveVersion = extra.pveVersion;
206
+ metadata.pveVersion = extra.pveVersion;
232
207
  }
233
208
  if (extra?.agentVersion) {
234
- data.agentVersion = extra.agentVersion;
209
+ metadata.agentVersion = extra.agentVersion;
235
210
  }
236
211
  // Counts: 0 is a legitimate value — gate on undefined, not falsiness.
237
212
  if (extra?.nodeCount !== undefined) {
238
- data.nodeCount = extra.nodeCount;
213
+ metadata.nodeCount = extra.nodeCount;
239
214
  }
240
215
  if (extra?.onlineNodeCount !== undefined) {
241
- data.onlineNodeCount = extra.onlineNodeCount;
216
+ metadata.onlineNodeCount = extra.onlineNodeCount;
242
217
  }
243
218
  if (extra?.guestCount !== undefined) {
244
- data.guestCount = extra.guestCount;
219
+ metadata.guestCount = extra.guestCount;
245
220
  }
246
221
  if (extra?.storageCount !== undefined) {
247
- data.storageCount = extra.storageCount;
222
+ metadata.storageCount = extra.storageCount;
248
223
  }
249
224
  if (extra?.guestsWithoutBackupCount !== undefined) {
250
- data.guestsWithoutBackupCount = extra.guestsWithoutBackupCount;
225
+ metadata.guestsWithoutBackupCount = extra.guestsWithoutBackupCount;
251
226
  }
252
227
 
253
228
  /*
254
- * Heartbeat write: a single-statement UPDATE with no hooks and no
255
- * `version` bump, avoiding the hot-row Postgres lock convoy that the
256
- * full updateOneById pipeline causes. See ServiceService.updateLastSeen.
229
+ * One gated, non-blocking heartbeat write. The gates, the fail-open /
230
+ * fail-closed split and the liveness-only fallback all live in
231
+ * ResourceHeartbeat see there for why this row's throttle used to
232
+ * provide no throttling at all.
257
233
  */
258
- await this.updateColumnsByIdWithoutHooks({
234
+ await ResourceHeartbeat.write({
235
+ service: this,
259
236
  id: clusterId,
260
- data: data,
237
+ cacheNamespace: LAST_SEEN_CACHE_NAMESPACE,
238
+ throttleInSeconds: LAST_SEEN_THROTTLE_SECONDS,
239
+ liveness: liveness,
240
+ metadata: metadata,
241
+ fingerprint: extrasFingerprint,
242
+ describe: `proxmox cluster ${clusterId.toString()}`,
261
243
  });
262
244
  }
263
245
 
@@ -1,9 +1,11 @@
1
1
  import DatabaseService from "./DatabaseService";
2
2
  import Model from "../../Models/DatabaseModels/ProxmoxResource";
3
3
  import CaptureSpan from "../Utils/Telemetry/CaptureSpan";
4
+ import ColumnLength from "../../Types/Database/ColumnLength";
4
5
  import ObjectID from "../../Types/ObjectID";
5
6
  import OneUptimeDate from "../../Types/Date";
6
7
  import QueryHelper from "../Types/Database/QueryHelper";
8
+ import { truncateShortText } from "../Utils/Database/TruncateColumnValue";
7
9
  import logger from "../Utils/Logger";
8
10
 
9
11
  /*
@@ -89,6 +91,26 @@ const UPSERT_COLUMNS: Array<string> = [
89
91
  "version",
90
92
  ];
91
93
 
94
+ /*
95
+ * ProxmoxResource's text columns are all ShortText (100 chars). The
96
+ * bulk paths below go through manager.query(), which skips the length
97
+ * validation DatabaseService applies to ordinary writes, so a single
98
+ * oversized value aborts the whole 500-row INSERT chunk it rides in.
99
+ * Clamp per value instead, so one pathological guest can never drop the
100
+ * rest of the scrape.
101
+ */
102
+ function sanitizeResource(r: ParsedProxmoxResource): ParsedProxmoxResource {
103
+ return {
104
+ ...r,
105
+ kind: truncateShortText(r.kind),
106
+ externalId: truncateShortText(r.externalId),
107
+ name: truncateShortText(r.name),
108
+ guestType: truncateShortText(r.guestType),
109
+ parentNodeName: truncateShortText(r.parentNodeName),
110
+ haState: truncateShortText(r.haState),
111
+ };
112
+ }
113
+
92
114
  export class Service extends DatabaseService<Model> {
93
115
  public constructor() {
94
116
  super(Model);
@@ -116,9 +138,21 @@ export class Service extends DatabaseService<Model> {
116
138
  return;
117
139
  }
118
140
 
141
+ const resources: Array<ParsedProxmoxResource> = data.resources.map(
142
+ (r: ParsedProxmoxResource) => {
143
+ const sanitized: ParsedProxmoxResource = sanitizeResource(r);
144
+ if (sanitized.externalId !== r.externalId) {
145
+ logger.warn(
146
+ `ProxmoxResource externalId exceeds ${ColumnLength.ShortText} chars; truncated to "${sanitized.externalId}" (cluster ${data.proxmoxClusterId.toString()}).`,
147
+ );
148
+ }
149
+ return sanitized;
150
+ },
151
+ );
152
+
119
153
  // Chunk to keep individual statement parameter counts reasonable.
120
- for (let i: number = 0; i < data.resources.length; i += UPSERT_BATCH_SIZE) {
121
- const chunk: Array<ParsedProxmoxResource> = data.resources.slice(
154
+ for (let i: number = 0; i < resources.length; i += UPSERT_BATCH_SIZE) {
155
+ const chunk: Array<ParsedProxmoxResource> = resources.slice(
122
156
  i,
123
157
  i + UPSERT_BATCH_SIZE,
124
158
  );
@@ -219,9 +253,14 @@ export class Service extends DatabaseService<Model> {
219
253
  valueFragments.push(
220
254
  `($${paramIndex++}, $${paramIndex++}, $${paramIndex++}::numeric, $${paramIndex++}::bigint, $${paramIndex++}::bigint, $${paramIndex++}::numeric, $${paramIndex++}::bigint, $${paramIndex++}::bigint, $${paramIndex++}::timestamptz)`,
221
255
  );
256
+ /*
257
+ * The identity clamps MUST match bulkUpsert's, or this mirror
258
+ * UPDATE would silently miss the row the upsert just wrote
259
+ * under the truncated externalId.
260
+ */
222
261
  params.push(
223
- m.kind,
224
- m.externalId,
262
+ truncateShortText(m.kind),
263
+ truncateShortText(m.externalId),
225
264
  m.cpuPercent !== null && m.cpuPercent !== undefined
226
265
  ? m.cpuPercent
227
266
  : null,
@@ -2,6 +2,7 @@ import DatabaseService from "./DatabaseService";
2
2
  import Model from "../../Models/DatabaseModels/RumApplication";
3
3
  import Label from "../../Models/DatabaseModels/Label";
4
4
  import CaptureSpan from "../Utils/Telemetry/CaptureSpan";
5
+ import ResourceHeartbeat from "../Utils/Telemetry/ResourceHeartbeat";
5
6
  import ObjectID from "../../Types/ObjectID";
6
7
  import QueryHelper from "../Types/Database/QueryHelper";
7
8
  import OneUptimeDate from "../../Types/Date";
@@ -276,7 +277,6 @@ export class Service extends DatabaseService<Model> {
276
277
  sdkLanguage?: string | undefined;
277
278
  },
278
279
  ): Promise<void> {
279
- const cacheKey: string = rumApplicationId.toString();
280
280
  const extrasFingerprint: string = crypto
281
281
  .createHash("sha1")
282
282
  .update(
@@ -288,58 +288,40 @@ export class Service extends DatabaseService<Model> {
288
288
  )
289
289
  .digest("hex");
290
290
 
291
- let cached: string | null = null;
292
- try {
293
- cached = await GlobalCache.getString(LAST_SEEN_CACHE_NAMESPACE, cacheKey);
294
- } catch {
295
- /*
296
- * Cache unavailable — fail open and refresh lastSeenAt anyway. A
297
- * cache error must never skip the DB write below, otherwise the
298
- * resource is wrongly marked "disconnected" while telemetry is
299
- * still flowing. Mirrors shouldRunMaintenance's fail-open stance.
300
- */
301
- cached = null;
302
- }
303
-
304
- if (cached === extrasFingerprint) {
305
- return; // same data was written recently
306
- }
307
-
308
- try {
309
- await GlobalCache.setString(
310
- LAST_SEEN_CACHE_NAMESPACE,
311
- cacheKey,
312
- extrasFingerprint,
313
- { expiresInSeconds: LAST_SEEN_THROTTLE_SECONDS },
314
- );
315
- } catch {
316
- // Best-effort throttle write; proceed with the DB update regardless.
317
- }
318
-
319
291
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
320
- const data: any = {
292
+ const liveness: any = {
321
293
  lastSeenAt: OneUptimeDate.getCurrentDate(),
322
294
  otelCollectorStatus: "connected",
323
295
  };
324
296
 
297
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
298
+ const metadata: any = {};
299
+
325
300
  if (extra?.agentVersion) {
326
- data.agentVersion = extra.agentVersion;
301
+ metadata.agentVersion = extra.agentVersion;
327
302
  }
328
303
  if (extra?.clientType) {
329
- data.clientType = extra.clientType;
304
+ metadata.clientType = extra.clientType;
330
305
  }
331
306
  if (extra?.sdkLanguage) {
332
- data.sdkLanguage = extra.sdkLanguage;
307
+ metadata.sdkLanguage = extra.sdkLanguage;
333
308
  }
334
309
 
335
310
  /*
336
- * Heartbeat write: a single-statement UPDATE with no hooks and no
337
- * `version` bump, avoiding the hot-row Postgres lock convoy that the
338
- * full updateOneById pipeline causes. See ServiceService.updateLastSeen.
311
+ * One gated, non-blocking heartbeat write. The gates, the fail-open /
312
+ * fail-closed split and the liveness-only fallback all live in
313
+ * ResourceHeartbeat see there for why this row's throttle used to
314
+ * provide no throttling at all.
339
315
  */
340
- await this.updateColumnsByIdWithoutHooks({
316
+ await ResourceHeartbeat.write({
317
+ service: this,
341
318
  id: rumApplicationId,
342
- data: data,
319
+ cacheNamespace: LAST_SEEN_CACHE_NAMESPACE,
320
+ throttleInSeconds: LAST_SEEN_THROTTLE_SECONDS,
321
+ liveness: liveness,
322
+ metadata: metadata,
323
+ fingerprint: extrasFingerprint,
324
+ describe: `rum application ${rumApplicationId.toString()}`,
343
325
  });
344
326
  }
345
327
 
@@ -26,6 +26,7 @@ import ScheduledMaintenanceStateTimeline from "../../Models/DatabaseModels/Sched
26
26
  import { IsBillingEnabled } from "../EnvironmentConfig";
27
27
  import ScheduledMaintenanceFeedService from "./ScheduledMaintenanceFeedService";
28
28
  import { ScheduledMaintenanceFeedEventType } from "../../Models/DatabaseModels/ScheduledMaintenanceFeed";
29
+ import ProjectScopedReferenceValidator from "../Utils/Database/ProjectScopedReferenceValidator";
29
30
  import logger, { LogAttributes } from "../Utils/Logger";
30
31
  import CaptureSpan from "../Utils/Telemetry/CaptureSpan";
31
32
  import { LIMIT_PER_PROJECT } from "../../Types/Database/LimitMax";
@@ -122,6 +123,26 @@ export class Service extends DatabaseService<ScheduledMaintenanceStateTimeline>
122
123
  throw new BadDataException("scheduledMaintenanceStateId is null");
123
124
  }
124
125
 
126
+ /*
127
+ * Same guard, same reason, as MonitorStatusTimelineService: an id that
128
+ * exists nowhere (or belongs to another project) used to reach Postgres
129
+ * and come back as a raw foreign key violation. The ordering check below
130
+ * does look the state up, but only when there IS a preceding row with an
131
+ * order, so the first timeline row for a scheduled maintenance event went
132
+ * through unchecked.
133
+ */
134
+ await ProjectScopedReferenceValidator.validateReferencesBelongToProject({
135
+ projectId: createBy.props.tenantId || createBy.data.projectId,
136
+ subject: "scheduled maintenance state timeline",
137
+ references: [
138
+ {
139
+ modelName: "Scheduled Maintenance State",
140
+ id: scheduledMaintenanceStateId,
141
+ service: ScheduledMaintenanceStateService,
142
+ },
143
+ ],
144
+ });
145
+
125
146
  const stateBeforeThis: ScheduledMaintenanceStateTimeline | null =
126
147
  await this.findOneBy({
127
148
  query: {