@oneuptime/common 14.0.95 → 14.0.96

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 (45) hide show
  1. package/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel.js +14 -37
  2. package/Models/DatabaseModels/DetectionRuleException.d.mts +25 -0
  3. package/Models/DatabaseModels/DetectionRuleException.d.ts +25 -0
  4. package/Models/DatabaseModels/DetectionRuleException.js +412 -0
  5. package/Models/DatabaseModels/DetectionRuleException.mjs +2 -0
  6. package/Models/DatabaseModels/Index.js +2 -0
  7. package/Types/Database/TableColumn.d.mts +8 -0
  8. package/Types/Database/TableColumn.d.ts +8 -0
  9. package/Types/Database/TableColumn.js +69 -23
  10. package/Types/Database/TableColumn.mjs +1 -0
  11. package/Types/JSONFunctions.js +16 -1
  12. package/Types/Monitor/MonitorType.js +5 -4
  13. package/Types/Monitor/TelemetryAlertRule.d.mts +111 -0
  14. package/Types/Monitor/TelemetryAlertRule.d.ts +111 -0
  15. package/Types/Monitor/TelemetryAlertRule.js +886 -0
  16. package/Types/Monitor/TelemetryAlertRule.mjs +5 -0
  17. package/Types/Monitor/TelemetryRulePreview.d.mts +57 -0
  18. package/Types/Monitor/TelemetryRulePreview.d.ts +57 -0
  19. package/Types/Monitor/TelemetryRulePreview.js +190 -0
  20. package/Types/Monitor/TelemetryRulePreview.mjs +6 -0
  21. package/Types/OnCallDutyPolicy/EveryNewEventRules.d.mts +23 -0
  22. package/Types/OnCallDutyPolicy/EveryNewEventRules.d.ts +23 -0
  23. package/Types/OnCallDutyPolicy/EveryNewEventRules.js +105 -0
  24. package/Types/OnCallDutyPolicy/EveryNewEventRules.mjs +9 -0
  25. package/Types/ProviderLogo/ProviderLogo.d.mts +17 -1
  26. package/Types/ProviderLogo/ProviderLogo.d.ts +17 -1
  27. package/Types/ProviderLogo/ProviderLogo.js +33 -0
  28. package/Types/SecurityEvent/DetectionRetrohunt.d.mts +38 -0
  29. package/Types/SecurityEvent/DetectionRetrohunt.d.ts +38 -0
  30. package/Types/SecurityEvent/DetectionRetrohunt.js +147 -0
  31. package/Types/SecurityEvent/DetectionRetrohunt.mjs +10 -0
  32. package/Types/SecurityEvent/DetectionRuleException.d.mts +65 -0
  33. package/Types/SecurityEvent/DetectionRuleException.d.ts +65 -0
  34. package/Types/SecurityEvent/DetectionRuleException.js +441 -0
  35. package/Types/SecurityEvent/DetectionRuleException.mjs +24 -0
  36. package/Types/Telemetry/OpenTelemetryGuides.d.mts +52 -0
  37. package/Types/Telemetry/OpenTelemetryGuides.d.ts +52 -0
  38. package/Types/Telemetry/OpenTelemetryGuides.js +419 -0
  39. package/Types/Telemetry/OpenTelemetryGuides.mjs +17 -0
  40. package/Utils/Schema/OpenApiMetadataRegistry.d.mts +4 -0
  41. package/Utils/Schema/OpenApiMetadataRegistry.d.ts +4 -0
  42. package/Utils/Schema/OpenApiMetadataRegistry.js +20 -0
  43. package/Utils/Schema/OpenApiMetadataRegistry.mjs +2 -0
  44. package/Utils/Schema/Zod.js +6 -0
  45. package/package.json +1 -1
@@ -0,0 +1,5 @@
1
+ import commonJsModule from "./TelemetryAlertRule.js";
2
+ export default commonJsModule.default;
3
+ export const TelemetryAlertRuleAction = commonJsModule.TelemetryAlertRuleAction;
4
+ export const TelemetryAlertRuleRecovery = commonJsModule.TelemetryAlertRuleRecovery;
5
+ export const TelemetryAlertRuleShapeProblem = commonJsModule.TelemetryAlertRuleShapeProblem;
@@ -0,0 +1,57 @@
1
+ import { FilterType } from "./CriteriaFilter.mjs";
2
+ export declare const PREVIEW_WINDOW_COUNT: number;
3
+ export declare const MAX_PREVIEW_RANGE_IN_SECONDS: number;
4
+ export declare const MIN_PREVIEW_WINDOW_IN_SECONDS: number;
5
+ export declare const MAX_PREVIEW_WINDOW_IN_SECONDS: number;
6
+ export interface TelemetryRulePreviewRange {
7
+ startTime: Date;
8
+ endTime: Date;
9
+ windowInSeconds: number;
10
+ }
11
+ export interface TelemetryRulePreviewBucket {
12
+ time: string;
13
+ value: number;
14
+ }
15
+ export interface TelemetryRulePreviewAnswer {
16
+ buckets: Array<TelemetryRulePreviewBucket>;
17
+ windowInSeconds: number;
18
+ startTime: string;
19
+ endTime: string;
20
+ }
21
+ export interface TelemetryRulePreviewPoint {
22
+ time: Date;
23
+ value: number;
24
+ }
25
+ export interface TelemetryRulePreviewSummary {
26
+ hasData: boolean;
27
+ windowCount: number;
28
+ matchedWindowCount: number;
29
+ timesItWouldHaveFired: number;
30
+ highest: number;
31
+ lowest: number;
32
+ typical: number;
33
+ latest: number | undefined;
34
+ }
35
+ export default class TelemetryRulePreviewUtil {
36
+ static getRange(data: {
37
+ windowInSeconds: number;
38
+ now: Date;
39
+ }): TelemetryRulePreviewRange;
40
+ static clampWindow(windowInSeconds: number): number;
41
+ static toPoints(answer: TelemetryRulePreviewAnswer): Array<TelemetryRulePreviewPoint>;
42
+ static summarize(data: {
43
+ points: Array<TelemetryRulePreviewPoint>;
44
+ filterType: FilterType | undefined;
45
+ threshold: number | undefined;
46
+ }): TelemetryRulePreviewSummary;
47
+ static isMatched(data: {
48
+ filterType: FilterType | undefined;
49
+ threshold: number | undefined;
50
+ value: number;
51
+ }): boolean;
52
+ static suggestThreshold(data: {
53
+ points: Array<TelemetryRulePreviewPoint>;
54
+ filterType: FilterType | undefined;
55
+ }): number | undefined;
56
+ static roundUp(value: number): number;
57
+ }
@@ -0,0 +1,57 @@
1
+ import { FilterType } from "./CriteriaFilter";
2
+ export declare const PREVIEW_WINDOW_COUNT: number;
3
+ export declare const MAX_PREVIEW_RANGE_IN_SECONDS: number;
4
+ export declare const MIN_PREVIEW_WINDOW_IN_SECONDS: number;
5
+ export declare const MAX_PREVIEW_WINDOW_IN_SECONDS: number;
6
+ export interface TelemetryRulePreviewRange {
7
+ startTime: Date;
8
+ endTime: Date;
9
+ windowInSeconds: number;
10
+ }
11
+ export interface TelemetryRulePreviewBucket {
12
+ time: string;
13
+ value: number;
14
+ }
15
+ export interface TelemetryRulePreviewAnswer {
16
+ buckets: Array<TelemetryRulePreviewBucket>;
17
+ windowInSeconds: number;
18
+ startTime: string;
19
+ endTime: string;
20
+ }
21
+ export interface TelemetryRulePreviewPoint {
22
+ time: Date;
23
+ value: number;
24
+ }
25
+ export interface TelemetryRulePreviewSummary {
26
+ hasData: boolean;
27
+ windowCount: number;
28
+ matchedWindowCount: number;
29
+ timesItWouldHaveFired: number;
30
+ highest: number;
31
+ lowest: number;
32
+ typical: number;
33
+ latest: number | undefined;
34
+ }
35
+ export default class TelemetryRulePreviewUtil {
36
+ static getRange(data: {
37
+ windowInSeconds: number;
38
+ now: Date;
39
+ }): TelemetryRulePreviewRange;
40
+ static clampWindow(windowInSeconds: number): number;
41
+ static toPoints(answer: TelemetryRulePreviewAnswer): Array<TelemetryRulePreviewPoint>;
42
+ static summarize(data: {
43
+ points: Array<TelemetryRulePreviewPoint>;
44
+ filterType: FilterType | undefined;
45
+ threshold: number | undefined;
46
+ }): TelemetryRulePreviewSummary;
47
+ static isMatched(data: {
48
+ filterType: FilterType | undefined;
49
+ threshold: number | undefined;
50
+ value: number;
51
+ }): boolean;
52
+ static suggestThreshold(data: {
53
+ points: Array<TelemetryRulePreviewPoint>;
54
+ filterType: FilterType | undefined;
55
+ }): number | undefined;
56
+ static roundUp(value: number): number;
57
+ }
@@ -0,0 +1,190 @@
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.MAX_PREVIEW_WINDOW_IN_SECONDS = exports.MIN_PREVIEW_WINDOW_IN_SECONDS = exports.MAX_PREVIEW_RANGE_IN_SECONDS = exports.PREVIEW_WINDOW_COUNT = void 0;
7
+ const Date_1 = __importDefault(require("../Date"));
8
+ const CriteriaFilter_1 = require("./CriteriaFilter");
9
+ const TelemetryAlertRule_1 = __importDefault(require("./TelemetryAlertRule"));
10
+ /*
11
+ * What a telemetry rule would have caught: the count it compares, one
12
+ * window at a time, over the hours before now.
13
+ *
14
+ * A Logs, Traces or Exceptions monitor counts what matched in the last N
15
+ * seconds, every minute. The rule editor shows that count for every
16
+ * window of the same length back from now, beside the threshold, so the
17
+ * person setting the rule sees what is normal and when it would have fired
18
+ * before they save it. The server counts (one ClickHouse read with the
19
+ * monitor's own query, grouped by window); this module says which windows,
20
+ * and reads the answer.
21
+ *
22
+ * Bounded on purpose: at most PREVIEW_WINDOW_COUNT windows, so a one-minute
23
+ * rule reads 2.4 hours back, a five-minute rule 12 hours and a fifteen-minute
24
+ * rule 36 hours, and nothing reads more than MAX_PREVIEW_RANGE_IN_SECONDS.
25
+ * Windows are whole: they end on a multiple of their length before now, so
26
+ * the newest one is not a half-filled window that reads as a drop.
27
+ */
28
+ exports.PREVIEW_WINDOW_COUNT = 144;
29
+ exports.MAX_PREVIEW_RANGE_IN_SECONDS = 7 * 24 * 60 * 60;
30
+ exports.MIN_PREVIEW_WINDOW_IN_SECONDS = 5;
31
+ exports.MAX_PREVIEW_WINDOW_IN_SECONDS = 24 * 60 * 60;
32
+ class TelemetryRulePreviewUtil {
33
+ /*
34
+ * The windows to read for a rule whose window is `windowInSeconds`, back
35
+ * from `now`. The window is clamped to what the monitor forms offer.
36
+ */
37
+ static getRange(data) {
38
+ const windowInSeconds = TelemetryRulePreviewUtil.clampWindow(data.windowInSeconds);
39
+ const windowInMs = windowInSeconds * 1000;
40
+ const windowCount = Math.max(1, Math.min(exports.PREVIEW_WINDOW_COUNT, Math.floor(exports.MAX_PREVIEW_RANGE_IN_SECONDS / windowInSeconds)));
41
+ const endMs = Math.floor(data.now.getTime() / windowInMs) * windowInMs;
42
+ const startMs = endMs - windowCount * windowInMs;
43
+ return {
44
+ startTime: new Date(startMs),
45
+ endTime: new Date(endMs),
46
+ windowInSeconds,
47
+ };
48
+ }
49
+ static clampWindow(windowInSeconds) {
50
+ if (!Number.isFinite(windowInSeconds) || windowInSeconds <= 0) {
51
+ return 60;
52
+ }
53
+ return Math.min(exports.MAX_PREVIEW_WINDOW_IN_SECONDS, Math.max(exports.MIN_PREVIEW_WINDOW_IN_SECONDS, Math.round(windowInSeconds)));
54
+ }
55
+ /*
56
+ * Every window of the range, in order, with its count: a window the
57
+ * server did not answer for had nothing in it, so it is 0.
58
+ */
59
+ static toPoints(answer) {
60
+ const windowInMs = TelemetryRulePreviewUtil.clampWindow(answer.windowInSeconds) * 1000;
61
+ const startMs = Date_1.default.fromString(answer.startTime).getTime();
62
+ const endMs = Date_1.default.fromString(answer.endTime).getTime();
63
+ const counts = new Map();
64
+ for (const bucket of answer.buckets) {
65
+ const timeMs = Date_1.default.fromString(bucket.time).getTime();
66
+ if (!Number.isFinite(timeMs)) {
67
+ continue;
68
+ }
69
+ const alignedMs = Math.floor(timeMs / windowInMs) * windowInMs;
70
+ counts.set(alignedMs, (counts.get(alignedMs) || 0) + (bucket.value || 0));
71
+ }
72
+ const points = [];
73
+ for (let timeMs = startMs; timeMs < endMs && points.length < exports.PREVIEW_WINDOW_COUNT; timeMs += windowInMs) {
74
+ points.push({ time: new Date(timeMs), value: counts.get(timeMs) || 0 });
75
+ }
76
+ return points;
77
+ }
78
+ /*
79
+ * What the rule makes of those windows. An anomaly rule is judged against
80
+ * a baseline the preview does not read, so it matches none here.
81
+ */
82
+ static summarize(data) {
83
+ const firstWithData = data.points.findIndex((point) => {
84
+ return point.value > 0;
85
+ });
86
+ const values = firstWithData < 0
87
+ ? []
88
+ : data.points
89
+ .slice(firstWithData)
90
+ .map((point) => {
91
+ return point.value;
92
+ });
93
+ let matchedWindowCount = 0;
94
+ let timesItWouldHaveFired = 0;
95
+ let wasMatching = false;
96
+ for (const value of values) {
97
+ const isMatching = TelemetryRulePreviewUtil.isMatched({
98
+ filterType: data.filterType,
99
+ threshold: data.threshold,
100
+ value,
101
+ });
102
+ if (isMatching) {
103
+ matchedWindowCount++;
104
+ if (!wasMatching) {
105
+ timesItWouldHaveFired++;
106
+ }
107
+ }
108
+ wasMatching = isMatching;
109
+ }
110
+ const sorted = [...values].sort((a, b) => {
111
+ return a - b;
112
+ });
113
+ return {
114
+ hasData: values.length > 0,
115
+ windowCount: values.length,
116
+ matchedWindowCount,
117
+ timesItWouldHaveFired,
118
+ highest: sorted.length > 0 ? sorted[sorted.length - 1] : 0,
119
+ lowest: sorted.length > 0 ? sorted[0] : 0,
120
+ typical: sorted.length > 0 ? sorted[Math.floor((sorted.length - 1) / 2)] : 0,
121
+ latest: values.length > 0 ? values[values.length - 1] : undefined,
122
+ };
123
+ }
124
+ static isMatched(data) {
125
+ if (!data.filterType ||
126
+ data.threshold === undefined ||
127
+ TelemetryAlertRule_1.default.isAnomaly(data.filterType)) {
128
+ return false;
129
+ }
130
+ return TelemetryAlertRule_1.default.matches({
131
+ filterType: data.filterType,
132
+ threshold: data.threshold,
133
+ value: data.value,
134
+ });
135
+ }
136
+ /*
137
+ * A threshold that would have stayed quiet over the windows read: above
138
+ * the busiest window for a rule that fires on too many, below the
139
+ * quietest for one that fires on too few. Rounded to a number people
140
+ * write. None for an exact value or an anomaly, and none without data:
141
+ * windows that held nothing say nothing about a number, and offering 1
142
+ * for them read as advice to alert on the first log.
143
+ */
144
+ static suggestThreshold(data) {
145
+ if (data.points.length === 0) {
146
+ return undefined;
147
+ }
148
+ const summary = TelemetryRulePreviewUtil.summarize({
149
+ points: data.points,
150
+ filterType: undefined,
151
+ threshold: undefined,
152
+ });
153
+ if (!summary.hasData) {
154
+ return undefined;
155
+ }
156
+ switch (data.filterType) {
157
+ case CriteriaFilter_1.FilterType.GreaterThan:
158
+ return TelemetryRulePreviewUtil.roundUp(Math.max(summary.highest * 1.2, summary.typical * 3, 1));
159
+ case CriteriaFilter_1.FilterType.GreaterThanOrEqualTo:
160
+ return (TelemetryRulePreviewUtil.roundUp(Math.max(summary.highest * 1.2, summary.typical * 3, 1)) + 1);
161
+ case CriteriaFilter_1.FilterType.LessThan:
162
+ case CriteriaFilter_1.FilterType.LessThanOrEqualTo: {
163
+ if (summary.lowest <= 0) {
164
+ return undefined;
165
+ }
166
+ const below = Math.floor(summary.lowest / 2);
167
+ return data.filterType === CriteriaFilter_1.FilterType.LessThan
168
+ ? Math.max(1, below)
169
+ : Math.max(0, below);
170
+ }
171
+ default:
172
+ return undefined;
173
+ }
174
+ }
175
+ /*
176
+ * Up to a number with two significant digits at most: 27.6 is 28, 1480
177
+ * is 1500, 9.2 is 10.
178
+ */
179
+ static roundUp(value) {
180
+ if (!Number.isFinite(value) || value <= 0) {
181
+ return 0;
182
+ }
183
+ if (value <= 10) {
184
+ return Math.ceil(value);
185
+ }
186
+ const magnitude = Math.pow(10, Math.floor(Math.log10(value)) - 1);
187
+ return Math.ceil(value / magnitude) * magnitude;
188
+ }
189
+ }
190
+ exports.default = TelemetryRulePreviewUtil;
@@ -0,0 +1,6 @@
1
+ import commonJsModule from "./TelemetryRulePreview.js";
2
+ export default commonJsModule.default;
3
+ export const MAX_PREVIEW_RANGE_IN_SECONDS = commonJsModule.MAX_PREVIEW_RANGE_IN_SECONDS;
4
+ export const MAX_PREVIEW_WINDOW_IN_SECONDS = commonJsModule.MAX_PREVIEW_WINDOW_IN_SECONDS;
5
+ export const MIN_PREVIEW_WINDOW_IN_SECONDS = commonJsModule.MIN_PREVIEW_WINDOW_IN_SECONDS;
6
+ export const PREVIEW_WINDOW_COUNT = commonJsModule.PREVIEW_WINDOW_COUNT;
@@ -0,0 +1,23 @@
1
+ import { JSONObject } from "../JSON.mjs";
2
+ export declare const PAGE_FOR_EVERY_NEW_INCIDENT_AND_ALERT_KEY: string;
3
+ /**
4
+ * Whether a policy create asks for the two rules, read from its misc data.
5
+ *
6
+ * Only `true` (or the text "true") asks. Nothing sent, null or false asks
7
+ * nothing - an API caller, Terraform or an import gets the policy alone, as
8
+ * before. Anything else is refused rather than read as no: a caller who
9
+ * meant to page the policy must not get one that silently pages nobody.
10
+ */
11
+ export declare const readPageForEveryNewIncidentAndAlert: (miscDataProps: JSONObject | null | undefined) => boolean;
12
+ export declare const RULE_NAME_MAX_LENGTH: number;
13
+ export declare const getEveryNewIncidentRuleName: (policyName: string | undefined | null) => string;
14
+ export declare const getEveryNewAlertRuleName: (policyName: string | undefined | null) => string;
15
+ export declare const EVERY_NEW_INCIDENT_RULE_DESCRIPTION: string;
16
+ export declare const EVERY_NEW_ALERT_RULE_DESCRIPTION: string;
17
+ export interface EveryNewEventRulesOfferFacts {
18
+ policyCount: number | null;
19
+ incidentRuleCount: number | null;
20
+ alertRuleCount: number | null;
21
+ mayAddRules: boolean;
22
+ }
23
+ export declare const shouldOfferEveryNewEventRules: (facts: EveryNewEventRulesOfferFacts) => boolean;
@@ -0,0 +1,23 @@
1
+ import { JSONObject } from "../JSON";
2
+ export declare const PAGE_FOR_EVERY_NEW_INCIDENT_AND_ALERT_KEY: string;
3
+ /**
4
+ * Whether a policy create asks for the two rules, read from its misc data.
5
+ *
6
+ * Only `true` (or the text "true") asks. Nothing sent, null or false asks
7
+ * nothing - an API caller, Terraform or an import gets the policy alone, as
8
+ * before. Anything else is refused rather than read as no: a caller who
9
+ * meant to page the policy must not get one that silently pages nobody.
10
+ */
11
+ export declare const readPageForEveryNewIncidentAndAlert: (miscDataProps: JSONObject | null | undefined) => boolean;
12
+ export declare const RULE_NAME_MAX_LENGTH: number;
13
+ export declare const getEveryNewIncidentRuleName: (policyName: string | undefined | null) => string;
14
+ export declare const getEveryNewAlertRuleName: (policyName: string | undefined | null) => string;
15
+ export declare const EVERY_NEW_INCIDENT_RULE_DESCRIPTION: string;
16
+ export declare const EVERY_NEW_ALERT_RULE_DESCRIPTION: string;
17
+ export interface EveryNewEventRulesOfferFacts {
18
+ policyCount: number | null;
19
+ incidentRuleCount: number | null;
20
+ alertRuleCount: number | null;
21
+ mayAddRules: boolean;
22
+ }
23
+ export declare const shouldOfferEveryNewEventRules: (facts: EveryNewEventRulesOfferFacts) => boolean;
@@ -0,0 +1,105 @@
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.shouldOfferEveryNewEventRules = exports.EVERY_NEW_ALERT_RULE_DESCRIPTION = exports.EVERY_NEW_INCIDENT_RULE_DESCRIPTION = exports.getEveryNewAlertRuleName = exports.getEveryNewIncidentRuleName = exports.RULE_NAME_MAX_LENGTH = exports.readPageForEveryNewIncidentAndAlert = exports.PAGE_FOR_EVERY_NEW_INCIDENT_AND_ALERT_KEY = void 0;
7
+ const ColumnLength_1 = __importDefault(require("../Database/ColumnLength"));
8
+ const BadDataException_1 = __importDefault(require("../Exception/BadDataException"));
9
+ /*
10
+ * A NEW PROJECT'S FIRST ON-CALL POLICY PAGES FOR EVERY INCIDENT AND ALERT.
11
+ *
12
+ * An on-call policy pages nobody until something runs it: an on-call rule
13
+ * under Incidents or Alerts > Rules > On-Call Rules, a monitor's criteria, a
14
+ * template, or someone by hand. Someone new followed the Home checklist's
15
+ * "Set up an on-call policy", picked themselves under "Who gets paged
16
+ * first?", saw the step ticked off - and was never paged, because no rule
17
+ * named the policy. Paging it for every incident took a second trip, to a
18
+ * folded Rules section of another product.
19
+ *
20
+ * Create On-Call Policy now offers, while the project has no on-call policy
21
+ * and no on-call rule yet, "Page this policy for every new incident and
22
+ * alert" - on to start with. The choice travels with the create as misc
23
+ * data under PAGE_FOR_EVERY_NEW_INCIDENT_AND_ALERT_KEY, and the server, once
24
+ * the policy exists, adds two on-call rules naming it: one for incidents,
25
+ * one for alerts, each matching everything (OnCallDutyPolicyService.create).
26
+ * They are ordinary rules, listed and changed where every on-call rule is.
27
+ *
28
+ * React-free and server-safe: the server, the dashboard and their tests
29
+ * read it.
30
+ */
31
+ exports.PAGE_FOR_EVERY_NEW_INCIDENT_AND_ALERT_KEY = "pageForEveryNewIncidentAndAlert";
32
+ /**
33
+ * Whether a policy create asks for the two rules, read from its misc data.
34
+ *
35
+ * Only `true` (or the text "true") asks. Nothing sent, null or false asks
36
+ * nothing - an API caller, Terraform or an import gets the policy alone, as
37
+ * before. Anything else is refused rather than read as no: a caller who
38
+ * meant to page the policy must not get one that silently pages nobody.
39
+ */
40
+ const readPageForEveryNewIncidentAndAlert = (miscDataProps) => {
41
+ if (!miscDataProps ||
42
+ typeof miscDataProps !== "object" ||
43
+ Array.isArray(miscDataProps)) {
44
+ return false;
45
+ }
46
+ const value = miscDataProps[exports.PAGE_FOR_EVERY_NEW_INCIDENT_AND_ALERT_KEY];
47
+ if (value === undefined || value === null || value === false) {
48
+ return false;
49
+ }
50
+ if (value === true) {
51
+ return true;
52
+ }
53
+ if (typeof value === "string") {
54
+ const text = value.trim().toLowerCase();
55
+ if (text === "true") {
56
+ return true;
57
+ }
58
+ if (text === "false" || text === "") {
59
+ return false;
60
+ }
61
+ }
62
+ throw new BadDataException_1.default(`${exports.PAGE_FOR_EVERY_NEW_INCIDENT_AND_ALERT_KEY} must be true or false.`);
63
+ };
64
+ exports.readPageForEveryNewIncidentAndAlert = readPageForEveryNewIncidentAndAlert;
65
+ // What the two rules are called, and the longest name a rule column holds.
66
+ exports.RULE_NAME_MAX_LENGTH = ColumnLength_1.default.ShortText;
67
+ const ELLIPSIS = "…";
68
+ const WHITESPACE_RUN = /\s+/g;
69
+ /*
70
+ * "Page <policy> for every <what>", cut to fit a rule's name column: the
71
+ * policy's name gives way, ending in "…", so the words around it stay
72
+ * whole. A policy with no name is "the new on-call policy".
73
+ */
74
+ const getRuleName = (policyName, what) => {
75
+ const prefix = "Page ";
76
+ const suffix = ` for every ${what}`;
77
+ const name = (policyName || "").replace(WHITESPACE_RUN, " ").trim() ||
78
+ "the new on-call policy";
79
+ const room = exports.RULE_NAME_MAX_LENGTH - prefix.length - suffix.length;
80
+ const shown = Array.from(name).length <= room
81
+ ? name
82
+ : `${Array.from(name)
83
+ .slice(0, room - ELLIPSIS.length)
84
+ .join("")
85
+ .trimEnd()}${ELLIPSIS}`;
86
+ return `${prefix}${shown}${suffix}`;
87
+ };
88
+ const getEveryNewIncidentRuleName = (policyName) => {
89
+ return getRuleName(policyName, "incident");
90
+ };
91
+ exports.getEveryNewIncidentRuleName = getEveryNewIncidentRuleName;
92
+ const getEveryNewAlertRuleName = (policyName) => {
93
+ return getRuleName(policyName, "alert");
94
+ };
95
+ exports.getEveryNewAlertRuleName = getEveryNewAlertRuleName;
96
+ // Each rule's description: what it does, and where it came from.
97
+ exports.EVERY_NEW_INCIDENT_RULE_DESCRIPTION = "Pages this on-call policy for every new incident. Added when the policy was created.";
98
+ exports.EVERY_NEW_ALERT_RULE_DESCRIPTION = "Pages this on-call policy for every new alert. Added when the policy was created.";
99
+ const shouldOfferEveryNewEventRules = (facts) => {
100
+ return (facts.mayAddRules &&
101
+ facts.policyCount === 0 &&
102
+ facts.incidentRuleCount === 0 &&
103
+ facts.alertRuleCount === 0);
104
+ };
105
+ exports.shouldOfferEveryNewEventRules = shouldOfferEveryNewEventRules;
@@ -0,0 +1,9 @@
1
+ import commonJsModule from "./EveryNewEventRules.js";
2
+ export const EVERY_NEW_ALERT_RULE_DESCRIPTION = commonJsModule.EVERY_NEW_ALERT_RULE_DESCRIPTION;
3
+ export const EVERY_NEW_INCIDENT_RULE_DESCRIPTION = commonJsModule.EVERY_NEW_INCIDENT_RULE_DESCRIPTION;
4
+ export const PAGE_FOR_EVERY_NEW_INCIDENT_AND_ALERT_KEY = commonJsModule.PAGE_FOR_EVERY_NEW_INCIDENT_AND_ALERT_KEY;
5
+ export const RULE_NAME_MAX_LENGTH = commonJsModule.RULE_NAME_MAX_LENGTH;
6
+ export const getEveryNewAlertRuleName = commonJsModule.getEveryNewAlertRuleName;
7
+ export const getEveryNewIncidentRuleName = commonJsModule.getEveryNewIncidentRuleName;
8
+ export const readPageForEveryNewIncidentAndAlert = commonJsModule.readPageForEveryNewIncidentAndAlert;
9
+ export const shouldOfferEveryNewEventRules = commonJsModule.shouldOfferEveryNewEventRules;
@@ -62,7 +62,23 @@ declare enum ProviderLogo {
62
62
  CPlusPlus = "cplusplus",
63
63
  Swift = "swift",
64
64
  React = "react",
65
- Angular = "angular"
65
+ Angular = "angular",
66
+ Express = "express",
67
+ NestJs = "nestjs",
68
+ NextJs = "nextjs",
69
+ Fastify = "fastify",
70
+ Koa = "koa",
71
+ Hapi = "hapi",
72
+ Bun = "bun",
73
+ Deno = "deno",
74
+ Django = "django",
75
+ Flask = "flask",
76
+ FastAPI = "fastapi",
77
+ Celery = "celery",
78
+ SpringBoot = "spring-boot",
79
+ Quarkus = "quarkus",
80
+ Kotlin = "kotlin",
81
+ Ktor = "ktor"
66
82
  }
67
83
  export default ProviderLogo;
68
84
  export declare const PROVIDER_LOGO_NAMES: Readonly<Record<ProviderLogo, string>>;
@@ -62,7 +62,23 @@ declare enum ProviderLogo {
62
62
  CPlusPlus = "cplusplus",
63
63
  Swift = "swift",
64
64
  React = "react",
65
- Angular = "angular"
65
+ Angular = "angular",
66
+ Express = "express",
67
+ NestJs = "nestjs",
68
+ NextJs = "nextjs",
69
+ Fastify = "fastify",
70
+ Koa = "koa",
71
+ Hapi = "hapi",
72
+ Bun = "bun",
73
+ Deno = "deno",
74
+ Django = "django",
75
+ Flask = "flask",
76
+ FastAPI = "fastapi",
77
+ Celery = "celery",
78
+ SpringBoot = "spring-boot",
79
+ Quarkus = "quarkus",
80
+ Kotlin = "kotlin",
81
+ Ktor = "ktor"
66
82
  }
67
83
  export default ProviderLogo;
68
84
  export declare const PROVIDER_LOGO_NAMES: Readonly<Record<ProviderLogo, string>>;
@@ -98,6 +98,23 @@ var ProviderLogo;
98
98
  ProviderLogo["Swift"] = "swift";
99
99
  ProviderLogo["React"] = "react";
100
100
  ProviderLogo["Angular"] = "angular";
101
+ // The frameworks and runtimes the OpenTelemetry guides are written for
102
+ ProviderLogo["Express"] = "express";
103
+ ProviderLogo["NestJs"] = "nestjs";
104
+ ProviderLogo["NextJs"] = "nextjs";
105
+ ProviderLogo["Fastify"] = "fastify";
106
+ ProviderLogo["Koa"] = "koa";
107
+ ProviderLogo["Hapi"] = "hapi";
108
+ ProviderLogo["Bun"] = "bun";
109
+ ProviderLogo["Deno"] = "deno";
110
+ ProviderLogo["Django"] = "django";
111
+ ProviderLogo["Flask"] = "flask";
112
+ ProviderLogo["FastAPI"] = "fastapi";
113
+ ProviderLogo["Celery"] = "celery";
114
+ ProviderLogo["SpringBoot"] = "spring-boot";
115
+ ProviderLogo["Quarkus"] = "quarkus";
116
+ ProviderLogo["Kotlin"] = "kotlin";
117
+ ProviderLogo["Ktor"] = "ktor";
101
118
  })(ProviderLogo || (ProviderLogo = {}));
102
119
  exports.default = ProviderLogo;
103
120
  /*
@@ -170,6 +187,22 @@ exports.PROVIDER_LOGO_NAMES = {
170
187
  [ProviderLogo.Swift]: "Swift",
171
188
  [ProviderLogo.React]: "React",
172
189
  [ProviderLogo.Angular]: "Angular",
190
+ [ProviderLogo.Express]: "Express",
191
+ [ProviderLogo.NestJs]: "NestJS",
192
+ [ProviderLogo.NextJs]: "Next.js",
193
+ [ProviderLogo.Fastify]: "Fastify",
194
+ [ProviderLogo.Koa]: "Koa",
195
+ [ProviderLogo.Hapi]: "hapi",
196
+ [ProviderLogo.Bun]: "Bun",
197
+ [ProviderLogo.Deno]: "Deno",
198
+ [ProviderLogo.Django]: "Django",
199
+ [ProviderLogo.Flask]: "Flask",
200
+ [ProviderLogo.FastAPI]: "FastAPI",
201
+ [ProviderLogo.Celery]: "Celery",
202
+ [ProviderLogo.SpringBoot]: "Spring Boot",
203
+ [ProviderLogo.Quarkus]: "Quarkus",
204
+ [ProviderLogo.Kotlin]: "Kotlin",
205
+ [ProviderLogo.Ktor]: "Ktor",
173
206
  };
174
207
  exports.ALL_PROVIDER_LOGOS = Object.values(ProviderLogo);
175
208
  function isProviderLogo(value) {
@@ -0,0 +1,38 @@
1
+ import { JSONObject } from "../JSON.mjs";
2
+ export declare const DETECTION_RETROHUNT_PERIODS_IN_HOURS: ReadonlyArray<number>;
3
+ export declare const DETECTION_RETROHUNT_DEFAULT_PERIOD_IN_HOURS: number;
4
+ export declare const DETECTION_RETROHUNT_MAX_GROUPS: number;
5
+ export declare const DETECTION_RETROHUNT_NOISY_FIRINGS_PER_DAY: number;
6
+ export declare function isDetectionRetrohuntPeriod(value: unknown): value is number;
7
+ export interface DetectionRetrohuntGroup {
8
+ value: string;
9
+ entityType: string;
10
+ firedCount: number;
11
+ eventCount: number;
12
+ firstFiredAt: Date | null;
13
+ lastFiredAt: Date | null;
14
+ sampleMessage: string;
15
+ summary: string;
16
+ }
17
+ export interface DetectionRetrohuntResult {
18
+ startTime: Date;
19
+ endTime: Date;
20
+ periodInHours: number;
21
+ isCorrelation: boolean;
22
+ windowInMinutes: number;
23
+ threshold: number | null;
24
+ firedCount: number;
25
+ groupCount: number;
26
+ eventCount: number;
27
+ matchedEventCount: number | null;
28
+ exceptionCount: number;
29
+ skippedEventCount: number | null;
30
+ preventedFiredCount: number | null;
31
+ groups: Array<DetectionRetrohuntGroup>;
32
+ hasMoreGroups: boolean;
33
+ candidateLimit: number | null;
34
+ }
35
+ export declare function getDetectionRetrohuntFiringsPerDay(result: Pick<DetectionRetrohuntResult, "firedCount" | "periodInHours">): number;
36
+ export declare function isDetectionRetrohuntNoisy(result: Pick<DetectionRetrohuntResult, "firedCount" | "periodInHours">): boolean;
37
+ export declare function detectionRetrohuntResultToJSON(result: DetectionRetrohuntResult): JSONObject;
38
+ export declare function parseDetectionRetrohuntResult(json: JSONObject): DetectionRetrohuntResult;
@@ -0,0 +1,38 @@
1
+ import { JSONObject } from "../JSON";
2
+ export declare const DETECTION_RETROHUNT_PERIODS_IN_HOURS: ReadonlyArray<number>;
3
+ export declare const DETECTION_RETROHUNT_DEFAULT_PERIOD_IN_HOURS: number;
4
+ export declare const DETECTION_RETROHUNT_MAX_GROUPS: number;
5
+ export declare const DETECTION_RETROHUNT_NOISY_FIRINGS_PER_DAY: number;
6
+ export declare function isDetectionRetrohuntPeriod(value: unknown): value is number;
7
+ export interface DetectionRetrohuntGroup {
8
+ value: string;
9
+ entityType: string;
10
+ firedCount: number;
11
+ eventCount: number;
12
+ firstFiredAt: Date | null;
13
+ lastFiredAt: Date | null;
14
+ sampleMessage: string;
15
+ summary: string;
16
+ }
17
+ export interface DetectionRetrohuntResult {
18
+ startTime: Date;
19
+ endTime: Date;
20
+ periodInHours: number;
21
+ isCorrelation: boolean;
22
+ windowInMinutes: number;
23
+ threshold: number | null;
24
+ firedCount: number;
25
+ groupCount: number;
26
+ eventCount: number;
27
+ matchedEventCount: number | null;
28
+ exceptionCount: number;
29
+ skippedEventCount: number | null;
30
+ preventedFiredCount: number | null;
31
+ groups: Array<DetectionRetrohuntGroup>;
32
+ hasMoreGroups: boolean;
33
+ candidateLimit: number | null;
34
+ }
35
+ export declare function getDetectionRetrohuntFiringsPerDay(result: Pick<DetectionRetrohuntResult, "firedCount" | "periodInHours">): number;
36
+ export declare function isDetectionRetrohuntNoisy(result: Pick<DetectionRetrohuntResult, "firedCount" | "periodInHours">): boolean;
37
+ export declare function detectionRetrohuntResultToJSON(result: DetectionRetrohuntResult): JSONObject;
38
+ export declare function parseDetectionRetrohuntResult(json: JSONObject): DetectionRetrohuntResult;