@oneuptime/common 14.0.109 → 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.
- package/Models/AnalyticsModels/SecurityEvent.js +1 -1
- package/Models/DatabaseModels/AIInsight.js +2 -2
- package/Models/DatabaseModels/AIRunRecording.d.mts +12 -0
- package/Models/DatabaseModels/AIRunRecording.d.ts +12 -0
- package/Models/DatabaseModels/AIRunRecording.js +181 -0
- package/Models/DatabaseModels/AIRunRecording.mjs +2 -0
- package/Models/DatabaseModels/Alert.js +20 -4
- package/Models/DatabaseModels/AlertEpisode.js +2 -2
- package/Models/DatabaseModels/AlertEpisodeOnCallRule.js +3 -3
- package/Models/DatabaseModels/AlertGroupingRule.d.mts +1 -0
- package/Models/DatabaseModels/AlertGroupingRule.d.ts +1 -0
- package/Models/DatabaseModels/AlertGroupingRule.js +48 -2
- package/Models/DatabaseModels/AlertOnCallRule.js +3 -3
- package/Models/DatabaseModels/AlertSeverity.js +13 -4
- package/Models/DatabaseModels/AlertState.js +1 -1
- package/Models/DatabaseModels/CallLog.js +12 -12
- package/Models/DatabaseModels/DataStore.js +9 -0
- package/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel.d.mts +2 -0
- package/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel.d.ts +2 -0
- package/Models/DatabaseModels/EmailLog.js +14 -14
- package/Models/DatabaseModels/Form.js +3 -3
- package/Models/DatabaseModels/FormSubmission.js +6 -6
- package/Models/DatabaseModels/GlobalConfig.d.mts +1 -0
- package/Models/DatabaseModels/GlobalConfig.d.ts +1 -0
- package/Models/DatabaseModels/GlobalConfig.js +74 -45
- package/Models/DatabaseModels/Incident.js +20 -4
- package/Models/DatabaseModels/IncidentEpisode.js +2 -2
- package/Models/DatabaseModels/IncidentEpisodeOnCallRule.js +3 -3
- package/Models/DatabaseModels/IncidentGroupingRule.d.mts +1 -0
- package/Models/DatabaseModels/IncidentGroupingRule.d.ts +1 -0
- package/Models/DatabaseModels/IncidentGroupingRule.js +48 -2
- package/Models/DatabaseModels/IncidentOnCallRule.js +3 -3
- package/Models/DatabaseModels/IncidentSeverity.js +13 -4
- package/Models/DatabaseModels/IncidentSlaRule.js +2 -2
- package/Models/DatabaseModels/IncidentState.js +1 -1
- package/Models/DatabaseModels/IncidentTemplate.js +2 -2
- package/Models/DatabaseModels/Index.js +4 -0
- package/Models/DatabaseModels/InventoryItem.js +11 -0
- package/Models/DatabaseModels/Monitor.js +54 -20
- package/Models/DatabaseModels/MonitorNetworkDevice.d.mts +11 -0
- package/Models/DatabaseModels/MonitorNetworkDevice.d.ts +11 -0
- package/Models/DatabaseModels/MonitorNetworkDevice.js +189 -0
- package/Models/DatabaseModels/MonitorNetworkDevice.mjs +2 -0
- package/Models/DatabaseModels/MonitorProbe.js +22 -5
- package/Models/DatabaseModels/NetworkDevice.d.mts +1 -0
- package/Models/DatabaseModels/NetworkDevice.d.ts +1 -0
- package/Models/DatabaseModels/NetworkDevice.js +64 -7
- package/Models/DatabaseModels/NetworkEndpoint.d.mts +1 -0
- package/Models/DatabaseModels/NetworkEndpoint.d.ts +1 -0
- package/Models/DatabaseModels/NetworkEndpoint.js +39 -7
- package/Models/DatabaseModels/NetworkInterface.js +5 -5
- package/Models/DatabaseModels/OnCallDutyPolicy.js +4 -2
- package/Models/DatabaseModels/OnCallDutyPolicyEscalationRule.js +1 -1
- package/Models/DatabaseModels/OnCallDutyPolicyEscalationRuleSchedule.js +8 -5
- package/Models/DatabaseModels/OnCallDutyPolicyEscalationRuleTeam.js +5 -2
- package/Models/DatabaseModels/OnCallDutyPolicyEscalationRuleUser.js +5 -2
- package/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.js +28 -11
- package/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.js +10 -7
- package/Models/DatabaseModels/OnCallDutyPolicyFeed.d.mts +1 -0
- package/Models/DatabaseModels/OnCallDutyPolicyFeed.d.ts +1 -0
- package/Models/DatabaseModels/OnCallDutyPolicyFeed.js +16 -11
- package/Models/DatabaseModels/OnCallDutyPolicyOwnerTeam.js +7 -4
- package/Models/DatabaseModels/OnCallDutyPolicyOwnerUser.js +7 -4
- package/Models/DatabaseModels/OnCallDutyPolicySchedule.js +6 -3
- package/Models/DatabaseModels/OnCallDutyPolicyScheduleCalendarFeed.js +4 -4
- package/Models/DatabaseModels/OnCallDutyPolicyScheduleLayer.js +3 -3
- package/Models/DatabaseModels/OnCallDutyPolicyScheduleLayerUser.js +6 -6
- package/Models/DatabaseModels/OnCallDutyPolicyTimeLog.js +9 -6
- package/Models/DatabaseModels/OnCallDutyPolicyUserOverride.js +35 -7
- package/Models/DatabaseModels/OpenStackCloudCheck.js +8 -1
- package/Models/DatabaseModels/Project.d.mts +3 -0
- package/Models/DatabaseModels/Project.d.ts +3 -0
- package/Models/DatabaseModels/Project.js +142 -5
- package/Models/DatabaseModels/ProjectCallSMSConfig.js +3 -1
- package/Models/DatabaseModels/ProjectSmtpConfig.js +2 -0
- package/Models/DatabaseModels/ProxmoxCluster.d.mts +1 -0
- package/Models/DatabaseModels/ProxmoxCluster.d.ts +1 -0
- package/Models/DatabaseModels/ProxmoxCluster.js +52 -3
- package/Models/DatabaseModels/PublicNoteApprovalRequest.js +3 -3
- package/Models/DatabaseModels/PublicNoteApprovalStep.js +1 -1
- package/Models/DatabaseModels/PushNotificationLog.js +12 -12
- package/Models/DatabaseModels/Reseller.js +8 -2
- package/Models/DatabaseModels/ResellerPlan.js +8 -2
- package/Models/DatabaseModels/RunbookExecution.js +2 -2
- package/Models/DatabaseModels/RunbookRule.js +6 -6
- package/Models/DatabaseModels/ScheduledMaintenance.js +9 -6
- package/Models/DatabaseModels/ScheduledMaintenanceCalendarFeed.js +1 -1
- package/Models/DatabaseModels/ScheduledMaintenanceInternalNote.js +7 -4
- package/Models/DatabaseModels/ScheduledMaintenanceLabelRule.js +1 -1
- package/Models/DatabaseModels/ScheduledMaintenanceMeasurement.js +7 -7
- package/Models/DatabaseModels/ScheduledMaintenanceMeasurementValue.js +3 -3
- package/Models/DatabaseModels/ScheduledMaintenanceOwnerRule.js +6 -6
- package/Models/DatabaseModels/ScheduledMaintenanceOwnerTeam.js +4 -4
- package/Models/DatabaseModels/ScheduledMaintenanceOwnerUser.js +4 -4
- package/Models/DatabaseModels/ScheduledMaintenancePublicNote.js +10 -7
- package/Models/DatabaseModels/ScheduledMaintenanceReminderRule.js +4 -4
- package/Models/DatabaseModels/ScheduledMaintenanceStateTimeline.js +4 -4
- package/Models/DatabaseModels/ScheduledMaintenanceTemplate.js +5 -5
- package/Models/DatabaseModels/Service.js +1 -1
- package/Models/DatabaseModels/ServiceLevelObjectiveBurnRateRule.js +4 -4
- package/Models/DatabaseModels/ServiceLevelObjectiveErrorBudgetPolicyTier.js +4 -4
- package/Models/DatabaseModels/SmsLog.js +12 -12
- package/Models/DatabaseModels/StatusPage.js +5 -5
- package/Models/DatabaseModels/StatusPageSubscriber.js +2 -2
- package/Models/DatabaseModels/TeamMember.js +10 -1
- package/Models/DatabaseModels/TelegramLog.js +12 -12
- package/Models/DatabaseModels/TelemetryIngestionKey.js +8 -5
- package/Models/DatabaseModels/TelemetryIngestionKeyRefusal.js +7 -4
- package/Models/DatabaseModels/User.d.mts +4 -0
- package/Models/DatabaseModels/User.d.ts +4 -0
- package/Models/DatabaseModels/User.js +100 -0
- package/Models/DatabaseModels/UserOnCallLog.js +6 -6
- package/Models/DatabaseModels/UserOnCallLogTimeline.js +3 -3
- package/Models/DatabaseModels/UserOnCallShiftReminderLog.js +2 -2
- package/Models/DatabaseModels/WebhookLog.js +12 -12
- package/Models/DatabaseModels/WhatsAppLog.js +12 -12
- package/Models/DatabaseModels/WorkspaceNotificationLog.js +12 -12
- package/Models/DatabaseModels/WorkspaceNotificationRule.js +36 -1
- package/Models/DatabaseModels/WorkspaceNotificationSummary.js +1 -1
- package/Models/DatabaseModels/WorkspacePublicNoteApprovalMessage.js +3 -3
- package/Server/Services/DatabaseService.d.mts +4 -1
- package/Server/Services/DatabaseService.d.ts +4 -1
- package/Server/Types/Database/CountBy.d.mts +1 -0
- package/Server/Types/Database/CountBy.d.ts +1 -0
- package/Server/Types/Database/UpdateLimit.d.mts +6 -0
- package/Server/Types/Database/UpdateLimit.d.ts +6 -0
- package/Types/AI/AIActionWords.d.mts +25 -1
- package/Types/AI/AIActionWords.d.ts +25 -1
- package/Types/AI/AIActionWords.js +166 -3
- package/Types/AI/AIActionWords.mjs +6 -0
- package/Types/AI/AIChatTypes.d.mts +4 -2
- package/Types/AI/AIChatTypes.d.ts +4 -2
- package/Types/AI/AIChatTypes.js +5 -0
- package/Types/AI/AiOutcomes.d.mts +57 -0
- package/Types/AI/AiOutcomes.d.ts +57 -0
- package/Types/AI/AiOutcomes.js +67 -0
- package/Types/AI/AiOutcomes.mjs +10 -0
- package/Types/AI/AiRunRefusal.d.mts +45 -0
- package/Types/AI/AiRunRefusal.d.ts +45 -0
- package/Types/AI/AiRunRefusal.js +187 -0
- package/Types/AI/AiRunRefusal.mjs +12 -0
- package/Types/AI/InvestigationRecording.d.mts +46 -0
- package/Types/AI/InvestigationRecording.d.ts +46 -0
- package/Types/AI/InvestigationRecording.js +42 -0
- package/Types/AI/InvestigationRecording.mjs +7 -0
- package/Types/API/HTTPResponse.d.mts +3 -0
- package/Types/API/HTTPResponse.d.ts +3 -0
- package/Types/API/HTTPResponse.js +15 -0
- package/Types/Analytics/ProductEvent.d.mts +6 -1
- package/Types/Analytics/ProductEvent.d.ts +6 -1
- package/Types/Analytics/ProductEvent.js +41 -0
- package/Types/AuditLog/AuditLogCoverage.d.mts +1 -0
- package/Types/AuditLog/AuditLogCoverage.d.ts +1 -0
- package/Types/AuditLog/AuditLogCoverage.js +4 -2
- package/Types/BaseDatabase/AggregateBy.d.mts +16 -0
- package/Types/BaseDatabase/AggregateBy.d.ts +16 -0
- package/Types/BaseDatabase/AggregationIntervalUtil.d.mts +16 -1
- package/Types/BaseDatabase/AggregationIntervalUtil.d.ts +16 -1
- package/Types/BaseDatabase/AggregationIntervalUtil.js +92 -2
- package/Types/BaseDatabase/ListResult.d.mts +1 -0
- package/Types/BaseDatabase/ListResult.d.ts +1 -0
- package/Types/CallAndSMS/ServerTwilioEnvironment.d.mts +47 -0
- package/Types/CallAndSMS/ServerTwilioEnvironment.d.ts +47 -0
- package/Types/CallAndSMS/ServerTwilioEnvironment.js +282 -0
- package/Types/CallAndSMS/ServerTwilioEnvironment.mjs +7 -0
- package/Types/Cloud/CloudResourceCatalog.d.mts +2 -0
- package/Types/Cloud/CloudResourceCatalog.d.ts +2 -0
- package/Types/Cloud/CloudResourceCatalog.js +33 -3
- package/Types/Cloud/CloudResourceCatalog.mjs +1 -0
- package/Types/Dashboard/DashboardAutoRefresh.d.mts +1 -0
- package/Types/Dashboard/DashboardAutoRefresh.d.ts +1 -0
- package/Types/Dashboard/DashboardAutoRefresh.js +21 -0
- package/Types/Dashboard/DashboardAutoRefresh.mjs +1 -0
- package/Types/DataObservability/DataCheckSuggestions.d.mts +25 -0
- package/Types/DataObservability/DataCheckSuggestions.d.ts +25 -0
- package/Types/DataObservability/DataCheckSuggestions.js +102 -65
- package/Types/DataObservability/DataCheckSuggestions.mjs +1 -0
- package/Types/Database/TableMetadata.d.mts +2 -0
- package/Types/Database/TableMetadata.d.ts +2 -0
- package/Types/Database/TableMetadata.js +6 -0
- package/Types/Date.d.mts +26 -2
- package/Types/Date.d.ts +26 -2
- package/Types/Date.js +81 -9
- package/Types/Date.mjs +1 -0
- package/Types/DateLanguage.d.mts +2 -0
- package/Types/DateLanguage.d.ts +2 -0
- package/Types/DateLanguage.js +44 -2
- package/Types/DateLanguage.mjs +2 -0
- package/Types/DirectionArrow.d.mts +7 -0
- package/Types/DirectionArrow.d.ts +7 -0
- package/Types/DirectionArrow.js +88 -0
- package/Types/DirectionArrow.mjs +7 -0
- package/Types/Docs/GlossaryTerm.d.mts +1 -0
- package/Types/Docs/GlossaryTerm.d.ts +1 -0
- package/Types/Docs/GlossaryTerm.js +2 -0
- package/Types/Docs/RetiredNames.d.mts +11 -0
- package/Types/Docs/RetiredNames.d.ts +11 -0
- package/Types/Docs/RetiredNames.js +139 -0
- package/Types/Docs/RetiredNames.mjs +3 -0
- package/Types/Email/ServerEmailEnvironment.d.mts +85 -0
- package/Types/Email/ServerEmailEnvironment.d.ts +85 -0
- package/Types/Email/ServerEmailEnvironment.js +793 -0
- package/Types/Email/ServerEmailEnvironment.mjs +14 -0
- package/Types/Exception/AiRunRefusalException.d.mts +6 -0
- package/Types/Exception/AiRunRefusalException.d.ts +6 -0
- package/Types/Exception/AiRunRefusalException.js +23 -0
- package/Types/Exception/AiRunRefusalException.mjs +2 -0
- package/Types/Exception/RefusalWithValues.d.mts +7 -0
- package/Types/Exception/RefusalWithValues.d.ts +7 -0
- package/Types/Exception/RefusalWithValues.js +76 -0
- package/Types/Exception/RefusalWithValues.mjs +3 -0
- package/Types/Exception/UnexplainedError.d.mts +13 -0
- package/Types/Exception/UnexplainedError.d.ts +13 -0
- package/Types/Exception/UnexplainedError.js +53 -1
- package/Types/Exception/UnexplainedError.mjs +1 -0
- package/Types/File/FileSize.d.mts +4 -1
- package/Types/File/FileSize.d.ts +4 -1
- package/Types/File/FileSize.js +18 -17
- package/Types/Form/FormTargetCatalog.js +2 -2
- package/Types/Form/FormTargetType.js +2 -2
- package/Types/HostCollector/HostCollector.d.mts +1 -0
- package/Types/HostCollector/HostCollector.d.ts +1 -0
- package/Types/HostCollector/HostCollector.js +26 -10
- package/Types/HostCollector/HostCollector.mjs +1 -0
- package/Types/ListData.d.mts +2 -0
- package/Types/ListData.d.ts +2 -0
- package/Types/ListData.js +4 -0
- package/Types/Monitor/MonitorCriteria.js +2 -2
- package/Types/Monitor/MonitorCriteriaInstance.js +9 -0
- package/Types/Monitor/MonitorNotCheckedReason.d.mts +7 -0
- package/Types/Monitor/MonitorNotCheckedReason.d.ts +7 -0
- package/Types/Monitor/MonitorNotCheckedReason.js +36 -0
- package/Types/Monitor/MonitorNotCheckedReason.mjs +4 -0
- package/Types/Monitor/MonitorStep.js +1 -1
- package/Types/Monitor/MonitorTemplateSyncField.d.mts +6 -0
- package/Types/Monitor/MonitorTemplateSyncField.d.ts +6 -0
- package/Types/Monitor/MonitorTemplateSyncField.js +106 -64
- package/Types/Monitor/NtpMonitor/NtpMonitorUtil.d.mts +1 -0
- package/Types/Monitor/NtpMonitor/NtpMonitorUtil.d.ts +1 -0
- package/Types/Monitor/NtpMonitor/NtpMonitorUtil.js +11 -3
- package/Types/Monitor/SnmpMonitor/NetworkTopology.d.mts +6 -0
- package/Types/Monitor/SnmpMonitor/NetworkTopology.d.ts +6 -0
- package/Types/Monitor/UptimeHistoryLabels.js +2 -2
- package/Types/Monitor/WhoIsTold.d.mts +3 -1
- package/Types/Monitor/WhoIsTold.d.ts +3 -1
- package/Types/Monitor/WhoIsTold.js +2 -1
- package/Types/NotificationRule/PagingLadder.d.mts +137 -0
- package/Types/NotificationRule/PagingLadder.d.ts +137 -0
- package/Types/NotificationRule/PagingLadder.js +682 -0
- package/Types/NotificationRule/PagingLadder.mjs +28 -0
- package/Types/NotificationSetting/NotificationEmailRollupCategory.js +1 -1
- package/Types/OnCallDutyPolicy/GlobalUserOverrideAccess.d.mts +1 -0
- package/Types/OnCallDutyPolicy/GlobalUserOverrideAccess.d.ts +1 -0
- package/Types/OnCallDutyPolicy/GlobalUserOverrideAccess.js +12 -9
- package/Types/OnCallDutyPolicy/GlobalUserOverrideAccess.mjs +1 -0
- package/Types/OnCallDutyPolicy/OnCallAcknowledgePage.d.mts +3 -1
- package/Types/OnCallDutyPolicy/OnCallAcknowledgePage.d.ts +3 -1
- package/Types/OnCallDutyPolicy/OnCallAcknowledgePage.js +24 -6
- package/Types/OnCallDutyPolicy/OnCallAcknowledgePage.mjs +1 -0
- package/Types/OnCallDutyPolicy/OnCallPageLine.d.mts +26 -0
- package/Types/OnCallDutyPolicy/OnCallPageLine.d.ts +26 -0
- package/Types/OnCallDutyPolicy/OnCallPageLine.js +136 -0
- package/Types/OnCallDutyPolicy/OnCallPageLine.mjs +18 -0
- package/Types/OnCallDutyPolicy/OnCallPagePassOn.d.mts +1 -0
- package/Types/OnCallDutyPolicy/OnCallPagePassOn.d.ts +1 -0
- package/Types/OnCallDutyPolicy/OnCallPolicyStartedByHand.d.mts +12 -0
- package/Types/OnCallDutyPolicy/OnCallPolicyStartedByHand.d.ts +12 -0
- package/Types/OnCallDutyPolicy/OnCallPolicyStartedByHand.js +38 -0
- package/Types/OnCallDutyPolicy/OnCallPolicyStartedByHand.mjs +3 -0
- package/Types/OnCallDutyPolicy/OnCallTestPage.d.mts +44 -0
- package/Types/OnCallDutyPolicy/OnCallTestPage.d.ts +44 -0
- package/Types/OnCallDutyPolicy/OnCallTestPage.js +96 -5
- package/Types/OnCallDutyPolicy/OnCallTestPage.mjs +1 -0
- package/Types/OnCallDutyPolicy/OnCallTestPageLine.d.mts +19 -0
- package/Types/OnCallDutyPolicy/OnCallTestPageLine.d.ts +19 -0
- package/Types/OnCallDutyPolicy/OnCallTestPageLine.js +222 -0
- package/Types/OnCallDutyPolicy/OnCallTestPageLine.mjs +6 -0
- package/Types/OnCallDutyPolicy/ScheduleLayerDefaults.js +5 -2
- package/Types/OnCallDutyPolicy/ScheduleLayersSave.d.mts +92 -0
- package/Types/OnCallDutyPolicy/ScheduleLayersSave.d.ts +92 -0
- package/Types/OnCallDutyPolicy/ScheduleLayersSave.js +512 -0
- package/Types/OnCallDutyPolicy/ScheduleLayersSave.mjs +7 -0
- package/Types/OnCallDutyPolicy/UserOverrideCoverRequest.js +9 -1
- package/Types/OnCallDutyPolicy/UserOverrideEdit.d.mts +23 -0
- package/Types/OnCallDutyPolicy/UserOverrideEdit.d.ts +23 -0
- package/Types/OnCallDutyPolicy/UserOverrideEdit.js +105 -0
- package/Types/OnCallDutyPolicy/UserOverrideEdit.mjs +6 -0
- package/Types/OnCallDutyPolicy/UserOverrideOverlap.d.mts +64 -0
- package/Types/OnCallDutyPolicy/UserOverrideOverlap.d.ts +64 -0
- package/Types/OnCallDutyPolicy/UserOverrideOverlap.js +237 -0
- package/Types/OnCallDutyPolicy/UserOverrideOverlap.mjs +14 -0
- package/Types/Permission.d.mts +2 -2
- package/Types/Permission.d.ts +2 -2
- package/Types/Permission.js +196 -195
- package/Types/Probe/ProbeCapability.d.mts +2 -1
- package/Types/Probe/ProbeCapability.d.ts +2 -1
- package/Types/Probe/ProbeCapability.js +10 -0
- package/Types/Product/ProductCatalog.d.mts +10 -0
- package/Types/Product/ProductCatalog.d.ts +10 -0
- package/Types/Product/ProductCatalog.js +208 -0
- package/Types/Product/ProductCatalog.mjs +6 -0
- package/Types/Product/ProductOfTable.d.mts +3 -0
- package/Types/Product/ProductOfTable.d.ts +3 -0
- package/Types/Product/ProductOfTable.js +68 -0
- package/Types/Product/ProductOfTable.mjs +3 -0
- package/Types/Product/ProjectProductsAnswer.d.mts +3 -0
- package/Types/Product/ProjectProductsAnswer.d.ts +3 -0
- package/Types/Product/ProjectProductsAnswer.js +35 -2
- package/Types/Product/ProjectProductsAnswer.mjs +1 -0
- package/Types/Product/ServerProducts.d.mts +65 -0
- package/Types/Product/ServerProducts.d.ts +65 -0
- package/Types/Product/ServerProducts.js +383 -0
- package/Types/Product/ServerProducts.mjs +26 -0
- package/Types/Product/ServerProductsAnswer.d.mts +21 -0
- package/Types/Product/ServerProductsAnswer.d.ts +21 -0
- package/Types/Product/ServerProductsAnswer.js +78 -0
- package/Types/Product/ServerProductsAnswer.mjs +5 -0
- package/Types/ProductFeedback/ProductFeedback.d.mts +3 -1
- package/Types/ProductFeedback/ProductFeedback.d.ts +3 -1
- package/Types/ProductFeedback/ProductFeedback.js +8 -0
- package/Types/ReaderLanguage.d.mts +1 -0
- package/Types/ReaderLanguage.d.ts +1 -0
- package/Types/ReaderLanguage.js +13 -1
- package/Types/ReaderLanguage.mjs +1 -0
- package/Types/Rules/RuleRun.js +2 -2
- package/Types/Rum/SessionReplayCustomEvents.d.mts +1 -0
- package/Types/Rum/SessionReplayCustomEvents.d.ts +1 -0
- package/Types/SampleProject/SampleProject.d.mts +54 -0
- package/Types/SampleProject/SampleProject.d.ts +54 -0
- package/Types/SampleProject/SampleProject.js +177 -0
- package/Types/SampleProject/SampleProject.mjs +22 -0
- package/Types/SampleProject/SampleProjectContent.d.mts +127 -0
- package/Types/SampleProject/SampleProjectContent.d.ts +127 -0
- package/Types/SampleProject/SampleProjectContent.js +397 -0
- package/Types/SampleProject/SampleProjectContent.mjs +18 -0
- package/Types/ScheduledMaintenance/MaintenanceCalendar.js +1 -1
- package/Types/ServerSending/ServerSendingStatus.d.mts +7 -0
- package/Types/ServerSending/ServerSendingStatus.d.ts +7 -0
- package/Types/ServerSending/ServerSendingStatus.js +49 -2
- package/Types/ServerSetup/ServerSetupChecklist.js +3 -3
- package/Types/StateTimeline/RowsKeptOnDelete.js +1 -1
- package/Types/StatusPage/NewIncidentSubscriberNotificationDefault.d.mts +8 -0
- package/Types/StatusPage/NewIncidentSubscriberNotificationDefault.d.ts +8 -0
- package/Types/StatusPage/NewIncidentSubscriberNotificationDefault.js +50 -0
- package/Types/StatusPage/NewIncidentSubscriberNotificationDefault.mjs +3 -0
- package/Types/StatusPage/PublicNoteSubscriberNotificationDefault.js +1 -1
- package/Types/Telemetry/CompatibleIngest.d.mts +20 -0
- package/Types/Telemetry/CompatibleIngest.d.ts +20 -0
- package/Types/Telemetry/CompatibleIngest.js +123 -0
- package/Types/Telemetry/CompatibleIngest.mjs +21 -0
- package/Types/Telemetry/TelemetryIngestSurface.d.mts +5 -0
- package/Types/Telemetry/TelemetryIngestSurface.d.ts +5 -0
- package/Types/Telemetry/TelemetryIngestSurface.js +54 -12
- package/Types/TimezoneAlias.d.mts +1 -0
- package/Types/TimezoneAlias.d.ts +1 -0
- package/Types/TimezoneAlias.js +13 -0
- package/Types/Translator.d.mts +1 -0
- package/Types/Translator.d.ts +1 -0
- package/Types/Translator.js +414 -50
- package/Types/Translator.mjs +1 -0
- package/Types/UsedBy/UsedBy.d.mts +103 -0
- package/Types/UsedBy/UsedBy.d.ts +103 -0
- package/Types/UsedBy/UsedBy.js +389 -0
- package/Types/UsedBy/UsedBy.mjs +20 -0
- package/Types/UsedBy/UsedByServerProducts.d.mts +4 -0
- package/Types/UsedBy/UsedByServerProducts.d.ts +4 -0
- package/Types/UsedBy/UsedByServerProducts.js +48 -0
- package/Types/UsedBy/UsedByServerProducts.mjs +3 -0
- package/Types/WelcomeChecklist/WelcomeChecklist.d.mts +6 -0
- package/Types/WelcomeChecklist/WelcomeChecklist.d.ts +6 -0
- package/Types/WelcomeChecklist/WelcomeChecklist.js +54 -2
- package/Types/WelcomeChecklist/WelcomeChecklist.mjs +4 -0
- package/Types/WelcomeChecklist/WelcomeChecklistAnswer.d.mts +1 -0
- package/Types/WelcomeChecklist/WelcomeChecklistAnswer.d.ts +1 -0
- package/Types/WelcomeChecklist/WelcomeChecklistAnswer.js +3 -0
- package/Types/Workflow/PassedOnFields.js +2 -1
- package/Types/Workflow/RunRecord.js +1 -1
- package/Types/Workflow/Templates.js +3 -3
- package/Types/Workspace/NotificationRules/BaseNotificationRule.d.mts +2 -0
- package/Types/Workspace/NotificationRules/BaseNotificationRule.d.ts +2 -0
- package/Types/Workspace/NotificationRules/NotificationRuleCondition.d.mts +28 -1
- package/Types/Workspace/NotificationRules/NotificationRuleCondition.d.ts +28 -1
- package/Types/Workspace/NotificationRules/NotificationRuleUpdates.d.mts +84 -0
- package/Types/Workspace/NotificationRules/NotificationRuleUpdates.d.ts +84 -0
- package/Types/Workspace/NotificationRules/NotificationRuleUpdates.js +456 -0
- package/Types/Workspace/NotificationRules/NotificationRuleUpdates.mjs +5 -0
- package/Utils/AI/MeaningMatch.d.mts +36 -0
- package/Utils/AI/MeaningMatch.d.ts +36 -0
- package/Utils/AI/MeaningMatch.js +535 -0
- package/Utils/AI/MeaningMatch.mjs +7 -0
- package/Utils/ArchivableValues.js +1 -1
- package/Utils/AuditLog/AuditLogValues.js +2 -2
- package/Utils/Dashboard/ClockWidgetFormat.d.mts +14 -2
- package/Utils/Dashboard/ClockWidgetFormat.d.ts +14 -2
- package/Utils/Dashboard/ClockWidgetFormat.js +105 -2
- package/Utils/Dashboard/DashboardViewConfigSignature.d.mts +3 -0
- package/Utils/Dashboard/DashboardViewConfigSignature.d.ts +3 -0
- package/Utils/Dashboard/DashboardViewConfigSignature.js +45 -0
- package/Utils/Dashboard/DashboardViewConfigSignature.mjs +3 -0
- package/Utils/Dashboard/ValueWidgetSeries.d.mts +2 -0
- package/Utils/Dashboard/ValueWidgetSeries.d.ts +2 -0
- package/Utils/Dashboard/ValueWidgetSeries.js +75 -0
- package/Utils/DataSecurity/TextScanner.js +2 -2
- package/Utils/DeveloperDocs/AiAssistantExamples.js +4 -4
- package/Utils/DeveloperDocs/CliCommands.d.mts +1 -0
- package/Utils/DeveloperDocs/CliCommands.d.ts +1 -0
- package/Utils/DeveloperDocs/CliCommands.js +2 -1
- package/Utils/DeveloperDocs/CliResources.js +2 -1
- package/Utils/DeveloperDocs/ExampleBuilder.js +1 -1
- package/Utils/DeveloperDocs/ResourceProfiles.js +2 -2
- package/Utils/DeveloperDocs/TerraformSchema.js +3 -1
- package/Utils/GuidedSetup/StatusPageRecords.d.mts +5 -0
- package/Utils/GuidedSetup/StatusPageRecords.d.ts +5 -0
- package/Utils/GuidedSetup/StatusPageRecords.js +27 -2
- package/Utils/GuidedSetup/StatusPageRecords.mjs +1 -0
- package/Utils/GuidedSetup/WebsiteMonitorRecords.js +6 -0
- package/Utils/HostAddressUtil.d.mts +1 -0
- package/Utils/HostAddressUtil.d.ts +1 -0
- package/Utils/HostAddressUtil.js +30 -0
- package/Utils/LinearRegExp/LinearRegExp.js +5 -1
- package/Utils/Markdown/LinkReferenceDefinitions.d.mts +8 -0
- package/Utils/Markdown/LinkReferenceDefinitions.d.ts +8 -0
- package/Utils/Markdown/LinkReferenceDefinitions.js +1493 -131
- package/Utils/Markdown/LinkReferenceDefinitions.mjs +1 -0
- package/Utils/Markdown/MarkdownTableCell.js +2 -1
- package/Utils/Markdown/OverLongText.js +523 -5
- package/Utils/Markdown/SlowMarkdown.d.mts +14 -0
- package/Utils/Markdown/SlowMarkdown.d.ts +14 -0
- package/Utils/Markdown/SlowMarkdown.js +595 -11
- package/Utils/Markdown/SlowMarkdown.mjs +6 -0
- package/Utils/Milliseconds.d.mts +7 -0
- package/Utils/Milliseconds.d.ts +7 -0
- package/Utils/Milliseconds.js +60 -0
- package/Utils/Milliseconds.mjs +4 -0
- package/Utils/ModelApiName.d.mts +11 -0
- package/Utils/ModelApiName.d.ts +11 -0
- package/Utils/ModelApiName.js +72 -0
- package/Utils/ModelApiName.mjs +5 -0
- package/Utils/Monitor/DeviceMacLearningUtil.d.mts +2 -1
- package/Utils/Monitor/DeviceMacLearningUtil.d.ts +2 -1
- package/Utils/Monitor/DeviceMacLearningUtil.js +26 -0
- package/Utils/Monitor/EndpointAttachmentUtil.d.mts +8 -0
- package/Utils/Monitor/EndpointAttachmentUtil.d.ts +8 -0
- package/Utils/Monitor/EndpointAttachmentUtil.js +97 -22
- package/Utils/Monitor/EndpointAttachmentUtil.mjs +4 -0
- package/Utils/Monitor/ExternalStatusPageReading.d.mts +3 -0
- package/Utils/Monitor/ExternalStatusPageReading.d.ts +3 -0
- package/Utils/Monitor/ExternalStatusPageReading.js +35 -1
- package/Utils/Monitor/ExternalStatusPageReading.mjs +2 -0
- package/Utils/Monitor/InterfaceInventoryUtil.d.mts +40 -0
- package/Utils/Monitor/InterfaceInventoryUtil.d.ts +40 -0
- package/Utils/Monitor/InterfaceInventoryUtil.js +217 -5
- package/Utils/Monitor/InterfaceInventoryUtil.mjs +8 -0
- package/Utils/Monitor/MonitorOverviewPresentationUtil.js +63 -29
- package/Utils/Monitor/MonitorOverviewProbeUtil.js +13 -2
- package/Utils/Monitor/MonitorRootCauseWording.d.mts +2 -0
- package/Utils/Monitor/MonitorRootCauseWording.d.ts +2 -0
- package/Utils/Monitor/MonitorRootCauseWording.js +58 -4
- package/Utils/Monitor/MonitorTemplateLinkRefusal.d.mts +9 -0
- package/Utils/Monitor/MonitorTemplateLinkRefusal.d.ts +9 -0
- package/Utils/Monitor/MonitorTemplateLinkRefusal.js +45 -0
- package/Utils/Monitor/MonitorTemplateLinkRefusal.mjs +6 -0
- package/Utils/Monitor/MonitoringOff.d.mts +2 -0
- package/Utils/Monitor/MonitoringOff.d.ts +2 -0
- package/Utils/Monitor/MonitoringOff.js +21 -0
- package/Utils/Monitor/NetworkTopologyUtil.d.mts +2 -1
- package/Utils/Monitor/NetworkTopologyUtil.d.ts +2 -1
- package/Utils/Monitor/NetworkTopologyUtil.js +10 -0
- package/Utils/Monitor/NotOperationalMonitorQuery.d.mts +2 -1
- package/Utils/Monitor/NotOperationalMonitorQuery.d.ts +2 -1
- package/Utils/Monitor/NotOperationalMonitorQuery.js +23 -4
- package/Utils/Monitor/ProbeFailureReading.d.mts +14 -0
- package/Utils/Monitor/ProbeFailureReading.d.ts +14 -0
- package/Utils/Monitor/ProbeFailureReading.js +137 -0
- package/Utils/Monitor/ProbeFailureReading.mjs +7 -0
- package/Utils/NetworkDevice/BoundMonitorNotChecked.d.mts +9 -0
- package/Utils/NetworkDevice/BoundMonitorNotChecked.d.ts +9 -0
- package/Utils/NetworkDevice/BoundMonitorNotChecked.js +15 -0
- package/Utils/NetworkDevice/BoundMonitorNotChecked.mjs +2 -0
- package/Utils/OpenStack/OpenStackCheckName.js +2 -1
- package/Utils/OpenStack/OpenStackLogScrub.js +1 -1
- package/Utils/OpenStack/OpenStackLogs.js +3 -2
- package/Utils/OpenStack/OpenStackTraces.js +2 -1
- package/Utils/Project/NextNumber.js +1 -1
- package/Utils/Project/NotificationChannels.js +5 -5
- package/Utils/Project/ProjectBalance.js +2 -2
- package/Utils/Project/TwilioAccount.js +2 -2
- package/Utils/PromQL/PromQLAst.d.mts +159 -0
- package/Utils/PromQL/PromQLAst.d.ts +159 -0
- package/Utils/PromQL/PromQLAst.js +118 -0
- package/Utils/PromQL/PromQLAst.mjs +12 -0
- package/Utils/PromQL/PromQLDuration.d.mts +2 -0
- package/Utils/PromQL/PromQLDuration.d.ts +2 -0
- package/Utils/PromQL/PromQLDuration.js +78 -0
- package/Utils/PromQL/PromQLDuration.mjs +3 -0
- package/Utils/PromQL/PromQLEngine.d.mts +15 -0
- package/Utils/PromQL/PromQLEngine.d.ts +15 -0
- package/Utils/PromQL/PromQLEngine.js +965 -0
- package/Utils/PromQL/PromQLEngine.mjs +7 -0
- package/Utils/PromQL/PromQLEngineTypes.d.mts +84 -0
- package/Utils/PromQL/PromQLEngineTypes.d.ts +84 -0
- package/Utils/PromQL/PromQLEngineTypes.js +10 -0
- package/Utils/PromQL/PromQLEngineTypes.mjs +2 -0
- package/Utils/PromQL/PromQLError.d.mts +11 -0
- package/Utils/PromQL/PromQLError.d.ts +11 -0
- package/Utils/PromQL/PromQLError.js +27 -0
- package/Utils/PromQL/PromQLError.mjs +3 -0
- package/Utils/PromQL/PromQLFunctionEvaluators.d.mts +8 -0
- package/Utils/PromQL/PromQLFunctionEvaluators.d.ts +8 -0
- package/Utils/PromQL/PromQLFunctionEvaluators.js +773 -0
- package/Utils/PromQL/PromQLFunctionEvaluators.mjs +3 -0
- package/Utils/PromQL/PromQLFunctions.d.mts +10 -0
- package/Utils/PromQL/PromQLFunctions.d.ts +10 -0
- package/Utils/PromQL/PromQLFunctions.js +127 -0
- package/Utils/PromQL/PromQLFunctions.mjs +4 -0
- package/Utils/PromQL/PromQLLabels.d.mts +11 -0
- package/Utils/PromQL/PromQLLabels.d.ts +11 -0
- package/Utils/PromQL/PromQLLabels.js +218 -0
- package/Utils/PromQL/PromQLLabels.mjs +9 -0
- package/Utils/PromQL/PromQLLexer.d.mts +39 -0
- package/Utils/PromQL/PromQLLexer.d.ts +39 -0
- package/Utils/PromQL/PromQLLexer.js +391 -0
- package/Utils/PromQL/PromQLLexer.mjs +3 -0
- package/Utils/PromQL/PromQLMath.d.mts +19 -0
- package/Utils/PromQL/PromQLMath.d.ts +19 -0
- package/Utils/PromQL/PromQLMath.js +200 -0
- package/Utils/PromQL/PromQLMath.mjs +9 -0
- package/Utils/PromQL/PromQLMetricNames.d.mts +21 -0
- package/Utils/PromQL/PromQLMetricNames.d.ts +21 -0
- package/Utils/PromQL/PromQLMetricNames.js +199 -0
- package/Utils/PromQL/PromQLMetricNames.mjs +8 -0
- package/Utils/PromQL/PromQLParser.d.mts +4 -0
- package/Utils/PromQL/PromQLParser.d.ts +4 -0
- package/Utils/PromQL/PromQLParser.js +831 -0
- package/Utils/PromQL/PromQLParser.mjs +4 -0
- package/Utils/PromQL/PromQLRegex.d.mts +9 -0
- package/Utils/PromQL/PromQLRegex.d.ts +9 -0
- package/Utils/PromQL/PromQLRegex.js +74 -0
- package/Utils/PromQL/PromQLRegex.mjs +2 -0
- package/Utils/PromQL/PrometheusResponse.d.mts +25 -0
- package/Utils/PromQL/PrometheusResponse.d.ts +25 -0
- package/Utils/PromQL/PrometheusResponse.js +90 -0
- package/Utils/PromQL/PrometheusResponse.mjs +3 -0
- package/Utils/Rum/PathInSentence.d.mts +5 -0
- package/Utils/Rum/PathInSentence.d.ts +5 -0
- package/Utils/Rum/PathInSentence.js +46 -0
- package/Utils/Rum/PathInSentence.mjs +6 -0
- package/Utils/Rum/UrlScrubber.d.mts +4 -0
- package/Utils/Rum/UrlScrubber.d.ts +4 -0
- package/Utils/Rum/UrlScrubber.js +143 -3
- package/Utils/Rum/UserFlow.d.mts +1 -1
- package/Utils/Rum/UserFlow.d.ts +1 -1
- package/Utils/Rum/UserFlow.js +180 -25
- package/Utils/Rum/UserFlow.mjs +1 -1
- package/Utils/Runbook/RunbookStepsSignature.d.mts +3 -0
- package/Utils/Runbook/RunbookStepsSignature.d.ts +3 -0
- package/Utils/Runbook/RunbookStepsSignature.js +30 -0
- package/Utils/Runbook/RunbookStepsSignature.mjs +3 -0
- package/Utils/ScheduledMaintenanceStart.d.mts +3 -0
- package/Utils/ScheduledMaintenanceStart.d.ts +3 -0
- package/Utils/ScheduledMaintenanceStart.js +9 -0
- package/Utils/Schema/ModelSchema.js +10 -1
- package/Utils/Schema/TypeSchemas.js +6 -0
- package/Utils/Slo/SloDuration.d.mts +5 -2
- package/Utils/Slo/SloDuration.d.ts +5 -2
- package/Utils/Slo/SloDuration.js +11 -6
- package/Utils/Slo/SloHealth.js +1 -1
- package/Utils/StateOrder.js +1 -4
- package/Utils/StateTimeline/StateTimelineRowDelete.js +1 -1
- package/Utils/Telemetry/HeartbeatAvailability.d.mts +4 -0
- package/Utils/Telemetry/HeartbeatAvailability.d.ts +4 -0
- package/Utils/Telemetry/HeartbeatAvailability.js +118 -26
- package/Utils/Uptime/DayUptimeGraphUtil.js +2 -2
- package/Utils/Uptime/UptimeMaintenanceUtil.js +2 -1
- package/Utils/ValueFormatter.d.mts +8 -6
- package/Utils/ValueFormatter.d.ts +8 -6
- package/Utils/ValueFormatter.js +145 -0
- package/package.json +1 -1
|
@@ -0,0 +1,831 @@
|
|
|
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.parsePromQL = exports.matchesEmptyValue = exports.getPromQLValueType = void 0;
|
|
7
|
+
const PromQLAst_1 = require("./PromQLAst");
|
|
8
|
+
const PromQLDuration_1 = require("./PromQLDuration");
|
|
9
|
+
const PromQLError_1 = __importDefault(require("./PromQLError"));
|
|
10
|
+
const PromQLFunctions_1 = require("./PromQLFunctions");
|
|
11
|
+
const PromQLLexer_1 = require("./PromQLLexer");
|
|
12
|
+
const PromQLRegex_1 = require("./PromQLRegex");
|
|
13
|
+
const PatternCache_1 = require("../LinearRegExp/PatternCache");
|
|
14
|
+
/*
|
|
15
|
+
* Parses a PromQL query into a checked syntax tree (promql/parser).
|
|
16
|
+
*
|
|
17
|
+
* A precedence-climbing parser over PromQLLexer's tokens. It checks what
|
|
18
|
+
* Prometheus' parser checks (argument types, `bool` on scalar comparisons,
|
|
19
|
+
* vector matching only between vectors, a selector that selects something),
|
|
20
|
+
* so a query OneUptime accepts is one Prometheus accepts, and the engine can
|
|
21
|
+
* trust the tree it is handed.
|
|
22
|
+
*/
|
|
23
|
+
const AGGREGATE_OPERATORS = new Map(Object.values(PromQLAst_1.PromQLAggregateOperator).map((operator) => {
|
|
24
|
+
return [operator, operator];
|
|
25
|
+
}));
|
|
26
|
+
const AGGREGATES_WITH_PARAMETER = new Set([
|
|
27
|
+
PromQLAst_1.PromQLAggregateOperator.Topk,
|
|
28
|
+
PromQLAst_1.PromQLAggregateOperator.Bottomk,
|
|
29
|
+
PromQLAst_1.PromQLAggregateOperator.Quantile,
|
|
30
|
+
PromQLAst_1.PromQLAggregateOperator.CountValues,
|
|
31
|
+
]);
|
|
32
|
+
const KEYWORD_BINARY_OPERATORS = {
|
|
33
|
+
and: PromQLAst_1.PromQLBinaryOperator.And,
|
|
34
|
+
or: PromQLAst_1.PromQLBinaryOperator.Or,
|
|
35
|
+
unless: PromQLAst_1.PromQLBinaryOperator.Unless,
|
|
36
|
+
atan2: PromQLAst_1.PromQLBinaryOperator.Atan2,
|
|
37
|
+
};
|
|
38
|
+
const SYMBOL_BINARY_OPERATORS = new Map([
|
|
39
|
+
[PromQLLexer_1.PromQLTokenType.Add, PromQLAst_1.PromQLBinaryOperator.Add],
|
|
40
|
+
[PromQLLexer_1.PromQLTokenType.Sub, PromQLAst_1.PromQLBinaryOperator.Sub],
|
|
41
|
+
[PromQLLexer_1.PromQLTokenType.Mul, PromQLAst_1.PromQLBinaryOperator.Mul],
|
|
42
|
+
[PromQLLexer_1.PromQLTokenType.Div, PromQLAst_1.PromQLBinaryOperator.Div],
|
|
43
|
+
[PromQLLexer_1.PromQLTokenType.Mod, PromQLAst_1.PromQLBinaryOperator.Mod],
|
|
44
|
+
[PromQLLexer_1.PromQLTokenType.Pow, PromQLAst_1.PromQLBinaryOperator.Pow],
|
|
45
|
+
[PromQLLexer_1.PromQLTokenType.Eql, PromQLAst_1.PromQLBinaryOperator.Eql],
|
|
46
|
+
[PromQLLexer_1.PromQLTokenType.Neq, PromQLAst_1.PromQLBinaryOperator.Neq],
|
|
47
|
+
[PromQLLexer_1.PromQLTokenType.Gtr, PromQLAst_1.PromQLBinaryOperator.Gtr],
|
|
48
|
+
[PromQLLexer_1.PromQLTokenType.Lss, PromQLAst_1.PromQLBinaryOperator.Lss],
|
|
49
|
+
[PromQLLexer_1.PromQLTokenType.Gte, PromQLAst_1.PromQLBinaryOperator.Gte],
|
|
50
|
+
[PromQLLexer_1.PromQLTokenType.Lte, PromQLAst_1.PromQLBinaryOperator.Lte],
|
|
51
|
+
]);
|
|
52
|
+
// Lowest first, as Prometheus binds them.
|
|
53
|
+
const PRECEDENCE = {
|
|
54
|
+
[PromQLAst_1.PromQLBinaryOperator.Or]: 1,
|
|
55
|
+
[PromQLAst_1.PromQLBinaryOperator.And]: 2,
|
|
56
|
+
[PromQLAst_1.PromQLBinaryOperator.Unless]: 2,
|
|
57
|
+
[PromQLAst_1.PromQLBinaryOperator.Eql]: 3,
|
|
58
|
+
[PromQLAst_1.PromQLBinaryOperator.Neq]: 3,
|
|
59
|
+
[PromQLAst_1.PromQLBinaryOperator.Gtr]: 3,
|
|
60
|
+
[PromQLAst_1.PromQLBinaryOperator.Lss]: 3,
|
|
61
|
+
[PromQLAst_1.PromQLBinaryOperator.Gte]: 3,
|
|
62
|
+
[PromQLAst_1.PromQLBinaryOperator.Lte]: 3,
|
|
63
|
+
[PromQLAst_1.PromQLBinaryOperator.Add]: 4,
|
|
64
|
+
[PromQLAst_1.PromQLBinaryOperator.Sub]: 4,
|
|
65
|
+
[PromQLAst_1.PromQLBinaryOperator.Mul]: 5,
|
|
66
|
+
[PromQLAst_1.PromQLBinaryOperator.Div]: 5,
|
|
67
|
+
[PromQLAst_1.PromQLBinaryOperator.Mod]: 5,
|
|
68
|
+
[PromQLAst_1.PromQLBinaryOperator.Atan2]: 5,
|
|
69
|
+
[PromQLAst_1.PromQLBinaryOperator.Pow]: 6,
|
|
70
|
+
};
|
|
71
|
+
/*
|
|
72
|
+
* A unary minus binds like `*`: `-a * b` is `(-a) * b`, but `-2 ^ 2` is
|
|
73
|
+
* `-(2 ^ 2)`, so its operand takes only what binds tighter than `*`.
|
|
74
|
+
*/
|
|
75
|
+
const UNARY_OPERAND_PRECEDENCE = PRECEDENCE[PromQLAst_1.PromQLBinaryOperator.Pow];
|
|
76
|
+
const MATCH_TYPES = new Map([
|
|
77
|
+
[PromQLLexer_1.PromQLTokenType.Assign, PromQLAst_1.PromQLMatchType.Equal],
|
|
78
|
+
[PromQLLexer_1.PromQLTokenType.Neq, PromQLAst_1.PromQLMatchType.NotEqual],
|
|
79
|
+
[PromQLLexer_1.PromQLTokenType.RegexMatch, PromQLAst_1.PromQLMatchType.RegexMatch],
|
|
80
|
+
[PromQLLexer_1.PromQLTokenType.RegexNoMatch, PromQLAst_1.PromQLMatchType.RegexNoMatch],
|
|
81
|
+
]);
|
|
82
|
+
const describeToken = (token) => {
|
|
83
|
+
switch (token.type) {
|
|
84
|
+
case PromQLLexer_1.PromQLTokenType.EOF:
|
|
85
|
+
return "the end of the query";
|
|
86
|
+
case PromQLLexer_1.PromQLTokenType.String:
|
|
87
|
+
return `the string "${token.text}"`;
|
|
88
|
+
case PromQLLexer_1.PromQLTokenType.Number:
|
|
89
|
+
return `the number ${token.text}`;
|
|
90
|
+
case PromQLLexer_1.PromQLTokenType.Duration:
|
|
91
|
+
return `the duration ${token.text}`;
|
|
92
|
+
case PromQLLexer_1.PromQLTokenType.Identifier:
|
|
93
|
+
case PromQLLexer_1.PromQLTokenType.MetricIdentifier:
|
|
94
|
+
return `"${token.text}"`;
|
|
95
|
+
default:
|
|
96
|
+
return `"${token.text}"`;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const parseNumberText = (text) => {
|
|
100
|
+
if (text.startsWith("0x") || text.startsWith("0X")) {
|
|
101
|
+
return parseInt(text.slice(2), 16);
|
|
102
|
+
}
|
|
103
|
+
return Number(text);
|
|
104
|
+
};
|
|
105
|
+
const getPromQLValueType = (expression) => {
|
|
106
|
+
switch (expression.kind) {
|
|
107
|
+
case PromQLAst_1.PromQLNodeKind.NumberLiteral:
|
|
108
|
+
return PromQLAst_1.PromQLValueType.Scalar;
|
|
109
|
+
case PromQLAst_1.PromQLNodeKind.StringLiteral:
|
|
110
|
+
return PromQLAst_1.PromQLValueType.String;
|
|
111
|
+
case PromQLAst_1.PromQLNodeKind.VectorSelector:
|
|
112
|
+
return PromQLAst_1.PromQLValueType.InstantVector;
|
|
113
|
+
case PromQLAst_1.PromQLNodeKind.MatrixSelector:
|
|
114
|
+
case PromQLAst_1.PromQLNodeKind.Subquery:
|
|
115
|
+
return PromQLAst_1.PromQLValueType.RangeVector;
|
|
116
|
+
case PromQLAst_1.PromQLNodeKind.Call:
|
|
117
|
+
return (0, PromQLFunctions_1.getPromQLFunction)(expression.functionName).returnType;
|
|
118
|
+
case PromQLAst_1.PromQLNodeKind.Aggregate:
|
|
119
|
+
return PromQLAst_1.PromQLValueType.InstantVector;
|
|
120
|
+
case PromQLAst_1.PromQLNodeKind.Binary:
|
|
121
|
+
return (0, exports.getPromQLValueType)(expression.lhs) === PromQLAst_1.PromQLValueType.Scalar &&
|
|
122
|
+
(0, exports.getPromQLValueType)(expression.rhs) === PromQLAst_1.PromQLValueType.Scalar
|
|
123
|
+
? PromQLAst_1.PromQLValueType.Scalar
|
|
124
|
+
: PromQLAst_1.PromQLValueType.InstantVector;
|
|
125
|
+
case PromQLAst_1.PromQLNodeKind.Unary:
|
|
126
|
+
case PromQLAst_1.PromQLNodeKind.Paren:
|
|
127
|
+
return (0, exports.getPromQLValueType)(expression.expression);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
exports.getPromQLValueType = getPromQLValueType;
|
|
131
|
+
class PromQLParser {
|
|
132
|
+
constructor(query) {
|
|
133
|
+
this.index = 0;
|
|
134
|
+
// Selectors and subqueries whose offset or `@` the query has written.
|
|
135
|
+
this.offsetWritten = new WeakSet();
|
|
136
|
+
this.atWritten = new WeakSet();
|
|
137
|
+
this.tokens = (0, PromQLLexer_1.tokenizePromQL)(query);
|
|
138
|
+
}
|
|
139
|
+
parse() {
|
|
140
|
+
if (this.peek().type === PromQLLexer_1.PromQLTokenType.EOF) {
|
|
141
|
+
throw new PromQLError_1.default("The query is empty. Write a PromQL expression, such as up or rate(http_requests_total[5m]).");
|
|
142
|
+
}
|
|
143
|
+
const expression = this.parseExpression(0);
|
|
144
|
+
const next = this.peek();
|
|
145
|
+
if (next.type !== PromQLLexer_1.PromQLTokenType.EOF) {
|
|
146
|
+
throw this.unexpected(next, "an operator or the end of the query");
|
|
147
|
+
}
|
|
148
|
+
return expression;
|
|
149
|
+
}
|
|
150
|
+
peek(offset = 0) {
|
|
151
|
+
return (this.tokens[this.index + offset] || this.tokens[this.tokens.length - 1]);
|
|
152
|
+
}
|
|
153
|
+
next() {
|
|
154
|
+
const token = this.peek();
|
|
155
|
+
if (token.type !== PromQLLexer_1.PromQLTokenType.EOF) {
|
|
156
|
+
this.index++;
|
|
157
|
+
}
|
|
158
|
+
return token;
|
|
159
|
+
}
|
|
160
|
+
expect(type, what) {
|
|
161
|
+
const token = this.peek();
|
|
162
|
+
if (token.type !== type) {
|
|
163
|
+
throw this.unexpected(token, what);
|
|
164
|
+
}
|
|
165
|
+
return this.next();
|
|
166
|
+
}
|
|
167
|
+
unexpected(token, expected) {
|
|
168
|
+
return new PromQLError_1.default(`Unexpected ${describeToken(token)} at position ${token.start + 1}: expected ${expected}.`, undefined, { start: token.start, end: Math.max(token.end, token.start + 1) });
|
|
169
|
+
}
|
|
170
|
+
isKeyword(token, keyword) {
|
|
171
|
+
return (token.type === PromQLLexer_1.PromQLTokenType.Identifier &&
|
|
172
|
+
token.text.toLowerCase() === keyword);
|
|
173
|
+
}
|
|
174
|
+
peekBinaryOperator() {
|
|
175
|
+
const token = this.peek();
|
|
176
|
+
if (token.type === PromQLLexer_1.PromQLTokenType.Identifier) {
|
|
177
|
+
return KEYWORD_BINARY_OPERATORS[token.text.toLowerCase()];
|
|
178
|
+
}
|
|
179
|
+
return SYMBOL_BINARY_OPERATORS.get(token.type);
|
|
180
|
+
}
|
|
181
|
+
parseExpression(minimumPrecedence) {
|
|
182
|
+
let lhs = this.parseUnaryOrPostfix();
|
|
183
|
+
for (;;) {
|
|
184
|
+
const operator = this.peekBinaryOperator();
|
|
185
|
+
if (!operator || PRECEDENCE[operator] < minimumPrecedence) {
|
|
186
|
+
return lhs;
|
|
187
|
+
}
|
|
188
|
+
const operatorToken = this.next();
|
|
189
|
+
const modifiers = this.parseBinaryModifiers();
|
|
190
|
+
// `^` is right-associative: 2 ^ 3 ^ 2 is 2 ^ (3 ^ 2).
|
|
191
|
+
const rhs = this.parseExpression(operator === PromQLAst_1.PromQLBinaryOperator.Pow
|
|
192
|
+
? PRECEDENCE[operator]
|
|
193
|
+
: PRECEDENCE[operator] + 1);
|
|
194
|
+
lhs = this.buildBinary({
|
|
195
|
+
operator,
|
|
196
|
+
operatorToken,
|
|
197
|
+
lhs,
|
|
198
|
+
rhs,
|
|
199
|
+
returnBool: modifiers.returnBool,
|
|
200
|
+
matching: modifiers.matching,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
parseBinaryModifiers() {
|
|
205
|
+
let returnBool = false;
|
|
206
|
+
if (this.isKeyword(this.peek(), "bool")) {
|
|
207
|
+
this.next();
|
|
208
|
+
returnBool = true;
|
|
209
|
+
}
|
|
210
|
+
const matching = {
|
|
211
|
+
cardinality: PromQLAst_1.PromQLVectorMatchCardinality.OneToOne,
|
|
212
|
+
on: false,
|
|
213
|
+
matchingLabels: [],
|
|
214
|
+
include: [],
|
|
215
|
+
};
|
|
216
|
+
const token = this.peek();
|
|
217
|
+
if (this.isKeyword(token, "on") || this.isKeyword(token, "ignoring")) {
|
|
218
|
+
this.next();
|
|
219
|
+
matching.on = token.text.toLowerCase() === "on";
|
|
220
|
+
matching.matchingLabels = this.parseLabelList();
|
|
221
|
+
const group = this.peek();
|
|
222
|
+
if (this.isKeyword(group, "group_left") ||
|
|
223
|
+
this.isKeyword(group, "group_right")) {
|
|
224
|
+
this.next();
|
|
225
|
+
matching.cardinality =
|
|
226
|
+
group.text.toLowerCase() === "group_left"
|
|
227
|
+
? PromQLAst_1.PromQLVectorMatchCardinality.ManyToOne
|
|
228
|
+
: PromQLAst_1.PromQLVectorMatchCardinality.OneToMany;
|
|
229
|
+
if (this.peek().type === PromQLLexer_1.PromQLTokenType.LeftParen) {
|
|
230
|
+
matching.include = this.parseLabelList();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return { returnBool, matching };
|
|
235
|
+
}
|
|
236
|
+
buildBinary(data) {
|
|
237
|
+
const { operator, operatorToken, lhs, rhs, returnBool, matching } = data;
|
|
238
|
+
const operatorPosition = {
|
|
239
|
+
start: operatorToken.start,
|
|
240
|
+
end: operatorToken.end,
|
|
241
|
+
};
|
|
242
|
+
const lhsType = (0, exports.getPromQLValueType)(lhs);
|
|
243
|
+
const rhsType = (0, exports.getPromQLValueType)(rhs);
|
|
244
|
+
if (returnBool && !(0, PromQLAst_1.isComparisonOperator)(operator)) {
|
|
245
|
+
throw new PromQLError_1.default(`The bool modifier only goes after a comparison (==, !=, >, <, >= or <=), not after "${operator}".`, undefined, operatorPosition);
|
|
246
|
+
}
|
|
247
|
+
if ((0, PromQLAst_1.isComparisonOperator)(operator) &&
|
|
248
|
+
!returnBool &&
|
|
249
|
+
lhsType === PromQLAst_1.PromQLValueType.Scalar &&
|
|
250
|
+
rhsType === PromQLAst_1.PromQLValueType.Scalar) {
|
|
251
|
+
throw new PromQLError_1.default(`A comparison between two numbers needs the bool modifier: write "${operator} bool".`, undefined, operatorPosition);
|
|
252
|
+
}
|
|
253
|
+
if ((0, PromQLAst_1.isSetOperator)(operator) &&
|
|
254
|
+
matching.cardinality === PromQLAst_1.PromQLVectorMatchCardinality.OneToOne) {
|
|
255
|
+
matching.cardinality = PromQLAst_1.PromQLVectorMatchCardinality.ManyToMany;
|
|
256
|
+
}
|
|
257
|
+
if (matching.on) {
|
|
258
|
+
for (const label of matching.matchingLabels) {
|
|
259
|
+
if (matching.include.includes(label)) {
|
|
260
|
+
throw new PromQLError_1.default(`The label "${label}" is in both on(...) and group_left/group_right(...). List it in one of them.`, undefined, operatorPosition);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
for (const [side, type] of [
|
|
265
|
+
[lhs, lhsType],
|
|
266
|
+
[rhs, rhsType],
|
|
267
|
+
]) {
|
|
268
|
+
if (type !== PromQLAst_1.PromQLValueType.Scalar &&
|
|
269
|
+
type !== PromQLAst_1.PromQLValueType.InstantVector) {
|
|
270
|
+
throw new PromQLError_1.default(`"${operator}" works on numbers and instant vectors, not on ${PromQLAst_1.PROMQL_VALUE_TYPE_WITH_ARTICLE[type]}.`, undefined, side.position);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
let finalMatching = matching;
|
|
274
|
+
if (lhsType !== PromQLAst_1.PromQLValueType.InstantVector ||
|
|
275
|
+
rhsType !== PromQLAst_1.PromQLValueType.InstantVector) {
|
|
276
|
+
if (matching.matchingLabels.length > 0) {
|
|
277
|
+
throw new PromQLError_1.default("Vector matching (on or ignoring) only works between two instant vectors.", undefined, operatorPosition);
|
|
278
|
+
}
|
|
279
|
+
finalMatching = undefined;
|
|
280
|
+
}
|
|
281
|
+
else if ((0, PromQLAst_1.isSetOperator)(operator)) {
|
|
282
|
+
if (matching.cardinality === PromQLAst_1.PromQLVectorMatchCardinality.OneToMany ||
|
|
283
|
+
matching.cardinality === PromQLAst_1.PromQLVectorMatchCardinality.ManyToOne) {
|
|
284
|
+
throw new PromQLError_1.default(`"${operator}" takes no group_left or group_right.`, undefined, operatorPosition);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
if ((lhsType === PromQLAst_1.PromQLValueType.Scalar ||
|
|
288
|
+
rhsType === PromQLAst_1.PromQLValueType.Scalar) &&
|
|
289
|
+
(0, PromQLAst_1.isSetOperator)(operator)) {
|
|
290
|
+
throw new PromQLError_1.default(`"${operator}" works between two instant vectors, not with a number.`, undefined, operatorPosition);
|
|
291
|
+
}
|
|
292
|
+
return {
|
|
293
|
+
kind: PromQLAst_1.PromQLNodeKind.Binary,
|
|
294
|
+
operator,
|
|
295
|
+
lhs,
|
|
296
|
+
rhs,
|
|
297
|
+
returnBool,
|
|
298
|
+
matching: finalMatching,
|
|
299
|
+
position: { start: lhs.position.start, end: rhs.position.end },
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
parseUnaryOrPostfix() {
|
|
303
|
+
const token = this.peek();
|
|
304
|
+
if (token.type === PromQLLexer_1.PromQLTokenType.Add ||
|
|
305
|
+
token.type === PromQLLexer_1.PromQLTokenType.Sub) {
|
|
306
|
+
this.next();
|
|
307
|
+
const operand = this.parseExpression(UNARY_OPERAND_PRECEDENCE);
|
|
308
|
+
const position = {
|
|
309
|
+
start: token.start,
|
|
310
|
+
end: operand.position.end,
|
|
311
|
+
};
|
|
312
|
+
// `-1` is the number -1, as in Prometheus.
|
|
313
|
+
if (operand.kind === PromQLAst_1.PromQLNodeKind.NumberLiteral) {
|
|
314
|
+
return Object.assign(Object.assign({}, operand), { value: token.type === PromQLLexer_1.PromQLTokenType.Sub ? -operand.value : operand.value, position });
|
|
315
|
+
}
|
|
316
|
+
const operandType = (0, exports.getPromQLValueType)(operand);
|
|
317
|
+
if (operandType !== PromQLAst_1.PromQLValueType.Scalar &&
|
|
318
|
+
operandType !== PromQLAst_1.PromQLValueType.InstantVector) {
|
|
319
|
+
throw new PromQLError_1.default(`A unary "${token.text}" works on a number or an instant vector, not on ${PromQLAst_1.PROMQL_VALUE_TYPE_WITH_ARTICLE[operandType]}.`, undefined, position);
|
|
320
|
+
}
|
|
321
|
+
return {
|
|
322
|
+
kind: PromQLAst_1.PromQLNodeKind.Unary,
|
|
323
|
+
operator: token.type === PromQLLexer_1.PromQLTokenType.Sub
|
|
324
|
+
? PromQLAst_1.PromQLBinaryOperator.Sub
|
|
325
|
+
: PromQLAst_1.PromQLBinaryOperator.Add,
|
|
326
|
+
expression: operand,
|
|
327
|
+
position,
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
return this.parsePostfix(this.parsePrimary());
|
|
331
|
+
}
|
|
332
|
+
parsePrimary() {
|
|
333
|
+
const token = this.peek();
|
|
334
|
+
switch (token.type) {
|
|
335
|
+
case PromQLLexer_1.PromQLTokenType.Number: {
|
|
336
|
+
this.next();
|
|
337
|
+
return {
|
|
338
|
+
kind: PromQLAst_1.PromQLNodeKind.NumberLiteral,
|
|
339
|
+
value: parseNumberText(token.text),
|
|
340
|
+
position: { start: token.start, end: token.end },
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
case PromQLLexer_1.PromQLTokenType.String: {
|
|
344
|
+
this.next();
|
|
345
|
+
return {
|
|
346
|
+
kind: PromQLAst_1.PromQLNodeKind.StringLiteral,
|
|
347
|
+
value: token.text,
|
|
348
|
+
position: { start: token.start, end: token.end },
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
case PromQLLexer_1.PromQLTokenType.LeftParen: {
|
|
352
|
+
this.next();
|
|
353
|
+
const inner = this.parseExpression(0);
|
|
354
|
+
const close = this.expect(PromQLLexer_1.PromQLTokenType.RightParen, '")"');
|
|
355
|
+
return {
|
|
356
|
+
kind: PromQLAst_1.PromQLNodeKind.Paren,
|
|
357
|
+
expression: inner,
|
|
358
|
+
position: { start: token.start, end: close.end },
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
case PromQLLexer_1.PromQLTokenType.LeftBrace:
|
|
362
|
+
return this.parseVectorSelector(undefined, token.start);
|
|
363
|
+
case PromQLLexer_1.PromQLTokenType.Identifier:
|
|
364
|
+
case PromQLLexer_1.PromQLTokenType.MetricIdentifier:
|
|
365
|
+
return this.parseIdentifierExpression();
|
|
366
|
+
default:
|
|
367
|
+
throw this.unexpected(token, "a metric name, a function, a number or an opening bracket");
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
parseIdentifierExpression() {
|
|
371
|
+
const token = this.next();
|
|
372
|
+
const lower = token.text.toLowerCase();
|
|
373
|
+
const following = this.peek();
|
|
374
|
+
if (token.type === PromQLLexer_1.PromQLTokenType.Identifier) {
|
|
375
|
+
const aggregate = AGGREGATE_OPERATORS.get(lower);
|
|
376
|
+
if (aggregate &&
|
|
377
|
+
(following.type === PromQLLexer_1.PromQLTokenType.LeftParen ||
|
|
378
|
+
this.isKeyword(following, "by") ||
|
|
379
|
+
this.isKeyword(following, "without"))) {
|
|
380
|
+
return this.parseAggregate(aggregate, token);
|
|
381
|
+
}
|
|
382
|
+
if (following.type === PromQLLexer_1.PromQLTokenType.LeftParen) {
|
|
383
|
+
return this.parseCall(token);
|
|
384
|
+
}
|
|
385
|
+
if (lower === "inf" || lower === "nan") {
|
|
386
|
+
return {
|
|
387
|
+
kind: PromQLAst_1.PromQLNodeKind.NumberLiteral,
|
|
388
|
+
value: lower === "inf" ? Infinity : NaN,
|
|
389
|
+
position: { start: token.start, end: token.end },
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
return this.parseVectorSelector(token.text, token.start);
|
|
394
|
+
}
|
|
395
|
+
parseVectorSelector(name, start) {
|
|
396
|
+
var _a, _b;
|
|
397
|
+
let metricName = name;
|
|
398
|
+
const matchers = [];
|
|
399
|
+
let end = (_b = (_a = this.tokens[this.index - 1]) === null || _a === void 0 ? void 0 : _a.end) !== null && _b !== void 0 ? _b : start;
|
|
400
|
+
if (this.peek().type === PromQLLexer_1.PromQLTokenType.LeftBrace) {
|
|
401
|
+
this.next();
|
|
402
|
+
while (this.peek().type !== PromQLLexer_1.PromQLTokenType.RightBrace) {
|
|
403
|
+
const labelToken = this.next();
|
|
404
|
+
let labelName;
|
|
405
|
+
if (labelToken.type === PromQLLexer_1.PromQLTokenType.String) {
|
|
406
|
+
// `{"http.server.duration"}`: a quoted metric name, Prometheus 3.
|
|
407
|
+
if (!MATCH_TYPES.has(this.peek().type)) {
|
|
408
|
+
if (metricName !== undefined) {
|
|
409
|
+
throw new PromQLError_1.default(`The metric name is written twice: "${metricName}" and "${labelToken.text}". Keep one.`, undefined, { start, end: labelToken.end });
|
|
410
|
+
}
|
|
411
|
+
metricName = labelToken.text;
|
|
412
|
+
this.finishMatcherListItem();
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
415
|
+
labelName = labelToken.text;
|
|
416
|
+
}
|
|
417
|
+
else if (labelToken.type === PromQLLexer_1.PromQLTokenType.Identifier) {
|
|
418
|
+
labelName = labelToken.text;
|
|
419
|
+
}
|
|
420
|
+
else {
|
|
421
|
+
throw this.unexpected(labelToken, "a label name");
|
|
422
|
+
}
|
|
423
|
+
const operatorToken = this.next();
|
|
424
|
+
const matchType = MATCH_TYPES.get(operatorToken.type);
|
|
425
|
+
if (!matchType) {
|
|
426
|
+
throw this.unexpected(operatorToken, '"=", "!=", "=~" or "!~"');
|
|
427
|
+
}
|
|
428
|
+
const valueToken = this.next();
|
|
429
|
+
if (valueToken.type !== PromQLLexer_1.PromQLTokenType.String) {
|
|
430
|
+
throw this.unexpected(valueToken, `a quoted value for the label "${labelName}"`);
|
|
431
|
+
}
|
|
432
|
+
if (matchType === PromQLAst_1.PromQLMatchType.RegexMatch ||
|
|
433
|
+
matchType === PromQLAst_1.PromQLMatchType.RegexNoMatch) {
|
|
434
|
+
try {
|
|
435
|
+
(0, PromQLRegex_1.compilePromQLRegex)(valueToken.text);
|
|
436
|
+
}
|
|
437
|
+
catch (error) {
|
|
438
|
+
// Why a regular expression cannot run here, or null.
|
|
439
|
+
const problem = (0, PatternCache_1.describePatternProblem)(error);
|
|
440
|
+
throw new PromQLError_1.default(problem === null
|
|
441
|
+
? `"${valueToken.text}" is not a regular expression the label "${labelName}" can be matched with.`
|
|
442
|
+
: `The pattern "${valueToken.text}" for the label "${labelName}" ${problem}`, undefined, { start: valueToken.start, end: valueToken.end });
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
if (labelName === PromQLAst_1.PROMQL_METRIC_NAME_LABEL && name !== undefined) {
|
|
446
|
+
throw new PromQLError_1.default(`The metric name is written twice: "${name}" and "${valueToken.text}". Keep one.`, undefined, { start, end: valueToken.end });
|
|
447
|
+
}
|
|
448
|
+
matchers.push({
|
|
449
|
+
name: labelName,
|
|
450
|
+
type: matchType,
|
|
451
|
+
value: valueToken.text,
|
|
452
|
+
});
|
|
453
|
+
this.finishMatcherListItem();
|
|
454
|
+
}
|
|
455
|
+
end = this.next().end;
|
|
456
|
+
}
|
|
457
|
+
if (metricName !== undefined) {
|
|
458
|
+
matchers.unshift({
|
|
459
|
+
name: PromQLAst_1.PROMQL_METRIC_NAME_LABEL,
|
|
460
|
+
type: PromQLAst_1.PromQLMatchType.Equal,
|
|
461
|
+
value: metricName,
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
const position = { start, end };
|
|
465
|
+
// `{job=""}` would select every series of every metric.
|
|
466
|
+
const selectsSomething = matchers.some((matcher) => {
|
|
467
|
+
return !(0, exports.matchesEmptyValue)(matcher);
|
|
468
|
+
});
|
|
469
|
+
if (!selectsSomething) {
|
|
470
|
+
throw new PromQLError_1.default('A selector needs a metric name or a label matcher that does not match an empty value, such as {job="api"}.', undefined, position);
|
|
471
|
+
}
|
|
472
|
+
return {
|
|
473
|
+
kind: PromQLAst_1.PromQLNodeKind.VectorSelector,
|
|
474
|
+
name: metricName,
|
|
475
|
+
matchers,
|
|
476
|
+
offsetMs: 0,
|
|
477
|
+
at: undefined,
|
|
478
|
+
position,
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
// After a matcher: a comma (a trailing one is fine) or the closing brace.
|
|
482
|
+
finishMatcherListItem() {
|
|
483
|
+
const token = this.peek();
|
|
484
|
+
if (token.type === PromQLLexer_1.PromQLTokenType.Comma) {
|
|
485
|
+
this.next();
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
if (token.type !== PromQLLexer_1.PromQLTokenType.RightBrace) {
|
|
489
|
+
throw this.unexpected(token, '"," or "}"');
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
parseLabelList() {
|
|
493
|
+
this.expect(PromQLLexer_1.PromQLTokenType.LeftParen, '"("');
|
|
494
|
+
const labels = [];
|
|
495
|
+
while (this.peek().type !== PromQLLexer_1.PromQLTokenType.RightParen) {
|
|
496
|
+
const token = this.next();
|
|
497
|
+
if (token.type !== PromQLLexer_1.PromQLTokenType.Identifier &&
|
|
498
|
+
token.type !== PromQLLexer_1.PromQLTokenType.String) {
|
|
499
|
+
throw this.unexpected(token, "a label name");
|
|
500
|
+
}
|
|
501
|
+
labels.push(token.text);
|
|
502
|
+
if (this.peek().type === PromQLLexer_1.PromQLTokenType.Comma) {
|
|
503
|
+
this.next();
|
|
504
|
+
continue;
|
|
505
|
+
}
|
|
506
|
+
if (this.peek().type !== PromQLLexer_1.PromQLTokenType.RightParen) {
|
|
507
|
+
throw this.unexpected(this.peek(), '"," or ")"');
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
this.next();
|
|
511
|
+
return labels;
|
|
512
|
+
}
|
|
513
|
+
parseArguments() {
|
|
514
|
+
this.expect(PromQLLexer_1.PromQLTokenType.LeftParen, '"("');
|
|
515
|
+
const args = [];
|
|
516
|
+
while (this.peek().type !== PromQLLexer_1.PromQLTokenType.RightParen) {
|
|
517
|
+
args.push(this.parseExpression(0));
|
|
518
|
+
if (this.peek().type === PromQLLexer_1.PromQLTokenType.Comma) {
|
|
519
|
+
this.next();
|
|
520
|
+
continue;
|
|
521
|
+
}
|
|
522
|
+
if (this.peek().type !== PromQLLexer_1.PromQLTokenType.RightParen) {
|
|
523
|
+
throw this.unexpected(this.peek(), '"," or ")"');
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
return { args, end: this.next().end };
|
|
527
|
+
}
|
|
528
|
+
parseAggregate(operator, operatorToken) {
|
|
529
|
+
let grouping = [];
|
|
530
|
+
let without = false;
|
|
531
|
+
let groupingWritten = false;
|
|
532
|
+
const readGrouping = () => {
|
|
533
|
+
const token = this.peek();
|
|
534
|
+
if (this.isKeyword(token, "by") || this.isKeyword(token, "without")) {
|
|
535
|
+
this.next();
|
|
536
|
+
without = token.text.toLowerCase() === "without";
|
|
537
|
+
grouping = this.parseLabelList();
|
|
538
|
+
groupingWritten = true;
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
readGrouping();
|
|
542
|
+
const { args, end } = this.parseArguments();
|
|
543
|
+
let finalEnd = end;
|
|
544
|
+
if (!groupingWritten) {
|
|
545
|
+
readGrouping();
|
|
546
|
+
if (groupingWritten) {
|
|
547
|
+
finalEnd = this.tokens[this.index - 1].end;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
const position = {
|
|
551
|
+
start: operatorToken.start,
|
|
552
|
+
end: finalEnd,
|
|
553
|
+
};
|
|
554
|
+
const expectedArguments = AGGREGATES_WITH_PARAMETER.has(operator)
|
|
555
|
+
? 2
|
|
556
|
+
: 1;
|
|
557
|
+
if (args.length !== expectedArguments) {
|
|
558
|
+
throw new PromQLError_1.default(`${operator}(...) takes ${expectedArguments} argument${expectedArguments === 1 ? "" : "s"}, but the query gives it ${args.length}.`, undefined, position);
|
|
559
|
+
}
|
|
560
|
+
const expression = args[expectedArguments - 1];
|
|
561
|
+
const parameter = expectedArguments === 2 ? args[0] : undefined;
|
|
562
|
+
this.expectType(expression, PromQLAst_1.PromQLValueType.InstantVector, `the expression in ${operator}(...)`);
|
|
563
|
+
if (parameter) {
|
|
564
|
+
this.expectType(parameter, operator === PromQLAst_1.PromQLAggregateOperator.CountValues
|
|
565
|
+
? PromQLAst_1.PromQLValueType.String
|
|
566
|
+
: PromQLAst_1.PromQLValueType.Scalar, `the first argument of ${operator}(...)`);
|
|
567
|
+
}
|
|
568
|
+
return {
|
|
569
|
+
kind: PromQLAst_1.PromQLNodeKind.Aggregate,
|
|
570
|
+
operator,
|
|
571
|
+
expression,
|
|
572
|
+
parameter,
|
|
573
|
+
grouping,
|
|
574
|
+
without,
|
|
575
|
+
position,
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
parseCall(nameToken) {
|
|
579
|
+
const functionName = nameToken.text;
|
|
580
|
+
if (PromQLFunctions_1.PROMQL_NATIVE_HISTOGRAM_FUNCTIONS.has(functionName)) {
|
|
581
|
+
throw new PromQLError_1.default(`${functionName}() reads Prometheus native histograms, which OneUptime does not store. Read the histogram's _count, _sum and _bucket series instead, for example with histogram_quantile().`, undefined, { start: nameToken.start, end: nameToken.end });
|
|
582
|
+
}
|
|
583
|
+
const signature = (0, PromQLFunctions_1.getPromQLFunction)(functionName);
|
|
584
|
+
if (!signature) {
|
|
585
|
+
throw new PromQLError_1.default(`Unknown function "${functionName}". The docs list every function OneUptime evaluates.`, undefined, { start: nameToken.start, end: nameToken.end });
|
|
586
|
+
}
|
|
587
|
+
const { args, end } = this.parseArguments();
|
|
588
|
+
const position = { start: nameToken.start, end };
|
|
589
|
+
const fixed = signature.argTypes.length;
|
|
590
|
+
if (signature.variadic === 0 && args.length !== fixed) {
|
|
591
|
+
throw new PromQLError_1.default(`${functionName}() takes ${fixed} argument${fixed === 1 ? "" : "s"}, but the query gives it ${args.length}.`, undefined, position);
|
|
592
|
+
}
|
|
593
|
+
if (signature.variadic !== 0) {
|
|
594
|
+
const minimum = fixed - 1;
|
|
595
|
+
if (args.length < minimum) {
|
|
596
|
+
throw new PromQLError_1.default(`${functionName}() takes at least ${minimum} argument${minimum === 1 ? "" : "s"}, but the query gives it ${args.length}.`, undefined, position);
|
|
597
|
+
}
|
|
598
|
+
const maximum = minimum + signature.variadic;
|
|
599
|
+
if (signature.variadic > 0 && args.length > maximum) {
|
|
600
|
+
throw new PromQLError_1.default(`${functionName}() takes at most ${maximum} argument${maximum === 1 ? "" : "s"}, but the query gives it ${args.length}.`, undefined, position);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
args.forEach((arg, argIndex) => {
|
|
604
|
+
const typeIndex = Math.min(argIndex, fixed - 1);
|
|
605
|
+
this.expectType(arg, signature.argTypes[typeIndex], `argument ${argIndex + 1} of ${functionName}()`);
|
|
606
|
+
});
|
|
607
|
+
return {
|
|
608
|
+
kind: PromQLAst_1.PromQLNodeKind.Call,
|
|
609
|
+
functionName,
|
|
610
|
+
args,
|
|
611
|
+
position,
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
expectType(expression, expected, context) {
|
|
615
|
+
const actual = (0, exports.getPromQLValueType)(expression);
|
|
616
|
+
if (actual === expected) {
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
let hint = "";
|
|
620
|
+
if (expected === PromQLAst_1.PromQLValueType.RangeVector &&
|
|
621
|
+
expression.kind === PromQLAst_1.PromQLNodeKind.VectorSelector) {
|
|
622
|
+
hint = " Add a range, such as [5m], after the selector.";
|
|
623
|
+
}
|
|
624
|
+
throw new PromQLError_1.default(`${capitalize(context)} must be ${PromQLAst_1.PROMQL_VALUE_TYPE_WITH_ARTICLE[expected]}, but it is ${PromQLAst_1.PROMQL_VALUE_TYPE_WITH_ARTICLE[actual]}.${hint}`, undefined, expression.position);
|
|
625
|
+
}
|
|
626
|
+
parsePostfix(primary) {
|
|
627
|
+
let expression = primary;
|
|
628
|
+
for (;;) {
|
|
629
|
+
const token = this.peek();
|
|
630
|
+
if (token.type === PromQLLexer_1.PromQLTokenType.LeftBracket) {
|
|
631
|
+
expression = this.parseRangeOrSubquery(expression);
|
|
632
|
+
continue;
|
|
633
|
+
}
|
|
634
|
+
if (this.isKeyword(token, "offset")) {
|
|
635
|
+
expression = this.parseOffset(expression);
|
|
636
|
+
continue;
|
|
637
|
+
}
|
|
638
|
+
if (token.type === PromQLLexer_1.PromQLTokenType.At) {
|
|
639
|
+
expression = this.parseAt(expression);
|
|
640
|
+
continue;
|
|
641
|
+
}
|
|
642
|
+
return expression;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
parseDurationValue(what, allowZero) {
|
|
646
|
+
const token = this.next();
|
|
647
|
+
let milliseconds = undefined;
|
|
648
|
+
if (token.type === PromQLLexer_1.PromQLTokenType.Duration) {
|
|
649
|
+
milliseconds = (0, PromQLDuration_1.parsePromQLDuration)(token.text);
|
|
650
|
+
}
|
|
651
|
+
else if (token.type === PromQLLexer_1.PromQLTokenType.Number) {
|
|
652
|
+
// A bare number is seconds, as Prometheus 3 reads it.
|
|
653
|
+
const seconds = parseNumberText(token.text);
|
|
654
|
+
milliseconds = Number.isFinite(seconds)
|
|
655
|
+
? Math.round(seconds * 1000)
|
|
656
|
+
: undefined;
|
|
657
|
+
}
|
|
658
|
+
else {
|
|
659
|
+
throw this.unexpected(token, `a duration for the ${what}, such as 5m`);
|
|
660
|
+
}
|
|
661
|
+
if (milliseconds === undefined) {
|
|
662
|
+
throw new PromQLError_1.default(`"${token.text}" is not a duration. Write the ${what} as 30s, 5m, 1h or 1h30m.`, undefined, { start: token.start, end: token.end });
|
|
663
|
+
}
|
|
664
|
+
if (!allowZero && milliseconds <= 0) {
|
|
665
|
+
throw new PromQLError_1.default(`The ${what} must be longer than zero.`, undefined, { start: token.start, end: token.end });
|
|
666
|
+
}
|
|
667
|
+
return milliseconds;
|
|
668
|
+
}
|
|
669
|
+
parseRangeOrSubquery(expression) {
|
|
670
|
+
const open = this.next();
|
|
671
|
+
const rangeMs = this.parseDurationValue("range", false);
|
|
672
|
+
if (this.peek().type === PromQLLexer_1.PromQLTokenType.Colon) {
|
|
673
|
+
this.next();
|
|
674
|
+
let stepMs = undefined;
|
|
675
|
+
if (this.peek().type !== PromQLLexer_1.PromQLTokenType.RightBracket) {
|
|
676
|
+
stepMs = this.parseDurationValue("subquery step", false);
|
|
677
|
+
}
|
|
678
|
+
const close = this.expect(PromQLLexer_1.PromQLTokenType.RightBracket, '"]"');
|
|
679
|
+
const subquery = {
|
|
680
|
+
kind: PromQLAst_1.PromQLNodeKind.Subquery,
|
|
681
|
+
expression,
|
|
682
|
+
rangeMs,
|
|
683
|
+
stepMs,
|
|
684
|
+
offsetMs: 0,
|
|
685
|
+
at: undefined,
|
|
686
|
+
position: { start: expression.position.start, end: close.end },
|
|
687
|
+
};
|
|
688
|
+
const innerType = (0, exports.getPromQLValueType)(expression);
|
|
689
|
+
if (innerType !== PromQLAst_1.PromQLValueType.InstantVector) {
|
|
690
|
+
throw new PromQLError_1.default(`A subquery ([range:step]) needs an instant vector before it, not ${PromQLAst_1.PROMQL_VALUE_TYPE_WITH_ARTICLE[innerType]}.`, undefined, subquery.position);
|
|
691
|
+
}
|
|
692
|
+
return subquery;
|
|
693
|
+
}
|
|
694
|
+
const close = this.expect(PromQLLexer_1.PromQLTokenType.RightBracket, '"]"');
|
|
695
|
+
const position = {
|
|
696
|
+
start: expression.position.start,
|
|
697
|
+
end: close.end,
|
|
698
|
+
};
|
|
699
|
+
if (expression.kind !== PromQLAst_1.PromQLNodeKind.VectorSelector) {
|
|
700
|
+
throw new PromQLError_1.default(`A range such as [5m] only goes after a selector, such as http_requests_total[5m]. To range over an expression, write a subquery: (...)[5m:1m].`, undefined, { start: open.start, end: close.end });
|
|
701
|
+
}
|
|
702
|
+
if (this.offsetWritten.has(expression)) {
|
|
703
|
+
throw new PromQLError_1.default("Write the offset after the range: up[5m] offset 1h, not up offset 1h[5m].", undefined, position);
|
|
704
|
+
}
|
|
705
|
+
if (this.atWritten.has(expression)) {
|
|
706
|
+
throw new PromQLError_1.default("Write @ after the range: up[5m] @ 1700000000, not up @ 1700000000[5m].", undefined, position);
|
|
707
|
+
}
|
|
708
|
+
const matrix = {
|
|
709
|
+
kind: PromQLAst_1.PromQLNodeKind.MatrixSelector,
|
|
710
|
+
vectorSelector: expression,
|
|
711
|
+
rangeMs,
|
|
712
|
+
position,
|
|
713
|
+
};
|
|
714
|
+
return matrix;
|
|
715
|
+
}
|
|
716
|
+
/*
|
|
717
|
+
* The node an offset or `@` written after `expression` belongs to, or
|
|
718
|
+
* undefined when nothing there can take one.
|
|
719
|
+
*/
|
|
720
|
+
modifierTarget(expression) {
|
|
721
|
+
if (expression.kind === PromQLAst_1.PromQLNodeKind.VectorSelector) {
|
|
722
|
+
return expression;
|
|
723
|
+
}
|
|
724
|
+
if (expression.kind === PromQLAst_1.PromQLNodeKind.MatrixSelector) {
|
|
725
|
+
return expression.vectorSelector;
|
|
726
|
+
}
|
|
727
|
+
if (expression.kind === PromQLAst_1.PromQLNodeKind.Subquery) {
|
|
728
|
+
return expression;
|
|
729
|
+
}
|
|
730
|
+
return undefined;
|
|
731
|
+
}
|
|
732
|
+
parseOffset(expression) {
|
|
733
|
+
const keyword = this.next();
|
|
734
|
+
let sign = 1;
|
|
735
|
+
if (this.peek().type === PromQLLexer_1.PromQLTokenType.Sub) {
|
|
736
|
+
this.next();
|
|
737
|
+
sign = -1;
|
|
738
|
+
}
|
|
739
|
+
else if (this.peek().type === PromQLLexer_1.PromQLTokenType.Add) {
|
|
740
|
+
this.next();
|
|
741
|
+
}
|
|
742
|
+
const offsetMs = sign * this.parseDurationValue("offset", true);
|
|
743
|
+
const target = this.modifierTarget(expression);
|
|
744
|
+
if (!target) {
|
|
745
|
+
throw new PromQLError_1.default("An offset only goes after a selector, a range or a subquery, such as up offset 1h or rate(up[5m] offset 1h).", undefined, { start: keyword.start, end: keyword.end });
|
|
746
|
+
}
|
|
747
|
+
if (this.offsetWritten.has(target)) {
|
|
748
|
+
throw new PromQLError_1.default("The offset is written twice. Keep one.", undefined, { start: keyword.start, end: keyword.end });
|
|
749
|
+
}
|
|
750
|
+
target.offsetMs = offsetMs;
|
|
751
|
+
this.offsetWritten.add(target);
|
|
752
|
+
expression.position = {
|
|
753
|
+
start: expression.position.start,
|
|
754
|
+
end: this.tokens[this.index - 1].end,
|
|
755
|
+
};
|
|
756
|
+
return expression;
|
|
757
|
+
}
|
|
758
|
+
parseAt(expression) {
|
|
759
|
+
const atToken = this.next();
|
|
760
|
+
let at;
|
|
761
|
+
const token = this.peek();
|
|
762
|
+
if ((this.isKeyword(token, "start") || this.isKeyword(token, "end")) &&
|
|
763
|
+
this.peek(1).type === PromQLLexer_1.PromQLTokenType.LeftParen) {
|
|
764
|
+
this.next();
|
|
765
|
+
this.next();
|
|
766
|
+
this.expect(PromQLLexer_1.PromQLTokenType.RightParen, '")"');
|
|
767
|
+
at = { kind: token.text.toLowerCase() === "start" ? "start" : "end" };
|
|
768
|
+
}
|
|
769
|
+
else {
|
|
770
|
+
let sign = 1;
|
|
771
|
+
if (this.peek().type === PromQLLexer_1.PromQLTokenType.Sub) {
|
|
772
|
+
this.next();
|
|
773
|
+
sign = -1;
|
|
774
|
+
}
|
|
775
|
+
else if (this.peek().type === PromQLLexer_1.PromQLTokenType.Add) {
|
|
776
|
+
this.next();
|
|
777
|
+
}
|
|
778
|
+
const numberToken = this.next();
|
|
779
|
+
if (numberToken.type !== PromQLLexer_1.PromQLTokenType.Number) {
|
|
780
|
+
throw this.unexpected(numberToken, "a Unix timestamp in seconds, start() or end() after @");
|
|
781
|
+
}
|
|
782
|
+
const seconds = sign * parseNumberText(numberToken.text);
|
|
783
|
+
if (!Number.isFinite(seconds)) {
|
|
784
|
+
throw new PromQLError_1.default("The time after @ must be a Unix timestamp in seconds, such as 1700000000.", undefined, { start: numberToken.start, end: numberToken.end });
|
|
785
|
+
}
|
|
786
|
+
at = { kind: "timestamp", timestampMs: Math.round(seconds * 1000) };
|
|
787
|
+
}
|
|
788
|
+
const target = this.modifierTarget(expression);
|
|
789
|
+
if (!target) {
|
|
790
|
+
throw new PromQLError_1.default("@ only goes after a selector, a range or a subquery, such as up @ 1700000000.", undefined, { start: atToken.start, end: atToken.end });
|
|
791
|
+
}
|
|
792
|
+
if (this.atWritten.has(target)) {
|
|
793
|
+
throw new PromQLError_1.default("@ is written twice. Keep one.", undefined, {
|
|
794
|
+
start: atToken.start,
|
|
795
|
+
end: atToken.end,
|
|
796
|
+
});
|
|
797
|
+
}
|
|
798
|
+
target.at = at;
|
|
799
|
+
this.atWritten.add(target);
|
|
800
|
+
expression.position = {
|
|
801
|
+
start: expression.position.start,
|
|
802
|
+
end: this.tokens[this.index - 1].end,
|
|
803
|
+
};
|
|
804
|
+
return expression;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
const capitalize = (text) => {
|
|
808
|
+
return text.length === 0 ? text : text[0].toUpperCase() + text.slice(1);
|
|
809
|
+
};
|
|
810
|
+
// Whether a matcher accepts a series that does not have its label at all.
|
|
811
|
+
const matchesEmptyValue = (matcher) => {
|
|
812
|
+
switch (matcher.type) {
|
|
813
|
+
case PromQLAst_1.PromQLMatchType.Equal:
|
|
814
|
+
return matcher.value === "";
|
|
815
|
+
case PromQLAst_1.PromQLMatchType.NotEqual:
|
|
816
|
+
return matcher.value !== "";
|
|
817
|
+
case PromQLAst_1.PromQLMatchType.RegexMatch:
|
|
818
|
+
return (0, PromQLRegex_1.compilePromQLRegex)(matcher.value).regex.test("");
|
|
819
|
+
case PromQLAst_1.PromQLMatchType.RegexNoMatch:
|
|
820
|
+
return !(0, PromQLRegex_1.compilePromQLRegex)(matcher.value).regex.test("");
|
|
821
|
+
}
|
|
822
|
+
};
|
|
823
|
+
exports.matchesEmptyValue = matchesEmptyValue;
|
|
824
|
+
/*
|
|
825
|
+
* The checked syntax tree of a PromQL query. Throws a PromQLError, with the
|
|
826
|
+
* position of the mistake, for a query Prometheus would refuse.
|
|
827
|
+
*/
|
|
828
|
+
const parsePromQL = (query) => {
|
|
829
|
+
return new PromQLParser(query).parse();
|
|
830
|
+
};
|
|
831
|
+
exports.parsePromQL = parsePromQL;
|