@oneuptime/common 14.0.110 → 14.2.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/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.d.mts +1 -0
- package/Models/DatabaseModels/Alert.d.ts +1 -0
- package/Models/DatabaseModels/Alert.js +52 -2
- package/Models/DatabaseModels/AutoRemediationSuggestion.d.mts +2 -0
- package/Models/DatabaseModels/AutoRemediationSuggestion.d.ts +2 -0
- package/Models/DatabaseModels/AutoRemediationSuggestion.js +62 -0
- package/Models/DatabaseModels/DataStore.js +9 -0
- package/Models/DatabaseModels/EmailLog.js +2 -2
- package/Models/DatabaseModels/Form.js +3 -3
- package/Models/DatabaseModels/FormSubmission.js +4 -4
- package/Models/DatabaseModels/GlobalConfig.js +46 -45
- package/Models/DatabaseModels/Incident.d.mts +1 -0
- package/Models/DatabaseModels/Incident.d.ts +1 -0
- package/Models/DatabaseModels/Incident.js +53 -2
- package/Models/DatabaseModels/IncidentPostmortemActionItem.d.mts +31 -0
- package/Models/DatabaseModels/IncidentPostmortemActionItem.d.ts +31 -0
- package/Models/DatabaseModels/IncidentPostmortemActionItem.js +591 -0
- package/Models/DatabaseModels/IncidentPostmortemActionItem.mjs +3 -0
- package/Models/DatabaseModels/IncidentSlaRule.js +2 -2
- package/Models/DatabaseModels/Index.js +6 -0
- package/Models/DatabaseModels/InventoryItem.js +11 -0
- package/Models/DatabaseModels/Monitor.js +51 -17
- 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.js +23 -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/OnCallDutyPolicyExecutionLog.js +19 -5
- package/Models/DatabaseModels/OnCallDutyPolicyFeed.d.mts +1 -0
- package/Models/DatabaseModels/OnCallDutyPolicyFeed.d.ts +1 -0
- package/Models/DatabaseModels/OnCallDutyPolicyFeed.js +2 -0
- package/Models/DatabaseModels/OnCallDutyPolicyUserOverride.js +35 -7
- package/Models/DatabaseModels/OpenStackCloudCheck.js +8 -1
- package/Models/DatabaseModels/Project.d.mts +1 -0
- package/Models/DatabaseModels/Project.d.ts +1 -0
- package/Models/DatabaseModels/Project.js +46 -3
- package/Models/DatabaseModels/ProjectCallSMSConfig.js +3 -1
- package/Models/DatabaseModels/ProjectSmtpConfig.js +2 -0
- package/Models/DatabaseModels/PublicNoteApprovalRequest.js +3 -3
- package/Models/DatabaseModels/PublicNoteApprovalStep.js +1 -1
- package/Models/DatabaseModels/RunbookExecution.js +2 -2
- package/Models/DatabaseModels/RunbookRule.js +6 -6
- package/Models/DatabaseModels/ScheduledMaintenance.js +3 -3
- package/Models/DatabaseModels/ScheduledMaintenanceCalendarFeed.js +1 -1
- package/Models/DatabaseModels/ScheduledMaintenanceLabelRule.js +1 -1
- package/Models/DatabaseModels/ScheduledMaintenanceMeasurement.js +7 -7
- package/Models/DatabaseModels/ScheduledMaintenanceMeasurementValue.js +1 -1
- 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 +3 -3
- package/Models/DatabaseModels/ScheduledMaintenanceReminderRule.js +4 -4
- package/Models/DatabaseModels/ScheduledMaintenanceStateTimeline.js +3 -3
- package/Models/DatabaseModels/ScheduledMaintenanceTemplate.js +5 -5
- package/Models/DatabaseModels/TeamMember.js +10 -1
- package/Models/DatabaseModels/TelemetryIngestionKey.js +1 -1
- 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 +28 -2
- package/Types/AI/AIActionWords.d.ts +28 -2
- package/Types/AI/AIActionWords.js +235 -3
- package/Types/AI/AIActionWords.mjs +8 -0
- package/Types/AI/AIChatTypes.d.mts +3 -1
- package/Types/AI/AIChatTypes.d.ts +3 -1
- package/Types/AI/AIReadTableWords.d.mts +192 -0
- package/Types/AI/AIReadTableWords.d.ts +192 -0
- package/Types/AI/AIReadTableWords.js +368 -0
- package/Types/AI/AIReadTableWords.mjs +18 -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 +48 -0
- package/Types/AI/AiRunRefusal.d.ts +48 -0
- package/Types/AI/AiRunRefusal.js +208 -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/AI/ResourceAiAccessPermissions.js +7 -18
- 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/AuditLog/AuditLogActionLabel.js +19 -9
- package/Types/BaseDatabase/AggregateBy.d.mts +16 -0
- package/Types/BaseDatabase/AggregateBy.d.ts +16 -0
- package/Types/BaseDatabase/AggregationIntervalUtil.d.mts +32 -1
- package/Types/BaseDatabase/AggregationIntervalUtil.d.ts +32 -1
- package/Types/BaseDatabase/AggregationIntervalUtil.js +199 -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/CloudResourceHealth.d.mts +30 -1
- package/Types/Cloud/CloudResourceHealth.d.ts +30 -1
- package/Types/Cloud/CloudResourceHealth.js +405 -13
- package/Types/Cloud/CloudResourceHealth.mjs +28 -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/DataCheckRefusals.d.mts +32 -0
- package/Types/DataObservability/DataCheckRefusals.d.ts +32 -0
- package/Types/DataObservability/DataCheckRefusals.js +77 -0
- package/Types/DataObservability/DataCheckRefusals.mjs +8 -0
- package/Types/Database/AccessControl/PermissionScopeNarrowing.js +4 -0
- package/Types/Date.d.mts +8 -1
- package/Types/Date.d.ts +8 -1
- package/Types/Date.js +61 -7
- package/Types/Date.mjs +1 -0
- package/Types/DateLanguage.d.mts +2 -0
- package/Types/DateLanguage.d.ts +2 -0
- package/Types/DateLanguage.js +8 -5
- package/Types/Email/EmailTemplateType.d.mts +1 -0
- package/Types/Email/EmailTemplateType.d.ts +1 -0
- package/Types/Email/EmailTemplateType.js +2 -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/EgressGuardException.js +1 -1
- package/Types/Exception/ErrorMessageRule.d.mts +1 -0
- package/Types/Exception/ErrorMessageRule.d.ts +1 -0
- package/Types/Exception/ErrorMessageRule.js +67 -13
- package/Types/Exception/ErrorMessageRule.mjs +1 -0
- package/Types/Exception/ExceptionMessages.d.mts +2 -0
- package/Types/Exception/ExceptionMessages.d.ts +2 -0
- package/Types/Exception/ExceptionMessages.js +2 -0
- package/Types/Form/FormTargetCatalog.js +2 -2
- package/Types/Form/FormTargetType.js +2 -2
- package/Types/Incident/PostmortemActionItemStatus.d.mts +17 -0
- package/Types/Incident/PostmortemActionItemStatus.d.ts +17 -0
- package/Types/Incident/PostmortemActionItemStatus.js +74 -0
- package/Types/Incident/PostmortemActionItemStatus.mjs +5 -0
- package/Types/JSONFunctions.js +10 -3
- package/Types/Link.d.mts +1 -0
- package/Types/Link.d.ts +1 -0
- package/Types/ListData.d.mts +2 -0
- package/Types/ListData.d.ts +2 -0
- package/Types/ListData.js +4 -0
- package/Types/MeaningKeys.d.mts +4 -0
- package/Types/MeaningKeys.d.ts +4 -0
- package/Types/MeaningKeys.js +74 -0
- package/Types/MeaningKeys.mjs +5 -0
- 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/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 -0
- package/Types/Monitor/WhoIsTold.d.ts +3 -0
- package/Types/Monitor/WhoIsTold.js +63 -13
- package/Types/NoBreakSpaces.d.mts +16 -0
- package/Types/NoBreakSpaces.d.ts +16 -0
- package/Types/NoBreakSpaces.js +419 -0
- package/Types/NoBreakSpaces.mjs +9 -0
- package/Types/NotificationRule/PagingLadder.d.mts +12 -0
- package/Types/NotificationRule/PagingLadder.d.ts +12 -0
- package/Types/NotificationRule/PagingLadder.js +159 -11
- package/Types/NotificationRule/PagingLadder.mjs +3 -0
- 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/OnCallPagePassOn.d.mts +1 -0
- package/Types/OnCallDutyPolicy/OnCallPagePassOn.d.ts +1 -0
- package/Types/OnCallDutyPolicy/OnCallPageRecordGone.d.mts +3 -0
- package/Types/OnCallDutyPolicy/OnCallPageRecordGone.d.ts +3 -0
- package/Types/OnCallDutyPolicy/OnCallPageRecordGone.js +42 -0
- package/Types/OnCallDutyPolicy/OnCallPageRecordGone.mjs +4 -0
- package/Types/OnCallDutyPolicy/OnCallPageWords.d.mts +6 -2
- package/Types/OnCallDutyPolicy/OnCallPageWords.d.ts +6 -2
- package/Types/OnCallDutyPolicy/OnCallPageWords.js +21 -20
- package/Types/OnCallDutyPolicy/OnCallPersonPage.d.mts +4 -0
- package/Types/OnCallDutyPolicy/OnCallPersonPage.d.ts +4 -0
- package/Types/OnCallDutyPolicy/OnCallPersonPage.js +125 -1
- package/Types/OnCallDutyPolicy/OnCallPersonPage.mjs +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 +2 -0
- package/Types/OnCallDutyPolicy/OnCallTestPage.d.ts +2 -0
- package/Types/OnCallDutyPolicy/OnCallTestPage.js +12 -0
- package/Types/OnCallDutyPolicy/OnCallTestPage.mjs +1 -0
- 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/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/OpenStack/OpenStackCapacity.js +12 -5
- package/Types/Permission.d.mts +4 -0
- package/Types/Permission.d.ts +4 -0
- package/Types/Permission.js +66 -10
- 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/ProductUsage.js +2 -1
- package/Types/Product/ProjectProductsAnswer.js +2 -1
- 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/ResourceAiAgent/AiResourceType.d.mts +1 -0
- package/Types/ResourceAiAgent/AiResourceType.d.ts +1 -0
- package/Types/ResourceAiAgent/AiResourceType.js +12 -0
- package/Types/Rules/RuleRun.js +2 -2
- package/Types/Rum/ProductAnalyticsEventReads.js +10 -1
- package/Types/Rum/ProductAnalyticsEvents.js +13 -1
- package/Types/Rum/SessionReplayCustomEvents.d.mts +4 -1
- package/Types/Rum/SessionReplayCustomEvents.d.ts +4 -1
- package/Types/Rum/SessionReplayCustomEvents.js +12 -0
- package/Types/Rum/SessionReplayCustomEvents.mjs +1 -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/SetupHealth/SetupHealth.d.mts +1 -0
- package/Types/SetupHealth/SetupHealth.d.ts +1 -0
- package/Types/SetupHealth/SetupHealth.js +13 -5
- package/Types/StateTimeline/RowsKeptOnDelete.js +1 -1
- package/Types/StatusPage/DefaultStatusNames.d.mts +11 -3
- package/Types/StatusPage/DefaultStatusNames.d.ts +11 -3
- package/Types/StatusPage/DefaultStatusNames.js +74 -28
- package/Types/StatusPage/DefaultStatusNames.mjs +9 -2
- 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/StatusPage/StateChangeNoteMessage.d.mts +3 -2
- package/Types/StatusPage/StateChangeNoteMessage.d.ts +3 -2
- package/Types/StatusPage/StateChangeNoteMessage.js +16 -13
- 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 +48 -7
- package/Types/Telemetry/TelemetryIngestionKeyType.js +7 -6
- 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 +470 -63
- package/Types/Translator.mjs +1 -0
- package/Types/UserSession/SessionLength.d.mts +33 -0
- package/Types/UserSession/SessionLength.d.ts +33 -0
- package/Types/UserSession/SessionLength.js +134 -5
- package/Types/UserSession/SessionLength.mjs +5 -0
- package/Types/Workflow/RunRecord.js +1 -1
- package/Types/Workflow/Templates.js +2 -2
- package/Types/Workflow/WorkflowStatus.js +21 -10
- 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 +26 -1
- package/Types/Workspace/NotificationRules/NotificationRuleCondition.d.ts +26 -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/InvestigationReport.js +2 -2
- package/Utils/API.d.mts +0 -11
- package/Utils/API.d.ts +0 -11
- package/Utils/API.js +0 -432
- package/Utils/AiRemediation/Resource/ResourceCommandPolicy.js +2 -2
- package/Utils/AiRemediation/VerifiedFixRunbook.d.mts +39 -0
- package/Utils/AiRemediation/VerifiedFixRunbook.d.ts +39 -0
- package/Utils/AiRemediation/VerifiedFixRunbook.js +231 -0
- package/Utils/AiRemediation/VerifiedFixRunbook.mjs +10 -0
- package/Utils/Dashboard/DashboardWidgetSorts.js +11 -2
- package/Utils/Dashboard/MonitorListWidgetFormat.d.mts +2 -1
- package/Utils/Dashboard/MonitorListWidgetFormat.d.ts +2 -1
- package/Utils/Dashboard/MonitorListWidgetFormat.js +5 -3
- 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/DefaultRecordNames.d.mts +6 -0
- package/Utils/DefaultRecordNames.d.ts +6 -0
- package/Utils/DefaultRecordNames.js +122 -0
- package/Utils/DefaultRecordNames.mjs +6 -0
- package/Utils/DeveloperDocs/ExampleBuilder.js +1 -1
- package/Utils/DeveloperDocs/ResourceProfiles.js +2 -2
- package/Utils/Grok/Grok.js +7 -4
- 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/Incident/PostmortemActionItemCodeTask.d.mts +20 -0
- package/Utils/Incident/PostmortemActionItemCodeTask.d.ts +20 -0
- package/Utils/Incident/PostmortemActionItemCodeTask.js +107 -0
- package/Utils/Incident/PostmortemActionItemCodeTask.mjs +10 -0
- package/Utils/Incident/PostmortemActionItemMarkdown.d.mts +39 -0
- package/Utils/Incident/PostmortemActionItemMarkdown.d.ts +39 -0
- package/Utils/Incident/PostmortemActionItemMarkdown.js +118 -0
- package/Utils/Incident/PostmortemActionItemMarkdown.mjs +12 -0
- package/Utils/Incident/PostmortemNoteActionItems.d.mts +29 -0
- package/Utils/Incident/PostmortemNoteActionItems.d.ts +29 -0
- package/Utils/Incident/PostmortemNoteActionItems.js +544 -0
- package/Utils/Incident/PostmortemNoteActionItems.mjs +7 -0
- package/Utils/LinearRegExp/LinearRegExp.js +5 -1
- package/Utils/LookupTable.d.mts +3 -0
- package/Utils/LookupTable.d.ts +3 -0
- package/Utils/LookupTable.js +61 -0
- package/Utils/LookupTable.mjs +3 -0
- package/Utils/Markdown/LinkReferenceDefinitions.d.mts +2 -0
- package/Utils/Markdown/LinkReferenceDefinitions.d.ts +2 -0
- package/Utils/Markdown/LinkReferenceDefinitions.js +101 -1
- package/Utils/Markdown/LinkReferenceDefinitions.mjs +2 -0
- package/Utils/Markdown/OverLongText.js +296 -2
- package/Utils/Markdown/SlowMarkdown.d.mts +1 -0
- package/Utils/Markdown/SlowMarkdown.d.ts +1 -0
- package/Utils/Markdown/SlowMarkdown.js +354 -4
- package/Utils/Markdown/SlowMarkdown.mjs +1 -0
- package/Utils/Metrics/MetricFormulaEvaluator.js +10 -4
- package/Utils/Metrics/MetricSeriesFingerprint.js +13 -4
- package/Utils/Metrics/MetricSeriesScope.d.mts +5 -0
- package/Utils/Metrics/MetricSeriesScope.d.ts +5 -0
- package/Utils/Metrics/MetricSeriesScope.js +5 -1
- 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/Monitor/EndpointAttachmentUtil.d.mts +8 -0
- package/Utils/Monitor/EndpointAttachmentUtil.d.ts +8 -0
- package/Utils/Monitor/EndpointAttachmentUtil.js +91 -21
- package/Utils/Monitor/EndpointAttachmentUtil.mjs +4 -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 +5 -0
- package/Utils/Monitor/MonitorRootCauseWording.d.ts +5 -0
- package/Utils/Monitor/MonitorRootCauseWording.js +148 -5
- 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/ProbeAgreementRule.d.mts +10 -0
- package/Utils/Monitor/ProbeAgreementRule.d.ts +10 -0
- package/Utils/Monitor/ProbeAgreementRule.js +58 -0
- package/Utils/Monitor/ProbeAgreementRule.mjs +3 -0
- package/Utils/Monitor/ProbeFailureReading.d.mts +18 -0
- package/Utils/Monitor/ProbeFailureReading.d.ts +18 -0
- package/Utils/Monitor/ProbeFailureReading.js +166 -0
- package/Utils/Monitor/ProbeFailureReading.mjs +8 -0
- package/Utils/Monitor/RequestFailureDescriptions.d.mts +61 -0
- package/Utils/Monitor/RequestFailureDescriptions.d.ts +61 -0
- package/Utils/Monitor/RequestFailureDescriptions.js +252 -0
- package/Utils/Monitor/RequestFailureDescriptions.mjs +6 -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/Project/NextNumber.js +1 -1
- 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 +974 -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 +829 -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/PromQLLabelOrder.d.mts +8 -0
- package/Utils/PromQL/PromQLLabelOrder.d.ts +8 -0
- package/Utils/PromQL/PromQLLabelOrder.js +212 -0
- package/Utils/PromQL/PromQLLabelOrder.mjs +6 -0
- package/Utils/PromQL/PromQLLabels.d.mts +11 -0
- package/Utils/PromQL/PromQLLabels.d.ts +11 -0
- package/Utils/PromQL/PromQLLabels.js +219 -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 +205 -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 +836 -0
- package/Utils/PromQL/PromQLParser.mjs +4 -0
- package/Utils/PromQL/PromQLRegex.d.mts +20 -0
- package/Utils/PromQL/PromQLRegex.d.ts +20 -0
- package/Utils/PromQL/PromQLRegex.js +1014 -0
- package/Utils/PromQL/PromQLRegex.mjs +5 -0
- package/Utils/PromQL/PrometheusResponse.d.mts +25 -0
- package/Utils/PromQL/PrometheusResponse.d.ts +25 -0
- package/Utils/PromQL/PrometheusResponse.js +92 -0
- package/Utils/PromQL/PrometheusResponse.mjs +3 -0
- package/Utils/PromQL/RE2CharacterClass.d.mts +24 -0
- package/Utils/PromQL/RE2CharacterClass.d.ts +24 -0
- package/Utils/PromQL/RE2CharacterClass.js +532 -0
- package/Utils/PromQL/RE2CharacterClass.mjs +16 -0
- package/Utils/RequestFailedDetailsUtil.d.mts +15 -0
- package/Utils/RequestFailedDetailsUtil.d.ts +15 -0
- package/Utils/RequestFailedDetailsUtil.js +452 -0
- package/Utils/RequestFailedDetailsUtil.mjs +2 -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 +5 -1
- package/Utils/Rum/UrlScrubber.d.ts +5 -1
- package/Utils/Rum/UrlScrubber.js +153 -7
- package/Utils/Rum/UserFlow.d.mts +1 -1
- package/Utils/Rum/UserFlow.d.ts +1 -1
- package/Utils/Rum/UserFlow.js +202 -29
- 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/Schema/TypeSchemas.js +6 -0
- package/Utils/SecurityCase/SecurityOverviewMetrics.d.mts +11 -1
- package/Utils/SecurityCase/SecurityOverviewMetrics.d.ts +11 -1
- package/Utils/SecurityCase/SecurityOverviewMetrics.js +99 -17
- package/Utils/SecurityCase/SecurityOverviewMetrics.mjs +3 -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/Sms/OnCallPageSms.d.mts +2 -0
- package/Utils/Sms/OnCallPageSms.d.ts +2 -0
- package/Utils/Sms/OnCallPageSms.js +3 -1
- package/Utils/StateListType.d.mts +11 -0
- package/Utils/StateListType.d.ts +11 -0
- package/Utils/StateListType.js +21 -0
- package/Utils/StateListType.mjs +2 -0
- package/Utils/StateOrder.d.mts +8 -11
- package/Utils/StateOrder.d.ts +8 -11
- package/Utils/StateOrder.js +50 -88
- package/Utils/StateOrder.mjs +2 -0
- package/Utils/StateTimeline/StateTimelineRowDelete.js +1 -1
- package/Utils/Suggestions/ActionItemCodeTaskSuggestion.d.mts +9 -0
- package/Utils/Suggestions/ActionItemCodeTaskSuggestion.d.ts +9 -0
- package/Utils/Suggestions/ActionItemCodeTaskSuggestion.js +25 -0
- package/Utils/Suggestions/ActionItemCodeTaskSuggestion.mjs +2 -0
- package/Utils/Suggestions/VerifiedFixRunbookSuggestion.d.mts +5 -0
- package/Utils/Suggestions/VerifiedFixRunbookSuggestion.d.ts +5 -0
- package/Utils/Suggestions/VerifiedFixRunbookSuggestion.js +39 -0
- package/Utils/Suggestions/VerifiedFixRunbookSuggestion.mjs +2 -0
- package/Utils/Syslog/SyslogMessageParser.js +16 -6
- package/Utils/Telemetry/HeartbeatAvailability.d.mts +4 -0
- package/Utils/Telemetry/HeartbeatAvailability.d.ts +4 -0
- package/Utils/Telemetry/HeartbeatAvailability.js +113 -26
- package/Utils/Uptime/DayUptimeGraphUtil.js +2 -2
- package/Utils/ValueFormatter.d.mts +1 -0
- package/Utils/ValueFormatter.d.ts +1 -0
- package/Utils/ValueFormatter.js +258 -18
- package/package.json +1 -1
|
@@ -0,0 +1,1014 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readNamedCapture = exports.compilePromQLRegex = exports.describePromQLPatternProblem = exports.PromQLPatternError = void 0;
|
|
4
|
+
const LinearRegExp_1 = require("../LinearRegExp/LinearRegExp");
|
|
5
|
+
const PatternCache_1 = require("../LinearRegExp/PatternCache");
|
|
6
|
+
const PatternProblem_1 = require("../LinearRegExp/PatternProblem");
|
|
7
|
+
const RE2CharacterClass_1 = require("./RE2CharacterClass");
|
|
8
|
+
/*
|
|
9
|
+
* PromQL's regular expressions, read in JavaScript.
|
|
10
|
+
*
|
|
11
|
+
* Prometheus matches with Go's RE2 and compiles a pattern as
|
|
12
|
+
* `^(?s:<pattern>)$`: a label matcher in NewFastRegexMatcher
|
|
13
|
+
* (model/labels/regexp.go, which reads the pattern with RE2's Perl flags
|
|
14
|
+
* and DotNL first), label_replace() in evalLabelReplace
|
|
15
|
+
* (promql/functions.go). So a pattern
|
|
16
|
+
* - is anchored at both ends of the whole value: `=~"api"` matches "api"
|
|
17
|
+
* and not "api-2";
|
|
18
|
+
* - reads `.` as any character, "\n" too: `=~"a.b"` matches "a\nb";
|
|
19
|
+
* - keeps its own flag groups inside: (?i), (?m), (?s) or (?U) applies from
|
|
20
|
+
* where it stands to the end of the group that holds it, as RE2 reads it
|
|
21
|
+
* (parsePerlFlags and parseRightParen in Go's regexp/syntax/parse.go).
|
|
22
|
+
* So `=~"(?m)api"` still means the whole value, and `=~"api(?i)SERVER"`
|
|
23
|
+
* matches "apiServer" and not "APIserver".
|
|
24
|
+
*
|
|
25
|
+
* A pattern is read here as RE2 reads it, in one pass, and written as
|
|
26
|
+
* JavaScript's RegExp without the u flag reads it:
|
|
27
|
+
* - A flag group. JavaScript has no (?i) that runs to the end of a group,
|
|
28
|
+
* only a modifier group around a part, (?i: ... ), and no U at all. (?i),
|
|
29
|
+
* (?m) and (?s) become modifier groups around the rest of their group,
|
|
30
|
+
* its alternatives kept apart; (?U) swaps each repeat's greed (x* reads
|
|
31
|
+
* as x*?, and x*? as x*).
|
|
32
|
+
* - `.` without s matches anything but "\n" in RE2, and in JavaScript
|
|
33
|
+
* anything but "\n", "\r", U+2028 and U+2029: it is written [^\n].
|
|
34
|
+
* - ^ and $ with m match next to a "\n" in RE2, and in JavaScript next to
|
|
35
|
+
* "\r", U+2028 and U+2029 too: a look-around leaves those three out.
|
|
36
|
+
* \A and \z are the whole value's start and end, under (?m) too.
|
|
37
|
+
* - A bracket is read into the set of code points RE2 reads it as
|
|
38
|
+
* (parseClass, parse.go) - a "]" first is a character, [:digit:] and
|
|
39
|
+
* [:^digit:] are POSIX classes, \d \s \w and their negations are RE2's
|
|
40
|
+
* (\s is [\t\n\f\r ], without JavaScript's \v and other spaces), a
|
|
41
|
+
* range's ends are single characters - and the set is written as a
|
|
42
|
+
* class (RE2CharacterClass.ts). So are \d \s \w outside one.
|
|
43
|
+
* - (?i) joins the cases Go's case folding joins: JavaScript's i flag
|
|
44
|
+
* joins most of them, and the rest - the Kelvin sign with k, the long s
|
|
45
|
+
* with s, letters beyond U+FFFF - are written out.
|
|
46
|
+
* - An escape is read as RE2 reads it (parseEscape): \Q...\E is its text,
|
|
47
|
+
* \x{41} and \x41 the code point, \0 to \777 octal, \a the bell. The
|
|
48
|
+
* escapes RE2 does not have are refused, as Prometheus refuses them.
|
|
49
|
+
* - A repeat repeats what RE2's repeats: what comes before a flag group
|
|
50
|
+
* (a(?i)* is a*), an assertion (^*), or a repeat with a flag group
|
|
51
|
+
* between ((?:a*)*). A repeat of a repeat with nothing between, a*+, is
|
|
52
|
+
* refused, as are counts over 1000 - counting a repeat inside another
|
|
53
|
+
* as their product (repeatIsValid) - and a {n} with a leading zero is
|
|
54
|
+
* a "{", as RE2 reads it.
|
|
55
|
+
* - Named groups, (?P<name> ... ) and (?<name> ... ), become groups with
|
|
56
|
+
* no name, their names kept beside them (groupNames): RE2 takes a name
|
|
57
|
+
* such as 1a, and two groups of the same name, which JavaScript does
|
|
58
|
+
* not.
|
|
59
|
+
*
|
|
60
|
+
* Refused, as Prometheus refuses them, each said in a sentence that names
|
|
61
|
+
* what is not read (PromQLPatternError): a POSIX class RE2 does not have
|
|
62
|
+
* ([[:nosuch:]]; names are lowercase), \C, look-aheads and look-behinds, a
|
|
63
|
+
* repeat over 1000, an escape RE2 does not have (\e, A), a group name
|
|
64
|
+
* that is not letters, digits and _. A back-reference (\1, \k<name>) is
|
|
65
|
+
* refused as the linear-time matcher refuses one.
|
|
66
|
+
*
|
|
67
|
+
* Where the reading still differs from Prometheus, decided:
|
|
68
|
+
* - \pL, \p{Greek} and other Unicode classes are refused: the linear-time
|
|
69
|
+
* matcher reads code units, not Unicode properties. Before, \pL was
|
|
70
|
+
* read as the letters "pL".
|
|
71
|
+
* - A character beyond U+FFFF, such as an emoji, is two characters to "."
|
|
72
|
+
* and to a negated class, where RE2 reads one: ^.$ does not match "😀"
|
|
73
|
+
* here. A bracket or escape that names such characters, [\x{1F600}-
|
|
74
|
+
* \x{1F64F}], matches each as one.
|
|
75
|
+
* - What label_replace()'s groups capture inside a repeat whose iteration
|
|
76
|
+
* can match nothing: (?:|x)+(\w*) on "xx" captures "xx" in Prometheus,
|
|
77
|
+
* whose automaton leaves the repeat for the empty alternative, and ""
|
|
78
|
+
* here, where the matcher repeats as JavaScript does (an iteration that
|
|
79
|
+
* matches nothing ends the repeat). Whether such a pattern matches is the
|
|
80
|
+
* same; only what a group captures in it differs. Kept: the matcher's
|
|
81
|
+
* captures are JavaScript's throughout.
|
|
82
|
+
* - label_replace() with parentheses that do not balance, a)|(b, or a \Q
|
|
83
|
+
* with no \E. Prometheus pastes the pattern into "^(?s:" ... ")$", so
|
|
84
|
+
* there a)|(b reads as ^(?s:a)|(b)$, and \Qa.b swallows the ")$" and is
|
|
85
|
+
* refused. Its label matchers read the pattern on its own: they refuse
|
|
86
|
+
* a)|(b and read \Qa.b as "a.b". Read here as those matchers read it,
|
|
87
|
+
* in label_replace() too.
|
|
88
|
+
*
|
|
89
|
+
* A matcher's pattern is written by a project's people, so it runs on the
|
|
90
|
+
* linear-time matcher (Utils/LinearRegExp), as every such pattern does: in
|
|
91
|
+
* time in line with the value it reads, as RE2 runs it. It is compiled once
|
|
92
|
+
* and kept (PatternCache), by the pattern, so a query that asks it about
|
|
93
|
+
* every series compiles it once.
|
|
94
|
+
*/
|
|
95
|
+
/*
|
|
96
|
+
* A pattern Prometheus refuses, or that is not read here, with the reason
|
|
97
|
+
* in words: a SyntaxError, as any pattern that is not a regular expression.
|
|
98
|
+
*/
|
|
99
|
+
class PromQLPatternError extends SyntaxError {
|
|
100
|
+
constructor(pattern, problem) {
|
|
101
|
+
super(`The pattern "${pattern}" ${problem}`);
|
|
102
|
+
this.problem = problem;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.PromQLPatternError = PromQLPatternError;
|
|
106
|
+
/*
|
|
107
|
+
* Why a pattern cannot be matched, in words for the person who wrote it:
|
|
108
|
+
* the end of a sentence that starts "The pattern ...". Null for an error
|
|
109
|
+
* that says nothing more than that the pattern is not one.
|
|
110
|
+
*/
|
|
111
|
+
const describePromQLPatternProblem = (error) => {
|
|
112
|
+
if (error instanceof PromQLPatternError) {
|
|
113
|
+
return error.problem;
|
|
114
|
+
}
|
|
115
|
+
return (0, PatternCache_1.describePatternProblem)(error);
|
|
116
|
+
};
|
|
117
|
+
exports.describePromQLPatternProblem = describePromQLPatternProblem;
|
|
118
|
+
// The most times RE2 repeats a part (repeat and repeatIsValid, parse.go).
|
|
119
|
+
const MAX_REPEAT = 1000;
|
|
120
|
+
// ^ and $ with m, matching next to a "\n" only, as RE2's do.
|
|
121
|
+
const LINE_START = "^(?<![\\r\\u2028\\u2029])";
|
|
122
|
+
const LINE_END = "$(?![\\r\\u2028\\u2029])";
|
|
123
|
+
// . without s: anything but "\n", as RE2's.
|
|
124
|
+
const ANY_BUT_NEWLINE = "[^\\n]";
|
|
125
|
+
// The flags a flag group names, by their letters.
|
|
126
|
+
const FLAG_LETTERS = new Map([
|
|
127
|
+
["i", "ignoreCase"],
|
|
128
|
+
["m", "multiline"],
|
|
129
|
+
["s", "dotAll"],
|
|
130
|
+
["U", "ungreedy"],
|
|
131
|
+
]);
|
|
132
|
+
// The flags a JavaScript modifier group sets: i, m and s, not U.
|
|
133
|
+
const MODIFIER_LETTERS = [
|
|
134
|
+
["i", "ignoreCase"],
|
|
135
|
+
["m", "multiline"],
|
|
136
|
+
["s", "dotAll"],
|
|
137
|
+
];
|
|
138
|
+
/*
|
|
139
|
+
* The flags a pattern starts with in Prometheus: ^ and $ at the ends of the
|
|
140
|
+
* whole value, and . matching "\n" (the `(?s:` around the pattern).
|
|
141
|
+
*/
|
|
142
|
+
const PROMETHEUS_FLAGS = {
|
|
143
|
+
ignoreCase: false,
|
|
144
|
+
multiline: false,
|
|
145
|
+
dotAll: true,
|
|
146
|
+
ungreedy: false,
|
|
147
|
+
};
|
|
148
|
+
const openGroup = (flags, start) => {
|
|
149
|
+
return {
|
|
150
|
+
flags: flags,
|
|
151
|
+
restFlags: flags,
|
|
152
|
+
restModifierGroups: 0,
|
|
153
|
+
alternativeModifierGroupOpen: false,
|
|
154
|
+
alternativeStarted: false,
|
|
155
|
+
lastAtom: null,
|
|
156
|
+
start: start,
|
|
157
|
+
repeats: 1,
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
/*
|
|
161
|
+
* The JavaScript modifier group that turns `from`'s i, m and s into `to`'s,
|
|
162
|
+
* such as "(?i-s:"; "" when they are the same.
|
|
163
|
+
*/
|
|
164
|
+
const modifierGroup = (from, to) => {
|
|
165
|
+
let added = "";
|
|
166
|
+
let removed = "";
|
|
167
|
+
for (const [letter, flag] of MODIFIER_LETTERS) {
|
|
168
|
+
if (to[flag] && !from[flag]) {
|
|
169
|
+
added += letter;
|
|
170
|
+
}
|
|
171
|
+
else if (!to[flag] && from[flag]) {
|
|
172
|
+
removed += letter;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (added.length === 0 && removed.length === 0) {
|
|
176
|
+
return "";
|
|
177
|
+
}
|
|
178
|
+
return `(?${added}${removed.length > 0 ? `-${removed}` : ""}:`;
|
|
179
|
+
};
|
|
180
|
+
const sameFlags = (one, other) => {
|
|
181
|
+
return (one.ignoreCase === other.ignoreCase &&
|
|
182
|
+
one.multiline === other.multiline &&
|
|
183
|
+
one.dotAll === other.dotAll &&
|
|
184
|
+
one.ungreedy === other.ungreedy);
|
|
185
|
+
};
|
|
186
|
+
const isDecimalDigit = (codeUnit) => {
|
|
187
|
+
return codeUnit >= 0x30 && codeUnit <= 0x39;
|
|
188
|
+
};
|
|
189
|
+
const isOctalDigit = (codeUnit) => {
|
|
190
|
+
return codeUnit >= 0x30 && codeUnit <= 0x37;
|
|
191
|
+
};
|
|
192
|
+
// isalnum in parse.go: ASCII letters and digits only.
|
|
193
|
+
const isAsciiAlphanumeric = (codePoint) => {
|
|
194
|
+
return (isDecimalDigit(codePoint) ||
|
|
195
|
+
(codePoint >= 0x41 && codePoint <= 0x5a) ||
|
|
196
|
+
(codePoint >= 0x61 && codePoint <= 0x7a));
|
|
197
|
+
};
|
|
198
|
+
const hexValue = (codeUnit) => {
|
|
199
|
+
if (isDecimalDigit(codeUnit)) {
|
|
200
|
+
return codeUnit - 0x30;
|
|
201
|
+
}
|
|
202
|
+
if (codeUnit >= 0x41 && codeUnit <= 0x46) {
|
|
203
|
+
return codeUnit - 0x41 + 10;
|
|
204
|
+
}
|
|
205
|
+
if (codeUnit >= 0x61 && codeUnit <= 0x66) {
|
|
206
|
+
return codeUnit - 0x61 + 10;
|
|
207
|
+
}
|
|
208
|
+
return -1;
|
|
209
|
+
};
|
|
210
|
+
// A group's name RE2 takes: ASCII letters, digits and _ (isValidCaptureName).
|
|
211
|
+
const isCaptureName = (name) => {
|
|
212
|
+
if (name.length === 0) {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
for (let index = 0; index < name.length; index++) {
|
|
216
|
+
const codeUnit = name.charCodeAt(index);
|
|
217
|
+
if (codeUnit !== 0x5f && !isAsciiAlphanumeric(codeUnit)) {
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return true;
|
|
222
|
+
};
|
|
223
|
+
// RE2's single-letter escapes for a control character (parseEscape).
|
|
224
|
+
const CONTROL_ESCAPES = new Map([
|
|
225
|
+
["a", 0x07],
|
|
226
|
+
["f", 0x0c],
|
|
227
|
+
["n", 0x0a],
|
|
228
|
+
["r", 0x0d],
|
|
229
|
+
["t", 0x09],
|
|
230
|
+
["v", 0x0b],
|
|
231
|
+
]);
|
|
232
|
+
// What a refusal says Prometheus does too.
|
|
233
|
+
const PROMETHEUS_TOO = "which Prometheus does not read either";
|
|
234
|
+
// The POSIX classes RE2 has, for a sentence: "[:alnum:], ... and [:xdigit:]".
|
|
235
|
+
const POSIX_CLASS_LIST = (() => {
|
|
236
|
+
const names = RE2CharacterClass_1.POSIX_CLASS_NAMES.map((name) => {
|
|
237
|
+
return `[:${name}:]`;
|
|
238
|
+
});
|
|
239
|
+
return `${names.slice(0, -1).join(", ")} and ${names[names.length - 1]}`;
|
|
240
|
+
})();
|
|
241
|
+
/*
|
|
242
|
+
* A pattern read as RE2 reads it, written as JavaScript's RegExp reads it,
|
|
243
|
+
* with the names of its groups.
|
|
244
|
+
*/
|
|
245
|
+
class RE2Translation {
|
|
246
|
+
constructor(pattern) {
|
|
247
|
+
this.position = 0;
|
|
248
|
+
this.output = [];
|
|
249
|
+
// The groups open where the reading is, the whole pattern first.
|
|
250
|
+
this.groups = [openGroup(PROMETHEUS_FLAGS, 0)];
|
|
251
|
+
// Each capturing group's name, group 1 first; null for a group with none.
|
|
252
|
+
this.groupNames = [];
|
|
253
|
+
/*
|
|
254
|
+
* Whether the last thing read is a repeat. RE2 refuses a repeat right
|
|
255
|
+
* after one, x** or x*??, as a nested repetition (repeat, parse.go), and
|
|
256
|
+
* repeats the repeat when anything comes between, even a flag group:
|
|
257
|
+
* x*(?i)* is (?:x*)*.
|
|
258
|
+
*/
|
|
259
|
+
this.afterRepeat = false;
|
|
260
|
+
/*
|
|
261
|
+
* Where the first ":]" after the last "[:" read is, -1 for none: found
|
|
262
|
+
* once for the "[:"s before it, as the reading only moves on, so a
|
|
263
|
+
* pattern of many "[:" is read in time in line with its length.
|
|
264
|
+
*/
|
|
265
|
+
this.posixClassEnd = -2;
|
|
266
|
+
this.pattern = pattern;
|
|
267
|
+
}
|
|
268
|
+
/*
|
|
269
|
+
* The pattern in JavaScript, to be read inside `(?s:` ... `)`, and the
|
|
270
|
+
* names of its groups. Throws a PromQLPatternError, or PatternProblemError
|
|
271
|
+
* for a back-reference, for what RE2 refuses, and a SyntaxError for what
|
|
272
|
+
* is no pattern at all: a group or bracket left open, a ")" that closes
|
|
273
|
+
* nothing, a "\" at the end.
|
|
274
|
+
*/
|
|
275
|
+
translate() {
|
|
276
|
+
while (this.position < this.pattern.length) {
|
|
277
|
+
this.readNext();
|
|
278
|
+
}
|
|
279
|
+
if (this.groups.length > 1) {
|
|
280
|
+
throw this.syntaxError("Unterminated group");
|
|
281
|
+
}
|
|
282
|
+
this.closeModifierGroups(this.group());
|
|
283
|
+
return { source: this.output.join(""), groupNames: this.groupNames };
|
|
284
|
+
}
|
|
285
|
+
group() {
|
|
286
|
+
return this.groups[this.groups.length - 1];
|
|
287
|
+
}
|
|
288
|
+
syntaxError(message) {
|
|
289
|
+
return new SyntaxError(`Invalid regular expression: /${this.pattern}/: ${message}`);
|
|
290
|
+
}
|
|
291
|
+
refuse(problem) {
|
|
292
|
+
return new PromQLPatternError(this.pattern, problem);
|
|
293
|
+
}
|
|
294
|
+
// Writes text the current alternative matches or asserts.
|
|
295
|
+
write(text) {
|
|
296
|
+
this.output.push(text);
|
|
297
|
+
this.group().alternativeStarted = true;
|
|
298
|
+
this.afterRepeat = false;
|
|
299
|
+
}
|
|
300
|
+
// Writes something a repeat after it repeats.
|
|
301
|
+
writeAtom(text, needsGroup, repeats = 1) {
|
|
302
|
+
const group = this.group();
|
|
303
|
+
const start = this.output.length;
|
|
304
|
+
this.write(text);
|
|
305
|
+
this.endAtom(group);
|
|
306
|
+
group.lastAtom = {
|
|
307
|
+
start: start,
|
|
308
|
+
end: this.output.length,
|
|
309
|
+
needsGroup: needsGroup,
|
|
310
|
+
repeats: repeats,
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
/*
|
|
314
|
+
* The alternative's last part is no longer last: no repeat can change it
|
|
315
|
+
* now, so the group counts it as it is.
|
|
316
|
+
*/
|
|
317
|
+
endAtom(group) {
|
|
318
|
+
if (group.lastAtom !== null) {
|
|
319
|
+
group.repeats = Math.max(group.repeats, group.lastAtom.repeats);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
writeSet(set) {
|
|
323
|
+
const written = (0, RE2CharacterClass_1.writeSet)(set);
|
|
324
|
+
this.writeAtom(written.source, written.needsGroup);
|
|
325
|
+
}
|
|
326
|
+
/*
|
|
327
|
+
* A code point matched as written, or under (?i) as Go folds it: the
|
|
328
|
+
* Kelvin sign and k alike.
|
|
329
|
+
*/
|
|
330
|
+
writeLiteral(codePoint) {
|
|
331
|
+
if (this.group().flags.ignoreCase && (0, RE2CharacterClass_1.needsWrittenCaseFold)(codePoint)) {
|
|
332
|
+
this.writeSet((0, RE2CharacterClass_1.caseFoldedLetter)(codePoint));
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
const written = (0, RE2CharacterClass_1.writeCodePoint)(codePoint);
|
|
336
|
+
this.writeAtom(written.source, written.needsGroup);
|
|
337
|
+
}
|
|
338
|
+
// The code point at `index`: a surrogate pair is one, as RE2 reads UTF-8.
|
|
339
|
+
codePointAt(index) {
|
|
340
|
+
return this.pattern.codePointAt(index);
|
|
341
|
+
}
|
|
342
|
+
static lengthOf(codePoint) {
|
|
343
|
+
return codePoint > 0xffff ? 2 : 1;
|
|
344
|
+
}
|
|
345
|
+
readNext() {
|
|
346
|
+
const character = this.pattern[this.position];
|
|
347
|
+
const flags = this.group().flags;
|
|
348
|
+
switch (character) {
|
|
349
|
+
case "\\":
|
|
350
|
+
this.readEscape();
|
|
351
|
+
return;
|
|
352
|
+
case "[":
|
|
353
|
+
this.readBracket();
|
|
354
|
+
return;
|
|
355
|
+
case "(":
|
|
356
|
+
this.readGroupStart();
|
|
357
|
+
return;
|
|
358
|
+
case ")":
|
|
359
|
+
this.readGroupEnd();
|
|
360
|
+
return;
|
|
361
|
+
case "|":
|
|
362
|
+
this.readBar();
|
|
363
|
+
return;
|
|
364
|
+
case "*":
|
|
365
|
+
case "+":
|
|
366
|
+
case "?":
|
|
367
|
+
this.position++;
|
|
368
|
+
this.readRepeat({
|
|
369
|
+
text: character,
|
|
370
|
+
min: character === "+" ? 1 : 0,
|
|
371
|
+
max: character === "?" ? 1 : -1,
|
|
372
|
+
counted: false,
|
|
373
|
+
});
|
|
374
|
+
return;
|
|
375
|
+
case "{": {
|
|
376
|
+
const repeat = this.bracedRepeat();
|
|
377
|
+
if (repeat !== null) {
|
|
378
|
+
this.position += repeat.text.length;
|
|
379
|
+
this.readRepeat(repeat);
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
// Not a repeat to RE2: a "{", {01} and {,5} included.
|
|
383
|
+
this.writeLiteral(0x7b);
|
|
384
|
+
this.position++;
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
case ".":
|
|
388
|
+
this.writeAtom(flags.dotAll ? "." : ANY_BUT_NEWLINE, false);
|
|
389
|
+
this.position++;
|
|
390
|
+
return;
|
|
391
|
+
case "^":
|
|
392
|
+
this.writeAtom(flags.multiline ? LINE_START : "^", true);
|
|
393
|
+
this.position++;
|
|
394
|
+
return;
|
|
395
|
+
case "$":
|
|
396
|
+
this.writeAtom(flags.multiline ? LINE_END : "$", true);
|
|
397
|
+
this.position++;
|
|
398
|
+
return;
|
|
399
|
+
default: {
|
|
400
|
+
const codePoint = this.codePointAt(this.position);
|
|
401
|
+
this.writeLiteral(codePoint);
|
|
402
|
+
this.position += RE2Translation.lengthOf(codePoint);
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
// An escape outside a bracket (the "\\" case of parse, parse.go).
|
|
408
|
+
readEscape() {
|
|
409
|
+
if (this.position + 1 >= this.pattern.length) {
|
|
410
|
+
throw this.syntaxError("\\ at end of pattern");
|
|
411
|
+
}
|
|
412
|
+
const flags = this.group().flags;
|
|
413
|
+
const letter = this.pattern[this.position + 1];
|
|
414
|
+
switch (letter) {
|
|
415
|
+
case "A":
|
|
416
|
+
// The value's start, under (?m) too.
|
|
417
|
+
this.writeAtom(flags.multiline ? "(?-m:^)" : "^", true);
|
|
418
|
+
this.position += 2;
|
|
419
|
+
return;
|
|
420
|
+
case "z":
|
|
421
|
+
this.writeAtom(flags.multiline ? "(?-m:$)" : "$", true);
|
|
422
|
+
this.position += 2;
|
|
423
|
+
return;
|
|
424
|
+
case "b":
|
|
425
|
+
case "B":
|
|
426
|
+
// A word boundary: ASCII word characters, in RE2 and JavaScript alike.
|
|
427
|
+
this.writeAtom(`\\${letter}`, true);
|
|
428
|
+
this.position += 2;
|
|
429
|
+
return;
|
|
430
|
+
case "C":
|
|
431
|
+
throw this.refuse(`uses \\C, one byte of a character, ${PROMETHEUS_TOO}. Use . to match any one character.`);
|
|
432
|
+
case "Q":
|
|
433
|
+
this.readQuoted();
|
|
434
|
+
return;
|
|
435
|
+
case "p":
|
|
436
|
+
case "P":
|
|
437
|
+
throw this.unicodeClassRefusal();
|
|
438
|
+
default:
|
|
439
|
+
break;
|
|
440
|
+
}
|
|
441
|
+
const perl = (0, RE2CharacterClass_1.perlClass)(letter.toLowerCase());
|
|
442
|
+
if (perl !== undefined) {
|
|
443
|
+
this.writeSet((0, RE2CharacterClass_1.namedSet)({
|
|
444
|
+
set: perl,
|
|
445
|
+
negated: letter !== letter.toLowerCase(),
|
|
446
|
+
ignoreCase: flags.ignoreCase,
|
|
447
|
+
}));
|
|
448
|
+
this.position += 2;
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
this.writeLiteral(this.readEscapedCodePoint(false));
|
|
452
|
+
}
|
|
453
|
+
/*
|
|
454
|
+
* \Q ... \E: every character between is itself, to the end of the pattern
|
|
455
|
+
* when no \E follows.
|
|
456
|
+
*/
|
|
457
|
+
readQuoted() {
|
|
458
|
+
const start = this.position + 2;
|
|
459
|
+
const end = this.pattern.indexOf("\\E", start);
|
|
460
|
+
const stop = end === -1 ? this.pattern.length : end;
|
|
461
|
+
for (let index = start; index < stop;) {
|
|
462
|
+
const codePoint = this.codePointAt(index);
|
|
463
|
+
this.writeLiteral(codePoint);
|
|
464
|
+
index += RE2Translation.lengthOf(codePoint);
|
|
465
|
+
}
|
|
466
|
+
this.position = end === -1 ? this.pattern.length : end + 2;
|
|
467
|
+
// \Q\E holds nothing, and still ends a repeat's run, as RE2 reads it.
|
|
468
|
+
this.afterRepeat = false;
|
|
469
|
+
}
|
|
470
|
+
unicodeClassRefusal() {
|
|
471
|
+
const letter = this.pattern[this.position + 1];
|
|
472
|
+
const braced = this.pattern[this.position + 2] === "{";
|
|
473
|
+
const close = this.pattern.indexOf("}", this.position);
|
|
474
|
+
const written = braced
|
|
475
|
+
? this.pattern.slice(this.position, close === -1 ? this.pattern.length : close + 1)
|
|
476
|
+
: this.pattern.slice(this.position, this.position + 3);
|
|
477
|
+
return this.refuse(`uses the Unicode class ${written.length > 2 ? written : `\\${letter}`}, which OneUptime cannot match yet, though Prometheus can. Write the characters it stands for in a bracket instead, such as [a-zA-Z].`);
|
|
478
|
+
}
|
|
479
|
+
/*
|
|
480
|
+
* The code point a one-character escape stands for, moving past it
|
|
481
|
+
* (parseEscape, parse.go): \ and any ASCII character but a letter or a
|
|
482
|
+
* digit is that character; \0 to \777 is octal; \x41 and \x{1F600} hex;
|
|
483
|
+
* \a \f \n \r \t \v control characters. Every other escape is refused, as
|
|
484
|
+
* RE2 refuses it.
|
|
485
|
+
*/
|
|
486
|
+
readEscapedCodePoint(inBracket) {
|
|
487
|
+
const escape = this.position;
|
|
488
|
+
if (escape + 1 >= this.pattern.length) {
|
|
489
|
+
throw this.syntaxError("\\ at end of pattern");
|
|
490
|
+
}
|
|
491
|
+
const codePoint = this.codePointAt(escape + 1);
|
|
492
|
+
const letter = String.fromCodePoint(codePoint);
|
|
493
|
+
if (codePoint < 0x80 && !isAsciiAlphanumeric(codePoint)) {
|
|
494
|
+
this.position = escape + 2;
|
|
495
|
+
return codePoint;
|
|
496
|
+
}
|
|
497
|
+
if (!inBracket &&
|
|
498
|
+
((codePoint >= 0x31 &&
|
|
499
|
+
codePoint <= 0x39 &&
|
|
500
|
+
!(codePoint <= 0x37 && isOctalDigit(this.pattern.charCodeAt(escape + 2)))) ||
|
|
501
|
+
letter === "k")) {
|
|
502
|
+
// \1 or \k<name>: "what group 1 matched", which RE2 has not.
|
|
503
|
+
throw new PatternProblem_1.PatternProblemError(PatternProblem_1.PatternProblemReason.BackReference, `The pattern refers back to a group (\\${letter}).`);
|
|
504
|
+
}
|
|
505
|
+
if (codePoint === 0x30 ||
|
|
506
|
+
(codePoint >= 0x31 &&
|
|
507
|
+
codePoint <= 0x37 &&
|
|
508
|
+
isOctalDigit(this.pattern.charCodeAt(escape + 2)))) {
|
|
509
|
+
// Up to three octal digits, the first one included.
|
|
510
|
+
let value = codePoint - 0x30;
|
|
511
|
+
let index = escape + 2;
|
|
512
|
+
while (index < escape + 4 &&
|
|
513
|
+
isOctalDigit(this.pattern.charCodeAt(index))) {
|
|
514
|
+
value = value * 8 + this.pattern.charCodeAt(index) - 0x30;
|
|
515
|
+
index++;
|
|
516
|
+
}
|
|
517
|
+
this.position = index;
|
|
518
|
+
return value;
|
|
519
|
+
}
|
|
520
|
+
if (letter === "x") {
|
|
521
|
+
return this.readHexEscape();
|
|
522
|
+
}
|
|
523
|
+
const control = CONTROL_ESCAPES.get(letter);
|
|
524
|
+
if (control !== undefined) {
|
|
525
|
+
this.position = escape + 2;
|
|
526
|
+
return control;
|
|
527
|
+
}
|
|
528
|
+
throw this.invalidEscape(this.pattern.slice(escape, escape + 1 + letter.length));
|
|
529
|
+
}
|
|
530
|
+
invalidEscape(written) {
|
|
531
|
+
return this.refuse(`uses ${written}, an escape ${PROMETHEUS_TOO}. Write the character itself, or its code as \\x{...}, such as \\x{41} for A.`);
|
|
532
|
+
}
|
|
533
|
+
// \x41 or \x{1F600}, the reading position on its "\".
|
|
534
|
+
readHexEscape() {
|
|
535
|
+
const escape = this.position;
|
|
536
|
+
if (this.pattern[escape + 2] === "{") {
|
|
537
|
+
let value = 0;
|
|
538
|
+
let index = escape + 3;
|
|
539
|
+
while (index < this.pattern.length && this.pattern[index] !== "}") {
|
|
540
|
+
const digit = hexValue(this.pattern.charCodeAt(index));
|
|
541
|
+
if (digit < 0) {
|
|
542
|
+
break;
|
|
543
|
+
}
|
|
544
|
+
value = value * 16 + digit;
|
|
545
|
+
if (value > RE2CharacterClass_1.MAX_CODE_POINT) {
|
|
546
|
+
break;
|
|
547
|
+
}
|
|
548
|
+
index++;
|
|
549
|
+
}
|
|
550
|
+
if (this.pattern[index] !== "}" ||
|
|
551
|
+
index === escape + 3 ||
|
|
552
|
+
value > RE2CharacterClass_1.MAX_CODE_POINT) {
|
|
553
|
+
const close = this.pattern.indexOf("}", escape);
|
|
554
|
+
throw this.invalidEscape(this.pattern.slice(escape, close === -1 ? this.pattern.length : close + 1));
|
|
555
|
+
}
|
|
556
|
+
this.position = index + 1;
|
|
557
|
+
return value;
|
|
558
|
+
}
|
|
559
|
+
const high = hexValue(this.pattern.charCodeAt(escape + 2));
|
|
560
|
+
const low = hexValue(this.pattern.charCodeAt(escape + 3));
|
|
561
|
+
if (high < 0 || low < 0) {
|
|
562
|
+
throw this.invalidEscape(this.pattern.slice(escape, escape + 4));
|
|
563
|
+
}
|
|
564
|
+
this.position = escape + 4;
|
|
565
|
+
return high * 16 + low;
|
|
566
|
+
}
|
|
567
|
+
/*
|
|
568
|
+
* A bracket, read to its "]" as RE2 reads it (parseClass, parse.go): a
|
|
569
|
+
* "]" first is a character; [:name:] and [:^name:] are POSIX classes,
|
|
570
|
+
* a name RE2 does not have refused; \d \s \w and their negations are
|
|
571
|
+
* RE2's; a range's ends are single characters; and under (?i) each part
|
|
572
|
+
* holds its other cases. Then turned inside out after a "^".
|
|
573
|
+
*/
|
|
574
|
+
readBracket() {
|
|
575
|
+
const ignoreCase = this.group().flags.ignoreCase;
|
|
576
|
+
let negated = false;
|
|
577
|
+
this.position++;
|
|
578
|
+
if (this.pattern[this.position] === "^") {
|
|
579
|
+
negated = true;
|
|
580
|
+
this.position++;
|
|
581
|
+
}
|
|
582
|
+
const pairs = [];
|
|
583
|
+
let first = true;
|
|
584
|
+
for (;;) {
|
|
585
|
+
if (this.position >= this.pattern.length) {
|
|
586
|
+
throw this.syntaxError("Unterminated character class");
|
|
587
|
+
}
|
|
588
|
+
const character = this.pattern[this.position];
|
|
589
|
+
if (character === "]" && !first) {
|
|
590
|
+
this.position++;
|
|
591
|
+
break;
|
|
592
|
+
}
|
|
593
|
+
first = false;
|
|
594
|
+
const named = this.readNamedClass(ignoreCase);
|
|
595
|
+
if (named !== null) {
|
|
596
|
+
pairs.push(...named);
|
|
597
|
+
continue;
|
|
598
|
+
}
|
|
599
|
+
const rangeStart = this.position;
|
|
600
|
+
const low = this.readBracketCharacter();
|
|
601
|
+
let high = low;
|
|
602
|
+
if (this.pattern[this.position] === "-" &&
|
|
603
|
+
this.position + 1 < this.pattern.length &&
|
|
604
|
+
this.pattern[this.position + 1] !== "]") {
|
|
605
|
+
this.position++;
|
|
606
|
+
this.refuseClassAsRangeEnd(rangeStart);
|
|
607
|
+
high = this.readBracketCharacter();
|
|
608
|
+
if (high < low) {
|
|
609
|
+
throw this.refuse(`holds the range ${this.pattern.slice(rangeStart, this.position)}, whose end comes before its start, ${PROMETHEUS_TOO}. Write the lower character first.`);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
pairs.push(...(ignoreCase ? (0, RE2CharacterClass_1.foldCase)([low, high]) : [low, high]));
|
|
613
|
+
}
|
|
614
|
+
const set = (0, RE2CharacterClass_1.toCodePointRanges)(pairs);
|
|
615
|
+
this.writeSet(negated ? (0, RE2CharacterClass_1.complementOf)(set) : set);
|
|
616
|
+
}
|
|
617
|
+
/*
|
|
618
|
+
* A range's end is one character (parseClassChar, parse.go): [a-\d] is
|
|
619
|
+
* refused, where JavaScript reads "a", "-" and a digit.
|
|
620
|
+
*/
|
|
621
|
+
refuseClassAsRangeEnd(rangeStart) {
|
|
622
|
+
var _a;
|
|
623
|
+
if (this.pattern[this.position] !== "\\") {
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
const letter = (_a = this.pattern[this.position + 1]) !== null && _a !== void 0 ? _a : "";
|
|
627
|
+
if ((0, RE2CharacterClass_1.perlClass)(letter.toLowerCase()) === undefined &&
|
|
628
|
+
letter !== "p" &&
|
|
629
|
+
letter !== "P") {
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
throw this.refuse(`ends the range ${this.pattern.slice(rangeStart, this.position + 2)} with a class, ${PROMETHEUS_TOO}: a range runs from one character to another. Write the class beside the range, as in [a-z\\d].`);
|
|
633
|
+
}
|
|
634
|
+
/*
|
|
635
|
+
* A POSIX class, a Perl class or a Unicode class at the reading position
|
|
636
|
+
* in a bracket, as its code points, moving past it; null when there is
|
|
637
|
+
* none.
|
|
638
|
+
*/
|
|
639
|
+
readNamedClass(ignoreCase) {
|
|
640
|
+
var _a;
|
|
641
|
+
const start = this.position;
|
|
642
|
+
if (this.pattern[start] === "[" &&
|
|
643
|
+
this.pattern[start + 1] === ":" &&
|
|
644
|
+
start + 2 < this.pattern.length) {
|
|
645
|
+
// RE2 reads to the first ":]", wherever it is (parseNamedClass).
|
|
646
|
+
if (this.posixClassEnd !== -1 && this.posixClassEnd < start + 2) {
|
|
647
|
+
this.posixClassEnd = this.pattern.indexOf(":]", start + 2);
|
|
648
|
+
}
|
|
649
|
+
const end = this.posixClassEnd;
|
|
650
|
+
if (end !== -1) {
|
|
651
|
+
const written = this.pattern.slice(start, end + 2);
|
|
652
|
+
const name = this.pattern.slice(start + 2, end);
|
|
653
|
+
const negated = name.startsWith("^");
|
|
654
|
+
const set = (0, RE2CharacterClass_1.posixClass)(negated ? name.slice(1) : name);
|
|
655
|
+
if (set === undefined) {
|
|
656
|
+
throw this.refuse(`names the character class ${written}, ${PROMETHEUS_TOO}. The classes are ${POSIX_CLASS_LIST}, written in lowercase, and [:^digit:] matches every character [:digit:] does not.`);
|
|
657
|
+
}
|
|
658
|
+
this.position = end + 2;
|
|
659
|
+
return (0, RE2CharacterClass_1.namedSet)({ set, negated, ignoreCase });
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
if (this.pattern[start] !== "\\") {
|
|
663
|
+
return null;
|
|
664
|
+
}
|
|
665
|
+
const letter = (_a = this.pattern[start + 1]) !== null && _a !== void 0 ? _a : "";
|
|
666
|
+
if (letter === "p" || letter === "P") {
|
|
667
|
+
throw this.unicodeClassRefusal();
|
|
668
|
+
}
|
|
669
|
+
const perl = (0, RE2CharacterClass_1.perlClass)(letter.toLowerCase());
|
|
670
|
+
if (perl === undefined) {
|
|
671
|
+
return null;
|
|
672
|
+
}
|
|
673
|
+
this.position = start + 2;
|
|
674
|
+
return (0, RE2CharacterClass_1.namedSet)({
|
|
675
|
+
set: perl,
|
|
676
|
+
negated: letter !== letter.toLowerCase(),
|
|
677
|
+
ignoreCase,
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
// One character of a bracket (parseClassChar): itself, or an escape.
|
|
681
|
+
readBracketCharacter() {
|
|
682
|
+
if (this.position >= this.pattern.length) {
|
|
683
|
+
throw this.syntaxError("Unterminated character class");
|
|
684
|
+
}
|
|
685
|
+
if (this.pattern[this.position] === "\\") {
|
|
686
|
+
return this.readEscapedCodePoint(true);
|
|
687
|
+
}
|
|
688
|
+
const codePoint = this.codePointAt(this.position);
|
|
689
|
+
this.position += RE2Translation.lengthOf(codePoint);
|
|
690
|
+
return codePoint;
|
|
691
|
+
}
|
|
692
|
+
/*
|
|
693
|
+
* The {n}, {n,} or {n,m} at the reading position, as RE2 reads one
|
|
694
|
+
* (parseRepeat, parse.go): digits with no leading zero; null when the
|
|
695
|
+
* "{" starts none, so it is a "{".
|
|
696
|
+
*/
|
|
697
|
+
bracedRepeat() {
|
|
698
|
+
const start = this.position;
|
|
699
|
+
const readNumber = (index) => {
|
|
700
|
+
let end = index;
|
|
701
|
+
while (isDecimalDigit(this.pattern.charCodeAt(end))) {
|
|
702
|
+
end++;
|
|
703
|
+
}
|
|
704
|
+
if (end === index || (this.pattern[index] === "0" && end > index + 1)) {
|
|
705
|
+
return null;
|
|
706
|
+
}
|
|
707
|
+
// Past 1e8 RE2 stops counting: a count that large is refused anyway.
|
|
708
|
+
return {
|
|
709
|
+
value: Math.min(Number(this.pattern.slice(index, end)), 1e8),
|
|
710
|
+
end,
|
|
711
|
+
};
|
|
712
|
+
};
|
|
713
|
+
const min = readNumber(start + 1);
|
|
714
|
+
if (min === null) {
|
|
715
|
+
return null;
|
|
716
|
+
}
|
|
717
|
+
let max = min.value;
|
|
718
|
+
let end = min.end;
|
|
719
|
+
if (this.pattern[end] === ",") {
|
|
720
|
+
if (this.pattern[end + 1] === "}") {
|
|
721
|
+
max = -1;
|
|
722
|
+
end++;
|
|
723
|
+
}
|
|
724
|
+
else {
|
|
725
|
+
const upper = readNumber(end + 1);
|
|
726
|
+
if (upper === null) {
|
|
727
|
+
return null;
|
|
728
|
+
}
|
|
729
|
+
max = upper.value;
|
|
730
|
+
end = upper.end;
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
if (this.pattern[end] !== "}") {
|
|
734
|
+
return null;
|
|
735
|
+
}
|
|
736
|
+
return {
|
|
737
|
+
text: this.pattern.slice(start, end + 1),
|
|
738
|
+
min: min.value,
|
|
739
|
+
max,
|
|
740
|
+
counted: true,
|
|
741
|
+
};
|
|
742
|
+
}
|
|
743
|
+
/*
|
|
744
|
+
* A repeat of what the alternative ends with, and the "?" after it that
|
|
745
|
+
* makes it lazy: under (?U), RE2 reads x* as lazy and x*? as greedy
|
|
746
|
+
* (repeat, parse.go). Written right after what it repeats, before any
|
|
747
|
+
* modifier group a flag group opened since, and around a group when
|
|
748
|
+
* JavaScript repeats it only so.
|
|
749
|
+
*/
|
|
750
|
+
readRepeat(repeat) {
|
|
751
|
+
if (repeat.counted && repeat.max >= 0 && repeat.min > repeat.max) {
|
|
752
|
+
throw this.refuse(`repeats a part ${repeat.text} times, the least more than the most, ${PROMETHEUS_TOO}. Write the smaller count first, as in {${repeat.max},${repeat.min}}.`);
|
|
753
|
+
}
|
|
754
|
+
if (repeat.counted &&
|
|
755
|
+
(repeat.min > MAX_REPEAT || repeat.max > MAX_REPEAT)) {
|
|
756
|
+
throw this.repeatCountRefusal(repeat.text);
|
|
757
|
+
}
|
|
758
|
+
if (this.afterRepeat) {
|
|
759
|
+
throw this.refuse(`repeats a repeat with ${repeat.text} right after it, ${PROMETHEUS_TOO}. Put the first repeat in a group to repeat it again, as in (?:a*)${repeat.text}.`);
|
|
760
|
+
}
|
|
761
|
+
const group = this.group();
|
|
762
|
+
const atom = group.lastAtom;
|
|
763
|
+
if (atom === null) {
|
|
764
|
+
throw this.refuse(`has the repeat ${repeat.text} with nothing before it to repeat, ${PROMETHEUS_TOO}. Write \\${repeat.text[0]} to match the character itself.`);
|
|
765
|
+
}
|
|
766
|
+
/*
|
|
767
|
+
* The count repeatIsValid reads: the most, or the least when unbounded.
|
|
768
|
+
* A count of 0 repeats nothing, so the counts inside it no longer count.
|
|
769
|
+
*/
|
|
770
|
+
const count = repeat.max === -1 ? repeat.min : repeat.max;
|
|
771
|
+
let repeats = atom.repeats;
|
|
772
|
+
if (repeat.counted) {
|
|
773
|
+
repeats = count === 0 ? 1 : count * atom.repeats;
|
|
774
|
+
if ((repeat.min >= 2 || repeat.max >= 2) && repeats > MAX_REPEAT) {
|
|
775
|
+
throw this.repeatCountRefusal(repeat.text);
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
let lazy = false;
|
|
779
|
+
if (this.pattern[this.position] === "?") {
|
|
780
|
+
lazy = true;
|
|
781
|
+
this.position++;
|
|
782
|
+
}
|
|
783
|
+
const operator = repeat.text + (lazy !== group.flags.ungreedy ? "?" : "");
|
|
784
|
+
if (atom.needsGroup) {
|
|
785
|
+
this.output.splice(atom.end, 0, `)${operator}`);
|
|
786
|
+
this.output.splice(atom.start, 0, "(?:");
|
|
787
|
+
}
|
|
788
|
+
else {
|
|
789
|
+
this.output.splice(atom.end, 0, operator);
|
|
790
|
+
}
|
|
791
|
+
group.lastAtom = {
|
|
792
|
+
start: atom.start,
|
|
793
|
+
end: atom.end + (atom.needsGroup ? 2 : 1),
|
|
794
|
+
needsGroup: true,
|
|
795
|
+
repeats: repeats,
|
|
796
|
+
};
|
|
797
|
+
this.afterRepeat = true;
|
|
798
|
+
}
|
|
799
|
+
repeatCountRefusal(written) {
|
|
800
|
+
return this.refuse(`repeats a part more than ${MAX_REPEAT} times (${written}), counting a repeat inside another as the two counts multiplied, and Prometheus repeats a part at most ${MAX_REPEAT} times. Repeat it fewer times, or use * or + for any number of times.`);
|
|
801
|
+
}
|
|
802
|
+
readGroupStart() {
|
|
803
|
+
const flags = this.group().flags;
|
|
804
|
+
if (this.pattern[this.position + 1] !== "?") {
|
|
805
|
+
// ( ... ): a capturing group.
|
|
806
|
+
this.openCapture(null);
|
|
807
|
+
this.position++;
|
|
808
|
+
return;
|
|
809
|
+
}
|
|
810
|
+
const kind = this.pattern.slice(this.position + 2, this.position + 4);
|
|
811
|
+
if (kind === "<=" ||
|
|
812
|
+
kind === "<!" ||
|
|
813
|
+
kind.startsWith("=") ||
|
|
814
|
+
kind.startsWith("!")) {
|
|
815
|
+
throw this.refuse(`uses the look-${kind.startsWith("<") ? "behind" : "ahead"} (?${kind.startsWith("<") ? kind : kind[0]}, ${PROMETHEUS_TOO}. Match the text itself instead, or leave values out with a second matcher that uses !~.`);
|
|
816
|
+
}
|
|
817
|
+
if ((kind === "P<" && this.position + 4 < this.pattern.length) ||
|
|
818
|
+
(kind.startsWith("<") && this.position + 3 < this.pattern.length)) {
|
|
819
|
+
this.readNamedGroupStart();
|
|
820
|
+
return;
|
|
821
|
+
}
|
|
822
|
+
this.readFlagGroup(flags);
|
|
823
|
+
}
|
|
824
|
+
// A capturing group's "(", and its name, if any.
|
|
825
|
+
openCapture(name) {
|
|
826
|
+
const start = this.output.length;
|
|
827
|
+
this.write("(");
|
|
828
|
+
this.groupNames.push(name);
|
|
829
|
+
this.groups.push(openGroup(this.group().flags, start));
|
|
830
|
+
}
|
|
831
|
+
/*
|
|
832
|
+
* (?P<name> ... ) or (?<name> ... ): a group with no name in JavaScript,
|
|
833
|
+
* its name kept in groupNames. RE2 reads to the first ">" and takes a
|
|
834
|
+
* name of letters, digits and _ (parsePerlFlags, isValidCaptureName).
|
|
835
|
+
*/
|
|
836
|
+
readNamedGroupStart() {
|
|
837
|
+
const nameStart = this.pattern[this.position + 2] === "P"
|
|
838
|
+
? this.position + 4
|
|
839
|
+
: this.position + 3;
|
|
840
|
+
const nameEnd = this.pattern.indexOf(">", nameStart);
|
|
841
|
+
if (nameEnd === -1 ||
|
|
842
|
+
!isCaptureName(this.pattern.slice(nameStart, nameEnd))) {
|
|
843
|
+
const written = nameEnd === -1
|
|
844
|
+
? this.pattern.slice(this.position)
|
|
845
|
+
: this.pattern.slice(this.position, nameEnd + 1);
|
|
846
|
+
throw this.refuse(`names a group ${written}, ${PROMETHEUS_TOO}. A group's name is letters, digits and _, closed by ">": (?P<host>...).`);
|
|
847
|
+
}
|
|
848
|
+
this.openCapture(this.pattern.slice(nameStart, nameEnd));
|
|
849
|
+
this.position = nameEnd + 1;
|
|
850
|
+
}
|
|
851
|
+
/*
|
|
852
|
+
* (?flags) or (?flags: ... ): RE2's i, m, s and U, set, or cleared after
|
|
853
|
+
* one "-", which a flag must follow (parsePerlFlags, parse.go).
|
|
854
|
+
* (?flags: ... ) sets them inside its group; (?flags) from where it stands
|
|
855
|
+
* to the end of the group that holds it.
|
|
856
|
+
*/
|
|
857
|
+
readFlagGroup(outer) {
|
|
858
|
+
var _a;
|
|
859
|
+
const flags = Object.assign({}, outer);
|
|
860
|
+
let index = this.position + 2;
|
|
861
|
+
let clearing = false;
|
|
862
|
+
let sawFlag = false;
|
|
863
|
+
for (;;) {
|
|
864
|
+
const character = (_a = this.pattern[index]) !== null && _a !== void 0 ? _a : "";
|
|
865
|
+
const flag = FLAG_LETTERS.get(character);
|
|
866
|
+
if (flag !== undefined) {
|
|
867
|
+
flags[flag] = !clearing;
|
|
868
|
+
sawFlag = true;
|
|
869
|
+
}
|
|
870
|
+
else if (character === "-" && !clearing) {
|
|
871
|
+
clearing = true;
|
|
872
|
+
sawFlag = false;
|
|
873
|
+
}
|
|
874
|
+
else if ((character === ":" || character === ")") &&
|
|
875
|
+
(!clearing || sawFlag)) {
|
|
876
|
+
break;
|
|
877
|
+
}
|
|
878
|
+
else {
|
|
879
|
+
throw this.refuse(`opens a group with ${this.pattern.slice(this.position, Math.min(index + 1, this.pattern.length))}, ${PROMETHEUS_TOO}. A group is (...), (?:...) or (?P<name>...), and a flag group (?i), (?m), (?s) or (?U), or (?i:...) for a part.`);
|
|
880
|
+
}
|
|
881
|
+
index++;
|
|
882
|
+
}
|
|
883
|
+
this.position = index + 1;
|
|
884
|
+
this.afterRepeat = false;
|
|
885
|
+
if (this.pattern[index] === ")") {
|
|
886
|
+
this.setFlags(flags);
|
|
887
|
+
return;
|
|
888
|
+
}
|
|
889
|
+
const opening = modifierGroup(outer, flags);
|
|
890
|
+
const start = this.output.length;
|
|
891
|
+
this.write(opening.length > 0 ? opening : "(?:");
|
|
892
|
+
this.groups.push(openGroup(flags, start));
|
|
893
|
+
}
|
|
894
|
+
/*
|
|
895
|
+
* (?flags): the flags change from here to the end of the group. What
|
|
896
|
+
* follows in this alternative goes inside a modifier group that sets
|
|
897
|
+
* them, closed at the alternative's end, and each later alternative
|
|
898
|
+
* starts with one of its own (readBar). At an alternative's start, one
|
|
899
|
+
* modifier group opened to the group's end does for this alternative and
|
|
900
|
+
* every later one. Written after what the alternative ends with, so a
|
|
901
|
+
* repeat right after the flag group still repeats it (readRepeat).
|
|
902
|
+
*/
|
|
903
|
+
setFlags(flags) {
|
|
904
|
+
const group = this.group();
|
|
905
|
+
if (sameFlags(group.flags, flags)) {
|
|
906
|
+
return;
|
|
907
|
+
}
|
|
908
|
+
group.flags = flags;
|
|
909
|
+
if (!group.alternativeStarted) {
|
|
910
|
+
this.openRestModifierGroup(group);
|
|
911
|
+
return;
|
|
912
|
+
}
|
|
913
|
+
if (group.alternativeModifierGroupOpen) {
|
|
914
|
+
this.output.push(")");
|
|
915
|
+
group.alternativeModifierGroupOpen = false;
|
|
916
|
+
}
|
|
917
|
+
const opening = modifierGroup(group.restFlags, group.flags);
|
|
918
|
+
if (opening.length > 0) {
|
|
919
|
+
this.output.push(opening);
|
|
920
|
+
group.alternativeModifierGroupOpen = true;
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
// A modifier group from here to the group's end, for its flags now.
|
|
924
|
+
openRestModifierGroup(group) {
|
|
925
|
+
const opening = modifierGroup(group.restFlags, group.flags);
|
|
926
|
+
if (opening.length === 0) {
|
|
927
|
+
return;
|
|
928
|
+
}
|
|
929
|
+
this.output.push(opening);
|
|
930
|
+
group.restModifierGroups++;
|
|
931
|
+
group.restFlags = group.flags;
|
|
932
|
+
}
|
|
933
|
+
/*
|
|
934
|
+
* "|": RE2 keeps the flags a flag group set to the end of the group, so
|
|
935
|
+
* the next alternative starts under them too.
|
|
936
|
+
*/
|
|
937
|
+
readBar() {
|
|
938
|
+
const group = this.group();
|
|
939
|
+
if (group.alternativeModifierGroupOpen) {
|
|
940
|
+
this.output.push(")");
|
|
941
|
+
group.alternativeModifierGroupOpen = false;
|
|
942
|
+
}
|
|
943
|
+
this.output.push("|");
|
|
944
|
+
this.position++;
|
|
945
|
+
group.alternativeStarted = false;
|
|
946
|
+
this.endAtom(group);
|
|
947
|
+
group.lastAtom = null;
|
|
948
|
+
this.afterRepeat = false;
|
|
949
|
+
this.openRestModifierGroup(group);
|
|
950
|
+
}
|
|
951
|
+
/*
|
|
952
|
+
* ")": the flags go back to those the group opened under, and the group
|
|
953
|
+
* is what a repeat after it repeats.
|
|
954
|
+
*/
|
|
955
|
+
readGroupEnd() {
|
|
956
|
+
if (this.groups.length === 1) {
|
|
957
|
+
throw this.syntaxError("Unmatched ')'");
|
|
958
|
+
}
|
|
959
|
+
const closed = this.groups.pop();
|
|
960
|
+
const parent = this.group();
|
|
961
|
+
this.endAtom(closed);
|
|
962
|
+
this.closeModifierGroups(closed);
|
|
963
|
+
this.output.push(")");
|
|
964
|
+
this.position++;
|
|
965
|
+
this.afterRepeat = false;
|
|
966
|
+
this.endAtom(parent);
|
|
967
|
+
parent.lastAtom = {
|
|
968
|
+
start: closed.start,
|
|
969
|
+
end: this.output.length,
|
|
970
|
+
needsGroup: false,
|
|
971
|
+
repeats: closed.repeats,
|
|
972
|
+
};
|
|
973
|
+
}
|
|
974
|
+
// Closes the modifier groups opened inside a group, at its end.
|
|
975
|
+
closeModifierGroups(group) {
|
|
976
|
+
const count = group.restModifierGroups + (group.alternativeModifierGroupOpen ? 1 : 0);
|
|
977
|
+
this.output.push(")".repeat(count));
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
/*
|
|
981
|
+
* The regular expression a matcher's pattern means, anchored as Prometheus
|
|
982
|
+
* anchors it. Throws a SyntaxError for a pattern that is not a regular
|
|
983
|
+
* expression - a PromQLPatternError, which says why, for one Prometheus
|
|
984
|
+
* refuses or OneUptime cannot read - and PatternProblemError for one the
|
|
985
|
+
* linear-time matcher cannot run (a back-reference, or one too large), as
|
|
986
|
+
* getLinearRegExp does.
|
|
987
|
+
*/
|
|
988
|
+
const compilePromQLRegex = (pattern, options) => {
|
|
989
|
+
// Refused before it is read: a query can carry megabytes.
|
|
990
|
+
(0, LinearRegExp_1.refusePatternTooLong)(pattern);
|
|
991
|
+
const translation = new RE2Translation(pattern).translate();
|
|
992
|
+
return {
|
|
993
|
+
regex: (0, PatternCache_1.getLinearRegExp)(`^(?s:${translation.source})$`, "", {
|
|
994
|
+
captures: (options === null || options === void 0 ? void 0 : options.captures) === true,
|
|
995
|
+
}),
|
|
996
|
+
anchoredPattern: `^(?s:${pattern})$`,
|
|
997
|
+
groupNames: translation.groupNames,
|
|
998
|
+
};
|
|
999
|
+
};
|
|
1000
|
+
exports.compilePromQLRegex = compilePromQLRegex;
|
|
1001
|
+
/*
|
|
1002
|
+
* What the first group of this name that took part in the match captured,
|
|
1003
|
+
* as Go's Expand reads $name and ${name}; undefined when none did.
|
|
1004
|
+
*/
|
|
1005
|
+
const readNamedCapture = (data) => {
|
|
1006
|
+
for (let index = 0; index < data.groupNames.length; index++) {
|
|
1007
|
+
if (data.groupNames[index] === data.name &&
|
|
1008
|
+
data.captures[index] !== undefined) {
|
|
1009
|
+
return data.captures[index];
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
return undefined;
|
|
1013
|
+
};
|
|
1014
|
+
exports.readNamedCapture = readNamedCapture;
|