@oneuptime/common 14.0.102 → 14.0.103

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 (208) hide show
  1. package/Models/DatabaseModels/Index.js +6 -0
  2. package/Models/DatabaseModels/LogSavedView.d.mts +1 -0
  3. package/Models/DatabaseModels/LogSavedView.d.ts +1 -0
  4. package/Models/DatabaseModels/LogSavedView.js +43 -1
  5. package/Models/DatabaseModels/NetworkControllerConnection.d.mts +1 -0
  6. package/Models/DatabaseModels/NetworkControllerConnection.d.ts +1 -0
  7. package/Models/DatabaseModels/NetworkControllerConnection.js +21 -0
  8. package/Models/DatabaseModels/Project.d.mts +3 -0
  9. package/Models/DatabaseModels/Project.d.ts +3 -0
  10. package/Models/DatabaseModels/Project.js +124 -0
  11. package/Models/DatabaseModels/Runner.d.mts +1 -0
  12. package/Models/DatabaseModels/Runner.d.ts +1 -0
  13. package/Models/DatabaseModels/Runner.js +40 -0
  14. package/Models/DatabaseModels/SecurityCase.d.mts +2 -1
  15. package/Models/DatabaseModels/SecurityCase.d.ts +2 -1
  16. package/Models/DatabaseModels/SecurityCase.js +27 -0
  17. package/Models/DatabaseModels/SecurityCaseCustomField.d.mts +20 -0
  18. package/Models/DatabaseModels/SecurityCaseCustomField.d.ts +20 -0
  19. package/Models/DatabaseModels/SecurityCaseCustomField.js +387 -0
  20. package/Models/DatabaseModels/SecurityCaseCustomField.mjs +2 -0
  21. package/Models/DatabaseModels/SecurityCaseNoteTemplate.d.mts +15 -0
  22. package/Models/DatabaseModels/SecurityCaseNoteTemplate.d.ts +15 -0
  23. package/Models/DatabaseModels/SecurityCaseNoteTemplate.js +309 -0
  24. package/Models/DatabaseModels/SecurityCaseNoteTemplate.mjs +2 -0
  25. package/Models/DatabaseModels/WorkspaceHomeChoice.d.mts +11 -0
  26. package/Models/DatabaseModels/WorkspaceHomeChoice.d.ts +11 -0
  27. package/Models/DatabaseModels/WorkspaceHomeChoice.js +186 -0
  28. package/Models/DatabaseModels/WorkspaceHomeChoice.mjs +2 -0
  29. package/Types/AI/AIFixReadiness.d.mts +2 -0
  30. package/Types/AI/AIFixReadiness.d.ts +2 -0
  31. package/Types/AI/AIFixReadiness.js +0 -6
  32. package/Types/AI/CodeTask.d.mts +3 -1
  33. package/Types/AI/CodeTask.d.ts +3 -1
  34. package/Types/AI/CodeTask.js +12 -0
  35. package/Types/CustomField/CustomFieldRecordKinds.js +5 -0
  36. package/Types/CustomField/CustomFieldSavedViews.js +2 -0
  37. package/Types/DateLanguage.js +3 -2
  38. package/Types/DockerSwarm/DockerSwarmInventoryExtractor.d.mts +1 -0
  39. package/Types/DockerSwarm/DockerSwarmInventoryExtractor.d.ts +1 -0
  40. package/Types/DockerSwarm/DockerSwarmInventoryExtractor.js +84 -6
  41. package/Types/DockerSwarm/DockerSwarmInventoryExtractor.mjs +1 -0
  42. package/Types/InstallScripts/InstallScripts.d.mts +1 -0
  43. package/Types/InstallScripts/InstallScripts.d.ts +1 -0
  44. package/Types/InstallScripts/InstallScripts.js +14 -0
  45. package/Types/Monitor/DockerSwarmAlertTemplates.d.mts +15 -0
  46. package/Types/Monitor/DockerSwarmAlertTemplates.d.ts +15 -0
  47. package/Types/Monitor/DockerSwarmAlertTemplates.js +168 -0
  48. package/Types/Monitor/DockerSwarmAlertTemplates.mjs +1 -0
  49. package/Types/Monitor/DockerSwarmMetricCatalog.d.mts +1 -1
  50. package/Types/Monitor/DockerSwarmMetricCatalog.d.ts +1 -1
  51. package/Types/Monitor/DockerSwarmMetricCatalog.js +43 -11
  52. package/Types/Monitor/SeriesContext/SeriesDebugHints.js +19 -0
  53. package/Types/NetworkController/NetworkControllerDeviceAdd.d.mts +70 -0
  54. package/Types/NetworkController/NetworkControllerDeviceAdd.d.ts +70 -0
  55. package/Types/NetworkController/NetworkControllerDeviceAdd.js +389 -0
  56. package/Types/NetworkController/NetworkControllerDeviceAdd.mjs +26 -0
  57. package/Types/NetworkController/NetworkControllerReadSummary.d.mts +2 -0
  58. package/Types/NetworkController/NetworkControllerReadSummary.d.ts +2 -0
  59. package/Types/NetworkController/NetworkControllerReadSummary.js +6 -1
  60. package/Types/NetworkDevice/NetworkTopologyLayout.d.mts +8 -0
  61. package/Types/NetworkDevice/NetworkTopologyLayout.d.ts +8 -0
  62. package/Types/NetworkDevice/NetworkTopologyLayout.js +49 -0
  63. package/Types/NetworkDevice/NetworkTopologyLayout.mjs +3 -0
  64. package/Types/Permission.d.mts +8 -0
  65. package/Types/Permission.d.ts +8 -0
  66. package/Types/Permission.js +87 -3
  67. package/Types/PushNotification/PushNotificationCategory.d.mts +3 -0
  68. package/Types/PushNotification/PushNotificationCategory.d.ts +3 -0
  69. package/Types/PushNotification/PushNotificationCategory.js +38 -0
  70. package/Types/PushNotification/PushNotificationCategory.mjs +4 -0
  71. package/Types/PushNotification/PushNotificationMessage.d.mts +1 -0
  72. package/Types/PushNotification/PushNotificationMessage.d.ts +1 -0
  73. package/Types/Runner/RunnerCodeFixes.d.mts +22 -0
  74. package/Types/Runner/RunnerCodeFixes.d.ts +22 -0
  75. package/Types/Runner/RunnerCodeFixes.js +129 -0
  76. package/Types/Runner/RunnerCodeFixes.mjs +9 -0
  77. package/Types/SecurityCase/SecurityCaseNumber.js +8 -4
  78. package/Types/SecurityEvent/MitreAttack.d.mts +2 -0
  79. package/Types/SecurityEvent/MitreAttack.d.ts +2 -0
  80. package/Types/SecurityEvent/MitreAttack.js +26 -0
  81. package/Types/SecurityEvent/MitreAttack.mjs +2 -0
  82. package/Types/SecurityEvent/OcsfSeverity.js +10 -1
  83. package/Types/Telemetry/TelemetrySearchQuery.js +14 -2
  84. package/Types/Workspace/WorkspaceMessagePayload.d.mts +7 -0
  85. package/Types/Workspace/WorkspaceMessagePayload.d.ts +7 -0
  86. package/Utils/CronScheduleText.d.mts +3 -0
  87. package/Utils/CronScheduleText.d.ts +3 -0
  88. package/Utils/CronScheduleText.js +307 -0
  89. package/Utils/CronScheduleText.mjs +3 -0
  90. package/Utils/Dashboard/DashboardBoardLayout.d.mts +2 -0
  91. package/Utils/Dashboard/DashboardBoardLayout.d.ts +2 -0
  92. package/Utils/Dashboard/DashboardBoardLayout.js +17 -4
  93. package/Utils/Dashboard/DashboardBoardLayout.mjs +1 -0
  94. package/Utils/DeveloperDocs/CliCommands.d.mts +114 -0
  95. package/Utils/DeveloperDocs/CliCommands.d.ts +114 -0
  96. package/Utils/DeveloperDocs/CliCommands.js +750 -0
  97. package/Utils/DeveloperDocs/CliCommands.mjs +37 -0
  98. package/Utils/DeveloperDocs/CliExamples.d.mts +59 -0
  99. package/Utils/DeveloperDocs/CliExamples.d.ts +59 -0
  100. package/Utils/DeveloperDocs/CliExamples.js +348 -0
  101. package/Utils/DeveloperDocs/CliExamples.mjs +17 -0
  102. package/Utils/DeveloperDocs/CliResources.d.mts +18 -0
  103. package/Utils/DeveloperDocs/CliResources.d.ts +18 -0
  104. package/Utils/DeveloperDocs/CliResources.js +129 -0
  105. package/Utils/DeveloperDocs/CliResources.mjs +6 -0
  106. package/Utils/DeveloperDocs/ExampleBuilder.d.mts +6 -0
  107. package/Utils/DeveloperDocs/ExampleBuilder.d.ts +6 -0
  108. package/Utils/DeveloperDocs/ExampleBuilder.js +27 -2
  109. package/Utils/DeveloperDocs/ExampleBuilder.mjs +1 -0
  110. package/Utils/DeveloperDocs/PageLookups.d.mts +1 -1
  111. package/Utils/DeveloperDocs/PageLookups.d.ts +1 -1
  112. package/Utils/DeveloperDocs/PageLookups.js +9 -2
  113. package/Utils/DeveloperDocs/TerraformSchema.d.mts +1 -0
  114. package/Utils/DeveloperDocs/TerraformSchema.d.ts +1 -0
  115. package/Utils/DeveloperDocs/TerraformSchema.js +3 -1
  116. package/Utils/DeveloperDocs/TerraformSchema.mjs +1 -0
  117. package/Utils/LookupTable.d.mts +3 -0
  118. package/Utils/LookupTable.d.ts +3 -0
  119. package/Utils/LookupTable.js +44 -0
  120. package/Utils/LookupTable.mjs +4 -0
  121. package/Utils/Monitor/MonitorCheckScheduleUtil.d.mts +62 -0
  122. package/Utils/Monitor/MonitorCheckScheduleUtil.d.ts +62 -0
  123. package/Utils/Monitor/MonitorCheckScheduleUtil.js +484 -0
  124. package/Utils/Monitor/MonitorCheckScheduleUtil.mjs +3 -0
  125. package/Utils/Monitor/MonitorOverviewFamily.d.mts +39 -0
  126. package/Utils/Monitor/MonitorOverviewFamily.d.ts +39 -0
  127. package/Utils/Monitor/MonitorOverviewFamily.js +207 -0
  128. package/Utils/Monitor/MonitorOverviewFamily.mjs +4 -0
  129. package/Utils/Monitor/MonitorOverviewPresentationUtil.d.mts +192 -0
  130. package/Utils/Monitor/MonitorOverviewPresentationUtil.d.ts +192 -0
  131. package/Utils/Monitor/MonitorOverviewPresentationUtil.js +1659 -0
  132. package/Utils/Monitor/MonitorOverviewPresentationUtil.mjs +5 -0
  133. package/Utils/Monitor/MonitorOverviewProbeUtil.d.mts +112 -0
  134. package/Utils/Monitor/MonitorOverviewProbeUtil.d.ts +112 -0
  135. package/Utils/Monitor/MonitorOverviewProbeUtil.js +640 -0
  136. package/Utils/Monitor/MonitorOverviewProbeUtil.mjs +3 -0
  137. package/Utils/Monitor/MonitorOverviewTargetUtil.d.mts +1 -1
  138. package/Utils/Monitor/MonitorOverviewTargetUtil.d.ts +1 -1
  139. package/Utils/Monitor/MonitorStatusHistoryUtil.d.mts +27 -0
  140. package/Utils/Monitor/MonitorStatusHistoryUtil.d.ts +27 -0
  141. package/Utils/Monitor/MonitorStatusHistoryUtil.js +132 -0
  142. package/Utils/Monitor/MonitorStatusHistoryUtil.mjs +2 -0
  143. package/Utils/Monitor/MonitorUptimeSummaryUtil.d.mts +44 -0
  144. package/Utils/Monitor/MonitorUptimeSummaryUtil.d.ts +44 -0
  145. package/Utils/Monitor/MonitorUptimeSummaryUtil.js +487 -0
  146. package/Utils/Monitor/MonitorUptimeSummaryUtil.mjs +2 -0
  147. package/Utils/OldestKeyMap.d.mts +10 -0
  148. package/Utils/OldestKeyMap.d.ts +10 -0
  149. package/Utils/OldestKeyMap.js +91 -0
  150. package/Utils/OldestKeyMap.mjs +2 -0
  151. package/Utils/Project/NextNumber.d.mts +4 -3
  152. package/Utils/Project/NextNumber.d.ts +4 -3
  153. package/Utils/Project/NextNumber.js +11 -2
  154. package/Utils/Project/NumberPrefix.d.mts +1 -1
  155. package/Utils/Project/NumberPrefix.d.ts +1 -1
  156. package/Utils/Project/NumberPrefix.js +12 -0
  157. package/Utils/Schema/AnalyticsModelSchema.d.mts +48 -0
  158. package/Utils/Schema/AnalyticsModelSchema.d.ts +48 -0
  159. package/Utils/Schema/AnalyticsModelSchema.js +767 -0
  160. package/Utils/Schema/AnalyticsModelSchema.mjs +2 -0
  161. package/Utils/Schema/BaseSchema.d.mts +117 -0
  162. package/Utils/Schema/BaseSchema.d.ts +117 -0
  163. package/Utils/Schema/BaseSchema.js +257 -0
  164. package/Utils/Schema/BaseSchema.mjs +3 -0
  165. package/Utils/Schema/ModelSchema.d.mts +80 -0
  166. package/Utils/Schema/ModelSchema.d.ts +80 -0
  167. package/Utils/Schema/ModelSchema.js +1727 -0
  168. package/Utils/Schema/ModelSchema.mjs +2 -0
  169. package/Utils/SecurityEvent/Connectors/AwsSecurityHubNormalizer.d.mts +0 -1
  170. package/Utils/SecurityEvent/Connectors/AwsSecurityHubNormalizer.d.ts +0 -1
  171. package/Utils/SecurityEvent/Connectors/AwsSecurityHubNormalizer.js +9 -25
  172. package/Utils/SecurityEvent/Connectors/AwsSecurityHubNormalizer.mjs +0 -1
  173. package/Utils/SecurityEvent/Connectors/EntraIdNormalizer.d.mts +1 -1
  174. package/Utils/SecurityEvent/Connectors/EntraIdNormalizer.d.ts +1 -1
  175. package/Utils/SecurityEvent/Connectors/EntraIdNormalizer.js +7 -6
  176. package/Utils/SecurityEvent/Connectors/GoogleWorkspaceNormalizer.d.mts +1 -1
  177. package/Utils/SecurityEvent/Connectors/GoogleWorkspaceNormalizer.d.ts +1 -1
  178. package/Utils/SecurityEvent/Connectors/GoogleWorkspaceNormalizer.js +10 -9
  179. package/Utils/SecurityEvent/Connectors/Microsoft365AuditNormalizer.js +4 -3
  180. package/Utils/SecurityEvent/Connectors/MicrosoftDefenderXdrNormalizer.js +12 -28
  181. package/Utils/SecurityEvent/Connectors/MicrosoftSentinelNormalizer.d.mts +1 -1
  182. package/Utils/SecurityEvent/Connectors/MicrosoftSentinelNormalizer.d.ts +1 -1
  183. package/Utils/SecurityEvent/Connectors/MicrosoftSentinelNormalizer.js +13 -24
  184. package/Utils/SecurityEvent/Connectors/MicrosoftSentinelNormalizer.mjs +1 -1
  185. package/Utils/SecurityEvent/Connectors/OktaNormalizer.d.mts +2 -2
  186. package/Utils/SecurityEvent/Connectors/OktaNormalizer.d.ts +2 -2
  187. package/Utils/SecurityEvent/Connectors/OktaNormalizer.js +7 -6
  188. package/Utils/SecurityEvent/Connectors/SplunkNormalizer.js +7 -26
  189. package/Utils/SecurityEvent/LogParsers/AzureActivityLogParser.js +4 -3
  190. package/Utils/SecurityEvent/LogParsers/WindowsEventLogParser.d.mts +2 -2
  191. package/Utils/SecurityEvent/LogParsers/WindowsEventLogParser.d.ts +2 -2
  192. package/Utils/SecurityEvent/LogParsers/WindowsEventLogParser.js +26 -16
  193. package/Utils/SecurityEvent/LogParsers/WindowsEventRecord.d.mts +1 -1
  194. package/Utils/SecurityEvent/LogParsers/WindowsEventRecord.d.ts +1 -1
  195. package/Utils/SecurityEvent/LogParsers/WindowsEventRecord.js +10 -6
  196. package/Utils/SecurityEvent/SecurityEventNormalizer.js +17 -11
  197. package/Utils/SecurityEvent/SecurityEventSearch.js +8 -1
  198. package/Utils/SecurityEvent/Sigma/SigmaRuleSetParser.js +4 -5
  199. package/Utils/SecurityEvent/ThreatIntel/StixPatternParser.js +7 -3
  200. package/Utils/SecurityEvent/UdmNormalizer.js +10 -6
  201. package/Utils/Telemetry/SavedViewDefault.js +4 -3
  202. package/Utils/Telemetry/SavedViewScope.d.mts +33 -0
  203. package/Utils/Telemetry/SavedViewScope.d.ts +33 -0
  204. package/Utils/Telemetry/SavedViewScope.js +105 -0
  205. package/Utils/Telemetry/SavedViewScope.mjs +7 -0
  206. package/package.json +1 -11
  207. package/UI/Utils/TranslateTemplate.d.mts +0 -8
  208. package/UI/Utils/TranslateTemplate.d.ts +0 -8
@@ -0,0 +1,487 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const Date_1 = require("../../Types/Date");
7
+ const BadDataException_1 = __importDefault(require("../../Types/Exception/BadDataException"));
8
+ const MonitorUptimeSummary_1 = require("../../Types/Monitor/MonitorUptimeSummary");
9
+ const ObjectID_1 = __importDefault(require("../../Types/ObjectID"));
10
+ const UptimePrecision_1 = __importDefault(require("../../Types/StatusPage/UptimePrecision"));
11
+ const TimezoneAlias_1 = __importDefault(require("../../Types/TimezoneAlias"));
12
+ const SloDuration_1 = require("../Slo/SloDuration");
13
+ const Translator_1 = require("../../Types/Translator");
14
+ const UptimeUtil_1 = __importDefault(require("../Uptime/UptimeUtil"));
15
+ /*
16
+ * What each caveat adds to a window's description, as a phrase of its own
17
+ * after a " · ".
18
+ */
19
+ const CAVEAT_TEXT = {
20
+ paused: (0, Translator_1.translationKey)("includes paused time"),
21
+ "not-checking": (0, Translator_1.translationKey)("includes time with no checks running"),
22
+ "no-results": (0, Translator_1.translationKey)("no check has completed yet"),
23
+ };
24
+ // English, word for word as the windows always read: no lookup.
25
+ const ENGLISH = (0, Translator_1.createTranslator)(undefined, "en");
26
+ const WINDOW_KEYS = Object.values(MonitorUptimeSummary_1.MonitorUptimeWindowKey);
27
+ // Used to trim "99.950" to "99.95" and "98.000" to "98".
28
+ const TRAILING_ZEROS = /0+$/;
29
+ const TRAILING_POINT = /\.$/;
30
+ // A finite, non-negative number, or 0. Wire values are never trusted.
31
+ const toSeconds = (value) => {
32
+ const numeric = typeof value === "number" ? value : Number(value);
33
+ if (!Number.isFinite(numeric) || numeric < 0) {
34
+ return 0;
35
+ }
36
+ return numeric;
37
+ };
38
+ const toDateOrNull = (value) => {
39
+ if (typeof value !== "string" || !value) {
40
+ return null;
41
+ }
42
+ const parsed = new Date(value);
43
+ return Number.isNaN(parsed.getTime()) ? null : parsed;
44
+ };
45
+ const durationsToJSON = (durations) => {
46
+ return durations.map((duration) => {
47
+ return {
48
+ monitorStatusId: duration.monitorStatusId.toString(),
49
+ seconds: duration.seconds,
50
+ };
51
+ });
52
+ };
53
+ const durationsFromJSON = (raw) => {
54
+ const durations = [];
55
+ if (!Array.isArray(raw)) {
56
+ return durations;
57
+ }
58
+ for (const item of raw) {
59
+ if (!item || typeof item !== "object") {
60
+ continue;
61
+ }
62
+ const statusId = item["monitorStatusId"];
63
+ if (typeof statusId !== "string" || !statusId) {
64
+ continue;
65
+ }
66
+ durations.push({
67
+ monitorStatusId: new ObjectID_1.default(statusId),
68
+ seconds: toSeconds(item["seconds"]),
69
+ });
70
+ }
71
+ return durations;
72
+ };
73
+ class MonitorUptimeSummaryUtil {
74
+ /*
75
+ * Adds day buckets up into one window. Durations are merged per status
76
+ * and ordered largest first, which is the order a legend wants.
77
+ */
78
+ static sumBuckets(data) {
79
+ let windowSeconds = 0;
80
+ let coveredSeconds = 0;
81
+ const secondsByStatusId = new Map();
82
+ for (const bucket of data.buckets || []) {
83
+ windowSeconds += toSeconds(bucket.daySeconds);
84
+ coveredSeconds += toSeconds(bucket.coveredSeconds);
85
+ for (const duration of bucket.statusDurations || []) {
86
+ const statusId = duration.monitorStatusId.toString();
87
+ secondsByStatusId.set(statusId, (secondsByStatusId.get(statusId) || 0) + toSeconds(duration.seconds));
88
+ }
89
+ }
90
+ const statusDurations = Array.from(secondsByStatusId.entries())
91
+ .map((entry) => {
92
+ return { monitorStatusId: new ObjectID_1.default(entry[0]), seconds: entry[1] };
93
+ })
94
+ .sort((a, b) => {
95
+ if (b.seconds !== a.seconds) {
96
+ return b.seconds - a.seconds;
97
+ }
98
+ // A stable order for equal durations, so the legend does not shuffle.
99
+ return a.monitorStatusId
100
+ .toString()
101
+ .localeCompare(b.monitorStatusId.toString());
102
+ });
103
+ return {
104
+ key: data.key,
105
+ startDate: data.startDate,
106
+ endDate: data.endDate,
107
+ windowSeconds: windowSeconds,
108
+ coveredSeconds: coveredSeconds,
109
+ statusDurations: statusDurations,
110
+ };
111
+ }
112
+ /*
113
+ * Downtime is time in any status that is not marked operational, which is
114
+ * how the status page and the old overview counted it. A "Degraded" status
115
+ * is downtime here.
116
+ */
117
+ static getDowntimeStatusIds(statuses) {
118
+ const ids = new Set();
119
+ for (const status of statuses || []) {
120
+ if (!status.isOperationalState) {
121
+ ids.add(status.id.toString());
122
+ }
123
+ }
124
+ return ids;
125
+ }
126
+ /*
127
+ * `caveat` notes time the window counts but nothing measured. The older
128
+ * `isPausedNow: true` is read as the "paused" caveat; a given `caveat`,
129
+ * including null, wins over it.
130
+ */
131
+ static getWindowPresentation(data) {
132
+ const t = data.translator || ENGLISH;
133
+ const window = data.window;
134
+ let caveat = data.isPausedNow ? "paused" : null;
135
+ if (data.caveat !== undefined) {
136
+ caveat = data.caveat;
137
+ }
138
+ if (!window) {
139
+ return null;
140
+ }
141
+ const coveredSeconds = toSeconds(window.coveredSeconds);
142
+ const windowSeconds = toSeconds(window.windowSeconds);
143
+ if (coveredSeconds < 1) {
144
+ return {
145
+ key: window.key,
146
+ kind: "NoData",
147
+ uptimePercent: null,
148
+ valueText: t.translateTemplate("No data"),
149
+ description: t.translateTemplate("Nothing recorded in this window"),
150
+ downtimeSeconds: 0,
151
+ coveredSeconds: coveredSeconds,
152
+ windowSeconds: windowSeconds,
153
+ // Partial describes a measured window; this one was not measured.
154
+ isPartial: false,
155
+ };
156
+ }
157
+ let downtimeSeconds = 0;
158
+ for (const duration of window.statusDurations || []) {
159
+ if (data.downtimeStatusIds.has(duration.monitorStatusId.toString())) {
160
+ downtimeSeconds += toSeconds(duration.seconds);
161
+ }
162
+ }
163
+ // Durations can never honestly exceed the time that was recorded.
164
+ downtimeSeconds = Math.min(downtimeSeconds, coveredSeconds);
165
+ /*
166
+ * Multiply before dividing: (1999 / 2000) * 100 is 99.94999..., which
167
+ * the floor in formatUptimePercent would turn into 99.949.
168
+ */
169
+ const uptimePercent = ((coveredSeconds - downtimeSeconds) * 100) / coveredSeconds;
170
+ const isPartial = coveredSeconds <
171
+ windowSeconds - MonitorUptimeSummaryUtil.COVERAGE_TOLERANCE_SECONDS;
172
+ /*
173
+ * Phrases joined with " · ", each looked up whole, with its duration
174
+ * written in the reader's language.
175
+ */
176
+ const phrases = [
177
+ downtimeSeconds > 0
178
+ ? t.translateTemplate("Down {{duration}}", {
179
+ duration: (0, SloDuration_1.formatDurationCompactInLanguage)(downtimeSeconds, t.language),
180
+ })
181
+ : t.translateTemplate("No downtime"),
182
+ ];
183
+ if (isPartial) {
184
+ phrases.push(t.translateTemplate("measured over {{duration}}", {
185
+ duration: (0, SloDuration_1.formatDurationCompactInLanguage)(coveredSeconds, t.language),
186
+ }));
187
+ }
188
+ if (caveat) {
189
+ phrases.push(t.translateTemplate(CAVEAT_TEXT[caveat]));
190
+ }
191
+ const description = phrases.join(" · ");
192
+ return {
193
+ key: window.key,
194
+ kind: "Measured",
195
+ uptimePercent: uptimePercent,
196
+ valueText: MonitorUptimeSummaryUtil.formatUptimePercent({
197
+ uptimePercent: uptimePercent,
198
+ downtimeSeconds: downtimeSeconds,
199
+ }),
200
+ description: description,
201
+ downtimeSeconds: downtimeSeconds,
202
+ coveredSeconds: coveredSeconds,
203
+ windowSeconds: windowSeconds,
204
+ isPartial: isPartial,
205
+ };
206
+ }
207
+ /*
208
+ * "100%" only when downtime is exactly zero. Anything else is floored to
209
+ * three decimals and capped at 99.999, so 43 seconds of downtime in 30
210
+ * days can never round up into a perfect score.
211
+ */
212
+ static formatUptimePercent(data) {
213
+ if (!(data.downtimeSeconds > 0)) {
214
+ return "100%";
215
+ }
216
+ const rawPercent = Number.isFinite(data.uptimePercent)
217
+ ? data.uptimePercent
218
+ : 0;
219
+ /*
220
+ * Strip floating-point noise before flooring, or 99.95 stored as
221
+ * 99.94999999999999 would read 99.949.
222
+ */
223
+ const cleanPercent = Math.round(rawPercent * 1e9) / 1e9;
224
+ let value = UptimeUtil_1.default.roundToPrecision({
225
+ number: cleanPercent,
226
+ precision: UptimePrecision_1.default.THREE_DECIMAL,
227
+ });
228
+ if (value >= 100) {
229
+ value = 99.999;
230
+ }
231
+ value = Math.max(0, value);
232
+ const text = value
233
+ .toFixed(3)
234
+ .replace(TRAILING_ZEROS, "")
235
+ .replace(TRAILING_POINT, "");
236
+ return `${text}%`;
237
+ }
238
+ static getWindow(summary, key) {
239
+ return (summary.windows || []).find((window) => {
240
+ return window.key === key;
241
+ });
242
+ }
243
+ /*
244
+ * Plain ISO and id strings, like UptimeDailyAggregateUtil, and for the
245
+ * same reason: the typed JSON envelopes would triple the payload.
246
+ */
247
+ static toJSON(summary) {
248
+ return {
249
+ monitorId: summary.monitorId.toString(),
250
+ timezone: summary.timezone,
251
+ generatedAt: summary.generatedAt.toISOString(),
252
+ startDate: summary.startDate.toISOString(),
253
+ endDate: summary.endDate.toISOString(),
254
+ buckets: summary.buckets.map((bucket) => {
255
+ return {
256
+ bucketStart: bucket.bucketStart.toISOString(),
257
+ bucketEnd: bucket.bucketEnd.toISOString(),
258
+ daySeconds: bucket.daySeconds,
259
+ coveredSeconds: bucket.coveredSeconds,
260
+ statusDurations: durationsToJSON(bucket.statusDurations),
261
+ };
262
+ }),
263
+ windows: summary.windows.map((window) => {
264
+ return {
265
+ key: window.key,
266
+ startDate: window.startDate.toISOString(),
267
+ endDate: window.endDate.toISOString(),
268
+ windowSeconds: window.windowSeconds,
269
+ coveredSeconds: window.coveredSeconds,
270
+ statusDurations: durationsToJSON(window.statusDurations),
271
+ };
272
+ }),
273
+ isComplete: summary.isComplete,
274
+ completeFrom: summary.completeFrom
275
+ ? summary.completeFrom.toISOString()
276
+ : null,
277
+ statuses: summary.statuses.map((status) => {
278
+ return {
279
+ id: status.id.toString(),
280
+ name: status.name,
281
+ color: status.color,
282
+ isOperationalState: status.isOperationalState,
283
+ isOfflineState: status.isOfflineState,
284
+ priority: status.priority,
285
+ };
286
+ }),
287
+ };
288
+ }
289
+ /*
290
+ * Total: never throws. Null when the payload is not a summary at all, so
291
+ * the page can say "could not be read" instead of drawing an empty strip
292
+ * that looks like a monitor with no history. Malformed parts inside a
293
+ * valid summary are skipped one by one.
294
+ */
295
+ static fromJSON(json) {
296
+ if (!json || typeof json !== "object" || Array.isArray(json)) {
297
+ return null;
298
+ }
299
+ const monitorId = json["monitorId"];
300
+ if (typeof monitorId !== "string" || !monitorId) {
301
+ return null;
302
+ }
303
+ const startDate = toDateOrNull(json["startDate"]);
304
+ const endDate = toDateOrNull(json["endDate"]);
305
+ if (!startDate || !endDate) {
306
+ return null;
307
+ }
308
+ const rawBuckets = json["buckets"];
309
+ if (!Array.isArray(rawBuckets)) {
310
+ return null;
311
+ }
312
+ const buckets = [];
313
+ for (const rawBucket of rawBuckets) {
314
+ if (!rawBucket || typeof rawBucket !== "object") {
315
+ continue;
316
+ }
317
+ const bucket = rawBucket;
318
+ const bucketStart = toDateOrNull(bucket["bucketStart"]);
319
+ const bucketEnd = toDateOrNull(bucket["bucketEnd"]);
320
+ if (!bucketStart || !bucketEnd) {
321
+ continue;
322
+ }
323
+ buckets.push({
324
+ bucketStart: bucketStart,
325
+ bucketEnd: bucketEnd,
326
+ daySeconds: toSeconds(bucket["daySeconds"]),
327
+ coveredSeconds: toSeconds(bucket["coveredSeconds"]),
328
+ statusDurations: durationsFromJSON(bucket["statusDurations"]),
329
+ });
330
+ }
331
+ const windows = [];
332
+ const rawWindows = json["windows"];
333
+ if (Array.isArray(rawWindows)) {
334
+ for (const rawWindow of rawWindows) {
335
+ if (!rawWindow || typeof rawWindow !== "object") {
336
+ continue;
337
+ }
338
+ const window = rawWindow;
339
+ const key = window["key"];
340
+ const windowStart = toDateOrNull(window["startDate"]);
341
+ const windowEnd = toDateOrNull(window["endDate"]);
342
+ if (typeof key !== "string" ||
343
+ !WINDOW_KEYS.includes(key) ||
344
+ !windowStart ||
345
+ !windowEnd) {
346
+ continue;
347
+ }
348
+ windows.push({
349
+ key: key,
350
+ startDate: windowStart,
351
+ endDate: windowEnd,
352
+ windowSeconds: toSeconds(window["windowSeconds"]),
353
+ coveredSeconds: toSeconds(window["coveredSeconds"]),
354
+ statusDurations: durationsFromJSON(window["statusDurations"]),
355
+ });
356
+ }
357
+ }
358
+ const statuses = [];
359
+ const rawStatuses = json["statuses"];
360
+ if (Array.isArray(rawStatuses)) {
361
+ for (const rawStatus of rawStatuses) {
362
+ if (!rawStatus || typeof rawStatus !== "object") {
363
+ continue;
364
+ }
365
+ const status = rawStatus;
366
+ const id = status["id"];
367
+ const name = status["name"];
368
+ if (typeof id !== "string" || !id || typeof name !== "string") {
369
+ continue;
370
+ }
371
+ const priority = status["priority"];
372
+ statuses.push({
373
+ id: new ObjectID_1.default(id),
374
+ name: name,
375
+ color: typeof status["color"] === "string" ? status["color"] : "",
376
+ isOperationalState: status["isOperationalState"] === true,
377
+ isOfflineState: status["isOfflineState"] === true,
378
+ priority: typeof priority === "number" && Number.isFinite(priority)
379
+ ? priority
380
+ : null,
381
+ });
382
+ }
383
+ }
384
+ return {
385
+ monitorId: new ObjectID_1.default(monitorId),
386
+ timezone: typeof json["timezone"] === "string" && json["timezone"]
387
+ ? json["timezone"]
388
+ : "UTC",
389
+ generatedAt: toDateOrNull(json["generatedAt"]) || endDate,
390
+ startDate: startDate,
391
+ endDate: endDate,
392
+ buckets: buckets,
393
+ windows: windows,
394
+ /*
395
+ * Absent means complete, as in UptimeDailyAggregateUtil: only an
396
+ * explicit false greys out the older bars.
397
+ */
398
+ isComplete: json["isComplete"] !== false,
399
+ completeFrom: toDateOrNull(json["completeFrom"]),
400
+ statuses: statuses,
401
+ };
402
+ }
403
+ /*
404
+ * The zone the day buckets are cut in. Missing means UTC; anything that
405
+ * is not an IANA name is refused rather than silently read as UTC, because
406
+ * a caller who sent "Europe/Lodnon" would otherwise get bars that are off
407
+ * by an hour and no hint why.
408
+ *
409
+ * The current name is returned, so the value handed to the database is
410
+ * always one it knows. moment answers a legacy name with that same name
411
+ * (its zone for "Asia/Calcutta" is called "Asia/Calcutta"), and Chromium
412
+ * reports Asia/Calcutta for India, but the Postgres in the shipped images
413
+ * has no legacy tzdata links and rejects several of them in AT TIME ZONE.
414
+ * So TimezoneAlias translates first — which also lets through
415
+ * US/Pacific-New, a name tzdata removed and moment no longer resolves.
416
+ */
417
+ static parseTimezone(raw) {
418
+ var _a;
419
+ if (typeof raw !== "string") {
420
+ return "UTC";
421
+ }
422
+ const trimmed = raw.trim();
423
+ if (!trimmed) {
424
+ return "UTC";
425
+ }
426
+ const currentName = TimezoneAlias_1.default.getCanonicalTimezone(trimmed);
427
+ let zoneName = null;
428
+ try {
429
+ zoneName = ((_a = Date_1.Moment.tz.zone(currentName)) === null || _a === void 0 ? void 0 : _a.name) || null;
430
+ }
431
+ catch (_b) {
432
+ zoneName = null;
433
+ }
434
+ if (!zoneName) {
435
+ throw new BadDataException_1.default("timezone must be an IANA time zone name, for example Europe/London.");
436
+ }
437
+ return zoneName;
438
+ }
439
+ /*
440
+ * The zone to cut day buckets in, as one parseTimezone accepts. A browser
441
+ * can carry newer zone data than the bundled moment-timezone (for example
442
+ * America/Coyhaique, added in tzdata 2025b); the server would refuse such
443
+ * a zone on every load, so it is swapped for moment's own guess, which
444
+ * matches the browser's offsets from the data it has. The page labels
445
+ * days with moment too, so both cut days on the same boundaries. UTC is
446
+ * the last resort.
447
+ */
448
+ static getBrowserTimezone() {
449
+ let zone = undefined;
450
+ try {
451
+ zone = Intl.DateTimeFormat().resolvedOptions().timeZone;
452
+ }
453
+ catch (_a) {
454
+ zone = undefined;
455
+ }
456
+ const known = MonitorUptimeSummaryUtil.toKnownZone(zone);
457
+ if (known) {
458
+ return known;
459
+ }
460
+ try {
461
+ return (MonitorUptimeSummaryUtil.toKnownZone(Date_1.Moment.tz.guess(true)) || "UTC");
462
+ }
463
+ catch (_b) {
464
+ return "UTC";
465
+ }
466
+ }
467
+ static toKnownZone(zone) {
468
+ if (!zone) {
469
+ return null;
470
+ }
471
+ try {
472
+ return Date_1.Moment.tz.zone(zone) ? zone : null;
473
+ }
474
+ catch (_a) {
475
+ return null;
476
+ }
477
+ }
478
+ }
479
+ /*
480
+ * How much of a window may be missing before it is called partial. The
481
+ * aggregate clips its last bucket to now(), and the request that produced
482
+ * it takes a moment, so a fully covered window can come back a few seconds
483
+ * short. A minute is well past that and well short of anything a person
484
+ * would call a gap.
485
+ */
486
+ MonitorUptimeSummaryUtil.COVERAGE_TOLERANCE_SECONDS = 60;
487
+ exports.default = MonitorUptimeSummaryUtil;
@@ -0,0 +1,2 @@
1
+ import commonJsModule from "./MonitorUptimeSummaryUtil.js";
2
+ export default commonJsModule.default;
@@ -0,0 +1,10 @@
1
+ export default class OldestKeyMap<K, V> extends Map<K, V> {
2
+ private readonly cursor;
3
+ private handedOut;
4
+ constructor();
5
+ oldestKey(): K | undefined;
6
+ set(key: K, value: V): this;
7
+ delete(key: K): boolean;
8
+ clear(): void;
9
+ private letGo;
10
+ }
@@ -0,0 +1,10 @@
1
+ export default class OldestKeyMap<K, V> extends Map<K, V> {
2
+ private readonly cursor;
3
+ private handedOut;
4
+ constructor();
5
+ oldestKey(): K | undefined;
6
+ set(key: K, value: V): this;
7
+ delete(key: K): boolean;
8
+ clear(): void;
9
+ private letGo;
10
+ }
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const OldestKeyCursor_1 = __importDefault(require("./OldestKeyCursor"));
7
+ /*
8
+ * A Map that answers its oldest key - the first in insertion order - in
9
+ * constant time, however much it has churned: for a bounded cache that
10
+ * evicts its oldest entry when it is full.
11
+ *
12
+ * Such a cache used to evict with map.keys().next(). V8 leaves a deleted
13
+ * entry's slot in the map's table until it compacts the table, and a new
14
+ * iterator starts at the first slot, so in a cache that evicts from the
15
+ * front on every write each keys().next() walked past every slot evicted
16
+ * since the last compaction: 10 to 14 microseconds a write in a full cache
17
+ * of 10,000 to 50,000 entries. oldestKey() keeps one iterator instead
18
+ * (OldestKeyCursor), and answers the same key.
19
+ *
20
+ * It keeps the iterator only while that is safe. An iterator keeps the table
21
+ * it was made on alive, with every value that table held, chained to each
22
+ * table the map is rebuilt into after it, until it next moves - so one kept
23
+ * across changes that do not move it holds on to values the map has
24
+ * deleted or replaced since (300 MB after a million writes and deletes of
25
+ * half-kilobyte values, 2026-10-27). This map lets the iterator go on every
26
+ * change that removes or replaces a value - a delete, a write over a key it
27
+ * has, clear() - except deleting the key oldestKey() just answered (an
28
+ * eviction, which moves the iterator onto the current table). Adding a new
29
+ * key keeps it: nothing the map held is let go of meanwhile, and the next
30
+ * eviction moves it. So a full cache that evicts on every write never walks
31
+ * past a deleted slot, and a cache that also deletes or rewrites keys costs
32
+ * what keys().next() did, and holds on to nothing it let go of.
33
+ *
34
+ * The key oldestKey() answers is meant to be deleted next. Asked again
35
+ * before that, it answers the same key.
36
+ *
37
+ * Use it as a Map: everything else is the Map's own. Tests/Utils/OldestKeyMap
38
+ * holds it to keys().next()'s answers and to letting go of what it deletes;
39
+ * Tests/Utils/OldestKeyEvictionGuard keeps keys().next() eviction out of the
40
+ * product.
41
+ */
42
+ class OldestKeyMap extends Map {
43
+ constructor() {
44
+ super();
45
+ // The key oldestKey() answered and nobody has deleted yet.
46
+ this.handedOut = null;
47
+ this.cursor = new OldestKeyCursor_1.default(this);
48
+ }
49
+ /*
50
+ * The oldest key, for its caller to delete; undefined when the map is
51
+ * empty.
52
+ */
53
+ oldestKey() {
54
+ if (this.handedOut && super.has(this.handedOut.key)) {
55
+ // Answered before and still here: that key again, from the start.
56
+ this.cursor.reset();
57
+ }
58
+ const key = this.cursor.takeOldest();
59
+ this.handedOut = key === undefined ? null : { key: key };
60
+ return key;
61
+ }
62
+ set(key, value) {
63
+ const sizeBefore = super.size;
64
+ super.set(key, value);
65
+ if (super.size === sizeBefore) {
66
+ // A value replaced: the iterator must not keep the one let go of.
67
+ this.letGo();
68
+ }
69
+ return this;
70
+ }
71
+ delete(key) {
72
+ const isEviction = this.handedOut !== null && this.handedOut.key === key;
73
+ const deleted = super.delete(key);
74
+ if (isEviction) {
75
+ this.handedOut = null;
76
+ }
77
+ else if (deleted) {
78
+ this.letGo();
79
+ }
80
+ return deleted;
81
+ }
82
+ clear() {
83
+ super.clear();
84
+ this.letGo();
85
+ }
86
+ letGo() {
87
+ this.cursor.reset();
88
+ this.handedOut = null;
89
+ }
90
+ }
91
+ exports.default = OldestKeyMap;
@@ -0,0 +1,2 @@
1
+ import commonJsModule from "./OldestKeyMap.js";
2
+ export default commonJsModule.default;
@@ -4,10 +4,11 @@ export declare enum NumberedRecordKind {
4
4
  IncidentEpisode = "IncidentEpisode",
5
5
  Alert = "Alert",
6
6
  AlertEpisode = "AlertEpisode",
7
- ScheduledMaintenance = "ScheduledMaintenance"
7
+ ScheduledMaintenance = "ScheduledMaintenance",
8
+ SecurityCase = "SecurityCase"
8
9
  }
9
- export type NumbersStartAtColumn = "incidentNumbersStartAt" | "incidentEpisodeNumbersStartAt" | "alertNumbersStartAt" | "alertEpisodeNumbersStartAt" | "scheduledMaintenanceNumbersStartAt";
10
- export type NumberCounterColumn = "incidentCounter" | "incidentEpisodeCounter" | "alertCounter" | "alertEpisodeCounter" | "scheduledMaintenanceCounter";
10
+ export type NumbersStartAtColumn = "incidentNumbersStartAt" | "incidentEpisodeNumbersStartAt" | "alertNumbersStartAt" | "alertEpisodeNumbersStartAt" | "scheduledMaintenanceNumbersStartAt" | "securityCaseNumbersStartAt";
11
+ export type NumberCounterColumn = "incidentCounter" | "incidentEpisodeCounter" | "alertCounter" | "alertEpisodeCounter" | "scheduledMaintenanceCounter" | "securityCaseCounter";
11
12
  export interface NumberedRecordKindInfo {
12
13
  kind: NumberedRecordKind;
13
14
  counterColumn: NumberCounterColumn;
@@ -4,10 +4,11 @@ export declare enum NumberedRecordKind {
4
4
  IncidentEpisode = "IncidentEpisode",
5
5
  Alert = "Alert",
6
6
  AlertEpisode = "AlertEpisode",
7
- ScheduledMaintenance = "ScheduledMaintenance"
7
+ ScheduledMaintenance = "ScheduledMaintenance",
8
+ SecurityCase = "SecurityCase"
8
9
  }
9
- export type NumbersStartAtColumn = "incidentNumbersStartAt" | "incidentEpisodeNumbersStartAt" | "alertNumbersStartAt" | "alertEpisodeNumbersStartAt" | "scheduledMaintenanceNumbersStartAt";
10
- export type NumberCounterColumn = "incidentCounter" | "incidentEpisodeCounter" | "alertCounter" | "alertEpisodeCounter" | "scheduledMaintenanceCounter";
10
+ export type NumbersStartAtColumn = "incidentNumbersStartAt" | "incidentEpisodeNumbersStartAt" | "alertNumbersStartAt" | "alertEpisodeNumbersStartAt" | "scheduledMaintenanceNumbersStartAt" | "securityCaseNumbersStartAt";
11
+ export type NumberCounterColumn = "incidentCounter" | "incidentEpisodeCounter" | "alertCounter" | "alertEpisodeCounter" | "scheduledMaintenanceCounter" | "securityCaseCounter";
11
12
  export interface NumberedRecordKindInfo {
12
13
  kind: NumberedRecordKind;
13
14
  counterColumn: NumberCounterColumn;
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.NextNumberProblem = exports.NUMBERED_RECORD_KINDS = exports.NumberedRecordKind = void 0;
7
7
  const BadDataException_1 = __importDefault(require("../../Types/Exception/BadDataException"));
8
8
  /*
9
- * Next numbers: the number a project's next incident, alert, episode or
10
- * scheduled maintenance event gets.
9
+ * Next numbers: the number a project's next incident, alert, episode,
10
+ * scheduled maintenance event or security case gets.
11
11
  *
12
12
  * Each kind of number comes from a counter on the project
13
13
  * (incidentCounter, ...) that holds the highest number given out so far, and
@@ -38,6 +38,7 @@ var NumberedRecordKind;
38
38
  NumberedRecordKind["Alert"] = "Alert";
39
39
  NumberedRecordKind["AlertEpisode"] = "AlertEpisode";
40
40
  NumberedRecordKind["ScheduledMaintenance"] = "ScheduledMaintenance";
41
+ NumberedRecordKind["SecurityCase"] = "SecurityCase";
41
42
  })(NumberedRecordKind || (exports.NumberedRecordKind = NumberedRecordKind = {}));
42
43
  exports.NUMBERED_RECORD_KINDS = [
43
44
  {
@@ -80,6 +81,14 @@ exports.NUMBERED_RECORD_KINDS = [
80
81
  title: "Scheduled Maintenance Numbers Start At",
81
82
  recordName: "scheduled maintenance event",
82
83
  },
84
+ {
85
+ kind: NumberedRecordKind.SecurityCase,
86
+ counterColumn: "securityCaseCounter",
87
+ startsAtColumn: "securityCaseNumbersStartAt",
88
+ prefixColumn: "securityCaseNumberPrefix",
89
+ title: "Security Case Numbers Start At",
90
+ recordName: "security case",
91
+ },
83
92
  ];
84
93
  var NextNumberProblem;
85
94
  (function (NextNumberProblem) {
@@ -1,4 +1,4 @@
1
- export type NumberPrefixColumn = "incidentNumberPrefix" | "incidentEpisodeNumberPrefix" | "alertNumberPrefix" | "alertEpisodeNumberPrefix" | "scheduledMaintenanceNumberPrefix";
1
+ export type NumberPrefixColumn = "incidentNumberPrefix" | "incidentEpisodeNumberPrefix" | "alertNumberPrefix" | "alertEpisodeNumberPrefix" | "scheduledMaintenanceNumberPrefix" | "securityCaseNumberPrefix";
2
2
  export interface NumberPrefixColumnInfo {
3
3
  column: NumberPrefixColumn;
4
4
  title: string;