@oneuptime/common 11.6.1 → 11.7.0

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 (420) hide show
  1. package/Models/AnalyticsModels/Index.ts +4 -0
  2. package/Models/AnalyticsModels/KubernetesCostAllocation.ts +842 -0
  3. package/Models/AnalyticsModels/NetworkFlow.ts +54 -0
  4. package/Models/AnalyticsModels/SloHistory.ts +243 -0
  5. package/Models/DatabaseModels/Index.ts +20 -0
  6. package/Models/DatabaseModels/NetworkDevice.ts +453 -6
  7. package/Models/DatabaseModels/NetworkDeviceDiscoveryScan.ts +7 -6
  8. package/Models/DatabaseModels/NetworkEndpoint.ts +753 -0
  9. package/Models/DatabaseModels/NetworkSite.ts +1155 -0
  10. package/Models/DatabaseModels/NetworkSiteAssignmentRule.ts +517 -0
  11. package/Models/DatabaseModels/NetworkSiteLink.ts +611 -0
  12. package/Models/DatabaseModels/NetworkSiteStatusTimeline.ts +520 -0
  13. package/Models/DatabaseModels/NetworkSiteType.ts +499 -0
  14. package/Models/DatabaseModels/ServiceLevelObjective.ts +1115 -0
  15. package/Models/DatabaseModels/ServiceLevelObjectiveBurnRateRule.ts +762 -0
  16. package/Models/DatabaseModels/ServiceLevelObjectiveOwnerTeam.ts +444 -0
  17. package/Models/DatabaseModels/ServiceLevelObjectiveOwnerUser.ts +443 -0
  18. package/Server/Infrastructure/Postgres/SchemaMigrations/1784757142154-AddNetworkSiteHierarchyAndEndpoints.ts +359 -0
  19. package/Server/Infrastructure/Postgres/SchemaMigrations/1784897317860-AddNetworkSiteAlerting.ts +48 -0
  20. package/Server/Infrastructure/Postgres/SchemaMigrations/1784970388777-AddNetworkDevicePollingColumns.ts +65 -0
  21. package/Server/Infrastructure/Postgres/SchemaMigrations/1784986826214-AddNetworkSiteTypeTable.ts +88 -0
  22. package/Server/Infrastructure/Postgres/SchemaMigrations/1784987015619-AddServiceLevelObjective.ts +391 -0
  23. package/Server/Infrastructure/Postgres/SchemaMigrations/1785066759532-MigrationName.ts +30 -0
  24. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +12 -0
  25. package/Server/Services/AnalyticsDatabaseService.ts +25 -9
  26. package/Server/Services/Index.ts +24 -0
  27. package/Server/Services/KubernetesCostAllocationService.ts +14 -0
  28. package/Server/Services/MetricService.ts +21 -2
  29. package/Server/Services/MonitorService.ts +22 -0
  30. package/Server/Services/NetworkDeviceService.ts +438 -2
  31. package/Server/Services/NetworkEndpointService.ts +414 -0
  32. package/Server/Services/NetworkSiteAssignmentRuleService.ts +98 -0
  33. package/Server/Services/NetworkSiteLinkService.ts +10 -0
  34. package/Server/Services/NetworkSiteService.ts +1254 -0
  35. package/Server/Services/NetworkSiteStatusTimelineService.ts +10 -0
  36. package/Server/Services/NetworkSiteTypeService.ts +10 -0
  37. package/Server/Services/ProjectService.ts +122 -2
  38. package/Server/Services/ServiceLevelObjectiveBurnRateRuleService.ts +457 -0
  39. package/Server/Services/ServiceLevelObjectiveOwnerTeamService.ts +10 -0
  40. package/Server/Services/ServiceLevelObjectiveOwnerUserService.ts +10 -0
  41. package/Server/Services/ServiceLevelObjectiveService.ts +685 -0
  42. package/Server/Services/SloHistoryService.ts +101 -0
  43. package/Server/Services/UserNotificationSettingService.ts +37 -0
  44. package/Server/Types/AnalyticsDatabase/AggregateBy.ts +9 -0
  45. package/Server/Types/Database/Permissions/OwnerTableRegistry.ts +15 -0
  46. package/Server/Utils/AnalyticsDatabase/Statement.ts +39 -3
  47. package/Server/Utils/AnalyticsDatabase/StatementGenerator.ts +87 -48
  48. package/Server/Utils/Memory.ts +9 -1
  49. package/Server/Utils/Monitor/Criteria/SnmpMonitorCriteria.ts +190 -12
  50. package/Server/Utils/Monitor/Data/OuiVendors.json +6920 -0
  51. package/Server/Utils/Monitor/DnsResolutionCache.ts +129 -0
  52. package/Server/Utils/Monitor/MonitorResource.ts +4 -30
  53. package/Server/Utils/Monitor/NetworkDeviceHydrationUtil.ts +214 -39
  54. package/Server/Utils/Monitor/NetworkDeviceMetricUtil.ts +343 -0
  55. package/Server/Utils/Monitor/NetworkDeviceWalkUtil.ts +251 -0
  56. package/Server/Utils/Monitor/NetworkInventoryUtil.ts +176 -142
  57. package/Server/Utils/Monitor/OuiLookupUtil.ts +49 -0
  58. package/Server/Utils/Monitor/SnmpInterfaceRateUtil.ts +17 -13
  59. package/Server/Utils/WhatsAppTemplateUtil.ts +7 -3
  60. package/Tests/Models/AnalyticsModels/KubernetesCostAllocation.test.ts +135 -0
  61. package/Tests/Models/NetworkSiteHierarchy.test.ts +134 -0
  62. package/Tests/Server/Services/AnalyticsDatabaseService.test.ts +239 -0
  63. package/Tests/Server/Services/KubernetesCostAllocationAggregate.test.ts +338 -0
  64. package/Tests/Server/Services/MetricServiceAggregate.test.ts +142 -0
  65. package/Tests/Server/Services/NetworkDeviceSiteAssignment.test.ts +484 -0
  66. package/Tests/Server/Services/NetworkEndpointServiceUpsert.test.ts +686 -0
  67. package/Tests/Server/Services/NetworkSiteAssignmentRuleService.test.ts +185 -0
  68. package/Tests/Server/Services/NetworkSiteService.test.ts +1354 -0
  69. package/Tests/Server/Services/ServiceLevelObjectiveBurnRateRuleService.test.ts +1313 -0
  70. package/Tests/Server/Services/ServiceLevelObjectiveService.test.ts +1988 -0
  71. package/Tests/Server/Utils/AnalyticsDatabase/Statement.test.ts +22 -0
  72. package/Tests/Server/Utils/AnalyticsDatabase/StatementGenerator.test.ts +404 -0
  73. package/Tests/Server/Utils/Encryption.test.ts +70 -0
  74. package/Tests/Server/Utils/FileAttachmentMarkdownUtil.test.ts +225 -0
  75. package/Tests/Server/Utils/JsonWebToken.test.ts +175 -0
  76. package/Tests/Server/Utils/LocalFile.test.ts +258 -0
  77. package/Tests/Server/Utils/Memory.test.ts +213 -0
  78. package/Tests/Server/Utils/Monitor/Criteria/LogMonitorCriteria.test.ts +30 -0
  79. package/Tests/Server/Utils/Monitor/Criteria/SnmpMonitorCriteria.test.ts +385 -0
  80. package/Tests/Server/Utils/Monitor/DnsResolutionCache.test.ts +194 -0
  81. package/Tests/Server/Utils/Monitor/NetworkDeviceHydrationUtil.test.ts +155 -0
  82. package/Tests/Server/Utils/Monitor/NetworkDeviceWalkUtil.test.ts +600 -0
  83. package/Tests/Server/Utils/Monitor/NetworkInventoryUtil.test.ts +151 -124
  84. package/Tests/Server/Utils/Monitor/SnmpInterfaceRateUtil.test.ts +496 -0
  85. package/Tests/Server/Utils/MonitorCriteriaDataExtractor.test.ts +175 -0
  86. package/Tests/Server/Utils/MonitorCriteriaMessageFormatter.test.ts +282 -0
  87. package/Tests/Server/Utils/OuiLookupUtil.test.ts +59 -0
  88. package/Tests/Server/Utils/SeriesResourceLabels.test.ts +117 -0
  89. package/Tests/Server/Utils/StackTraceParser.test.ts +370 -0
  90. package/Tests/Server/Utils/Stream.test.ts +87 -0
  91. package/Tests/Server/Utils/ValidateGlobalProviderProjectTeams.test.ts +221 -0
  92. package/Tests/Server/Utils/WhatsAppTemplateUtil.test.ts +199 -0
  93. package/Tests/Types/Database/CompareOperatorWireSerialization.test.ts +33 -0
  94. package/Tests/Types/Email.test.ts +198 -0
  95. package/Tests/Types/Kubernetes/KubernetesObjectParser.test.ts +177 -0
  96. package/Tests/Types/Log/LogQueryToFilter.test.ts +111 -0
  97. package/Tests/Types/Monitor/MonitorCriteria.test.ts +155 -0
  98. package/Tests/Types/Monitor/MonitorCriteriaInstance.test.ts +465 -0
  99. package/Tests/Types/Monitor/MonitorStep.test.ts +183 -0
  100. package/Tests/Types/Monitor/MonitorStepNetworkDeviceMonitor.test.ts +141 -1
  101. package/Tests/Types/Monitor/MonitorSteps.test.ts +183 -0
  102. package/Tests/Types/Monitor/MonitorType.test.ts +59 -1
  103. package/Tests/Types/Monitor/NetworkDeviceAlertPack.test.ts +97 -0
  104. package/Tests/Types/Monitor/SnmpEndpointDiscovery.test.ts +151 -0
  105. package/Tests/Types/Monitor/SnmpVendorTemplate.test.ts +110 -6
  106. package/Tests/Types/NetworkSite/DefaultNetworkSiteType.test.ts +129 -0
  107. package/Tests/Types/SerializableObjectDictionary.test.ts +166 -0
  108. package/Tests/Types/Time/RangeStartAndEndDateTime.test.ts +98 -0
  109. package/Tests/Types/WebsiteRequest.test.ts +230 -0
  110. package/Tests/UI/Components/EntityFilterRoundTrip.test.tsx +103 -0
  111. package/Tests/UI/Components/ModelTable/BaseModelTableUrlState.test.tsx +612 -0
  112. package/Tests/UI/Components/ModelTable/FilterDataToQuery.test.ts +275 -0
  113. package/Tests/UI/Utils/LogExport.test.ts +159 -0
  114. package/Tests/UI/Utils/Navigation.test.ts +183 -0
  115. package/Tests/UI/Utils/TableFilterUrlState.test.ts +539 -0
  116. package/Tests/UI/Utils/TableViewUrlState.test.ts +272 -0
  117. package/Tests/Utils/Base64.test.ts +51 -0
  118. package/Tests/Utils/Boolean.test.ts +76 -0
  119. package/Tests/Utils/Crypto.test.ts +48 -0
  120. package/Tests/Utils/Dashboard/DashboardSloComponent.test.ts +259 -0
  121. package/Tests/Utils/Dashboard/ModelQueryVariableInterpolation.test.ts +162 -0
  122. package/Tests/Utils/Enum.test.ts +54 -0
  123. package/Tests/Utils/IpCanonicalUtil.test.ts +85 -0
  124. package/Tests/Utils/Memory.test.ts +44 -0
  125. package/Tests/Utils/Metrics/MetricSeriesFingerprint.test.ts +160 -0
  126. package/Tests/Utils/Monitor/EndpointAttachmentUtil.test.ts +836 -0
  127. package/Tests/Utils/Monitor/MonitorMetricType.test.ts +218 -0
  128. package/Tests/Utils/Monitor/NetworkTopologyUtil.test.ts +447 -0
  129. package/Tests/Utils/NetworkSite/CidrMatchUtil.test.ts +440 -0
  130. package/Tests/Utils/NetworkSite/MaterializedPathUtil.test.ts +205 -0
  131. package/Tests/Utils/NetworkSite/SiteStatusRollupUtil.test.ts +221 -0
  132. package/Tests/Utils/NetworkSite/SiteUptimeUtil.test.ts +283 -0
  133. package/Tests/Utils/ObjectUtil.test.ts +30 -0
  134. package/Tests/Utils/Slo/SloBurnRateRuleState.test.ts +124 -0
  135. package/Tests/Utils/Slo/SloDuration.test.ts +148 -0
  136. package/Tests/Utils/Slo/SloHealth.test.ts +334 -0
  137. package/Tests/Utils/Slo/SloStatusColor.test.ts +89 -0
  138. package/Tests/Utils/Slo/SloUtil.test.ts +1980 -0
  139. package/Tests/Utils/Slo/SloWidgetFormat.test.ts +605 -0
  140. package/Tests/Utils/TechStack.test.ts +50 -0
  141. package/Tests/Utils/Traces/CriticalPath.test.ts +178 -0
  142. package/Types/AnalyticsDatabase/AnalyticsTableName.ts +10 -0
  143. package/Types/BaseDatabase/EqualTo.ts +9 -1
  144. package/Types/BaseDatabase/EqualToOrNull.ts +9 -1
  145. package/Types/BaseDatabase/NotEqual.ts +9 -1
  146. package/Types/Dashboard/DashboardComponentType.ts +1 -0
  147. package/Types/Dashboard/DashboardComponents/ComponentArgument.ts +1 -0
  148. package/Types/Dashboard/DashboardComponents/DashboardSloComponent.ts +42 -0
  149. package/Types/Dashboard/DashboardTemplates.ts +214 -0
  150. package/Types/Email/EmailTemplateType.ts +2 -0
  151. package/Types/Kubernetes/KubernetesCostIngest.ts +79 -0
  152. package/Types/Monitor/CriteriaFilter.ts +9 -0
  153. package/Types/Monitor/MonitorStep.ts +5 -8
  154. package/Types/Monitor/MonitorStepNetworkDeviceMonitor.ts +27 -5
  155. package/Types/Monitor/MonitorType.ts +15 -5
  156. package/Types/Monitor/SnmpMonitor/ArpEntry.ts +14 -0
  157. package/Types/Monitor/SnmpMonitor/FdbEntry.ts +18 -0
  158. package/Types/Monitor/SnmpMonitor/NetworkDeviceAlertPack.ts +10 -3
  159. package/Types/Monitor/SnmpMonitor/NetworkTopology.ts +31 -5
  160. package/Types/Monitor/SnmpMonitor/SnmpMonitorResponse.ts +12 -0
  161. package/Types/Monitor/SnmpMonitor/SnmpVendorTemplate.ts +231 -3
  162. package/Types/NetworkSite/DefaultNetworkSiteType.ts +20 -0
  163. package/Types/NotificationSetting/NotificationSettingEventType.ts +4 -0
  164. package/Types/Permission.ts +449 -0
  165. package/Types/ServiceLevelObjective/SliType.ts +6 -0
  166. package/Types/ServiceLevelObjective/SloMultiMonitorMode.ts +6 -0
  167. package/Types/ServiceLevelObjective/SloStatus.ts +9 -0
  168. package/Types/ServiceLevelObjective/SloWindowType.ts +6 -0
  169. package/Types/Telemetry/ServiceType.ts +1 -0
  170. package/UI/Components/Filters/EntityFilter.tsx +16 -0
  171. package/UI/Components/Filters/FilterViewer.tsx +22 -5
  172. package/UI/Components/List/List.tsx +8 -0
  173. package/UI/Components/ModelTable/BaseModelTable.tsx +309 -106
  174. package/UI/Components/ModelTable/FilterDataToQuery.ts +172 -0
  175. package/UI/Components/Navbar/NavBar.tsx +16 -2
  176. package/UI/Components/Navbar/NavBarMenuModal.tsx +3 -3
  177. package/UI/Utils/Navigation.ts +10 -0
  178. package/UI/Utils/TableFilterUrlState.ts +204 -17
  179. package/UI/Utils/TableViewUrlState.ts +165 -0
  180. package/Utils/Dashboard/Components/DashboardSloComponent.ts +114 -0
  181. package/Utils/Dashboard/Components/Index.ts +7 -0
  182. package/Utils/IpCanonicalUtil.ts +134 -0
  183. package/Utils/Monitor/EndpointAttachmentUtil.ts +508 -0
  184. package/Utils/Monitor/NetworkTopologyUtil.ts +157 -5
  185. package/Utils/NetworkSite/CidrMatchUtil.ts +296 -0
  186. package/Utils/NetworkSite/MaterializedPathUtil.ts +115 -0
  187. package/Utils/NetworkSite/SiteStatusRollupUtil.ts +97 -0
  188. package/Utils/NetworkSite/SiteUptimeUtil.ts +111 -0
  189. package/Utils/Slo/SloBurnRateRuleState.ts +91 -0
  190. package/Utils/Slo/SloDuration.ts +165 -0
  191. package/Utils/Slo/SloEvaluation.ts +22 -0
  192. package/Utils/Slo/SloHealth.ts +302 -0
  193. package/Utils/Slo/SloStatusColor.ts +54 -0
  194. package/Utils/Slo/SloUtil.ts +637 -0
  195. package/Utils/Slo/SloWidgetFormat.ts +383 -0
  196. package/build/dist/Models/AnalyticsModels/Index.js +4 -0
  197. package/build/dist/Models/AnalyticsModels/Index.js.map +1 -1
  198. package/build/dist/Models/AnalyticsModels/KubernetesCostAllocation.js +713 -0
  199. package/build/dist/Models/AnalyticsModels/KubernetesCostAllocation.js.map +1 -0
  200. package/build/dist/Models/AnalyticsModels/NetworkFlow.js +44 -0
  201. package/build/dist/Models/AnalyticsModels/NetworkFlow.js.map +1 -1
  202. package/build/dist/Models/AnalyticsModels/SloHistory.js +218 -0
  203. package/build/dist/Models/AnalyticsModels/SloHistory.js.map +1 -0
  204. package/build/dist/Models/DatabaseModels/Index.js +20 -0
  205. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  206. package/build/dist/Models/DatabaseModels/NetworkDevice.js +458 -6
  207. package/build/dist/Models/DatabaseModels/NetworkDevice.js.map +1 -1
  208. package/build/dist/Models/DatabaseModels/NetworkDeviceDiscoveryScan.js +0 -6
  209. package/build/dist/Models/DatabaseModels/NetworkDeviceDiscoveryScan.js.map +1 -1
  210. package/build/dist/Models/DatabaseModels/NetworkEndpoint.js +779 -0
  211. package/build/dist/Models/DatabaseModels/NetworkEndpoint.js.map +1 -0
  212. package/build/dist/Models/DatabaseModels/NetworkSite.js +1180 -0
  213. package/build/dist/Models/DatabaseModels/NetworkSite.js.map +1 -0
  214. package/build/dist/Models/DatabaseModels/NetworkSiteAssignmentRule.js +534 -0
  215. package/build/dist/Models/DatabaseModels/NetworkSiteAssignmentRule.js.map +1 -0
  216. package/build/dist/Models/DatabaseModels/NetworkSiteLink.js +629 -0
  217. package/build/dist/Models/DatabaseModels/NetworkSiteLink.js.map +1 -0
  218. package/build/dist/Models/DatabaseModels/NetworkSiteStatusTimeline.js +538 -0
  219. package/build/dist/Models/DatabaseModels/NetworkSiteStatusTimeline.js.map +1 -0
  220. package/build/dist/Models/DatabaseModels/NetworkSiteType.js +522 -0
  221. package/build/dist/Models/DatabaseModels/NetworkSiteType.js.map +1 -0
  222. package/build/dist/Models/DatabaseModels/ServiceLevelObjective.js +1134 -0
  223. package/build/dist/Models/DatabaseModels/ServiceLevelObjective.js.map +1 -0
  224. package/build/dist/Models/DatabaseModels/ServiceLevelObjectiveBurnRateRule.js +769 -0
  225. package/build/dist/Models/DatabaseModels/ServiceLevelObjectiveBurnRateRule.js.map +1 -0
  226. package/build/dist/Models/DatabaseModels/ServiceLevelObjectiveOwnerTeam.js +460 -0
  227. package/build/dist/Models/DatabaseModels/ServiceLevelObjectiveOwnerTeam.js.map +1 -0
  228. package/build/dist/Models/DatabaseModels/ServiceLevelObjectiveOwnerUser.js +459 -0
  229. package/build/dist/Models/DatabaseModels/ServiceLevelObjectiveOwnerUser.js.map +1 -0
  230. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784757142154-AddNetworkSiteHierarchyAndEndpoints.js +130 -0
  231. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784757142154-AddNetworkSiteHierarchyAndEndpoints.js.map +1 -0
  232. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784897317860-AddNetworkSiteAlerting.js +31 -0
  233. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784897317860-AddNetworkSiteAlerting.js.map +1 -0
  234. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784970388777-AddNetworkDevicePollingColumns.js +36 -0
  235. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784970388777-AddNetworkDevicePollingColumns.js.map +1 -0
  236. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784986826214-AddNetworkSiteTypeTable.js +49 -0
  237. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784986826214-AddNetworkSiteTypeTable.js.map +1 -0
  238. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784987015619-AddServiceLevelObjective.js +140 -0
  239. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784987015619-AddServiceLevelObjective.js.map +1 -0
  240. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1785066759532-MigrationName.js +21 -0
  241. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1785066759532-MigrationName.js.map +1 -0
  242. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +12 -0
  243. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  244. package/build/dist/Server/Services/AnalyticsDatabaseService.js +23 -6
  245. package/build/dist/Server/Services/AnalyticsDatabaseService.js.map +1 -1
  246. package/build/dist/Server/Services/Index.js +24 -0
  247. package/build/dist/Server/Services/Index.js.map +1 -1
  248. package/build/dist/Server/Services/KubernetesCostAllocationService.js +12 -0
  249. package/build/dist/Server/Services/KubernetesCostAllocationService.js.map +1 -0
  250. package/build/dist/Server/Services/MetricService.js +21 -3
  251. package/build/dist/Server/Services/MetricService.js.map +1 -1
  252. package/build/dist/Server/Services/MonitorService.js +19 -0
  253. package/build/dist/Server/Services/MonitorService.js.map +1 -1
  254. package/build/dist/Server/Services/NetworkDeviceService.js +351 -1
  255. package/build/dist/Server/Services/NetworkDeviceService.js.map +1 -1
  256. package/build/dist/Server/Services/NetworkEndpointService.js +319 -0
  257. package/build/dist/Server/Services/NetworkEndpointService.js.map +1 -0
  258. package/build/dist/Server/Services/NetworkSiteAssignmentRuleService.js +90 -0
  259. package/build/dist/Server/Services/NetworkSiteAssignmentRuleService.js.map +1 -0
  260. package/build/dist/Server/Services/NetworkSiteLinkService.js +9 -0
  261. package/build/dist/Server/Services/NetworkSiteLinkService.js.map +1 -0
  262. package/build/dist/Server/Services/NetworkSiteService.js +1038 -0
  263. package/build/dist/Server/Services/NetworkSiteService.js.map +1 -0
  264. package/build/dist/Server/Services/NetworkSiteStatusTimelineService.js +9 -0
  265. package/build/dist/Server/Services/NetworkSiteStatusTimelineService.js.map +1 -0
  266. package/build/dist/Server/Services/NetworkSiteTypeService.js +9 -0
  267. package/build/dist/Server/Services/NetworkSiteTypeService.js.map +1 -0
  268. package/build/dist/Server/Services/ProjectService.js +98 -2
  269. package/build/dist/Server/Services/ProjectService.js.map +1 -1
  270. package/build/dist/Server/Services/ServiceLevelObjectiveBurnRateRuleService.js +358 -0
  271. package/build/dist/Server/Services/ServiceLevelObjectiveBurnRateRuleService.js.map +1 -0
  272. package/build/dist/Server/Services/ServiceLevelObjectiveOwnerTeamService.js +9 -0
  273. package/build/dist/Server/Services/ServiceLevelObjectiveOwnerTeamService.js.map +1 -0
  274. package/build/dist/Server/Services/ServiceLevelObjectiveOwnerUserService.js +9 -0
  275. package/build/dist/Server/Services/ServiceLevelObjectiveOwnerUserService.js.map +1 -0
  276. package/build/dist/Server/Services/ServiceLevelObjectiveService.js +588 -0
  277. package/build/dist/Server/Services/ServiceLevelObjectiveService.js.map +1 -0
  278. package/build/dist/Server/Services/SloHistoryService.js +77 -0
  279. package/build/dist/Server/Services/SloHistoryService.js.map +1 -0
  280. package/build/dist/Server/Services/UserNotificationSettingService.js +20 -0
  281. package/build/dist/Server/Services/UserNotificationSettingService.js.map +1 -1
  282. package/build/dist/Server/Types/AnalyticsDatabase/AggregateBy.js +9 -0
  283. package/build/dist/Server/Types/AnalyticsDatabase/AggregateBy.js.map +1 -1
  284. package/build/dist/Server/Types/Database/Permissions/OwnerTableRegistry.js +15 -0
  285. package/build/dist/Server/Types/Database/Permissions/OwnerTableRegistry.js.map +1 -1
  286. package/build/dist/Server/Utils/AnalyticsDatabase/Statement.js +31 -0
  287. package/build/dist/Server/Utils/AnalyticsDatabase/Statement.js.map +1 -1
  288. package/build/dist/Server/Utils/AnalyticsDatabase/StatementGenerator.js +76 -48
  289. package/build/dist/Server/Utils/AnalyticsDatabase/StatementGenerator.js.map +1 -1
  290. package/build/dist/Server/Utils/Memory.js +9 -1
  291. package/build/dist/Server/Utils/Memory.js.map +1 -1
  292. package/build/dist/Server/Utils/Monitor/Criteria/SnmpMonitorCriteria.js +132 -10
  293. package/build/dist/Server/Utils/Monitor/Criteria/SnmpMonitorCriteria.js.map +1 -1
  294. package/build/dist/Server/Utils/Monitor/Data/OuiVendors.json +6920 -0
  295. package/build/dist/Server/Utils/Monitor/DnsResolutionCache.js +77 -0
  296. package/build/dist/Server/Utils/Monitor/DnsResolutionCache.js.map +1 -0
  297. package/build/dist/Server/Utils/Monitor/MonitorResource.js +21 -41
  298. package/build/dist/Server/Utils/Monitor/MonitorResource.js.map +1 -1
  299. package/build/dist/Server/Utils/Monitor/NetworkDeviceHydrationUtil.js +152 -40
  300. package/build/dist/Server/Utils/Monitor/NetworkDeviceHydrationUtil.js.map +1 -1
  301. package/build/dist/Server/Utils/Monitor/NetworkDeviceMetricUtil.js +262 -0
  302. package/build/dist/Server/Utils/Monitor/NetworkDeviceMetricUtil.js.map +1 -0
  303. package/build/dist/Server/Utils/Monitor/NetworkDeviceWalkUtil.js +201 -0
  304. package/build/dist/Server/Utils/Monitor/NetworkDeviceWalkUtil.js.map +1 -0
  305. package/build/dist/Server/Utils/Monitor/NetworkInventoryUtil.js +152 -120
  306. package/build/dist/Server/Utils/Monitor/NetworkInventoryUtil.js.map +1 -1
  307. package/build/dist/Server/Utils/Monitor/OuiLookupUtil.js +44 -0
  308. package/build/dist/Server/Utils/Monitor/OuiLookupUtil.js.map +1 -0
  309. package/build/dist/Server/Utils/Monitor/SnmpInterfaceRateUtil.js +10 -10
  310. package/build/dist/Server/Utils/Monitor/SnmpInterfaceRateUtil.js.map +1 -1
  311. package/build/dist/Server/Utils/WhatsAppTemplateUtil.js +5 -0
  312. package/build/dist/Server/Utils/WhatsAppTemplateUtil.js.map +1 -1
  313. package/build/dist/Types/AnalyticsDatabase/AnalyticsTableName.js +10 -0
  314. package/build/dist/Types/AnalyticsDatabase/AnalyticsTableName.js.map +1 -1
  315. package/build/dist/Types/BaseDatabase/EqualTo.js +9 -1
  316. package/build/dist/Types/BaseDatabase/EqualTo.js.map +1 -1
  317. package/build/dist/Types/BaseDatabase/EqualToOrNull.js +9 -1
  318. package/build/dist/Types/BaseDatabase/EqualToOrNull.js.map +1 -1
  319. package/build/dist/Types/BaseDatabase/NotEqual.js +9 -1
  320. package/build/dist/Types/BaseDatabase/NotEqual.js.map +1 -1
  321. package/build/dist/Types/Dashboard/DashboardComponentType.js +1 -0
  322. package/build/dist/Types/Dashboard/DashboardComponentType.js.map +1 -1
  323. package/build/dist/Types/Dashboard/DashboardComponents/ComponentArgument.js +1 -0
  324. package/build/dist/Types/Dashboard/DashboardComponents/ComponentArgument.js.map +1 -1
  325. package/build/dist/Types/Dashboard/DashboardComponents/DashboardSloComponent.js +23 -0
  326. package/build/dist/Types/Dashboard/DashboardComponents/DashboardSloComponent.js.map +1 -0
  327. package/build/dist/Types/Dashboard/DashboardTemplates.js +205 -0
  328. package/build/dist/Types/Dashboard/DashboardTemplates.js.map +1 -1
  329. package/build/dist/Types/Email/EmailTemplateType.js +1 -0
  330. package/build/dist/Types/Email/EmailTemplateType.js.map +1 -1
  331. package/build/dist/Types/Kubernetes/KubernetesCostIngest.js +21 -0
  332. package/build/dist/Types/Kubernetes/KubernetesCostIngest.js.map +1 -0
  333. package/build/dist/Types/Monitor/CriteriaFilter.js +1 -0
  334. package/build/dist/Types/Monitor/CriteriaFilter.js.map +1 -1
  335. package/build/dist/Types/Monitor/MonitorStep.js +5 -5
  336. package/build/dist/Types/Monitor/MonitorStep.js.map +1 -1
  337. package/build/dist/Types/Monitor/MonitorStepNetworkDeviceMonitor.js +8 -0
  338. package/build/dist/Types/Monitor/MonitorStepNetworkDeviceMonitor.js.map +1 -1
  339. package/build/dist/Types/Monitor/MonitorType.js +15 -5
  340. package/build/dist/Types/Monitor/MonitorType.js.map +1 -1
  341. package/build/dist/Types/Monitor/SnmpMonitor/ArpEntry.js +2 -0
  342. package/build/dist/Types/Monitor/SnmpMonitor/ArpEntry.js.map +1 -0
  343. package/build/dist/Types/Monitor/SnmpMonitor/FdbEntry.js +2 -0
  344. package/build/dist/Types/Monitor/SnmpMonitor/FdbEntry.js.map +1 -0
  345. package/build/dist/Types/Monitor/SnmpMonitor/NetworkDeviceAlertPack.js +9 -3
  346. package/build/dist/Types/Monitor/SnmpMonitor/NetworkDeviceAlertPack.js.map +1 -1
  347. package/build/dist/Types/Monitor/SnmpMonitor/SnmpVendorTemplate.js +217 -3
  348. package/build/dist/Types/Monitor/SnmpMonitor/SnmpVendorTemplate.js.map +1 -1
  349. package/build/dist/Types/NetworkSite/DefaultNetworkSiteType.js +21 -0
  350. package/build/dist/Types/NetworkSite/DefaultNetworkSiteType.js.map +1 -0
  351. package/build/dist/Types/NotificationSetting/NotificationSettingEventType.js +3 -0
  352. package/build/dist/Types/NotificationSetting/NotificationSettingEventType.js.map +1 -1
  353. package/build/dist/Types/Permission.js +409 -0
  354. package/build/dist/Types/Permission.js.map +1 -1
  355. package/build/dist/Types/ServiceLevelObjective/SliType.js +7 -0
  356. package/build/dist/Types/ServiceLevelObjective/SliType.js.map +1 -0
  357. package/build/dist/Types/ServiceLevelObjective/SloMultiMonitorMode.js +7 -0
  358. package/build/dist/Types/ServiceLevelObjective/SloMultiMonitorMode.js.map +1 -0
  359. package/build/dist/Types/ServiceLevelObjective/SloStatus.js +10 -0
  360. package/build/dist/Types/ServiceLevelObjective/SloStatus.js.map +1 -0
  361. package/build/dist/Types/ServiceLevelObjective/SloWindowType.js +7 -0
  362. package/build/dist/Types/ServiceLevelObjective/SloWindowType.js.map +1 -0
  363. package/build/dist/Types/Telemetry/ServiceType.js +1 -0
  364. package/build/dist/Types/Telemetry/ServiceType.js.map +1 -1
  365. package/build/dist/UI/Components/Filters/EntityFilter.js +15 -0
  366. package/build/dist/UI/Components/Filters/EntityFilter.js.map +1 -1
  367. package/build/dist/UI/Components/Filters/FilterViewer.js +19 -4
  368. package/build/dist/UI/Components/Filters/FilterViewer.js.map +1 -1
  369. package/build/dist/UI/Components/List/List.js +1 -1
  370. package/build/dist/UI/Components/List/List.js.map +1 -1
  371. package/build/dist/UI/Components/ModelTable/BaseModelTable.js +235 -89
  372. package/build/dist/UI/Components/ModelTable/BaseModelTable.js.map +1 -1
  373. package/build/dist/UI/Components/ModelTable/FilterDataToQuery.js +96 -0
  374. package/build/dist/UI/Components/ModelTable/FilterDataToQuery.js.map +1 -0
  375. package/build/dist/UI/Components/Navbar/NavBar.js +14 -2
  376. package/build/dist/UI/Components/Navbar/NavBar.js.map +1 -1
  377. package/build/dist/UI/Components/Navbar/NavBarMenuModal.js +3 -2
  378. package/build/dist/UI/Components/Navbar/NavBarMenuModal.js.map +1 -1
  379. package/build/dist/UI/Utils/Navigation.js +9 -0
  380. package/build/dist/UI/Utils/Navigation.js.map +1 -1
  381. package/build/dist/UI/Utils/TableFilterUrlState.js +159 -15
  382. package/build/dist/UI/Utils/TableFilterUrlState.js.map +1 -1
  383. package/build/dist/UI/Utils/TableViewUrlState.js +103 -0
  384. package/build/dist/UI/Utils/TableViewUrlState.js.map +1 -0
  385. package/build/dist/Utils/Dashboard/Components/DashboardSloComponent.js +93 -0
  386. package/build/dist/Utils/Dashboard/Components/DashboardSloComponent.js.map +1 -0
  387. package/build/dist/Utils/Dashboard/Components/Index.js +4 -0
  388. package/build/dist/Utils/Dashboard/Components/Index.js.map +1 -1
  389. package/build/dist/Utils/IpCanonicalUtil.js +110 -0
  390. package/build/dist/Utils/IpCanonicalUtil.js.map +1 -0
  391. package/build/dist/Utils/Monitor/EndpointAttachmentUtil.js +311 -0
  392. package/build/dist/Utils/Monitor/EndpointAttachmentUtil.js.map +1 -0
  393. package/build/dist/Utils/Monitor/NetworkTopologyUtil.js +98 -5
  394. package/build/dist/Utils/Monitor/NetworkTopologyUtil.js.map +1 -1
  395. package/build/dist/Utils/NetworkSite/CidrMatchUtil.js +222 -0
  396. package/build/dist/Utils/NetworkSite/CidrMatchUtil.js.map +1 -0
  397. package/build/dist/Utils/NetworkSite/MaterializedPathUtil.js +89 -0
  398. package/build/dist/Utils/NetworkSite/MaterializedPathUtil.js.map +1 -0
  399. package/build/dist/Utils/NetworkSite/SiteStatusRollupUtil.js +60 -0
  400. package/build/dist/Utils/NetworkSite/SiteStatusRollupUtil.js.map +1 -0
  401. package/build/dist/Utils/NetworkSite/SiteUptimeUtil.js +76 -0
  402. package/build/dist/Utils/NetworkSite/SiteUptimeUtil.js.map +1 -0
  403. package/build/dist/Utils/Slo/SloBurnRateRuleState.js +35 -0
  404. package/build/dist/Utils/Slo/SloBurnRateRuleState.js.map +1 -0
  405. package/build/dist/Utils/Slo/SloDuration.js +87 -0
  406. package/build/dist/Utils/Slo/SloDuration.js.map +1 -0
  407. package/build/dist/Utils/Slo/SloEvaluation.js +21 -0
  408. package/build/dist/Utils/Slo/SloEvaluation.js.map +1 -0
  409. package/build/dist/Utils/Slo/SloHealth.js +179 -0
  410. package/build/dist/Utils/Slo/SloHealth.js.map +1 -0
  411. package/build/dist/Utils/Slo/SloStatusColor.js +18 -0
  412. package/build/dist/Utils/Slo/SloStatusColor.js.map +1 -0
  413. package/build/dist/Utils/Slo/SloUtil.js +393 -0
  414. package/build/dist/Utils/Slo/SloUtil.js.map +1 -0
  415. package/build/dist/Utils/Slo/SloWidgetFormat.js +174 -0
  416. package/build/dist/Utils/Slo/SloWidgetFormat.js.map +1 -0
  417. package/package.json +2 -2
  418. package/Types/Dashboard/DashboardComponents/Index.ts +0 -7
  419. package/build/dist/Types/Dashboard/DashboardComponents/Index.js +0 -8
  420. package/build/dist/Types/Dashboard/DashboardComponents/Index.js.map +0 -1
@@ -0,0 +1,179 @@
1
+ import SliType from "../../Types/ServiceLevelObjective/SliType";
2
+ import SloMultiMonitorMode from "../../Types/ServiceLevelObjective/SloMultiMonitorMode";
3
+ import SloStatus from "../../Types/ServiceLevelObjective/SloStatus";
4
+ import SloWindowType from "../../Types/ServiceLevelObjective/SloWindowType";
5
+ /**
6
+ * The "should I be worried, and about what?" layer of the SLO UI.
7
+ *
8
+ * Two things live here, both pure and both previously inlined (and
9
+ * subtly wrong) in the React pages:
10
+ *
11
+ * 1. The remaining-budget tier that drives every red/amber/green in the
12
+ * SLO surfaces. The pages hardcoded `remaining <= 20`, which silently
13
+ * disagreed with any SLO whose `atRiskThresholdPercentage` was not the
14
+ * default 20 — an SLO could render green while the worker had already
15
+ * moved it to At Risk.
16
+ *
17
+ * 2. The reason an SLO is not producing numbers. `Misconfigured` and
18
+ * `Paused` are the two statuses that mean "we are not measuring
19
+ * anything", and the pages showed them as a bare grey pill with no
20
+ * explanation and no way to act. The reasons here mirror exactly the
21
+ * guard clauses in the evaluation worker (EvaluateSlos.evaluateSlo).
22
+ *
23
+ * Kept free of React so both the SLO pages and the dashboard SLO widget
24
+ * can import it, and so every branch is unit-testable without a DOM.
25
+ */
26
+ /** The DB default for `ServiceLevelObjective.atRiskThresholdPercentage`. */
27
+ export const DEFAULT_AT_RISK_THRESHOLD_PERCENTAGE = 20;
28
+ /** The DB default for `ServiceLevelObjective.windowDays`. */
29
+ export const DEFAULT_ROLLING_WINDOW_DAYS = 30;
30
+ export var SloBudgetTier;
31
+ (function (SloBudgetTier) {
32
+ /** The worker has not evaluated this SLO yet — assert nothing. */
33
+ SloBudgetTier["Unknown"] = "Unknown";
34
+ SloBudgetTier["Healthy"] = "Healthy";
35
+ SloBudgetTier["AtRisk"] = "AtRisk";
36
+ SloBudgetTier["Exhausted"] = "Exhausted";
37
+ })(SloBudgetTier || (SloBudgetTier = {}));
38
+ const toFiniteNumber = (value) => {
39
+ if (typeof value !== "number" || !isFinite(value)) {
40
+ return null;
41
+ }
42
+ return value;
43
+ };
44
+ export const getSloBudgetTier = (data) => {
45
+ var _a;
46
+ const remaining = toFiniteNumber(data.errorBudgetRemainingPercentage);
47
+ if (remaining === null) {
48
+ return SloBudgetTier.Unknown;
49
+ }
50
+ if (remaining <= 0) {
51
+ return SloBudgetTier.Exhausted;
52
+ }
53
+ const threshold = (_a = toFiniteNumber(data.atRiskThresholdPercentage)) !== null && _a !== void 0 ? _a : DEFAULT_AT_RISK_THRESHOLD_PERCENTAGE;
54
+ if (remaining <= threshold) {
55
+ return SloBudgetTier.AtRisk;
56
+ }
57
+ return SloBudgetTier.Healthy;
58
+ };
59
+ export var SloNoticeType;
60
+ (function (SloNoticeType) {
61
+ SloNoticeType["Info"] = "Info";
62
+ SloNoticeType["Warning"] = "Warning";
63
+ SloNoticeType["Danger"] = "Danger";
64
+ })(SloNoticeType || (SloNoticeType = {}));
65
+ export const getSloNotice = (data) => {
66
+ var _a;
67
+ if (data.isEnabled === false) {
68
+ return {
69
+ type: SloNoticeType.Info,
70
+ title: "This SLO is disabled",
71
+ body: "It is not being evaluated and its burn rate rules will not fire alerts. Turn Enabled back on in SLO Details to resume measuring.",
72
+ };
73
+ }
74
+ const monitorCount = (_a = toFiniteNumber(data.monitorCount)) !== null && _a !== void 0 ? _a : 0;
75
+ if (data.sloStatus === SloStatus.Misconfigured) {
76
+ if (data.sliType && data.sliType !== SliType.MonitorUptime) {
77
+ return {
78
+ type: SloNoticeType.Warning,
79
+ title: "This SLO cannot be evaluated",
80
+ body: `Only "${SliType.MonitorUptime}" SLIs are supported today. Change the SLI type to Monitor Uptime and attach the monitors this objective measures.`,
81
+ };
82
+ }
83
+ if (monitorCount === 0) {
84
+ return {
85
+ type: SloNoticeType.Warning,
86
+ title: "No monitors attached",
87
+ body: "An SLO measures uptime from its monitors, so it cannot be evaluated without at least one. Add monitors in SLO Details below.",
88
+ };
89
+ }
90
+ const target = toFiniteNumber(data.targetPercentage);
91
+ if (target === null || target <= 0 || target >= 100) {
92
+ return {
93
+ type: SloNoticeType.Warning,
94
+ title: "The target is out of range",
95
+ body: "A target must be greater than 0 and less than 100 — a 100% target leaves no error budget to track. Set a target such as 99.9 in SLO Details below.",
96
+ };
97
+ }
98
+ return {
99
+ type: SloNoticeType.Warning,
100
+ title: "This SLO cannot be evaluated",
101
+ body: "Check that it has monitors attached and a target below 100%, then wait a few minutes for the next evaluation.",
102
+ };
103
+ }
104
+ if (data.sloStatus === SloStatus.Paused) {
105
+ return {
106
+ type: SloNoticeType.Info,
107
+ title: "Measurement is paused",
108
+ body: "Every monitor attached to this SLO has active monitoring disabled — by hand, by a manual incident, or by a scheduled maintenance event — so there is no signal to measure. The SLO resumes automatically when a monitor starts reporting again.",
109
+ };
110
+ }
111
+ if (!data.lastEvaluatedAt) {
112
+ return {
113
+ type: SloNoticeType.Info,
114
+ title: "Not evaluated yet",
115
+ body: "OneUptime evaluates SLOs every few minutes. The first numbers will appear shortly after this SLO is created.",
116
+ };
117
+ }
118
+ return null;
119
+ };
120
+ /**
121
+ * True when a rolling-window SLO is younger than its own window, so the
122
+ * budget it is measuring against is smaller than the full-window budget.
123
+ *
124
+ * The SLI denominator is clamped forward to the earliest monitor event
125
+ * (SloUtil.computeAnyDownSli), which means `errorBudgetTotalSeconds` for a
126
+ * young SLO is proportionally short — a 30-day SLO with a week of data
127
+ * carries a 7-day budget. Both the SLOs Overview and the Error Budgets
128
+ * doc promise the dashboard flags this as "window not yet full"; this is
129
+ * the detection behind that flag.
130
+ *
131
+ * Two cases are excluded on purpose:
132
+ *
133
+ * - Calendar-month windows: their budget is fixed at the FULL period from
134
+ * day one (never prorated), so the concept does not apply.
135
+ *
136
+ * - Monitor Seconds Average: its denominator is the SUM of monitored
137
+ * seconds ACROSS monitors (SloUtil.computeMonitorSecondsAverageSli), so
138
+ * `errorBudgetTotalSeconds` scales with the monitor count and cannot be
139
+ * compared against a single-window budget. A five-monitor SLO with a
140
+ * week of data would carry 35 monitor-days against a 30-day yardstick
141
+ * and read as mature. Rather than guess at a monitor count the caller
142
+ * may not have loaded, say nothing — a missing hint beats a wrong one.
143
+ *
144
+ * The 1% tolerance absorbs the gap between "now" and the worker's last
145
+ * evaluation — without it, a fully mature SLO would flicker the banner on
146
+ * every evaluation cycle.
147
+ */
148
+ const WINDOW_FULL_TOLERANCE_FRACTION = 0.99;
149
+ export const isRollingWindowNotYetFull = (data) => {
150
+ var _a;
151
+ if (data.windowType === SloWindowType.CalendarMonth) {
152
+ return false;
153
+ }
154
+ if (data.multiMonitorMode === SloMultiMonitorMode.MonitorSecondsAverage) {
155
+ return false;
156
+ }
157
+ const budgetTotalSeconds = toFiniteNumber(data.errorBudgetTotalSeconds);
158
+ const target = toFiniteNumber(data.targetPercentage);
159
+ /*
160
+ * Not evaluated yet, or a target that would make the full-window budget
161
+ * meaningless: the "not evaluated" notice already covers the first case,
162
+ * and the Misconfigured notice covers the second.
163
+ */
164
+ if (budgetTotalSeconds === null ||
165
+ budgetTotalSeconds <= 0 ||
166
+ target === null ||
167
+ target <= 0 ||
168
+ target >= 100) {
169
+ return false;
170
+ }
171
+ const windowDays = (_a = toFiniteNumber(data.windowDays)) !== null && _a !== void 0 ? _a : DEFAULT_ROLLING_WINDOW_DAYS;
172
+ if (windowDays <= 0) {
173
+ return false;
174
+ }
175
+ const fullWindowBudgetSeconds = (1 - target / 100) * windowDays * 24 * 60 * 60;
176
+ return (budgetTotalSeconds <
177
+ fullWindowBudgetSeconds * WINDOW_FULL_TOLERANCE_FRACTION);
178
+ };
179
+ //# sourceMappingURL=SloHealth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SloHealth.js","sourceRoot":"","sources":["../../../../Utils/Slo/SloHealth.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,2CAA2C,CAAC;AAChE,OAAO,mBAAmB,MAAM,uDAAuD,CAAC;AACxF,OAAO,SAAS,MAAM,6CAA6C,CAAC;AACpE,OAAO,aAAa,MAAM,iDAAiD,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,4EAA4E;AAC5E,MAAM,CAAC,MAAM,oCAAoC,GAAW,EAAE,CAAC;AAE/D,6DAA6D;AAC7D,MAAM,CAAC,MAAM,2BAA2B,GAAW,EAAE,CAAC;AAEtD,MAAM,CAAN,IAAY,aAMX;AAND,WAAY,aAAa;IACvB,kEAAkE;IAClE,oCAAmB,CAAA;IACnB,oCAAmB,CAAA;IACnB,kCAAiB,CAAA;IACjB,wCAAuB,CAAA;AACzB,CAAC,EANW,aAAa,KAAb,aAAa,QAMxB;AAMD,MAAM,cAAc,GAA2B,CAC7C,KAAgC,EACjB,EAAE;IACjB,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,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A2BG;AACH,MAAM,8BAA8B,GAAW,IAAI,CAAC;AAUpD,MAAM,CAAC,MAAM,yBAAyB,GACpC,CAAC,IAMA,EAAW,EAAE;;IACZ,IAAI,IAAI,CAAC,UAAU,KAAK,aAAa,CAAC,aAAa,EAAE,CAAC;QACpD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,IAAI,CAAC,gBAAgB,KAAK,mBAAmB,CAAC,qBAAqB,EAAE,CAAC;QACxE,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,kBAAkB,GAAkB,cAAc,CACtD,IAAI,CAAC,uBAAuB,CAC7B,CAAC;IACF,MAAM,MAAM,GAAkB,cAAc,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAEpE;;;;OAIG;IACH,IACE,kBAAkB,KAAK,IAAI;QAC3B,kBAAkB,IAAI,CAAC;QACvB,MAAM,KAAK,IAAI;QACf,MAAM,IAAI,CAAC;QACX,MAAM,IAAI,GAAG,EACb,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,UAAU,GACd,MAAA,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,mCAAI,2BAA2B,CAAC;IAEjE,IAAI,UAAU,IAAI,CAAC,EAAE,CAAC;QACpB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,uBAAuB,GAC3B,CAAC,CAAC,GAAG,MAAM,GAAG,GAAG,CAAC,GAAG,UAAU,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;IAEjD,OAAO,CACL,kBAAkB;QAClB,uBAAuB,GAAG,8BAA8B,CACzD,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { Gray500, Green, Red, Yellow } from "../../Types/BrandColors";
2
+ import SloStatus from "../../Types/ServiceLevelObjective/SloStatus";
3
+ export const getSloStatusColor = (status) => {
4
+ if (status === SloStatus.Healthy) {
5
+ return Green;
6
+ }
7
+ if (status === SloStatus.AtRisk) {
8
+ return Yellow;
9
+ }
10
+ if (status === SloStatus.BudgetExhausted) {
11
+ return Red;
12
+ }
13
+ return Gray500;
14
+ };
15
+ export const getSloStatusText = (status) => {
16
+ return status || "Unknown";
17
+ };
18
+ //# sourceMappingURL=SloStatusColor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SloStatusColor.js","sourceRoot":"","sources":["../../../../Utils/Slo/SloStatusColor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtE,OAAO,SAAS,MAAM,6CAA6C,CAAC;AAoBpE,MAAM,CAAC,MAAM,iBAAiB,GAA8B,CAC1D,MAAoC,EAC7B,EAAE;IACT,IAAI,MAAM,KAAK,SAAS,CAAC,OAAO,EAAE,CAAC;QACjC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,MAAM,KAAK,SAAS,CAAC,MAAM,EAAE,CAAC;QAChC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,MAAM,KAAK,SAAS,CAAC,eAAe,EAAE,CAAC;QACzC,OAAO,GAAG,CAAC;IACb,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAWF,MAAM,CAAC,MAAM,gBAAgB,GAA6B,CACxD,MAAoC,EAC5B,EAAE;IACV,OAAO,MAAM,IAAI,SAAS,CAAC;AAC7B,CAAC,CAAC"}
@@ -0,0 +1,393 @@
1
+ import OneUptimeDate, { Moment } from "../../Types/Date";
2
+ import BadDataException from "../../Types/Exception/BadDataException";
3
+ import SloMultiMonitorMode from "../../Types/ServiceLevelObjective/SloMultiMonitorMode";
4
+ import SloStatus from "../../Types/ServiceLevelObjective/SloStatus";
5
+ import UptimeUtil from "../Uptime/UptimeUtil";
6
+ /**
7
+ * SLO / error budget math. Isomorphic (no server imports) so it is shared by the
8
+ * worker, the dashboard, and later the status page - exactly like UptimeUtil.
9
+ *
10
+ * Design notes (see SLO design doc paragraph 3.1 / 5):
11
+ *
12
+ * - Multi-monitor downtime must NOT be computed by feeding several monitors into
13
+ * UptimeUtil.getNonOverlappingMonitorEvents: its priority flatten lets a
14
+ * better-status event that merely ends later truncate a concurrent worse-status
15
+ * event (Monitor A Offline 10:00-11:00 + Monitor B Operational 10:30-12:00
16
+ * silently loses 30 minutes of downtime). That flatten was built for rendering
17
+ * one status-page bar, not cross-monitor budget math. This util therefore works
18
+ * per monitor (getMonitorEventsForId is per-monitor and correct) and combines
19
+ * monitors with explicit semantics (SloMultiMonitorMode).
20
+ *
21
+ * - Every comparison against a threshold uses UNROUNDED values. Round only at
22
+ * render time (roundForDisplay floors - fine for display, wrong for
23
+ * classification).
24
+ */
25
+ export default class SloUtil {
26
+ /**
27
+ * Extracts the downtime intervals of a SINGLE monitor inside the window.
28
+ * Uses UptimeUtil.getMonitorEventsForId, which is per-monitor: it clips events
29
+ * to the window, caps them at "now" and imputes an end for open
30
+ * (endsAt = null) rows. Events whose status is not in `downtimeStatuses` are
31
+ * dropped.
32
+ */
33
+ static getDowntimeIntervalsForMonitor(monitorId, timelines, downtimeStatuses, window) {
34
+ const events = UptimeUtil.getMonitorEventsForId(monitorId, timelines, window);
35
+ const intervals = [];
36
+ for (const event of events) {
37
+ const isDowntimeEvent = Boolean(downtimeStatuses.find((status) => {
38
+ var _a;
39
+ return ((_a = status.id) === null || _a === void 0 ? void 0 : _a.toString()) === event.eventStatusId.toString();
40
+ }));
41
+ if (isDowntimeEvent) {
42
+ intervals.push({
43
+ startDate: event.startDate,
44
+ endDate: event.endDate,
45
+ });
46
+ }
47
+ }
48
+ return intervals;
49
+ }
50
+ /**
51
+ * The EARLIEST event start across the attached monitors inside `window`, or
52
+ * null when no monitor has an event that overlaps the window at all.
53
+ *
54
+ * Uses the SAME UptimeUtil.getMonitorEventsForId clipping path the SLI
55
+ * denominator uses, so the answer has identical semantics to the clamp inside
56
+ * computeTimeSli: because events are clipped to the window, the returned date
57
+ * is always >= window.startDate, i.e. it is "how far back this window can
58
+ * actually see data".
59
+ *
60
+ * This exists for callers that must distinguish "the metric is fine" from
61
+ * "we have not observed enough history to judge it yet" - most importantly the
62
+ * burn-rate evaluator, whose FIXED-LENGTH long window would otherwise silently
63
+ * collapse to the data age (see EvaluateSlos.evaluateBurnRateRule).
64
+ */
65
+ static getEarliestEventStartDate(perMonitorTimelines, window) {
66
+ let earliestEventStart = null;
67
+ for (const monitor of perMonitorTimelines) {
68
+ const events = UptimeUtil.getMonitorEventsForId(monitor.monitorId, monitor.timelines, window);
69
+ for (const event of events) {
70
+ if (!earliestEventStart ||
71
+ event.startDate.getTime() < earliestEventStart.getTime()) {
72
+ earliestEventStart = event.startDate;
73
+ }
74
+ }
75
+ }
76
+ return earliestEventStart;
77
+ }
78
+ /**
79
+ * Merges overlapping and adjacent intervals into a disjoint, sorted set.
80
+ * Millisecond-precise (raw timestamps, not second-granularity moment
81
+ * comparisons) so the merged length agrees with
82
+ * OneUptimeDate.getSecondsBetweenDates.
83
+ */
84
+ static mergeIntervals(intervals) {
85
+ const sorted = [...intervals].sort((a, b) => {
86
+ return a.startDate.getTime() - b.startDate.getTime();
87
+ });
88
+ const merged = [];
89
+ for (const interval of sorted) {
90
+ // skip empty / inverted intervals.
91
+ if (interval.endDate.getTime() <= interval.startDate.getTime()) {
92
+ continue;
93
+ }
94
+ const last = merged[merged.length - 1];
95
+ // overlapping OR adjacent (start === last end) -> extend the last interval.
96
+ if (last && interval.startDate.getTime() <= last.endDate.getTime()) {
97
+ if (interval.endDate.getTime() > last.endDate.getTime()) {
98
+ last.endDate = interval.endDate;
99
+ }
100
+ continue;
101
+ }
102
+ merged.push({
103
+ startDate: interval.startDate,
104
+ endDate: interval.endDate,
105
+ });
106
+ }
107
+ return merged;
108
+ }
109
+ /**
110
+ * Union downtime across monitors: per monitor, extract its down intervals from
111
+ * its OWN event list, then take the interval union across monitors and sum the
112
+ * seconds. This is the AnyDown numerator.
113
+ *
114
+ * The correctness case this exists for: Monitor A Offline 10:00-11:00 while
115
+ * Monitor B is Operational 10:30-12:00 must yield 3600 seconds of downtime,
116
+ * NOT 1800 - which is what the cross-monitor priority flatten in
117
+ * UptimeUtil.getNonOverlappingMonitorEvents produces.
118
+ */
119
+ static getUnionDowntimeSeconds(perMonitor, downtimeStatuses, window) {
120
+ const allIntervals = [];
121
+ for (const monitor of perMonitor) {
122
+ allIntervals.push(...this.getDowntimeIntervalsForMonitor(monitor.monitorId, monitor.timelines, downtimeStatuses, window));
123
+ }
124
+ const merged = this.mergeIntervals(allIntervals);
125
+ let totalSeconds = 0;
126
+ for (const interval of merged) {
127
+ totalSeconds += OneUptimeDate.getSecondsBetweenDates(interval.startDate, interval.endDate);
128
+ }
129
+ return totalSeconds;
130
+ }
131
+ /**
132
+ * Time-based SLI over MonitorStatusTimeline data.
133
+ *
134
+ * Denominator rules:
135
+ * - The window end is always clipped to "now" (a window reaching into the
136
+ * future must not inflate the denominator).
137
+ * - AnyDown: the window start is clamped forward to the EARLIEST first event
138
+ * across the attached monitors, so a young SLO is measured from its first
139
+ * data point, not diluted by time before any monitor existed. The clamp uses
140
+ * the merged set's earliest event so that one old monitor anchors the window
141
+ * for the whole SLO.
142
+ * - MonitorSecondsAverage: the clamp happens PER MONITOR (each monitor's own
143
+ * first event), mirroring UptimeUtil.getTotalDowntimeInSeconds - otherwise
144
+ * adding a young monitor dilutes the SLI.
145
+ *
146
+ * No data at all (no timeline rows for any monitor) => totalSeconds 0,
147
+ * sliPercentage 100 - callers decide what "no data" means (the evaluator marks
148
+ * such SLOs Misconfigured/Paused; it never treats them as healthy 100%).
149
+ *
150
+ * Rows exist but none overlap the window => the monitor was up for the whole
151
+ * window as far as the window can tell: full-window denominator, 0 bad seconds
152
+ * (same answer UptimeUtil gives - see the "orphaned row" production incident
153
+ * test in UptimeUtil.test.ts).
154
+ *
155
+ * All values are UNROUNDED.
156
+ */
157
+ static computeTimeSli(data) {
158
+ const { perMonitorTimelines, downtimeStatuses, window, mode } = data;
159
+ const hasAnyTimelineRows = perMonitorTimelines.some((monitor) => {
160
+ return monitor.timelines.length > 0;
161
+ });
162
+ if (!hasAnyTimelineRows) {
163
+ return {
164
+ badSeconds: 0,
165
+ totalSeconds: 0,
166
+ sliPercentage: 100,
167
+ };
168
+ }
169
+ if (mode === SloMultiMonitorMode.MonitorSecondsAverage) {
170
+ return this.computeMonitorSecondsAverageSli({
171
+ perMonitorTimelines,
172
+ downtimeStatuses,
173
+ window,
174
+ });
175
+ }
176
+ return this.computeAnyDownSli({
177
+ perMonitorTimelines,
178
+ downtimeStatuses,
179
+ window,
180
+ });
181
+ }
182
+ static computeAnyDownSli(data) {
183
+ const { perMonitorTimelines, downtimeStatuses, window } = data;
184
+ const windowEndDate = OneUptimeDate.getLesserDate(window.endDate, OneUptimeDate.getCurrentDate());
185
+ /*
186
+ * Earliest first event across monitors. Events from getMonitorEventsForId are
187
+ * already clipped to the window, so every start is >= window.startDate: the
188
+ * clamp can only move the window start FORWARD (young SLO), never backward.
189
+ */
190
+ const earliestEventStart = this.getEarliestEventStartDate(perMonitorTimelines, window);
191
+ /*
192
+ * Rows exist but none clip into the window: as far as the window can tell the
193
+ * monitors were up throughout - full-window denominator, zero bad seconds
194
+ * (matches UptimeUtil's behaviour for the same input).
195
+ */
196
+ const windowStartDate = earliestEventStart
197
+ ? OneUptimeDate.getGreaterDate(window.startDate, earliestEventStart)
198
+ : window.startDate;
199
+ const totalSeconds = OneUptimeDate.getSecondsBetweenDates(windowStartDate, windowEndDate);
200
+ if (totalSeconds <= 0) {
201
+ return {
202
+ badSeconds: 0,
203
+ totalSeconds: 0,
204
+ sliPercentage: 100,
205
+ };
206
+ }
207
+ const badSeconds = this.getUnionDowntimeSeconds(perMonitorTimelines, downtimeStatuses, window);
208
+ return {
209
+ badSeconds,
210
+ totalSeconds,
211
+ sliPercentage: ((totalSeconds - badSeconds) / totalSeconds) * 100,
212
+ };
213
+ }
214
+ static computeMonitorSecondsAverageSli(data) {
215
+ const { perMonitorTimelines, downtimeStatuses, window } = data;
216
+ let badSeconds = 0;
217
+ let totalSeconds = 0;
218
+ for (const monitor of perMonitorTimelines) {
219
+ /*
220
+ * Guard against rows of other monitors leaking into this monitor's array -
221
+ * getTotalDowntimeInSeconds does not filter by monitor id, and feeding it a
222
+ * multi-monitor array would reintroduce the priority-flatten bug.
223
+ */
224
+ const ownTimelines = monitor.timelines.filter((timeline) => {
225
+ var _a;
226
+ return (((_a = timeline.monitorId) === null || _a === void 0 ? void 0 : _a.toString()) === monitor.monitorId.toString());
227
+ });
228
+ /*
229
+ * A monitor with no timeline rows at all has no data - skip it instead of
230
+ * letting it contribute a full window of implied uptime.
231
+ */
232
+ if (ownTimelines.length === 0) {
233
+ continue;
234
+ }
235
+ const { totalDowntimeInSeconds, totalSecondsInTimePeriod, } = UptimeUtil.getTotalDowntimeInSeconds(ownTimelines, downtimeStatuses, window);
236
+ badSeconds += totalDowntimeInSeconds;
237
+ totalSeconds += totalSecondsInTimePeriod;
238
+ }
239
+ if (totalSeconds <= 0) {
240
+ return {
241
+ badSeconds: 0,
242
+ totalSeconds: 0,
243
+ sliPercentage: 100,
244
+ };
245
+ }
246
+ return {
247
+ badSeconds,
248
+ totalSeconds,
249
+ sliPercentage: (1 - badSeconds / totalSeconds) * 100,
250
+ };
251
+ }
252
+ /**
253
+ * Error budget from an SLI measurement.
254
+ *
255
+ * Provide either `sliPercentage` or `badSeconds` (badSeconds wins when both are
256
+ * given, since it is the exact number the SLI was derived from).
257
+ *
258
+ * budgetRemainingSeconds is SIGNED - negative when over budget. Never clamp it
259
+ * here; clamp in the UI only. budgetRemainingPercentage is capped at 100 but
260
+ * NOT floored at 0.
261
+ */
262
+ static getErrorBudget(data) {
263
+ const { sliPercentage, badSeconds, totalSeconds, targetPercentage } = data;
264
+ this.validateTargetPercentage(targetPercentage);
265
+ if (badSeconds === undefined && sliPercentage === undefined) {
266
+ throw new BadDataException("Either sliPercentage or badSeconds must be provided to compute the error budget.");
267
+ }
268
+ // no elapsed window yet => nothing consumed, full budget remaining.
269
+ if (totalSeconds === 0) {
270
+ return {
271
+ budgetTotalSeconds: 0,
272
+ budgetConsumedSeconds: 0,
273
+ budgetRemainingSeconds: 0,
274
+ budgetRemainingPercentage: 100,
275
+ };
276
+ }
277
+ const allowedBadFraction = 1 - targetPercentage / 100;
278
+ const budgetTotalSeconds = allowedBadFraction * totalSeconds;
279
+ const budgetConsumedSeconds = badSeconds !== undefined
280
+ ? badSeconds
281
+ : (1 - sliPercentage / 100) * totalSeconds;
282
+ const budgetRemainingSeconds = budgetTotalSeconds - budgetConsumedSeconds;
283
+ const budgetRemainingPercentage = Math.min(100, (budgetRemainingSeconds / budgetTotalSeconds) * 100);
284
+ return {
285
+ budgetTotalSeconds,
286
+ budgetConsumedSeconds,
287
+ budgetRemainingSeconds,
288
+ budgetRemainingPercentage,
289
+ };
290
+ }
291
+ /**
292
+ * Burn rate: how many times faster than "exactly on target" the budget is being
293
+ * consumed over the measured period. 1 = burning exactly the sustainable rate,
294
+ * 14.4 = the canonical fast-burn page threshold for a 30-day window.
295
+ *
296
+ * Works identically for seconds (time-based SLIs) and event counts (event-based
297
+ * SLIs) - pass bad/total counts in badSeconds/totalSeconds.
298
+ *
299
+ * totalSeconds === 0 (no data in the lookback) => 0: no evidence of burn -
300
+ * callers skip burn rules on no-data windows.
301
+ */
302
+ static computeBurnRate(data) {
303
+ const { badSeconds, totalSeconds, targetPercentage } = data;
304
+ this.validateTargetPercentage(targetPercentage);
305
+ if (totalSeconds === 0) {
306
+ return 0;
307
+ }
308
+ const allowedBadFraction = 1 - targetPercentage / 100;
309
+ return badSeconds / totalSeconds / allowedBadFraction;
310
+ }
311
+ /**
312
+ * Status from remaining budget, with hysteresis so rolling windows that
313
+ * re-cross a boundary as bad seconds age out do not flap:
314
+ *
315
+ * - enter BudgetExhausted when remaining <= 0; exit only when remaining >= 2
316
+ * - enter AtRisk when remaining <= atRiskThreshold; exit back to Healthy only
317
+ * when remaining >= atRiskThreshold + 5
318
+ *
319
+ * All comparisons use UNROUNDED percentages. This function never emits
320
+ * Misconfigured or Paused - those are set by the caller (zero monitors /
321
+ * all monitors paused) before any math runs.
322
+ */
323
+ static computeSloStatus(data) {
324
+ const { budgetRemainingPercentage, currentStatus } = data;
325
+ const threshold = data.atRiskThresholdPercentage;
326
+ // enter exhausted.
327
+ if (budgetRemainingPercentage <= 0) {
328
+ return SloStatus.BudgetExhausted;
329
+ }
330
+ // hysteresis: stay exhausted until the budget has meaningfully recovered.
331
+ if (currentStatus === SloStatus.BudgetExhausted &&
332
+ budgetRemainingPercentage < 2) {
333
+ return SloStatus.BudgetExhausted;
334
+ }
335
+ // enter at risk.
336
+ if (budgetRemainingPercentage <= threshold) {
337
+ return SloStatus.AtRisk;
338
+ }
339
+ // hysteresis: stay at risk until comfortably above the threshold.
340
+ if (currentStatus === SloStatus.AtRisk &&
341
+ budgetRemainingPercentage < threshold + 5) {
342
+ return SloStatus.AtRisk;
343
+ }
344
+ return SloStatus.Healthy;
345
+ }
346
+ /**
347
+ * The full calendar month containing `at`, resolved in the given IANA timezone
348
+ * (default UTC - calendar boundaries are undefined without a zone). Timezone
349
+ * support comes from moment-timezone, which OneUptimeDate already wraps.
350
+ *
351
+ * `endDate` is EXCLUSIVE (the first instant of the next month).
352
+ * `totalSecondsInFullPeriod` is the real elapsed seconds of the whole month and
353
+ * is the budget denominator for calendar windows - fixed at period start, NOT
354
+ * elapsed time. Note the rollover consequence: on the 1st the budget silently
355
+ * resets to full.
356
+ */
357
+ static getCalendarMonthWindow(data) {
358
+ const timezone = data.timezone || "UTC";
359
+ if (!Moment.tz.zone(timezone)) {
360
+ throw new BadDataException(`Unknown timezone: ${timezone}`);
361
+ }
362
+ const startOfMonth = Moment.tz(data.at, timezone).startOf("month");
363
+ const startDate = startOfMonth.toDate();
364
+ const endDate = startOfMonth.clone().add(1, "month").toDate();
365
+ return {
366
+ startDate,
367
+ endDate,
368
+ totalSecondsInFullPeriod: OneUptimeDate.getSecondsBetweenDates(startDate, endDate),
369
+ };
370
+ }
371
+ /**
372
+ * Display-only rounding (delegates to UptimeUtil.roundToPrecision, which
373
+ * FLOORS). All status/threshold comparisons in this util use unrounded values;
374
+ * use this at render time only - never before classification.
375
+ */
376
+ static roundForDisplay(value, precision) {
377
+ return UptimeUtil.roundToPrecision({
378
+ number: value,
379
+ precision,
380
+ });
381
+ }
382
+ static validateTargetPercentage(targetPercentage) {
383
+ /*
384
+ * target >= 100 makes allowedBadFraction 0 (or negative): every budget
385
+ * formula divides by zero and NaN propagates everywhere. target <= 0 is
386
+ * meaningless.
387
+ */
388
+ if (targetPercentage >= 100 || targetPercentage <= 0) {
389
+ throw new BadDataException("SLO target percentage must be greater than 0 and less than 100.");
390
+ }
391
+ }
392
+ }
393
+ //# sourceMappingURL=SloUtil.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SloUtil.js","sourceRoot":"","sources":["../../../../Utils/Slo/SloUtil.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,gBAAgB,MAAM,wCAAwC,CAAC;AAGtE,OAAO,mBAAmB,MAAM,uDAAuD,CAAC;AACxF,OAAO,SAAS,MAAM,6CAA6C,CAAC;AAEpE,OAAO,UAA4B,MAAM,sBAAsB,CAAC;AA2DhE;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,OAAO,OAAO,OAAO;IAC1B;;;;;;OAMG;IACI,MAAM,CAAC,8BAA8B,CAC1C,SAAmB,EACnB,SAAuC,EACvC,gBAAsC,EACtC,MAAoB;QAEpB,MAAM,MAAM,GAAwB,UAAU,CAAC,qBAAqB,CAClE,SAAS,EACT,SAAS,EACT,MAAM,CACP,CAAC;QAEF,MAAM,SAAS,GAA4B,EAAE,CAAC;QAE9C,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,MAAM,eAAe,GAAY,OAAO,CACtC,gBAAgB,CAAC,IAAI,CAAC,CAAC,MAAqB,EA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