@justair/justair-library 4.7.19 → 4.7.21
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/package.json +1 -1
- package/src/models/monitors.js +14 -10
package/package.json
CHANGED
package/src/models/monitors.js
CHANGED
|
@@ -52,22 +52,22 @@ const correctionSchema = mongoose.Schema(
|
|
|
52
52
|
equation: {
|
|
53
53
|
type: String,
|
|
54
54
|
required: function () {
|
|
55
|
-
return this.equationType ===
|
|
55
|
+
return this.equationType === "custom";
|
|
56
56
|
},
|
|
57
57
|
validate: {
|
|
58
|
-
validator: function(value) {
|
|
58
|
+
validator: function (value) {
|
|
59
59
|
if (!value) return true; // Allow empty for non-custom types
|
|
60
|
-
if (value.includes(
|
|
60
|
+
if (value.includes("\0")) return false;
|
|
61
61
|
try {
|
|
62
62
|
const encoder = new TextEncoder();
|
|
63
|
-
const decoder = new TextDecoder(
|
|
63
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
64
64
|
decoder.decode(encoder.encode(value));
|
|
65
65
|
return true;
|
|
66
66
|
} catch (e) {
|
|
67
67
|
return false;
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
|
-
message:
|
|
70
|
+
message: "Equation contains invalid UTF-8 characters",
|
|
71
71
|
},
|
|
72
72
|
},
|
|
73
73
|
context: {
|
|
@@ -77,7 +77,7 @@ const correctionSchema = mongoose.Schema(
|
|
|
77
77
|
},
|
|
78
78
|
variables: {
|
|
79
79
|
required: function () {
|
|
80
|
-
return this.equationType ===
|
|
80
|
+
return this.equationType === "linear";
|
|
81
81
|
},
|
|
82
82
|
type: Object,
|
|
83
83
|
},
|
|
@@ -96,19 +96,19 @@ const correctionHistorySchema = mongoose.Schema(
|
|
|
96
96
|
type: String,
|
|
97
97
|
required: true,
|
|
98
98
|
validate: {
|
|
99
|
-
validator: function(value) {
|
|
99
|
+
validator: function (value) {
|
|
100
100
|
// Check for null bytes and validate UTF-8
|
|
101
|
-
if (value.includes(
|
|
101
|
+
if (value.includes("\0")) return false;
|
|
102
102
|
try {
|
|
103
103
|
const encoder = new TextEncoder();
|
|
104
|
-
const decoder = new TextDecoder(
|
|
104
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
105
105
|
decoder.decode(encoder.encode(value));
|
|
106
106
|
return true;
|
|
107
107
|
} catch (e) {
|
|
108
108
|
return false;
|
|
109
109
|
}
|
|
110
110
|
},
|
|
111
|
-
message:
|
|
111
|
+
message: "Pollutant contains invalid UTF-8 characters",
|
|
112
112
|
},
|
|
113
113
|
},
|
|
114
114
|
oldValue: {
|
|
@@ -179,6 +179,7 @@ const monitorsSchema = mongoose.Schema(
|
|
|
179
179
|
"airGradient",
|
|
180
180
|
"oizom",
|
|
181
181
|
"metOne",
|
|
182
|
+
"aqMesh",
|
|
182
183
|
],
|
|
183
184
|
},
|
|
184
185
|
monitorType: String,
|
|
@@ -277,6 +278,9 @@ monitorsSchema.index({ monitorSupplier: 1 });
|
|
|
277
278
|
monitorsSchema.index({ monitorIdFromSupplier: 1 });
|
|
278
279
|
monitorsSchema.index({ monitorState: 1 });
|
|
279
280
|
|
|
281
|
+
//network metrics for anomalies
|
|
282
|
+
monitorsSchema.index({ sponsor: 1, isActive: 1, monitorSupplier: 1 })
|
|
283
|
+
|
|
280
284
|
// Pre-hook to log single document deletions
|
|
281
285
|
monitorsSchema.pre("findOneAndDelete", async function () {
|
|
282
286
|
const docToDelete = await this.model.findOne(this.getFilter()).lean();
|