@justair/justair-library 4.15.0-alpha.d287cce → 4.15.1-alpha.179b7ed
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/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/models/monitors.d.ts.map +1 -1
- package/dist/models/organizations.d.ts.map +1 -1
- package/dist/models/sampleSites.d.ts.map +1 -1
- package/dist/models/sites.d.ts +3 -0
- package/dist/models/sites.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/index.js +6 -0
- package/src/models/monitors.js +5 -0
- package/src/models/organizations.js +12 -1
- package/src/models/sampleSites.js +5 -0
- package/src/models/sites.js +55 -0
package/dist/index.d.ts
CHANGED
|
@@ -56,6 +56,8 @@ import { networkMetricsSchema } from "./models/networkMetrics.js";
|
|
|
56
56
|
import { NetworkMetrics } from "./models/networkMetrics.js";
|
|
57
57
|
import { rateOfChangeSchema } from "./models/rateOfChange.js";
|
|
58
58
|
import { RateOfChange } from "./models/rateOfChange.js";
|
|
59
|
+
import { sitesSchema } from "./models/sites.js";
|
|
60
|
+
import { Sites } from "./models/sites.js";
|
|
59
61
|
import { sampleSitesSchema } from "./models/sampleSites.js";
|
|
60
62
|
import { SampleSites } from "./models/sampleSites.js";
|
|
61
63
|
import { sampleSiteAuditSchema } from "./models/sampleSites.js";
|
|
@@ -66,5 +68,5 @@ import { Samples } from "./models/samples.js";
|
|
|
66
68
|
import { samplesAuditSchema } from "./models/samples.js";
|
|
67
69
|
import { SamplesAudit } from "./models/samples.js";
|
|
68
70
|
import { sampleParameterReferenceConcentrations } from "./models/samples.js";
|
|
69
|
-
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, sampleSitesSchema, SampleSites, sampleSiteAuditSchema, SampleSiteAudit, sampleParametersEnum, samplesSchema, Samples, samplesAuditSchema, SamplesAudit, sampleParameterReferenceConcentrations };
|
|
71
|
+
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 };
|
|
70
72
|
//# 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":"AA+EA;;;iBAEC;yBAzBwB,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;4BAKxC,mBAAmB;sBAAnB,mBAAmB;kCAS/C,yBAAyB;4BAAzB,yBAAyB;sCAAzB,yBAAyB;gCAAzB,yBAAyB;qCAAzB,yBAAyB;8BASzB,qBAAqB;wBAArB,qBAAqB;mCAArB,qBAAqB;6BAArB,qBAAqB;uDAArB,qBAAqB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monitors.d.ts","sourceRoot":"","sources":["../../src/models/monitors.js"],"names":[],"mappings":"AAiLA,
|
|
1
|
+
{"version":3,"file":"monitors.d.ts","sourceRoot":"","sources":["../../src/models/monitors.js"],"names":[],"mappings":"AAiLA,iCA+HE;AA6IF,2BAA4D;AA9S5D,qCA4BE;AAGF,+BAAwE;AA7KxE,sCAsBE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organizations.d.ts","sourceRoot":"","sources":["../../src/models/organizations.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"organizations.d.ts","sourceRoot":"","sources":["../../src/models/organizations.js"],"names":[],"mappings":"AAoGA,sCAsBE;AAyDF,gCAA2E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sampleSites.d.ts","sourceRoot":"","sources":["../../src/models/sampleSites.js"],"names":[],"mappings":"AA8EA,
|
|
1
|
+
{"version":3,"file":"sampleSites.d.ts","sourceRoot":"","sources":["../../src/models/sampleSites.js"],"names":[],"mappings":"AA8EA,oCAwDE;AA2JF,8BAAqE;AAzOrE,wCAgBE;AAGF,kCAAiF;AAvEjF,4CAWE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sites.d.ts","sourceRoot":"","sources":["../../src/models/sites.js"],"names":[],"mappings":"AAGA,8BAoCE;AAaF,wBAAmD"}
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -56,6 +56,9 @@ import { RateOfChange, rateOfChangeSchema } from "./models/rateOfChange.js";
|
|
|
56
56
|
import Database from "./config/db.js"; // Import the new Database class
|
|
57
57
|
import CustomLogger from "./config/logger.js";
|
|
58
58
|
|
|
59
|
+
// Sites related imports
|
|
60
|
+
import { sitesSchema, Sites } from "./models/sites.js";
|
|
61
|
+
|
|
59
62
|
// SampleSites related imports
|
|
60
63
|
import {
|
|
61
64
|
sampleSitesSchema,
|
|
@@ -132,6 +135,9 @@ export {
|
|
|
132
135
|
NetworkMetrics,
|
|
133
136
|
rateOfChangeSchema,
|
|
134
137
|
RateOfChange,
|
|
138
|
+
// Sites related exports
|
|
139
|
+
sitesSchema,
|
|
140
|
+
Sites,
|
|
135
141
|
// SampleSites related exports
|
|
136
142
|
sampleSitesSchema,
|
|
137
143
|
SampleSites,
|
package/src/models/monitors.js
CHANGED
|
@@ -289,6 +289,11 @@ const monitorsSchema = mongoose.Schema(
|
|
|
289
289
|
enum: Object.values(deploymentTypesEnum),
|
|
290
290
|
default: deploymentTypesEnum.STATIONARY,
|
|
291
291
|
},
|
|
292
|
+
siteId: {
|
|
293
|
+
type: mongoose.Types.ObjectId,
|
|
294
|
+
ref: "Sites",
|
|
295
|
+
default: null,
|
|
296
|
+
},
|
|
292
297
|
// Optional Clarity node ID (1:1 relationship with Node-S sensor)
|
|
293
298
|
nodeId: { type: String },
|
|
294
299
|
// Active alarms from Clarity node (keyed by alarmType)
|
|
@@ -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: [
|
|
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],
|
|
@@ -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
|
+
{
|
|
13
|
+
type: mongoose.Types.ObjectId,
|
|
14
|
+
ref: "Monitors",
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
sponsor: { type: mongoose.Types.ObjectId, ref: "Organizations" },
|
|
18
|
+
location: {
|
|
19
|
+
city: { type: String },
|
|
20
|
+
state: { type: String },
|
|
21
|
+
county: { type: String },
|
|
22
|
+
street: { type: String },
|
|
23
|
+
zip_code: { type: String },
|
|
24
|
+
neighborhood: { type: String },
|
|
25
|
+
gps: {
|
|
26
|
+
type: {
|
|
27
|
+
type: String,
|
|
28
|
+
enum: ["Point"],
|
|
29
|
+
},
|
|
30
|
+
coordinates: {
|
|
31
|
+
type: [Number],
|
|
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 };
|