@oneuptime/common 14.0.109 → 14.0.110
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Models/AnalyticsModels/SecurityEvent.js +1 -1
- package/Models/DatabaseModels/AIInsight.js +2 -2
- package/Models/DatabaseModels/Alert.js +2 -2
- package/Models/DatabaseModels/AlertEpisode.js +2 -2
- package/Models/DatabaseModels/AlertEpisodeOnCallRule.js +3 -3
- package/Models/DatabaseModels/AlertGroupingRule.d.mts +1 -0
- package/Models/DatabaseModels/AlertGroupingRule.d.ts +1 -0
- package/Models/DatabaseModels/AlertGroupingRule.js +48 -2
- package/Models/DatabaseModels/AlertOnCallRule.js +3 -3
- package/Models/DatabaseModels/AlertSeverity.js +13 -4
- package/Models/DatabaseModels/AlertState.js +1 -1
- package/Models/DatabaseModels/CallLog.js +12 -12
- package/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel.d.mts +2 -0
- package/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel.d.ts +2 -0
- package/Models/DatabaseModels/EmailLog.js +12 -12
- package/Models/DatabaseModels/FormSubmission.js +2 -2
- package/Models/DatabaseModels/GlobalConfig.d.mts +1 -0
- package/Models/DatabaseModels/GlobalConfig.d.ts +1 -0
- package/Models/DatabaseModels/GlobalConfig.js +28 -0
- package/Models/DatabaseModels/Incident.js +2 -2
- package/Models/DatabaseModels/IncidentEpisode.js +2 -2
- package/Models/DatabaseModels/IncidentEpisodeOnCallRule.js +3 -3
- package/Models/DatabaseModels/IncidentGroupingRule.d.mts +1 -0
- package/Models/DatabaseModels/IncidentGroupingRule.d.ts +1 -0
- package/Models/DatabaseModels/IncidentGroupingRule.js +48 -2
- package/Models/DatabaseModels/IncidentOnCallRule.js +3 -3
- package/Models/DatabaseModels/IncidentSeverity.js +13 -4
- package/Models/DatabaseModels/IncidentState.js +1 -1
- package/Models/DatabaseModels/IncidentTemplate.js +2 -2
- package/Models/DatabaseModels/Monitor.js +3 -3
- package/Models/DatabaseModels/NetworkDevice.d.mts +1 -0
- package/Models/DatabaseModels/NetworkDevice.d.ts +1 -0
- package/Models/DatabaseModels/NetworkDevice.js +41 -0
- package/Models/DatabaseModels/OnCallDutyPolicy.js +4 -2
- package/Models/DatabaseModels/OnCallDutyPolicyEscalationRule.js +1 -1
- package/Models/DatabaseModels/OnCallDutyPolicyEscalationRuleSchedule.js +8 -5
- package/Models/DatabaseModels/OnCallDutyPolicyEscalationRuleTeam.js +5 -2
- package/Models/DatabaseModels/OnCallDutyPolicyEscalationRuleUser.js +5 -2
- package/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.js +9 -6
- package/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.js +10 -7
- package/Models/DatabaseModels/OnCallDutyPolicyFeed.js +14 -11
- package/Models/DatabaseModels/OnCallDutyPolicyOwnerTeam.js +7 -4
- package/Models/DatabaseModels/OnCallDutyPolicyOwnerUser.js +7 -4
- package/Models/DatabaseModels/OnCallDutyPolicySchedule.js +6 -3
- package/Models/DatabaseModels/OnCallDutyPolicyScheduleCalendarFeed.js +4 -4
- package/Models/DatabaseModels/OnCallDutyPolicyScheduleLayer.js +3 -3
- package/Models/DatabaseModels/OnCallDutyPolicyScheduleLayerUser.js +6 -6
- package/Models/DatabaseModels/OnCallDutyPolicyTimeLog.js +9 -6
- package/Models/DatabaseModels/Project.d.mts +2 -0
- package/Models/DatabaseModels/Project.d.ts +2 -0
- package/Models/DatabaseModels/Project.js +96 -2
- package/Models/DatabaseModels/ProxmoxCluster.d.mts +1 -0
- package/Models/DatabaseModels/ProxmoxCluster.d.ts +1 -0
- package/Models/DatabaseModels/ProxmoxCluster.js +52 -3
- package/Models/DatabaseModels/PushNotificationLog.js +12 -12
- package/Models/DatabaseModels/Reseller.js +8 -2
- package/Models/DatabaseModels/ResellerPlan.js +8 -2
- package/Models/DatabaseModels/ScheduledMaintenance.js +6 -3
- package/Models/DatabaseModels/ScheduledMaintenanceInternalNote.js +7 -4
- package/Models/DatabaseModels/ScheduledMaintenanceMeasurementValue.js +2 -2
- package/Models/DatabaseModels/ScheduledMaintenancePublicNote.js +7 -4
- package/Models/DatabaseModels/ScheduledMaintenanceStateTimeline.js +1 -1
- package/Models/DatabaseModels/Service.js +1 -1
- package/Models/DatabaseModels/ServiceLevelObjectiveBurnRateRule.js +4 -4
- package/Models/DatabaseModels/ServiceLevelObjectiveErrorBudgetPolicyTier.js +4 -4
- package/Models/DatabaseModels/SmsLog.js +12 -12
- package/Models/DatabaseModels/StatusPage.js +5 -5
- package/Models/DatabaseModels/StatusPageSubscriber.js +2 -2
- package/Models/DatabaseModels/TelegramLog.js +12 -12
- package/Models/DatabaseModels/TelemetryIngestionKey.js +8 -5
- package/Models/DatabaseModels/TelemetryIngestionKeyRefusal.js +7 -4
- package/Models/DatabaseModels/User.d.mts +4 -0
- package/Models/DatabaseModels/User.d.ts +4 -0
- package/Models/DatabaseModels/User.js +100 -0
- package/Models/DatabaseModels/UserOnCallLog.js +6 -6
- package/Models/DatabaseModels/UserOnCallLogTimeline.js +3 -3
- package/Models/DatabaseModels/UserOnCallShiftReminderLog.js +2 -2
- package/Models/DatabaseModels/WebhookLog.js +12 -12
- package/Models/DatabaseModels/WhatsAppLog.js +12 -12
- package/Models/DatabaseModels/WorkspaceNotificationLog.js +12 -12
- package/Types/AI/AIChatTypes.d.mts +2 -1
- package/Types/AI/AIChatTypes.d.ts +2 -1
- package/Types/AI/AIChatTypes.js +5 -0
- package/Types/Analytics/ProductEvent.d.mts +6 -1
- package/Types/Analytics/ProductEvent.d.ts +6 -1
- package/Types/Analytics/ProductEvent.js +41 -0
- package/Types/AuditLog/AuditLogCoverage.d.mts +1 -0
- package/Types/AuditLog/AuditLogCoverage.d.ts +1 -0
- package/Types/AuditLog/AuditLogCoverage.js +4 -2
- package/Types/Cloud/CloudResourceCatalog.d.mts +2 -0
- package/Types/Cloud/CloudResourceCatalog.d.ts +2 -0
- package/Types/Cloud/CloudResourceCatalog.js +33 -3
- package/Types/Cloud/CloudResourceCatalog.mjs +1 -0
- package/Types/DataObservability/DataCheckSuggestions.d.mts +25 -0
- package/Types/DataObservability/DataCheckSuggestions.d.ts +25 -0
- package/Types/DataObservability/DataCheckSuggestions.js +102 -65
- package/Types/DataObservability/DataCheckSuggestions.mjs +1 -0
- package/Types/Database/TableMetadata.d.mts +2 -0
- package/Types/Database/TableMetadata.d.ts +2 -0
- package/Types/Database/TableMetadata.js +6 -0
- package/Types/Date.d.mts +20 -1
- package/Types/Date.d.ts +20 -1
- package/Types/Date.js +42 -2
- package/Types/DateLanguage.d.mts +2 -0
- package/Types/DateLanguage.d.ts +2 -0
- package/Types/DateLanguage.js +44 -2
- package/Types/DateLanguage.mjs +2 -0
- package/Types/DirectionArrow.d.mts +7 -0
- package/Types/DirectionArrow.d.ts +7 -0
- package/Types/DirectionArrow.js +88 -0
- package/Types/DirectionArrow.mjs +7 -0
- package/Types/Docs/GlossaryTerm.d.mts +1 -0
- package/Types/Docs/GlossaryTerm.d.ts +1 -0
- package/Types/Docs/GlossaryTerm.js +2 -0
- package/Types/Docs/RetiredNames.d.mts +11 -0
- package/Types/Docs/RetiredNames.d.ts +11 -0
- package/Types/Docs/RetiredNames.js +139 -0
- package/Types/Docs/RetiredNames.mjs +3 -0
- package/Types/Exception/RefusalWithValues.d.mts +7 -0
- package/Types/Exception/RefusalWithValues.d.ts +7 -0
- package/Types/Exception/RefusalWithValues.js +76 -0
- package/Types/Exception/RefusalWithValues.mjs +3 -0
- package/Types/Exception/UnexplainedError.d.mts +13 -0
- package/Types/Exception/UnexplainedError.d.ts +13 -0
- package/Types/Exception/UnexplainedError.js +53 -1
- package/Types/Exception/UnexplainedError.mjs +1 -0
- package/Types/File/FileSize.d.mts +4 -1
- package/Types/File/FileSize.d.ts +4 -1
- package/Types/File/FileSize.js +18 -17
- package/Types/HostCollector/HostCollector.d.mts +1 -0
- package/Types/HostCollector/HostCollector.d.ts +1 -0
- package/Types/HostCollector/HostCollector.js +26 -10
- package/Types/HostCollector/HostCollector.mjs +1 -0
- package/Types/Monitor/MonitorCriteria.js +2 -2
- package/Types/Monitor/MonitorStep.js +1 -1
- package/Types/Monitor/MonitorTemplateSyncField.d.mts +6 -0
- package/Types/Monitor/MonitorTemplateSyncField.d.ts +6 -0
- package/Types/Monitor/MonitorTemplateSyncField.js +106 -64
- package/Types/Monitor/NtpMonitor/NtpMonitorUtil.d.mts +1 -0
- package/Types/Monitor/NtpMonitor/NtpMonitorUtil.d.ts +1 -0
- package/Types/Monitor/NtpMonitor/NtpMonitorUtil.js +11 -3
- package/Types/Monitor/WhoIsTold.d.mts +3 -1
- package/Types/Monitor/WhoIsTold.d.ts +3 -1
- package/Types/Monitor/WhoIsTold.js +2 -1
- package/Types/NotificationRule/PagingLadder.d.mts +137 -0
- package/Types/NotificationRule/PagingLadder.d.ts +137 -0
- package/Types/NotificationRule/PagingLadder.js +682 -0
- package/Types/NotificationRule/PagingLadder.mjs +28 -0
- package/Types/NotificationSetting/NotificationEmailRollupCategory.js +1 -1
- package/Types/OnCallDutyPolicy/OnCallPageLine.d.mts +26 -0
- package/Types/OnCallDutyPolicy/OnCallPageLine.d.ts +26 -0
- package/Types/OnCallDutyPolicy/OnCallPageLine.js +136 -0
- package/Types/OnCallDutyPolicy/OnCallPageLine.mjs +18 -0
- package/Types/OnCallDutyPolicy/OnCallTestPage.d.mts +44 -0
- package/Types/OnCallDutyPolicy/OnCallTestPage.d.ts +44 -0
- package/Types/OnCallDutyPolicy/OnCallTestPage.js +96 -5
- package/Types/OnCallDutyPolicy/OnCallTestPage.mjs +1 -0
- package/Types/OnCallDutyPolicy/OnCallTestPageLine.d.mts +19 -0
- package/Types/OnCallDutyPolicy/OnCallTestPageLine.d.ts +19 -0
- package/Types/OnCallDutyPolicy/OnCallTestPageLine.js +222 -0
- package/Types/OnCallDutyPolicy/OnCallTestPageLine.mjs +6 -0
- package/Types/OnCallDutyPolicy/ScheduleLayerDefaults.js +5 -2
- package/Types/OnCallDutyPolicy/UserOverrideCoverRequest.js +9 -1
- package/Types/Permission.d.mts +2 -2
- package/Types/Permission.d.ts +2 -2
- package/Types/Permission.js +194 -193
- package/Types/Product/ProductCatalog.d.mts +10 -0
- package/Types/Product/ProductCatalog.d.ts +10 -0
- package/Types/Product/ProductCatalog.js +208 -0
- package/Types/Product/ProductCatalog.mjs +6 -0
- package/Types/Product/ProductOfTable.d.mts +3 -0
- package/Types/Product/ProductOfTable.d.ts +3 -0
- package/Types/Product/ProductOfTable.js +68 -0
- package/Types/Product/ProductOfTable.mjs +3 -0
- package/Types/Product/ProjectProductsAnswer.d.mts +3 -0
- package/Types/Product/ProjectProductsAnswer.d.ts +3 -0
- package/Types/Product/ProjectProductsAnswer.js +35 -2
- package/Types/Product/ProjectProductsAnswer.mjs +1 -0
- package/Types/Product/ServerProducts.d.mts +65 -0
- package/Types/Product/ServerProducts.d.ts +65 -0
- package/Types/Product/ServerProducts.js +383 -0
- package/Types/Product/ServerProducts.mjs +26 -0
- package/Types/Product/ServerProductsAnswer.d.mts +21 -0
- package/Types/Product/ServerProductsAnswer.d.ts +21 -0
- package/Types/Product/ServerProductsAnswer.js +78 -0
- package/Types/Product/ServerProductsAnswer.mjs +5 -0
- package/Types/ProductFeedback/ProductFeedback.d.mts +3 -1
- package/Types/ProductFeedback/ProductFeedback.d.ts +3 -1
- package/Types/ProductFeedback/ProductFeedback.js +8 -0
- package/Types/Rum/SessionReplayCustomEvents.d.mts +1 -0
- package/Types/Rum/SessionReplayCustomEvents.d.ts +1 -0
- package/Types/SampleProject/SampleProject.d.mts +54 -0
- package/Types/SampleProject/SampleProject.d.ts +54 -0
- package/Types/SampleProject/SampleProject.js +177 -0
- package/Types/SampleProject/SampleProject.mjs +22 -0
- package/Types/SampleProject/SampleProjectContent.d.mts +127 -0
- package/Types/SampleProject/SampleProjectContent.d.ts +127 -0
- package/Types/SampleProject/SampleProjectContent.js +397 -0
- package/Types/SampleProject/SampleProjectContent.mjs +18 -0
- package/Types/Telemetry/TelemetryIngestSurface.js +6 -5
- package/Types/Translator.d.mts +1 -0
- package/Types/Translator.d.ts +1 -0
- package/Types/Translator.js +40 -2
- package/Types/Translator.mjs +1 -0
- package/Types/UsedBy/UsedBy.d.mts +103 -0
- package/Types/UsedBy/UsedBy.d.ts +103 -0
- package/Types/UsedBy/UsedBy.js +389 -0
- package/Types/UsedBy/UsedBy.mjs +20 -0
- package/Types/UsedBy/UsedByServerProducts.d.mts +4 -0
- package/Types/UsedBy/UsedByServerProducts.d.ts +4 -0
- package/Types/UsedBy/UsedByServerProducts.js +48 -0
- package/Types/UsedBy/UsedByServerProducts.mjs +3 -0
- package/Types/WelcomeChecklist/WelcomeChecklist.d.mts +6 -0
- package/Types/WelcomeChecklist/WelcomeChecklist.d.ts +6 -0
- package/Types/WelcomeChecklist/WelcomeChecklist.js +54 -2
- package/Types/WelcomeChecklist/WelcomeChecklist.mjs +4 -0
- package/Types/WelcomeChecklist/WelcomeChecklistAnswer.d.mts +1 -0
- package/Types/WelcomeChecklist/WelcomeChecklistAnswer.d.ts +1 -0
- package/Types/WelcomeChecklist/WelcomeChecklistAnswer.js +3 -0
- package/Types/Workflow/PassedOnFields.js +2 -1
- package/Types/Workflow/Templates.js +1 -1
- package/Types/Workspace/NotificationRules/NotificationRuleCondition.d.mts +2 -0
- package/Types/Workspace/NotificationRules/NotificationRuleCondition.d.ts +2 -0
- package/Utils/AI/MeaningMatch.d.mts +36 -0
- package/Utils/AI/MeaningMatch.d.ts +36 -0
- package/Utils/AI/MeaningMatch.js +535 -0
- package/Utils/AI/MeaningMatch.mjs +7 -0
- package/Utils/ArchivableValues.js +1 -1
- package/Utils/AuditLog/AuditLogValues.js +2 -2
- package/Utils/Dashboard/ClockWidgetFormat.d.mts +14 -2
- package/Utils/Dashboard/ClockWidgetFormat.d.ts +14 -2
- package/Utils/Dashboard/ClockWidgetFormat.js +105 -2
- package/Utils/Dashboard/DashboardViewConfigSignature.d.mts +3 -0
- package/Utils/Dashboard/DashboardViewConfigSignature.d.ts +3 -0
- package/Utils/Dashboard/DashboardViewConfigSignature.js +45 -0
- package/Utils/Dashboard/DashboardViewConfigSignature.mjs +3 -0
- package/Utils/DataSecurity/TextScanner.js +2 -2
- package/Utils/DeveloperDocs/AiAssistantExamples.js +4 -4
- package/Utils/DeveloperDocs/CliCommands.d.mts +1 -0
- package/Utils/DeveloperDocs/CliCommands.d.ts +1 -0
- package/Utils/DeveloperDocs/CliCommands.js +2 -1
- package/Utils/DeveloperDocs/CliResources.js +2 -1
- package/Utils/DeveloperDocs/TerraformSchema.js +3 -1
- package/Utils/Markdown/LinkReferenceDefinitions.d.mts +8 -0
- package/Utils/Markdown/LinkReferenceDefinitions.d.ts +8 -0
- package/Utils/Markdown/LinkReferenceDefinitions.js +1493 -131
- package/Utils/Markdown/LinkReferenceDefinitions.mjs +1 -0
- package/Utils/Markdown/MarkdownTableCell.js +2 -1
- package/Utils/Markdown/OverLongText.js +523 -5
- package/Utils/Markdown/SlowMarkdown.d.mts +14 -0
- package/Utils/Markdown/SlowMarkdown.d.ts +14 -0
- package/Utils/Markdown/SlowMarkdown.js +595 -11
- package/Utils/Markdown/SlowMarkdown.mjs +6 -0
- package/Utils/ModelApiName.d.mts +11 -0
- package/Utils/ModelApiName.d.ts +11 -0
- package/Utils/ModelApiName.js +72 -0
- package/Utils/ModelApiName.mjs +5 -0
- package/Utils/Monitor/DeviceMacLearningUtil.d.mts +2 -1
- package/Utils/Monitor/DeviceMacLearningUtil.d.ts +2 -1
- package/Utils/Monitor/DeviceMacLearningUtil.js +26 -0
- package/Utils/Monitor/EndpointAttachmentUtil.js +8 -3
- package/Utils/Monitor/ExternalStatusPageReading.d.mts +3 -0
- package/Utils/Monitor/ExternalStatusPageReading.d.ts +3 -0
- package/Utils/Monitor/ExternalStatusPageReading.js +35 -1
- package/Utils/Monitor/ExternalStatusPageReading.mjs +2 -0
- package/Utils/Monitor/MonitorTemplateLinkRefusal.d.mts +9 -0
- package/Utils/Monitor/MonitorTemplateLinkRefusal.d.ts +9 -0
- package/Utils/Monitor/MonitorTemplateLinkRefusal.js +45 -0
- package/Utils/Monitor/MonitorTemplateLinkRefusal.mjs +6 -0
- package/Utils/OpenStack/OpenStackCheckName.js +2 -1
- package/Utils/OpenStack/OpenStackLogScrub.js +1 -1
- package/Utils/OpenStack/OpenStackLogs.js +3 -2
- package/Utils/OpenStack/OpenStackTraces.js +2 -1
- package/Utils/Project/NotificationChannels.js +5 -5
- package/Utils/Project/ProjectBalance.js +2 -2
- package/Utils/Project/TwilioAccount.js +2 -2
- package/Utils/ScheduledMaintenanceStart.d.mts +3 -0
- package/Utils/ScheduledMaintenanceStart.d.ts +3 -0
- package/Utils/ScheduledMaintenanceStart.js +9 -0
- package/Utils/Schema/ModelSchema.js +10 -1
- package/Utils/Uptime/UptimeMaintenanceUtil.js +2 -1
- package/Utils/ValueFormatter.d.mts +8 -6
- package/Utils/ValueFormatter.d.ts +8 -6
- package/Utils/ValueFormatter.js +145 -0
- package/package.json +1 -1
|
@@ -0,0 +1,682 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.readPagingLadderSteps = exports.getPagingLadderStepsProblem = exports.isEmptyPagingLadderPlan = exports.getPagingLadderRules = exports.planPagingLadderSave = exports.readPagingLadder = exports.readPagingLadderCells = exports.comparePagingLadderCell = exports.getPagingLadderStepFromRule = exports.normalizePagingLadderSteps = exports.comparePagingLadderSteps = exports.getPagingLadderStepKey = exports.getPagingLadderMethodKey = exports.normalizePagingLadderStep = exports.getPagingLadderCellKey = exports.getLivePagingLadderCells = exports.getPagingLadderCells = exports.readPagingId = exports.getPagingMethodColumnForChannel = exports.getChannelForPagingMethodColumn = exports.isPagingMethodColumn = exports.PAGING_METHOD_COLUMNS = exports.MAX_PAGING_LADDER_WAIT_IN_MINUTES = exports.PAGING_LADDER_WAITS_IN_MINUTES = exports.getSeverityColumnForOnCallRuleKind = exports.PAGING_LADDER_APPLY_ROUTE = exports.PAGING_LADDER_API_PATH = void 0;
|
|
37
|
+
const OnCallRuleKind_1 = __importStar(require("./OnCallRuleKind"));
|
|
38
|
+
const PushNotificationLevel_1 = require("./PushNotificationLevel");
|
|
39
|
+
const NotificationRepeat_1 = require("./NotificationRepeat");
|
|
40
|
+
const OnCallPageChannel_1 = require("../OnCallDutyPolicy/OnCallPageChannel");
|
|
41
|
+
/*
|
|
42
|
+
* HOW TO REACH ME: ONE PAGING LADDER FOR EVERYTHING (#6820).
|
|
43
|
+
*
|
|
44
|
+
* A person's on-call rules are a grid: four kinds of page (incidents,
|
|
45
|
+
* incident episodes, alerts, alert episodes), a card per severity in each,
|
|
46
|
+
* and in each card rules of the form "this method, after this many
|
|
47
|
+
* minutes". What most people want to say is one sentence - "push and SMS
|
|
48
|
+
* at once, then a call after five minutes" - for every card. That sentence
|
|
49
|
+
* is a ladder: a list of steps, each a method and a wait.
|
|
50
|
+
*
|
|
51
|
+
* A ladder is not stored anywhere. It is read from the grid's rows and
|
|
52
|
+
* written back as them: saving one writes one UserNotificationRule per step
|
|
53
|
+
* in every live card, exactly the rows a person would get by adding them to
|
|
54
|
+
* each card by hand. Nothing about how pages are sent changes, and every
|
|
55
|
+
* reader of the rules (UserOnCallLogService, On-Call Readiness, Who is told,
|
|
56
|
+
* Setup health, the setup checklist) keeps reading the same rows.
|
|
57
|
+
*
|
|
58
|
+
* - getPagingLadderCells: the grid's cards, from the project's severities.
|
|
59
|
+
* - readPagingLadder: the ladder a person's rules make, and the cards that
|
|
60
|
+
* differ from it ("Critical incidents: also a call at once").
|
|
61
|
+
* - planPagingLadderSave: the rows to create, change and delete so every
|
|
62
|
+
* live card holds the ladder, keeping the rows that already do.
|
|
63
|
+
* - getPagingLadderRules: the rows a ladder is, for a person with none.
|
|
64
|
+
*
|
|
65
|
+
* Archived severities are left as they are. Nobody picks one again - the
|
|
66
|
+
* server refuses a new rule for one (ArchivedValueCheck) - and the records
|
|
67
|
+
* that keep one still page by its rules, so a ladder neither reads them nor
|
|
68
|
+
* writes them. A severity added later is given the person's rules by the
|
|
69
|
+
* backfill (Workers BackfillNotificationRulesForNewSeverities), which
|
|
70
|
+
* mirrors what the person already has: a ladder, when they have one.
|
|
71
|
+
*
|
|
72
|
+
* The order of a ladder is its waits: steps fire after their wait, and two
|
|
73
|
+
* with the same wait fire together. Steps with the same wait are listed
|
|
74
|
+
* gentlest first (push before SMS before a call), the way people say it.
|
|
75
|
+
*
|
|
76
|
+
* Pure: no models, no database, no React. The Dashboard reads and draws a
|
|
77
|
+
* ladder with it, the server writes one with it (PagingLadderService), and
|
|
78
|
+
* anything else that sets up paging - Ask AI's set_up_paging - can too.
|
|
79
|
+
*/
|
|
80
|
+
// Where the Dashboard saves a ladder (Server/API/PagingLadderAPI).
|
|
81
|
+
exports.PAGING_LADDER_API_PATH = "/paging-ladder";
|
|
82
|
+
exports.PAGING_LADDER_APPLY_ROUTE = `${exports.PAGING_LADDER_API_PATH}/apply`;
|
|
83
|
+
/*
|
|
84
|
+
* Incidents and incident episodes are banded by incident severity, alerts
|
|
85
|
+
* and alert episodes by alert severity.
|
|
86
|
+
*/
|
|
87
|
+
const SEVERITY_COLUMN_BY_KIND = {
|
|
88
|
+
[OnCallRuleKind_1.default.Incidents]: "incidentSeverityId",
|
|
89
|
+
[OnCallRuleKind_1.default.IncidentEpisodes]: "incidentSeverityId",
|
|
90
|
+
[OnCallRuleKind_1.default.Alerts]: "alertSeverityId",
|
|
91
|
+
[OnCallRuleKind_1.default.AlertEpisodes]: "alertSeverityId",
|
|
92
|
+
};
|
|
93
|
+
const getSeverityColumnForOnCallRuleKind = (kind) => {
|
|
94
|
+
return SEVERITY_COLUMN_BY_KIND[kind];
|
|
95
|
+
};
|
|
96
|
+
exports.getSeverityColumnForOnCallRuleKind = getSeverityColumnForOnCallRuleKind;
|
|
97
|
+
// The waits the page offers, in minutes; a rule can hold any other.
|
|
98
|
+
exports.PAGING_LADDER_WAITS_IN_MINUTES = [
|
|
99
|
+
0, 5, 10, 15, 30, 60,
|
|
100
|
+
];
|
|
101
|
+
// The longest wait a ladder takes: a day.
|
|
102
|
+
exports.MAX_PAGING_LADDER_WAIT_IN_MINUTES = 24 * 60;
|
|
103
|
+
/*
|
|
104
|
+
* Steps with the same wait fire together. They are listed gentlest first,
|
|
105
|
+
* so a ladder reads the way people say it: "push, then SMS, then a call".
|
|
106
|
+
*/
|
|
107
|
+
const GENTLEST_FIRST = [
|
|
108
|
+
OnCallPageChannel_1.OnCallPageChannel.Push,
|
|
109
|
+
OnCallPageChannel_1.OnCallPageChannel.Email,
|
|
110
|
+
OnCallPageChannel_1.OnCallPageChannel.Slack,
|
|
111
|
+
OnCallPageChannel_1.OnCallPageChannel.MicrosoftTeams,
|
|
112
|
+
OnCallPageChannel_1.OnCallPageChannel.Mattermost,
|
|
113
|
+
OnCallPageChannel_1.OnCallPageChannel.Telegram,
|
|
114
|
+
OnCallPageChannel_1.OnCallPageChannel.WhatsApp,
|
|
115
|
+
OnCallPageChannel_1.OnCallPageChannel.SMS,
|
|
116
|
+
OnCallPageChannel_1.OnCallPageChannel.Call,
|
|
117
|
+
OnCallPageChannel_1.OnCallPageChannel.Webhook,
|
|
118
|
+
OnCallPageChannel_1.OnCallPageChannel.CustomChannel,
|
|
119
|
+
];
|
|
120
|
+
// Every method column, in the order a rule's columns are read.
|
|
121
|
+
exports.PAGING_METHOD_COLUMNS = OnCallPageChannel_1.ON_CALL_PAGE_CHANNELS.map((info) => {
|
|
122
|
+
return info.field;
|
|
123
|
+
});
|
|
124
|
+
const isPagingMethodColumn = (value) => {
|
|
125
|
+
return exports.PAGING_METHOD_COLUMNS.includes(value);
|
|
126
|
+
};
|
|
127
|
+
exports.isPagingMethodColumn = isPagingMethodColumn;
|
|
128
|
+
// The channel a method column pages by.
|
|
129
|
+
const getChannelForPagingMethodColumn = (column) => {
|
|
130
|
+
const info = OnCallPageChannel_1.ON_CALL_PAGE_CHANNELS.find((candidate) => {
|
|
131
|
+
return candidate.field === column;
|
|
132
|
+
});
|
|
133
|
+
return info ? info.channel : OnCallPageChannel_1.OnCallPageChannel.Email;
|
|
134
|
+
};
|
|
135
|
+
exports.getChannelForPagingMethodColumn = getChannelForPagingMethodColumn;
|
|
136
|
+
// The method column of a channel.
|
|
137
|
+
const getPagingMethodColumnForChannel = (channel) => {
|
|
138
|
+
const info = OnCallPageChannel_1.ON_CALL_PAGE_CHANNELS.find((candidate) => {
|
|
139
|
+
return candidate.channel === channel;
|
|
140
|
+
});
|
|
141
|
+
return info ? info.field : null;
|
|
142
|
+
};
|
|
143
|
+
exports.getPagingMethodColumnForChannel = getPagingMethodColumnForChannel;
|
|
144
|
+
// An id in any of the shapes a row carries it, as a plain string ("" when none).
|
|
145
|
+
const readPagingId = (value) => {
|
|
146
|
+
if (value === null || value === undefined) {
|
|
147
|
+
return "";
|
|
148
|
+
}
|
|
149
|
+
if (typeof value === "string") {
|
|
150
|
+
return value.trim();
|
|
151
|
+
}
|
|
152
|
+
if (typeof value === "object") {
|
|
153
|
+
const record = value;
|
|
154
|
+
// An un-hydrated ObjectID: { _type: "ObjectID", value: "<uuid>" }.
|
|
155
|
+
if (typeof record["value"] === "string") {
|
|
156
|
+
return record["value"].trim();
|
|
157
|
+
}
|
|
158
|
+
// A relation object: { _id: "<uuid>" }.
|
|
159
|
+
if (typeof record["_id"] === "string") {
|
|
160
|
+
return record["_id"].trim();
|
|
161
|
+
}
|
|
162
|
+
const text = String(value);
|
|
163
|
+
if (text && text !== "[object Object]") {
|
|
164
|
+
return text.trim();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return "";
|
|
168
|
+
};
|
|
169
|
+
exports.readPagingId = readPagingId;
|
|
170
|
+
const readRuleId = (rule) => {
|
|
171
|
+
return (0, exports.readPagingId)(rule.id) || (0, exports.readPagingId)(rule._id);
|
|
172
|
+
};
|
|
173
|
+
const readWait = (value) => {
|
|
174
|
+
const wait = typeof value === "number" ? value : Number(value);
|
|
175
|
+
if (!Number.isFinite(wait) || wait < 0) {
|
|
176
|
+
return 0;
|
|
177
|
+
}
|
|
178
|
+
return Math.round(wait);
|
|
179
|
+
};
|
|
180
|
+
const readPushLevel = (value) => {
|
|
181
|
+
if (PushNotificationLevel_1.PUSH_NOTIFICATION_LEVELS.includes(value)) {
|
|
182
|
+
return value;
|
|
183
|
+
}
|
|
184
|
+
return PushNotificationLevel_1.DEFAULT_PUSH_NOTIFICATION_LEVEL;
|
|
185
|
+
};
|
|
186
|
+
const readRepeat = (value) => {
|
|
187
|
+
const repeat = typeof value === "number" ? value : Number(value);
|
|
188
|
+
if (!Number.isFinite(repeat) || repeat <= 0) {
|
|
189
|
+
return NotificationRepeat_1.NO_NOTIFICATION_REPEAT;
|
|
190
|
+
}
|
|
191
|
+
return Math.round(repeat);
|
|
192
|
+
};
|
|
193
|
+
/*
|
|
194
|
+
* The cards of the grid, in its order: Incidents, Incident Episodes,
|
|
195
|
+
* Alerts, Alert Episodes, and in each the severities in the order given
|
|
196
|
+
* (most severe first, as the project ranks them). Archived ones are
|
|
197
|
+
* included, marked: a ladder leaves them as they are.
|
|
198
|
+
*/
|
|
199
|
+
const getPagingLadderCells = (data) => {
|
|
200
|
+
const cells = [];
|
|
201
|
+
for (const kind of OnCallRuleKind_1.ON_CALL_RULE_KINDS) {
|
|
202
|
+
const severityColumn = (0, exports.getSeverityColumnForOnCallRuleKind)(kind);
|
|
203
|
+
const severities = severityColumn === "incidentSeverityId"
|
|
204
|
+
? data.incidentSeverities
|
|
205
|
+
: data.alertSeverities;
|
|
206
|
+
for (const severity of severities) {
|
|
207
|
+
const severityId = (0, exports.readPagingId)(severity.id) || (0, exports.readPagingId)(severity._id);
|
|
208
|
+
if (!severityId) {
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
cells.push({
|
|
212
|
+
kind: kind,
|
|
213
|
+
ruleType: (0, OnCallRuleKind_1.getRuleTypeForOnCallRuleKind)(kind),
|
|
214
|
+
severityColumn: severityColumn,
|
|
215
|
+
severityId: severityId,
|
|
216
|
+
severityName: severity.name || "",
|
|
217
|
+
isArchived: Boolean(severity.isArchived),
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return cells;
|
|
222
|
+
};
|
|
223
|
+
exports.getPagingLadderCells = getPagingLadderCells;
|
|
224
|
+
// The cards a ladder applies to: every card whose severity is not archived.
|
|
225
|
+
const getLivePagingLadderCells = (cells) => {
|
|
226
|
+
return cells.filter((cell) => {
|
|
227
|
+
return !cell.isArchived;
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
exports.getLivePagingLadderCells = getLivePagingLadderCells;
|
|
231
|
+
// One card's key: its rule type and severity.
|
|
232
|
+
const getPagingLadderCellKey = (cell) => {
|
|
233
|
+
return `${cell.ruleType}|${cell.severityId}`;
|
|
234
|
+
};
|
|
235
|
+
exports.getPagingLadderCellKey = getPagingLadderCellKey;
|
|
236
|
+
// The card a rule is on, by its rule type and the severity column of its kind.
|
|
237
|
+
const getRuleCellKey = (rule) => {
|
|
238
|
+
for (const kind of OnCallRuleKind_1.ON_CALL_RULE_KINDS) {
|
|
239
|
+
if (rule.ruleType !== (0, OnCallRuleKind_1.getRuleTypeForOnCallRuleKind)(kind)) {
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
const severityId = (0, exports.readPagingId)(rule[(0, exports.getSeverityColumnForOnCallRuleKind)(kind)]);
|
|
243
|
+
if (!severityId) {
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
return (0, exports.getPagingLadderCellKey)({
|
|
247
|
+
ruleType: rule.ruleType,
|
|
248
|
+
severityId: severityId,
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
return null;
|
|
252
|
+
};
|
|
253
|
+
/*
|
|
254
|
+
* A step with its push settings made explicit for a push method (the
|
|
255
|
+
* rule's defaults when left out) and left off any other, and its wait a
|
|
256
|
+
* whole number of minutes, so two steps that page the same way compare
|
|
257
|
+
* equal.
|
|
258
|
+
*/
|
|
259
|
+
const normalizePagingLadderStep = (step) => {
|
|
260
|
+
const normalized = {
|
|
261
|
+
methodColumn: step.methodColumn,
|
|
262
|
+
methodId: (0, exports.readPagingId)(step.methodId),
|
|
263
|
+
notifyAfterMinutes: readWait(step.notifyAfterMinutes),
|
|
264
|
+
};
|
|
265
|
+
if (step.methodColumn === "userPushId") {
|
|
266
|
+
normalized.pushNotificationLevel = readPushLevel(step.pushNotificationLevel);
|
|
267
|
+
normalized.repeatEveryMinutes = readRepeat(step.repeatEveryMinutes);
|
|
268
|
+
}
|
|
269
|
+
return normalized;
|
|
270
|
+
};
|
|
271
|
+
exports.normalizePagingLadderStep = normalizePagingLadderStep;
|
|
272
|
+
// Which method a step pages, whatever its wait.
|
|
273
|
+
const getPagingLadderMethodKey = (step) => {
|
|
274
|
+
return `${step.methodColumn}:${(0, exports.readPagingId)(step.methodId)}`;
|
|
275
|
+
};
|
|
276
|
+
exports.getPagingLadderMethodKey = getPagingLadderMethodKey;
|
|
277
|
+
// A method and its wait: two steps with the same key page the same way, at the same time.
|
|
278
|
+
const getMethodAndWaitKey = (step) => {
|
|
279
|
+
return `${(0, exports.getPagingLadderMethodKey)(step)}@${readWait(step.notifyAfterMinutes)}`;
|
|
280
|
+
};
|
|
281
|
+
// Everything about a step, push settings included.
|
|
282
|
+
const getPagingLadderStepKey = (step) => {
|
|
283
|
+
const normalized = (0, exports.normalizePagingLadderStep)(step);
|
|
284
|
+
return [
|
|
285
|
+
getMethodAndWaitKey(normalized),
|
|
286
|
+
normalized.pushNotificationLevel || "",
|
|
287
|
+
normalized.repeatEveryMinutes === undefined
|
|
288
|
+
? ""
|
|
289
|
+
: String(normalized.repeatEveryMinutes),
|
|
290
|
+
].join("|");
|
|
291
|
+
};
|
|
292
|
+
exports.getPagingLadderStepKey = getPagingLadderStepKey;
|
|
293
|
+
const getGentlenessRank = (column) => {
|
|
294
|
+
const rank = GENTLEST_FIRST.indexOf((0, exports.getChannelForPagingMethodColumn)(column));
|
|
295
|
+
return rank === -1 ? GENTLEST_FIRST.length : rank;
|
|
296
|
+
};
|
|
297
|
+
// Steps in the order they page: by wait, then gentlest first, then by method.
|
|
298
|
+
const comparePagingLadderSteps = (a, b) => {
|
|
299
|
+
const byWait = readWait(a.notifyAfterMinutes) - readWait(b.notifyAfterMinutes);
|
|
300
|
+
if (byWait !== 0) {
|
|
301
|
+
return byWait;
|
|
302
|
+
}
|
|
303
|
+
const byChannel = getGentlenessRank(a.methodColumn) - getGentlenessRank(b.methodColumn);
|
|
304
|
+
if (byChannel !== 0) {
|
|
305
|
+
return byChannel;
|
|
306
|
+
}
|
|
307
|
+
return (0, exports.readPagingId)(a.methodId).localeCompare((0, exports.readPagingId)(b.methodId));
|
|
308
|
+
};
|
|
309
|
+
exports.comparePagingLadderSteps = comparePagingLadderSteps;
|
|
310
|
+
/*
|
|
311
|
+
* A ladder as it is kept and compared: every step normalized, a step that
|
|
312
|
+
* pages the same way at the same time as another said once (the first
|
|
313
|
+
* one's push settings win), steps with no method left out, in paging order.
|
|
314
|
+
*/
|
|
315
|
+
const normalizePagingLadderSteps = (steps) => {
|
|
316
|
+
const seen = new Set();
|
|
317
|
+
const normalized = [];
|
|
318
|
+
for (const step of steps) {
|
|
319
|
+
if (!(0, exports.isPagingMethodColumn)(step.methodColumn)) {
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
const candidate = (0, exports.normalizePagingLadderStep)(step);
|
|
323
|
+
if (!candidate.methodId) {
|
|
324
|
+
continue;
|
|
325
|
+
}
|
|
326
|
+
const key = getMethodAndWaitKey(candidate);
|
|
327
|
+
if (seen.has(key)) {
|
|
328
|
+
continue;
|
|
329
|
+
}
|
|
330
|
+
seen.add(key);
|
|
331
|
+
normalized.push(candidate);
|
|
332
|
+
}
|
|
333
|
+
return normalized.sort(exports.comparePagingLadderSteps);
|
|
334
|
+
};
|
|
335
|
+
exports.normalizePagingLadderSteps = normalizePagingLadderSteps;
|
|
336
|
+
/*
|
|
337
|
+
* The step a rule is, or null for a rule that pages nothing: an opt-out
|
|
338
|
+
* row ("do not page me here"), or a row that names no method. A row that
|
|
339
|
+
* names two methods (possible through the API) is read by its first.
|
|
340
|
+
*/
|
|
341
|
+
const getPagingLadderStepFromRule = (rule) => {
|
|
342
|
+
if (rule.isOptOut === true) {
|
|
343
|
+
return null;
|
|
344
|
+
}
|
|
345
|
+
for (const column of exports.PAGING_METHOD_COLUMNS) {
|
|
346
|
+
const methodId = (0, exports.readPagingId)(rule[column]);
|
|
347
|
+
if (!methodId) {
|
|
348
|
+
continue;
|
|
349
|
+
}
|
|
350
|
+
return (0, exports.normalizePagingLadderStep)({
|
|
351
|
+
methodColumn: column,
|
|
352
|
+
methodId: methodId,
|
|
353
|
+
notifyAfterMinutes: readWait(rule.notifyAfterMinutes),
|
|
354
|
+
pushNotificationLevel: readPushLevel(rule.pushNotificationLevel),
|
|
355
|
+
repeatEveryMinutes: readRepeat(rule.repeatEveryMinutes),
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
return null;
|
|
359
|
+
};
|
|
360
|
+
exports.getPagingLadderStepFromRule = getPagingLadderStepFromRule;
|
|
361
|
+
const getStepsSignature = (steps) => {
|
|
362
|
+
return steps.map(exports.getPagingLadderStepKey).join(",");
|
|
363
|
+
};
|
|
364
|
+
const isSamePushSettings = (a, b) => {
|
|
365
|
+
return (0, exports.getPagingLadderStepKey)(a) === (0, exports.getPagingLadderStepKey)(b);
|
|
366
|
+
};
|
|
367
|
+
// How one card's steps differ from the ladder's.
|
|
368
|
+
const comparePagingLadderCell = (data) => {
|
|
369
|
+
const ladderByMethodAndWait = new Map();
|
|
370
|
+
for (const ladderStep of data.ladder) {
|
|
371
|
+
ladderByMethodAndWait.set(getMethodAndWaitKey(ladderStep), ladderStep);
|
|
372
|
+
}
|
|
373
|
+
const extra = [];
|
|
374
|
+
const changed = [];
|
|
375
|
+
const matched = new Set();
|
|
376
|
+
for (const step of data.steps) {
|
|
377
|
+
const key = getMethodAndWaitKey(step);
|
|
378
|
+
const ladderStep = ladderByMethodAndWait.get(key);
|
|
379
|
+
if (!ladderStep) {
|
|
380
|
+
extra.push(step);
|
|
381
|
+
continue;
|
|
382
|
+
}
|
|
383
|
+
matched.add(key);
|
|
384
|
+
if (!isSamePushSettings(step, ladderStep)) {
|
|
385
|
+
changed.push({ step: step, ladderStep: ladderStep });
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
const missing = data.ladder.filter((ladderStep) => {
|
|
389
|
+
return !matched.has(getMethodAndWaitKey(ladderStep));
|
|
390
|
+
});
|
|
391
|
+
if (extra.length === 0 &&
|
|
392
|
+
missing.length === 0 &&
|
|
393
|
+
changed.length === 0 &&
|
|
394
|
+
!data.isMuted) {
|
|
395
|
+
return null;
|
|
396
|
+
}
|
|
397
|
+
return {
|
|
398
|
+
cell: data.cell,
|
|
399
|
+
extra: extra,
|
|
400
|
+
missing: missing,
|
|
401
|
+
changed: changed,
|
|
402
|
+
isMuted: data.isMuted,
|
|
403
|
+
};
|
|
404
|
+
};
|
|
405
|
+
exports.comparePagingLadderCell = comparePagingLadderCell;
|
|
406
|
+
// Each live card's steps, from the person's rules.
|
|
407
|
+
const readPagingLadderCells = (data) => {
|
|
408
|
+
const rulesByCell = new Map();
|
|
409
|
+
for (const rule of data.rules) {
|
|
410
|
+
const cellKey = getRuleCellKey(rule);
|
|
411
|
+
if (!cellKey) {
|
|
412
|
+
continue;
|
|
413
|
+
}
|
|
414
|
+
const list = rulesByCell.get(cellKey) || [];
|
|
415
|
+
list.push(rule);
|
|
416
|
+
rulesByCell.set(cellKey, list);
|
|
417
|
+
}
|
|
418
|
+
return (0, exports.getLivePagingLadderCells)(data.cells).map((cell) => {
|
|
419
|
+
const rules = rulesByCell.get((0, exports.getPagingLadderCellKey)(cell)) || [];
|
|
420
|
+
const steps = (0, exports.normalizePagingLadderSteps)(rules
|
|
421
|
+
.map(exports.getPagingLadderStepFromRule)
|
|
422
|
+
.filter((step) => {
|
|
423
|
+
return step !== null;
|
|
424
|
+
}));
|
|
425
|
+
const hasOptOut = rules.some((rule) => {
|
|
426
|
+
return rule.isOptOut === true;
|
|
427
|
+
});
|
|
428
|
+
return {
|
|
429
|
+
cell: cell,
|
|
430
|
+
steps: steps,
|
|
431
|
+
isMuted: hasOptOut && steps.length === 0,
|
|
432
|
+
ruleCount: rules.length,
|
|
433
|
+
};
|
|
434
|
+
});
|
|
435
|
+
};
|
|
436
|
+
exports.readPagingLadderCells = readPagingLadderCells;
|
|
437
|
+
/*
|
|
438
|
+
* The ladder a person's rules make: what most live cards page - every
|
|
439
|
+
* one of them for most people, since a verified method starts with a rule
|
|
440
|
+
* in every card - and the cards that differ from it. A tie goes to the
|
|
441
|
+
* card first in the grid's order (the most severe incident). With no card
|
|
442
|
+
* paging anything, the ladder is empty.
|
|
443
|
+
*/
|
|
444
|
+
const readPagingLadder = (data) => {
|
|
445
|
+
const cellReadings = (0, exports.readPagingLadderCells)(data);
|
|
446
|
+
const counts = new Map();
|
|
447
|
+
for (const reading of cellReadings) {
|
|
448
|
+
if (reading.steps.length === 0) {
|
|
449
|
+
continue;
|
|
450
|
+
}
|
|
451
|
+
const signature = getStepsSignature(reading.steps);
|
|
452
|
+
const known = counts.get(signature);
|
|
453
|
+
if (known) {
|
|
454
|
+
known.count++;
|
|
455
|
+
continue;
|
|
456
|
+
}
|
|
457
|
+
counts.set(signature, { count: 1, steps: reading.steps });
|
|
458
|
+
}
|
|
459
|
+
let ladder = [];
|
|
460
|
+
let bestCount = 0;
|
|
461
|
+
// Map keeps insertion order, so the first card wins a tie.
|
|
462
|
+
for (const candidate of counts.values()) {
|
|
463
|
+
if (candidate.count > bestCount) {
|
|
464
|
+
bestCount = candidate.count;
|
|
465
|
+
ladder = candidate.steps;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
const differences = [];
|
|
469
|
+
for (const reading of cellReadings) {
|
|
470
|
+
const difference = (0, exports.comparePagingLadderCell)({
|
|
471
|
+
cell: reading.cell,
|
|
472
|
+
steps: reading.steps,
|
|
473
|
+
isMuted: reading.isMuted,
|
|
474
|
+
ladder: ladder,
|
|
475
|
+
});
|
|
476
|
+
if (difference) {
|
|
477
|
+
differences.push(difference);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
return {
|
|
481
|
+
steps: ladder.map((step) => {
|
|
482
|
+
return Object.assign({}, step);
|
|
483
|
+
}),
|
|
484
|
+
isOneLadder: differences.length === 0,
|
|
485
|
+
differences: differences,
|
|
486
|
+
cells: cellReadings,
|
|
487
|
+
};
|
|
488
|
+
};
|
|
489
|
+
exports.readPagingLadder = readPagingLadder;
|
|
490
|
+
const toRuleToCreate = (data) => {
|
|
491
|
+
var _a;
|
|
492
|
+
const step = (0, exports.normalizePagingLadderStep)(data.step);
|
|
493
|
+
const rule = {
|
|
494
|
+
ruleType: data.cell.ruleType,
|
|
495
|
+
severityColumn: data.cell.severityColumn,
|
|
496
|
+
severityId: data.cell.severityId,
|
|
497
|
+
methodColumn: step.methodColumn,
|
|
498
|
+
methodId: step.methodId,
|
|
499
|
+
notifyAfterMinutes: step.notifyAfterMinutes,
|
|
500
|
+
repeatEveryMinutes: (_a = step.repeatEveryMinutes) !== null && _a !== void 0 ? _a : NotificationRepeat_1.NO_NOTIFICATION_REPEAT,
|
|
501
|
+
};
|
|
502
|
+
if (step.methodColumn === "userPushId") {
|
|
503
|
+
rule.pushNotificationLevel =
|
|
504
|
+
step.pushNotificationLevel || PushNotificationLevel_1.DEFAULT_PUSH_NOTIFICATION_LEVEL;
|
|
505
|
+
}
|
|
506
|
+
return rule;
|
|
507
|
+
};
|
|
508
|
+
/*
|
|
509
|
+
* What to write so every live card holds the ladder, and nothing else.
|
|
510
|
+
* Archived cards, rules of no card (the on-call and off-call shift rules)
|
|
511
|
+
* and rules on a severity the project no longer has are left as they are.
|
|
512
|
+
*
|
|
513
|
+
* In each live card:
|
|
514
|
+
* 1. a row that already pages a step exactly is kept;
|
|
515
|
+
* 2. a row that pages a step's method at another wait, or sounding or
|
|
516
|
+
* repeating otherwise, is changed to the step - the same row, so its
|
|
517
|
+
* method is never rewritten (only an admin may re-point a method);
|
|
518
|
+
* 3. what is left over is deleted: other methods, an opt-out row, a row
|
|
519
|
+
* that names no method, a second copy of a step;
|
|
520
|
+
* 4. what is still missing is created.
|
|
521
|
+
*/
|
|
522
|
+
const planPagingLadderSave = (data) => {
|
|
523
|
+
const ladder = (0, exports.normalizePagingLadderSteps)(data.steps);
|
|
524
|
+
const plan = {
|
|
525
|
+
create: [],
|
|
526
|
+
update: [],
|
|
527
|
+
delete: [],
|
|
528
|
+
unchangedCount: 0,
|
|
529
|
+
};
|
|
530
|
+
const rulesByCell = new Map();
|
|
531
|
+
for (const rule of data.rules) {
|
|
532
|
+
const cellKey = getRuleCellKey(rule);
|
|
533
|
+
if (!cellKey || !readRuleId(rule)) {
|
|
534
|
+
continue;
|
|
535
|
+
}
|
|
536
|
+
const list = rulesByCell.get(cellKey) || [];
|
|
537
|
+
list.push(rule);
|
|
538
|
+
rulesByCell.set(cellKey, list);
|
|
539
|
+
}
|
|
540
|
+
for (const cell of (0, exports.getLivePagingLadderCells)(data.cells)) {
|
|
541
|
+
const remainingRules = [
|
|
542
|
+
...(rulesByCell.get((0, exports.getPagingLadderCellKey)(cell)) || []),
|
|
543
|
+
];
|
|
544
|
+
const remainingSteps = [...ladder];
|
|
545
|
+
// 1. Exact matches stay.
|
|
546
|
+
for (let i = remainingSteps.length - 1; i >= 0; i--) {
|
|
547
|
+
const stepKey = (0, exports.getPagingLadderStepKey)(remainingSteps[i]);
|
|
548
|
+
const ruleIndex = remainingRules.findIndex((rule) => {
|
|
549
|
+
const ruleStep = (0, exports.getPagingLadderStepFromRule)(rule);
|
|
550
|
+
return Boolean(ruleStep && (0, exports.getPagingLadderStepKey)(ruleStep) === stepKey);
|
|
551
|
+
});
|
|
552
|
+
if (ruleIndex === -1) {
|
|
553
|
+
continue;
|
|
554
|
+
}
|
|
555
|
+
remainingRules.splice(ruleIndex, 1);
|
|
556
|
+
remainingSteps.splice(i, 1);
|
|
557
|
+
plan.unchangedCount++;
|
|
558
|
+
}
|
|
559
|
+
// 2. The same method at another wait, or with other push settings, is changed.
|
|
560
|
+
for (let i = 0; i < remainingSteps.length;) {
|
|
561
|
+
const step = remainingSteps[i];
|
|
562
|
+
const methodKey = (0, exports.getPagingLadderMethodKey)(step);
|
|
563
|
+
const ruleIndex = remainingRules.findIndex((rule) => {
|
|
564
|
+
const ruleStep = (0, exports.getPagingLadderStepFromRule)(rule);
|
|
565
|
+
return Boolean(ruleStep && (0, exports.getPagingLadderMethodKey)(ruleStep) === methodKey);
|
|
566
|
+
});
|
|
567
|
+
if (ruleIndex === -1) {
|
|
568
|
+
i++;
|
|
569
|
+
continue;
|
|
570
|
+
}
|
|
571
|
+
const rule = remainingRules[ruleIndex];
|
|
572
|
+
const ruleStep = (0, exports.getPagingLadderStepFromRule)(rule);
|
|
573
|
+
const update = { id: readRuleId(rule) };
|
|
574
|
+
if (ruleStep.notifyAfterMinutes !== step.notifyAfterMinutes) {
|
|
575
|
+
update.notifyAfterMinutes = step.notifyAfterMinutes;
|
|
576
|
+
}
|
|
577
|
+
if (step.methodColumn === "userPushId") {
|
|
578
|
+
if (ruleStep.pushNotificationLevel !== step.pushNotificationLevel) {
|
|
579
|
+
update.pushNotificationLevel = step.pushNotificationLevel;
|
|
580
|
+
}
|
|
581
|
+
if (ruleStep.repeatEveryMinutes !== step.repeatEveryMinutes) {
|
|
582
|
+
update.repeatEveryMinutes = step.repeatEveryMinutes;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
plan.update.push(update);
|
|
586
|
+
remainingRules.splice(ruleIndex, 1);
|
|
587
|
+
remainingSteps.splice(i, 1);
|
|
588
|
+
}
|
|
589
|
+
// 3. What is left over goes.
|
|
590
|
+
for (const rule of remainingRules) {
|
|
591
|
+
plan.delete.push(readRuleId(rule));
|
|
592
|
+
}
|
|
593
|
+
// 4. What is still missing is added.
|
|
594
|
+
for (const step of remainingSteps) {
|
|
595
|
+
plan.create.push(toRuleToCreate({ cell: cell, step: step }));
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
return plan;
|
|
599
|
+
};
|
|
600
|
+
exports.planPagingLadderSave = planPagingLadderSave;
|
|
601
|
+
/*
|
|
602
|
+
* The rows a ladder is, in every live card, for a person with no rules:
|
|
603
|
+
* one rule per step per card, in the grid's order.
|
|
604
|
+
*/
|
|
605
|
+
const getPagingLadderRules = (data) => {
|
|
606
|
+
return (0, exports.planPagingLadderSave)({
|
|
607
|
+
cells: data.cells,
|
|
608
|
+
rules: [],
|
|
609
|
+
steps: data.steps,
|
|
610
|
+
}).create;
|
|
611
|
+
};
|
|
612
|
+
exports.getPagingLadderRules = getPagingLadderRules;
|
|
613
|
+
// Whether a plan writes nothing.
|
|
614
|
+
const isEmptyPagingLadderPlan = (plan) => {
|
|
615
|
+
return (plan.create.length === 0 &&
|
|
616
|
+
plan.update.length === 0 &&
|
|
617
|
+
plan.delete.length === 0);
|
|
618
|
+
};
|
|
619
|
+
exports.isEmptyPagingLadderPlan = isEmptyPagingLadderPlan;
|
|
620
|
+
/*
|
|
621
|
+
* Why a ladder sent to the server cannot be saved, as a sentence that says
|
|
622
|
+
* what to do; null when it can. Checked on the server before anything is
|
|
623
|
+
* written, and by the page before it sends.
|
|
624
|
+
*/
|
|
625
|
+
const getPagingLadderStepsProblem = (steps) => {
|
|
626
|
+
if (!Array.isArray(steps) || steps.length === 0) {
|
|
627
|
+
return "A ladder needs at least one step. Add a way to reach you, then save.";
|
|
628
|
+
}
|
|
629
|
+
for (const value of steps) {
|
|
630
|
+
if (!value || typeof value !== "object") {
|
|
631
|
+
return "Each step of a ladder needs a notification method and a wait. Choose both, then save.";
|
|
632
|
+
}
|
|
633
|
+
const step = value;
|
|
634
|
+
if (!(0, exports.isPagingMethodColumn)(step["methodColumn"])) {
|
|
635
|
+
return "A step names a kind of notification method OneUptime does not know. Choose one of your notification methods, then save.";
|
|
636
|
+
}
|
|
637
|
+
if (!(0, exports.readPagingId)(step["methodId"])) {
|
|
638
|
+
return "A step has no notification method. Choose one of your notification methods, then save.";
|
|
639
|
+
}
|
|
640
|
+
const wait = step["notifyAfterMinutes"];
|
|
641
|
+
if (typeof wait !== "number" ||
|
|
642
|
+
!Number.isInteger(wait) ||
|
|
643
|
+
wait < 0 ||
|
|
644
|
+
wait > exports.MAX_PAGING_LADDER_WAIT_IN_MINUTES) {
|
|
645
|
+
return "A step's wait must be a whole number of minutes from 0 to 1440 (a day). Choose another wait, then save.";
|
|
646
|
+
}
|
|
647
|
+
const level = step["pushNotificationLevel"];
|
|
648
|
+
if (level !== undefined &&
|
|
649
|
+
level !== null &&
|
|
650
|
+
!PushNotificationLevel_1.PUSH_NOTIFICATION_LEVELS.includes(level)) {
|
|
651
|
+
return "A push step must sound as a Critical alert or a Standard notification. Choose one, then save.";
|
|
652
|
+
}
|
|
653
|
+
const repeat = step["repeatEveryMinutes"];
|
|
654
|
+
if (repeat !== undefined &&
|
|
655
|
+
repeat !== null &&
|
|
656
|
+
repeat !== NotificationRepeat_1.NO_NOTIFICATION_REPEAT &&
|
|
657
|
+
!NotificationRepeat_1.REPEAT_EVERY_MINUTES_OPTIONS.includes(repeat)) {
|
|
658
|
+
return "A push step repeats every 1, 2, 3, 5, 10, 15 or 30 minutes, or not at all. Choose one, then save.";
|
|
659
|
+
}
|
|
660
|
+
if (step["methodColumn"] !== "userPushId" &&
|
|
661
|
+
typeof repeat === "number" &&
|
|
662
|
+
repeat !== NotificationRepeat_1.NO_NOTIFICATION_REPEAT) {
|
|
663
|
+
return "Only a push step can repeat until acknowledged. Turn repeating off for the other steps, then save.";
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
return null;
|
|
667
|
+
};
|
|
668
|
+
exports.getPagingLadderStepsProblem = getPagingLadderStepsProblem;
|
|
669
|
+
// A ladder sent as JSON, as steps: call getPagingLadderStepsProblem first.
|
|
670
|
+
const readPagingLadderSteps = (steps) => {
|
|
671
|
+
return (0, exports.normalizePagingLadderSteps)(steps.map((value) => {
|
|
672
|
+
const step = (value || {});
|
|
673
|
+
return {
|
|
674
|
+
methodColumn: step["methodColumn"],
|
|
675
|
+
methodId: (0, exports.readPagingId)(step["methodId"]),
|
|
676
|
+
notifyAfterMinutes: step["notifyAfterMinutes"],
|
|
677
|
+
pushNotificationLevel: step["pushNotificationLevel"],
|
|
678
|
+
repeatEveryMinutes: step["repeatEveryMinutes"],
|
|
679
|
+
};
|
|
680
|
+
}));
|
|
681
|
+
};
|
|
682
|
+
exports.readPagingLadderSteps = readPagingLadderSteps;
|