@oneuptime/common 14.3.0 → 15.0.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/AIAgent.js +5 -1
- package/Models/DatabaseModels/AcmeCertificate.js +14 -0
- package/Models/DatabaseModels/Alert.js +6 -8
- package/Models/DatabaseModels/AlertEpisodeStateTimeline.js +3 -2
- package/Models/DatabaseModels/AlertSeverity.js +3 -12
- package/Models/DatabaseModels/ApiKey.d.mts +3 -1
- package/Models/DatabaseModels/ApiKey.d.ts +3 -1
- package/Models/DatabaseModels/ApiKey.js +67 -14
- package/Models/DatabaseModels/AutoRemediationSuggestion.d.mts +1 -0
- package/Models/DatabaseModels/AutoRemediationSuggestion.d.ts +1 -0
- package/Models/DatabaseModels/AutoRemediationSuggestion.js +37 -4
- package/Models/DatabaseModels/CallLog.js +15 -3
- package/Models/DatabaseModels/CodeRepository.d.mts +1 -0
- package/Models/DatabaseModels/CodeRepository.d.ts +1 -0
- package/Models/DatabaseModels/CodeRepository.js +45 -2
- package/Models/DatabaseModels/CodeRepositoryMintedToken.d.mts +25 -0
- package/Models/DatabaseModels/CodeRepositoryMintedToken.d.ts +25 -0
- package/Models/DatabaseModels/CodeRepositoryMintedToken.js +436 -0
- package/Models/DatabaseModels/CodeRepositoryMintedToken.mjs +2 -0
- package/Models/DatabaseModels/Dashboard.js +10 -2
- package/Models/DatabaseModels/DashboardDomain.js +22 -27
- package/Models/DatabaseModels/DatabaseBaseModel/RuleBaseModel.d.mts +2 -0
- package/Models/DatabaseModels/DatabaseBaseModel/RuleBaseModel.d.ts +2 -0
- package/Models/DatabaseModels/DatabaseBaseModel/RuleBaseModel.js +30 -0
- package/Models/DatabaseModels/EmailLog.js +15 -3
- package/Models/DatabaseModels/File.js +4 -2
- package/Models/DatabaseModels/FormDomain.js +10 -2
- package/Models/DatabaseModels/GlobalConfig.d.mts +9 -1
- package/Models/DatabaseModels/GlobalConfig.d.ts +9 -1
- package/Models/DatabaseModels/GlobalConfig.js +186 -10
- package/Models/DatabaseModels/Incident.js +38 -44
- package/Models/DatabaseModels/IncidentEpisodePublicNote.js +11 -16
- package/Models/DatabaseModels/IncidentEpisodeStateTimeline.js +3 -2
- package/Models/DatabaseModels/IncidentPublicNote.js +11 -16
- package/Models/DatabaseModels/IncidentSeverity.js +3 -12
- package/Models/DatabaseModels/IncidentStateTimeline.js +12 -16
- package/Models/DatabaseModels/IncidentTemplate.js +6 -11
- package/Models/DatabaseModels/IncomingRequestSecret.d.mts +6 -0
- package/Models/DatabaseModels/IncomingRequestSecret.d.ts +6 -0
- package/Models/DatabaseModels/IncomingRequestSecret.js +156 -29
- package/Models/DatabaseModels/Index.js +2 -5
- package/Models/DatabaseModels/Monitor.d.mts +1 -0
- package/Models/DatabaseModels/Monitor.d.ts +1 -0
- package/Models/DatabaseModels/Monitor.js +97 -22
- package/Models/DatabaseModels/MonitorNetworkDevice.js +4 -1
- package/Models/DatabaseModels/MonitorTemplate.js +3 -1
- package/Models/DatabaseModels/MonitorTest.js +3 -1
- package/Models/DatabaseModels/NetworkDevice.js +16 -3
- package/Models/DatabaseModels/NetworkEndpoint.d.mts +1 -0
- package/Models/DatabaseModels/NetworkEndpoint.d.ts +1 -0
- package/Models/DatabaseModels/NetworkEndpoint.js +39 -0
- package/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.js +45 -12
- package/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.d.mts +2 -0
- package/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.d.ts +2 -0
- package/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.js +93 -5
- package/Models/DatabaseModels/OnCallDutyPolicySchedule.d.mts +1 -0
- package/Models/DatabaseModels/OnCallDutyPolicySchedule.d.ts +1 -0
- package/Models/DatabaseModels/OnCallDutyPolicySchedule.js +43 -0
- package/Models/DatabaseModels/Probe.js +5 -1
- package/Models/DatabaseModels/Project.d.mts +1 -1
- package/Models/DatabaseModels/Project.d.ts +1 -1
- package/Models/DatabaseModels/Project.js +59 -64
- package/Models/DatabaseModels/ProjectSmtpConfig.js +44 -49
- package/Models/DatabaseModels/PushNotificationLog.js +15 -3
- package/Models/DatabaseModels/Reseller.js +2 -8
- package/Models/DatabaseModels/ResellerPlan.js +2 -8
- package/Models/DatabaseModels/RunbookExecution.js +4 -4
- package/Models/DatabaseModels/Runner.d.mts +1 -0
- package/Models/DatabaseModels/Runner.d.ts +1 -0
- package/Models/DatabaseModels/Runner.js +50 -0
- package/Models/DatabaseModels/ScheduledMaintenance.js +32 -24
- package/Models/DatabaseModels/ScheduledMaintenancePublicNote.js +11 -16
- package/Models/DatabaseModels/ScheduledMaintenanceStateTimeline.js +12 -16
- package/Models/DatabaseModels/ScheduledMaintenanceTemplate.js +9 -8
- package/Models/DatabaseModels/ServiceLevelObjective.js +7 -0
- package/Models/DatabaseModels/SmsLog.js +15 -3
- package/Models/DatabaseModels/StatusPage.js +30 -11
- package/Models/DatabaseModels/StatusPageAnnouncement.js +19 -24
- package/Models/DatabaseModels/StatusPageDomain.js +24 -27
- package/Models/DatabaseModels/StatusPageSubscriber.js +5 -4
- package/Models/DatabaseModels/TelegramLog.js +15 -3
- package/Models/DatabaseModels/User.d.mts +0 -3
- package/Models/DatabaseModels/User.d.ts +0 -3
- package/Models/DatabaseModels/User.js +5 -73
- package/Models/DatabaseModels/UserOnCallLog.d.mts +1 -0
- package/Models/DatabaseModels/UserOnCallLog.d.ts +1 -0
- package/Models/DatabaseModels/UserOnCallLog.js +52 -5
- package/Models/DatabaseModels/UserOnCallLogTimeline.js +10 -2
- package/Models/DatabaseModels/UserWebhook.js +14 -5
- package/Models/DatabaseModels/WebhookLog.js +15 -3
- package/Models/DatabaseModels/WhatsAppLog.js +15 -3
- package/Models/DatabaseModels/WorkspaceNotificationLog.js +15 -3
- package/Models/DatabaseModels/WorkspaceNotificationRule.js +10 -7
- package/Models/DatabaseModels/WorkspaceProjectAuthToken.js +16 -2
- package/Models/DatabaseModels/WorkspaceUserAuthToken.js +13 -2
- package/Server/Services/DatabaseService.d.mts +57 -38
- package/Server/Services/DatabaseService.d.ts +57 -38
- package/Server/Types/Database/Permissions/PrivateRecordPermission.d.mts +123 -0
- package/Server/Types/Database/Permissions/PrivateRecordPermission.d.ts +123 -0
- package/Types/AI/AIActionWords.d.mts +14 -1
- package/Types/AI/AIActionWords.d.ts +14 -1
- package/Types/AI/AIActionWords.js +85 -1
- package/Types/AI/AIActionWords.mjs +4 -0
- package/Types/AI/AIAgentRunLimits.js +5 -4
- package/Types/AI/AIChatTypes.js +8 -3
- package/Types/AI/AIReadTableWords.js +7 -2
- package/Types/AI/AiActivityInsights.d.mts +1 -0
- package/Types/AI/AiActivityInsights.d.ts +1 -0
- package/Types/AI/CodeTask.d.mts +1 -0
- package/Types/AI/CodeTask.d.ts +1 -0
- package/Types/AI/CodeTask.js +7 -0
- package/Types/AI/ResourceAiAccessApi.d.mts +4 -0
- package/Types/AI/ResourceAiAccessApi.d.ts +4 -0
- package/Types/Accounts/MoreWaysToSignIn.d.mts +1 -0
- package/Types/Accounts/MoreWaysToSignIn.d.ts +1 -0
- package/Types/Accounts/MoreWaysToSignIn.js +11 -0
- package/Types/Accounts/MoreWaysToSignIn.mjs +2 -0
- package/Types/Accounts/SignInMessages.d.mts +5 -0
- package/Types/Accounts/SignInMessages.d.ts +5 -0
- package/Types/Accounts/SignInMessages.js +19 -1
- package/Types/Accounts/SignInMessages.mjs +2 -0
- package/Types/Analytics/ProductEvent.d.mts +7 -2
- package/Types/Analytics/ProductEvent.d.ts +7 -2
- package/Types/Analytics/ProductEvent.js +62 -12
- package/Types/ApiKey/ApiKeyShownOnce.d.mts +11 -0
- package/Types/ApiKey/ApiKeyShownOnce.d.ts +11 -0
- package/Types/ApiKey/ApiKeyShownOnce.js +78 -0
- package/Types/ApiKey/ApiKeyShownOnce.mjs +6 -0
- package/Types/AuditLog/AuditLogAction.d.mts +1 -0
- package/Types/AuditLog/AuditLogAction.d.ts +1 -0
- package/Types/AuditLog/AuditLogAction.js +11 -1
- package/Types/AuditLog/AuditLogActionLabel.js +1 -0
- package/Types/AuditLog/AuditLogCoverage.js +1 -0
- package/Types/AuditLog/AuditLogSessionEvent.d.mts +15 -3
- package/Types/AuditLog/AuditLogSessionEvent.d.ts +15 -3
- package/Types/AuditLog/AuditLogSessionEvent.js +107 -12
- package/Types/AuditLog/AuditLogSessionEvent.mjs +6 -0
- package/Types/AuditLog/AuditLogSignInFailure.d.mts +30 -0
- package/Types/AuditLog/AuditLogSignInFailure.d.ts +30 -0
- package/Types/AuditLog/AuditLogSignInFailure.js +109 -0
- package/Types/AuditLog/AuditLogSignInFailure.mjs +8 -0
- package/Types/AuditLog/AuditLogStatusPageSession.d.mts +29 -0
- package/Types/AuditLog/AuditLogStatusPageSession.d.ts +29 -0
- package/Types/AuditLog/AuditLogStatusPageSession.js +106 -0
- package/Types/AuditLog/AuditLogStatusPageSession.mjs +9 -0
- package/Types/AuditLog/Export/AuditLogExportEntriesLost.d.mts +11 -0
- package/Types/AuditLog/Export/AuditLogExportEntriesLost.d.ts +11 -0
- package/Types/AuditLog/Export/AuditLogExportEntriesLost.js +57 -0
- package/Types/AuditLog/Export/AuditLogExportEntriesLost.mjs +5 -0
- package/Types/AutoRemediation/RemediationApprovals.d.mts +39 -0
- package/Types/AutoRemediation/RemediationApprovals.d.ts +39 -0
- package/Types/AutoRemediation/RemediationApprovals.js +174 -8
- package/Types/AutoRemediation/RemediationApprovals.mjs +9 -0
- package/Types/AutoRemediation/RemediationPlanFingerprint.d.mts +15 -0
- package/Types/AutoRemediation/RemediationPlanFingerprint.d.ts +15 -0
- package/Types/AutoRemediation/RemediationPlanFingerprint.js +131 -0
- package/Types/AutoRemediation/RemediationPlanFingerprint.mjs +6 -0
- package/Types/BaseDatabase/SortNulls.d.mts +5 -0
- package/Types/BaseDatabase/SortNulls.d.ts +5 -0
- package/Types/BaseDatabase/SortNulls.js +14 -0
- package/Types/BaseDatabase/SortNulls.mjs +2 -0
- package/Types/Billing/AdminProjectInvoice.d.mts +20 -0
- package/Types/Billing/AdminProjectInvoice.d.ts +20 -0
- package/Types/Billing/AdminProjectInvoice.js +85 -0
- package/Types/Billing/AdminProjectInvoice.mjs +6 -0
- package/Types/CloudConnection/CloudAiAgentCost.d.mts +6 -2
- package/Types/CloudConnection/CloudAiAgentCost.d.ts +6 -2
- package/Types/CloudConnection/CloudAiAgentCost.js +28 -2
- package/Types/CloudConnection/CloudAiAgentCost.mjs +4 -0
- package/Types/CloudConnection/CloudAiAgentSetupCommands.d.mts +19 -1
- package/Types/CloudConnection/CloudAiAgentSetupCommands.d.ts +19 -1
- package/Types/CloudConnection/CloudAiAgentSetupCommands.js +354 -16
- package/Types/CloudConnection/CloudAiAgentSetupCommands.mjs +17 -0
- package/Types/CustomDomain/UploadedCertificateRefusals.d.mts +10 -0
- package/Types/CustomDomain/UploadedCertificateRefusals.d.ts +10 -0
- package/Types/CustomDomain/UploadedCertificateRefusals.js +69 -0
- package/Types/CustomDomain/UploadedCertificateRefusals.mjs +11 -0
- package/Types/DataObservability/DataLineageMap.d.mts +147 -0
- package/Types/DataObservability/DataLineageMap.d.ts +147 -0
- package/Types/DataObservability/DataLineageMap.js +503 -0
- package/Types/DataObservability/DataLineageMap.mjs +20 -0
- package/Types/DataObservability/DataObservabilityApiTypes.d.mts +1 -0
- package/Types/DataObservability/DataObservabilityApiTypes.d.ts +1 -0
- package/Types/DataObservability/DataObservabilityApiTypes.js +2 -0
- package/Types/Database/TableColumn.d.mts +1 -0
- package/Types/Database/TableColumn.d.ts +1 -0
- package/Types/Database/UserAttribution.js +7 -3
- package/Types/Date.d.mts +0 -2
- package/Types/Date.d.ts +0 -2
- package/Types/Date.js +12 -19
- package/Types/Email/EmailMessage.d.mts +2 -0
- package/Types/Email/EmailMessage.d.ts +2 -0
- package/Types/Email/EmailRecipients.d.mts +11 -0
- package/Types/Email/EmailRecipients.d.ts +11 -0
- package/Types/Email/EmailRecipients.js +84 -0
- package/Types/Email/EmailRecipients.mjs +6 -0
- package/Types/Email/EmailTemplateType.d.mts +2 -1
- package/Types/Email/EmailTemplateType.d.ts +2 -1
- package/Types/Email/EmailTemplateType.js +5 -0
- package/Types/IP/IP.js +27 -1
- package/Types/JoinedSerializableObjects.d.mts +6 -0
- package/Types/JoinedSerializableObjects.d.ts +6 -0
- package/Types/JoinedSerializableObjects.js +14 -0
- package/Types/JoinedSerializableObjects.mjs +3 -0
- package/Types/Kubernetes/KubernetesClusterAiLogs.d.mts +2 -0
- package/Types/Kubernetes/KubernetesClusterAiLogs.d.ts +2 -0
- package/Types/MasterApiKey/MasterApiKeyAnswer.d.mts +15 -0
- package/Types/MasterApiKey/MasterApiKeyAnswer.d.ts +15 -0
- package/Types/MasterApiKey/MasterApiKeyAnswer.js +81 -0
- package/Types/MasterApiKey/MasterApiKeyAnswer.mjs +5 -0
- package/Types/MeaningKeys.js +19 -0
- package/Types/Monitor/IncomingMonitor/IncomingMonitorRequest.d.mts +2 -0
- package/Types/Monitor/IncomingMonitor/IncomingMonitorRequest.d.ts +2 -0
- package/Types/Monitor/IncomingMonitor/IncomingRequestSecret.d.mts +23 -1
- package/Types/Monitor/IncomingMonitor/IncomingRequestSecret.d.ts +23 -1
- package/Types/Monitor/IncomingMonitor/IncomingRequestSecret.js +105 -4
- package/Types/Monitor/IncomingMonitor/IncomingRequestSecret.mjs +7 -0
- package/Types/Monitor/IncomingMonitor/WebhookVerificationProvider.d.mts +11 -0
- package/Types/Monitor/IncomingMonitor/WebhookVerificationProvider.d.ts +11 -0
- package/Types/Monitor/IncomingMonitor/WebhookVerificationProvider.js +28 -0
- package/Types/Monitor/IncomingMonitor/WebhookVerificationProvider.mjs +3 -0
- package/Types/Monitor/MonitorCriteria.js +8 -0
- package/Types/Monitor/MonitorCriteriaInstance.js +8 -0
- package/Types/Monitor/MonitorGroupUptimeSummary.d.mts +12 -0
- package/Types/Monitor/MonitorGroupUptimeSummary.d.ts +12 -0
- package/Types/Monitor/MonitorGroupUptimeSummary.js +2 -0
- package/Types/Monitor/MonitorGroupUptimeSummary.mjs +1 -0
- package/Types/Monitor/MonitorJsonTypes.d.mts +4 -0
- package/Types/Monitor/MonitorJsonTypes.d.ts +4 -0
- package/Types/Monitor/MonitorJsonTypes.js +31 -0
- package/Types/Monitor/MonitorJsonTypes.mjs +2 -0
- package/Types/Monitor/MonitorStep.js +8 -0
- package/Types/Monitor/MonitorSteps.js +8 -0
- package/Types/Monitor/MonitorStepsColumnTransformer.browser.d.mts +3 -0
- package/Types/Monitor/MonitorStepsColumnTransformer.browser.d.ts +3 -0
- package/Types/Monitor/MonitorStepsColumnTransformer.browser.js +21 -0
- package/Types/Monitor/MonitorStepsColumnTransformer.browser.mjs +2 -0
- package/Types/Monitor/MonitorStepsColumnTransformer.d.mts +3 -0
- package/Types/Monitor/MonitorStepsColumnTransformer.d.ts +3 -0
- package/Types/Monitor/MonitorStepsColumnTransformer.js +24 -0
- package/Types/Monitor/MonitorStepsColumnTransformer.mjs +2 -0
- package/Types/Monitor/UptimeHistoryLabels.d.mts +4 -0
- package/Types/Monitor/UptimeHistoryLabels.d.ts +4 -0
- package/Types/Monitor/UptimeHistoryLabels.js +4 -0
- package/Types/Monitor/WhoIsTold.d.mts +25 -0
- package/Types/Monitor/WhoIsTold.d.ts +25 -0
- package/Types/Monitor/WhoIsTold.js +171 -19
- package/Types/Monitor/WhoIsTold.mjs +3 -0
- package/Types/NoBreakSpaces.d.mts +5 -1
- package/Types/NoBreakSpaces.d.ts +5 -1
- package/Types/NoBreakSpaces.js +107 -52
- package/Types/NoBreakSpaces.mjs +1 -0
- package/Types/NotificationRule/PagingLadder.d.mts +2 -0
- package/Types/NotificationRule/PagingLadder.d.ts +2 -0
- package/Types/NotificationRule/PagingLadder.js +47 -1
- package/Types/NotificationRule/PagingLadder.mjs +1 -0
- package/Types/OnCallDutyPolicy/OnCalDutyExecutionLogTimelineStatus.d.mts +2 -1
- package/Types/OnCallDutyPolicy/OnCalDutyExecutionLogTimelineStatus.d.ts +2 -1
- package/Types/OnCallDutyPolicy/OnCalDutyExecutionLogTimelineStatus.js +6 -0
- package/Types/OnCallDutyPolicy/OnCallAcknowledgementTimeout.d.mts +5 -0
- package/Types/OnCallDutyPolicy/OnCallAcknowledgementTimeout.d.ts +5 -0
- package/Types/OnCallDutyPolicy/OnCallAcknowledgementTimeout.js +41 -0
- package/Types/OnCallDutyPolicy/OnCallAcknowledgementTimeout.mjs +1 -0
- package/Types/OnCallDutyPolicy/OnCallLogLine.d.mts +6 -1
- package/Types/OnCallDutyPolicy/OnCallLogLine.d.ts +6 -1
- package/Types/OnCallDutyPolicy/OnCallLogLine.js +60 -0
- package/Types/OnCallDutyPolicy/OnCallPageMerge.d.mts +32 -0
- package/Types/OnCallDutyPolicy/OnCallPageMerge.d.ts +32 -0
- package/Types/OnCallDutyPolicy/OnCallPageMerge.js +192 -0
- package/Types/OnCallDutyPolicy/OnCallPageMerge.mjs +14 -0
- package/Types/OnCallDutyPolicy/OnCallRunLevel.d.mts +40 -0
- package/Types/OnCallDutyPolicy/OnCallRunLevel.d.ts +40 -0
- package/Types/OnCallDutyPolicy/OnCallRunLevel.js +142 -0
- package/Types/OnCallDutyPolicy/OnCallRunLevel.mjs +13 -0
- package/Types/Password.d.mts +18 -12
- package/Types/Password.d.ts +18 -12
- package/Types/Password.js +63 -58
- package/Types/Password.mjs +3 -3
- package/Types/Permission.d.mts +4 -0
- package/Types/Permission.d.ts +4 -0
- package/Types/Permission.js +48 -0
- package/Types/PrivateRecord/PrivateRecordParts.js +50 -0
- package/Types/Probe/ProbeCapability.d.mts +2 -1
- package/Types/Probe/ProbeCapability.d.ts +2 -1
- package/Types/Probe/ProbeCapability.js +11 -0
- package/Types/Product/ProjectProducts.d.mts +1 -15
- package/Types/Product/ProjectProducts.d.ts +1 -15
- package/Types/Product/ProjectProducts.js +38 -129
- package/Types/Product/ProjectProducts.mjs +1 -5
- package/Types/Product/ProjectProductsAnswer.js +5 -6
- package/Types/ProductFeedback/ProductFeedback.d.mts +29 -4
- package/Types/ProductFeedback/ProductFeedback.d.ts +29 -4
- package/Types/ProductFeedback/ProductFeedback.js +176 -28
- package/Types/ProductFeedback/ProductFeedback.mjs +11 -1
- package/Types/ResourceAiAgent/CloudAiAgentNames.d.mts +6 -0
- package/Types/ResourceAiAgent/CloudAiAgentNames.d.ts +6 -0
- package/Types/ResourceAiAgent/CloudAiAgentNames.js +20 -1
- package/Types/ResourceAiAgent/CloudAiAgentNames.mjs +5 -0
- package/Types/ResourceAiAgent/ResourceAiAccess.d.mts +3 -1
- package/Types/ResourceAiAgent/ResourceAiAccess.d.ts +3 -1
- package/Types/ResourceAiAgent/ResourceAiAccess.js +18 -1
- package/Types/ResourceAiAgent/ResourceAiAccess.mjs +2 -0
- package/Types/Retention/ResolvedRecordRetention.d.mts +33 -0
- package/Types/Retention/ResolvedRecordRetention.d.ts +33 -0
- package/Types/Retention/ResolvedRecordRetention.js +211 -1
- package/Types/Retention/ResolvedRecordRetention.mjs +13 -0
- package/Types/Retention/ResolvedRecordRetentionAnswers.d.mts +28 -0
- package/Types/Retention/ResolvedRecordRetentionAnswers.d.ts +28 -0
- package/Types/Retention/ResolvedRecordRetentionAnswers.js +134 -0
- package/Types/Retention/ResolvedRecordRetentionAnswers.mjs +5 -0
- package/Types/Rules/RuleEmptiedLimit.d.mts +20 -0
- package/Types/Rules/RuleEmptiedLimit.d.ts +20 -0
- package/Types/Rules/RuleEmptiedLimit.js +131 -0
- package/Types/Rules/RuleEmptiedLimit.mjs +9 -0
- package/Types/Runbook/RunbookStepTimeout.js +11 -10
- package/Types/Runner/GlobalRunnerRepositoryTokens.d.mts +18 -0
- package/Types/Runner/GlobalRunnerRepositoryTokens.d.ts +18 -0
- package/Types/Runner/GlobalRunnerRepositoryTokens.js +97 -0
- package/Types/Runner/GlobalRunnerRepositoryTokens.mjs +8 -0
- package/Types/Runner/GlobalRunnerSandbox.d.mts +38 -0
- package/Types/Runner/GlobalRunnerSandbox.d.ts +38 -0
- package/Types/Runner/GlobalRunnerSandbox.js +178 -0
- package/Types/Runner/GlobalRunnerSandbox.mjs +9 -0
- package/Types/Runner/GlobalRunnerWork.js +9 -4
- package/Types/Runner/RunnerCodeFixCapability.d.mts +14 -0
- package/Types/Runner/RunnerCodeFixCapability.d.ts +14 -0
- package/Types/Runner/RunnerCodeFixCapability.js +103 -0
- package/Types/Runner/RunnerCodeFixCapability.mjs +7 -0
- package/Types/Runner/RunnerCodeFixes.d.mts +3 -0
- package/Types/Runner/RunnerCodeFixes.d.ts +3 -0
- package/Types/Runner/RunnerCodeFixes.js +27 -4
- package/Types/Runner/RunnerCodeFixes.mjs +1 -0
- package/Types/SSO/SessionsWithoutSso.d.mts +10 -0
- package/Types/SSO/SessionsWithoutSso.d.ts +10 -0
- package/Types/SSO/SessionsWithoutSso.js +39 -0
- package/Types/SSO/SessionsWithoutSso.mjs +5 -0
- package/Types/SerializableObjectDictionary.js +11 -8
- package/Types/SetupHealth/SetupHealth.d.mts +47 -2
- package/Types/SetupHealth/SetupHealth.d.ts +47 -2
- package/Types/SetupHealth/SetupHealth.js +228 -1
- package/Types/SetupHealth/SetupHealth.mjs +12 -0
- package/Types/StatusPage/StatusPageReport.d.mts +5 -2
- package/Types/StatusPage/StatusPageReport.d.ts +5 -2
- package/Types/StatusPage/SubscriberNotificationTemplateVariables.js +2 -2
- package/Types/StatusPage/UptimeDailyAggregate.d.mts +1 -0
- package/Types/StatusPage/UptimeDailyAggregate.d.ts +1 -0
- package/Types/Telemetry/LlmConventions.d.mts +1 -1
- package/Types/Telemetry/LlmConventions.d.ts +1 -1
- package/Types/Telemetry/LlmConventions.js +1 -1
- package/Types/Telemetry/ScrubRule.d.mts +1 -0
- package/Types/Telemetry/ScrubRule.d.ts +1 -0
- package/Types/Telemetry/ScrubRule.js +47 -0
- package/Types/Translator.d.mts +5 -2
- package/Types/Translator.d.ts +5 -2
- package/Types/Translator.js +43 -19
- package/Types/UsedBy/UsedBy.d.mts +107 -4
- package/Types/UsedBy/UsedBy.d.ts +107 -4
- package/Types/UsedBy/UsedBy.js +339 -6
- package/Types/UsedBy/UsedBy.mjs +12 -0
- package/Types/UsedBy/UsedByServerProducts.d.mts +5 -2
- package/Types/UsedBy/UsedByServerProducts.d.ts +5 -2
- package/Types/UsedBy/UsedByServerProducts.js +115 -6
- package/Types/UsedBy/UsedByServerProducts.mjs +1 -0
- package/Types/UserNotification/UserNotificationExecutionStatus.d.mts +2 -1
- package/Types/UserNotification/UserNotificationExecutionStatus.d.ts +2 -1
- package/Types/UserNotification/UserNotificationExecutionStatus.js +7 -0
- package/Types/UserSession/SessionEndCause.d.mts +1 -0
- package/Types/UserSession/SessionEndCause.d.ts +1 -0
- package/Types/UserSession/SessionEndCause.js +8 -1
- package/Types/WelcomeChecklist/ProjectGoal.js +5 -5
- package/Types/WelcomeChecklist/WelcomeChecklist.d.mts +4 -0
- package/Types/WelcomeChecklist/WelcomeChecklist.d.ts +4 -0
- package/Types/WelcomeChecklist/WelcomeChecklist.js +63 -1
- package/Types/WelcomeChecklist/WelcomeChecklist.mjs +4 -0
- package/Types/WelcomeChecklist/WelcomeChecklistAnswer.d.mts +0 -1
- package/Types/WelcomeChecklist/WelcomeChecklistAnswer.d.ts +0 -1
- package/Types/WelcomeChecklist/WelcomeChecklistAnswer.js +0 -3
- package/Types/Workflow/WatchedFields.d.mts +1 -0
- package/Types/Workflow/WatchedFields.d.ts +1 -0
- package/Types/Workflow/WatchedFields.js +10 -1
- package/Types/Workflow/WatchedFields.mjs +1 -0
- package/Types/Workflow/WorkflowPrivateRecords.d.mts +2 -0
- package/Types/Workflow/WorkflowPrivateRecords.d.ts +2 -0
- package/Types/Workflow/WorkflowPrivateRecords.js +33 -0
- package/Types/Workflow/WorkflowPrivateRecords.mjs +3 -0
- package/Types/Workspace/NotificationRules/BaseNotificationRule.d.mts +1 -0
- package/Types/Workspace/NotificationRules/BaseNotificationRule.d.ts +1 -0
- package/Types/Workspace/NotificationRules/EventType.js +4 -3
- package/Types/Workspace/NotificationRules/NotificationRuleUpdates.d.mts +19 -2
- package/Types/Workspace/NotificationRules/NotificationRuleUpdates.d.ts +19 -2
- package/Types/Workspace/NotificationRules/NotificationRuleUpdates.js +127 -8
- package/Types/Workspace/WorkspaceLiveMessageKey.d.mts +5 -1
- package/Types/Workspace/WorkspaceLiveMessageKey.d.ts +5 -1
- package/Types/Workspace/WorkspaceLiveMessageKey.js +12 -0
- package/Types/Workspace/WorkspaceMessagePayload.d.mts +6 -0
- package/Types/Workspace/WorkspaceMessagePayload.d.ts +6 -0
- package/Utils/API.d.mts +6 -7
- package/Utils/API.d.ts +6 -7
- package/Utils/API.js +57 -35
- package/Utils/AiRemediation/Resource/CloudOperationCatalog.d.mts +10 -0
- package/Utils/AiRemediation/Resource/CloudOperationCatalog.d.ts +10 -0
- package/Utils/AiRemediation/Resource/CloudOperationCatalog.js +89 -1
- package/Utils/AiRemediation/Resource/CloudOperationCatalog.mjs +4 -0
- package/Utils/Billing/InvoiceAmount.d.mts +4 -0
- package/Utils/Billing/InvoiceAmount.d.ts +4 -0
- package/Utils/Billing/InvoiceAmount.js +35 -0
- package/Utils/Billing/InvoiceAmount.mjs +2 -0
- package/Utils/CertificateReissue.js +4 -3
- package/Utils/CronScheduleText.js +10 -3
- package/Utils/CronTab.js +6 -33
- package/Utils/Dashboard/MonitorListWidgetFormat.d.mts +5 -18
- package/Utils/Dashboard/MonitorListWidgetFormat.d.ts +5 -18
- package/Utils/Dashboard/MonitorListWidgetFormat.js +54 -18
- package/Utils/DeveloperDocs/ResourceProfiles.js +2 -1
- package/Utils/DeveloperDocs/TerraformSchema.js +3 -2
- package/Utils/LinearRegExp/LinearRegExp.d.mts +1 -0
- package/Utils/LinearRegExp/LinearRegExp.d.ts +1 -0
- package/Utils/LinearRegExp/LinearRegExp.js +17 -0
- package/Utils/Markdown/LinkReferenceDefinitions.d.mts +6 -0
- package/Utils/Markdown/LinkReferenceDefinitions.d.ts +6 -0
- package/Utils/Markdown/LinkReferenceDefinitions.js +477 -152
- package/Utils/Markdown/LinkReferenceDefinitions.mjs +1 -0
- package/Utils/Markdown/SlowMarkdown.js +168 -33
- package/Utils/Metrics/MetricFormulaEvaluator.d.mts +20 -4
- package/Utils/Metrics/MetricFormulaEvaluator.d.ts +20 -4
- package/Utils/Metrics/MetricFormulaEvaluator.js +233 -29
- package/Utils/Metrics/MetricResultUnitConverter.js +7 -1
- package/Utils/Metrics/MetricSeriesArrivalUtil.d.mts +4 -0
- package/Utils/Metrics/MetricSeriesArrivalUtil.d.ts +4 -0
- package/Utils/Metrics/MetricSeriesArrivalUtil.js +27 -0
- package/Utils/Metrics/MetricZeroFill.d.mts +45 -0
- package/Utils/Metrics/MetricZeroFill.d.ts +45 -0
- package/Utils/Metrics/MetricZeroFill.js +145 -0
- package/Utils/Metrics/MetricZeroFill.mjs +2 -0
- package/Utils/ModelImportExport.js +4 -1
- package/Utils/Monitor/EndpointAttachmentUtil.d.mts +3 -0
- package/Utils/Monitor/EndpointAttachmentUtil.d.ts +3 -0
- package/Utils/Monitor/EndpointAttachmentUtil.js +57 -0
- package/Utils/Monitor/HeartbeatSweepSchedule.d.mts +9 -0
- package/Utils/Monitor/HeartbeatSweepSchedule.d.ts +9 -0
- package/Utils/Monitor/HeartbeatSweepSchedule.js +52 -0
- package/Utils/Monitor/HeartbeatSweepSchedule.mjs +5 -0
- package/Utils/Monitor/MonitorFirstCheck.d.mts +32 -0
- package/Utils/Monitor/MonitorFirstCheck.d.ts +32 -0
- package/Utils/Monitor/MonitorFirstCheck.js +128 -0
- package/Utils/Monitor/MonitorFirstCheck.mjs +4 -0
- package/Utils/Monitor/MonitorFirstCheckOverdue.d.mts +12 -0
- package/Utils/Monitor/MonitorFirstCheckOverdue.d.ts +12 -0
- package/Utils/Monitor/MonitorFirstCheckOverdue.js +87 -0
- package/Utils/Monitor/MonitorFirstCheckOverdue.mjs +2 -0
- package/Utils/Monitor/MonitorGroupUptimeSummaryUtil.d.mts +11 -0
- package/Utils/Monitor/MonitorGroupUptimeSummaryUtil.d.ts +11 -0
- package/Utils/Monitor/MonitorGroupUptimeSummaryUtil.js +86 -0
- package/Utils/Monitor/MonitorGroupUptimeSummaryUtil.mjs +2 -0
- package/Utils/Monitor/MonitorOverviewPresentationUtil.d.mts +4 -0
- package/Utils/Monitor/MonitorOverviewPresentationUtil.d.ts +4 -0
- package/Utils/Monitor/MonitorOverviewPresentationUtil.js +122 -4
- package/Utils/Monitor/MonitorRowStatus.d.mts +56 -0
- package/Utils/Monitor/MonitorRowStatus.d.ts +56 -0
- package/Utils/Monitor/MonitorRowStatus.js +189 -0
- package/Utils/Monitor/MonitorRowStatus.mjs +6 -0
- package/Utils/Monitor/MonitorSummarySnapshotUtil.js +3 -2
- package/Utils/Monitor/MonitorUptimeSummaryUtil.js +14 -3
- package/Utils/NetworkDevice/TransceiverHealthUtil.js +2 -2
- package/Utils/Profiles/ProfileFrames.js +11 -4
- package/Utils/Profiles/ProfileFunctionNames.d.mts +2 -0
- package/Utils/Profiles/ProfileFunctionNames.d.ts +2 -0
- package/Utils/Profiles/ProfileFunctionNames.js +104 -0
- package/Utils/Profiles/ProfileFunctionNames.mjs +3 -0
- package/Utils/Project/ProjectBalance.js +2 -2
- package/Utils/Project/TwilioAccount.d.mts +3 -0
- package/Utils/Project/TwilioAccount.d.ts +3 -0
- package/Utils/Project/TwilioAccount.js +58 -18
- package/Utils/Project/TwilioAccount.mjs +2 -0
- package/Utils/ResponseTooLarge.d.mts +5 -0
- package/Utils/ResponseTooLarge.d.ts +5 -0
- package/Utils/ResponseTooLarge.js +69 -0
- package/Utils/ResponseTooLarge.mjs +2 -0
- package/Utils/RetryAfter.d.mts +17 -0
- package/Utils/RetryAfter.d.ts +17 -0
- package/Utils/RetryAfter.js +251 -0
- package/Utils/RetryAfter.mjs +5 -0
- package/Utils/ScheduledMaintenanceStart.js +2 -3
- package/Utils/Schema/BaseSchema.d.mts +12 -5
- package/Utils/Schema/BaseSchema.d.ts +12 -5
- package/Utils/Schema/BaseSchema.js +43 -4
- package/Utils/Schema/BaseSchema.mjs +1 -0
- package/Utils/Schema/ModelSchema.d.mts +10 -0
- package/Utils/Schema/ModelSchema.d.ts +10 -0
- package/Utils/Schema/ModelSchema.js +251 -22
- package/Utils/Slo/SloMonthlyReport.d.mts +187 -0
- package/Utils/Slo/SloMonthlyReport.d.ts +187 -0
- package/Utils/Slo/SloMonthlyReport.js +945 -0
- package/Utils/Slo/SloMonthlyReport.mjs +35 -0
- package/Utils/Slo/SloOverviewText.js +7 -2
- package/Utils/Slo/SloProjection.js +2 -1
- package/Utils/Slo/SloUtil.d.mts +5 -0
- package/Utils/Slo/SloUtil.d.ts +5 -0
- package/Utils/Slo/SloUtil.js +5 -0
- package/Utils/Slo/SloWidgetFormat.js +3 -1
- package/Utils/StatusPage/FrozenMonitorResources.d.mts +30 -0
- package/Utils/StatusPage/FrozenMonitorResources.d.ts +30 -0
- package/Utils/StatusPage/FrozenMonitorResources.js +147 -12
- package/Utils/StatusPage/FrozenMonitorResources.mjs +2 -0
- package/Utils/StatusPage/GroupNestingLayout.js +3 -2
- package/Utils/StatusPage/HistoryChartBarColors.d.mts +2 -0
- package/Utils/StatusPage/HistoryChartBarColors.d.ts +2 -0
- package/Utils/StatusPage/HistoryChartBarColors.js +15 -1
- package/Utils/StatusPage/HistoryChartBarColors.mjs +2 -0
- package/Utils/StatusPage/Report.js +12 -4
- package/Utils/StatusPage/ReportText.d.mts +4 -0
- package/Utils/StatusPage/ReportText.d.ts +4 -0
- package/Utils/StatusPage/ReportText.js +22 -2
- package/Utils/StatusPage/ReportText.mjs +1 -0
- package/Utils/StatusPage/ResourceUptime.js +32 -25
- package/Utils/StatusPage/UptimeDailyAggregateUtil.js +17 -3
- package/Utils/Syslog/SyslogMessageParser.d.mts +25 -0
- package/Utils/Syslog/SyslogMessageParser.d.ts +25 -0
- package/Utils/Syslog/SyslogMessageParser.js +428 -100
- package/Utils/Syslog/SyslogMessageParser.mjs +3 -0
- package/Utils/Syslog/SyslogRawCopies.d.mts +20 -0
- package/Utils/Syslog/SyslogRawCopies.d.ts +20 -0
- package/Utils/Syslog/SyslogRawCopies.js +283 -0
- package/Utils/Syslog/SyslogRawCopies.mjs +2 -0
- package/Utils/Telemetry/CorrelationIdAttributes.d.mts +8 -0
- package/Utils/Telemetry/CorrelationIdAttributes.d.ts +8 -0
- package/Utils/Telemetry/CorrelationIdAttributes.js +118 -0
- package/Utils/Telemetry/CorrelationIdAttributes.mjs +5 -0
- package/Utils/Telemetry/ScrubJsonKeys.d.mts +11 -0
- package/Utils/Telemetry/ScrubJsonKeys.d.ts +11 -0
- package/Utils/Telemetry/ScrubJsonKeys.js +505 -0
- package/Utils/Telemetry/ScrubJsonKeys.mjs +2 -0
- package/Utils/Telemetry/ScrubJsonText.d.mts +25 -0
- package/Utils/Telemetry/ScrubJsonText.d.ts +25 -0
- package/Utils/Telemetry/ScrubJsonText.js +568 -0
- package/Utils/Telemetry/ScrubJsonText.mjs +4 -0
- package/Utils/Telemetry/ScrubMask.d.mts +1 -0
- package/Utils/Telemetry/ScrubMask.d.ts +1 -0
- package/Utils/Telemetry/ScrubMask.js +54 -0
- package/Utils/Telemetry/ScrubMask.mjs +2 -0
- package/Utils/Telemetry/ScrubNestedValues.d.mts +5 -2
- package/Utils/Telemetry/ScrubNestedValues.d.ts +5 -2
- package/Utils/Telemetry/ScrubNestedValues.js +56 -9
- package/Utils/Uptime/DayUptimeGraphUtil.d.mts +17 -0
- package/Utils/Uptime/DayUptimeGraphUtil.d.ts +17 -0
- package/Utils/Uptime/DayUptimeGraphUtil.js +91 -3
- package/Utils/Uptime/DayUptimeGraphUtil.mjs +1 -0
- package/Utils/Uptime/TimeBeforeFirstCheck.d.mts +11 -0
- package/Utils/Uptime/TimeBeforeFirstCheck.d.ts +11 -0
- package/Utils/Uptime/TimeBeforeFirstCheck.js +188 -0
- package/Utils/Uptime/TimeBeforeFirstCheck.mjs +2 -0
- package/package.json +1 -1
- package/Models/DatabaseModels/GreenlockCertificate.d.mts +0 -10
- package/Models/DatabaseModels/GreenlockCertificate.d.ts +0 -10
- package/Models/DatabaseModels/GreenlockCertificate.js +0 -143
- package/Models/DatabaseModels/GreenlockCertificate.mjs +0 -2
- package/Models/DatabaseModels/GreenlockChallenge.d.mts +0 -10
- package/Models/DatabaseModels/GreenlockChallenge.d.ts +0 -10
- package/Models/DatabaseModels/GreenlockChallenge.js +0 -144
- package/Models/DatabaseModels/GreenlockChallenge.mjs +0 -2
- package/Types/SampleProject/SampleProject.d.mts +0 -54
- package/Types/SampleProject/SampleProject.d.ts +0 -54
- package/Types/SampleProject/SampleProject.js +0 -177
- package/Types/SampleProject/SampleProject.mjs +0 -22
- package/Types/SampleProject/SampleProjectContent.d.mts +0 -127
- package/Types/SampleProject/SampleProjectContent.d.ts +0 -127
- package/Types/SampleProject/SampleProjectContent.js +0 -397
- package/Types/SampleProject/SampleProjectContent.mjs +0 -18
|
@@ -0,0 +1,945 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.getSloMonthlyReportFilename = exports.buildSloMonthlyReportCsv = exports.toSloCsvField = exports.parseSloMonthlyReport = exports.sloMonthlyReportToJSON = exports.getSloMonthlyReportSummary = exports.buildUnavailableSloMonthlyReport = exports.buildSloMonthlyReport = exports.getSloMonthlyReportUnit = exports.judgeSloMonthlyFigures = exports.getSloMonthVerdict = exports.getSloErrorBudgetUsedPercentage = exports.isValidSloTargetPercentage = exports.computeMonitorUptimeMonthlyFigures = exports.sumSloMonthlyFigures = exports.getRequestMonthlyFigures = exports.getTimelinesInMonth = exports.getSloReportMonths = exports.getSloMonthlyReportTimezone = exports.isSameSloMonthlyReportPeriod = exports.getSloMonthlyReportPeriodQuery = exports.parseSloMonthlyReportPeriod = exports.SLO_MONTHLY_REPORT_OPTION_ERRORS = exports.SLO_MONTHLY_REPORT_UNAVAILABLE_MESSAGES = exports.SloMonthlyReportUnavailableReason = exports.SloMonthVerdict = exports.SloMonthlyReportUnit = exports.SloMonthlyReportPeriodKind = exports.SLO_MONTHLY_REPORT_DEFAULT_TIMEZONE = exports.SLO_MONTHLY_REPORT_EARLIEST_YEAR = exports.SLO_MONTHLY_REPORT_MAX_MONTHS = exports.SLO_MONTHLY_REPORT_DEFAULT_MONTHS = exports.SLO_MONTHLY_REPORT_MONTH_CHOICES = exports.SLO_MONTHLY_REPORT_ROUTE = void 0;
|
|
40
|
+
const Date_1 = __importStar(require("../../Types/Date"));
|
|
41
|
+
const BadDataException_1 = __importDefault(require("../../Types/Exception/BadDataException"));
|
|
42
|
+
const SliType_1 = __importDefault(require("../../Types/ServiceLevelObjective/SliType"));
|
|
43
|
+
const SloMultiMonitorMode_1 = __importDefault(require("../../Types/ServiceLevelObjective/SloMultiMonitorMode"));
|
|
44
|
+
const SloRequestSli_1 = require("./SloRequestSli");
|
|
45
|
+
const SloUtil_1 = __importDefault(require("./SloUtil"));
|
|
46
|
+
/*
|
|
47
|
+
* AN SLO'S MONTHLY REPORT: how the SLO did in each calendar month of a
|
|
48
|
+
* period - the last few months, or one calendar year - and over the whole
|
|
49
|
+
* period, the months in the SLO's own timezone (UTC when it has none).
|
|
50
|
+
*
|
|
51
|
+
* GET /service-level-objective/:id/monthly-report?months=12
|
|
52
|
+
* GET /service-level-objective/:id/monthly-report?year=2025
|
|
53
|
+
*
|
|
54
|
+
* Nothing is stored for it. A Monitor Uptime SLO's months are worked out
|
|
55
|
+
* from its monitors' status timelines, which OneUptime keeps for as long as
|
|
56
|
+
* the monitors exist, exactly as the evaluation worker measures a window
|
|
57
|
+
* (SloUtil.computeTimeSli): so a report reaches back before the SLO was
|
|
58
|
+
* created, and a status timeline edited later is reflected the next time
|
|
59
|
+
* the report is read. A request SLO's months are summed from the request
|
|
60
|
+
* counts the worker keeps in SloHistory (400 days), from where the current
|
|
61
|
+
* counting starts (firstAccumulatedBucketStartAt) - and so are a Metric
|
|
62
|
+
* SLO's, from the good and total events of its metric that the worker keeps
|
|
63
|
+
* the same way. Each month is measured
|
|
64
|
+
* against the SLO's monitors, services, downtime statuses and target as
|
|
65
|
+
* they are now.
|
|
66
|
+
*
|
|
67
|
+
* Each month says:
|
|
68
|
+
*
|
|
69
|
+
* - its SLI, UNROUNDED (null when nothing was measured in it);
|
|
70
|
+
* - what it was measured over: seconds (`total`) and the seconds counted
|
|
71
|
+
* as downtime (`bad`) for monitors, requests and bad requests for a
|
|
72
|
+
* request SLO;
|
|
73
|
+
* - how much of its error budget it used;
|
|
74
|
+
* - its verdict: Met or Missed once the month is over. The month still
|
|
75
|
+
* running is On Track or Below Target - and Missed as soon as its
|
|
76
|
+
* downtime is more than the whole month allows, which no later uptime
|
|
77
|
+
* can undo.
|
|
78
|
+
*
|
|
79
|
+
* The total is the period measured as one: its seconds and bad seconds are
|
|
80
|
+
* the months' sums (the months split the period, so this is the period's
|
|
81
|
+
* own SLI), judged as the months are.
|
|
82
|
+
*
|
|
83
|
+
* Isomorphic (no server imports): the server builds the report
|
|
84
|
+
* (Server/Utils/Slo/SloMonthlyReportMeasurement), the Dashboard reads it
|
|
85
|
+
* back with parseSloMonthlyReport and downloads it with
|
|
86
|
+
* buildSloMonthlyReportCsv, and a test can drive every rule here without a
|
|
87
|
+
* database.
|
|
88
|
+
*/
|
|
89
|
+
exports.SLO_MONTHLY_REPORT_ROUTE = "/monthly-report";
|
|
90
|
+
// The months the Dashboard offers, and the period it opens on.
|
|
91
|
+
exports.SLO_MONTHLY_REPORT_MONTH_CHOICES = [
|
|
92
|
+
3, 6, 9, 12,
|
|
93
|
+
];
|
|
94
|
+
exports.SLO_MONTHLY_REPORT_DEFAULT_MONTHS = 12;
|
|
95
|
+
/*
|
|
96
|
+
* The most months one "last months" report covers: two years. A request
|
|
97
|
+
* SLO's counts are kept for 400 days, so its older months read as no data.
|
|
98
|
+
*/
|
|
99
|
+
exports.SLO_MONTHLY_REPORT_MAX_MONTHS = 24;
|
|
100
|
+
// The earliest calendar year a report may be asked for.
|
|
101
|
+
exports.SLO_MONTHLY_REPORT_EARLIEST_YEAR = 2000;
|
|
102
|
+
exports.SLO_MONTHLY_REPORT_DEFAULT_TIMEZONE = "UTC";
|
|
103
|
+
var SloMonthlyReportPeriodKind;
|
|
104
|
+
(function (SloMonthlyReportPeriodKind) {
|
|
105
|
+
// The months ending with the current one: "months=6".
|
|
106
|
+
SloMonthlyReportPeriodKind["LastMonths"] = "LastMonths";
|
|
107
|
+
// One calendar year, January to December: "year=2025".
|
|
108
|
+
SloMonthlyReportPeriodKind["Year"] = "Year";
|
|
109
|
+
})(SloMonthlyReportPeriodKind || (exports.SloMonthlyReportPeriodKind = SloMonthlyReportPeriodKind = {}));
|
|
110
|
+
// What a report's figures count.
|
|
111
|
+
var SloMonthlyReportUnit;
|
|
112
|
+
(function (SloMonthlyReportUnit) {
|
|
113
|
+
// Monitor Uptime: seconds measured, and the seconds counted as downtime.
|
|
114
|
+
SloMonthlyReportUnit["Seconds"] = "Seconds";
|
|
115
|
+
// Request Success and Request Latency: requests, and the bad ones.
|
|
116
|
+
SloMonthlyReportUnit["Requests"] = "Requests";
|
|
117
|
+
// Metric: the events of its counter or histogram, and the bad ones.
|
|
118
|
+
SloMonthlyReportUnit["Events"] = "Events";
|
|
119
|
+
})(SloMonthlyReportUnit || (exports.SloMonthlyReportUnit = SloMonthlyReportUnit = {}));
|
|
120
|
+
var SloMonthVerdict;
|
|
121
|
+
(function (SloMonthVerdict) {
|
|
122
|
+
// A month that is over, at or above the target.
|
|
123
|
+
SloMonthVerdict["Met"] = "Met";
|
|
124
|
+
// Below the target - or, while the month runs, already past what it allows.
|
|
125
|
+
SloMonthVerdict["Missed"] = "Missed";
|
|
126
|
+
// The month still running, at or above the target so far.
|
|
127
|
+
SloMonthVerdict["OnTrack"] = "OnTrack";
|
|
128
|
+
// The month still running, below the target so far.
|
|
129
|
+
SloMonthVerdict["BelowTarget"] = "BelowTarget";
|
|
130
|
+
// Nothing was measured: no monitor data, or no request counted.
|
|
131
|
+
SloMonthVerdict["NoData"] = "NoData";
|
|
132
|
+
})(SloMonthVerdict || (exports.SloMonthVerdict = SloMonthVerdict = {}));
|
|
133
|
+
/*
|
|
134
|
+
* Why a report holds no months: the SLO measures nothing OneUptime can
|
|
135
|
+
* report on yet. The Dashboard says each in the reader's words; the API
|
|
136
|
+
* carries the English sentence beside the code
|
|
137
|
+
* (SLO_MONTHLY_REPORT_UNAVAILABLE_MESSAGES).
|
|
138
|
+
*/
|
|
139
|
+
var SloMonthlyReportUnavailableReason;
|
|
140
|
+
(function (SloMonthlyReportUnavailableReason) {
|
|
141
|
+
SloMonthlyReportUnavailableReason["NoMonitors"] = "NoMonitors";
|
|
142
|
+
SloMonthlyReportUnavailableReason["NoServices"] = "NoServices";
|
|
143
|
+
SloMonthlyReportUnavailableReason["NoServicesForMetric"] = "NoServicesForMetric";
|
|
144
|
+
SloMonthlyReportUnavailableReason["NoMetric"] = "NoMetric";
|
|
145
|
+
SloMonthlyReportUnavailableReason["NoLatencyThreshold"] = "NoLatencyThreshold";
|
|
146
|
+
SloMonthlyReportUnavailableReason["NotMeasured"] = "NotMeasured";
|
|
147
|
+
SloMonthlyReportUnavailableReason["TargetOutOfRange"] = "TargetOutOfRange";
|
|
148
|
+
})(SloMonthlyReportUnavailableReason || (exports.SloMonthlyReportUnavailableReason = SloMonthlyReportUnavailableReason = {}));
|
|
149
|
+
exports.SLO_MONTHLY_REPORT_UNAVAILABLE_MESSAGES = {
|
|
150
|
+
[SloMonthlyReportUnavailableReason.NoMonitors]: "No monitors are attached to this SLO, so there is nothing to report. Attach monitors, or add a monitor rule, first.",
|
|
151
|
+
[SloMonthlyReportUnavailableReason.NoServices]: "This SLO measures requests, but no services are chosen, so there is nothing to report. Choose the services whose requests it measures first.",
|
|
152
|
+
[SloMonthlyReportUnavailableReason.NoServicesForMetric]: "This SLO measures a metric, but no services are chosen, so there is nothing to report. Choose the services whose metric it measures first.",
|
|
153
|
+
[SloMonthlyReportUnavailableReason.NoMetric]: "This Metric SLO has no metric it can count, so there is nothing to report. Choose its metric, and how its good events are told apart, first.",
|
|
154
|
+
[SloMonthlyReportUnavailableReason.NoLatencyThreshold]: "This Request Latency SLO has no latency threshold, so no request can be counted as fast enough. Set its latency threshold first.",
|
|
155
|
+
[SloMonthlyReportUnavailableReason.NotMeasured]: "OneUptime does not measure this SLO's SLI type, so there is nothing to report. Choose Monitor Uptime, Request Success, Request Latency or Metric.",
|
|
156
|
+
[SloMonthlyReportUnavailableReason.TargetOutOfRange]: "This SLO's target is outside the valid range - it must be greater than 0 and below 100 - so no month can be judged against it. Set a target such as 99.9 first.",
|
|
157
|
+
};
|
|
158
|
+
exports.SLO_MONTHLY_REPORT_OPTION_ERRORS = {
|
|
159
|
+
months: `The months option must be a whole number from 1 to ${exports.SLO_MONTHLY_REPORT_MAX_MONTHS}: how many months the report covers, ending with the current month.`,
|
|
160
|
+
year: `The year option must be a calendar year from ${exports.SLO_MONTHLY_REPORT_EARLIEST_YEAR} to this year, such as 2025.`,
|
|
161
|
+
both: "Ask for either months or year, not both: months covers the last few months, and year one calendar year.",
|
|
162
|
+
};
|
|
163
|
+
// ---- The period ------------------------------------------------------------
|
|
164
|
+
// Named, because eslint's wrap-regex and prettier fight over a bare literal.
|
|
165
|
+
const WHOLE_NUMBER_PATTERN = /^\s*\d+\s*$/;
|
|
166
|
+
const readWholeNumber = (value) => {
|
|
167
|
+
if (typeof value === "number") {
|
|
168
|
+
return Number.isInteger(value) ? value : null;
|
|
169
|
+
}
|
|
170
|
+
if (typeof value !== "string" || !WHOLE_NUMBER_PATTERN.test(value)) {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
return parseInt(value.trim(), 10);
|
|
174
|
+
};
|
|
175
|
+
const isGiven = (value) => {
|
|
176
|
+
return value !== undefined && value !== null && value !== "";
|
|
177
|
+
};
|
|
178
|
+
/*
|
|
179
|
+
* The period a request asks for: `months` (1 to 24, the current month
|
|
180
|
+
* included) or `year` (a calendar year), from a query string or a JSON
|
|
181
|
+
* body. Neither gives the Dashboard's default, the last 12 months. A value
|
|
182
|
+
* that is not one of those is refused with what to send instead.
|
|
183
|
+
*/
|
|
184
|
+
const parseSloMonthlyReportPeriod = (data) => {
|
|
185
|
+
const hasMonths = isGiven(data.months);
|
|
186
|
+
const hasYear = isGiven(data.year);
|
|
187
|
+
if (hasMonths && hasYear) {
|
|
188
|
+
throw new BadDataException_1.default(exports.SLO_MONTHLY_REPORT_OPTION_ERRORS.both);
|
|
189
|
+
}
|
|
190
|
+
if (hasYear) {
|
|
191
|
+
const year = readWholeNumber(data.year);
|
|
192
|
+
/*
|
|
193
|
+
* One year past the current UTC year is allowed: in a timezone ahead of
|
|
194
|
+
* UTC, the new year starts a few hours before it does in UTC.
|
|
195
|
+
*/
|
|
196
|
+
if (year === null ||
|
|
197
|
+
year < exports.SLO_MONTHLY_REPORT_EARLIEST_YEAR ||
|
|
198
|
+
year > data.now.getUTCFullYear() + 1) {
|
|
199
|
+
throw new BadDataException_1.default(exports.SLO_MONTHLY_REPORT_OPTION_ERRORS.year);
|
|
200
|
+
}
|
|
201
|
+
return { kind: SloMonthlyReportPeriodKind.Year, year: year };
|
|
202
|
+
}
|
|
203
|
+
if (!hasMonths) {
|
|
204
|
+
return {
|
|
205
|
+
kind: SloMonthlyReportPeriodKind.LastMonths,
|
|
206
|
+
months: exports.SLO_MONTHLY_REPORT_DEFAULT_MONTHS,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
const months = readWholeNumber(data.months);
|
|
210
|
+
if (months === null || months < 1 || months > exports.SLO_MONTHLY_REPORT_MAX_MONTHS) {
|
|
211
|
+
throw new BadDataException_1.default(exports.SLO_MONTHLY_REPORT_OPTION_ERRORS.months);
|
|
212
|
+
}
|
|
213
|
+
return { kind: SloMonthlyReportPeriodKind.LastMonths, months: months };
|
|
214
|
+
};
|
|
215
|
+
exports.parseSloMonthlyReportPeriod = parseSloMonthlyReportPeriod;
|
|
216
|
+
/*
|
|
217
|
+
* The period as a query string's values, as the API reads them back:
|
|
218
|
+
* { months: "6" } or { year: "2025" }.
|
|
219
|
+
*/
|
|
220
|
+
const getSloMonthlyReportPeriodQuery = (period) => {
|
|
221
|
+
if (period.kind === SloMonthlyReportPeriodKind.Year) {
|
|
222
|
+
return { year: period.year.toString() };
|
|
223
|
+
}
|
|
224
|
+
return { months: period.months.toString() };
|
|
225
|
+
};
|
|
226
|
+
exports.getSloMonthlyReportPeriodQuery = getSloMonthlyReportPeriodQuery;
|
|
227
|
+
const isSameSloMonthlyReportPeriod = (a, b) => {
|
|
228
|
+
if (a.kind === SloMonthlyReportPeriodKind.Year) {
|
|
229
|
+
return b.kind === SloMonthlyReportPeriodKind.Year && a.year === b.year;
|
|
230
|
+
}
|
|
231
|
+
return (b.kind === SloMonthlyReportPeriodKind.LastMonths && a.months === b.months);
|
|
232
|
+
};
|
|
233
|
+
exports.isSameSloMonthlyReportPeriod = isSameSloMonthlyReportPeriod;
|
|
234
|
+
/*
|
|
235
|
+
* The zone a report's months are cut in: the SLO's own (what its Calendar
|
|
236
|
+
* Month window uses), or UTC when it has none - or names one this server
|
|
237
|
+
* does not know, which would otherwise leave every month undefined.
|
|
238
|
+
*/
|
|
239
|
+
const getSloMonthlyReportTimezone = (timezone) => {
|
|
240
|
+
const trimmed = (timezone || "").trim();
|
|
241
|
+
if (trimmed && Date_1.Moment.tz.zone(trimmed)) {
|
|
242
|
+
return trimmed;
|
|
243
|
+
}
|
|
244
|
+
return exports.SLO_MONTHLY_REPORT_DEFAULT_TIMEZONE;
|
|
245
|
+
};
|
|
246
|
+
exports.getSloMonthlyReportTimezone = getSloMonthlyReportTimezone;
|
|
247
|
+
/*
|
|
248
|
+
* The calendar months of a period, oldest first, in the timezone: the last
|
|
249
|
+
* `months` months ending with the one `now` is in, or January to December
|
|
250
|
+
* of a year - without the months that have not started yet. The month `now`
|
|
251
|
+
* is in is the month to date.
|
|
252
|
+
*/
|
|
253
|
+
const getSloReportMonths = (data) => {
|
|
254
|
+
const timezone = (0, exports.getSloMonthlyReportTimezone)(data.timezone);
|
|
255
|
+
const nowTime = data.now.getTime();
|
|
256
|
+
let firstMonth;
|
|
257
|
+
let count;
|
|
258
|
+
if (data.period.kind === SloMonthlyReportPeriodKind.Year) {
|
|
259
|
+
firstMonth = Date_1.Moment.tz({ year: data.period.year, month: 0, date: 1 }, timezone).startOf("month");
|
|
260
|
+
count = 12;
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
count = Math.max(1, Math.floor(data.period.months));
|
|
264
|
+
firstMonth = Date_1.Moment.tz(data.now, timezone)
|
|
265
|
+
.startOf("month")
|
|
266
|
+
.subtract(count - 1, "months");
|
|
267
|
+
}
|
|
268
|
+
const months = [];
|
|
269
|
+
for (let index = 0; index < count; index++) {
|
|
270
|
+
const start = firstMonth
|
|
271
|
+
.clone()
|
|
272
|
+
.add(index, "months");
|
|
273
|
+
if (start.valueOf() > nowTime) {
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
const end = start.clone().add(1, "month");
|
|
277
|
+
months.push({
|
|
278
|
+
startDate: start.toDate(),
|
|
279
|
+
endDate: end.toDate(),
|
|
280
|
+
isMonthToDate: end.valueOf() > nowTime,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
return months;
|
|
284
|
+
};
|
|
285
|
+
exports.getSloReportMonths = getSloReportMonths;
|
|
286
|
+
// ---- Measuring -------------------------------------------------------------
|
|
287
|
+
const NO_FIGURES = {
|
|
288
|
+
total: 0,
|
|
289
|
+
bad: 0,
|
|
290
|
+
sliPercentage: null,
|
|
291
|
+
};
|
|
292
|
+
const toTime = (value) => {
|
|
293
|
+
if (!value) {
|
|
294
|
+
return NaN;
|
|
295
|
+
}
|
|
296
|
+
return Date_1.default.fromString(value).getTime();
|
|
297
|
+
};
|
|
298
|
+
/*
|
|
299
|
+
* The rows of a monitor's status timeline that hold time inside the month:
|
|
300
|
+
* started before it ends, and ended after it starts or still open. Strict
|
|
301
|
+
* on both sides, so a row that only touches the month - one that starts the
|
|
302
|
+
* instant the next month does - is no data for it: SloUtil reads a window
|
|
303
|
+
* whose rows hold none of its time as up from start to end.
|
|
304
|
+
*/
|
|
305
|
+
const getTimelinesInMonth = (timelines, month) => {
|
|
306
|
+
const start = month.startDate.getTime();
|
|
307
|
+
const end = month.endDate.getTime();
|
|
308
|
+
return timelines.filter((timeline) => {
|
|
309
|
+
const startsAt = toTime(timeline.startsAt);
|
|
310
|
+
if (!Number.isFinite(startsAt) || startsAt >= end) {
|
|
311
|
+
return false;
|
|
312
|
+
}
|
|
313
|
+
if (!timeline.endsAt) {
|
|
314
|
+
return true;
|
|
315
|
+
}
|
|
316
|
+
return toTime(timeline.endsAt) > start;
|
|
317
|
+
});
|
|
318
|
+
};
|
|
319
|
+
exports.getTimelinesInMonth = getTimelinesInMonth;
|
|
320
|
+
const toTimeFigures = (result) => {
|
|
321
|
+
if (result.totalSeconds <= 0) {
|
|
322
|
+
return { ...NO_FIGURES };
|
|
323
|
+
}
|
|
324
|
+
return {
|
|
325
|
+
total: result.totalSeconds,
|
|
326
|
+
bad: result.badSeconds,
|
|
327
|
+
sliPercentage: result.sliPercentage,
|
|
328
|
+
};
|
|
329
|
+
};
|
|
330
|
+
/*
|
|
331
|
+
* The figures of a set of counts: requests counted, the bad ones, and their
|
|
332
|
+
* SLI - none when nothing was counted.
|
|
333
|
+
*/
|
|
334
|
+
const getRequestMonthlyFigures = (counts) => {
|
|
335
|
+
const sli = (0, SloRequestSli_1.computeEventSli)(counts);
|
|
336
|
+
if (sli.totalEventCount <= 0) {
|
|
337
|
+
return { ...NO_FIGURES };
|
|
338
|
+
}
|
|
339
|
+
return {
|
|
340
|
+
total: sli.totalEventCount,
|
|
341
|
+
bad: sli.badEventCount,
|
|
342
|
+
sliPercentage: sli.sliPercentage,
|
|
343
|
+
};
|
|
344
|
+
};
|
|
345
|
+
exports.getRequestMonthlyFigures = getRequestMonthlyFigures;
|
|
346
|
+
/*
|
|
347
|
+
* The figures of several months together: their sums, and the SLI of the
|
|
348
|
+
* sums - the period's own, since the months split it.
|
|
349
|
+
*/
|
|
350
|
+
const sumSloMonthlyFigures = (figures) => {
|
|
351
|
+
let total = 0;
|
|
352
|
+
let bad = 0;
|
|
353
|
+
for (const month of figures) {
|
|
354
|
+
if (month.sliPercentage === null || month.total <= 0) {
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
total += month.total;
|
|
358
|
+
bad += month.bad;
|
|
359
|
+
}
|
|
360
|
+
if (total <= 0) {
|
|
361
|
+
return { ...NO_FIGURES };
|
|
362
|
+
}
|
|
363
|
+
return {
|
|
364
|
+
total: total,
|
|
365
|
+
bad: bad,
|
|
366
|
+
sliPercentage: ((total - bad) / total) * 100,
|
|
367
|
+
};
|
|
368
|
+
};
|
|
369
|
+
exports.sumSloMonthlyFigures = sumSloMonthlyFigures;
|
|
370
|
+
/*
|
|
371
|
+
* A Monitor Uptime SLO's months, measured as the evaluation worker measures
|
|
372
|
+
* a window (SloUtil.computeTimeSli): the SLO's monitors combined by its
|
|
373
|
+
* multi-monitor mode, and each monitor alone for the breakdown. The
|
|
374
|
+
* timelines are those of the whole period; each month reads only its own
|
|
375
|
+
* rows, so a month before a monitor had data is no data rather than up.
|
|
376
|
+
*/
|
|
377
|
+
const computeMonitorUptimeMonthlyFigures = (data) => {
|
|
378
|
+
const sloMonths = [];
|
|
379
|
+
const monitors = data.perMonitorTimelines.map((monitor) => {
|
|
380
|
+
return { monitorId: monitor.monitorId, months: [] };
|
|
381
|
+
});
|
|
382
|
+
for (const month of data.months) {
|
|
383
|
+
const window = {
|
|
384
|
+
startDate: month.startDate,
|
|
385
|
+
endDate: month.endDate,
|
|
386
|
+
};
|
|
387
|
+
const monthTimelines = data.perMonitorTimelines.map((monitor) => {
|
|
388
|
+
return {
|
|
389
|
+
monitorId: monitor.monitorId,
|
|
390
|
+
timelines: (0, exports.getTimelinesInMonth)(monitor.timelines, window),
|
|
391
|
+
};
|
|
392
|
+
});
|
|
393
|
+
sloMonths.push(toTimeFigures(SloUtil_1.default.computeTimeSli({
|
|
394
|
+
perMonitorTimelines: monthTimelines,
|
|
395
|
+
downtimeStatuses: data.downtimeStatuses,
|
|
396
|
+
window: window,
|
|
397
|
+
mode: data.mode,
|
|
398
|
+
})));
|
|
399
|
+
monthTimelines.forEach((monitorTimelines, index) => {
|
|
400
|
+
monitors[index].months.push(toTimeFigures(SloUtil_1.default.computeTimeSli({
|
|
401
|
+
perMonitorTimelines: [monitorTimelines],
|
|
402
|
+
downtimeStatuses: data.downtimeStatuses,
|
|
403
|
+
window: window,
|
|
404
|
+
mode: SloMultiMonitorMode_1.default.AnyDown,
|
|
405
|
+
})));
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
return { months: sloMonths, monitors: monitors };
|
|
409
|
+
};
|
|
410
|
+
exports.computeMonitorUptimeMonthlyFigures = computeMonitorUptimeMonthlyFigures;
|
|
411
|
+
// ---- Judging -----------------------------------------------------------------
|
|
412
|
+
const isValidSloTargetPercentage = (targetPercentage) => {
|
|
413
|
+
return (typeof targetPercentage === "number" &&
|
|
414
|
+
Number.isFinite(targetPercentage) &&
|
|
415
|
+
targetPercentage > 0 &&
|
|
416
|
+
targetPercentage < 100);
|
|
417
|
+
};
|
|
418
|
+
exports.isValidSloTargetPercentage = isValidSloTargetPercentage;
|
|
419
|
+
/*
|
|
420
|
+
* The share of the error budget a month used: its bad seconds or requests
|
|
421
|
+
* against the bad ones the target allows over `budgetBase` - what it was
|
|
422
|
+
* measured over, or, for a month still running measured in seconds, that
|
|
423
|
+
* plus the seconds left in it.
|
|
424
|
+
*/
|
|
425
|
+
const getSloErrorBudgetUsedPercentage = (data) => {
|
|
426
|
+
var _a;
|
|
427
|
+
if (data.figures.sliPercentage === null ||
|
|
428
|
+
data.figures.total <= 0 ||
|
|
429
|
+
!(0, exports.isValidSloTargetPercentage)(data.targetPercentage)) {
|
|
430
|
+
return null;
|
|
431
|
+
}
|
|
432
|
+
const base = Math.max(data.figures.total, (_a = data.budgetBase) !== null && _a !== void 0 ? _a : data.figures.total);
|
|
433
|
+
const allowedBad = (1 - data.targetPercentage / 100) * base;
|
|
434
|
+
return (data.figures.bad / allowedBad) * 100;
|
|
435
|
+
};
|
|
436
|
+
exports.getSloErrorBudgetUsedPercentage = getSloErrorBudgetUsedPercentage;
|
|
437
|
+
/*
|
|
438
|
+
* A month's verdict, from UNROUNDED figures. Over: Met or Missed. Still
|
|
439
|
+
* running: Missed once its error budget for the whole month is spent (only
|
|
440
|
+
* a month measured in seconds knows its whole budget - requests still to
|
|
441
|
+
* come can always lift a request SLO's month), else On Track or Below
|
|
442
|
+
* Target by its SLI so far.
|
|
443
|
+
*/
|
|
444
|
+
const getSloMonthVerdict = (data) => {
|
|
445
|
+
if (data.sliPercentage === null ||
|
|
446
|
+
!(0, exports.isValidSloTargetPercentage)(data.targetPercentage)) {
|
|
447
|
+
return SloMonthVerdict.NoData;
|
|
448
|
+
}
|
|
449
|
+
const isAtOrAboveTarget = data.sliPercentage >= data.targetPercentage;
|
|
450
|
+
if (!data.isMonthToDate) {
|
|
451
|
+
return isAtOrAboveTarget ? SloMonthVerdict.Met : SloMonthVerdict.Missed;
|
|
452
|
+
}
|
|
453
|
+
if (typeof data.wholeMonthBudgetUsedPercentage === "number" &&
|
|
454
|
+
data.wholeMonthBudgetUsedPercentage > 100) {
|
|
455
|
+
return SloMonthVerdict.Missed;
|
|
456
|
+
}
|
|
457
|
+
return isAtOrAboveTarget
|
|
458
|
+
? SloMonthVerdict.OnTrack
|
|
459
|
+
: SloMonthVerdict.BelowTarget;
|
|
460
|
+
};
|
|
461
|
+
exports.getSloMonthVerdict = getSloMonthVerdict;
|
|
462
|
+
// Seconds still to come in a month, or none once it is over.
|
|
463
|
+
const getSecondsLeft = (endDate, now) => {
|
|
464
|
+
return Math.max(0, (endDate.getTime() - now.getTime()) / 1000);
|
|
465
|
+
};
|
|
466
|
+
/*
|
|
467
|
+
* Figures judged: their error budget used and their verdict. A period that
|
|
468
|
+
* runs into the current month is judged as that month is, with the seconds
|
|
469
|
+
* still to come in it added to its budget.
|
|
470
|
+
*/
|
|
471
|
+
const judgeSloMonthlyFigures = (data) => {
|
|
472
|
+
const isSeconds = data.unit === SloMonthlyReportUnit.Seconds;
|
|
473
|
+
const budgetBase = data.isMonthToDate && isSeconds
|
|
474
|
+
? data.figures.total + data.secondsLeft
|
|
475
|
+
: undefined;
|
|
476
|
+
const errorBudgetUsedPercentage = (0, exports.getSloErrorBudgetUsedPercentage)({
|
|
477
|
+
figures: data.figures,
|
|
478
|
+
targetPercentage: data.targetPercentage,
|
|
479
|
+
budgetBase: budgetBase,
|
|
480
|
+
});
|
|
481
|
+
return {
|
|
482
|
+
...data.figures,
|
|
483
|
+
errorBudgetUsedPercentage: errorBudgetUsedPercentage,
|
|
484
|
+
verdict: (0, exports.getSloMonthVerdict)({
|
|
485
|
+
sliPercentage: data.figures.sliPercentage,
|
|
486
|
+
targetPercentage: data.targetPercentage,
|
|
487
|
+
isMonthToDate: data.isMonthToDate,
|
|
488
|
+
wholeMonthBudgetUsedPercentage: isSeconds
|
|
489
|
+
? errorBudgetUsedPercentage
|
|
490
|
+
: null,
|
|
491
|
+
}),
|
|
492
|
+
};
|
|
493
|
+
};
|
|
494
|
+
exports.judgeSloMonthlyFigures = judgeSloMonthlyFigures;
|
|
495
|
+
const getSloMonthlyReportUnit = (sliType) => {
|
|
496
|
+
if ((0, SloRequestSli_1.isRequestSliType)(sliType)) {
|
|
497
|
+
return SloMonthlyReportUnit.Requests;
|
|
498
|
+
}
|
|
499
|
+
if (sliType === SliType_1.default.Metric) {
|
|
500
|
+
return SloMonthlyReportUnit.Events;
|
|
501
|
+
}
|
|
502
|
+
return SloMonthlyReportUnit.Seconds;
|
|
503
|
+
};
|
|
504
|
+
exports.getSloMonthlyReportUnit = getSloMonthlyReportUnit;
|
|
505
|
+
/*
|
|
506
|
+
* A report from its months' figures: each month and the total judged, and
|
|
507
|
+
* each monitor's breakdown judged and sorted worst total first (by name
|
|
508
|
+
* between equals), so the monitor that cost the SLO most heads the list.
|
|
509
|
+
*/
|
|
510
|
+
const buildSloMonthlyReport = (data) => {
|
|
511
|
+
const unit = (0, exports.getSloMonthlyReportUnit)(data.sliType);
|
|
512
|
+
const monthToDate = data.months.find((month) => {
|
|
513
|
+
return month.isMonthToDate;
|
|
514
|
+
});
|
|
515
|
+
const secondsLeftInPeriod = monthToDate
|
|
516
|
+
? getSecondsLeft(monthToDate.endDate, data.now)
|
|
517
|
+
: 0;
|
|
518
|
+
const judgeMonths = (figures) => {
|
|
519
|
+
return data.months.map((month, index) => {
|
|
520
|
+
return (0, exports.judgeSloMonthlyFigures)({
|
|
521
|
+
figures: figures[index] || { ...NO_FIGURES },
|
|
522
|
+
targetPercentage: data.targetPercentage,
|
|
523
|
+
unit: unit,
|
|
524
|
+
isMonthToDate: month.isMonthToDate,
|
|
525
|
+
secondsLeft: month.isMonthToDate
|
|
526
|
+
? getSecondsLeft(month.endDate, data.now)
|
|
527
|
+
: 0,
|
|
528
|
+
});
|
|
529
|
+
});
|
|
530
|
+
};
|
|
531
|
+
const judgeTotal = (figures) => {
|
|
532
|
+
return (0, exports.judgeSloMonthlyFigures)({
|
|
533
|
+
figures: (0, exports.sumSloMonthlyFigures)(data.months.map((_month, index) => {
|
|
534
|
+
return figures[index] || { ...NO_FIGURES };
|
|
535
|
+
})),
|
|
536
|
+
targetPercentage: data.targetPercentage,
|
|
537
|
+
unit: unit,
|
|
538
|
+
isMonthToDate: Boolean(monthToDate),
|
|
539
|
+
secondsLeft: secondsLeftInPeriod,
|
|
540
|
+
});
|
|
541
|
+
};
|
|
542
|
+
const rows = judgeMonths(data.figures).map((judged, index) => {
|
|
543
|
+
const month = data.months[index];
|
|
544
|
+
return {
|
|
545
|
+
monthStart: month.startDate,
|
|
546
|
+
monthEnd: month.endDate,
|
|
547
|
+
isMonthToDate: month.isMonthToDate,
|
|
548
|
+
...judged,
|
|
549
|
+
};
|
|
550
|
+
});
|
|
551
|
+
const monitors = (data.monitors || []).map((monitor) => {
|
|
552
|
+
return {
|
|
553
|
+
monitorId: monitor.monitorId.toString(),
|
|
554
|
+
name: monitor.name,
|
|
555
|
+
months: judgeMonths(monitor.months),
|
|
556
|
+
total: judgeTotal(monitor.months),
|
|
557
|
+
};
|
|
558
|
+
});
|
|
559
|
+
monitors.sort((a, b) => {
|
|
560
|
+
var _a, _b;
|
|
561
|
+
const aSli = (_a = a.total.sliPercentage) !== null && _a !== void 0 ? _a : Infinity;
|
|
562
|
+
const bSli = (_b = b.total.sliPercentage) !== null && _b !== void 0 ? _b : Infinity;
|
|
563
|
+
if (aSli !== bSli) {
|
|
564
|
+
return aSli < bSli ? -1 : 1;
|
|
565
|
+
}
|
|
566
|
+
return a.name.localeCompare(b.name);
|
|
567
|
+
});
|
|
568
|
+
return {
|
|
569
|
+
sloId: data.sloId.toString(),
|
|
570
|
+
sloName: data.sloName || "",
|
|
571
|
+
sliType: data.sliType,
|
|
572
|
+
unit: unit,
|
|
573
|
+
targetPercentage: data.targetPercentage,
|
|
574
|
+
timezone: data.timezone,
|
|
575
|
+
period: data.period,
|
|
576
|
+
generatedAt: data.now,
|
|
577
|
+
unavailableReason: null,
|
|
578
|
+
months: rows,
|
|
579
|
+
total: {
|
|
580
|
+
...judgeTotal(data.figures),
|
|
581
|
+
includesMonthToDate: Boolean(monthToDate),
|
|
582
|
+
},
|
|
583
|
+
monitors: monitors,
|
|
584
|
+
};
|
|
585
|
+
};
|
|
586
|
+
exports.buildSloMonthlyReport = buildSloMonthlyReport;
|
|
587
|
+
// A report of an SLO that measures nothing to report on, with why.
|
|
588
|
+
const buildUnavailableSloMonthlyReport = (data) => {
|
|
589
|
+
return {
|
|
590
|
+
sloId: data.sloId.toString(),
|
|
591
|
+
sloName: data.sloName || "",
|
|
592
|
+
sliType: data.sliType,
|
|
593
|
+
unit: (0, exports.getSloMonthlyReportUnit)(data.sliType),
|
|
594
|
+
targetPercentage: (0, exports.isValidSloTargetPercentage)(data.targetPercentage)
|
|
595
|
+
? data.targetPercentage
|
|
596
|
+
: null,
|
|
597
|
+
timezone: data.timezone,
|
|
598
|
+
period: data.period,
|
|
599
|
+
generatedAt: data.now,
|
|
600
|
+
unavailableReason: data.reason,
|
|
601
|
+
months: [],
|
|
602
|
+
total: {
|
|
603
|
+
...NO_FIGURES,
|
|
604
|
+
errorBudgetUsedPercentage: null,
|
|
605
|
+
verdict: SloMonthVerdict.NoData,
|
|
606
|
+
includesMonthToDate: false,
|
|
607
|
+
},
|
|
608
|
+
monitors: [],
|
|
609
|
+
};
|
|
610
|
+
};
|
|
611
|
+
exports.buildUnavailableSloMonthlyReport = buildUnavailableSloMonthlyReport;
|
|
612
|
+
const getSloMonthlyReportSummary = (report) => {
|
|
613
|
+
let completeMonthCount = 0;
|
|
614
|
+
let metMonthCount = 0;
|
|
615
|
+
let worstMonth = null;
|
|
616
|
+
for (const row of report.months) {
|
|
617
|
+
if (row.sliPercentage === null) {
|
|
618
|
+
continue;
|
|
619
|
+
}
|
|
620
|
+
if (!row.isMonthToDate) {
|
|
621
|
+
completeMonthCount++;
|
|
622
|
+
if (row.verdict === SloMonthVerdict.Met) {
|
|
623
|
+
metMonthCount++;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
if (worstMonth === null ||
|
|
627
|
+
row.sliPercentage < worstMonth.sliPercentage) {
|
|
628
|
+
worstMonth = row;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
let leadingMonthsWithoutData = 0;
|
|
632
|
+
for (const row of report.months) {
|
|
633
|
+
if (row.sliPercentage !== null) {
|
|
634
|
+
break;
|
|
635
|
+
}
|
|
636
|
+
leadingMonthsWithoutData++;
|
|
637
|
+
}
|
|
638
|
+
return {
|
|
639
|
+
completeMonthCount: completeMonthCount,
|
|
640
|
+
metMonthCount: metMonthCount,
|
|
641
|
+
worstMonth: worstMonth,
|
|
642
|
+
leadingMonthsWithoutData: leadingMonthsWithoutData,
|
|
643
|
+
};
|
|
644
|
+
};
|
|
645
|
+
exports.getSloMonthlyReportSummary = getSloMonthlyReportSummary;
|
|
646
|
+
const figuresToJson = (figures) => {
|
|
647
|
+
const json = {
|
|
648
|
+
total: figures.total,
|
|
649
|
+
bad: figures.bad,
|
|
650
|
+
verdict: figures.verdict,
|
|
651
|
+
};
|
|
652
|
+
// A JSONObject holds no null: a figure that was not measured is left out.
|
|
653
|
+
if (figures.sliPercentage !== null) {
|
|
654
|
+
json["sliPercentage"] = figures.sliPercentage;
|
|
655
|
+
}
|
|
656
|
+
if (figures.errorBudgetUsedPercentage !== null) {
|
|
657
|
+
json["errorBudgetUsedPercentage"] = figures.errorBudgetUsedPercentage;
|
|
658
|
+
}
|
|
659
|
+
return json;
|
|
660
|
+
};
|
|
661
|
+
/*
|
|
662
|
+
* The report as the API answers it: dates as ISO strings, every figure
|
|
663
|
+
* unrounded, and an unmeasured figure left out (it reads back as null).
|
|
664
|
+
*/
|
|
665
|
+
const sloMonthlyReportToJSON = (report) => {
|
|
666
|
+
const json = {
|
|
667
|
+
sloId: report.sloId,
|
|
668
|
+
sloName: report.sloName,
|
|
669
|
+
unit: report.unit,
|
|
670
|
+
timezone: report.timezone,
|
|
671
|
+
period: report.period.kind === SloMonthlyReportPeriodKind.Year
|
|
672
|
+
? { kind: report.period.kind, year: report.period.year }
|
|
673
|
+
: { kind: report.period.kind, months: report.period.months },
|
|
674
|
+
generatedAt: report.generatedAt.toISOString(),
|
|
675
|
+
months: report.months.map((row) => {
|
|
676
|
+
return {
|
|
677
|
+
monthStart: row.monthStart.toISOString(),
|
|
678
|
+
monthEnd: row.monthEnd.toISOString(),
|
|
679
|
+
isMonthToDate: row.isMonthToDate,
|
|
680
|
+
...figuresToJson(row),
|
|
681
|
+
};
|
|
682
|
+
}),
|
|
683
|
+
total: {
|
|
684
|
+
includesMonthToDate: report.total.includesMonthToDate,
|
|
685
|
+
...figuresToJson(report.total),
|
|
686
|
+
},
|
|
687
|
+
monitors: report.monitors.map((monitor) => {
|
|
688
|
+
return {
|
|
689
|
+
monitorId: monitor.monitorId,
|
|
690
|
+
name: monitor.name,
|
|
691
|
+
months: monitor.months.map(figuresToJson),
|
|
692
|
+
total: figuresToJson(monitor.total),
|
|
693
|
+
};
|
|
694
|
+
}),
|
|
695
|
+
};
|
|
696
|
+
if (report.sliType) {
|
|
697
|
+
json["sliType"] = report.sliType;
|
|
698
|
+
}
|
|
699
|
+
if (report.targetPercentage !== null) {
|
|
700
|
+
json["targetPercentage"] = report.targetPercentage;
|
|
701
|
+
}
|
|
702
|
+
if (report.unavailableReason) {
|
|
703
|
+
json["unavailableReason"] = report.unavailableReason;
|
|
704
|
+
json["unavailableMessage"] =
|
|
705
|
+
exports.SLO_MONTHLY_REPORT_UNAVAILABLE_MESSAGES[report.unavailableReason];
|
|
706
|
+
}
|
|
707
|
+
return json;
|
|
708
|
+
};
|
|
709
|
+
exports.sloMonthlyReportToJSON = sloMonthlyReportToJSON;
|
|
710
|
+
const asObject = (value) => {
|
|
711
|
+
return value && typeof value === "object" && !Array.isArray(value)
|
|
712
|
+
? value
|
|
713
|
+
: null;
|
|
714
|
+
};
|
|
715
|
+
const asArray = (value) => {
|
|
716
|
+
return Array.isArray(value) ? value : [];
|
|
717
|
+
};
|
|
718
|
+
const asFinite = (value) => {
|
|
719
|
+
const parsed = typeof value === "number"
|
|
720
|
+
? value
|
|
721
|
+
: typeof value === "string" && value.trim() !== ""
|
|
722
|
+
? Number(value)
|
|
723
|
+
: NaN;
|
|
724
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
725
|
+
};
|
|
726
|
+
const asDate = (value) => {
|
|
727
|
+
if (typeof value !== "string" && !(value instanceof Date)) {
|
|
728
|
+
return null;
|
|
729
|
+
}
|
|
730
|
+
const date = new Date(value);
|
|
731
|
+
return Number.isFinite(date.getTime()) ? date : null;
|
|
732
|
+
};
|
|
733
|
+
const asEnum = (value, values) => {
|
|
734
|
+
return Object.values(values).includes(value) ? value : null;
|
|
735
|
+
};
|
|
736
|
+
const parseFigures = (value) => {
|
|
737
|
+
var _a, _b;
|
|
738
|
+
const json = asObject(value) || {};
|
|
739
|
+
const sliPercentage = asFinite(json["sliPercentage"]);
|
|
740
|
+
return {
|
|
741
|
+
total: Math.max(0, (_a = asFinite(json["total"])) !== null && _a !== void 0 ? _a : 0),
|
|
742
|
+
bad: Math.max(0, (_b = asFinite(json["bad"])) !== null && _b !== void 0 ? _b : 0),
|
|
743
|
+
sliPercentage: sliPercentage,
|
|
744
|
+
errorBudgetUsedPercentage: asFinite(json["errorBudgetUsedPercentage"]),
|
|
745
|
+
// A verdict the page cannot read is not guessed at.
|
|
746
|
+
verdict: asEnum(json["verdict"], SloMonthVerdict) || SloMonthVerdict.NoData,
|
|
747
|
+
};
|
|
748
|
+
};
|
|
749
|
+
/*
|
|
750
|
+
* A report read back from the API's answer, or null when the answer is not
|
|
751
|
+
* one. Lenient with each figure - a month the page cannot read is a month
|
|
752
|
+
* without data - so one bad value never hides the rest of the report.
|
|
753
|
+
*/
|
|
754
|
+
const parseSloMonthlyReport = (value) => {
|
|
755
|
+
const json = asObject(value);
|
|
756
|
+
if (!json || typeof json["sloId"] !== "string") {
|
|
757
|
+
return null;
|
|
758
|
+
}
|
|
759
|
+
const periodJson = asObject(json["period"]) || {};
|
|
760
|
+
const year = asFinite(periodJson["year"]);
|
|
761
|
+
const months = asFinite(periodJson["months"]);
|
|
762
|
+
const period = periodJson["kind"] === SloMonthlyReportPeriodKind.Year && year !== null
|
|
763
|
+
? { kind: SloMonthlyReportPeriodKind.Year, year: year }
|
|
764
|
+
: {
|
|
765
|
+
kind: SloMonthlyReportPeriodKind.LastMonths,
|
|
766
|
+
months: months !== null && months !== void 0 ? months : exports.SLO_MONTHLY_REPORT_DEFAULT_MONTHS,
|
|
767
|
+
};
|
|
768
|
+
const rows = [];
|
|
769
|
+
for (const item of asArray(json["months"])) {
|
|
770
|
+
const row = asObject(item);
|
|
771
|
+
const monthStart = asDate(row === null || row === void 0 ? void 0 : row["monthStart"]);
|
|
772
|
+
const monthEnd = asDate(row === null || row === void 0 ? void 0 : row["monthEnd"]);
|
|
773
|
+
if (!row || !monthStart || !monthEnd) {
|
|
774
|
+
continue;
|
|
775
|
+
}
|
|
776
|
+
rows.push({
|
|
777
|
+
monthStart: monthStart,
|
|
778
|
+
monthEnd: monthEnd,
|
|
779
|
+
isMonthToDate: row["isMonthToDate"] === true,
|
|
780
|
+
...parseFigures(row),
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
const totalJson = asObject(json["total"]) || {};
|
|
784
|
+
const monitors = [];
|
|
785
|
+
for (const item of asArray(json["monitors"])) {
|
|
786
|
+
const monitor = asObject(item);
|
|
787
|
+
if (!monitor || typeof monitor["monitorId"] !== "string") {
|
|
788
|
+
continue;
|
|
789
|
+
}
|
|
790
|
+
const monitorMonths = asArray(monitor["months"]).map(parseFigures);
|
|
791
|
+
monitors.push({
|
|
792
|
+
monitorId: monitor["monitorId"],
|
|
793
|
+
name: typeof monitor["name"] === "string" ? monitor["name"] : "",
|
|
794
|
+
// Exactly one per month of the report, whatever the answer held.
|
|
795
|
+
months: rows.map((_row, index) => {
|
|
796
|
+
return monitorMonths[index] || parseFigures(null);
|
|
797
|
+
}),
|
|
798
|
+
total: parseFigures(monitor["total"]),
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
return {
|
|
802
|
+
sloId: json["sloId"],
|
|
803
|
+
sloName: typeof json["sloName"] === "string" ? json["sloName"] : "",
|
|
804
|
+
sliType: asEnum(json["sliType"], SliType_1.default),
|
|
805
|
+
unit: asEnum(json["unit"], SloMonthlyReportUnit) ||
|
|
806
|
+
SloMonthlyReportUnit.Seconds,
|
|
807
|
+
targetPercentage: asFinite(json["targetPercentage"]),
|
|
808
|
+
timezone: typeof json["timezone"] === "string" && json["timezone"]
|
|
809
|
+
? json["timezone"]
|
|
810
|
+
: exports.SLO_MONTHLY_REPORT_DEFAULT_TIMEZONE,
|
|
811
|
+
period: period,
|
|
812
|
+
generatedAt: asDate(json["generatedAt"]) || new Date(),
|
|
813
|
+
unavailableReason: asEnum(json["unavailableReason"], SloMonthlyReportUnavailableReason),
|
|
814
|
+
months: rows,
|
|
815
|
+
total: {
|
|
816
|
+
includesMonthToDate: totalJson["includesMonthToDate"] === true,
|
|
817
|
+
...parseFigures(totalJson),
|
|
818
|
+
},
|
|
819
|
+
monitors: monitors,
|
|
820
|
+
};
|
|
821
|
+
};
|
|
822
|
+
exports.parseSloMonthlyReport = parseSloMonthlyReport;
|
|
823
|
+
// ---- CSV ---------------------------------------------------------------------
|
|
824
|
+
// A field holding one of these is quoted (RFC 4180).
|
|
825
|
+
const CSV_QUOTED_FIELD_PATTERN = /[",\r\n]/;
|
|
826
|
+
/*
|
|
827
|
+
* A CSV field: quoted when it holds a comma, a quote or a line break (RFC
|
|
828
|
+
* 4180), and a field a spreadsheet would run as a formula - a monitor named
|
|
829
|
+
* "=HYPERLINK(...)" - is kept as text. The same rules as the tables' Export
|
|
830
|
+
* CSV (Common/UI/Utils/TableColumnsToCsv), here so the server could write
|
|
831
|
+
* the file too.
|
|
832
|
+
*/
|
|
833
|
+
const toSloCsvField = (value) => {
|
|
834
|
+
let text = value;
|
|
835
|
+
const first = text.charAt(0);
|
|
836
|
+
if (first === "=" ||
|
|
837
|
+
first === "+" ||
|
|
838
|
+
first === "@" ||
|
|
839
|
+
first === "\t" ||
|
|
840
|
+
first === "\r") {
|
|
841
|
+
text = `'${text}`;
|
|
842
|
+
}
|
|
843
|
+
if (CSV_QUOTED_FIELD_PATTERN.test(text)) {
|
|
844
|
+
return `"${text.replace(/"/g, '""')}"`;
|
|
845
|
+
}
|
|
846
|
+
return text;
|
|
847
|
+
};
|
|
848
|
+
exports.toSloCsvField = toSloCsvField;
|
|
849
|
+
const VERDICT_CSV_WORDS = {
|
|
850
|
+
[SloMonthVerdict.Met]: "Met",
|
|
851
|
+
[SloMonthVerdict.Missed]: "Missed",
|
|
852
|
+
[SloMonthVerdict.OnTrack]: "On track",
|
|
853
|
+
[SloMonthVerdict.BelowTarget]: "Below target",
|
|
854
|
+
[SloMonthVerdict.NoData]: "No data",
|
|
855
|
+
};
|
|
856
|
+
// A figure as a spreadsheet reads it: a dot for decimals, nothing when unmeasured.
|
|
857
|
+
const fixed = (value, decimals) => {
|
|
858
|
+
if (value === null || !Number.isFinite(value)) {
|
|
859
|
+
return "";
|
|
860
|
+
}
|
|
861
|
+
return value.toFixed(decimals);
|
|
862
|
+
};
|
|
863
|
+
/*
|
|
864
|
+
* The report as a CSV file, one row per month and the total last. Written
|
|
865
|
+
* for a spreadsheet, not a page: English headers, months as YYYY-MM in the
|
|
866
|
+
* report's timezone, figures with a dot and no unit, so a sum or a chart can
|
|
867
|
+
* be made of them in any language. A Monitor Uptime SLO with several
|
|
868
|
+
* monitors adds each monitor's SLI as a column.
|
|
869
|
+
*/
|
|
870
|
+
const buildSloMonthlyReportCsv = (report) => {
|
|
871
|
+
const countedHeaders = {
|
|
872
|
+
[SloMonthlyReportUnit.Seconds]: [
|
|
873
|
+
"Measured (seconds)",
|
|
874
|
+
"Downtime (seconds)",
|
|
875
|
+
],
|
|
876
|
+
[SloMonthlyReportUnit.Requests]: ["Requests", "Bad requests"],
|
|
877
|
+
[SloMonthlyReportUnit.Events]: ["Events", "Bad events"],
|
|
878
|
+
};
|
|
879
|
+
const headers = [
|
|
880
|
+
"Month",
|
|
881
|
+
"Month to date",
|
|
882
|
+
"SLI (%)",
|
|
883
|
+
"Target (%)",
|
|
884
|
+
...countedHeaders[report.unit],
|
|
885
|
+
"Error budget used (%)",
|
|
886
|
+
"Result",
|
|
887
|
+
];
|
|
888
|
+
const monitorColumns = report.monitors.length > 1 ? report.monitors : [];
|
|
889
|
+
for (const monitor of monitorColumns) {
|
|
890
|
+
headers.push(`${monitor.name || monitor.monitorId} SLI (%)`);
|
|
891
|
+
}
|
|
892
|
+
const target = fixed(report.targetPercentage, 4);
|
|
893
|
+
const figureCells = (figures) => {
|
|
894
|
+
return [
|
|
895
|
+
fixed(figures.sliPercentage, 4),
|
|
896
|
+
target,
|
|
897
|
+
fixed(figures.total, 0),
|
|
898
|
+
fixed(figures.bad, 0),
|
|
899
|
+
fixed(figures.errorBudgetUsedPercentage, 2),
|
|
900
|
+
VERDICT_CSV_WORDS[figures.verdict],
|
|
901
|
+
];
|
|
902
|
+
};
|
|
903
|
+
const lines = [headers];
|
|
904
|
+
report.months.forEach((row, index) => {
|
|
905
|
+
lines.push([
|
|
906
|
+
Date_1.Moment.tz(row.monthStart, report.timezone).format("YYYY-MM"),
|
|
907
|
+
row.isMonthToDate ? "Yes" : "No",
|
|
908
|
+
...figureCells(row),
|
|
909
|
+
...monitorColumns.map((monitor) => {
|
|
910
|
+
var _a, _b;
|
|
911
|
+
return fixed((_b = (_a = monitor.months[index]) === null || _a === void 0 ? void 0 : _a.sliPercentage) !== null && _b !== void 0 ? _b : null, 4);
|
|
912
|
+
}),
|
|
913
|
+
]);
|
|
914
|
+
});
|
|
915
|
+
lines.push([
|
|
916
|
+
"Total",
|
|
917
|
+
report.total.includesMonthToDate ? "Yes" : "No",
|
|
918
|
+
...figureCells(report.total),
|
|
919
|
+
...monitorColumns.map((monitor) => {
|
|
920
|
+
return fixed(monitor.total.sliPercentage, 4);
|
|
921
|
+
}),
|
|
922
|
+
]);
|
|
923
|
+
return lines
|
|
924
|
+
.map((line) => {
|
|
925
|
+
return line.map(exports.toSloCsvField).join(",");
|
|
926
|
+
})
|
|
927
|
+
.join("\r\n");
|
|
928
|
+
};
|
|
929
|
+
exports.buildSloMonthlyReportCsv = buildSloMonthlyReportCsv;
|
|
930
|
+
/*
|
|
931
|
+
* The file's name: the SLO's name made safe for a file, and the period -
|
|
932
|
+
* "checkout-api-monthly-report-2025.csv", "checkout-api-monthly-report-last-6-months.csv".
|
|
933
|
+
*/
|
|
934
|
+
const getSloMonthlyReportFilename = (data) => {
|
|
935
|
+
const slug = (data.sloName || "")
|
|
936
|
+
.replace(/[^a-zA-Z0-9-_]+/g, "-")
|
|
937
|
+
.replace(/^-+|-+$/g, "")
|
|
938
|
+
.toLowerCase()
|
|
939
|
+
.substring(0, 60) || "slo";
|
|
940
|
+
const period = data.period.kind === SloMonthlyReportPeriodKind.Year
|
|
941
|
+
? data.period.year.toString()
|
|
942
|
+
: `last-${data.period.months}-months`;
|
|
943
|
+
return `${slug}-monthly-report-${period}.csv`;
|
|
944
|
+
};
|
|
945
|
+
exports.getSloMonthlyReportFilename = getSloMonthlyReportFilename;
|