@justair/justair-library 5.0.0-alpha.56f07df → 5.0.0-alpha.c16a87f
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/README.md +1 -1
- package/dist/constants/pollutants.d.ts +15 -14
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/models/measurements.d.ts.map +1 -1
- package/dist/models/monitors.d.ts +0 -1
- package/dist/models/monitors.d.ts.map +1 -1
- package/dist/models/sampleSites.d.ts +0 -3
- package/dist/models/sampleSites.d.ts.map +1 -1
- package/dist/models/samples.d.ts.map +1 -1
- package/dist/models/sites.d.ts +3 -0
- package/dist/models/sites.d.ts.map +1 -0
- package/dist/models/tests/sampleSites.test.d.ts +2 -0
- package/dist/models/tests/sampleSites.test.d.ts.map +1 -0
- package/dist/models/tests/samples.test.d.ts +2 -0
- package/dist/models/tests/samples.test.d.ts.map +1 -0
- package/dist/models/tests/sites.test.d.ts +2 -0
- package/dist/models/tests/sites.test.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/constants/pollutants.js +2 -3
- package/src/index.js +6 -2
- package/src/models/measurements.js +0 -6
- package/src/models/monitors.js +6 -11
- package/src/models/sampleSites.js +5 -13
- package/src/models/samples.js +7 -7
- package/src/models/sites.js +55 -0
package/README.md
CHANGED
|
@@ -353,7 +353,7 @@ export namespace PARAMETERS {
|
|
|
353
353
|
}
|
|
354
354
|
}
|
|
355
355
|
export namespace HEAVY_METALS {
|
|
356
|
-
namespace C6H6 {
|
|
356
|
+
export namespace C6H6 {
|
|
357
357
|
let id_20: string;
|
|
358
358
|
export { id_20 as id };
|
|
359
359
|
let label_20: string;
|
|
@@ -371,7 +371,7 @@ export namespace HEAVY_METALS {
|
|
|
371
371
|
let impacts_20: string;
|
|
372
372
|
export { impacts_20 as impacts };
|
|
373
373
|
}
|
|
374
|
-
namespace AS {
|
|
374
|
+
export namespace AS {
|
|
375
375
|
let id_21: string;
|
|
376
376
|
export { id_21 as id };
|
|
377
377
|
let label_21: string;
|
|
@@ -389,7 +389,7 @@ export namespace HEAVY_METALS {
|
|
|
389
389
|
let impacts_21: string;
|
|
390
390
|
export { impacts_21 as impacts };
|
|
391
391
|
}
|
|
392
|
-
namespace BA {
|
|
392
|
+
export namespace BA {
|
|
393
393
|
let id_22: string;
|
|
394
394
|
export { id_22 as id };
|
|
395
395
|
let label_22: string;
|
|
@@ -407,7 +407,7 @@ export namespace HEAVY_METALS {
|
|
|
407
407
|
let impacts_22: string;
|
|
408
408
|
export { impacts_22 as impacts };
|
|
409
409
|
}
|
|
410
|
-
namespace BE {
|
|
410
|
+
export namespace BE {
|
|
411
411
|
let id_23: string;
|
|
412
412
|
export { id_23 as id };
|
|
413
413
|
let label_23: string;
|
|
@@ -425,7 +425,7 @@ export namespace HEAVY_METALS {
|
|
|
425
425
|
let impacts_23: string;
|
|
426
426
|
export { impacts_23 as impacts };
|
|
427
427
|
}
|
|
428
|
-
namespace
|
|
428
|
+
export namespace CO_1 {
|
|
429
429
|
let id_24: string;
|
|
430
430
|
export { id_24 as id };
|
|
431
431
|
let label_24: string;
|
|
@@ -443,7 +443,8 @@ export namespace HEAVY_METALS {
|
|
|
443
443
|
let impacts_24: string;
|
|
444
444
|
export { impacts_24 as impacts };
|
|
445
445
|
}
|
|
446
|
-
|
|
446
|
+
export { CO_1 as CO };
|
|
447
|
+
export namespace NI {
|
|
447
448
|
let id_25: string;
|
|
448
449
|
export { id_25 as id };
|
|
449
450
|
let label_25: string;
|
|
@@ -461,7 +462,7 @@ export namespace HEAVY_METALS {
|
|
|
461
462
|
let impacts_25: string;
|
|
462
463
|
export { impacts_25 as impacts };
|
|
463
464
|
}
|
|
464
|
-
namespace CD {
|
|
465
|
+
export namespace CD {
|
|
465
466
|
let id_26: string;
|
|
466
467
|
export { id_26 as id };
|
|
467
468
|
let label_26: string;
|
|
@@ -479,7 +480,7 @@ export namespace HEAVY_METALS {
|
|
|
479
480
|
let impacts_26: string;
|
|
480
481
|
export { impacts_26 as impacts };
|
|
481
482
|
}
|
|
482
|
-
namespace CR {
|
|
483
|
+
export namespace CR {
|
|
483
484
|
let id_27: string;
|
|
484
485
|
export { id_27 as id };
|
|
485
486
|
let label_27: string;
|
|
@@ -497,7 +498,7 @@ export namespace HEAVY_METALS {
|
|
|
497
498
|
let impacts_27: string;
|
|
498
499
|
export { impacts_27 as impacts };
|
|
499
500
|
}
|
|
500
|
-
namespace PB {
|
|
501
|
+
export namespace PB {
|
|
501
502
|
let id_28: string;
|
|
502
503
|
export { id_28 as id };
|
|
503
504
|
let label_28: string;
|
|
@@ -515,7 +516,7 @@ export namespace HEAVY_METALS {
|
|
|
515
516
|
let impacts_28: string;
|
|
516
517
|
export { impacts_28 as impacts };
|
|
517
518
|
}
|
|
518
|
-
namespace FE {
|
|
519
|
+
export namespace FE {
|
|
519
520
|
let id_29: string;
|
|
520
521
|
export { id_29 as id };
|
|
521
522
|
let label_29: string;
|
|
@@ -533,7 +534,7 @@ export namespace HEAVY_METALS {
|
|
|
533
534
|
let impacts_29: string;
|
|
534
535
|
export { impacts_29 as impacts };
|
|
535
536
|
}
|
|
536
|
-
namespace MN {
|
|
537
|
+
export namespace MN {
|
|
537
538
|
let id_30: string;
|
|
538
539
|
export { id_30 as id };
|
|
539
540
|
let label_30: string;
|
|
@@ -551,7 +552,7 @@ export namespace HEAVY_METALS {
|
|
|
551
552
|
let impacts_30: string;
|
|
552
553
|
export { impacts_30 as impacts };
|
|
553
554
|
}
|
|
554
|
-
namespace SE {
|
|
555
|
+
export namespace SE {
|
|
555
556
|
let id_31: string;
|
|
556
557
|
export { id_31 as id };
|
|
557
558
|
let label_31: string;
|
|
@@ -569,7 +570,7 @@ export namespace HEAVY_METALS {
|
|
|
569
570
|
let impacts_31: string;
|
|
570
571
|
export { impacts_31 as impacts };
|
|
571
572
|
}
|
|
572
|
-
namespace CU {
|
|
573
|
+
export namespace CU {
|
|
573
574
|
let id_32: string;
|
|
574
575
|
export { id_32 as id };
|
|
575
576
|
let label_32: string;
|
|
@@ -587,7 +588,7 @@ export namespace HEAVY_METALS {
|
|
|
587
588
|
let impacts_32: string;
|
|
588
589
|
export { impacts_32 as impacts };
|
|
589
590
|
}
|
|
590
|
-
namespace ZN {
|
|
591
|
+
export namespace ZN {
|
|
591
592
|
let id_33: string;
|
|
592
593
|
export { id_33 as id };
|
|
593
594
|
let label_33: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -43,7 +43,6 @@ import { eventsAuditSchema } from "./models/events.js";
|
|
|
43
43
|
import { MonitorAudit } from "./models/monitors.js";
|
|
44
44
|
import { monitorAuditSchema } from "./models/monitors.js";
|
|
45
45
|
import { parametersEnum } from "./models/monitors.js";
|
|
46
|
-
import { legacyParametersEnum } from "./models/monitors.js";
|
|
47
46
|
import { deploymentTypesEnum } from "./models/monitors.js";
|
|
48
47
|
import { AlertsAudit } from "./models/alerts.js";
|
|
49
48
|
import { Alerts } from "./models/alerts.js";
|
|
@@ -57,6 +56,8 @@ import { networkMetricsSchema } from "./models/networkMetrics.js";
|
|
|
57
56
|
import { NetworkMetrics } from "./models/networkMetrics.js";
|
|
58
57
|
import { rateOfChangeSchema } from "./models/rateOfChange.js";
|
|
59
58
|
import { RateOfChange } from "./models/rateOfChange.js";
|
|
59
|
+
import { sitesSchema } from "./models/sites.js";
|
|
60
|
+
import { Sites } from "./models/sites.js";
|
|
60
61
|
import { sampleSitesSchema } from "./models/sampleSites.js";
|
|
61
62
|
import { SampleSites } from "./models/sampleSites.js";
|
|
62
63
|
import { sampleSiteAuditSchema } from "./models/sampleSites.js";
|
|
@@ -69,5 +70,5 @@ import { SamplesAudit } from "./models/samples.js";
|
|
|
69
70
|
import { sampleParameterReferenceConcentrations } from "./models/samples.js";
|
|
70
71
|
import { PARAMETERS } from "./constants/pollutants.js";
|
|
71
72
|
import { HEAVY_METALS } from "./constants/pollutants.js";
|
|
72
|
-
export { Database, adminSchema, Admin, configurationsSchema, Configurations, measurementsSchema, Measurements, monitorRequestsSchema, MonitorRequests, monitorsSchema, Monitors, organizationsSchema, Organizations, usersSchema, Users, eventsSchema, Events, lightMonitorSchema, LightMonitors, monitorSuppliersSchema, MonitorSuppliers, contextsSchema, Contexts, parametersSchema, Parameters, announcementSchema, Announcements, jobsSchema, Jobs, apiKeySchema, ApiKey, UsageMetrics, usageMetricsSchema, Audit, auditSchema, EventsAudit, eventsAuditSchema, MonitorAudit, monitorAuditSchema, parametersEnum,
|
|
73
|
+
export { Database, adminSchema, Admin, configurationsSchema, Configurations, measurementsSchema, Measurements, monitorRequestsSchema, MonitorRequests, monitorsSchema, Monitors, organizationsSchema, Organizations, usersSchema, Users, eventsSchema, Events, lightMonitorSchema, LightMonitors, monitorSuppliersSchema, MonitorSuppliers, contextsSchema, Contexts, parametersSchema, Parameters, announcementSchema, Announcements, jobsSchema, Jobs, apiKeySchema, ApiKey, UsageMetrics, usageMetricsSchema, Audit, auditSchema, EventsAudit, eventsAuditSchema, MonitorAudit, monitorAuditSchema, parametersEnum, deploymentTypesEnum, AlertsAudit, Alerts, alertsSchema, alertsAuditSchema, Features, featuresSchema, dataCompletenessSchema, DataCompleteness, networkMetricsSchema, NetworkMetrics, rateOfChangeSchema, RateOfChange, sitesSchema, Sites, sampleSitesSchema, SampleSites, sampleSiteAuditSchema, SampleSiteAudit, sampleParametersEnum, samplesSchema, Samples, samplesAuditSchema, SamplesAudit, sampleParameterReferenceConcentrations, PARAMETERS, HEAVY_METALS };
|
|
73
74
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAgFA;;;iBAEC;yBA1BwB,oBAAoB;qBADxB,gBAAgB;4BAvDF,mBAAmB;sBAAnB,mBAAmB;qCAI/C,4BAA4B;+BAA5B,4BAA4B;mCAM5B,0BAA0B;6BAA1B,0BAA0B;sCAI1B,6BAA6B;gCAA7B,6BAA6B;+BAQ7B,sBAAsB;yBAAtB,sBAAsB;oCACsB,2BAA2B;8BAA3B,2BAA2B;4BAQ3C,mBAAmB;sBAAnB,mBAAmB;6BAM/C,oBAAoB;uBAApB,oBAAoB;mCAbuB,2BAA2B;8BAA3B,2BAA2B;uCAItE,8BAA8B;iCAA9B,8BAA8B;+BACI,sBAAsB;yBAAtB,sBAAsB;iCAClB,wBAAwB;2BAAxB,wBAAwB;mCAQnB,2BAA2B;8BAA3B,2BAA2B;2BAC5C,kBAAkB;qBAAlB,kBAAkB;6BACd,oBAAoB;uBAApB,oBAAoB;6BACR,0BAA0B;mCAA1B,0BAA0B;sBA/BpE,0BAA0B;4BAA1B,0BAA0B;4BA2B1B,oBAAoB;kCAApB,oBAAoB;6BAfpB,sBAAsB;mCAAtB,sBAAsB;+BAAtB,sBAAsB;oCAAtB,sBAAsB;4BAyBtB,oBAAoB;uBAApB,oBAAoB;6BAApB,oBAAoB;kCAApB,oBAAoB;yBACc,sBAAsB;+BAAtB,sBAAsB;uCAIxD,8BAA8B;iCAA9B,8BAA8B;qCACgB,4BAA4B;+BAA5B,4BAA4B;mCAChC,0BAA0B;6BAA1B,0BAA0B;4BAMxC,mBAAmB;sBAAnB,mBAAmB;kCAS/C,yBAAyB;4BAAzB,yBAAyB;sCAAzB,yBAAyB;gCAAzB,yBAAyB;qCAAzB,yBAAyB;8BASzB,qBAAqB;wBAArB,qBAAqB;mCAArB,qBAAqB;6BAArB,qBAAqB;uDAArB,qBAAqB;2BArBa,2BAA2B;6BAA3B,2BAA2B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"measurements.d.ts","sourceRoot":"","sources":["../../src/models/measurements.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"measurements.d.ts","sourceRoot":"","sources":["../../src/models/measurements.js"],"names":[],"mappings":"AA8FA,qCA0BE;AA2IF,+BAAwE;AAxKxE,wBAAmD;AAzBnD,8BAuBE;AAjEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCE;qBA5DmB,UAAU"}
|
|
@@ -3,7 +3,6 @@ export const Monitors: any;
|
|
|
3
3
|
export const monitorAuditSchema: any;
|
|
4
4
|
export const MonitorAudit: any;
|
|
5
5
|
export const parametersEnum: string[];
|
|
6
|
-
export const legacyParametersEnum: string[];
|
|
7
6
|
export namespace deploymentTypesEnum {
|
|
8
7
|
let STATIONARY: string;
|
|
9
8
|
let MOBILE: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monitors.d.ts","sourceRoot":"","sources":["../../src/models/monitors.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"monitors.d.ts","sourceRoot":"","sources":["../../src/models/monitors.js"],"names":[],"mappings":"AA6JA,iCA8HE;AAuIF,2BAA4D;AAvS5D,qCA4BE;AAGF,+BAAwE;AAvJxE,sCAAoD"}
|
|
@@ -3,7 +3,4 @@ export const SampleSites: any;
|
|
|
3
3
|
export const sampleSiteAuditSchema: any;
|
|
4
4
|
export const SampleSiteAudit: any;
|
|
5
5
|
export const sampleParametersEnum: string[];
|
|
6
|
-
export const sampleParameterReferenceConcentrations: {
|
|
7
|
-
[k: string]: any;
|
|
8
|
-
};
|
|
9
6
|
//# sourceMappingURL=sampleSites.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sampleSites.d.ts","sourceRoot":"","sources":["../../src/models/sampleSites.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sampleSites.d.ts","sourceRoot":"","sources":["../../src/models/sampleSites.js"],"names":[],"mappings":"AAsDA,oCAuDE;AAqJF,8BAAqE;AAlOrE,wCAgBE;AAGF,kCAAiF;AA7CjF,4CAAuD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"samples.d.ts","sourceRoot":"","sources":["../../src/models/samples.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"samples.d.ts","sourceRoot":"","sources":["../../src/models/samples.js"],"names":[],"mappings":"AAqCA,gCAmBE;AAkIF,0BAAyD;AAxJzD,+BAAwE;AAxBxE,qCAqBE;AA1BF;;EAEE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sites.d.ts","sourceRoot":"","sources":["../../src/models/sites.js"],"names":[],"mappings":"AAGA,8BAoCE;AAaF,wBAAmD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sampleSites.test.d.ts","sourceRoot":"","sources":["../../../src/models/tests/sampleSites.test.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"samples.test.d.ts","sourceRoot":"","sources":["../../../src/models/tests/samples.test.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sites.test.d.ts","sourceRoot":"","sources":["../../../src/models/tests/sites.test.js"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -205,7 +205,6 @@ export const PARAMETERS = {
|
|
|
205
205
|
|
|
206
206
|
// Parameters analyzed from physical air samples in a laboratory.
|
|
207
207
|
// These correspond to SampleSites.parameters and are not measured by real-time sensors.
|
|
208
|
-
// Note: Cobalt uses the key COBALT (not CO) to avoid collision with PARAMETERS.CO (Carbon Monoxide).
|
|
209
208
|
export const HEAVY_METALS = {
|
|
210
209
|
C6H6: {
|
|
211
210
|
id: "C6H6",
|
|
@@ -247,8 +246,8 @@ export const HEAVY_METALS = {
|
|
|
247
246
|
origin: "Beryllium occurs naturally in rocks, soil, coal, and oil. It gets into the air through mining and industrial processing, burning coal or fuel oil, and tobacco smoke.",
|
|
248
247
|
impacts: "Short-term exposure to high levels can cause lung inflammation, coughing, and difficulty breathing. Long-term exposure can cause permanent lung scarring, reduced lung capacity, shortness of breath, and fatigue. It has also been linked to an increased risk of lung cancer.",
|
|
249
248
|
},
|
|
250
|
-
|
|
251
|
-
id: "
|
|
249
|
+
CO: {
|
|
250
|
+
id: "CO",
|
|
252
251
|
label: "Cobalt",
|
|
253
252
|
name: "Cobalt (Co)",
|
|
254
253
|
unit: "µg/m³",
|
package/src/index.js
CHANGED
|
@@ -19,7 +19,6 @@ import {
|
|
|
19
19
|
monitorAuditSchema,
|
|
20
20
|
MonitorAudit,
|
|
21
21
|
parametersEnum,
|
|
22
|
-
legacyParametersEnum,
|
|
23
22
|
deploymentTypesEnum,
|
|
24
23
|
} from "./models/monitors.js";
|
|
25
24
|
import { organizationsSchema, Organizations } from "./models/organizations.js";
|
|
@@ -58,6 +57,9 @@ import Database from "./config/db.js"; // Import the new Database class
|
|
|
58
57
|
import CustomLogger from "./config/logger.js";
|
|
59
58
|
import { PARAMETERS, HEAVY_METALS } from "./constants/pollutants.js";
|
|
60
59
|
|
|
60
|
+
// Sites related imports
|
|
61
|
+
import { sitesSchema, Sites } from "./models/sites.js";
|
|
62
|
+
|
|
61
63
|
// SampleSites related imports
|
|
62
64
|
import {
|
|
63
65
|
sampleSitesSchema,
|
|
@@ -121,7 +123,6 @@ export {
|
|
|
121
123
|
MonitorAudit,
|
|
122
124
|
monitorAuditSchema,
|
|
123
125
|
parametersEnum,
|
|
124
|
-
legacyParametersEnum,
|
|
125
126
|
deploymentTypesEnum,
|
|
126
127
|
AlertsAudit,
|
|
127
128
|
Alerts,
|
|
@@ -135,6 +136,9 @@ export {
|
|
|
135
136
|
NetworkMetrics,
|
|
136
137
|
rateOfChangeSchema,
|
|
137
138
|
RateOfChange,
|
|
139
|
+
// Sites related exports
|
|
140
|
+
sitesSchema,
|
|
141
|
+
Sites,
|
|
138
142
|
// SampleSites related exports
|
|
139
143
|
sampleSitesSchema,
|
|
140
144
|
SampleSites,
|
|
@@ -83,7 +83,6 @@ const auditSchema = mongoose.Schema(
|
|
|
83
83
|
},
|
|
84
84
|
annotations: [annotationSchema], // Include annotations in audit trail
|
|
85
85
|
isCorrected: { type: Boolean },
|
|
86
|
-
isFog: { type: Boolean },
|
|
87
86
|
},
|
|
88
87
|
{
|
|
89
88
|
timestamps: true,
|
|
@@ -139,7 +138,6 @@ measurementsSchema.index({ "annotations.userId": 1 });
|
|
|
139
138
|
measurementsSchema.pre("findOneAndDelete", async function () {
|
|
140
139
|
const docToDelete = await this.model.findOne(this.getFilter());
|
|
141
140
|
if (docToDelete) {
|
|
142
|
-
console.log("Logging findOneAndDelete to audit", docToDelete);
|
|
143
141
|
const auditLog = new Audit({
|
|
144
142
|
monitorId: docToDelete.monitorId,
|
|
145
143
|
orgId: docToDelete.orgId,
|
|
@@ -190,11 +188,9 @@ measurementsSchema.pre("deleteMany", async function () {
|
|
|
190
188
|
|
|
191
189
|
// Pre-hook to log a single document deletion (for deleteOne)
|
|
192
190
|
measurementsSchema.pre("deleteOne", async function () {
|
|
193
|
-
console.log("deleteOne pre-hook triggered");
|
|
194
191
|
const docToDelete = await this.model.findOne(this.getFilter()).lean();
|
|
195
192
|
|
|
196
193
|
if (docToDelete) {
|
|
197
|
-
console.log("Logging deleteOne to audit", docToDelete);
|
|
198
194
|
const auditLog = new Audit({
|
|
199
195
|
monitorId: docToDelete.monitorId,
|
|
200
196
|
orgId: docToDelete.orgId,
|
|
@@ -218,7 +214,6 @@ measurementsSchema.pre("deleteOne", async function () {
|
|
|
218
214
|
measurementsSchema.pre("findOneAndUpdate", async function () {
|
|
219
215
|
const docToUpdate = await this.model.findOne(this.getFilter()).lean();
|
|
220
216
|
if (docToUpdate) {
|
|
221
|
-
console.log("Logging findOneAndUpdate to audit", docToUpdate);
|
|
222
217
|
const auditLog = new Audit({
|
|
223
218
|
monitorId: docToUpdate.monitorId,
|
|
224
219
|
orgId: docToUpdate.orgId,
|
|
@@ -242,7 +237,6 @@ measurementsSchema.pre("findOneAndUpdate", async function () {
|
|
|
242
237
|
measurementsSchema.pre("updateMany", async function () {
|
|
243
238
|
const docsToUpdate = await this.model.find(this.getFilter()).lean();
|
|
244
239
|
if (docsToUpdate.length) {
|
|
245
|
-
console.log(`Logging ${docsToUpdate.length} documents to audit`);
|
|
246
240
|
const auditLogs = docsToUpdate.map((doc) => ({
|
|
247
241
|
monitorId: doc.monitorId,
|
|
248
242
|
orgId: doc.orgId,
|
package/src/models/monitors.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import mongoose from "mongoose";
|
|
2
2
|
import { PARAMETERS } from "../constants/pollutants.js";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
const legacyParametersEnum = ["PM2.5", "Temperature", "Humidity", "OZONE", "WS And Direction"];
|
|
6
|
-
|
|
7
|
-
const parametersEnum = [...Object.keys(PARAMETERS), ...legacyParametersEnum];
|
|
4
|
+
const parametersEnum = [...Object.keys(PARAMETERS)];
|
|
8
5
|
|
|
9
6
|
const deploymentTypesEnum = {
|
|
10
7
|
STATIONARY: "stationary",
|
|
@@ -272,6 +269,10 @@ const monitorsSchema = mongoose.Schema(
|
|
|
272
269
|
enum: Object.values(deploymentTypesEnum),
|
|
273
270
|
default: deploymentTypesEnum.STATIONARY,
|
|
274
271
|
},
|
|
272
|
+
siteId: {
|
|
273
|
+
type: mongoose.Types.ObjectId,
|
|
274
|
+
ref: "Sites",
|
|
275
|
+
},
|
|
275
276
|
// Optional Clarity node ID (1:1 relationship with Node-S sensor)
|
|
276
277
|
nodeId: { type: String },
|
|
277
278
|
// Active alarms from Clarity node (keyed by alarmType)
|
|
@@ -308,7 +309,6 @@ monitorsSchema.index({ deploymentType: 1 });
|
|
|
308
309
|
monitorsSchema.pre("findOneAndDelete", async function () {
|
|
309
310
|
const docToDelete = await this.model.findOne(this.getFilter()).lean();
|
|
310
311
|
if (docToDelete) {
|
|
311
|
-
console.log("Logging findOneAndDelete to monitor audit", docToDelete);
|
|
312
312
|
const auditLog = new MonitorAudit({
|
|
313
313
|
monitorId: docToDelete._id,
|
|
314
314
|
orgId: docToDelete.sponsor,
|
|
@@ -335,11 +335,9 @@ monitorsSchema.pre("findOneAndDelete", async function () {
|
|
|
335
335
|
|
|
336
336
|
// Pre-hook to log multiple document deletions
|
|
337
337
|
monitorsSchema.pre("deleteMany", async function () {
|
|
338
|
-
console.log("deleteMany pre-hook triggered for monitors");
|
|
339
338
|
const docsToDelete = await this.model.find(this.getFilter()).lean();
|
|
340
339
|
|
|
341
340
|
if (docsToDelete.length) {
|
|
342
|
-
console.log(`Logging ${docsToDelete.length} monitor documents to audit`);
|
|
343
341
|
const auditLogs = docsToDelete.map((doc) => ({
|
|
344
342
|
monitorId: doc._id,
|
|
345
343
|
orgId: doc.sponsor,
|
|
@@ -364,11 +362,9 @@ monitorsSchema.pre("deleteMany", async function () {
|
|
|
364
362
|
|
|
365
363
|
// Pre-hook to log a single document deletion (for deleteOne)
|
|
366
364
|
monitorsSchema.pre("deleteOne", async function () {
|
|
367
|
-
console.log("deleteOne pre-hook triggered for monitors");
|
|
368
365
|
const docToDelete = await this.model.findOne(this.getFilter()).lean();
|
|
369
366
|
|
|
370
367
|
if (docToDelete) {
|
|
371
|
-
console.log("Logging deleteOne to monitor audit", docToDelete);
|
|
372
368
|
const auditLog = new MonitorAudit({
|
|
373
369
|
monitorId: docToDelete._id,
|
|
374
370
|
orgId: docToDelete.sponsor,
|
|
@@ -397,7 +393,6 @@ monitorsSchema.pre("deleteOne", async function () {
|
|
|
397
393
|
monitorsSchema.pre("updateMany", async function () {
|
|
398
394
|
const docsToUpdate = await this.model.find(this.getFilter()).lean();
|
|
399
395
|
if (docsToUpdate.length) {
|
|
400
|
-
console.log(`Logging ${docsToUpdate.length} monitor documents to audit`);
|
|
401
396
|
const auditLogs = docsToUpdate.map((doc) => ({
|
|
402
397
|
monitorId: doc._id,
|
|
403
398
|
orgId: doc.sponsor,
|
|
@@ -423,4 +418,4 @@ monitorsSchema.pre("updateMany", async function () {
|
|
|
423
418
|
// Create the Monitors model
|
|
424
419
|
const Monitors = mongoose.model("Monitors", monitorsSchema);
|
|
425
420
|
|
|
426
|
-
export { monitorsSchema, Monitors, monitorAuditSchema, MonitorAudit, parametersEnum,
|
|
421
|
+
export { monitorsSchema, Monitors, monitorAuditSchema, MonitorAudit, parametersEnum, deploymentTypesEnum };
|
|
@@ -6,12 +6,6 @@ const generateSiteCode = customAlphabet('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 8);
|
|
|
6
6
|
|
|
7
7
|
const sampleParametersEnum = Object.keys(HEAVY_METALS);
|
|
8
8
|
|
|
9
|
-
// EPA IRIS chronic inhalation reference concentrations (µg/m³)
|
|
10
|
-
// null = no established inhalation RfC
|
|
11
|
-
const sampleParameterReferenceConcentrations = Object.fromEntries(
|
|
12
|
-
Object.entries(HEAVY_METALS).map(([key, p]) => [key, p.rfc])
|
|
13
|
-
);
|
|
14
|
-
|
|
15
9
|
const noteSchema = mongoose.Schema({
|
|
16
10
|
note: {
|
|
17
11
|
type: String,
|
|
@@ -105,6 +99,10 @@ const sampleSitesSchema = mongoose.Schema(
|
|
|
105
99
|
],
|
|
106
100
|
notes: { type: [noteSchema] },
|
|
107
101
|
image: { type: String },
|
|
102
|
+
siteId: {
|
|
103
|
+
type: mongoose.Types.ObjectId,
|
|
104
|
+
ref: "Sites",
|
|
105
|
+
},
|
|
108
106
|
},
|
|
109
107
|
{
|
|
110
108
|
timestamps: true,
|
|
@@ -139,7 +137,6 @@ sampleSitesSchema.index({ parameters: 1 });
|
|
|
139
137
|
sampleSitesSchema.pre("findOneAndDelete", async function () {
|
|
140
138
|
const docToDelete = await this.model.findOne(this.getFilter()).lean();
|
|
141
139
|
if (docToDelete) {
|
|
142
|
-
console.log("Logging findOneAndDelete to sample site audit", docToDelete);
|
|
143
140
|
let coordinates = null;
|
|
144
141
|
if (docToDelete.location && docToDelete.location.gps && Array.isArray(docToDelete.location.gps.coordinates)) {
|
|
145
142
|
coordinates = docToDelete.location.gps.coordinates;
|
|
@@ -165,11 +162,9 @@ sampleSitesSchema.pre("findOneAndDelete", async function () {
|
|
|
165
162
|
|
|
166
163
|
// Pre-hook to log multiple document deletions
|
|
167
164
|
sampleSitesSchema.pre("deleteMany", async function () {
|
|
168
|
-
console.log("deleteMany pre-hook triggered for sample sites");
|
|
169
165
|
const docsToDelete = await this.model.find(this.getFilter()).lean();
|
|
170
166
|
|
|
171
167
|
if (docsToDelete.length) {
|
|
172
|
-
console.log(`Logging ${docsToDelete.length} sample site documents to audit`);
|
|
173
168
|
const auditLogs = docsToDelete.map((doc) => {
|
|
174
169
|
let coordinates = null;
|
|
175
170
|
if (doc.location && doc.location.gps && Array.isArray(doc.location.gps.coordinates)) {
|
|
@@ -201,11 +196,9 @@ sampleSitesSchema.pre("deleteMany", async function () {
|
|
|
201
196
|
|
|
202
197
|
// Pre-hook to log a single document deletion (for deleteOne)
|
|
203
198
|
sampleSitesSchema.pre("deleteOne", async function () {
|
|
204
|
-
console.log("deleteOne pre-hook triggered for sample sites");
|
|
205
199
|
const docToDelete = await this.model.findOne(this.getFilter()).lean();
|
|
206
200
|
|
|
207
201
|
if (docToDelete) {
|
|
208
|
-
console.log("Logging deleteOne to sample site audit", docToDelete);
|
|
209
202
|
let coordinates = null;
|
|
210
203
|
if (docToDelete.location && docToDelete.location.gps && Array.isArray(docToDelete.location.gps.coordinates)) {
|
|
211
204
|
coordinates = docToDelete.location.gps.coordinates;
|
|
@@ -233,7 +226,6 @@ sampleSitesSchema.pre("deleteOne", async function () {
|
|
|
233
226
|
sampleSitesSchema.pre("updateMany", async function () {
|
|
234
227
|
const docsToUpdate = await this.model.find(this.getFilter()).lean();
|
|
235
228
|
if (docsToUpdate.length) {
|
|
236
|
-
console.log(`Logging ${docsToUpdate.length} sample site documents to audit`);
|
|
237
229
|
const auditLogs = docsToUpdate.map((doc) => {
|
|
238
230
|
let coordinates = null;
|
|
239
231
|
if (doc.location && doc.location.gps && Array.isArray(doc.location.gps.coordinates)) {
|
|
@@ -266,4 +258,4 @@ sampleSitesSchema.pre("updateMany", async function () {
|
|
|
266
258
|
// Create the SampleSites model
|
|
267
259
|
const SampleSites = mongoose.model("SampleSites", sampleSitesSchema);
|
|
268
260
|
|
|
269
|
-
export { sampleSitesSchema, SampleSites, sampleSiteAuditSchema, SampleSiteAudit, sampleParametersEnum
|
|
261
|
+
export { sampleSitesSchema, SampleSites, sampleSiteAuditSchema, SampleSiteAudit, sampleParametersEnum };
|
package/src/models/samples.js
CHANGED
|
@@ -12,6 +12,7 @@ const samplesAuditSchema = mongoose.Schema(
|
|
|
12
12
|
{
|
|
13
13
|
siteId: { type: mongoose.Types.ObjectId, ref: "SampleSites" },
|
|
14
14
|
orgId: { type: mongoose.Types.ObjectId, ref: "Organizations" },
|
|
15
|
+
filterId: { type: String },
|
|
15
16
|
siteCode: { type: String }, // reference to SampleSites.code
|
|
16
17
|
periodStartDate: { type: Date },
|
|
17
18
|
periodEndDate: { type: Date },
|
|
@@ -38,6 +39,7 @@ const samplesSchema = mongoose.Schema(
|
|
|
38
39
|
{
|
|
39
40
|
siteId: { type: mongoose.Types.ObjectId, ref: "SampleSites" },
|
|
40
41
|
orgId: { type: mongoose.Types.ObjectId, ref: "Organizations" },
|
|
42
|
+
filterId: { type: String },
|
|
41
43
|
siteCode: { type: String }, // reference to SampleSites.code
|
|
42
44
|
periodStartDate: { type: Date },
|
|
43
45
|
periodEndDate: { type: Date },
|
|
@@ -65,10 +67,10 @@ samplesSchema.index({ siteId: 1, uploadDate: -1 });
|
|
|
65
67
|
samplesSchema.pre("findOneAndDelete", async function () {
|
|
66
68
|
const docToDelete = await this.model.findOne(this.getFilter()).lean();
|
|
67
69
|
if (docToDelete) {
|
|
68
|
-
console.log("Logging findOneAndDelete to audit", docToDelete);
|
|
69
70
|
const auditLog = new SamplesAudit({
|
|
70
71
|
siteId: docToDelete.siteId,
|
|
71
72
|
orgId: docToDelete.orgId,
|
|
73
|
+
filterId: docToDelete.filterId,
|
|
72
74
|
siteCode: docToDelete.siteCode,
|
|
73
75
|
periodStartDate: docToDelete.periodStartDate,
|
|
74
76
|
periodEndDate: docToDelete.periodEndDate,
|
|
@@ -87,13 +89,12 @@ samplesSchema.pre("findOneAndDelete", async function () {
|
|
|
87
89
|
|
|
88
90
|
// Pre-hook to log multiple document deletions
|
|
89
91
|
samplesSchema.pre("deleteMany", async function () {
|
|
90
|
-
console.log("deleteMany pre-hook triggered");
|
|
91
92
|
const docsToDelete = await this.model.find(this.getFilter()).lean();
|
|
92
93
|
if (docsToDelete.length) {
|
|
93
|
-
console.log(`Logging ${docsToDelete.length} documents to audit`);
|
|
94
94
|
const auditLogs = docsToDelete.map((doc) => ({
|
|
95
95
|
siteId: doc.siteId,
|
|
96
96
|
orgId: doc.orgId,
|
|
97
|
+
filterId: doc.filterId,
|
|
97
98
|
siteCode: doc.siteCode,
|
|
98
99
|
periodStartDate: doc.periodStartDate,
|
|
99
100
|
periodEndDate: doc.periodEndDate,
|
|
@@ -112,13 +113,12 @@ samplesSchema.pre("deleteMany", async function () {
|
|
|
112
113
|
|
|
113
114
|
// Pre-hook to log a single document deletion (for deleteOne)
|
|
114
115
|
samplesSchema.pre("deleteOne", async function () {
|
|
115
|
-
console.log("deleteOne pre-hook triggered");
|
|
116
116
|
const docToDelete = await this.model.findOne(this.getFilter()).lean();
|
|
117
117
|
if (docToDelete) {
|
|
118
|
-
console.log("Logging deleteOne to audit", docToDelete);
|
|
119
118
|
const auditLog = new SamplesAudit({
|
|
120
119
|
siteId: docToDelete.siteId,
|
|
121
120
|
orgId: docToDelete.orgId,
|
|
121
|
+
filterId: docToDelete.filterId,
|
|
122
122
|
siteCode: docToDelete.siteCode,
|
|
123
123
|
periodStartDate: docToDelete.periodStartDate,
|
|
124
124
|
periodEndDate: docToDelete.periodEndDate,
|
|
@@ -139,10 +139,10 @@ samplesSchema.pre("deleteOne", async function () {
|
|
|
139
139
|
samplesSchema.pre("findOneAndUpdate", async function () {
|
|
140
140
|
const docToUpdate = await this.model.findOne(this.getFilter()).lean();
|
|
141
141
|
if (docToUpdate) {
|
|
142
|
-
console.log("Logging findOneAndUpdate to audit", docToUpdate);
|
|
143
142
|
const auditLog = new SamplesAudit({
|
|
144
143
|
siteId: docToUpdate.siteId,
|
|
145
144
|
orgId: docToUpdate.orgId,
|
|
145
|
+
filterId: docToUpdate.filterId,
|
|
146
146
|
siteCode: docToUpdate.siteCode,
|
|
147
147
|
periodStartDate: docToUpdate.periodStartDate,
|
|
148
148
|
periodEndDate: docToUpdate.periodEndDate,
|
|
@@ -163,10 +163,10 @@ samplesSchema.pre("findOneAndUpdate", async function () {
|
|
|
163
163
|
samplesSchema.pre("updateMany", async function () {
|
|
164
164
|
const docsToUpdate = await this.model.find(this.getFilter()).lean();
|
|
165
165
|
if (docsToUpdate.length) {
|
|
166
|
-
console.log(`Logging ${docsToUpdate.length} documents to audit`);
|
|
167
166
|
const auditLogs = docsToUpdate.map((doc) => ({
|
|
168
167
|
siteId: doc.siteId,
|
|
169
168
|
orgId: doc.orgId,
|
|
169
|
+
filterId: doc.filterId,
|
|
170
170
|
siteCode: doc.siteCode,
|
|
171
171
|
periodStartDate: doc.periodStartDate,
|
|
172
172
|
periodEndDate: doc.periodEndDate,
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
|
|
3
|
+
// Sites Schema
|
|
4
|
+
const sitesSchema = mongoose.Schema(
|
|
5
|
+
{
|
|
6
|
+
name: { type: String },
|
|
7
|
+
sampleSiteId: {
|
|
8
|
+
type: mongoose.Types.ObjectId,
|
|
9
|
+
ref: "SampleSites",
|
|
10
|
+
},
|
|
11
|
+
monitorIds: {
|
|
12
|
+
type: [{ type: mongoose.Types.ObjectId, ref: "Monitors" }],
|
|
13
|
+
default: undefined,
|
|
14
|
+
},
|
|
15
|
+
sponsor: { type: mongoose.Types.ObjectId, ref: "Organizations" },
|
|
16
|
+
location: {
|
|
17
|
+
city: { type: String },
|
|
18
|
+
state: { type: String },
|
|
19
|
+
county: { type: String },
|
|
20
|
+
street: { type: String },
|
|
21
|
+
zip_code: { type: String },
|
|
22
|
+
neighborhood: { type: String },
|
|
23
|
+
gps: {
|
|
24
|
+
type: {
|
|
25
|
+
type: String,
|
|
26
|
+
enum: ["Point"],
|
|
27
|
+
required: true,
|
|
28
|
+
},
|
|
29
|
+
coordinates: {
|
|
30
|
+
type: [Number],
|
|
31
|
+
required: true,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
isActive: { type: Boolean, default: true },
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
timestamps: true,
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
// Geographic queries
|
|
43
|
+
sitesSchema.index({ "location.gps": "2dsphere" });
|
|
44
|
+
|
|
45
|
+
// Sponsor-based queries
|
|
46
|
+
sitesSchema.index({ sponsor: 1, isActive: 1 });
|
|
47
|
+
|
|
48
|
+
// Back-reference lookups
|
|
49
|
+
sitesSchema.index({ sampleSiteId: 1 });
|
|
50
|
+
sitesSchema.index({ monitorIds: 1 });
|
|
51
|
+
|
|
52
|
+
// Create the Sites model
|
|
53
|
+
const Sites = mongoose.model("Sites", sitesSchema);
|
|
54
|
+
|
|
55
|
+
export { sitesSchema, Sites };
|