@oneuptime/common 14.0.91 → 14.0.93

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 (174) hide show
  1. package/Models/DatabaseModels/Alert.js +8 -1
  2. package/Models/DatabaseModels/AlertEpisodeMember.d.mts +1 -0
  3. package/Models/DatabaseModels/AlertEpisodeMember.d.ts +1 -0
  4. package/Models/DatabaseModels/AlertEpisodeMember.js +50 -0
  5. package/Models/DatabaseModels/AutoRemediationRule.js +1 -1
  6. package/Models/DatabaseModels/CodeRepository.d.mts +1 -0
  7. package/Models/DatabaseModels/CodeRepository.d.ts +1 -0
  8. package/Models/DatabaseModels/CodeRepository.js +69 -6
  9. package/Models/DatabaseModels/IncidentEpisodeMember.d.mts +1 -0
  10. package/Models/DatabaseModels/IncidentEpisodeMember.d.ts +1 -0
  11. package/Models/DatabaseModels/IncidentEpisodeMember.js +50 -0
  12. package/Models/DatabaseModels/IncomingCallPolicy.js +1 -1
  13. package/Models/DatabaseModels/LlmProvider.js +1 -1
  14. package/Models/DatabaseModels/MonitorTemplate.js +10 -4
  15. package/Models/DatabaseModels/NetworkDeviceDiscoveryScan.js +13 -13
  16. package/Models/DatabaseModels/OnCallDutyPolicy.js +1 -1
  17. package/Models/DatabaseModels/ScheduledMaintenanceReminderRule.js +1 -1
  18. package/Models/DatabaseModels/StatusPage.d.mts +2 -0
  19. package/Models/DatabaseModels/StatusPage.d.ts +2 -0
  20. package/Models/DatabaseModels/StatusPage.js +100 -0
  21. package/Types/AI/CodeTask.d.mts +1 -0
  22. package/Types/AI/CodeTask.d.ts +1 -0
  23. package/Types/AI/TelemetryAiActivity.d.mts +1 -0
  24. package/Types/AI/TelemetryAiActivity.d.ts +1 -0
  25. package/Types/AI/TelemetryAiActivity.js +4 -0
  26. package/Types/CodeRepository/CodeRepositorySetting.d.mts +15 -0
  27. package/Types/CodeRepository/CodeRepositorySetting.d.ts +15 -0
  28. package/Types/CodeRepository/CodeRepositorySetting.js +49 -0
  29. package/Types/CodeRepository/CodeRepositorySetting.mjs +3 -0
  30. package/Types/Database/BlankColumnValue.d.mts +6 -0
  31. package/Types/Database/BlankColumnValue.d.ts +6 -0
  32. package/Types/Database/BlankColumnValue.js +77 -0
  33. package/Types/Database/BlankColumnValue.mjs +4 -0
  34. package/Types/Date.d.mts +10 -0
  35. package/Types/Date.d.ts +10 -0
  36. package/Types/Date.js +385 -98
  37. package/Types/DateLanguage.d.mts +67 -0
  38. package/Types/DateLanguage.d.ts +67 -0
  39. package/Types/DateLanguage.js +478 -0
  40. package/Types/DateLanguage.mjs +21 -0
  41. package/Types/Email/EmailTemplateType.d.mts +1 -0
  42. package/Types/Email/EmailTemplateType.d.ts +1 -0
  43. package/Types/Email/EmailTemplateType.js +1 -0
  44. package/Types/IncomingCall/IncomingCallPolicyRepeat.d.mts +6 -0
  45. package/Types/IncomingCall/IncomingCallPolicyRepeat.d.ts +6 -0
  46. package/Types/IncomingCall/IncomingCallPolicyRepeat.js +41 -14
  47. package/Types/IncomingCall/IncomingCallPolicyRepeat.mjs +3 -0
  48. package/Types/Monitor/CriteriaFilter.d.mts +1 -0
  49. package/Types/Monitor/CriteriaFilter.d.ts +1 -0
  50. package/Types/Monitor/CriteriaFilter.js +9 -0
  51. package/Types/Monitor/DatabaseMetricCatalog.js +2 -2
  52. package/Types/Monitor/KubernetesEventAlertTemplates.d.mts +20 -0
  53. package/Types/Monitor/KubernetesEventAlertTemplates.d.ts +20 -0
  54. package/Types/Monitor/KubernetesEventAlertTemplates.js +232 -0
  55. package/Types/Monitor/KubernetesEventAlertTemplates.mjs +8 -0
  56. package/Types/Monitor/MonitorType.js +12 -2
  57. package/Types/Monitor/Recommendation/MonitorRecommendationCatalog.js +27 -2
  58. package/Types/Monitor/Recommendation/MonitorRecommendationUtil.d.mts +1 -0
  59. package/Types/Monitor/Recommendation/MonitorRecommendationUtil.d.ts +1 -0
  60. package/Types/Monitor/Recommendation/MonitorRecommendationUtil.js +31 -1
  61. package/Types/Monitor/SnmpMonitor/NetworkDeviceAlertPack.d.mts +3 -1
  62. package/Types/Monitor/SnmpMonitor/NetworkDeviceAlertPack.d.ts +3 -1
  63. package/Types/Monitor/SnmpMonitor/NetworkDeviceAlertPack.js +3 -2
  64. package/Types/Monitor/SnmpMonitor/SnmpMonitorResponse.d.mts +1 -0
  65. package/Types/Monitor/SnmpMonitor/SnmpMonitorResponse.d.ts +1 -0
  66. package/Types/NotificationSetting/NotificationEmailRollupCategory.js +2 -0
  67. package/Types/NotificationSetting/NotificationEmailRollupPolicy.js +10 -3
  68. package/Types/NotificationSetting/NotificationSettingEventType.d.mts +1 -0
  69. package/Types/NotificationSetting/NotificationSettingEventType.d.ts +1 -0
  70. package/Types/NotificationSetting/NotificationSettingEventType.js +7 -0
  71. package/Types/OnCallDutyPolicy/OnCallDutyPolicyRepeat.d.mts +7 -0
  72. package/Types/OnCallDutyPolicy/OnCallDutyPolicyRepeat.d.ts +7 -0
  73. package/Types/OnCallDutyPolicy/OnCallDutyPolicyRepeat.js +51 -0
  74. package/Types/OnCallDutyPolicy/OnCallDutyPolicyRepeat.mjs +4 -0
  75. package/Types/Reminder/ScheduledMaintenanceReminderNeverReminds.d.mts +8 -0
  76. package/Types/Reminder/ScheduledMaintenanceReminderNeverReminds.d.ts +8 -0
  77. package/Types/Reminder/ScheduledMaintenanceReminderNeverReminds.js +55 -0
  78. package/Types/Reminder/ScheduledMaintenanceReminderNeverReminds.mjs +5 -0
  79. package/Types/Runner/CodeRepositoryRunner.d.mts +7 -0
  80. package/Types/Runner/CodeRepositoryRunner.d.ts +7 -0
  81. package/Types/Runner/CodeRepositoryRunner.js +60 -14
  82. package/Types/Runner/CodeRepositoryRunner.mjs +1 -0
  83. package/Types/SecurityEvent/OcsfProcessActivity.d.mts +25 -0
  84. package/Types/SecurityEvent/OcsfProcessActivity.d.ts +25 -0
  85. package/Types/SecurityEvent/OcsfProcessActivity.js +131 -0
  86. package/Types/SecurityEvent/OcsfProcessActivity.mjs +8 -0
  87. package/Types/Workflow/Templates.js +2 -5
  88. package/UI/Utils/TranslateTemplate.d.mts +73 -0
  89. package/UI/Utils/TranslateTemplate.d.ts +73 -0
  90. package/Utils/ColorContrast.d.mts +3 -0
  91. package/Utils/ColorContrast.d.ts +3 -0
  92. package/Utils/ColorContrast.js +41 -3
  93. package/Utils/ColorContrast.mjs +2 -0
  94. package/Utils/CronTab.d.mts +41 -3
  95. package/Utils/CronTab.d.ts +41 -3
  96. package/Utils/CronTab.js +112 -38
  97. package/Utils/Incident/WhoOpenedItRootCause.d.mts +2 -0
  98. package/Utils/Incident/WhoOpenedItRootCause.d.ts +2 -0
  99. package/Utils/Incident/WhoOpenedItRootCause.js +50 -0
  100. package/Utils/Incident/WhoOpenedItRootCause.mjs +3 -0
  101. package/Utils/Monitor/MonitorOverviewTargetUtil.d.mts +2 -0
  102. package/Utils/Monitor/MonitorOverviewTargetUtil.d.ts +2 -0
  103. package/Utils/Monitor/MonitorOverviewTargetUtil.js +13 -2
  104. package/Utils/Monitor/SyntheticMonitorStepsUtil.d.mts +18 -0
  105. package/Utils/Monitor/SyntheticMonitorStepsUtil.d.ts +18 -0
  106. package/Utils/Monitor/SyntheticMonitorStepsUtil.js +129 -0
  107. package/Utils/Monitor/SyntheticMonitorStepsUtil.mjs +4 -0
  108. package/Utils/Rules/RuleRunSummary.d.mts +1 -0
  109. package/Utils/Rules/RuleRunSummary.d.ts +1 -0
  110. package/Utils/Rules/RuleRunSummary.js +19 -1
  111. package/Utils/Rules/RuleRunSummary.mjs +1 -0
  112. package/Utils/SecurityEvent/Destinations/GoogleSecOpsUdmMapper.d.mts +5 -0
  113. package/Utils/SecurityEvent/Destinations/GoogleSecOpsUdmMapper.d.ts +5 -0
  114. package/Utils/SecurityEvent/Destinations/GoogleSecOpsUdmMapper.js +219 -58
  115. package/Utils/SecurityEvent/OcsfNormalizer.js +22 -13
  116. package/Utils/Slo/SloDuration.d.mts +1 -0
  117. package/Utils/Slo/SloDuration.d.ts +1 -0
  118. package/Utils/Slo/SloDuration.js +57 -8
  119. package/Utils/Slo/SloDuration.mjs +1 -0
  120. package/Utils/Sms/Gsm7Text.js +9 -1
  121. package/Utils/Sms/OnCallPageSms.d.mts +2 -0
  122. package/Utils/Sms/OnCallPageSms.d.ts +2 -0
  123. package/Utils/Sms/OnCallPageSms.js +19 -2
  124. package/Utils/Sms/OnCallPageSms.mjs +1 -0
  125. package/Utils/Sms/SubscriberSms.d.mts +2 -0
  126. package/Utils/Sms/SubscriberSms.d.ts +2 -0
  127. package/Utils/Sms/SubscriberSms.js +35 -0
  128. package/Utils/Sms/SubscriberSms.mjs +3 -0
  129. package/Utils/Suggestions/CodeFixSuggestion.d.mts +15 -0
  130. package/Utils/Suggestions/CodeFixSuggestion.d.ts +15 -0
  131. package/Utils/Suggestions/CodeFixSuggestion.js +62 -1
  132. package/Utils/Suggestions/CodeFixSuggestion.mjs +4 -0
  133. package/Utils/Suggestions/ProfileFixSuggestion.js +4 -0
  134. package/Utils/Suggestions/SuggestionBlocker.d.mts +8 -0
  135. package/Utils/Suggestions/SuggestionBlocker.d.ts +8 -0
  136. package/Utils/Suggestions/SuggestionBlocker.js +51 -0
  137. package/Utils/Suggestions/SuggestionBlocker.mjs +4 -0
  138. package/Utils/Suggestions/SuggestionOffer.d.mts +2 -1
  139. package/Utils/Suggestions/SuggestionOffer.d.ts +2 -1
  140. package/Utils/Suggestions/SuggestionOffer.js +5 -0
  141. package/Utils/Suggestions/TelemetryAiFixSuggestion.d.mts +2 -7
  142. package/Utils/Suggestions/TelemetryAiFixSuggestion.d.ts +2 -7
  143. package/Utils/Suggestions/TelemetryAiFixSuggestion.js +8 -36
  144. package/Utils/Suggestions/TelemetryImprovementSuggestion.d.mts +1 -0
  145. package/Utils/Suggestions/TelemetryImprovementSuggestion.d.ts +1 -0
  146. package/Utils/Suggestions/TelemetryImprovementSuggestion.js +1 -0
  147. package/Utils/Suggestions/TracePerformanceFixSuggestion.d.mts +6 -0
  148. package/Utils/Suggestions/TracePerformanceFixSuggestion.d.ts +6 -0
  149. package/Utils/Suggestions/TracePerformanceFixSuggestion.js +46 -5
  150. package/package.json +8 -1
  151. package/Utils/Monitor/MonitorCheckScheduleUtil.d.mts +0 -61
  152. package/Utils/Monitor/MonitorCheckScheduleUtil.d.ts +0 -61
  153. package/Utils/Monitor/MonitorCheckScheduleUtil.js +0 -476
  154. package/Utils/Monitor/MonitorCheckScheduleUtil.mjs +0 -3
  155. package/Utils/Monitor/MonitorOverviewFamily.d.mts +0 -39
  156. package/Utils/Monitor/MonitorOverviewFamily.d.ts +0 -39
  157. package/Utils/Monitor/MonitorOverviewFamily.js +0 -206
  158. package/Utils/Monitor/MonitorOverviewFamily.mjs +0 -4
  159. package/Utils/Monitor/MonitorOverviewPresentationUtil.d.mts +0 -189
  160. package/Utils/Monitor/MonitorOverviewPresentationUtil.d.ts +0 -189
  161. package/Utils/Monitor/MonitorOverviewPresentationUtil.js +0 -1480
  162. package/Utils/Monitor/MonitorOverviewPresentationUtil.mjs +0 -5
  163. package/Utils/Monitor/MonitorOverviewProbeUtil.d.mts +0 -112
  164. package/Utils/Monitor/MonitorOverviewProbeUtil.d.ts +0 -112
  165. package/Utils/Monitor/MonitorOverviewProbeUtil.js +0 -640
  166. package/Utils/Monitor/MonitorOverviewProbeUtil.mjs +0 -3
  167. package/Utils/Monitor/MonitorStatusHistoryUtil.d.mts +0 -27
  168. package/Utils/Monitor/MonitorStatusHistoryUtil.d.ts +0 -27
  169. package/Utils/Monitor/MonitorStatusHistoryUtil.js +0 -132
  170. package/Utils/Monitor/MonitorStatusHistoryUtil.mjs +0 -2
  171. package/Utils/Monitor/MonitorUptimeSummaryUtil.d.mts +0 -42
  172. package/Utils/Monitor/MonitorUptimeSummaryUtil.d.ts +0 -42
  173. package/Utils/Monitor/MonitorUptimeSummaryUtil.js +0 -468
  174. package/Utils/Monitor/MonitorUptimeSummaryUtil.mjs +0 -2
@@ -1,468 +0,0 @@
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 UptimeUtil_1 = __importDefault(require("../Uptime/UptimeUtil"));
14
- const CAVEAT_SUFFIX = {
15
- paused: " · includes paused time",
16
- "not-checking": " · includes time with no checks running",
17
- "no-results": " · no check has completed yet",
18
- };
19
- const WINDOW_KEYS = Object.values(MonitorUptimeSummary_1.MonitorUptimeWindowKey);
20
- // Used to trim "99.950" to "99.95" and "98.000" to "98".
21
- const TRAILING_ZEROS = /0+$/;
22
- const TRAILING_POINT = /\.$/;
23
- // A finite, non-negative number, or 0. Wire values are never trusted.
24
- const toSeconds = (value) => {
25
- const numeric = typeof value === "number" ? value : Number(value);
26
- if (!Number.isFinite(numeric) || numeric < 0) {
27
- return 0;
28
- }
29
- return numeric;
30
- };
31
- const toDateOrNull = (value) => {
32
- if (typeof value !== "string" || !value) {
33
- return null;
34
- }
35
- const parsed = new Date(value);
36
- return Number.isNaN(parsed.getTime()) ? null : parsed;
37
- };
38
- const durationsToJSON = (durations) => {
39
- return durations.map((duration) => {
40
- return {
41
- monitorStatusId: duration.monitorStatusId.toString(),
42
- seconds: duration.seconds,
43
- };
44
- });
45
- };
46
- const durationsFromJSON = (raw) => {
47
- const durations = [];
48
- if (!Array.isArray(raw)) {
49
- return durations;
50
- }
51
- for (const item of raw) {
52
- if (!item || typeof item !== "object") {
53
- continue;
54
- }
55
- const statusId = item["monitorStatusId"];
56
- if (typeof statusId !== "string" || !statusId) {
57
- continue;
58
- }
59
- durations.push({
60
- monitorStatusId: new ObjectID_1.default(statusId),
61
- seconds: toSeconds(item["seconds"]),
62
- });
63
- }
64
- return durations;
65
- };
66
- class MonitorUptimeSummaryUtil {
67
- /*
68
- * Adds day buckets up into one window. Durations are merged per status
69
- * and ordered largest first, which is the order a legend wants.
70
- */
71
- static sumBuckets(data) {
72
- let windowSeconds = 0;
73
- let coveredSeconds = 0;
74
- const secondsByStatusId = new Map();
75
- for (const bucket of data.buckets || []) {
76
- windowSeconds += toSeconds(bucket.daySeconds);
77
- coveredSeconds += toSeconds(bucket.coveredSeconds);
78
- for (const duration of bucket.statusDurations || []) {
79
- const statusId = duration.monitorStatusId.toString();
80
- secondsByStatusId.set(statusId, (secondsByStatusId.get(statusId) || 0) + toSeconds(duration.seconds));
81
- }
82
- }
83
- const statusDurations = Array.from(secondsByStatusId.entries())
84
- .map((entry) => {
85
- return { monitorStatusId: new ObjectID_1.default(entry[0]), seconds: entry[1] };
86
- })
87
- .sort((a, b) => {
88
- if (b.seconds !== a.seconds) {
89
- return b.seconds - a.seconds;
90
- }
91
- // A stable order for equal durations, so the legend does not shuffle.
92
- return a.monitorStatusId
93
- .toString()
94
- .localeCompare(b.monitorStatusId.toString());
95
- });
96
- return {
97
- key: data.key,
98
- startDate: data.startDate,
99
- endDate: data.endDate,
100
- windowSeconds: windowSeconds,
101
- coveredSeconds: coveredSeconds,
102
- statusDurations: statusDurations,
103
- };
104
- }
105
- /*
106
- * Downtime is time in any status that is not marked operational, which is
107
- * how the status page and the old overview counted it. A "Degraded" status
108
- * is downtime here.
109
- */
110
- static getDowntimeStatusIds(statuses) {
111
- const ids = new Set();
112
- for (const status of statuses || []) {
113
- if (!status.isOperationalState) {
114
- ids.add(status.id.toString());
115
- }
116
- }
117
- return ids;
118
- }
119
- /*
120
- * `caveat` notes time the window counts but nothing measured. The older
121
- * `isPausedNow: true` is read as the "paused" caveat; a given `caveat`,
122
- * including null, wins over it.
123
- */
124
- static getWindowPresentation(data) {
125
- const window = data.window;
126
- let caveat = data.isPausedNow ? "paused" : null;
127
- if (data.caveat !== undefined) {
128
- caveat = data.caveat;
129
- }
130
- if (!window) {
131
- return null;
132
- }
133
- const coveredSeconds = toSeconds(window.coveredSeconds);
134
- const windowSeconds = toSeconds(window.windowSeconds);
135
- if (coveredSeconds < 1) {
136
- return {
137
- key: window.key,
138
- kind: "NoData",
139
- uptimePercent: null,
140
- valueText: "No data",
141
- description: "Nothing recorded in this window",
142
- downtimeSeconds: 0,
143
- coveredSeconds: coveredSeconds,
144
- windowSeconds: windowSeconds,
145
- // Partial describes a measured window; this one was not measured.
146
- isPartial: false,
147
- };
148
- }
149
- let downtimeSeconds = 0;
150
- for (const duration of window.statusDurations || []) {
151
- if (data.downtimeStatusIds.has(duration.monitorStatusId.toString())) {
152
- downtimeSeconds += toSeconds(duration.seconds);
153
- }
154
- }
155
- // Durations can never honestly exceed the time that was recorded.
156
- downtimeSeconds = Math.min(downtimeSeconds, coveredSeconds);
157
- /*
158
- * Multiply before dividing: (1999 / 2000) * 100 is 99.94999..., which
159
- * the floor in formatUptimePercent would turn into 99.949.
160
- */
161
- const uptimePercent = ((coveredSeconds - downtimeSeconds) * 100) / coveredSeconds;
162
- const isPartial = coveredSeconds <
163
- windowSeconds - MonitorUptimeSummaryUtil.COVERAGE_TOLERANCE_SECONDS;
164
- let description = downtimeSeconds > 0
165
- ? `Down ${(0, SloDuration_1.formatDurationCompact)(downtimeSeconds)}`
166
- : "No downtime";
167
- if (isPartial) {
168
- description += ` · measured over ${(0, SloDuration_1.formatDurationCompact)(coveredSeconds)}`;
169
- }
170
- if (caveat) {
171
- description += CAVEAT_SUFFIX[caveat];
172
- }
173
- return {
174
- key: window.key,
175
- kind: "Measured",
176
- uptimePercent: uptimePercent,
177
- valueText: MonitorUptimeSummaryUtil.formatUptimePercent({
178
- uptimePercent: uptimePercent,
179
- downtimeSeconds: downtimeSeconds,
180
- }),
181
- description: description,
182
- downtimeSeconds: downtimeSeconds,
183
- coveredSeconds: coveredSeconds,
184
- windowSeconds: windowSeconds,
185
- isPartial: isPartial,
186
- };
187
- }
188
- /*
189
- * "100%" only when downtime is exactly zero. Anything else is floored to
190
- * three decimals and capped at 99.999, so 43 seconds of downtime in 30
191
- * days can never round up into a perfect score.
192
- */
193
- static formatUptimePercent(data) {
194
- if (!(data.downtimeSeconds > 0)) {
195
- return "100%";
196
- }
197
- const rawPercent = Number.isFinite(data.uptimePercent)
198
- ? data.uptimePercent
199
- : 0;
200
- /*
201
- * Strip floating-point noise before flooring, or 99.95 stored as
202
- * 99.94999999999999 would read 99.949.
203
- */
204
- const cleanPercent = Math.round(rawPercent * 1e9) / 1e9;
205
- let value = UptimeUtil_1.default.roundToPrecision({
206
- number: cleanPercent,
207
- precision: UptimePrecision_1.default.THREE_DECIMAL,
208
- });
209
- if (value >= 100) {
210
- value = 99.999;
211
- }
212
- value = Math.max(0, value);
213
- const text = value
214
- .toFixed(3)
215
- .replace(TRAILING_ZEROS, "")
216
- .replace(TRAILING_POINT, "");
217
- return `${text}%`;
218
- }
219
- static getWindow(summary, key) {
220
- return (summary.windows || []).find((window) => {
221
- return window.key === key;
222
- });
223
- }
224
- /*
225
- * Plain ISO and id strings, like UptimeDailyAggregateUtil, and for the
226
- * same reason: the typed JSON envelopes would triple the payload.
227
- */
228
- static toJSON(summary) {
229
- return {
230
- monitorId: summary.monitorId.toString(),
231
- timezone: summary.timezone,
232
- generatedAt: summary.generatedAt.toISOString(),
233
- startDate: summary.startDate.toISOString(),
234
- endDate: summary.endDate.toISOString(),
235
- buckets: summary.buckets.map((bucket) => {
236
- return {
237
- bucketStart: bucket.bucketStart.toISOString(),
238
- bucketEnd: bucket.bucketEnd.toISOString(),
239
- daySeconds: bucket.daySeconds,
240
- coveredSeconds: bucket.coveredSeconds,
241
- statusDurations: durationsToJSON(bucket.statusDurations),
242
- };
243
- }),
244
- windows: summary.windows.map((window) => {
245
- return {
246
- key: window.key,
247
- startDate: window.startDate.toISOString(),
248
- endDate: window.endDate.toISOString(),
249
- windowSeconds: window.windowSeconds,
250
- coveredSeconds: window.coveredSeconds,
251
- statusDurations: durationsToJSON(window.statusDurations),
252
- };
253
- }),
254
- isComplete: summary.isComplete,
255
- completeFrom: summary.completeFrom
256
- ? summary.completeFrom.toISOString()
257
- : null,
258
- statuses: summary.statuses.map((status) => {
259
- return {
260
- id: status.id.toString(),
261
- name: status.name,
262
- color: status.color,
263
- isOperationalState: status.isOperationalState,
264
- isOfflineState: status.isOfflineState,
265
- priority: status.priority,
266
- };
267
- }),
268
- };
269
- }
270
- /*
271
- * Total: never throws. Null when the payload is not a summary at all, so
272
- * the page can say "could not be read" instead of drawing an empty strip
273
- * that looks like a monitor with no history. Malformed parts inside a
274
- * valid summary are skipped one by one.
275
- */
276
- static fromJSON(json) {
277
- if (!json || typeof json !== "object" || Array.isArray(json)) {
278
- return null;
279
- }
280
- const monitorId = json["monitorId"];
281
- if (typeof monitorId !== "string" || !monitorId) {
282
- return null;
283
- }
284
- const startDate = toDateOrNull(json["startDate"]);
285
- const endDate = toDateOrNull(json["endDate"]);
286
- if (!startDate || !endDate) {
287
- return null;
288
- }
289
- const rawBuckets = json["buckets"];
290
- if (!Array.isArray(rawBuckets)) {
291
- return null;
292
- }
293
- const buckets = [];
294
- for (const rawBucket of rawBuckets) {
295
- if (!rawBucket || typeof rawBucket !== "object") {
296
- continue;
297
- }
298
- const bucket = rawBucket;
299
- const bucketStart = toDateOrNull(bucket["bucketStart"]);
300
- const bucketEnd = toDateOrNull(bucket["bucketEnd"]);
301
- if (!bucketStart || !bucketEnd) {
302
- continue;
303
- }
304
- buckets.push({
305
- bucketStart: bucketStart,
306
- bucketEnd: bucketEnd,
307
- daySeconds: toSeconds(bucket["daySeconds"]),
308
- coveredSeconds: toSeconds(bucket["coveredSeconds"]),
309
- statusDurations: durationsFromJSON(bucket["statusDurations"]),
310
- });
311
- }
312
- const windows = [];
313
- const rawWindows = json["windows"];
314
- if (Array.isArray(rawWindows)) {
315
- for (const rawWindow of rawWindows) {
316
- if (!rawWindow || typeof rawWindow !== "object") {
317
- continue;
318
- }
319
- const window = rawWindow;
320
- const key = window["key"];
321
- const windowStart = toDateOrNull(window["startDate"]);
322
- const windowEnd = toDateOrNull(window["endDate"]);
323
- if (typeof key !== "string" ||
324
- !WINDOW_KEYS.includes(key) ||
325
- !windowStart ||
326
- !windowEnd) {
327
- continue;
328
- }
329
- windows.push({
330
- key: key,
331
- startDate: windowStart,
332
- endDate: windowEnd,
333
- windowSeconds: toSeconds(window["windowSeconds"]),
334
- coveredSeconds: toSeconds(window["coveredSeconds"]),
335
- statusDurations: durationsFromJSON(window["statusDurations"]),
336
- });
337
- }
338
- }
339
- const statuses = [];
340
- const rawStatuses = json["statuses"];
341
- if (Array.isArray(rawStatuses)) {
342
- for (const rawStatus of rawStatuses) {
343
- if (!rawStatus || typeof rawStatus !== "object") {
344
- continue;
345
- }
346
- const status = rawStatus;
347
- const id = status["id"];
348
- const name = status["name"];
349
- if (typeof id !== "string" || !id || typeof name !== "string") {
350
- continue;
351
- }
352
- const priority = status["priority"];
353
- statuses.push({
354
- id: new ObjectID_1.default(id),
355
- name: name,
356
- color: typeof status["color"] === "string" ? status["color"] : "",
357
- isOperationalState: status["isOperationalState"] === true,
358
- isOfflineState: status["isOfflineState"] === true,
359
- priority: typeof priority === "number" && Number.isFinite(priority)
360
- ? priority
361
- : null,
362
- });
363
- }
364
- }
365
- return {
366
- monitorId: new ObjectID_1.default(monitorId),
367
- timezone: typeof json["timezone"] === "string" && json["timezone"]
368
- ? json["timezone"]
369
- : "UTC",
370
- generatedAt: toDateOrNull(json["generatedAt"]) || endDate,
371
- startDate: startDate,
372
- endDate: endDate,
373
- buckets: buckets,
374
- windows: windows,
375
- /*
376
- * Absent means complete, as in UptimeDailyAggregateUtil: only an
377
- * explicit false greys out the older bars.
378
- */
379
- isComplete: json["isComplete"] !== false,
380
- completeFrom: toDateOrNull(json["completeFrom"]),
381
- statuses: statuses,
382
- };
383
- }
384
- /*
385
- * The zone the day buckets are cut in. Missing means UTC; anything that
386
- * is not an IANA name is refused rather than silently read as UTC, because
387
- * a caller who sent "Europe/Lodnon" would otherwise get bars that are off
388
- * by an hour and no hint why.
389
- *
390
- * The current name is returned, so the value handed to the database is
391
- * always one it knows. moment answers a legacy name with that same name
392
- * (its zone for "Asia/Calcutta" is called "Asia/Calcutta"), and Chromium
393
- * reports Asia/Calcutta for India, but the Postgres in the shipped images
394
- * has no legacy tzdata links and rejects several of them in AT TIME ZONE.
395
- * So TimezoneAlias translates first — which also lets through
396
- * US/Pacific-New, a name tzdata removed and moment no longer resolves.
397
- */
398
- static parseTimezone(raw) {
399
- var _a;
400
- if (typeof raw !== "string") {
401
- return "UTC";
402
- }
403
- const trimmed = raw.trim();
404
- if (!trimmed) {
405
- return "UTC";
406
- }
407
- const currentName = TimezoneAlias_1.default.getCanonicalTimezone(trimmed);
408
- let zoneName = null;
409
- try {
410
- zoneName = ((_a = Date_1.Moment.tz.zone(currentName)) === null || _a === void 0 ? void 0 : _a.name) || null;
411
- }
412
- catch (_b) {
413
- zoneName = null;
414
- }
415
- if (!zoneName) {
416
- throw new BadDataException_1.default("timezone must be an IANA time zone name, for example Europe/London.");
417
- }
418
- return zoneName;
419
- }
420
- /*
421
- * The zone to cut day buckets in, as one parseTimezone accepts. A browser
422
- * can carry newer zone data than the bundled moment-timezone (for example
423
- * America/Coyhaique, added in tzdata 2025b); the server would refuse such
424
- * a zone on every load, so it is swapped for moment's own guess, which
425
- * matches the browser's offsets from the data it has. The page labels
426
- * days with moment too, so both cut days on the same boundaries. UTC is
427
- * the last resort.
428
- */
429
- static getBrowserTimezone() {
430
- let zone = undefined;
431
- try {
432
- zone = Intl.DateTimeFormat().resolvedOptions().timeZone;
433
- }
434
- catch (_a) {
435
- zone = undefined;
436
- }
437
- const known = MonitorUptimeSummaryUtil.toKnownZone(zone);
438
- if (known) {
439
- return known;
440
- }
441
- try {
442
- return (MonitorUptimeSummaryUtil.toKnownZone(Date_1.Moment.tz.guess(true)) || "UTC");
443
- }
444
- catch (_b) {
445
- return "UTC";
446
- }
447
- }
448
- static toKnownZone(zone) {
449
- if (!zone) {
450
- return null;
451
- }
452
- try {
453
- return Date_1.Moment.tz.zone(zone) ? zone : null;
454
- }
455
- catch (_a) {
456
- return null;
457
- }
458
- }
459
- }
460
- /*
461
- * How much of a window may be missing before it is called partial. The
462
- * aggregate clips its last bucket to now(), and the request that produced
463
- * it takes a moment, so a fully covered window can come back a few seconds
464
- * short. A minute is well past that and well short of anything a person
465
- * would call a gap.
466
- */
467
- MonitorUptimeSummaryUtil.COVERAGE_TOLERANCE_SECONDS = 60;
468
- exports.default = MonitorUptimeSummaryUtil;
@@ -1,2 +0,0 @@
1
- import commonJsModule from "./MonitorUptimeSummaryUtil.js";
2
- export default commonJsModule.default;