@oneuptime/common 14.0.91 → 14.0.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Models/DatabaseModels/AutoRemediationRule.js +1 -1
- package/Models/DatabaseModels/CodeRepository.d.mts +1 -0
- package/Models/DatabaseModels/CodeRepository.d.ts +1 -0
- package/Models/DatabaseModels/CodeRepository.js +69 -6
- package/Types/AI/CodeTask.d.mts +1 -0
- package/Types/AI/CodeTask.d.ts +1 -0
- package/Types/AI/TelemetryAiActivity.d.mts +1 -0
- package/Types/AI/TelemetryAiActivity.d.ts +1 -0
- package/Types/AI/TelemetryAiActivity.js +4 -0
- package/Types/CodeRepository/CodeRepositorySetting.d.mts +15 -0
- package/Types/CodeRepository/CodeRepositorySetting.d.ts +15 -0
- package/Types/CodeRepository/CodeRepositorySetting.js +49 -0
- package/Types/CodeRepository/CodeRepositorySetting.mjs +3 -0
- package/Types/Date.d.mts +10 -0
- package/Types/Date.d.ts +10 -0
- package/Types/Date.js +385 -98
- package/Types/DateLanguage.d.mts +67 -0
- package/Types/DateLanguage.d.ts +67 -0
- package/Types/DateLanguage.js +478 -0
- package/Types/DateLanguage.mjs +21 -0
- package/Types/Runner/CodeRepositoryRunner.d.mts +7 -0
- package/Types/Runner/CodeRepositoryRunner.d.ts +7 -0
- package/Types/Runner/CodeRepositoryRunner.js +60 -14
- package/Types/Runner/CodeRepositoryRunner.mjs +1 -0
- package/Types/SecurityEvent/OcsfProcessActivity.d.mts +25 -0
- package/Types/SecurityEvent/OcsfProcessActivity.d.ts +25 -0
- package/Types/SecurityEvent/OcsfProcessActivity.js +131 -0
- package/Types/SecurityEvent/OcsfProcessActivity.mjs +8 -0
- package/UI/Utils/TranslateTemplate.d.mts +73 -0
- package/UI/Utils/TranslateTemplate.d.ts +73 -0
- package/Utils/CronTab.d.mts +41 -3
- package/Utils/CronTab.d.ts +41 -3
- package/Utils/CronTab.js +112 -38
- package/Utils/Monitor/MonitorOverviewTargetUtil.d.mts +2 -0
- package/Utils/Monitor/MonitorOverviewTargetUtil.d.ts +2 -0
- package/Utils/Monitor/MonitorOverviewTargetUtil.js +13 -2
- package/Utils/SecurityEvent/Destinations/GoogleSecOpsUdmMapper.d.mts +5 -0
- package/Utils/SecurityEvent/Destinations/GoogleSecOpsUdmMapper.d.ts +5 -0
- package/Utils/SecurityEvent/Destinations/GoogleSecOpsUdmMapper.js +219 -58
- package/Utils/SecurityEvent/OcsfNormalizer.js +22 -13
- package/Utils/Slo/SloDuration.d.mts +1 -0
- package/Utils/Slo/SloDuration.d.ts +1 -0
- package/Utils/Slo/SloDuration.js +57 -8
- package/Utils/Slo/SloDuration.mjs +1 -0
- package/Utils/Suggestions/CodeFixSuggestion.d.mts +15 -0
- package/Utils/Suggestions/CodeFixSuggestion.d.ts +15 -0
- package/Utils/Suggestions/CodeFixSuggestion.js +62 -1
- package/Utils/Suggestions/CodeFixSuggestion.mjs +4 -0
- package/Utils/Suggestions/ProfileFixSuggestion.js +4 -0
- package/Utils/Suggestions/SuggestionBlocker.d.mts +8 -0
- package/Utils/Suggestions/SuggestionBlocker.d.ts +8 -0
- package/Utils/Suggestions/SuggestionBlocker.js +51 -0
- package/Utils/Suggestions/SuggestionBlocker.mjs +4 -0
- package/Utils/Suggestions/SuggestionOffer.d.mts +2 -1
- package/Utils/Suggestions/SuggestionOffer.d.ts +2 -1
- package/Utils/Suggestions/SuggestionOffer.js +5 -0
- package/Utils/Suggestions/TelemetryAiFixSuggestion.d.mts +2 -7
- package/Utils/Suggestions/TelemetryAiFixSuggestion.d.ts +2 -7
- package/Utils/Suggestions/TelemetryAiFixSuggestion.js +8 -36
- package/Utils/Suggestions/TelemetryImprovementSuggestion.d.mts +1 -0
- package/Utils/Suggestions/TelemetryImprovementSuggestion.d.ts +1 -0
- package/Utils/Suggestions/TelemetryImprovementSuggestion.js +1 -0
- package/Utils/Suggestions/TracePerformanceFixSuggestion.d.mts +6 -0
- package/Utils/Suggestions/TracePerformanceFixSuggestion.d.ts +6 -0
- package/Utils/Suggestions/TracePerformanceFixSuggestion.js +46 -5
- package/package.json +8 -1
- package/Utils/Monitor/MonitorCheckScheduleUtil.d.mts +0 -61
- package/Utils/Monitor/MonitorCheckScheduleUtil.d.ts +0 -61
- package/Utils/Monitor/MonitorCheckScheduleUtil.js +0 -476
- package/Utils/Monitor/MonitorCheckScheduleUtil.mjs +0 -3
- package/Utils/Monitor/MonitorOverviewFamily.d.mts +0 -39
- package/Utils/Monitor/MonitorOverviewFamily.d.ts +0 -39
- package/Utils/Monitor/MonitorOverviewFamily.js +0 -206
- package/Utils/Monitor/MonitorOverviewFamily.mjs +0 -4
- package/Utils/Monitor/MonitorOverviewPresentationUtil.d.mts +0 -189
- package/Utils/Monitor/MonitorOverviewPresentationUtil.d.ts +0 -189
- package/Utils/Monitor/MonitorOverviewPresentationUtil.js +0 -1480
- package/Utils/Monitor/MonitorOverviewPresentationUtil.mjs +0 -5
- package/Utils/Monitor/MonitorOverviewProbeUtil.d.mts +0 -112
- package/Utils/Monitor/MonitorOverviewProbeUtil.d.ts +0 -112
- package/Utils/Monitor/MonitorOverviewProbeUtil.js +0 -640
- package/Utils/Monitor/MonitorOverviewProbeUtil.mjs +0 -3
- package/Utils/Monitor/MonitorStatusHistoryUtil.d.mts +0 -27
- package/Utils/Monitor/MonitorStatusHistoryUtil.d.ts +0 -27
- package/Utils/Monitor/MonitorStatusHistoryUtil.js +0 -132
- package/Utils/Monitor/MonitorStatusHistoryUtil.mjs +0 -2
- package/Utils/Monitor/MonitorUptimeSummaryUtil.d.mts +0 -42
- package/Utils/Monitor/MonitorUptimeSummaryUtil.d.ts +0 -42
- package/Utils/Monitor/MonitorUptimeSummaryUtil.js +0 -468
- package/Utils/Monitor/MonitorUptimeSummaryUtil.mjs +0 -2
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import Monitor from "../../Models/DatabaseModels/Monitor";
|
|
2
|
-
export declare enum MonitorCheckFreshness {
|
|
3
|
-
Fresh = "Fresh",
|
|
4
|
-
Stale = "Stale",
|
|
5
|
-
AwaitingFirstResult = "AwaitingFirstResult",
|
|
6
|
-
NotScheduled = "NotScheduled",
|
|
7
|
-
Unknown = "Unknown"
|
|
8
|
-
}
|
|
9
|
-
export interface MonitorCheckFreshnessResult {
|
|
10
|
-
freshness: MonitorCheckFreshness;
|
|
11
|
-
overdueSeconds: number | null;
|
|
12
|
-
resultAgeSeconds: number | null;
|
|
13
|
-
}
|
|
14
|
-
export interface MonitorScheduledRun {
|
|
15
|
-
runAt: Date;
|
|
16
|
-
spacingSeconds: number;
|
|
17
|
-
}
|
|
18
|
-
export interface MonitorResultLateness {
|
|
19
|
-
lateSeconds: number;
|
|
20
|
-
graceSeconds: number;
|
|
21
|
-
}
|
|
22
|
-
export default class MonitorCheckScheduleUtil {
|
|
23
|
-
static readonly DEFAULT_CADENCE_SECONDS: number;
|
|
24
|
-
static getCadenceSeconds(data: {
|
|
25
|
-
monitoringInterval: string | null | undefined;
|
|
26
|
-
from: Date;
|
|
27
|
-
}): number | null;
|
|
28
|
-
static resolveCadenceSeconds(data: {
|
|
29
|
-
monitoringInterval: string | null | undefined;
|
|
30
|
-
from: Date;
|
|
31
|
-
}): number;
|
|
32
|
-
static getNextRunAfter(data: {
|
|
33
|
-
monitoringInterval: string | null | undefined;
|
|
34
|
-
after: Date;
|
|
35
|
-
}): MonitorScheduledRun | null;
|
|
36
|
-
private static getNextTwoRuns;
|
|
37
|
-
private static isScheduleWithoutRuns;
|
|
38
|
-
static getResultLateness(data: {
|
|
39
|
-
lastResultAt: Date;
|
|
40
|
-
monitoringInterval?: string | null | undefined;
|
|
41
|
-
cadenceSeconds: number;
|
|
42
|
-
now: Date;
|
|
43
|
-
}): MonitorResultLateness;
|
|
44
|
-
static describeInterval(monitoringInterval: string | null | undefined): string;
|
|
45
|
-
static getGraceSeconds(cadenceSeconds: number): number;
|
|
46
|
-
static getCheckFreshness(data: {
|
|
47
|
-
isScheduled: boolean;
|
|
48
|
-
isKnown: boolean;
|
|
49
|
-
lastResultAt: Date | undefined;
|
|
50
|
-
nextCheckAt: Date | undefined;
|
|
51
|
-
cadenceSeconds: number;
|
|
52
|
-
createdAt: Date | undefined;
|
|
53
|
-
now: Date;
|
|
54
|
-
monitoringInterval?: string | null | undefined;
|
|
55
|
-
}): MonitorCheckFreshnessResult;
|
|
56
|
-
static getLatestSignalAt(data: {
|
|
57
|
-
monitor: Monitor;
|
|
58
|
-
probeLastResultAt: Date | undefined;
|
|
59
|
-
}): Date | undefined;
|
|
60
|
-
static parseDate(value: unknown): Date | undefined;
|
|
61
|
-
}
|
|
@@ -1,476 +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
|
-
exports.MonitorCheckFreshness = void 0;
|
|
7
|
-
const Date_1 = __importDefault(require("../../Types/Date"));
|
|
8
|
-
const CronTab_1 = __importDefault(require("../CronTab"));
|
|
9
|
-
const MonitoringIntervalUtil_1 = __importDefault(require("./MonitoringIntervalUtil"));
|
|
10
|
-
/*
|
|
11
|
-
* "Is this monitor being checked on time?" for the monitor overview.
|
|
12
|
-
*
|
|
13
|
-
* The cadence comes from the same reading of Monitor.monitoringInterval the
|
|
14
|
-
* scheduler uses (MonitoringIntervalUtil), so a monitor storing a legacy
|
|
15
|
-
* "5m" is judged against five minutes, as it is actually probed. An
|
|
16
|
-
* unreadable value, or a schedule that never runs, falls back to one
|
|
17
|
-
* minute, as the scheduler does.
|
|
18
|
-
*/
|
|
19
|
-
var MonitorCheckFreshness;
|
|
20
|
-
(function (MonitorCheckFreshness) {
|
|
21
|
-
// A result arrived within the cadence plus grace.
|
|
22
|
-
MonitorCheckFreshness["Fresh"] = "Fresh";
|
|
23
|
-
// Nothing arrived for longer than the cadence plus grace.
|
|
24
|
-
MonitorCheckFreshness["Stale"] = "Stale";
|
|
25
|
-
// Never reported, and still young enough that this is expected.
|
|
26
|
-
MonitorCheckFreshness["AwaitingFirstResult"] = "AwaitingFirstResult";
|
|
27
|
-
// Not on a schedule right now (paused, no probe, or push-based).
|
|
28
|
-
MonitorCheckFreshness["NotScheduled"] = "NotScheduled";
|
|
29
|
-
// The results could not be read, so nothing can be said.
|
|
30
|
-
MonitorCheckFreshness["Unknown"] = "Unknown";
|
|
31
|
-
})(MonitorCheckFreshness || (exports.MonitorCheckFreshness = MonitorCheckFreshness = {}));
|
|
32
|
-
const secondsBetween = (later, earlier) => {
|
|
33
|
-
return (later.getTime() - earlier.getTime()) / 1000;
|
|
34
|
-
};
|
|
35
|
-
const toWholeSeconds = (seconds) => {
|
|
36
|
-
return Math.max(0, Math.floor(seconds));
|
|
37
|
-
};
|
|
38
|
-
const CRON_FIELD_SEPARATOR = /\s+/;
|
|
39
|
-
const DIGITS_ONLY = /^\d+$/;
|
|
40
|
-
// Month names as CronTab reads them: the first three letters.
|
|
41
|
-
const MONTH_NAMES = [
|
|
42
|
-
"jan",
|
|
43
|
-
"feb",
|
|
44
|
-
"mar",
|
|
45
|
-
"apr",
|
|
46
|
-
"may",
|
|
47
|
-
"jun",
|
|
48
|
-
"jul",
|
|
49
|
-
"aug",
|
|
50
|
-
"sep",
|
|
51
|
-
"oct",
|
|
52
|
-
"nov",
|
|
53
|
-
"dec",
|
|
54
|
-
];
|
|
55
|
-
// The most days each month ever has: February has 29 in a leap year.
|
|
56
|
-
const LONGEST_MONTH_DAYS = [
|
|
57
|
-
31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
|
|
58
|
-
];
|
|
59
|
-
/*
|
|
60
|
-
* Schedules that never run, remembered once found. CronTab accepts
|
|
61
|
-
* "0 0 30 2 *" (the 30th of February), but it only gives up looking for
|
|
62
|
-
* its next run after a million-step search, well over a second of the
|
|
63
|
-
* page's main thread, and the overview asks once per probe and again for
|
|
64
|
-
* freshness on every render. Only schedules with no run are kept, so this
|
|
65
|
-
* stays tiny; the cap just bounds a tab left open for weeks.
|
|
66
|
-
*/
|
|
67
|
-
const SCHEDULES_WITHOUT_RUNS = new Set();
|
|
68
|
-
const MAX_SCHEDULES_WITHOUT_RUNS = 64;
|
|
69
|
-
const rememberScheduleWithoutRuns = (cron) => {
|
|
70
|
-
if (SCHEDULES_WITHOUT_RUNS.size >= MAX_SCHEDULES_WITHOUT_RUNS) {
|
|
71
|
-
SCHEDULES_WITHOUT_RUNS.clear();
|
|
72
|
-
}
|
|
73
|
-
SCHEDULES_WITHOUT_RUNS.add(cron);
|
|
74
|
-
};
|
|
75
|
-
/*
|
|
76
|
-
* The values a cron field allows, read the way CronTab reads them: "*",
|
|
77
|
-
* "a" and "a-b", each with an optional "/step", in a comma list, and
|
|
78
|
-
* month names. Null for anything else, which is then left to CronTab.
|
|
79
|
-
*/
|
|
80
|
-
const expandCronField = (data) => {
|
|
81
|
-
const readValue = (raw) => {
|
|
82
|
-
const token = raw.trim().toLowerCase();
|
|
83
|
-
let value = Number.NaN;
|
|
84
|
-
if (DIGITS_ONLY.test(token)) {
|
|
85
|
-
value = parseInt(token, 10);
|
|
86
|
-
}
|
|
87
|
-
else if (data.names) {
|
|
88
|
-
const index = data.names.indexOf(token.slice(0, 3));
|
|
89
|
-
if (index !== -1) {
|
|
90
|
-
value = index + data.min;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return value >= data.min && value <= data.max ? value : null;
|
|
94
|
-
};
|
|
95
|
-
const values = [];
|
|
96
|
-
for (const rawTerm of data.field.split(",")) {
|
|
97
|
-
const [rangePart, stepPart, ...extra] = rawTerm
|
|
98
|
-
.trim()
|
|
99
|
-
.split("/");
|
|
100
|
-
if (!rangePart || extra.length > 0) {
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
let step = 1;
|
|
104
|
-
if (stepPart !== undefined) {
|
|
105
|
-
step = DIGITS_ONLY.test(stepPart) ? parseInt(stepPart, 10) : 0;
|
|
106
|
-
if (step <= 0) {
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
let start = null;
|
|
111
|
-
let end = null;
|
|
112
|
-
if (rangePart === "*") {
|
|
113
|
-
start = data.min;
|
|
114
|
-
end = data.max;
|
|
115
|
-
}
|
|
116
|
-
else if (rangePart.includes("-")) {
|
|
117
|
-
const [startText, endText, ...rangeExtra] = rangePart.split("-");
|
|
118
|
-
if (startText === undefined ||
|
|
119
|
-
endText === undefined ||
|
|
120
|
-
rangeExtra.length > 0) {
|
|
121
|
-
return null;
|
|
122
|
-
}
|
|
123
|
-
start = readValue(startText);
|
|
124
|
-
end = readValue(endText);
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
// "a/step" runs from a to the end of the range, as in CronTab.
|
|
128
|
-
start = readValue(rangePart);
|
|
129
|
-
end = stepPart === undefined ? start : data.max;
|
|
130
|
-
}
|
|
131
|
-
if (start === null || end === null || start > end) {
|
|
132
|
-
return null;
|
|
133
|
-
}
|
|
134
|
-
for (let value = start; value <= end; value += step) {
|
|
135
|
-
values.push(value);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return values.length > 0 ? values : null;
|
|
139
|
-
};
|
|
140
|
-
class MonitorCheckScheduleUtil {
|
|
141
|
-
/*
|
|
142
|
-
* Seconds between two consecutive runs after `from`, or null when the
|
|
143
|
-
* interval is empty or unreadable, or never runs. Measured from the
|
|
144
|
-
* schedule rather than parsed from the text, so a custom cron gets its
|
|
145
|
-
* real spacing.
|
|
146
|
-
*/
|
|
147
|
-
static getCadenceSeconds(data) {
|
|
148
|
-
try {
|
|
149
|
-
const runs = MonitorCheckScheduleUtil.getNextTwoRuns({
|
|
150
|
-
monitoringInterval: data.monitoringInterval,
|
|
151
|
-
after: data.from,
|
|
152
|
-
});
|
|
153
|
-
if (!runs) {
|
|
154
|
-
return null;
|
|
155
|
-
}
|
|
156
|
-
const cadence = secondsBetween(runs[1], runs[0]);
|
|
157
|
-
return cadence > 0 ? cadence : null;
|
|
158
|
-
}
|
|
159
|
-
catch (_a) {
|
|
160
|
-
return null;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
static resolveCadenceSeconds(data) {
|
|
164
|
-
var _a;
|
|
165
|
-
return ((_a = MonitorCheckScheduleUtil.getCadenceSeconds(data)) !== null && _a !== void 0 ? _a : MonitorCheckScheduleUtil.DEFAULT_CADENCE_SECONDS);
|
|
166
|
-
}
|
|
167
|
-
/*
|
|
168
|
-
* The first run the schedule has after `after`, and the spacing of the
|
|
169
|
-
* schedule at that point. Null when the interval is empty or unreadable,
|
|
170
|
-
* or never runs.
|
|
171
|
-
*/
|
|
172
|
-
static getNextRunAfter(data) {
|
|
173
|
-
try {
|
|
174
|
-
const runs = MonitorCheckScheduleUtil.getNextTwoRuns(data);
|
|
175
|
-
if (!runs) {
|
|
176
|
-
return null;
|
|
177
|
-
}
|
|
178
|
-
const spacingSeconds = secondsBetween(runs[1], runs[0]);
|
|
179
|
-
return spacingSeconds > 0
|
|
180
|
-
? { runAt: runs[0], spacingSeconds: spacingSeconds }
|
|
181
|
-
: null;
|
|
182
|
-
}
|
|
183
|
-
catch (_a) {
|
|
184
|
-
return null;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
/*
|
|
188
|
-
* The schedule's first two runs after `after`, or null when the interval
|
|
189
|
-
* is empty or unreadable, or never runs. The scheduler checks a schedule
|
|
190
|
-
* that never runs every minute, as it does an unreadable one, so callers
|
|
191
|
-
* take the same uniform-cadence path for both.
|
|
192
|
-
*/
|
|
193
|
-
static getNextTwoRuns(data) {
|
|
194
|
-
const cron = MonitoringIntervalUtil_1.default.toCronOrNull(data.monitoringInterval);
|
|
195
|
-
/*
|
|
196
|
-
* An Invalid Date would send CronTab's month search round forever, as
|
|
197
|
-
* no month ever equals NaN.
|
|
198
|
-
*/
|
|
199
|
-
if (!cron || !Number.isFinite(data.after.getTime())) {
|
|
200
|
-
return null;
|
|
201
|
-
}
|
|
202
|
-
if (MonitorCheckScheduleUtil.isScheduleWithoutRuns(cron)) {
|
|
203
|
-
return null;
|
|
204
|
-
}
|
|
205
|
-
const runs = CronTab_1.default.getNextExecutionTimes(cron, 2, data.after);
|
|
206
|
-
if (!runs[0] || !runs[1]) {
|
|
207
|
-
// A schedule that runs at all always has two more runs in reach.
|
|
208
|
-
rememberScheduleWithoutRuns(cron);
|
|
209
|
-
return null;
|
|
210
|
-
}
|
|
211
|
-
return runs;
|
|
212
|
-
}
|
|
213
|
-
/*
|
|
214
|
-
* True for a schedule known never to run, and for one whose day fields
|
|
215
|
-
* show it without CronTab's search: a day of the month that no allowed
|
|
216
|
-
* month has ("0 0 30 2 *", "0 0 31 4 *"). A restricted day of the week
|
|
217
|
-
* matches some day in every month, and CronTab ORs it with the day of the
|
|
218
|
-
* month, so only a bare "*" there leaves the day of the month to decide.
|
|
219
|
-
*/
|
|
220
|
-
static isScheduleWithoutRuns(cron) {
|
|
221
|
-
var _a;
|
|
222
|
-
if (SCHEDULES_WITHOUT_RUNS.has(cron)) {
|
|
223
|
-
return true;
|
|
224
|
-
}
|
|
225
|
-
const fields = cron.trim().split(CRON_FIELD_SEPARATOR);
|
|
226
|
-
if (fields.length !== 5 && fields.length !== 6) {
|
|
227
|
-
return false;
|
|
228
|
-
}
|
|
229
|
-
// A sixth field is a leading seconds field.
|
|
230
|
-
const offset = fields.length - 5;
|
|
231
|
-
const dayOfMonthField = fields[2 + offset];
|
|
232
|
-
const monthField = fields[3 + offset];
|
|
233
|
-
const dayOfWeekField = fields[4 + offset];
|
|
234
|
-
if (dayOfMonthField === "*") {
|
|
235
|
-
return false;
|
|
236
|
-
}
|
|
237
|
-
const days = expandCronField({
|
|
238
|
-
field: dayOfMonthField,
|
|
239
|
-
min: 1,
|
|
240
|
-
max: 31,
|
|
241
|
-
});
|
|
242
|
-
const months = expandCronField({
|
|
243
|
-
field: monthField,
|
|
244
|
-
min: 1,
|
|
245
|
-
max: 12,
|
|
246
|
-
names: MONTH_NAMES,
|
|
247
|
-
});
|
|
248
|
-
if (!days || !months || days.length === 0 || months.length === 0) {
|
|
249
|
-
return false;
|
|
250
|
-
}
|
|
251
|
-
const firstDay = Math.min(...days);
|
|
252
|
-
const distinctMonths = Array.from(new Set(months));
|
|
253
|
-
/*
|
|
254
|
-
* The scheduler parses with cron-parser, which refuses a single month
|
|
255
|
-
* that has no such day whatever the day of the week says ("0 0 30 2 1"
|
|
256
|
-
* throws "Invalid explicit day of month definition"), and then runs the
|
|
257
|
-
* monitor every minute. Over several months it ORs the day of the week
|
|
258
|
-
* in, as CronTab does, so there only a bare "*" leaves the day of the
|
|
259
|
-
* month to decide.
|
|
260
|
-
*/
|
|
261
|
-
const isSingleMonthWithoutDay = distinctMonths.length === 1 &&
|
|
262
|
-
firstDay > ((_a = LONGEST_MONTH_DAYS[distinctMonths[0] - 1]) !== null && _a !== void 0 ? _a : 31);
|
|
263
|
-
const isEveryMonthWithoutDay = dayOfWeekField === "*" &&
|
|
264
|
-
distinctMonths.every((month) => {
|
|
265
|
-
var _a;
|
|
266
|
-
return firstDay > ((_a = LONGEST_MONTH_DAYS[month - 1]) !== null && _a !== void 0 ? _a : 31);
|
|
267
|
-
});
|
|
268
|
-
const hasNoDay = isSingleMonthWithoutDay || isEveryMonthWithoutDay;
|
|
269
|
-
if (hasNoDay) {
|
|
270
|
-
rememberScheduleWithoutRuns(cron);
|
|
271
|
-
}
|
|
272
|
-
return hasNoDay;
|
|
273
|
-
}
|
|
274
|
-
/*
|
|
275
|
-
* How late the result after `lastResultAt` is. Judged against the run the
|
|
276
|
-
* schedule wanted after that result, not against the spacing around now:
|
|
277
|
-
* a schedule with gaps ("every 5 minutes, 9 to 5 on weekdays") would
|
|
278
|
-
* otherwise read as overdue through every night and weekend, because at
|
|
279
|
-
* 20:00 its runs are still five minutes apart. Without a readable
|
|
280
|
-
* interval the result is due one cadence after it arrived, as before.
|
|
281
|
-
*/
|
|
282
|
-
static getResultLateness(data) {
|
|
283
|
-
const nextRun = MonitorCheckScheduleUtil.getNextRunAfter({
|
|
284
|
-
monitoringInterval: data.monitoringInterval,
|
|
285
|
-
after: data.lastResultAt,
|
|
286
|
-
});
|
|
287
|
-
if (nextRun) {
|
|
288
|
-
return {
|
|
289
|
-
lateSeconds: secondsBetween(data.now, nextRun.runAt),
|
|
290
|
-
graceSeconds: MonitorCheckScheduleUtil.getGraceSeconds(nextRun.spacingSeconds),
|
|
291
|
-
};
|
|
292
|
-
}
|
|
293
|
-
const cadenceSeconds = Number.isFinite(data.cadenceSeconds)
|
|
294
|
-
? Math.max(0, data.cadenceSeconds)
|
|
295
|
-
: MonitorCheckScheduleUtil.DEFAULT_CADENCE_SECONDS;
|
|
296
|
-
// A timestamp from the future (clock skew) counts as just now.
|
|
297
|
-
const ageSeconds = Math.max(0, secondsBetween(data.now, data.lastResultAt));
|
|
298
|
-
return {
|
|
299
|
-
lateSeconds: ageSeconds - cadenceSeconds,
|
|
300
|
-
graceSeconds: MonitorCheckScheduleUtil.getGraceSeconds(cadenceSeconds),
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
/*
|
|
304
|
-
* "Every 5 minutes". An empty or unreadable interval, or one that never
|
|
305
|
-
* runs, is described as the schedule it actually gets: every minute.
|
|
306
|
-
*/
|
|
307
|
-
static describeInterval(monitoringInterval) {
|
|
308
|
-
const cron = MonitoringIntervalUtil_1.default.toCronOrNull(monitoringInterval);
|
|
309
|
-
if (!cron || MonitorCheckScheduleUtil.isScheduleWithoutRuns(cron)) {
|
|
310
|
-
return "Every minute";
|
|
311
|
-
}
|
|
312
|
-
return CronTab_1.default.getHumanReadableDescription(cron) || "Every minute";
|
|
313
|
-
}
|
|
314
|
-
/*
|
|
315
|
-
* How late a result may be before the overview calls it overdue. Probes
|
|
316
|
-
* claim work in batches and a busy probe runs behind, so a check is not
|
|
317
|
-
* late the second its cadence elapses: allow two cadences, and never less
|
|
318
|
-
* than five minutes.
|
|
319
|
-
*/
|
|
320
|
-
static getGraceSeconds(cadenceSeconds) {
|
|
321
|
-
if (!Number.isFinite(cadenceSeconds) || cadenceSeconds < 0) {
|
|
322
|
-
return 300;
|
|
323
|
-
}
|
|
324
|
-
return Math.max(300, 2 * cadenceSeconds);
|
|
325
|
-
}
|
|
326
|
-
/*
|
|
327
|
-
* `now` must be on the server's clock: every time compared with it
|
|
328
|
-
* (results, claims, creation) was stamped by the server, so a browser
|
|
329
|
-
* clock that runs fast would otherwise read as every check being late.
|
|
330
|
-
* With `monitoringInterval`, a result is due at the schedule's first run
|
|
331
|
-
* after it (see getResultLateness); without it, one cadence after it.
|
|
332
|
-
*/
|
|
333
|
-
static getCheckFreshness(data) {
|
|
334
|
-
const resultAgeSeconds = data.lastResultAt
|
|
335
|
-
? toWholeSeconds(secondsBetween(data.now, data.lastResultAt))
|
|
336
|
-
: null;
|
|
337
|
-
if (!data.isScheduled) {
|
|
338
|
-
return {
|
|
339
|
-
freshness: MonitorCheckFreshness.NotScheduled,
|
|
340
|
-
overdueSeconds: null,
|
|
341
|
-
resultAgeSeconds: resultAgeSeconds,
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
if (!data.isKnown) {
|
|
345
|
-
return {
|
|
346
|
-
freshness: MonitorCheckFreshness.Unknown,
|
|
347
|
-
overdueSeconds: null,
|
|
348
|
-
resultAgeSeconds: resultAgeSeconds,
|
|
349
|
-
};
|
|
350
|
-
}
|
|
351
|
-
const cadenceSeconds = Number.isFinite(data.cadenceSeconds)
|
|
352
|
-
? Math.max(0, data.cadenceSeconds)
|
|
353
|
-
: MonitorCheckScheduleUtil.DEFAULT_CADENCE_SECONDS;
|
|
354
|
-
const graceSeconds = MonitorCheckScheduleUtil.getGraceSeconds(cadenceSeconds);
|
|
355
|
-
if (!data.lastResultAt) {
|
|
356
|
-
/*
|
|
357
|
-
* A monitor that has never reported is only "waiting" while it is
|
|
358
|
-
* young. Once its first scheduled run after creation is further back
|
|
359
|
-
* than the grace, the first result is overdue like any other.
|
|
360
|
-
*/
|
|
361
|
-
if (data.createdAt) {
|
|
362
|
-
const lateness = MonitorCheckScheduleUtil.getResultLateness({
|
|
363
|
-
lastResultAt: data.createdAt,
|
|
364
|
-
monitoringInterval: data.monitoringInterval,
|
|
365
|
-
cadenceSeconds: cadenceSeconds,
|
|
366
|
-
now: data.now,
|
|
367
|
-
});
|
|
368
|
-
if (lateness.lateSeconds > lateness.graceSeconds) {
|
|
369
|
-
return {
|
|
370
|
-
freshness: MonitorCheckFreshness.Stale,
|
|
371
|
-
overdueSeconds: toWholeSeconds(lateness.lateSeconds),
|
|
372
|
-
resultAgeSeconds: null,
|
|
373
|
-
};
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
return {
|
|
377
|
-
freshness: MonitorCheckFreshness.AwaitingFirstResult,
|
|
378
|
-
overdueSeconds: null,
|
|
379
|
-
resultAgeSeconds: null,
|
|
380
|
-
};
|
|
381
|
-
}
|
|
382
|
-
// A timestamp from the future (clock skew) counts as just now.
|
|
383
|
-
const ageSeconds = Math.max(0, secondsBetween(data.now, data.lastResultAt));
|
|
384
|
-
const lateness = MonitorCheckScheduleUtil.getResultLateness({
|
|
385
|
-
lastResultAt: data.lastResultAt,
|
|
386
|
-
monitoringInterval: data.monitoringInterval,
|
|
387
|
-
cadenceSeconds: cadenceSeconds,
|
|
388
|
-
now: data.now,
|
|
389
|
-
});
|
|
390
|
-
if (lateness.lateSeconds > lateness.graceSeconds) {
|
|
391
|
-
return {
|
|
392
|
-
freshness: MonitorCheckFreshness.Stale,
|
|
393
|
-
overdueSeconds: toWholeSeconds(lateness.lateSeconds),
|
|
394
|
-
resultAgeSeconds: toWholeSeconds(ageSeconds),
|
|
395
|
-
};
|
|
396
|
-
}
|
|
397
|
-
/*
|
|
398
|
-
* The scheduler's own promise: if the next run was due longer ago than
|
|
399
|
-
* the grace, the check is late even when the last result is recent (a
|
|
400
|
-
* long cadence with a stuck probe).
|
|
401
|
-
*/
|
|
402
|
-
if (data.nextCheckAt) {
|
|
403
|
-
const pastDueSeconds = secondsBetween(data.now, data.nextCheckAt);
|
|
404
|
-
if (pastDueSeconds > graceSeconds) {
|
|
405
|
-
return {
|
|
406
|
-
freshness: MonitorCheckFreshness.Stale,
|
|
407
|
-
overdueSeconds: toWholeSeconds(pastDueSeconds),
|
|
408
|
-
resultAgeSeconds: toWholeSeconds(ageSeconds),
|
|
409
|
-
};
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
return {
|
|
413
|
-
freshness: MonitorCheckFreshness.Fresh,
|
|
414
|
-
overdueSeconds: null,
|
|
415
|
-
resultAgeSeconds: toWholeSeconds(ageSeconds),
|
|
416
|
-
};
|
|
417
|
-
}
|
|
418
|
-
/*
|
|
419
|
-
* The newest sign of life from any family: a probe result, a heartbeat, an
|
|
420
|
-
* email, an agent report or a telemetry evaluation. The overview reloads
|
|
421
|
-
* the evaluation log only when this moves.
|
|
422
|
-
*/
|
|
423
|
-
static getLatestSignalAt(data) {
|
|
424
|
-
var _a;
|
|
425
|
-
const candidates = [
|
|
426
|
-
MonitorCheckScheduleUtil.parseDate(data.probeLastResultAt),
|
|
427
|
-
MonitorCheckScheduleUtil.parseDate((_a = data.monitor.incomingMonitorRequest) === null || _a === void 0 ? void 0 : _a.incomingRequestReceivedAt),
|
|
428
|
-
MonitorCheckScheduleUtil.parseDate(data.monitor.incomingEmailMonitorLastEmailReceivedAt),
|
|
429
|
-
MonitorCheckScheduleUtil.parseDate(data.monitor.serverMonitorRequestReceivedAt),
|
|
430
|
-
MonitorCheckScheduleUtil.parseDate(data.monitor.telemetryMonitorLastMonitorAt),
|
|
431
|
-
];
|
|
432
|
-
let latest = undefined;
|
|
433
|
-
for (const candidate of candidates) {
|
|
434
|
-
if (candidate && (!latest || candidate.getTime() > latest.getTime())) {
|
|
435
|
-
latest = candidate;
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
return latest;
|
|
439
|
-
}
|
|
440
|
-
/*
|
|
441
|
-
* A timestamp as it may arrive in a JSON column or a probe response: a
|
|
442
|
-
* Date, an ISO string, or a typed { _type: "DateTime", value } envelope.
|
|
443
|
-
* Anything unreadable is undefined rather than an Invalid Date, which
|
|
444
|
-
* would poison every comparison it touched.
|
|
445
|
-
*/
|
|
446
|
-
static parseDate(value) {
|
|
447
|
-
if (value === null || value === undefined || value === "") {
|
|
448
|
-
return undefined;
|
|
449
|
-
}
|
|
450
|
-
try {
|
|
451
|
-
let parsed = undefined;
|
|
452
|
-
if (value instanceof Date) {
|
|
453
|
-
parsed = value;
|
|
454
|
-
}
|
|
455
|
-
else if (typeof value === "string" || typeof value === "object") {
|
|
456
|
-
parsed = Date_1.default.fromString(value);
|
|
457
|
-
}
|
|
458
|
-
else if (typeof value === "number") {
|
|
459
|
-
parsed = new Date(value);
|
|
460
|
-
}
|
|
461
|
-
if (!parsed || Number.isNaN(parsed.getTime())) {
|
|
462
|
-
return undefined;
|
|
463
|
-
}
|
|
464
|
-
return parsed;
|
|
465
|
-
}
|
|
466
|
-
catch (_a) {
|
|
467
|
-
return undefined;
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
/*
|
|
472
|
-
* The scheduler's fallback when an interval cannot be read (see
|
|
473
|
-
* MonitorProbeService.resolveNextPingAt and the telemetry worker).
|
|
474
|
-
*/
|
|
475
|
-
MonitorCheckScheduleUtil.DEFAULT_CADENCE_SECONDS = 60;
|
|
476
|
-
exports.default = MonitorCheckScheduleUtil;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import MonitorMetricType from "../../Types/Monitor/MonitorMetricType.mjs";
|
|
2
|
-
import MonitorType from "../../Types/Monitor/MonitorType.mjs";
|
|
3
|
-
export declare enum MonitorOverviewFamily {
|
|
4
|
-
ProbeCheck = "ProbeCheck",
|
|
5
|
-
Heartbeat = "Heartbeat",
|
|
6
|
-
Agent = "Agent",
|
|
7
|
-
TelemetrySignal = "TelemetrySignal",
|
|
8
|
-
Infrastructure = "Infrastructure",
|
|
9
|
-
NetworkDevice = "NetworkDevice",
|
|
10
|
-
ProbeStatus = "ProbeStatus",
|
|
11
|
-
Manual = "Manual"
|
|
12
|
-
}
|
|
13
|
-
export declare enum MonitorOverviewSetupKind {
|
|
14
|
-
HeartbeatUrl = "HeartbeatUrl",
|
|
15
|
-
InboundEmail = "InboundEmail",
|
|
16
|
-
ServerAgent = "ServerAgent"
|
|
17
|
-
}
|
|
18
|
-
export type MonitorOverviewSideCard = "probes" | "connection" | "manual";
|
|
19
|
-
export type MonitorOverviewTelemetryPreview = "Logs" | "Metrics" | "Traces" | "SecurityEvents";
|
|
20
|
-
export type MonitorOverviewEvaluationPolicy = "PerProbe" | "Latest" | "None";
|
|
21
|
-
export interface MonitorOverviewLayout {
|
|
22
|
-
family: MonitorOverviewFamily;
|
|
23
|
-
responseTimeMetric: MonitorMetricType | null;
|
|
24
|
-
telemetryPreview: MonitorOverviewTelemetryPreview | null;
|
|
25
|
-
evaluationPolicy: MonitorOverviewEvaluationPolicy;
|
|
26
|
-
setupKind: MonitorOverviewSetupKind | null;
|
|
27
|
-
sideCard: MonitorOverviewSideCard | null;
|
|
28
|
-
summaryDescription: string | null;
|
|
29
|
-
}
|
|
30
|
-
export default class MonitorOverviewFamilyUtil {
|
|
31
|
-
static getFamily(monitorType: MonitorType): MonitorOverviewFamily;
|
|
32
|
-
static getLayout(monitorType: MonitorType): MonitorOverviewLayout;
|
|
33
|
-
private static getResponseTimeMetric;
|
|
34
|
-
private static getTelemetryPreview;
|
|
35
|
-
private static getEvaluationPolicy;
|
|
36
|
-
private static getSetupKind;
|
|
37
|
-
private static getSideCard;
|
|
38
|
-
private static getSummaryDescription;
|
|
39
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import MonitorMetricType from "../../Types/Monitor/MonitorMetricType";
|
|
2
|
-
import MonitorType from "../../Types/Monitor/MonitorType";
|
|
3
|
-
export declare enum MonitorOverviewFamily {
|
|
4
|
-
ProbeCheck = "ProbeCheck",
|
|
5
|
-
Heartbeat = "Heartbeat",
|
|
6
|
-
Agent = "Agent",
|
|
7
|
-
TelemetrySignal = "TelemetrySignal",
|
|
8
|
-
Infrastructure = "Infrastructure",
|
|
9
|
-
NetworkDevice = "NetworkDevice",
|
|
10
|
-
ProbeStatus = "ProbeStatus",
|
|
11
|
-
Manual = "Manual"
|
|
12
|
-
}
|
|
13
|
-
export declare enum MonitorOverviewSetupKind {
|
|
14
|
-
HeartbeatUrl = "HeartbeatUrl",
|
|
15
|
-
InboundEmail = "InboundEmail",
|
|
16
|
-
ServerAgent = "ServerAgent"
|
|
17
|
-
}
|
|
18
|
-
export type MonitorOverviewSideCard = "probes" | "connection" | "manual";
|
|
19
|
-
export type MonitorOverviewTelemetryPreview = "Logs" | "Metrics" | "Traces" | "SecurityEvents";
|
|
20
|
-
export type MonitorOverviewEvaluationPolicy = "PerProbe" | "Latest" | "None";
|
|
21
|
-
export interface MonitorOverviewLayout {
|
|
22
|
-
family: MonitorOverviewFamily;
|
|
23
|
-
responseTimeMetric: MonitorMetricType | null;
|
|
24
|
-
telemetryPreview: MonitorOverviewTelemetryPreview | null;
|
|
25
|
-
evaluationPolicy: MonitorOverviewEvaluationPolicy;
|
|
26
|
-
setupKind: MonitorOverviewSetupKind | null;
|
|
27
|
-
sideCard: MonitorOverviewSideCard | null;
|
|
28
|
-
summaryDescription: string | null;
|
|
29
|
-
}
|
|
30
|
-
export default class MonitorOverviewFamilyUtil {
|
|
31
|
-
static getFamily(monitorType: MonitorType): MonitorOverviewFamily;
|
|
32
|
-
static getLayout(monitorType: MonitorType): MonitorOverviewLayout;
|
|
33
|
-
private static getResponseTimeMetric;
|
|
34
|
-
private static getTelemetryPreview;
|
|
35
|
-
private static getEvaluationPolicy;
|
|
36
|
-
private static getSetupKind;
|
|
37
|
-
private static getSideCard;
|
|
38
|
-
private static getSummaryDescription;
|
|
39
|
-
}
|