@oneuptime/common 14.1.0 → 14.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (249) hide show
  1. package/Models/DatabaseModels/Alert.d.mts +1 -0
  2. package/Models/DatabaseModels/Alert.d.ts +1 -0
  3. package/Models/DatabaseModels/Alert.js +34 -0
  4. package/Models/DatabaseModels/AutoRemediationSuggestion.d.mts +2 -0
  5. package/Models/DatabaseModels/AutoRemediationSuggestion.d.ts +2 -0
  6. package/Models/DatabaseModels/AutoRemediationSuggestion.js +62 -0
  7. package/Models/DatabaseModels/Incident.d.mts +1 -0
  8. package/Models/DatabaseModels/Incident.d.ts +1 -0
  9. package/Models/DatabaseModels/Incident.js +35 -0
  10. package/Models/DatabaseModels/IncidentPostmortemActionItem.d.mts +31 -0
  11. package/Models/DatabaseModels/IncidentPostmortemActionItem.d.ts +31 -0
  12. package/Models/DatabaseModels/IncidentPostmortemActionItem.js +591 -0
  13. package/Models/DatabaseModels/IncidentPostmortemActionItem.mjs +3 -0
  14. package/Models/DatabaseModels/Index.js +2 -0
  15. package/Models/DatabaseModels/TelemetryIngestionKey.js +1 -1
  16. package/Types/AI/AIActionWords.d.mts +3 -1
  17. package/Types/AI/AIActionWords.d.ts +3 -1
  18. package/Types/AI/AIActionWords.js +70 -1
  19. package/Types/AI/AIActionWords.mjs +2 -0
  20. package/Types/AI/AIChatTypes.d.mts +2 -1
  21. package/Types/AI/AIChatTypes.d.ts +2 -1
  22. package/Types/AI/AIReadTableWords.d.mts +192 -0
  23. package/Types/AI/AIReadTableWords.d.ts +192 -0
  24. package/Types/AI/AIReadTableWords.js +368 -0
  25. package/Types/AI/AIReadTableWords.mjs +18 -0
  26. package/Types/AI/AiRunRefusal.d.mts +3 -0
  27. package/Types/AI/AiRunRefusal.d.ts +3 -0
  28. package/Types/AI/AiRunRefusal.js +22 -1
  29. package/Types/AI/ResourceAiAccessPermissions.js +7 -18
  30. package/Types/AuditLog/AuditLogActionLabel.js +19 -9
  31. package/Types/BaseDatabase/AggregationIntervalUtil.d.mts +16 -0
  32. package/Types/BaseDatabase/AggregationIntervalUtil.d.ts +16 -0
  33. package/Types/BaseDatabase/AggregationIntervalUtil.js +123 -16
  34. package/Types/Cloud/CloudResourceHealth.d.mts +30 -1
  35. package/Types/Cloud/CloudResourceHealth.d.ts +30 -1
  36. package/Types/Cloud/CloudResourceHealth.js +405 -13
  37. package/Types/Cloud/CloudResourceHealth.mjs +28 -0
  38. package/Types/DataObservability/DataCheckRefusals.d.mts +32 -0
  39. package/Types/DataObservability/DataCheckRefusals.d.ts +32 -0
  40. package/Types/DataObservability/DataCheckRefusals.js +77 -0
  41. package/Types/DataObservability/DataCheckRefusals.mjs +8 -0
  42. package/Types/Database/AccessControl/PermissionScopeNarrowing.js +4 -0
  43. package/Types/Date.d.mts +2 -0
  44. package/Types/Date.d.ts +2 -0
  45. package/Types/Date.js +22 -0
  46. package/Types/DateLanguage.d.mts +2 -0
  47. package/Types/DateLanguage.d.ts +2 -0
  48. package/Types/DateLanguage.js +8 -5
  49. package/Types/Email/EmailTemplateType.d.mts +1 -0
  50. package/Types/Email/EmailTemplateType.d.ts +1 -0
  51. package/Types/Email/EmailTemplateType.js +2 -0
  52. package/Types/Exception/EgressGuardException.js +1 -1
  53. package/Types/Exception/ErrorMessageRule.d.mts +1 -0
  54. package/Types/Exception/ErrorMessageRule.d.ts +1 -0
  55. package/Types/Exception/ErrorMessageRule.js +67 -13
  56. package/Types/Exception/ErrorMessageRule.mjs +1 -0
  57. package/Types/Exception/ExceptionMessages.d.mts +2 -0
  58. package/Types/Exception/ExceptionMessages.d.ts +2 -0
  59. package/Types/Exception/ExceptionMessages.js +2 -0
  60. package/Types/Incident/PostmortemActionItemStatus.d.mts +17 -0
  61. package/Types/Incident/PostmortemActionItemStatus.d.ts +17 -0
  62. package/Types/Incident/PostmortemActionItemStatus.js +74 -0
  63. package/Types/Incident/PostmortemActionItemStatus.mjs +5 -0
  64. package/Types/JSONFunctions.js +10 -3
  65. package/Types/Link.d.mts +1 -0
  66. package/Types/Link.d.ts +1 -0
  67. package/Types/MeaningKeys.d.mts +4 -0
  68. package/Types/MeaningKeys.d.ts +4 -0
  69. package/Types/MeaningKeys.js +74 -0
  70. package/Types/MeaningKeys.mjs +5 -0
  71. package/Types/Monitor/WhoIsTold.d.mts +3 -0
  72. package/Types/Monitor/WhoIsTold.d.ts +3 -0
  73. package/Types/Monitor/WhoIsTold.js +63 -13
  74. package/Types/NoBreakSpaces.d.mts +16 -0
  75. package/Types/NoBreakSpaces.d.ts +16 -0
  76. package/Types/NoBreakSpaces.js +419 -0
  77. package/Types/NoBreakSpaces.mjs +9 -0
  78. package/Types/NotificationRule/PagingLadder.d.mts +12 -0
  79. package/Types/NotificationRule/PagingLadder.d.ts +12 -0
  80. package/Types/NotificationRule/PagingLadder.js +159 -11
  81. package/Types/NotificationRule/PagingLadder.mjs +3 -0
  82. package/Types/OnCallDutyPolicy/OnCallPageRecordGone.d.mts +3 -0
  83. package/Types/OnCallDutyPolicy/OnCallPageRecordGone.d.ts +3 -0
  84. package/Types/OnCallDutyPolicy/OnCallPageRecordGone.js +42 -0
  85. package/Types/OnCallDutyPolicy/OnCallPageRecordGone.mjs +4 -0
  86. package/Types/OnCallDutyPolicy/OnCallPageWords.d.mts +6 -2
  87. package/Types/OnCallDutyPolicy/OnCallPageWords.d.ts +6 -2
  88. package/Types/OnCallDutyPolicy/OnCallPageWords.js +21 -20
  89. package/Types/OnCallDutyPolicy/OnCallPersonPage.d.mts +4 -0
  90. package/Types/OnCallDutyPolicy/OnCallPersonPage.d.ts +4 -0
  91. package/Types/OnCallDutyPolicy/OnCallPersonPage.js +125 -1
  92. package/Types/OnCallDutyPolicy/OnCallPersonPage.mjs +1 -0
  93. package/Types/OnCallDutyPolicy/OnCallTestPage.d.mts +2 -0
  94. package/Types/OnCallDutyPolicy/OnCallTestPage.d.ts +2 -0
  95. package/Types/OnCallDutyPolicy/OnCallTestPage.js +12 -0
  96. package/Types/OnCallDutyPolicy/OnCallTestPage.mjs +1 -0
  97. package/Types/OpenStack/OpenStackCapacity.js +12 -5
  98. package/Types/Permission.d.mts +4 -0
  99. package/Types/Permission.d.ts +4 -0
  100. package/Types/Permission.js +64 -8
  101. package/Types/Product/ProductUsage.js +2 -1
  102. package/Types/Product/ProjectProductsAnswer.js +2 -1
  103. package/Types/ResourceAiAgent/AiResourceType.d.mts +1 -0
  104. package/Types/ResourceAiAgent/AiResourceType.d.ts +1 -0
  105. package/Types/ResourceAiAgent/AiResourceType.js +12 -0
  106. package/Types/Rum/ProductAnalyticsEventReads.js +10 -1
  107. package/Types/Rum/ProductAnalyticsEvents.js +13 -1
  108. package/Types/Rum/SessionReplayCustomEvents.d.mts +4 -1
  109. package/Types/Rum/SessionReplayCustomEvents.d.ts +4 -1
  110. package/Types/Rum/SessionReplayCustomEvents.js +12 -0
  111. package/Types/Rum/SessionReplayCustomEvents.mjs +1 -0
  112. package/Types/SetupHealth/SetupHealth.d.mts +1 -0
  113. package/Types/SetupHealth/SetupHealth.d.ts +1 -0
  114. package/Types/SetupHealth/SetupHealth.js +13 -5
  115. package/Types/StatusPage/DefaultStatusNames.d.mts +11 -3
  116. package/Types/StatusPage/DefaultStatusNames.d.ts +11 -3
  117. package/Types/StatusPage/DefaultStatusNames.js +74 -28
  118. package/Types/StatusPage/DefaultStatusNames.mjs +9 -2
  119. package/Types/StatusPage/StateChangeNoteMessage.d.mts +3 -2
  120. package/Types/StatusPage/StateChangeNoteMessage.d.ts +3 -2
  121. package/Types/StatusPage/StateChangeNoteMessage.js +16 -13
  122. package/Types/Telemetry/TelemetryIngestionKeyType.js +7 -6
  123. package/Types/Translator.d.mts +1 -0
  124. package/Types/Translator.d.ts +1 -0
  125. package/Types/Translator.js +100 -19
  126. package/Types/Translator.mjs +1 -0
  127. package/Types/UserSession/SessionLength.d.mts +33 -0
  128. package/Types/UserSession/SessionLength.d.ts +33 -0
  129. package/Types/UserSession/SessionLength.js +134 -5
  130. package/Types/UserSession/SessionLength.mjs +5 -0
  131. package/Types/Workflow/WorkflowStatus.js +21 -10
  132. package/Utils/AI/InvestigationReport.js +2 -2
  133. package/Utils/API.d.mts +0 -11
  134. package/Utils/API.d.ts +0 -11
  135. package/Utils/API.js +0 -432
  136. package/Utils/AiRemediation/Resource/ResourceCommandPolicy.js +2 -2
  137. package/Utils/AiRemediation/VerifiedFixRunbook.d.mts +39 -0
  138. package/Utils/AiRemediation/VerifiedFixRunbook.d.ts +39 -0
  139. package/Utils/AiRemediation/VerifiedFixRunbook.js +231 -0
  140. package/Utils/AiRemediation/VerifiedFixRunbook.mjs +10 -0
  141. package/Utils/Dashboard/DashboardWidgetSorts.js +11 -2
  142. package/Utils/Dashboard/MonitorListWidgetFormat.d.mts +2 -1
  143. package/Utils/Dashboard/MonitorListWidgetFormat.d.ts +2 -1
  144. package/Utils/Dashboard/MonitorListWidgetFormat.js +5 -3
  145. package/Utils/DefaultRecordNames.d.mts +6 -0
  146. package/Utils/DefaultRecordNames.d.ts +6 -0
  147. package/Utils/DefaultRecordNames.js +122 -0
  148. package/Utils/DefaultRecordNames.mjs +6 -0
  149. package/Utils/Grok/Grok.js +7 -4
  150. package/Utils/Incident/PostmortemActionItemCodeTask.d.mts +20 -0
  151. package/Utils/Incident/PostmortemActionItemCodeTask.d.ts +20 -0
  152. package/Utils/Incident/PostmortemActionItemCodeTask.js +107 -0
  153. package/Utils/Incident/PostmortemActionItemCodeTask.mjs +10 -0
  154. package/Utils/Incident/PostmortemActionItemMarkdown.d.mts +39 -0
  155. package/Utils/Incident/PostmortemActionItemMarkdown.d.ts +39 -0
  156. package/Utils/Incident/PostmortemActionItemMarkdown.js +118 -0
  157. package/Utils/Incident/PostmortemActionItemMarkdown.mjs +12 -0
  158. package/Utils/Incident/PostmortemNoteActionItems.d.mts +29 -0
  159. package/Utils/Incident/PostmortemNoteActionItems.d.ts +29 -0
  160. package/Utils/Incident/PostmortemNoteActionItems.js +544 -0
  161. package/Utils/Incident/PostmortemNoteActionItems.mjs +7 -0
  162. package/Utils/LookupTable.d.mts +3 -0
  163. package/Utils/LookupTable.d.ts +3 -0
  164. package/Utils/LookupTable.js +61 -0
  165. package/Utils/LookupTable.mjs +3 -0
  166. package/Utils/Markdown/LinkReferenceDefinitions.d.mts +2 -0
  167. package/Utils/Markdown/LinkReferenceDefinitions.d.ts +2 -0
  168. package/Utils/Markdown/LinkReferenceDefinitions.js +101 -1
  169. package/Utils/Markdown/LinkReferenceDefinitions.mjs +2 -0
  170. package/Utils/Markdown/OverLongText.js +296 -2
  171. package/Utils/Markdown/SlowMarkdown.d.mts +1 -0
  172. package/Utils/Markdown/SlowMarkdown.d.ts +1 -0
  173. package/Utils/Markdown/SlowMarkdown.js +354 -4
  174. package/Utils/Markdown/SlowMarkdown.mjs +1 -0
  175. package/Utils/Metrics/MetricFormulaEvaluator.js +10 -4
  176. package/Utils/Metrics/MetricSeriesFingerprint.js +13 -4
  177. package/Utils/Metrics/MetricSeriesScope.d.mts +5 -0
  178. package/Utils/Metrics/MetricSeriesScope.d.ts +5 -0
  179. package/Utils/Metrics/MetricSeriesScope.js +5 -1
  180. package/Utils/Monitor/MonitorRootCauseWording.d.mts +3 -0
  181. package/Utils/Monitor/MonitorRootCauseWording.d.ts +3 -0
  182. package/Utils/Monitor/MonitorRootCauseWording.js +100 -11
  183. package/Utils/Monitor/ProbeAgreementRule.d.mts +10 -0
  184. package/Utils/Monitor/ProbeAgreementRule.d.ts +10 -0
  185. package/Utils/Monitor/ProbeAgreementRule.js +58 -0
  186. package/Utils/Monitor/ProbeAgreementRule.mjs +3 -0
  187. package/Utils/Monitor/ProbeFailureReading.d.mts +4 -0
  188. package/Utils/Monitor/ProbeFailureReading.d.ts +4 -0
  189. package/Utils/Monitor/ProbeFailureReading.js +30 -1
  190. package/Utils/Monitor/ProbeFailureReading.mjs +1 -0
  191. package/Utils/Monitor/RequestFailureDescriptions.d.mts +61 -0
  192. package/Utils/Monitor/RequestFailureDescriptions.d.ts +61 -0
  193. package/Utils/Monitor/RequestFailureDescriptions.js +252 -0
  194. package/Utils/Monitor/RequestFailureDescriptions.mjs +6 -0
  195. package/Utils/PromQL/PromQLEngine.js +18 -9
  196. package/Utils/PromQL/PromQLFunctionEvaluators.js +114 -58
  197. package/Utils/PromQL/PromQLLabelOrder.d.mts +8 -0
  198. package/Utils/PromQL/PromQLLabelOrder.d.ts +8 -0
  199. package/Utils/PromQL/PromQLLabelOrder.js +212 -0
  200. package/Utils/PromQL/PromQLLabelOrder.mjs +6 -0
  201. package/Utils/PromQL/PromQLLabels.js +4 -3
  202. package/Utils/PromQL/PromQLMetricNames.js +8 -2
  203. package/Utils/PromQL/PromQLParser.js +11 -6
  204. package/Utils/PromQL/PromQLRegex.d.mts +11 -0
  205. package/Utils/PromQL/PromQLRegex.d.ts +11 -0
  206. package/Utils/PromQL/PromQLRegex.js +990 -50
  207. package/Utils/PromQL/PromQLRegex.mjs +3 -0
  208. package/Utils/PromQL/PrometheusResponse.js +3 -1
  209. package/Utils/PromQL/RE2CharacterClass.d.mts +24 -0
  210. package/Utils/PromQL/RE2CharacterClass.d.ts +24 -0
  211. package/Utils/PromQL/RE2CharacterClass.js +532 -0
  212. package/Utils/PromQL/RE2CharacterClass.mjs +16 -0
  213. package/Utils/RequestFailedDetailsUtil.d.mts +15 -0
  214. package/Utils/RequestFailedDetailsUtil.d.ts +15 -0
  215. package/Utils/RequestFailedDetailsUtil.js +452 -0
  216. package/Utils/RequestFailedDetailsUtil.mjs +2 -0
  217. package/Utils/Rum/UrlScrubber.d.mts +1 -1
  218. package/Utils/Rum/UrlScrubber.d.ts +1 -1
  219. package/Utils/Rum/UrlScrubber.js +10 -4
  220. package/Utils/Rum/UserFlow.js +22 -4
  221. package/Utils/SecurityCase/SecurityOverviewMetrics.d.mts +11 -1
  222. package/Utils/SecurityCase/SecurityOverviewMetrics.d.ts +11 -1
  223. package/Utils/SecurityCase/SecurityOverviewMetrics.js +99 -17
  224. package/Utils/SecurityCase/SecurityOverviewMetrics.mjs +3 -0
  225. package/Utils/Sms/OnCallPageSms.d.mts +2 -0
  226. package/Utils/Sms/OnCallPageSms.d.ts +2 -0
  227. package/Utils/Sms/OnCallPageSms.js +3 -1
  228. package/Utils/StateListType.d.mts +11 -0
  229. package/Utils/StateListType.d.ts +11 -0
  230. package/Utils/StateListType.js +21 -0
  231. package/Utils/StateListType.mjs +2 -0
  232. package/Utils/StateOrder.d.mts +8 -11
  233. package/Utils/StateOrder.d.ts +8 -11
  234. package/Utils/StateOrder.js +49 -84
  235. package/Utils/StateOrder.mjs +2 -0
  236. package/Utils/Suggestions/ActionItemCodeTaskSuggestion.d.mts +9 -0
  237. package/Utils/Suggestions/ActionItemCodeTaskSuggestion.d.ts +9 -0
  238. package/Utils/Suggestions/ActionItemCodeTaskSuggestion.js +25 -0
  239. package/Utils/Suggestions/ActionItemCodeTaskSuggestion.mjs +2 -0
  240. package/Utils/Suggestions/VerifiedFixRunbookSuggestion.d.mts +5 -0
  241. package/Utils/Suggestions/VerifiedFixRunbookSuggestion.d.ts +5 -0
  242. package/Utils/Suggestions/VerifiedFixRunbookSuggestion.js +39 -0
  243. package/Utils/Suggestions/VerifiedFixRunbookSuggestion.mjs +2 -0
  244. package/Utils/Syslog/SyslogMessageParser.js +16 -6
  245. package/Utils/Telemetry/HeartbeatAvailability.js +16 -21
  246. package/Utils/ValueFormatter.d.mts +1 -0
  247. package/Utils/ValueFormatter.d.ts +1 -0
  248. package/Utils/ValueFormatter.js +258 -18
  249. package/package.json +1 -1
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
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;
36
+ exports.readPagingLadderSteps = exports.getPagingLadderStepsProblem = exports.isEmptyPagingLadderPlan = exports.getPagingLadderStepsForNewCell = exports.getPagingLadderRules = exports.planPagingLadderSave = exports.readPagingLadder = exports.readPagingLadderCells = exports.comparePagingLadderCell = exports.getPagingLadderStepFromRule = exports.getPagingLadderStepsFromRule = 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.getSeverityColumnForRuleType = exports.getSeverityColumnForOnCallRuleKind = exports.PAGING_LADDER_APPLY_ROUTE = exports.PAGING_LADDER_API_PATH = void 0;
37
37
  const OnCallRuleKind_1 = __importStar(require("./OnCallRuleKind"));
38
38
  const PushNotificationLevel_1 = require("./PushNotificationLevel");
39
39
  const NotificationRepeat_1 = require("./NotificationRepeat");
@@ -61,13 +61,16 @@ const OnCallPageChannel_1 = require("../OnCallDutyPolicy/OnCallPageChannel");
61
61
  * - planPagingLadderSave: the rows to create, change and delete so every
62
62
  * live card holds the ladder, keeping the rows that already do.
63
63
  * - getPagingLadderRules: the rows a ladder is, for a person with none.
64
+ * - getPagingLadderStepsForNewCell: what a card added later starts with,
65
+ * read from the person's other cards on its tab.
64
66
  *
65
67
  * Archived severities are left as they are. Nobody picks one again - the
66
68
  * server refuses a new rule for one (ArchivedValueCheck) - and the records
67
69
  * that keep one still page by its rules, so a ladder neither reads them nor
68
70
  * 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
+ * backfill (Workers BackfillNotificationRulesForNewSeverities), which reads
72
+ * them with getPagingLadderStepsForNewCell: a ladder, push settings and
73
+ * all, when they have one.
71
74
  *
72
75
  * The order of a ladder is its waits: steps fire after their wait, and two
73
76
  * with the same wait fire together. Steps with the same wait are listed
@@ -94,6 +97,16 @@ const getSeverityColumnForOnCallRuleKind = (kind) => {
94
97
  return SEVERITY_COLUMN_BY_KIND[kind];
95
98
  };
96
99
  exports.getSeverityColumnForOnCallRuleKind = getSeverityColumnForOnCallRuleKind;
100
+ // The severity column of a rule type, or null for a rule type of no card.
101
+ const getSeverityColumnForRuleType = (ruleType) => {
102
+ for (const kind of OnCallRuleKind_1.ON_CALL_RULE_KINDS) {
103
+ if ((0, OnCallRuleKind_1.getRuleTypeForOnCallRuleKind)(kind) === ruleType) {
104
+ return SEVERITY_COLUMN_BY_KIND[kind];
105
+ }
106
+ }
107
+ return null;
108
+ };
109
+ exports.getSeverityColumnForRuleType = getSeverityColumnForRuleType;
97
110
  // The waits the page offers, in minutes; a rule can hold any other.
98
111
  exports.PAGING_LADDER_WAITS_IN_MINUTES = [
99
112
  0, 5, 10, 15, 30, 60,
@@ -334,28 +347,39 @@ const normalizePagingLadderSteps = (steps) => {
334
347
  };
335
348
  exports.normalizePagingLadderSteps = normalizePagingLadderSteps;
336
349
  /*
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.
350
+ * Every step a rule pages, in the order a rule's columns are read: none
351
+ * for an opt-out row ("do not page me here") or a row that names no
352
+ * method, and two for a row that names two methods (possible through the
353
+ * API), which pages both.
340
354
  */
341
- const getPagingLadderStepFromRule = (rule) => {
355
+ const getPagingLadderStepsFromRule = (rule) => {
342
356
  if (rule.isOptOut === true) {
343
- return null;
357
+ return [];
344
358
  }
359
+ const steps = [];
345
360
  for (const column of exports.PAGING_METHOD_COLUMNS) {
346
361
  const methodId = (0, exports.readPagingId)(rule[column]);
347
362
  if (!methodId) {
348
363
  continue;
349
364
  }
350
- return (0, exports.normalizePagingLadderStep)({
365
+ steps.push((0, exports.normalizePagingLadderStep)({
351
366
  methodColumn: column,
352
367
  methodId: methodId,
353
368
  notifyAfterMinutes: readWait(rule.notifyAfterMinutes),
354
369
  pushNotificationLevel: readPushLevel(rule.pushNotificationLevel),
355
370
  repeatEveryMinutes: readRepeat(rule.repeatEveryMinutes),
356
- });
371
+ }));
357
372
  }
358
- return null;
373
+ return steps;
374
+ };
375
+ exports.getPagingLadderStepsFromRule = getPagingLadderStepsFromRule;
376
+ /*
377
+ * The step a rule is, or null for a rule that pages nothing: an opt-out
378
+ * row, or a row that names no method. A row that names two methods is read
379
+ * by its first.
380
+ */
381
+ const getPagingLadderStepFromRule = (rule) => {
382
+ return (0, exports.getPagingLadderStepsFromRule)(rule)[0] || null;
359
383
  };
360
384
  exports.getPagingLadderStepFromRule = getPagingLadderStepFromRule;
361
385
  const getStepsSignature = (steps) => {
@@ -610,6 +634,130 @@ const getPagingLadderRules = (data) => {
610
634
  }).create;
611
635
  };
612
636
  exports.getPagingLadderRules = getPagingLadderRules;
637
+ /*
638
+ * THE RULES OF A CARD ADDED LATER (#7452).
639
+ *
640
+ * A severity the project adds is a new card on two tabs (Incidents and
641
+ * Incident Episodes, or Alerts and Alert Episodes), and nobody has a rule
642
+ * in it yet. The backfill (Workers BackfillNotificationRulesForNewSeverities)
643
+ * gives each person, in each new card, what their other cards on its tab
644
+ * page, read the way How to Reach Me reads them:
645
+ *
646
+ * - The tab's live cards are read. An archived severity's rules, a rule
647
+ * of no card (an episode rule written before episode rules had a
648
+ * severity) and a rule on a severity the project no longer has are not
649
+ * on the page, a ladder leaves them as they are, and mixed in they
650
+ * would make the new card differ from the ladder. They are read only
651
+ * for a person with no rule on any live card of the tab, as all that
652
+ * person has said about it.
653
+ * - Every method and wait those cards page is a step of the new card,
654
+ * once: "Critical: a call at once" and "Minor: email after 15 minutes"
655
+ * give both, so nobody loses a way to be reached.
656
+ * - A push sounds and repeats as it does on most of the cards that send
657
+ * it at that wait; a tie goes to the card first in the grid's order
658
+ * (the most severe). Read without them, every new push rule was
659
+ * Critical and sent once (#7452): a ladder of "push, Standard, every 5
660
+ * minutes" now gives the new card exactly that, so one ladder stays
661
+ * one ladder.
662
+ * - When nothing read pages anything and one of the rules is an opt-out,
663
+ * the new card is muted too: a person who muted the tab is not paged
664
+ * for the severity added to it.
665
+ *
666
+ * Null when the person has no rule on the tab at all: the backfill gives
667
+ * them their verified email, at once.
668
+ */
669
+ const getPagingLadderStepsForNewCell = (data) => {
670
+ const severityColumn = (0, exports.getSeverityColumnForRuleType)(data.ruleType);
671
+ if (!severityColumn) {
672
+ return null;
673
+ }
674
+ const newSeverityId = (0, exports.readPagingId)(data.severityId);
675
+ const tabRules = data.rules.filter((rule) => {
676
+ return (rule.ruleType === data.ruleType &&
677
+ (0, exports.readPagingId)(rule[severityColumn]) !== newSeverityId);
678
+ });
679
+ if (tabRules.length === 0) {
680
+ return null;
681
+ }
682
+ // The tab's live cards, in the grid's order, each with the person's rules.
683
+ const liveCards = new Map();
684
+ for (const cell of (0, exports.getLivePagingLadderCells)(data.cells)) {
685
+ if (cell.ruleType === data.ruleType && cell.severityId !== newSeverityId) {
686
+ liveCards.set((0, exports.getPagingLadderCellKey)(cell), []);
687
+ }
688
+ }
689
+ // The rest, by the severity they name ("" for none), in the order given.
690
+ const otherCards = new Map();
691
+ for (const rule of tabRules) {
692
+ const cellKey = getRuleCellKey(rule);
693
+ const liveCard = cellKey
694
+ ? liveCards.get(cellKey)
695
+ : undefined;
696
+ if (liveCard) {
697
+ liveCard.push(rule);
698
+ continue;
699
+ }
700
+ const severityId = (0, exports.readPagingId)(rule[severityColumn]);
701
+ const otherCard = otherCards.get(severityId) || [];
702
+ otherCard.push(rule);
703
+ otherCards.set(severityId, otherCard);
704
+ }
705
+ let cards = Array.from(liveCards.values()).filter((card) => {
706
+ return card.length > 0;
707
+ });
708
+ if (cards.length === 0) {
709
+ cards = Array.from(otherCards.values());
710
+ }
711
+ /*
712
+ * Each card votes once for how it sends each method at each wait (a step
713
+ * it says twice is said once), in the order the cards are read.
714
+ */
715
+ const votesByMethodAndWait = new Map();
716
+ for (const card of cards) {
717
+ const cardSteps = [];
718
+ for (const rule of card) {
719
+ cardSteps.push(...(0, exports.getPagingLadderStepsFromRule)(rule));
720
+ }
721
+ for (const cardStep of (0, exports.normalizePagingLadderSteps)(cardSteps)) {
722
+ const methodAndWaitKey = getMethodAndWaitKey(cardStep);
723
+ const stepKey = (0, exports.getPagingLadderStepKey)(cardStep);
724
+ const votes = votesByMethodAndWait.get(methodAndWaitKey) || [];
725
+ const known = votes.find((vote) => {
726
+ return (0, exports.getPagingLadderStepKey)(vote.step) === stepKey;
727
+ });
728
+ if (known) {
729
+ known.count++;
730
+ }
731
+ else {
732
+ votes.push({ step: cardStep, count: 1 });
733
+ }
734
+ votesByMethodAndWait.set(methodAndWaitKey, votes);
735
+ }
736
+ }
737
+ const steps = [];
738
+ for (const votes of votesByMethodAndWait.values()) {
739
+ // Most cards win; the first card read wins a tie.
740
+ let winner = votes[0];
741
+ for (const vote of votes) {
742
+ if (vote.count > winner.count) {
743
+ winner = vote;
744
+ }
745
+ }
746
+ steps.push(Object.assign({}, winner.step));
747
+ }
748
+ if (steps.length > 0) {
749
+ return { steps: steps.sort(exports.comparePagingLadderSteps), isMuted: false };
750
+ }
751
+ return {
752
+ steps: [],
753
+ isMuted: cards.some((card) => {
754
+ return card.some((rule) => {
755
+ return rule.isOptOut === true;
756
+ });
757
+ }),
758
+ };
759
+ };
760
+ exports.getPagingLadderStepsForNewCell = getPagingLadderStepsForNewCell;
613
761
  // Whether a plan writes nothing.
614
762
  const isEmptyPagingLadderPlan = (plan) => {
615
763
  return (plan.create.length === 0 &&
@@ -14,9 +14,12 @@ export const getPagingLadderMethodKey = commonJsModule.getPagingLadderMethodKey;
14
14
  export const getPagingLadderRules = commonJsModule.getPagingLadderRules;
15
15
  export const getPagingLadderStepFromRule = commonJsModule.getPagingLadderStepFromRule;
16
16
  export const getPagingLadderStepKey = commonJsModule.getPagingLadderStepKey;
17
+ export const getPagingLadderStepsForNewCell = commonJsModule.getPagingLadderStepsForNewCell;
18
+ export const getPagingLadderStepsFromRule = commonJsModule.getPagingLadderStepsFromRule;
17
19
  export const getPagingLadderStepsProblem = commonJsModule.getPagingLadderStepsProblem;
18
20
  export const getPagingMethodColumnForChannel = commonJsModule.getPagingMethodColumnForChannel;
19
21
  export const getSeverityColumnForOnCallRuleKind = commonJsModule.getSeverityColumnForOnCallRuleKind;
22
+ export const getSeverityColumnForRuleType = commonJsModule.getSeverityColumnForRuleType;
20
23
  export const isEmptyPagingLadderPlan = commonJsModule.isEmptyPagingLadderPlan;
21
24
  export const isPagingMethodColumn = commonJsModule.isPagingMethodColumn;
22
25
  export const normalizePagingLadderStep = commonJsModule.normalizePagingLadderStep;
@@ -0,0 +1,3 @@
1
+ export declare const ON_CALL_PAGE_RECORD_DELETED_MESSAGE_START: string;
2
+ export declare const ON_CALL_PAGE_NAMES_NO_RECORD_MESSAGE: string;
3
+ export declare function getOnCallPageRecordDeletedMessage(recordKind: string | null | undefined): string;
@@ -0,0 +1,3 @@
1
+ export declare const ON_CALL_PAGE_RECORD_DELETED_MESSAGE_START: string;
2
+ export declare const ON_CALL_PAGE_NAMES_NO_RECORD_MESSAGE: string;
3
+ export declare function getOnCallPageRecordDeletedMessage(recordKind: string | null | undefined): string;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ /*
3
+ * A PERSON'S PAGE WHOSE INCIDENT, ALERT OR EPISODE IS GONE.
4
+ *
5
+ * A person's on-call log pages them about one record - an incident, an
6
+ * alert, an incident episode or an alert episode - and runs their On-Call
7
+ * Rules ("call me after 10 minutes") until it is acknowledged. A record
8
+ * deleted while some of those rules were still due does not come back:
9
+ * nothing is left to page about, and nobody can acknowledge it. So the log
10
+ * ends there (UserOnCallLog:ExecutePendingExecutions), Completed, saying its
11
+ * record was deleted - the words a page again already ended with when its
12
+ * record was deleted (OnCallAcknowledgementTimeout.getPageAgainOverReason:
13
+ * "incident is deleted").
14
+ *
15
+ * It used to throw a plain Error, which the worker reads as a failure a
16
+ * retry can fix: the log stayed Executing, and was tried, failed and logged
17
+ * an error every minute, forever (issue #8106). Nothing else ends an
18
+ * Executing log: UserOnCallLog:TimeoutStuckExecutions ends Started ones.
19
+ *
20
+ * A log that names no record at all - only a test page has none
21
+ * (OnCallTestPage), and it ends before its record is looked for - is as
22
+ * permanent, and ends the same way.
23
+ */
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.ON_CALL_PAGE_NAMES_NO_RECORD_MESSAGE = exports.ON_CALL_PAGE_RECORD_DELETED_MESSAGE_START = void 0;
26
+ exports.getOnCallPageRecordDeletedMessage = getOnCallPageRecordDeletedMessage;
27
+ // How a log's message starts when its record was deleted.
28
+ exports.ON_CALL_PAGE_RECORD_DELETED_MESSAGE_START = "Execution completed because ";
29
+ // "Execution completed because this page names no incident, alert or episode."
30
+ exports.ON_CALL_PAGE_NAMES_NO_RECORD_MESSAGE = "Execution completed because this page names no incident, alert or episode.";
31
+ /*
32
+ * "Execution completed because incident is deleted." - for the kind of
33
+ * record the log paged about ("incident", "alert", "incident episode",
34
+ * "alert episode"), or the message for a log that names none.
35
+ */
36
+ function getOnCallPageRecordDeletedMessage(recordKind) {
37
+ const kind = (recordKind || "").trim();
38
+ if (!kind) {
39
+ return exports.ON_CALL_PAGE_NAMES_NO_RECORD_MESSAGE;
40
+ }
41
+ return `${exports.ON_CALL_PAGE_RECORD_DELETED_MESSAGE_START}${kind} is deleted.`;
42
+ }
@@ -0,0 +1,4 @@
1
+ import commonJsModule from "./OnCallPageRecordGone.js";
2
+ export const ON_CALL_PAGE_NAMES_NO_RECORD_MESSAGE = commonJsModule.ON_CALL_PAGE_NAMES_NO_RECORD_MESSAGE;
3
+ export const ON_CALL_PAGE_RECORD_DELETED_MESSAGE_START = commonJsModule.ON_CALL_PAGE_RECORD_DELETED_MESSAGE_START;
4
+ export const getOnCallPageRecordDeletedMessage = commonJsModule.getOnCallPageRecordDeletedMessage;
@@ -1,4 +1,6 @@
1
1
  import { OnCallPageAgainNotice } from "./OnCallAcknowledgementTimeout.mjs";
2
+ import { DEFAULT_ALERT_SEVERITY_NAMES } from "../StatusPage/DefaultStatusNames.mjs";
3
+ import { StateListType } from "../../Utils/StateOrder.mjs";
2
4
  import { Translator } from "../Translator.mjs";
3
5
  export declare enum OnCallPageKind {
4
6
  Incident = "incident",
@@ -8,8 +10,9 @@ export declare enum OnCallPageKind {
8
10
  }
9
11
  export declare const getEnglishPageTranslator: () => Translator;
10
12
  export declare const ON_CALL_PAGE_KINDS: ReadonlyArray<OnCallPageKind>;
11
- export declare const DEFAULT_ALERT_SEVERITY_NAMES: ReadonlyArray<string>;
12
- export declare const getOnCallPageStateName: (translator: Translator, name: string | null | undefined) => string;
13
+ export { DEFAULT_ALERT_SEVERITY_NAMES };
14
+ export type OnCallPageNameList = StateListType.IncidentState | StateListType.IncidentSeverity | StateListType.AlertState | StateListType.AlertSeverity;
15
+ export declare const getOnCallPageStateName: (translator: Translator, list: OnCallPageNameList, name: string | null | undefined) => string;
13
16
  export declare const getOnCallPageKindLabel: (translator: Translator, kind: OnCallPageKind) => string;
14
17
  export declare const getOnCallPageRecordLabel: (translator: Translator, kind: OnCallPageKind, number: string | null | undefined) => string;
15
18
  export declare const getOnCallPageKindWords: (translator: Translator, kind: OnCallPageKind) => string;
@@ -53,6 +56,7 @@ export interface OnCallPageSmsWords {
53
56
  projectName: string;
54
57
  isPageAgain: boolean;
55
58
  lead: string;
59
+ isPolicyLead?: boolean | undefined;
56
60
  }) => string;
57
61
  action: string;
58
62
  }
@@ -1,4 +1,6 @@
1
1
  import { OnCallPageAgainNotice } from "./OnCallAcknowledgementTimeout";
2
+ import { DEFAULT_ALERT_SEVERITY_NAMES } from "../StatusPage/DefaultStatusNames";
3
+ import { StateListType } from "../../Utils/StateOrder";
2
4
  import { Translator } from "../Translator";
3
5
  export declare enum OnCallPageKind {
4
6
  Incident = "incident",
@@ -8,8 +10,9 @@ export declare enum OnCallPageKind {
8
10
  }
9
11
  export declare const getEnglishPageTranslator: () => Translator;
10
12
  export declare const ON_CALL_PAGE_KINDS: ReadonlyArray<OnCallPageKind>;
11
- export declare const DEFAULT_ALERT_SEVERITY_NAMES: ReadonlyArray<string>;
12
- export declare const getOnCallPageStateName: (translator: Translator, name: string | null | undefined) => string;
13
+ export { DEFAULT_ALERT_SEVERITY_NAMES };
14
+ export type OnCallPageNameList = StateListType.IncidentState | StateListType.IncidentSeverity | StateListType.AlertState | StateListType.AlertSeverity;
15
+ export declare const getOnCallPageStateName: (translator: Translator, list: OnCallPageNameList, name: string | null | undefined) => string;
13
16
  export declare const getOnCallPageKindLabel: (translator: Translator, kind: OnCallPageKind) => string;
14
17
  export declare const getOnCallPageRecordLabel: (translator: Translator, kind: OnCallPageKind, number: string | null | undefined) => string;
15
18
  export declare const getOnCallPageKindWords: (translator: Translator, kind: OnCallPageKind) => string;
@@ -53,6 +56,7 @@ export interface OnCallPageSmsWords {
53
56
  projectName: string;
54
57
  isPageAgain: boolean;
55
58
  lead: string;
59
+ isPolicyLead?: boolean | undefined;
56
60
  }) => string;
57
61
  action: string;
58
62
  }
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getOnCallPageSmsWords = exports.getOnCallPageCantTakeItEscalate = exports.getOnCallPageAcknowledge = exports.getOnCallPageTapToAcknowledge = exports.getOnCallPageViewInOneUptime = exports.getOnCallPageOnCallWhyLine = exports.getOnCallPageChatHeadline = exports.getOnCallPagePersonPagePushBody = exports.getOnCallPagePushWords = exports.getOnCallPageMemberView = exports.getOnCallPageMemberMonitor = exports.getOnCallPageUntitledMember = exports.getOnCallPageNoResources = exports.getOnCallPageNoRootCause = exports.getOnCallPageEmailSubject = exports.getOnCallPageKindWords = exports.getOnCallPageRecordLabel = exports.getOnCallPageKindLabel = exports.getOnCallPageStateName = exports.DEFAULT_ALERT_SEVERITY_NAMES = exports.ON_CALL_PAGE_KINDS = exports.getEnglishPageTranslator = exports.OnCallPageKind = void 0;
4
4
  const OnCallAcknowledgementTimeout_1 = require("./OnCallAcknowledgementTimeout");
5
5
  const DefaultStatusNames_1 = require("../StatusPage/DefaultStatusNames");
6
+ Object.defineProperty(exports, "DEFAULT_ALERT_SEVERITY_NAMES", { enumerable: true, get: function () { return DefaultStatusNames_1.DEFAULT_ALERT_SEVERITY_NAMES; } });
7
+ const DefaultRecordNames_1 = require("../../Utils/DefaultRecordNames");
6
8
  const Translator_1 = require("../Translator");
7
9
  /*
8
10
  * WHAT A PAGE SAYS, IN THE LANGUAGE OF THE PERSON IT PAGES.
@@ -123,30 +125,17 @@ exports.ON_CALL_PAGE_KINDS = [
123
125
  OnCallPageKind.IncidentEpisode,
124
126
  OnCallPageKind.AlertEpisode,
125
127
  ];
126
- /*
127
- * The default names a new project's alert severities start with. A status
128
- * page never shows an alert, so they are not among the status page's
129
- * names (StatusPage/DefaultStatusNames); a page shows them to its person.
130
- */
131
- exports.DEFAULT_ALERT_SEVERITY_NAMES = [
132
- (0, Translator_1.translationKey)("High"),
133
- (0, Translator_1.translationKey)("Low"),
134
- ];
135
128
  /*
136
129
  * A state's or a severity's name as a page shows it: OneUptime's own
137
130
  * default names in the person's language ("Identifiziert", "Kritischer
138
- * Vorfall", "Hoch"), a name the project gave it as written.
131
+ * Vorfall", "Hoch"), a name the project gave it as written. Which names
132
+ * are defaults goes by the record's own list, as on the Dashboard
133
+ * (Utils/DefaultRecordNames): an incident severity a project named "High"
134
+ * is its own and reads as written, while the default alert severity High
135
+ * reads "Hoch" (#8066).
139
136
  */
140
- const getOnCallPageStateName = (translator, name) => {
141
- if (!name) {
142
- return "";
143
- }
144
- const trimmed = name.trim();
145
- if (!(0, DefaultStatusNames_1.isDefaultStatusName)(trimmed) &&
146
- !exports.DEFAULT_ALERT_SEVERITY_NAMES.includes(trimmed)) {
147
- return name;
148
- }
149
- return translator.translateText(trimmed) || name;
137
+ const getOnCallPageStateName = (translator, list, name) => {
138
+ return (0, DefaultRecordNames_1.translateRecordName)(translator, list, name);
150
139
  };
151
140
  exports.getOnCallPageStateName = getOnCallPageStateName;
152
141
  // "Incident", "Alert episode": a record's kind as a label.
@@ -355,6 +344,18 @@ const getOnCallPageSmsWords = (translator) => {
355
344
  return `${withNumber} (${severityName})`;
356
345
  },
357
346
  head: (data) => {
347
+ if (data.lead && data.isPolicyLead) {
348
+ return data.projectName
349
+ ? translator.translateTemplate("{{lead}} for {{record}} in {{project}}", {
350
+ lead: data.lead,
351
+ record: data.record,
352
+ project: data.projectName,
353
+ })
354
+ : translator.translateTemplate("{{lead}} for {{record}}", {
355
+ lead: data.lead,
356
+ record: data.record,
357
+ });
358
+ }
358
359
  if (data.lead) {
359
360
  return data.projectName
360
361
  ? translator.translateTemplate("{{lead}} about {{record}} in {{project}}", {
@@ -14,7 +14,10 @@ export interface OnCallPersonPageNotice {
14
14
  teamName?: string | undefined;
15
15
  scheduleName?: string | undefined;
16
16
  message?: string | undefined;
17
+ policyName?: string | undefined;
18
+ policyLevel?: number | undefined;
17
19
  }
20
+ export declare function isOnCallPolicyStartedByHandNotice(notice: OnCallPersonPageNotice | null | undefined): boolean;
18
21
  export declare function getOnCallPersonPagePager(notice: OnCallPersonPageNotice): string | TranslatableTerm;
19
22
  export declare function getOnCallPersonPageLead(notice: OnCallPersonPageNotice, translator?: Translator): string;
20
23
  export declare function getOnCallPersonPageWhyLine(notice: OnCallPersonPageNotice, translator?: Translator): string;
@@ -40,6 +43,7 @@ export declare function getOnCallPersonPageEmailLine(data: {
40
43
  recordNoun: string;
41
44
  projectName: string;
42
45
  notice: OnCallPersonPageNotice;
46
+ recordLabel?: string | undefined;
43
47
  translator?: Translator | undefined;
44
48
  }): string;
45
49
  export declare function getOnCallPersonPageEmailMessageLine(notice: OnCallPersonPageNotice, translator?: Translator): string;
@@ -14,7 +14,10 @@ export interface OnCallPersonPageNotice {
14
14
  teamName?: string | undefined;
15
15
  scheduleName?: string | undefined;
16
16
  message?: string | undefined;
17
+ policyName?: string | undefined;
18
+ policyLevel?: number | undefined;
17
19
  }
20
+ export declare function isOnCallPolicyStartedByHandNotice(notice: OnCallPersonPageNotice | null | undefined): boolean;
18
21
  export declare function getOnCallPersonPagePager(notice: OnCallPersonPageNotice): string | TranslatableTerm;
19
22
  export declare function getOnCallPersonPageLead(notice: OnCallPersonPageNotice, translator?: Translator): string;
20
23
  export declare function getOnCallPersonPageWhyLine(notice: OnCallPersonPageNotice, translator?: Translator): string;
@@ -40,6 +43,7 @@ export declare function getOnCallPersonPageEmailLine(data: {
40
43
  recordNoun: string;
41
44
  projectName: string;
42
45
  notice: OnCallPersonPageNotice;
46
+ recordLabel?: string | undefined;
43
47
  translator?: Translator | undefined;
44
48
  }): string;
45
49
  export declare function getOnCallPersonPageEmailMessageLine(notice: OnCallPersonPageNotice, translator?: Translator): string;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ON_CALL_PERSON_PAGE_MESSAGE_MAX_LENGTH = void 0;
4
4
  exports.isOnCallPersonPage = isOnCallPersonPage;
5
5
  exports.toOnCallPersonPageMessage = toOnCallPersonPageMessage;
6
+ exports.isOnCallPolicyStartedByHandNotice = isOnCallPolicyStartedByHandNotice;
6
7
  exports.getOnCallPersonPagePager = getOnCallPersonPagePager;
7
8
  exports.getOnCallPersonPageLead = getOnCallPersonPageLead;
8
9
  exports.getOnCallPersonPageWhyLine = getOnCallPersonPageWhyLine;
@@ -47,6 +48,20 @@ const Translator_1 = require("../Translator");
47
48
  * who paged wrote, where the notification has room for it (OnCallPersonPageNotice).
48
49
  * WhatsApp's words are a template Meta approved, and stay as they are.
49
50
  *
51
+ * AN ON-CALL POLICY A PERSON STARTED BY HAND (OnCallPolicyStartedByHand) IS
52
+ * ASKED FOR TOO, AND SAYS SO THE SAME WAY. Execute On-Call Policy in the
53
+ * Dashboard, Slack, Microsoft Teams or Mattermost, or a page that names a
54
+ * policy, is mostly started on a record somebody is on already, and its
55
+ * notifications told the people its levels page that "a new incident has
56
+ * been created", at every level and every repeat, from nobody
57
+ * (https://github.com/OneUptime/oneuptime/issues/7838). Its notice names the
58
+ * policy (policyName) and the level that pages this person (policyLevel),
59
+ * and every sentence below words it for a policy: "Alice Kim started
60
+ * Database escalation", "You're getting this because you're on level 2 of
61
+ * Database escalation." - never "paged you by name", which the policy's
62
+ * level did, not the person. The message a page that names a policy carries
63
+ * (pageMessage) is said in every channel, as a person's page's is.
64
+ *
50
65
  * This file holds the rule and its words, for the server (the workers that
51
66
  * end runs, the notifications, the runs' chat messages) and for the docs
52
67
  * tests. It imports nothing that needs a server or React.
@@ -105,6 +120,22 @@ function toOnCallPersonPageMessage(message) {
105
120
  function pager(notice) {
106
121
  return notice.pagedByName.trim() || "Someone";
107
122
  }
123
+ /*
124
+ * Whether a notice is of an on-call policy a person started by hand
125
+ * (OnCallPolicyStartedByHand): it names the policy.
126
+ */
127
+ function isOnCallPolicyStartedByHandNotice(notice) {
128
+ return Boolean(notice && (notice.policyName || "").trim());
129
+ }
130
+ // The policy a notice names, as written. Empty for a person's page.
131
+ function startedPolicy(notice) {
132
+ return (notice.policyName || "").trim();
133
+ }
134
+ // The level a notice names, as a whole number from 1. Null for none.
135
+ function startedLevel(notice) {
136
+ const level = Number(notice.policyLevel);
137
+ return Number.isInteger(level) && level >= 1 ? level : null;
138
+ }
108
139
  /*
109
140
  * The name of who paged as a sentence's value: their name as written, or
110
141
  * "Someone" in the sentence's language. An observer's page words its own
@@ -122,6 +153,17 @@ function getOnCallPersonPagePager(notice) {
122
153
  * is one of its members.
123
154
  */
124
155
  function getOnCallPersonPageLead(notice, translator = getEnglishTranslator()) {
156
+ const policyName = startedPolicy(notice);
157
+ /*
158
+ * A policy started by hand: "Alice Kim started Database escalation" -
159
+ * whom it pages is the policy's, said by the why line.
160
+ */
161
+ if (policyName) {
162
+ return translator.translateTemplate("{{pager}} started {{policy}}", {
163
+ pager: getOnCallPersonPagePager(notice),
164
+ policy: policyName,
165
+ });
166
+ }
125
167
  const teamName = (notice.teamName || "").trim();
126
168
  if (teamName) {
127
169
  return translator.translateTemplate("{{pager}} paged {{team}}", {
@@ -147,6 +189,9 @@ function getOnCallPersonPageLead(notice, translator = getEnglishTranslator()) {
147
189
  * Primary.", "... because Alice Kim paged you by name."
148
190
  */
149
191
  function getOnCallPersonPageWhyLine(notice, translator = getEnglishTranslator()) {
192
+ if (startedPolicy(notice)) {
193
+ return getPolicyStartedByHandWhyLine(notice, translator);
194
+ }
150
195
  const teamName = (notice.teamName || "").trim();
151
196
  if (teamName) {
152
197
  return translator.translateTemplate("You're getting this because you're a member of {{team}}.", { team: teamName });
@@ -157,6 +202,37 @@ function getOnCallPersonPageWhyLine(notice, translator = getEnglishTranslator())
157
202
  }
158
203
  return translator.translateTemplate("You're getting this because {{pager}} paged you by name.", { pager: getOnCallPersonPagePager(notice) });
159
204
  }
205
+ /*
206
+ * Why the person reading it was paged by a policy a person started by hand:
207
+ * the policy's level - through a team, a schedule, or naming them - where a
208
+ * person's page says "... because Alice Kim paged you by name.":
209
+ * "You're getting this because you're a member of Platform, on level 2 of
210
+ * Database escalation.", "... because you're on call in Primary, on level 1
211
+ * of Database escalation.", "... because you're on level 1 of Database
212
+ * escalation." Without a level, the policy, the team or the schedule alone.
213
+ */
214
+ function getPolicyStartedByHandWhyLine(notice, translator) {
215
+ const policyName = startedPolicy(notice);
216
+ const level = startedLevel(notice);
217
+ const teamName = (notice.teamName || "").trim();
218
+ const scheduleName = (notice.scheduleName || "").trim();
219
+ if (level === null) {
220
+ if (teamName) {
221
+ return translator.translateTemplate("You're getting this because you're a member of {{team}}.", { team: teamName });
222
+ }
223
+ if (scheduleName) {
224
+ return translator.translateTemplate("You're getting this because you're on call in {{schedule}}.", { schedule: scheduleName });
225
+ }
226
+ return translator.translateTemplate("You're getting this because {{policy}} pages you.", { policy: policyName });
227
+ }
228
+ if (teamName) {
229
+ return translator.translateTemplate("You're getting this because you're a member of {{team}}, on level {{level}} of {{policy}}.", { team: teamName, level: String(level), policy: policyName });
230
+ }
231
+ if (scheduleName) {
232
+ return translator.translateTemplate("You're getting this because you're on call in {{schedule}}, on level {{level}} of {{policy}}.", { schedule: scheduleName, level: String(level), policy: policyName });
233
+ }
234
+ return translator.translateTemplate("You're getting this because you're on level {{level}} of {{policy}}.", { level: String(level), policy: policyName });
235
+ }
160
236
  // The page's message, when it has one: what the person who paged wrote.
161
237
  function getOnCallPersonPageMessage(notice) {
162
238
  return toOnCallPersonPageMessage(notice.message);
@@ -216,6 +292,15 @@ function getOnCallPersonPagePushBody(data) {
216
292
  * Platform about an incident". Every kind of record starts with a vowel.
217
293
  */
218
294
  function getOnCallPersonPageCallSentence(data) {
295
+ const policyName = startedPolicy(data.notice);
296
+ /*
297
+ * A policy started by hand: "Alice Kim started the on-call policy
298
+ * Database escalation for an incident" - said, a policy's name alone
299
+ * would not say what it is.
300
+ */
301
+ if (policyName) {
302
+ return `${pager(data.notice)} started the on-call policy ${policyName} for an ${data.recordNoun}`;
303
+ }
219
304
  return `${getOnCallPersonPageLead(data.notice)} about an ${data.recordNoun}`;
220
305
  }
221
306
  /*
@@ -237,6 +322,14 @@ const PERSON_PAGE_RECORD_WORDS = {
237
322
  },
238
323
  };
239
324
  function getOnCallPersonPageEmailLine(data) {
325
+ if (startedPolicy(data.notice)) {
326
+ return getPolicyStartedByHandEmailLine({
327
+ record: (data.recordLabel || "").trim() || data.recordNoun.trim(),
328
+ projectName: data.projectName,
329
+ notice: data.notice,
330
+ translator: data.translator || getEnglishTranslator(),
331
+ });
332
+ }
240
333
  const project = data.projectName.trim();
241
334
  const teamName = (data.notice.teamName || "").trim();
242
335
  const scheduleName = (data.notice.scheduleName || "").trim();
@@ -276,6 +369,31 @@ function getOnCallPersonPageEmailLine(data) {
276
369
  second: second,
277
370
  });
278
371
  }
372
+ /*
373
+ * What a policy started by hand's email says first: who started which
374
+ * policy for the record, then why this person - "Alice Kim started
375
+ * Database escalation for Incident INC-42 in the project Acme. You're
376
+ * getting this because you're a member of Platform, on level 2 of Database
377
+ * escalation."
378
+ */
379
+ function getPolicyStartedByHandEmailLine(data) {
380
+ const translator = data.translator;
381
+ const project = data.projectName.trim();
382
+ const first = translator.translateTemplate(project
383
+ ? (0, Translator_1.translationKey)("{{lead}} for {{record}} in the project {{project}}.")
384
+ : (0, Translator_1.translationKey)("{{lead}} for {{record}}."), {
385
+ lead: (0, Translator_1.composedValue)((sentence) => {
386
+ return getOnCallPersonPageLead(data.notice, sentence);
387
+ }),
388
+ record: data.record,
389
+ project: project,
390
+ });
391
+ // Two sentences, as the language puts one after another.
392
+ return translator.translateTemplate("{{first}} {{second}}", {
393
+ first: first,
394
+ second: getOnCallPersonPageWhyLine(data.notice, translator),
395
+ });
396
+ }
279
397
  /*
280
398
  * The line an email shows the message on, when the page has one: "Alice
281
399
  * Kim wrote: “Can you check the database?”". Empty for none.
@@ -296,7 +414,13 @@ function getOnCallPersonPageEmailMessageLine(notice, translator = getEnglishTran
296
414
  */
297
415
  function getOnCallPersonPageEmailSubject(data) {
298
416
  const translator = data.translator || getEnglishTranslator();
299
- return translator.translateTemplate("ACTION REQUIRED: {{lead}} about {{record}} - {{title}}", {
417
+ /*
418
+ * A policy started by hand: "ACTION REQUIRED: Alice Kim started Database
419
+ * escalation for Incident INC-42 - <title>".
420
+ */
421
+ return translator.translateTemplate(startedPolicy(data.notice)
422
+ ? (0, Translator_1.translationKey)("ACTION REQUIRED: {{lead}} for {{record}} - {{title}}")
423
+ : (0, Translator_1.translationKey)("ACTION REQUIRED: {{lead}} about {{record}} - {{title}}"), {
300
424
  lead: (0, Translator_1.composedValue)((sentence) => {
301
425
  return getOnCallPersonPageLead(data.notice, sentence);
302
426
  }),
@@ -13,4 +13,5 @@ export const getOnCallPersonPagePushTitle = commonJsModule.getOnCallPersonPagePu
13
13
  export const getOnCallPersonPageQuotedMessage = commonJsModule.getOnCallPersonPageQuotedMessage;
14
14
  export const getOnCallPersonPageWhyLine = commonJsModule.getOnCallPersonPageWhyLine;
15
15
  export const isOnCallPersonPage = commonJsModule.isOnCallPersonPage;
16
+ export const isOnCallPolicyStartedByHandNotice = commonJsModule.isOnCallPolicyStartedByHandNotice;
16
17
  export const toOnCallPersonPageMessage = commonJsModule.toOnCallPersonPageMessage;