@justair/justair-library 4.15.0-alpha.d287cce → 5.0.0-alpha.56f07df

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.
@@ -61,6 +61,17 @@ const featureSchema = new Schema({
61
61
  },
62
62
  });
63
63
 
64
+ const customAlertLevelSchema = new Schema(
65
+ {
66
+ parameter: { type: String },
67
+ startAlertLevel: {
68
+ type: String,
69
+ enum: ["Good", "Moderate", "Unhealthy for SG", "Unhealthy", "Very Unhealthy", "Hazardous"],
70
+ },
71
+ },
72
+ { _id: false }
73
+ );
74
+
64
75
  const computeResetTime = (rateLimitType, baseTime = new Date()) => {
65
76
  const resetTime = new Date(baseTime);
66
77
 
@@ -97,7 +108,7 @@ const organizationsSchema = mongoose.Schema(
97
108
  orgCode: String,
98
109
  orgDescription: String,
99
110
  orgLogo: String,
100
- customAlertLevels: { type: [Object], default: [{ parameter: "AQI", startAlertLevel: "Unhealthy for SG" }] },
111
+ customAlertLevels: { type: [customAlertLevelSchema], default: [{ parameter: "AQI", startAlertLevel: "Unhealthy for SG" }] },
101
112
  connectedMonitors: [{ type: mongoose.Types.ObjectId, ref: "Monitors" }],
102
113
  communityMessages: [Object],
103
114
  weeklyReportData: [Object],
@@ -1,34 +1,16 @@
1
1
  import mongoose from "mongoose";
2
2
  import { customAlphabet } from 'nanoid';
3
+ import { HEAVY_METALS } from "../constants/pollutants.js";
4
+
3
5
  const generateSiteCode = customAlphabet('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 8);
4
6
 
5
- const sampleParametersEnum = [
6
- "C6H6", // Benzene
7
- "PB", // Lead
8
- "AS", // Arsenic
9
- "CD", // Cadmium
10
- "CR", // Chromium
11
- "NI", // Nickel
12
- "BA", // Barium
13
- "FE", // Iron
14
- "CU", // Copper
15
- "ZN", // Zinc
16
- ];
7
+ const sampleParametersEnum = Object.keys(HEAVY_METALS);
17
8
 
18
9
  // EPA IRIS chronic inhalation reference concentrations (µg/m³)
19
10
  // null = no established inhalation RfC
20
- const sampleParameterReferenceConcentrations = {
21
- C6H6: 30,
22
- PB: 0,
23
- AS: 0.03,
24
- CD: 0.01,
25
- CR: 0.1,
26
- NI: null,
27
- BA: null,
28
- FE: null,
29
- CU: null,
30
- ZN: null,
31
- };
11
+ const sampleParameterReferenceConcentrations = Object.fromEntries(
12
+ Object.entries(HEAVY_METALS).map(([key, p]) => [key, p.rfc])
13
+ );
32
14
 
33
15
  const noteSchema = mongoose.Schema({
34
16
  note: {
@@ -1,20 +1,11 @@
1
1
  import mongoose from "mongoose";
2
+ import { HEAVY_METALS } from "../constants/pollutants.js";
2
3
 
3
4
  // EPA IRIS chronic inhalation reference concentrations (µg/m³)
4
5
  // null = no established inhalation RfC
5
- // Moved here from sampleSites.js because reference concentrations are directly related to sample validation and comparison logic, not site metadata. Centralizing them in the samples model improves maintainability and keeps sample-related constants together.
6
- const sampleParameterReferenceConcentrations = {
7
- C6H6: 30,
8
- PB: 0,
9
- AS: 0.03,
10
- CD: 0.01,
11
- CR: 0.1,
12
- NI: null,
13
- BA: null,
14
- FE: null,
15
- CU: null,
16
- ZN: null,
17
- };
6
+ const sampleParameterReferenceConcentrations = Object.fromEntries(
7
+ Object.entries(HEAVY_METALS).map(([key, p]) => [key, p.rfc])
8
+ );
18
9
 
19
10
  // Samples Audit Schema
20
11
  const samplesAuditSchema = mongoose.Schema(