@oneuptime/common 14.0.110 → 14.1.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 (322) hide show
  1. package/Models/DatabaseModels/AIRunRecording.d.mts +12 -0
  2. package/Models/DatabaseModels/AIRunRecording.d.ts +12 -0
  3. package/Models/DatabaseModels/AIRunRecording.js +181 -0
  4. package/Models/DatabaseModels/AIRunRecording.mjs +2 -0
  5. package/Models/DatabaseModels/Alert.js +18 -2
  6. package/Models/DatabaseModels/DataStore.js +9 -0
  7. package/Models/DatabaseModels/EmailLog.js +2 -2
  8. package/Models/DatabaseModels/Form.js +3 -3
  9. package/Models/DatabaseModels/FormSubmission.js +4 -4
  10. package/Models/DatabaseModels/GlobalConfig.js +46 -45
  11. package/Models/DatabaseModels/Incident.js +18 -2
  12. package/Models/DatabaseModels/IncidentSlaRule.js +2 -2
  13. package/Models/DatabaseModels/Index.js +4 -0
  14. package/Models/DatabaseModels/InventoryItem.js +11 -0
  15. package/Models/DatabaseModels/Monitor.js +51 -17
  16. package/Models/DatabaseModels/MonitorNetworkDevice.d.mts +11 -0
  17. package/Models/DatabaseModels/MonitorNetworkDevice.d.ts +11 -0
  18. package/Models/DatabaseModels/MonitorNetworkDevice.js +189 -0
  19. package/Models/DatabaseModels/MonitorNetworkDevice.mjs +2 -0
  20. package/Models/DatabaseModels/MonitorProbe.js +22 -5
  21. package/Models/DatabaseModels/NetworkDevice.js +23 -7
  22. package/Models/DatabaseModels/NetworkEndpoint.d.mts +1 -0
  23. package/Models/DatabaseModels/NetworkEndpoint.d.ts +1 -0
  24. package/Models/DatabaseModels/NetworkEndpoint.js +39 -7
  25. package/Models/DatabaseModels/NetworkInterface.js +5 -5
  26. package/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.js +19 -5
  27. package/Models/DatabaseModels/OnCallDutyPolicyFeed.d.mts +1 -0
  28. package/Models/DatabaseModels/OnCallDutyPolicyFeed.d.ts +1 -0
  29. package/Models/DatabaseModels/OnCallDutyPolicyFeed.js +2 -0
  30. package/Models/DatabaseModels/OnCallDutyPolicyUserOverride.js +35 -7
  31. package/Models/DatabaseModels/OpenStackCloudCheck.js +8 -1
  32. package/Models/DatabaseModels/Project.d.mts +1 -0
  33. package/Models/DatabaseModels/Project.d.ts +1 -0
  34. package/Models/DatabaseModels/Project.js +46 -3
  35. package/Models/DatabaseModels/ProjectCallSMSConfig.js +3 -1
  36. package/Models/DatabaseModels/ProjectSmtpConfig.js +2 -0
  37. package/Models/DatabaseModels/PublicNoteApprovalRequest.js +3 -3
  38. package/Models/DatabaseModels/PublicNoteApprovalStep.js +1 -1
  39. package/Models/DatabaseModels/RunbookExecution.js +2 -2
  40. package/Models/DatabaseModels/RunbookRule.js +6 -6
  41. package/Models/DatabaseModels/ScheduledMaintenance.js +3 -3
  42. package/Models/DatabaseModels/ScheduledMaintenanceCalendarFeed.js +1 -1
  43. package/Models/DatabaseModels/ScheduledMaintenanceLabelRule.js +1 -1
  44. package/Models/DatabaseModels/ScheduledMaintenanceMeasurement.js +7 -7
  45. package/Models/DatabaseModels/ScheduledMaintenanceMeasurementValue.js +1 -1
  46. package/Models/DatabaseModels/ScheduledMaintenanceOwnerRule.js +6 -6
  47. package/Models/DatabaseModels/ScheduledMaintenanceOwnerTeam.js +4 -4
  48. package/Models/DatabaseModels/ScheduledMaintenanceOwnerUser.js +4 -4
  49. package/Models/DatabaseModels/ScheduledMaintenancePublicNote.js +3 -3
  50. package/Models/DatabaseModels/ScheduledMaintenanceReminderRule.js +4 -4
  51. package/Models/DatabaseModels/ScheduledMaintenanceStateTimeline.js +3 -3
  52. package/Models/DatabaseModels/ScheduledMaintenanceTemplate.js +5 -5
  53. package/Models/DatabaseModels/TeamMember.js +10 -1
  54. package/Models/DatabaseModels/WorkspaceNotificationRule.js +36 -1
  55. package/Models/DatabaseModels/WorkspaceNotificationSummary.js +1 -1
  56. package/Models/DatabaseModels/WorkspacePublicNoteApprovalMessage.js +3 -3
  57. package/Server/Services/DatabaseService.d.mts +4 -1
  58. package/Server/Services/DatabaseService.d.ts +4 -1
  59. package/Server/Types/Database/CountBy.d.mts +1 -0
  60. package/Server/Types/Database/CountBy.d.ts +1 -0
  61. package/Server/Types/Database/UpdateLimit.d.mts +6 -0
  62. package/Server/Types/Database/UpdateLimit.d.ts +6 -0
  63. package/Types/AI/AIActionWords.d.mts +25 -1
  64. package/Types/AI/AIActionWords.d.ts +25 -1
  65. package/Types/AI/AIActionWords.js +166 -3
  66. package/Types/AI/AIActionWords.mjs +6 -0
  67. package/Types/AI/AIChatTypes.d.mts +2 -1
  68. package/Types/AI/AIChatTypes.d.ts +2 -1
  69. package/Types/AI/AiOutcomes.d.mts +57 -0
  70. package/Types/AI/AiOutcomes.d.ts +57 -0
  71. package/Types/AI/AiOutcomes.js +67 -0
  72. package/Types/AI/AiOutcomes.mjs +10 -0
  73. package/Types/AI/AiRunRefusal.d.mts +45 -0
  74. package/Types/AI/AiRunRefusal.d.ts +45 -0
  75. package/Types/AI/AiRunRefusal.js +187 -0
  76. package/Types/AI/AiRunRefusal.mjs +12 -0
  77. package/Types/AI/InvestigationRecording.d.mts +46 -0
  78. package/Types/AI/InvestigationRecording.d.ts +46 -0
  79. package/Types/AI/InvestigationRecording.js +42 -0
  80. package/Types/AI/InvestigationRecording.mjs +7 -0
  81. package/Types/API/HTTPResponse.d.mts +3 -0
  82. package/Types/API/HTTPResponse.d.ts +3 -0
  83. package/Types/API/HTTPResponse.js +15 -0
  84. package/Types/BaseDatabase/AggregateBy.d.mts +16 -0
  85. package/Types/BaseDatabase/AggregateBy.d.ts +16 -0
  86. package/Types/BaseDatabase/AggregationIntervalUtil.d.mts +16 -1
  87. package/Types/BaseDatabase/AggregationIntervalUtil.d.ts +16 -1
  88. package/Types/BaseDatabase/AggregationIntervalUtil.js +92 -2
  89. package/Types/BaseDatabase/ListResult.d.mts +1 -0
  90. package/Types/BaseDatabase/ListResult.d.ts +1 -0
  91. package/Types/CallAndSMS/ServerTwilioEnvironment.d.mts +47 -0
  92. package/Types/CallAndSMS/ServerTwilioEnvironment.d.ts +47 -0
  93. package/Types/CallAndSMS/ServerTwilioEnvironment.js +282 -0
  94. package/Types/CallAndSMS/ServerTwilioEnvironment.mjs +7 -0
  95. package/Types/Dashboard/DashboardAutoRefresh.d.mts +1 -0
  96. package/Types/Dashboard/DashboardAutoRefresh.d.ts +1 -0
  97. package/Types/Dashboard/DashboardAutoRefresh.js +21 -0
  98. package/Types/Dashboard/DashboardAutoRefresh.mjs +1 -0
  99. package/Types/Date.d.mts +6 -1
  100. package/Types/Date.d.ts +6 -1
  101. package/Types/Date.js +39 -7
  102. package/Types/Date.mjs +1 -0
  103. package/Types/Email/ServerEmailEnvironment.d.mts +85 -0
  104. package/Types/Email/ServerEmailEnvironment.d.ts +85 -0
  105. package/Types/Email/ServerEmailEnvironment.js +793 -0
  106. package/Types/Email/ServerEmailEnvironment.mjs +14 -0
  107. package/Types/Exception/AiRunRefusalException.d.mts +6 -0
  108. package/Types/Exception/AiRunRefusalException.d.ts +6 -0
  109. package/Types/Exception/AiRunRefusalException.js +23 -0
  110. package/Types/Exception/AiRunRefusalException.mjs +2 -0
  111. package/Types/Form/FormTargetCatalog.js +2 -2
  112. package/Types/Form/FormTargetType.js +2 -2
  113. package/Types/ListData.d.mts +2 -0
  114. package/Types/ListData.d.ts +2 -0
  115. package/Types/ListData.js +4 -0
  116. package/Types/Monitor/MonitorCriteriaInstance.js +9 -0
  117. package/Types/Monitor/MonitorNotCheckedReason.d.mts +7 -0
  118. package/Types/Monitor/MonitorNotCheckedReason.d.ts +7 -0
  119. package/Types/Monitor/MonitorNotCheckedReason.js +36 -0
  120. package/Types/Monitor/MonitorNotCheckedReason.mjs +4 -0
  121. package/Types/Monitor/SnmpMonitor/NetworkTopology.d.mts +6 -0
  122. package/Types/Monitor/SnmpMonitor/NetworkTopology.d.ts +6 -0
  123. package/Types/Monitor/UptimeHistoryLabels.js +2 -2
  124. package/Types/OnCallDutyPolicy/GlobalUserOverrideAccess.d.mts +1 -0
  125. package/Types/OnCallDutyPolicy/GlobalUserOverrideAccess.d.ts +1 -0
  126. package/Types/OnCallDutyPolicy/GlobalUserOverrideAccess.js +12 -9
  127. package/Types/OnCallDutyPolicy/GlobalUserOverrideAccess.mjs +1 -0
  128. package/Types/OnCallDutyPolicy/OnCallAcknowledgePage.d.mts +3 -1
  129. package/Types/OnCallDutyPolicy/OnCallAcknowledgePage.d.ts +3 -1
  130. package/Types/OnCallDutyPolicy/OnCallAcknowledgePage.js +24 -6
  131. package/Types/OnCallDutyPolicy/OnCallAcknowledgePage.mjs +1 -0
  132. package/Types/OnCallDutyPolicy/OnCallPagePassOn.d.mts +1 -0
  133. package/Types/OnCallDutyPolicy/OnCallPagePassOn.d.ts +1 -0
  134. package/Types/OnCallDutyPolicy/OnCallPolicyStartedByHand.d.mts +12 -0
  135. package/Types/OnCallDutyPolicy/OnCallPolicyStartedByHand.d.ts +12 -0
  136. package/Types/OnCallDutyPolicy/OnCallPolicyStartedByHand.js +38 -0
  137. package/Types/OnCallDutyPolicy/OnCallPolicyStartedByHand.mjs +3 -0
  138. package/Types/OnCallDutyPolicy/ScheduleLayersSave.d.mts +92 -0
  139. package/Types/OnCallDutyPolicy/ScheduleLayersSave.d.ts +92 -0
  140. package/Types/OnCallDutyPolicy/ScheduleLayersSave.js +512 -0
  141. package/Types/OnCallDutyPolicy/ScheduleLayersSave.mjs +7 -0
  142. package/Types/OnCallDutyPolicy/UserOverrideEdit.d.mts +23 -0
  143. package/Types/OnCallDutyPolicy/UserOverrideEdit.d.ts +23 -0
  144. package/Types/OnCallDutyPolicy/UserOverrideEdit.js +105 -0
  145. package/Types/OnCallDutyPolicy/UserOverrideEdit.mjs +6 -0
  146. package/Types/OnCallDutyPolicy/UserOverrideOverlap.d.mts +64 -0
  147. package/Types/OnCallDutyPolicy/UserOverrideOverlap.d.ts +64 -0
  148. package/Types/OnCallDutyPolicy/UserOverrideOverlap.js +237 -0
  149. package/Types/OnCallDutyPolicy/UserOverrideOverlap.mjs +14 -0
  150. package/Types/Permission.js +2 -2
  151. package/Types/Probe/ProbeCapability.d.mts +2 -1
  152. package/Types/Probe/ProbeCapability.d.ts +2 -1
  153. package/Types/Probe/ProbeCapability.js +10 -0
  154. package/Types/ReaderLanguage.d.mts +1 -0
  155. package/Types/ReaderLanguage.d.ts +1 -0
  156. package/Types/ReaderLanguage.js +13 -1
  157. package/Types/ReaderLanguage.mjs +1 -0
  158. package/Types/Rules/RuleRun.js +2 -2
  159. package/Types/ScheduledMaintenance/MaintenanceCalendar.js +1 -1
  160. package/Types/ServerSending/ServerSendingStatus.d.mts +7 -0
  161. package/Types/ServerSending/ServerSendingStatus.d.ts +7 -0
  162. package/Types/ServerSending/ServerSendingStatus.js +49 -2
  163. package/Types/ServerSetup/ServerSetupChecklist.js +3 -3
  164. package/Types/StateTimeline/RowsKeptOnDelete.js +1 -1
  165. package/Types/StatusPage/NewIncidentSubscriberNotificationDefault.d.mts +8 -0
  166. package/Types/StatusPage/NewIncidentSubscriberNotificationDefault.d.ts +8 -0
  167. package/Types/StatusPage/NewIncidentSubscriberNotificationDefault.js +50 -0
  168. package/Types/StatusPage/NewIncidentSubscriberNotificationDefault.mjs +3 -0
  169. package/Types/StatusPage/PublicNoteSubscriberNotificationDefault.js +1 -1
  170. package/Types/Telemetry/CompatibleIngest.d.mts +20 -0
  171. package/Types/Telemetry/CompatibleIngest.d.ts +20 -0
  172. package/Types/Telemetry/CompatibleIngest.js +123 -0
  173. package/Types/Telemetry/CompatibleIngest.mjs +21 -0
  174. package/Types/Telemetry/TelemetryIngestSurface.d.mts +5 -0
  175. package/Types/Telemetry/TelemetryIngestSurface.d.ts +5 -0
  176. package/Types/Telemetry/TelemetryIngestSurface.js +48 -7
  177. package/Types/TimezoneAlias.d.mts +1 -0
  178. package/Types/TimezoneAlias.d.ts +1 -0
  179. package/Types/TimezoneAlias.js +13 -0
  180. package/Types/Translator.js +374 -48
  181. package/Types/Workflow/RunRecord.js +1 -1
  182. package/Types/Workflow/Templates.js +2 -2
  183. package/Types/Workspace/NotificationRules/BaseNotificationRule.d.mts +2 -0
  184. package/Types/Workspace/NotificationRules/BaseNotificationRule.d.ts +2 -0
  185. package/Types/Workspace/NotificationRules/NotificationRuleCondition.d.mts +26 -1
  186. package/Types/Workspace/NotificationRules/NotificationRuleCondition.d.ts +26 -1
  187. package/Types/Workspace/NotificationRules/NotificationRuleUpdates.d.mts +84 -0
  188. package/Types/Workspace/NotificationRules/NotificationRuleUpdates.d.ts +84 -0
  189. package/Types/Workspace/NotificationRules/NotificationRuleUpdates.js +456 -0
  190. package/Types/Workspace/NotificationRules/NotificationRuleUpdates.mjs +5 -0
  191. package/Utils/Dashboard/ValueWidgetSeries.d.mts +2 -0
  192. package/Utils/Dashboard/ValueWidgetSeries.d.ts +2 -0
  193. package/Utils/Dashboard/ValueWidgetSeries.js +75 -0
  194. package/Utils/DeveloperDocs/ExampleBuilder.js +1 -1
  195. package/Utils/DeveloperDocs/ResourceProfiles.js +2 -2
  196. package/Utils/GuidedSetup/StatusPageRecords.d.mts +5 -0
  197. package/Utils/GuidedSetup/StatusPageRecords.d.ts +5 -0
  198. package/Utils/GuidedSetup/StatusPageRecords.js +27 -2
  199. package/Utils/GuidedSetup/StatusPageRecords.mjs +1 -0
  200. package/Utils/GuidedSetup/WebsiteMonitorRecords.js +6 -0
  201. package/Utils/HostAddressUtil.d.mts +1 -0
  202. package/Utils/HostAddressUtil.d.ts +1 -0
  203. package/Utils/HostAddressUtil.js +30 -0
  204. package/Utils/LinearRegExp/LinearRegExp.js +5 -1
  205. package/Utils/Milliseconds.d.mts +7 -0
  206. package/Utils/Milliseconds.d.ts +7 -0
  207. package/Utils/Milliseconds.js +60 -0
  208. package/Utils/Milliseconds.mjs +4 -0
  209. package/Utils/Monitor/EndpointAttachmentUtil.d.mts +8 -0
  210. package/Utils/Monitor/EndpointAttachmentUtil.d.ts +8 -0
  211. package/Utils/Monitor/EndpointAttachmentUtil.js +91 -21
  212. package/Utils/Monitor/EndpointAttachmentUtil.mjs +4 -0
  213. package/Utils/Monitor/InterfaceInventoryUtil.d.mts +40 -0
  214. package/Utils/Monitor/InterfaceInventoryUtil.d.ts +40 -0
  215. package/Utils/Monitor/InterfaceInventoryUtil.js +217 -5
  216. package/Utils/Monitor/InterfaceInventoryUtil.mjs +8 -0
  217. package/Utils/Monitor/MonitorOverviewPresentationUtil.js +63 -29
  218. package/Utils/Monitor/MonitorOverviewProbeUtil.js +13 -2
  219. package/Utils/Monitor/MonitorRootCauseWording.d.mts +2 -0
  220. package/Utils/Monitor/MonitorRootCauseWording.d.ts +2 -0
  221. package/Utils/Monitor/MonitorRootCauseWording.js +58 -4
  222. package/Utils/Monitor/MonitoringOff.d.mts +2 -0
  223. package/Utils/Monitor/MonitoringOff.d.ts +2 -0
  224. package/Utils/Monitor/MonitoringOff.js +21 -0
  225. package/Utils/Monitor/NetworkTopologyUtil.d.mts +2 -1
  226. package/Utils/Monitor/NetworkTopologyUtil.d.ts +2 -1
  227. package/Utils/Monitor/NetworkTopologyUtil.js +10 -0
  228. package/Utils/Monitor/NotOperationalMonitorQuery.d.mts +2 -1
  229. package/Utils/Monitor/NotOperationalMonitorQuery.d.ts +2 -1
  230. package/Utils/Monitor/NotOperationalMonitorQuery.js +23 -4
  231. package/Utils/Monitor/ProbeFailureReading.d.mts +14 -0
  232. package/Utils/Monitor/ProbeFailureReading.d.ts +14 -0
  233. package/Utils/Monitor/ProbeFailureReading.js +137 -0
  234. package/Utils/Monitor/ProbeFailureReading.mjs +7 -0
  235. package/Utils/NetworkDevice/BoundMonitorNotChecked.d.mts +9 -0
  236. package/Utils/NetworkDevice/BoundMonitorNotChecked.d.ts +9 -0
  237. package/Utils/NetworkDevice/BoundMonitorNotChecked.js +15 -0
  238. package/Utils/NetworkDevice/BoundMonitorNotChecked.mjs +2 -0
  239. package/Utils/Project/NextNumber.js +1 -1
  240. package/Utils/PromQL/PromQLAst.d.mts +159 -0
  241. package/Utils/PromQL/PromQLAst.d.ts +159 -0
  242. package/Utils/PromQL/PromQLAst.js +118 -0
  243. package/Utils/PromQL/PromQLAst.mjs +12 -0
  244. package/Utils/PromQL/PromQLDuration.d.mts +2 -0
  245. package/Utils/PromQL/PromQLDuration.d.ts +2 -0
  246. package/Utils/PromQL/PromQLDuration.js +78 -0
  247. package/Utils/PromQL/PromQLDuration.mjs +3 -0
  248. package/Utils/PromQL/PromQLEngine.d.mts +15 -0
  249. package/Utils/PromQL/PromQLEngine.d.ts +15 -0
  250. package/Utils/PromQL/PromQLEngine.js +965 -0
  251. package/Utils/PromQL/PromQLEngine.mjs +7 -0
  252. package/Utils/PromQL/PromQLEngineTypes.d.mts +84 -0
  253. package/Utils/PromQL/PromQLEngineTypes.d.ts +84 -0
  254. package/Utils/PromQL/PromQLEngineTypes.js +10 -0
  255. package/Utils/PromQL/PromQLEngineTypes.mjs +2 -0
  256. package/Utils/PromQL/PromQLError.d.mts +11 -0
  257. package/Utils/PromQL/PromQLError.d.ts +11 -0
  258. package/Utils/PromQL/PromQLError.js +27 -0
  259. package/Utils/PromQL/PromQLError.mjs +3 -0
  260. package/Utils/PromQL/PromQLFunctionEvaluators.d.mts +8 -0
  261. package/Utils/PromQL/PromQLFunctionEvaluators.d.ts +8 -0
  262. package/Utils/PromQL/PromQLFunctionEvaluators.js +773 -0
  263. package/Utils/PromQL/PromQLFunctionEvaluators.mjs +3 -0
  264. package/Utils/PromQL/PromQLFunctions.d.mts +10 -0
  265. package/Utils/PromQL/PromQLFunctions.d.ts +10 -0
  266. package/Utils/PromQL/PromQLFunctions.js +127 -0
  267. package/Utils/PromQL/PromQLFunctions.mjs +4 -0
  268. package/Utils/PromQL/PromQLLabels.d.mts +11 -0
  269. package/Utils/PromQL/PromQLLabels.d.ts +11 -0
  270. package/Utils/PromQL/PromQLLabels.js +218 -0
  271. package/Utils/PromQL/PromQLLabels.mjs +9 -0
  272. package/Utils/PromQL/PromQLLexer.d.mts +39 -0
  273. package/Utils/PromQL/PromQLLexer.d.ts +39 -0
  274. package/Utils/PromQL/PromQLLexer.js +391 -0
  275. package/Utils/PromQL/PromQLLexer.mjs +3 -0
  276. package/Utils/PromQL/PromQLMath.d.mts +19 -0
  277. package/Utils/PromQL/PromQLMath.d.ts +19 -0
  278. package/Utils/PromQL/PromQLMath.js +200 -0
  279. package/Utils/PromQL/PromQLMath.mjs +9 -0
  280. package/Utils/PromQL/PromQLMetricNames.d.mts +21 -0
  281. package/Utils/PromQL/PromQLMetricNames.d.ts +21 -0
  282. package/Utils/PromQL/PromQLMetricNames.js +199 -0
  283. package/Utils/PromQL/PromQLMetricNames.mjs +8 -0
  284. package/Utils/PromQL/PromQLParser.d.mts +4 -0
  285. package/Utils/PromQL/PromQLParser.d.ts +4 -0
  286. package/Utils/PromQL/PromQLParser.js +831 -0
  287. package/Utils/PromQL/PromQLParser.mjs +4 -0
  288. package/Utils/PromQL/PromQLRegex.d.mts +9 -0
  289. package/Utils/PromQL/PromQLRegex.d.ts +9 -0
  290. package/Utils/PromQL/PromQLRegex.js +74 -0
  291. package/Utils/PromQL/PromQLRegex.mjs +2 -0
  292. package/Utils/PromQL/PrometheusResponse.d.mts +25 -0
  293. package/Utils/PromQL/PrometheusResponse.d.ts +25 -0
  294. package/Utils/PromQL/PrometheusResponse.js +90 -0
  295. package/Utils/PromQL/PrometheusResponse.mjs +3 -0
  296. package/Utils/Rum/PathInSentence.d.mts +5 -0
  297. package/Utils/Rum/PathInSentence.d.ts +5 -0
  298. package/Utils/Rum/PathInSentence.js +46 -0
  299. package/Utils/Rum/PathInSentence.mjs +6 -0
  300. package/Utils/Rum/UrlScrubber.d.mts +4 -0
  301. package/Utils/Rum/UrlScrubber.d.ts +4 -0
  302. package/Utils/Rum/UrlScrubber.js +143 -3
  303. package/Utils/Rum/UserFlow.d.mts +1 -1
  304. package/Utils/Rum/UserFlow.d.ts +1 -1
  305. package/Utils/Rum/UserFlow.js +180 -25
  306. package/Utils/Rum/UserFlow.mjs +1 -1
  307. package/Utils/Runbook/RunbookStepsSignature.d.mts +3 -0
  308. package/Utils/Runbook/RunbookStepsSignature.d.ts +3 -0
  309. package/Utils/Runbook/RunbookStepsSignature.js +30 -0
  310. package/Utils/Runbook/RunbookStepsSignature.mjs +3 -0
  311. package/Utils/Schema/TypeSchemas.js +6 -0
  312. package/Utils/Slo/SloDuration.d.mts +5 -2
  313. package/Utils/Slo/SloDuration.d.ts +5 -2
  314. package/Utils/Slo/SloDuration.js +11 -6
  315. package/Utils/Slo/SloHealth.js +1 -1
  316. package/Utils/StateOrder.js +1 -4
  317. package/Utils/StateTimeline/StateTimelineRowDelete.js +1 -1
  318. package/Utils/Telemetry/HeartbeatAvailability.d.mts +4 -0
  319. package/Utils/Telemetry/HeartbeatAvailability.d.ts +4 -0
  320. package/Utils/Telemetry/HeartbeatAvailability.js +118 -26
  321. package/Utils/Uptime/DayUptimeGraphUtil.js +2 -2
  322. package/package.json +1 -1
@@ -0,0 +1,391 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.tokenizePromQL = exports.PromQLTokenType = void 0;
7
+ const PromQLError_1 = __importDefault(require("./PromQLError"));
8
+ /*
9
+ * Splits a PromQL query into tokens (promql/parser/lex.go).
10
+ *
11
+ * A hand-written scanner: PromQL's strings carry Go's escapes, its durations
12
+ * are a number glued to a unit (`5m`), and `#` starts a comment, none of which
13
+ * a regular expression tokenizer gets right on its own.
14
+ */
15
+ var PromQLTokenType;
16
+ (function (PromQLTokenType) {
17
+ PromQLTokenType["Identifier"] = "Identifier";
18
+ // An identifier with a colon in it, which only a metric name may have.
19
+ PromQLTokenType["MetricIdentifier"] = "MetricIdentifier";
20
+ PromQLTokenType["Number"] = "Number";
21
+ PromQLTokenType["Duration"] = "Duration";
22
+ PromQLTokenType["String"] = "String";
23
+ PromQLTokenType["LeftParen"] = "(";
24
+ PromQLTokenType["RightParen"] = ")";
25
+ PromQLTokenType["LeftBrace"] = "{";
26
+ PromQLTokenType["RightBrace"] = "}";
27
+ PromQLTokenType["LeftBracket"] = "[";
28
+ PromQLTokenType["RightBracket"] = "]";
29
+ PromQLTokenType["Comma"] = ",";
30
+ PromQLTokenType["Colon"] = ":";
31
+ PromQLTokenType["At"] = "@";
32
+ PromQLTokenType["Add"] = "+";
33
+ PromQLTokenType["Sub"] = "-";
34
+ PromQLTokenType["Mul"] = "*";
35
+ PromQLTokenType["Div"] = "/";
36
+ PromQLTokenType["Mod"] = "%";
37
+ PromQLTokenType["Pow"] = "^";
38
+ PromQLTokenType["Eql"] = "==";
39
+ PromQLTokenType["Neq"] = "!=";
40
+ PromQLTokenType["Gtr"] = ">";
41
+ PromQLTokenType["Lss"] = "<";
42
+ PromQLTokenType["Gte"] = ">=";
43
+ PromQLTokenType["Lte"] = "<=";
44
+ PromQLTokenType["Assign"] = "=";
45
+ PromQLTokenType["RegexMatch"] = "=~";
46
+ PromQLTokenType["RegexNoMatch"] = "!~";
47
+ PromQLTokenType["EOF"] = "EOF";
48
+ })(PromQLTokenType || (exports.PromQLTokenType = PromQLTokenType = {}));
49
+ const isDigit = (character) => {
50
+ return character >= "0" && character <= "9";
51
+ };
52
+ const isAlpha = (character) => {
53
+ return ((character >= "a" && character <= "z") ||
54
+ (character >= "A" && character <= "Z") ||
55
+ character === "_");
56
+ };
57
+ const isAlphaNumeric = (character) => {
58
+ return isAlpha(character) || isDigit(character);
59
+ };
60
+ const isHexDigit = (character) => {
61
+ return (isDigit(character) ||
62
+ (character >= "a" && character <= "f") ||
63
+ (character >= "A" && character <= "F"));
64
+ };
65
+ const isWhiteSpace = (character) => {
66
+ return (character === " " ||
67
+ character === "\t" ||
68
+ character === "\n" ||
69
+ character === "\r");
70
+ };
71
+ const DURATION_UNITS = [
72
+ "ms",
73
+ "y",
74
+ "w",
75
+ "d",
76
+ "h",
77
+ "m",
78
+ "s",
79
+ ];
80
+ const SIMPLE_ESCAPES = {
81
+ a: "\x07",
82
+ b: "\b",
83
+ f: "\f",
84
+ n: "\n",
85
+ r: "\r",
86
+ t: "\t",
87
+ v: "\v",
88
+ "\\": "\\",
89
+ "'": "'",
90
+ '"': '"',
91
+ };
92
+ const TWO_CHARACTER_OPERATORS = {
93
+ "==": PromQLTokenType.Eql,
94
+ "!=": PromQLTokenType.Neq,
95
+ ">=": PromQLTokenType.Gte,
96
+ "<=": PromQLTokenType.Lte,
97
+ "=~": PromQLTokenType.RegexMatch,
98
+ "!~": PromQLTokenType.RegexNoMatch,
99
+ };
100
+ const ONE_CHARACTER_TOKENS = {
101
+ "(": PromQLTokenType.LeftParen,
102
+ ")": PromQLTokenType.RightParen,
103
+ "{": PromQLTokenType.LeftBrace,
104
+ "}": PromQLTokenType.RightBrace,
105
+ "[": PromQLTokenType.LeftBracket,
106
+ "]": PromQLTokenType.RightBracket,
107
+ ",": PromQLTokenType.Comma,
108
+ ":": PromQLTokenType.Colon,
109
+ "@": PromQLTokenType.At,
110
+ "+": PromQLTokenType.Add,
111
+ "-": PromQLTokenType.Sub,
112
+ "*": PromQLTokenType.Mul,
113
+ "/": PromQLTokenType.Div,
114
+ "%": PromQLTokenType.Mod,
115
+ "^": PromQLTokenType.Pow,
116
+ ">": PromQLTokenType.Gtr,
117
+ "<": PromQLTokenType.Lss,
118
+ "=": PromQLTokenType.Assign,
119
+ };
120
+ class PromQLLexer {
121
+ constructor(input) {
122
+ this.position = 0;
123
+ this.tokens = [];
124
+ this.input = input;
125
+ }
126
+ tokenize() {
127
+ while (this.position < this.input.length) {
128
+ const character = this.input[this.position];
129
+ if (isWhiteSpace(character)) {
130
+ this.position++;
131
+ continue;
132
+ }
133
+ // A comment runs to the end of its line.
134
+ if (character === "#") {
135
+ while (this.position < this.input.length &&
136
+ this.input[this.position] !== "\n") {
137
+ this.position++;
138
+ }
139
+ continue;
140
+ }
141
+ if (isDigit(character) || (character === "." && isDigit(this.peek(1)))) {
142
+ this.scanNumberOrDuration();
143
+ continue;
144
+ }
145
+ if (isAlpha(character) || character === ":") {
146
+ /*
147
+ * A colon is part of a metric name (`job:rate5m`) except where it
148
+ * separates a subquery's range from its step, which always follows
149
+ * a duration and is caught by the bracket rule below.
150
+ */
151
+ if (character === ":" && this.isInsideSubqueryBrackets()) {
152
+ this.push(PromQLTokenType.Colon, ":", this.position, ++this.position);
153
+ continue;
154
+ }
155
+ this.scanIdentifier();
156
+ continue;
157
+ }
158
+ if (character === '"' || character === "'") {
159
+ this.scanQuotedString(character);
160
+ continue;
161
+ }
162
+ if (character === "`") {
163
+ this.scanRawString();
164
+ continue;
165
+ }
166
+ const pair = this.input.slice(this.position, this.position + 2);
167
+ const pairType = TWO_CHARACTER_OPERATORS[pair];
168
+ if (pairType) {
169
+ this.push(pairType, pair, this.position, this.position + 2);
170
+ this.position += 2;
171
+ continue;
172
+ }
173
+ const singleType = ONE_CHARACTER_TOKENS[character];
174
+ if (singleType) {
175
+ this.push(singleType, character, this.position, this.position + 1);
176
+ this.position++;
177
+ continue;
178
+ }
179
+ throw new PromQLError_1.default(`Unexpected character "${character}" at position ${this.position + 1}.`, undefined, { start: this.position, end: this.position + 1 });
180
+ }
181
+ this.push(PromQLTokenType.EOF, "", this.input.length, this.input.length);
182
+ return this.tokens;
183
+ }
184
+ peek(offset) {
185
+ return this.input[this.position + offset] || "";
186
+ }
187
+ push(type, text, start, end) {
188
+ this.tokens.push({ type, text, start, end });
189
+ }
190
+ /*
191
+ * True while the scanner sits between `[` and `]` right after a duration:
192
+ * `[5m:1m]`. Brackets never nest in PromQL, so the last bracket token
193
+ * decides.
194
+ */
195
+ isInsideSubqueryBrackets() {
196
+ for (let index = this.tokens.length - 1; index >= 0; index--) {
197
+ const token = this.tokens[index];
198
+ if (token.type === PromQLTokenType.RightBracket) {
199
+ return false;
200
+ }
201
+ if (token.type === PromQLTokenType.LeftBracket) {
202
+ const previous = this.tokens[this.tokens.length - 1];
203
+ return (previous !== undefined &&
204
+ (previous.type === PromQLTokenType.Duration ||
205
+ previous.type === PromQLTokenType.Number));
206
+ }
207
+ }
208
+ return false;
209
+ }
210
+ scanIdentifier() {
211
+ const start = this.position;
212
+ while (this.position < this.input.length &&
213
+ (isAlphaNumeric(this.input[this.position]) ||
214
+ this.input[this.position] === ":")) {
215
+ this.position++;
216
+ }
217
+ const text = this.input.slice(start, this.position);
218
+ this.push(text.includes(":")
219
+ ? PromQLTokenType.MetricIdentifier
220
+ : PromQLTokenType.Identifier, text, start, this.position);
221
+ }
222
+ scanNumberOrDuration() {
223
+ const start = this.position;
224
+ // Hexadecimal: 0x1F.
225
+ if (this.input[this.position] === "0" &&
226
+ (this.peek(1) === "x" || this.peek(1) === "X") &&
227
+ isHexDigit(this.peek(2))) {
228
+ this.position += 2;
229
+ while (this.position < this.input.length &&
230
+ isHexDigit(this.input[this.position])) {
231
+ this.position++;
232
+ }
233
+ this.finishNumber(start);
234
+ return;
235
+ }
236
+ while (this.position < this.input.length &&
237
+ isDigit(this.input[this.position])) {
238
+ this.position++;
239
+ }
240
+ // A duration: digits glued to a unit, possibly several (`1h30m`).
241
+ if (this.startsDurationUnit()) {
242
+ this.scanDurationRest(start);
243
+ return;
244
+ }
245
+ if (this.input[this.position] === ".") {
246
+ this.position++;
247
+ while (this.position < this.input.length &&
248
+ isDigit(this.input[this.position])) {
249
+ this.position++;
250
+ }
251
+ }
252
+ if (this.input[this.position] === "e" ||
253
+ this.input[this.position] === "E") {
254
+ const afterExponent = this.peek(1);
255
+ const signed = afterExponent === "+" || afterExponent === "-";
256
+ if (isDigit(signed ? this.peek(2) : afterExponent)) {
257
+ this.position += signed ? 2 : 1;
258
+ while (this.position < this.input.length &&
259
+ isDigit(this.input[this.position])) {
260
+ this.position++;
261
+ }
262
+ }
263
+ }
264
+ this.finishNumber(start);
265
+ }
266
+ finishNumber(start) {
267
+ // `1x` is neither a number nor a duration.
268
+ if (this.position < this.input.length &&
269
+ isAlpha(this.input[this.position])) {
270
+ throw new PromQLError_1.default(`"${this.input.slice(start, this.position + 1)}" is not a number or a duration. Write a number such as 1.5, or a duration such as 5m.`, undefined, { start, end: this.position + 1 });
271
+ }
272
+ this.push(PromQLTokenType.Number, this.input.slice(start, this.position), start, this.position);
273
+ }
274
+ startsDurationUnit() {
275
+ for (const unit of DURATION_UNITS) {
276
+ if (this.input.startsWith(unit, this.position)) {
277
+ const after = this.input[this.position + unit.length] || "";
278
+ // `5m` but not `5min`: a unit ends where the letters end.
279
+ if (!isAlphaNumeric(after) || isDigit(after)) {
280
+ return true;
281
+ }
282
+ }
283
+ }
284
+ return false;
285
+ }
286
+ scanDurationRest(start) {
287
+ while (this.position < this.input.length) {
288
+ let matchedUnit = undefined;
289
+ for (const unit of DURATION_UNITS) {
290
+ if (this.input.startsWith(unit, this.position)) {
291
+ const after = this.input[this.position + unit.length] || "";
292
+ if (!isAlphaNumeric(after) || isDigit(after)) {
293
+ matchedUnit = unit;
294
+ break;
295
+ }
296
+ }
297
+ }
298
+ if (!matchedUnit) {
299
+ break;
300
+ }
301
+ this.position += matchedUnit.length;
302
+ if (!isDigit(this.input[this.position] || "")) {
303
+ break;
304
+ }
305
+ while (this.position < this.input.length &&
306
+ isDigit(this.input[this.position])) {
307
+ this.position++;
308
+ }
309
+ }
310
+ const text = this.input.slice(start, this.position);
311
+ if (this.position < this.input.length &&
312
+ isAlpha(this.input[this.position])) {
313
+ throw new PromQLError_1.default(`"${text}${this.input[this.position]}" is not a duration. Write a duration such as 30s, 5m, 1h or 1h30m.`, undefined, { start, end: this.position + 1 });
314
+ }
315
+ this.push(PromQLTokenType.Duration, text, start, this.position);
316
+ }
317
+ scanQuotedString(quote) {
318
+ const start = this.position;
319
+ this.position++;
320
+ let value = "";
321
+ while (this.position < this.input.length) {
322
+ const character = this.input[this.position];
323
+ if (character === quote) {
324
+ this.position++;
325
+ this.push(PromQLTokenType.String, value, start, this.position);
326
+ return;
327
+ }
328
+ if (character === "\n") {
329
+ break;
330
+ }
331
+ if (character === "\\") {
332
+ value += this.scanEscape(start);
333
+ continue;
334
+ }
335
+ value += character;
336
+ this.position++;
337
+ }
338
+ throw new PromQLError_1.default(`The string that starts at position ${start + 1} is not closed. End it with ${quote}.`, undefined, { start, end: this.input.length });
339
+ }
340
+ scanEscape(stringStart) {
341
+ const escapeStart = this.position;
342
+ const next = this.peek(1);
343
+ const simple = SIMPLE_ESCAPES[next];
344
+ if (simple !== undefined) {
345
+ this.position += 2;
346
+ return simple;
347
+ }
348
+ const readHex = (length) => {
349
+ const digits = this.input.slice(this.position + 2, this.position + 2 + length);
350
+ if (digits.length !== length || !Array.from(digits).every(isHexDigit)) {
351
+ throw new PromQLError_1.default(`The escape at position ${escapeStart + 1} is not complete: \\${next} takes ${length} hexadecimal digits.`, undefined, { start: stringStart, end: escapeStart + 2 + length });
352
+ }
353
+ this.position += 2 + length;
354
+ return String.fromCodePoint(parseInt(digits, 16));
355
+ };
356
+ if (next === "x") {
357
+ return readHex(2);
358
+ }
359
+ if (next === "u") {
360
+ return readHex(4);
361
+ }
362
+ if (next === "U") {
363
+ return readHex(8);
364
+ }
365
+ // Three octal digits: \101 is "A".
366
+ if (next >= "0" && next <= "7") {
367
+ const digits = this.input.slice(this.position + 1, this.position + 4);
368
+ if (digits.length === 3 &&
369
+ Array.from(digits).every((digit) => {
370
+ return digit >= "0" && digit <= "7";
371
+ })) {
372
+ this.position += 4;
373
+ return String.fromCharCode(parseInt(digits, 8));
374
+ }
375
+ }
376
+ throw new PromQLError_1.default(`Unknown escape "\\${next}" at position ${escapeStart + 1}. Write a backslash as \\\\.`, undefined, { start: stringStart, end: escapeStart + 2 });
377
+ }
378
+ scanRawString() {
379
+ const start = this.position;
380
+ const end = this.input.indexOf("`", start + 1);
381
+ if (end === -1) {
382
+ throw new PromQLError_1.default(`The string that starts at position ${start + 1} is not closed. End it with \`.`, undefined, { start, end: this.input.length });
383
+ }
384
+ this.position = end + 1;
385
+ this.push(PromQLTokenType.String, this.input.slice(start + 1, end), start, this.position);
386
+ }
387
+ }
388
+ const tokenizePromQL = (input) => {
389
+ return new PromQLLexer(input).tokenize();
390
+ };
391
+ exports.tokenizePromQL = tokenizePromQL;
@@ -0,0 +1,3 @@
1
+ import commonJsModule from "./PromQLLexer.js";
2
+ export const PromQLTokenType = commonJsModule.PromQLTokenType;
3
+ export const tokenizePromQL = commonJsModule.tokenizePromQL;
@@ -0,0 +1,19 @@
1
+ export interface KahanSum {
2
+ sum: number;
3
+ compensation: number;
4
+ }
5
+ export declare const kahanAdd: (state: KahanSum, value: number) => void;
6
+ export declare const kahanResult: (state: KahanSum) => number;
7
+ export declare const promQLQuantile: (phi: number, values: Array<number>) => number;
8
+ export declare const compareWithNaNFirst: (a: number, b: number) => number;
9
+ export declare const linearRegression: (timestampsMs: ArrayLike<number>, values: ArrayLike<number>, interceptTimeMs: number) => {
10
+ slope: number;
11
+ intercept: number;
12
+ };
13
+ export interface HistogramBucket {
14
+ upperBound: number;
15
+ count: number;
16
+ }
17
+ export declare const bucketQuantile: (phi: number, input: Array<HistogramBucket>) => number;
18
+ export declare const promQLPow: (base: number, exponent: number) => number;
19
+ export declare const upperBound: (sorted: ArrayLike<number>, value: number) => number;
@@ -0,0 +1,19 @@
1
+ export interface KahanSum {
2
+ sum: number;
3
+ compensation: number;
4
+ }
5
+ export declare const kahanAdd: (state: KahanSum, value: number) => void;
6
+ export declare const kahanResult: (state: KahanSum) => number;
7
+ export declare const promQLQuantile: (phi: number, values: Array<number>) => number;
8
+ export declare const compareWithNaNFirst: (a: number, b: number) => number;
9
+ export declare const linearRegression: (timestampsMs: ArrayLike<number>, values: ArrayLike<number>, interceptTimeMs: number) => {
10
+ slope: number;
11
+ intercept: number;
12
+ };
13
+ export interface HistogramBucket {
14
+ upperBound: number;
15
+ count: number;
16
+ }
17
+ export declare const bucketQuantile: (phi: number, input: Array<HistogramBucket>) => number;
18
+ export declare const promQLPow: (base: number, exponent: number) => number;
19
+ export declare const upperBound: (sorted: ArrayLike<number>, value: number) => number;
@@ -0,0 +1,200 @@
1
+ "use strict";
2
+ /*
3
+ * The arithmetic PromQL's functions share, written as Prometheus writes it
4
+ * (promql/functions.go, promql/quantile.go) so results agree to the last
5
+ * digit where the order of additions matters.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.upperBound = exports.promQLPow = exports.bucketQuantile = exports.linearRegression = exports.compareWithNaNFirst = exports.promQLQuantile = exports.kahanResult = exports.kahanAdd = void 0;
9
+ // Neumaier's improvement of Kahan summation, as kahanSumInc in Prometheus.
10
+ const kahanAdd = (state, value) => {
11
+ const total = state.sum + value;
12
+ if (!Number.isFinite(total)) {
13
+ state.compensation = 0;
14
+ }
15
+ else if (Math.abs(state.sum) >= Math.abs(value)) {
16
+ state.compensation += state.sum - total + value;
17
+ }
18
+ else {
19
+ state.compensation += value - total + state.sum;
20
+ }
21
+ state.sum = total;
22
+ };
23
+ exports.kahanAdd = kahanAdd;
24
+ const kahanResult = (state) => {
25
+ return state.sum + state.compensation;
26
+ };
27
+ exports.kahanResult = kahanResult;
28
+ /*
29
+ * The φ-quantile of a list of values, interpolating between the two nearest
30
+ * ranks. NaN sorts first, as Prometheus sorts it.
31
+ */
32
+ const promQLQuantile = (phi, values) => {
33
+ if (values.length === 0 || Number.isNaN(phi)) {
34
+ return NaN;
35
+ }
36
+ if (phi < 0) {
37
+ return -Infinity;
38
+ }
39
+ if (phi > 1) {
40
+ return Infinity;
41
+ }
42
+ const sorted = [...values].sort(exports.compareWithNaNFirst);
43
+ const count = sorted.length;
44
+ const rank = phi * (count - 1);
45
+ const lowerIndex = Math.max(0, Math.floor(rank));
46
+ const upperIndex = Math.min(count - 1, lowerIndex + 1);
47
+ const weight = rank - Math.floor(rank);
48
+ return sorted[lowerIndex] * (1 - weight) + sorted[upperIndex] * weight;
49
+ };
50
+ exports.promQLQuantile = promQLQuantile;
51
+ const compareWithNaNFirst = (a, b) => {
52
+ if (Number.isNaN(a)) {
53
+ return Number.isNaN(b) ? 0 : -1;
54
+ }
55
+ if (Number.isNaN(b)) {
56
+ return 1;
57
+ }
58
+ return a - b;
59
+ };
60
+ exports.compareWithNaNFirst = compareWithNaNFirst;
61
+ /*
62
+ * The least-squares line through samples, with x in seconds from
63
+ * `interceptTimeMs`: the slope per second, and the value at that time.
64
+ */
65
+ const linearRegression = (timestampsMs, values, interceptTimeMs) => {
66
+ const sumX = { sum: 0, compensation: 0 };
67
+ const sumY = { sum: 0, compensation: 0 };
68
+ const sumXY = { sum: 0, compensation: 0 };
69
+ const sumX2 = { sum: 0, compensation: 0 };
70
+ const initialY = values[0];
71
+ let constantY = true;
72
+ let count = 0;
73
+ for (let index = 0; index < values.length; index++) {
74
+ const y = values[index];
75
+ if (constantY && index > 0 && y !== initialY) {
76
+ constantY = false;
77
+ }
78
+ count++;
79
+ const x = (timestampsMs[index] - interceptTimeMs) / 1000;
80
+ (0, exports.kahanAdd)(sumX, x);
81
+ (0, exports.kahanAdd)(sumY, y);
82
+ (0, exports.kahanAdd)(sumXY, x * y);
83
+ (0, exports.kahanAdd)(sumX2, x * x);
84
+ }
85
+ if (constantY) {
86
+ if (!Number.isFinite(initialY)) {
87
+ return { slope: NaN, intercept: NaN };
88
+ }
89
+ return { slope: 0, intercept: initialY };
90
+ }
91
+ const totalX = (0, exports.kahanResult)(sumX);
92
+ const totalY = (0, exports.kahanResult)(sumY);
93
+ const covarianceXY = (0, exports.kahanResult)(sumXY) - (totalX * totalY) / count;
94
+ const varianceX = (0, exports.kahanResult)(sumX2) - (totalX * totalX) / count;
95
+ const slope = covarianceXY / varianceX;
96
+ const intercept = totalY / count - (slope * totalX) / count;
97
+ return { slope, intercept };
98
+ };
99
+ exports.linearRegression = linearRegression;
100
+ /*
101
+ * The φ-quantile of a classic histogram's cumulative buckets
102
+ * (bucketQuantile): the buckets need a +Inf one, and the quantile is
103
+ * interpolated linearly inside the bucket it falls in.
104
+ */
105
+ const bucketQuantile = (phi, input) => {
106
+ if (Number.isNaN(phi)) {
107
+ return NaN;
108
+ }
109
+ if (phi < 0) {
110
+ return -Infinity;
111
+ }
112
+ if (phi > 1) {
113
+ return Infinity;
114
+ }
115
+ const sorted = [...input].sort((a, b) => {
116
+ return a.upperBound - b.upperBound;
117
+ });
118
+ if (sorted.length === 0 ||
119
+ sorted[sorted.length - 1].upperBound !== Infinity) {
120
+ return NaN;
121
+ }
122
+ // Buckets with the same bound (two sources of one histogram) add up.
123
+ const buckets = [];
124
+ for (const bucket of sorted) {
125
+ const last = buckets[buckets.length - 1];
126
+ if (last && last.upperBound === bucket.upperBound) {
127
+ last.count += bucket.count;
128
+ }
129
+ else {
130
+ buckets.push(Object.assign({}, bucket));
131
+ }
132
+ }
133
+ // Counts only grow from bucket to bucket; a dip is a scrape artefact.
134
+ for (let index = 1; index < buckets.length; index++) {
135
+ if (buckets[index].count < buckets[index - 1].count) {
136
+ buckets[index].count = buckets[index - 1].count;
137
+ }
138
+ }
139
+ if (buckets.length < 2) {
140
+ return NaN;
141
+ }
142
+ const observations = buckets[buckets.length - 1].count;
143
+ if (observations === 0) {
144
+ return NaN;
145
+ }
146
+ let rank = phi * observations;
147
+ let bucketIndex = buckets.length - 1;
148
+ for (let index = 0; index < buckets.length - 1; index++) {
149
+ if (buckets[index].count >= rank) {
150
+ bucketIndex = index;
151
+ break;
152
+ }
153
+ }
154
+ if (bucketIndex === buckets.length - 1) {
155
+ return buckets[buckets.length - 2].upperBound;
156
+ }
157
+ if (bucketIndex === 0 && buckets[0].upperBound <= 0) {
158
+ return buckets[0].upperBound;
159
+ }
160
+ let bucketStart = 0;
161
+ const bucketEnd = buckets[bucketIndex].upperBound;
162
+ let count = buckets[bucketIndex].count;
163
+ if (bucketIndex > 0) {
164
+ bucketStart = buckets[bucketIndex - 1].upperBound;
165
+ count -= buckets[bucketIndex - 1].count;
166
+ rank -= buckets[bucketIndex - 1].count;
167
+ }
168
+ return bucketStart + (bucketEnd - bucketStart) * (rank / count);
169
+ };
170
+ exports.bucketQuantile = bucketQuantile;
171
+ // Go's math.Pow agrees with JavaScript but for two edge cases.
172
+ const promQLPow = (base, exponent) => {
173
+ if (base === 1) {
174
+ return 1;
175
+ }
176
+ if (base === -1 && !Number.isFinite(exponent) && !Number.isNaN(exponent)) {
177
+ return 1;
178
+ }
179
+ return Math.pow(base, exponent);
180
+ };
181
+ exports.promQLPow = promQLPow;
182
+ /*
183
+ * The index of the first timestamp after `value` in an ascending list:
184
+ * every index before it is at or before `value`.
185
+ */
186
+ const upperBound = (sorted, value) => {
187
+ let low = 0;
188
+ let high = sorted.length;
189
+ while (low < high) {
190
+ const middle = (low + high) >>> 1;
191
+ if (sorted[middle] <= value) {
192
+ low = middle + 1;
193
+ }
194
+ else {
195
+ high = middle;
196
+ }
197
+ }
198
+ return low;
199
+ };
200
+ exports.upperBound = upperBound;
@@ -0,0 +1,9 @@
1
+ import commonJsModule from "./PromQLMath.js";
2
+ export const bucketQuantile = commonJsModule.bucketQuantile;
3
+ export const compareWithNaNFirst = commonJsModule.compareWithNaNFirst;
4
+ export const kahanAdd = commonJsModule.kahanAdd;
5
+ export const kahanResult = commonJsModule.kahanResult;
6
+ export const linearRegression = commonJsModule.linearRegression;
7
+ export const promQLPow = commonJsModule.promQLPow;
8
+ export const promQLQuantile = commonJsModule.promQLQuantile;
9
+ export const upperBound = commonJsModule.upperBound;
@@ -0,0 +1,21 @@
1
+ import { PromQLLabels } from "./PromQLLabels.mjs";
2
+ export declare const PROMQL_LABEL_NAME_SQL_PATTERN: string;
3
+ export declare const toPromQLMetricName: (name: string) => string;
4
+ export declare const toPromQLLabelName: (key: string) => string;
5
+ export declare const attributesToPromQLLabels: (attributes: Record<string, unknown>) => PromQLLabels;
6
+ export declare enum PromQLSeriesKind {
7
+ Value = "value",
8
+ Bucket = "bucket",
9
+ Count = "count",
10
+ Sum = "sum"
11
+ }
12
+ export interface PromQLMetricRequest {
13
+ storedName: string;
14
+ kind: PromQLSeriesKind;
15
+ seriesName: string;
16
+ }
17
+ export declare const resolvePromQLMetricName: (queriedName: string, storedNames: ReadonlyArray<string>) => Array<PromQLMetricRequest>;
18
+ export declare const promQLSeriesNamesOf: (storedName: string, pointType: string | undefined) => Array<{
19
+ name: string;
20
+ kind: PromQLSeriesKind;
21
+ }>;
@@ -0,0 +1,21 @@
1
+ import { PromQLLabels } from "./PromQLLabels";
2
+ export declare const PROMQL_LABEL_NAME_SQL_PATTERN: string;
3
+ export declare const toPromQLMetricName: (name: string) => string;
4
+ export declare const toPromQLLabelName: (key: string) => string;
5
+ export declare const attributesToPromQLLabels: (attributes: Record<string, unknown>) => PromQLLabels;
6
+ export declare enum PromQLSeriesKind {
7
+ Value = "value",
8
+ Bucket = "bucket",
9
+ Count = "count",
10
+ Sum = "sum"
11
+ }
12
+ export interface PromQLMetricRequest {
13
+ storedName: string;
14
+ kind: PromQLSeriesKind;
15
+ seriesName: string;
16
+ }
17
+ export declare const resolvePromQLMetricName: (queriedName: string, storedNames: ReadonlyArray<string>) => Array<PromQLMetricRequest>;
18
+ export declare const promQLSeriesNamesOf: (storedName: string, pointType: string | undefined) => Array<{
19
+ name: string;
20
+ kind: PromQLSeriesKind;
21
+ }>;