@justair/justair-library 3.3.4-lima → 3.3.4-november

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justair/justair-library",
3
- "version": "3.3.4-lima",
3
+ "version": "3.3.4-november",
4
4
  "description": "JustAir Internal Library",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -14,29 +14,17 @@ const parametersEnum = [
14
14
  "WS And Direction",
15
15
  ];
16
16
 
17
- const parameterThresholdsSchema = mongoose.Schema({
18
- parameter: {
19
- type: mongoose.Schema.Types.Mixed,
20
- validate: {
21
- validator: function(v) {
22
- return Object.keys(v).every(key => parametersEnum.includes(key)
23
- );
24
- },
25
- message: props => `${props.value} is not a valid parameter threshold object`
26
- }
17
+ const thresholdSchema = new mongoose.Schema({
18
+ invalid: {
19
+ min: Number,
20
+ max: Number
27
21
  },
28
- });
29
-
30
- /*Ensure the parameter value is one of our valid parameters */
31
- parameterThresholdsSchema.path('parameter').validate(function(value) {
32
- console.log(value)
33
- for (let key of value.keys()) {
34
- if (!parametersEnum.includes(key)) {
35
- return false;
36
- }
22
+ warning: {
23
+ min: Number,
24
+ max: Number
37
25
  }
38
- return true;
39
- }, 'Invalid parameter key');
26
+ }, { _id: false });
27
+
40
28
 
41
29
  // Monitors Schema
42
30
  const monitorsSchema = mongoose.Schema(
@@ -110,7 +98,7 @@ const monitorsSchema = mongoose.Schema(
110
98
  validate: {
111
99
  validator: function(v) {
112
100
  return Object.keys(v).every(key =>
113
- pollutants.includes(key) &&
101
+ parametersEnum.includes(key) &&
114
102
  thresholdSchema.path('invalid.min').instance(v[key].invalid.min) &&
115
103
  thresholdSchema.path('invalid.max').instance(v[key].invalid.max) &&
116
104
  thresholdSchema.path('warning.min').instance(v[key].warning.min) &&