@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
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getTableColumns = exports.getTableColumn = void 0;
6
+ exports.getTableColumnNames = exports.getTableColumns = exports.getTableColumn = void 0;
7
7
  const CanonicalModelInstance_1 = __importDefault(require("./CanonicalModelInstance"));
8
8
  const UserAttribution_1 = __importDefault(require("./UserAttribution"));
9
9
  require("reflect-metadata");
@@ -47,35 +47,81 @@ exports.getTableColumn = getTableColumn;
47
47
  * model would lose it. See CanonicalModelInstance.ts.
48
48
  */
49
49
  const tableColumnsCache = new WeakMap();
50
- const getTableColumns = (target) => {
50
+ /*
51
+ * The column dictionary of `target`'s class, and whether it is the one
52
+ * cached for the class. Never handed out as is: getTableColumns copies it,
53
+ * and getTableColumnNames reads lists from it.
54
+ */
55
+ function readTableColumns(target) {
51
56
  const modelClass = target.constructor;
52
- let cached = tableColumnsCache.get(modelClass);
53
- if (!cached) {
54
- const canonical = (0, CanonicalModelInstance_1.default)(target);
55
- const metadataSource = canonical || target;
56
- const dictonary = {};
57
- const keys = Object.keys(metadataSource);
58
- for (const key of keys) {
59
- const metadata = Reflect.getMetadata(tableColumn, metadataSource, key);
60
- if (metadata) {
61
- dictonary[key] = resolveModelType(metadata);
62
- }
63
- }
64
- cached = dictonary;
65
- /*
66
- * No canonical instance (see CanonicalModelInstance): answer from the
67
- * instance we were handed, but do NOT cache it for the class - that
68
- * instance may be a mutilated one, and a cached answer outlives it.
69
- */
70
- if (canonical) {
71
- tableColumnsCache.set(modelClass, cached);
57
+ const cached = tableColumnsCache.get(modelClass);
58
+ if (cached) {
59
+ return { dictionary: cached, isClassCache: true };
60
+ }
61
+ const canonical = (0, CanonicalModelInstance_1.default)(target);
62
+ const metadataSource = canonical || target;
63
+ const dictonary = {};
64
+ const keys = Object.keys(metadataSource);
65
+ for (const key of keys) {
66
+ const metadata = Reflect.getMetadata(tableColumn, metadataSource, key);
67
+ if (metadata) {
68
+ dictonary[key] = resolveModelType(metadata);
72
69
  }
73
70
  }
71
+ /*
72
+ * No canonical instance (see CanonicalModelInstance): answer from the
73
+ * instance we were handed, but do NOT cache it for the class - that
74
+ * instance may be a mutilated one, and a cached answer outlives it.
75
+ */
76
+ if (canonical) {
77
+ tableColumnsCache.set(modelClass, dictonary);
78
+ }
79
+ return { dictionary: dictonary, isClassCache: Boolean(canonical) };
80
+ }
81
+ const getTableColumns = (target) => {
74
82
  /*
75
83
  * Hand out a copy, not the cached dictionary itself: callers mutate the
76
84
  * result (the API reference docs delete entries from it), which would
77
85
  * otherwise strip columns from every later call for the same class.
78
86
  */
79
- return Object.assign({}, cached);
87
+ return Object.assign({}, readTableColumns(target).dictionary);
80
88
  };
81
89
  exports.getTableColumns = getTableColumns;
90
+ const tableColumnNamesCache = new WeakMap();
91
+ function namesOf(dictionary) {
92
+ const all = [];
93
+ const encrypted = [];
94
+ const hashed = [];
95
+ const unique = [];
96
+ const required = [];
97
+ for (const key in dictionary) {
98
+ all.push(key);
99
+ const metadata = dictionary[key];
100
+ if (metadata === null || metadata === void 0 ? void 0 : metadata.encrypted) {
101
+ encrypted.push(key);
102
+ }
103
+ if (metadata === null || metadata === void 0 ? void 0 : metadata.hashed) {
104
+ hashed.push(key);
105
+ }
106
+ if (metadata === null || metadata === void 0 ? void 0 : metadata.unique) {
107
+ unique.push(key);
108
+ }
109
+ if (metadata === null || metadata === void 0 ? void 0 : metadata.required) {
110
+ required.push(key);
111
+ }
112
+ }
113
+ return { all, encrypted, hashed, unique, required };
114
+ }
115
+ const getTableColumnNames = (target) => {
116
+ const read = readTableColumns(target);
117
+ if (!read.isClassCache) {
118
+ return namesOf(read.dictionary);
119
+ }
120
+ let names = tableColumnNamesCache.get(read.dictionary);
121
+ if (!names) {
122
+ names = namesOf(read.dictionary);
123
+ tableColumnNamesCache.set(read.dictionary, names);
124
+ }
125
+ return names;
126
+ };
127
+ exports.getTableColumnNames = getTableColumnNames;
@@ -1,4 +1,5 @@
1
1
  import commonJsModule from "./TableColumn.js";
2
2
  export default commonJsModule.default;
3
3
  export const getTableColumn = commonJsModule.getTableColumn;
4
+ export const getTableColumnNames = commonJsModule.getTableColumnNames;
4
5
  export const getTableColumns = commonJsModule.getTableColumns;
@@ -414,8 +414,23 @@ class JSONFunctions {
414
414
  }
415
415
  return returnArr;
416
416
  }
417
+ /*
418
+ * JSON5's grammar is a superset of JSON's, so it reads every JSON text to
419
+ * the same value JSON.parse does - and the engine's JSON.parse is about
420
+ * 25 times faster at it than JSON5's parser, written in JavaScript, for
421
+ * the short texts read here on every signed-in request (a token's payload)
422
+ * and every cache read. So JSON goes to JSON.parse, and only what JSON.parse
423
+ * refuses goes on to JSON5, whose syntax and errors are then what they
424
+ * were. Tests/Types/JSONFunctionsParseFastPath.test.ts holds the two paths
425
+ * to the same values.
426
+ */
417
427
  static parse(val) {
418
- return json5_1.default.parse(val);
428
+ try {
429
+ return JSON.parse(val);
430
+ }
431
+ catch (_a) {
432
+ return json5_1.default.parse(val);
433
+ }
419
434
  }
420
435
  /*
421
436
  * Guarding only against an array leaves every OTHER non-object through:
@@ -690,7 +690,8 @@ class MonitorTypeHelper {
690
690
  {
691
691
  monitorType: MonitorType.Logs,
692
692
  title: "Logs",
693
- description: "Alert on log volume or matching log content from any source.",
693
+ // What its recipes answer (TelemetryRuleRecipes), in their words.
694
+ description: "Alert when errors pile up, a message appears, or logs stop.",
694
695
  icon: IconProp_1.default.Logs,
695
696
  keywords: [
696
697
  "log",
@@ -741,7 +742,7 @@ class MonitorTypeHelper {
741
742
  {
742
743
  monitorType: MonitorType.Exceptions,
743
744
  title: "Exceptions",
744
- description: "Alert on exceptions and error groups from any source.",
745
+ description: "Alert when an exception happens, comes back, or spikes.",
745
746
  icon: IconProp_1.default.Bug,
746
747
  keywords: [
747
748
  "exception",
@@ -761,7 +762,7 @@ class MonitorTypeHelper {
761
762
  * card promises no latency. Latency is alerted on through a Metrics
762
763
  * monitor on a request duration metric, which answers "latency".
763
764
  */
764
- description: "Alert on the number of matching spans, like failed requests, from any source.",
765
+ description: "Alert when requests fail, or stop arriving.",
765
766
  icon: IconProp_1.default.Waterfall,
766
767
  keywords: [
767
768
  "trace",
@@ -778,7 +779,7 @@ class MonitorTypeHelper {
778
779
  {
779
780
  monitorType: MonitorType.Metrics,
780
781
  title: "Metrics",
781
- description: "Alert on any metric you ingest.",
782
+ description: "Alert when a metric goes above or below a value, or looks unusual.",
782
783
  icon: IconProp_1.default.Heartbeat,
783
784
  keywords: [
784
785
  "metric",
@@ -0,0 +1,111 @@
1
+ import ObjectID from "../ObjectID.mjs";
2
+ import RollingTime from "../RollingTime/RollingTime.mjs";
3
+ import { CriteriaAlert } from "./CriteriaAlert.mjs";
4
+ import { CheckOn, EvaluateOverTimeType, FilterType, MetricAnomalyDetectionOptions, NoDataPolicy } from "./CriteriaFilter.mjs";
5
+ import { CriteriaIncident } from "./CriteriaIncident.mjs";
6
+ import MonitorCriteria from "./MonitorCriteria.mjs";
7
+ import MonitorStep from "./MonitorStep.mjs";
8
+ import MonitorType from "./MonitorType.mjs";
9
+ export declare enum TelemetryAlertRuleAction {
10
+ Alert = "Alert",
11
+ Incident = "Incident",
12
+ AlertAndIncident = "AlertAndIncident",
13
+ StatusOnly = "StatusOnly"
14
+ }
15
+ export declare enum TelemetryAlertRuleRecovery {
16
+ DefaultStatus = "DefaultStatus",
17
+ Opposite = "Opposite",
18
+ OppositeWithMargin = "OppositeWithMargin",
19
+ Disjoint = "Disjoint"
20
+ }
21
+ export declare enum TelemetryAlertRuleShapeProblem {
22
+ NotARuleMonitorType = "NotARuleMonitorType",
23
+ NoCriteria = "NoCriteria",
24
+ SeveralRules = "SeveralRules",
25
+ DisabledRule = "DisabledRule",
26
+ SeveralFilters = "SeveralFilters",
27
+ OtherCheck = "OtherCheck",
28
+ UnsupportedCondition = "UnsupportedCondition",
29
+ SeveralIncidentsOrAlerts = "SeveralIncidentsOrAlerts",
30
+ GroupedIncidents = "GroupedIncidents",
31
+ UnknownMetric = "UnknownMetric"
32
+ }
33
+ export interface TelemetryAlertRule {
34
+ filterType: FilterType;
35
+ threshold: number | undefined;
36
+ windowInSeconds: number | undefined;
37
+ rollingTime: RollingTime | undefined;
38
+ metricAlias: string | undefined;
39
+ metricAggregationType: EvaluateOverTimeType | undefined;
40
+ onNoDataPolicy: NoDataPolicy | undefined;
41
+ thresholdUnit: string | undefined;
42
+ anomalyDetection: MetricAnomalyDetectionOptions | undefined;
43
+ action: TelemetryAlertRuleAction;
44
+ monitorStatusId: ObjectID | undefined;
45
+ incident: CriteriaIncident | undefined;
46
+ alert: CriteriaAlert | undefined;
47
+ name: string;
48
+ ruleCriteriaId: string;
49
+ recovery: TelemetryAlertRuleRecovery;
50
+ }
51
+ export interface TelemetryAlertRuleReadResult {
52
+ rule: TelemetryAlertRule | null;
53
+ problem: TelemetryAlertRuleShapeProblem | null;
54
+ }
55
+ export default class TelemetryAlertRuleUtil {
56
+ static readonly RULE_MONITOR_TYPES: ReadonlyArray<MonitorType>;
57
+ static isRuleMonitorType(monitorType: MonitorType | undefined): boolean;
58
+ static getMeasureCheckOn(monitorType: MonitorType): CheckOn | null;
59
+ static isCountMonitorType(monitorType: MonitorType): boolean;
60
+ static supportsAnomaly(monitorType: MonitorType): boolean;
61
+ static getComparisons(data: {
62
+ monitorType: MonitorType;
63
+ current?: FilterType | undefined;
64
+ }): Array<FilterType>;
65
+ static isAnomaly(filterType: FilterType | undefined): boolean;
66
+ static getWindowInSeconds(data: {
67
+ monitorType: MonitorType;
68
+ monitorStep: MonitorStep;
69
+ }): number | undefined;
70
+ static getRollingTime(monitorStep: MonitorStep): RollingTime;
71
+ static getMetricAliases(monitorStep: MonitorStep): Array<string>;
72
+ static read(data: {
73
+ monitorType: MonitorType;
74
+ monitorStep: MonitorStep;
75
+ defaultMonitorStatusId: ObjectID | undefined;
76
+ }): TelemetryAlertRuleReadResult;
77
+ static write(data: {
78
+ monitorType: MonitorType;
79
+ monitorStep: MonitorStep;
80
+ rule: TelemetryAlertRule;
81
+ }): MonitorStep;
82
+ static buildCriteria(data: {
83
+ monitorType: MonitorType;
84
+ rule: TelemetryAlertRule;
85
+ }): MonitorCriteria;
86
+ static writeWindow(data: {
87
+ monitorType: MonitorType;
88
+ monitorStep: MonitorStep;
89
+ rule: Pick<TelemetryAlertRule, "windowInSeconds" | "rollingTime">;
90
+ }): void;
91
+ static matches(data: {
92
+ filterType: FilterType;
93
+ threshold: number;
94
+ value: number;
95
+ }): boolean;
96
+ private static isReadableComparison;
97
+ private static getRuleInstanceProblem;
98
+ private static isRecoveryCandidate;
99
+ private static getRecoveryKind;
100
+ private static compareFilterSets;
101
+ private static getAction;
102
+ private static newRuleInstance;
103
+ private static buildRuleFilter;
104
+ private static buildRecoveryFilter;
105
+ private static getOppositeFilterType;
106
+ private static applyRuleToInstance;
107
+ private static isSameComparison;
108
+ static toNumber(value: unknown): number | undefined;
109
+ private static isSameNumber;
110
+ private static setOrDelete;
111
+ }
@@ -0,0 +1,111 @@
1
+ import ObjectID from "../ObjectID";
2
+ import RollingTime from "../RollingTime/RollingTime";
3
+ import { CriteriaAlert } from "./CriteriaAlert";
4
+ import { CheckOn, EvaluateOverTimeType, FilterType, MetricAnomalyDetectionOptions, NoDataPolicy } from "./CriteriaFilter";
5
+ import { CriteriaIncident } from "./CriteriaIncident";
6
+ import MonitorCriteria from "./MonitorCriteria";
7
+ import MonitorStep from "./MonitorStep";
8
+ import MonitorType from "./MonitorType";
9
+ export declare enum TelemetryAlertRuleAction {
10
+ Alert = "Alert",
11
+ Incident = "Incident",
12
+ AlertAndIncident = "AlertAndIncident",
13
+ StatusOnly = "StatusOnly"
14
+ }
15
+ export declare enum TelemetryAlertRuleRecovery {
16
+ DefaultStatus = "DefaultStatus",
17
+ Opposite = "Opposite",
18
+ OppositeWithMargin = "OppositeWithMargin",
19
+ Disjoint = "Disjoint"
20
+ }
21
+ export declare enum TelemetryAlertRuleShapeProblem {
22
+ NotARuleMonitorType = "NotARuleMonitorType",
23
+ NoCriteria = "NoCriteria",
24
+ SeveralRules = "SeveralRules",
25
+ DisabledRule = "DisabledRule",
26
+ SeveralFilters = "SeveralFilters",
27
+ OtherCheck = "OtherCheck",
28
+ UnsupportedCondition = "UnsupportedCondition",
29
+ SeveralIncidentsOrAlerts = "SeveralIncidentsOrAlerts",
30
+ GroupedIncidents = "GroupedIncidents",
31
+ UnknownMetric = "UnknownMetric"
32
+ }
33
+ export interface TelemetryAlertRule {
34
+ filterType: FilterType;
35
+ threshold: number | undefined;
36
+ windowInSeconds: number | undefined;
37
+ rollingTime: RollingTime | undefined;
38
+ metricAlias: string | undefined;
39
+ metricAggregationType: EvaluateOverTimeType | undefined;
40
+ onNoDataPolicy: NoDataPolicy | undefined;
41
+ thresholdUnit: string | undefined;
42
+ anomalyDetection: MetricAnomalyDetectionOptions | undefined;
43
+ action: TelemetryAlertRuleAction;
44
+ monitorStatusId: ObjectID | undefined;
45
+ incident: CriteriaIncident | undefined;
46
+ alert: CriteriaAlert | undefined;
47
+ name: string;
48
+ ruleCriteriaId: string;
49
+ recovery: TelemetryAlertRuleRecovery;
50
+ }
51
+ export interface TelemetryAlertRuleReadResult {
52
+ rule: TelemetryAlertRule | null;
53
+ problem: TelemetryAlertRuleShapeProblem | null;
54
+ }
55
+ export default class TelemetryAlertRuleUtil {
56
+ static readonly RULE_MONITOR_TYPES: ReadonlyArray<MonitorType>;
57
+ static isRuleMonitorType(monitorType: MonitorType | undefined): boolean;
58
+ static getMeasureCheckOn(monitorType: MonitorType): CheckOn | null;
59
+ static isCountMonitorType(monitorType: MonitorType): boolean;
60
+ static supportsAnomaly(monitorType: MonitorType): boolean;
61
+ static getComparisons(data: {
62
+ monitorType: MonitorType;
63
+ current?: FilterType | undefined;
64
+ }): Array<FilterType>;
65
+ static isAnomaly(filterType: FilterType | undefined): boolean;
66
+ static getWindowInSeconds(data: {
67
+ monitorType: MonitorType;
68
+ monitorStep: MonitorStep;
69
+ }): number | undefined;
70
+ static getRollingTime(monitorStep: MonitorStep): RollingTime;
71
+ static getMetricAliases(monitorStep: MonitorStep): Array<string>;
72
+ static read(data: {
73
+ monitorType: MonitorType;
74
+ monitorStep: MonitorStep;
75
+ defaultMonitorStatusId: ObjectID | undefined;
76
+ }): TelemetryAlertRuleReadResult;
77
+ static write(data: {
78
+ monitorType: MonitorType;
79
+ monitorStep: MonitorStep;
80
+ rule: TelemetryAlertRule;
81
+ }): MonitorStep;
82
+ static buildCriteria(data: {
83
+ monitorType: MonitorType;
84
+ rule: TelemetryAlertRule;
85
+ }): MonitorCriteria;
86
+ static writeWindow(data: {
87
+ monitorType: MonitorType;
88
+ monitorStep: MonitorStep;
89
+ rule: Pick<TelemetryAlertRule, "windowInSeconds" | "rollingTime">;
90
+ }): void;
91
+ static matches(data: {
92
+ filterType: FilterType;
93
+ threshold: number;
94
+ value: number;
95
+ }): boolean;
96
+ private static isReadableComparison;
97
+ private static getRuleInstanceProblem;
98
+ private static isRecoveryCandidate;
99
+ private static getRecoveryKind;
100
+ private static compareFilterSets;
101
+ private static getAction;
102
+ private static newRuleInstance;
103
+ private static buildRuleFilter;
104
+ private static buildRecoveryFilter;
105
+ private static getOppositeFilterType;
106
+ private static applyRuleToInstance;
107
+ private static isSameComparison;
108
+ static toNumber(value: unknown): number | undefined;
109
+ private static isSameNumber;
110
+ private static setOrDelete;
111
+ }