@justair/justair-library 3.3.3 → 3.3.4-beta
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 +85 -85
- package/package.json +27 -27
- package/src/config/db.js +42 -42
- package/src/config/logger.js +44 -44
- package/src/index.js +93 -93
- package/src/models/admin.js +22 -22
- package/src/models/announcements.js +31 -31
- package/src/models/apiKey.js +22 -22
- package/src/models/configurations.js +17 -17
- package/src/models/contexts.js +13 -13
- package/src/models/events.js +124 -124
- package/src/models/jobs.js +34 -34
- package/src/models/lightmonitors.js +28 -28
- package/src/models/measurements.js +130 -130
- package/src/models/monitorRequests.js +15 -15
- package/src/models/monitorSuppliers.js +11 -11
- package/src/models/monitorType.js +40 -0
- package/src/models/monitors.js +125 -95
- package/src/models/organizations.js +23 -23
- package/src/models/parameters.js +11 -11
- package/src/models/qanotifications.js +29 -29
- package/src/models/referenceMonitorInfo.js +18 -18
- package/src/models/tests/admin.test.js +42 -42
- package/src/models/tests/configurations.test.js +44 -44
- package/src/models/tests/measurements.test.js +46 -46
- package/src/models/tests/monitorRequests.test.js +46 -46
- package/src/models/tests/monitors.test.js +62 -62
- package/src/models/tests/organizations.test.js +51 -51
- package/src/models/tests/users.test.js +54 -54
- package/src/models/usageMetrics.js +28 -28
- package/src/models/users.js +30 -30
- package/tsconfig.json +10 -10
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import mongoose from "mongoose";
|
|
2
|
-
|
|
3
|
-
const locationSchema = mongoose.Schema(
|
|
4
|
-
{
|
|
5
|
-
city: { type: String, default: null },
|
|
6
|
-
county: { type: String, default: null },
|
|
7
|
-
state: { type: String, required: [true, "state is required"] },
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
timestamps: false,
|
|
11
|
-
_id: false,
|
|
12
|
-
}
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
const announcementSchema = mongoose.Schema(
|
|
16
|
-
{
|
|
17
|
-
category: { type: String, required: [true, "category is required"]},
|
|
18
|
-
message: { type: String, required: [true, "message is required"] },
|
|
19
|
-
link: String,
|
|
20
|
-
location: { type: locationSchema, required: [true, "location is required"] },
|
|
21
|
-
isActive: { type: Boolean, default: false },
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
timestamps: true,
|
|
25
|
-
}
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
const Announcements = mongoose.model("Announcements", announcementSchema);
|
|
29
|
-
|
|
30
|
-
export { announcementSchema, Announcements };
|
|
31
|
-
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
|
|
3
|
+
const locationSchema = mongoose.Schema(
|
|
4
|
+
{
|
|
5
|
+
city: { type: String, default: null },
|
|
6
|
+
county: { type: String, default: null },
|
|
7
|
+
state: { type: String, required: [true, "state is required"] },
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
timestamps: false,
|
|
11
|
+
_id: false,
|
|
12
|
+
}
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const announcementSchema = mongoose.Schema(
|
|
16
|
+
{
|
|
17
|
+
category: { type: String, required: [true, "category is required"]},
|
|
18
|
+
message: { type: String, required: [true, "message is required"] },
|
|
19
|
+
link: String,
|
|
20
|
+
location: { type: locationSchema, required: [true, "location is required"] },
|
|
21
|
+
isActive: { type: Boolean, default: false },
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
timestamps: true,
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const Announcements = mongoose.model("Announcements", announcementSchema);
|
|
29
|
+
|
|
30
|
+
export { announcementSchema, Announcements };
|
|
31
|
+
|
package/src/models/apiKey.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import mongoose from "mongoose";
|
|
2
|
-
const apiKeySchema = mongoose.Schema(
|
|
3
|
-
{
|
|
4
|
-
adminId: { type: mongoose.Schema.Types.ObjectId, ref: "Admin" },
|
|
5
|
-
clientKey: { type: String, unique: true },
|
|
6
|
-
permissions: {
|
|
7
|
-
type: Object,
|
|
8
|
-
of: [{ type: mongoose.Schema.Types.ObjectId }],
|
|
9
|
-
default: new Map(),
|
|
10
|
-
},
|
|
11
|
-
accessToken: String,
|
|
12
|
-
refreshToken: String,
|
|
13
|
-
lastUsedAt: Date,
|
|
14
|
-
isActive: Boolean,
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
timestamps: true,
|
|
18
|
-
}
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
const ApiKey = mongoose.model("ApiKey", apiKeySchema);
|
|
22
|
-
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
const apiKeySchema = mongoose.Schema(
|
|
3
|
+
{
|
|
4
|
+
adminId: { type: mongoose.Schema.Types.ObjectId, ref: "Admin" },
|
|
5
|
+
clientKey: { type: String, unique: true },
|
|
6
|
+
permissions: {
|
|
7
|
+
type: Object,
|
|
8
|
+
of: [{ type: mongoose.Schema.Types.ObjectId }],
|
|
9
|
+
default: new Map(),
|
|
10
|
+
},
|
|
11
|
+
accessToken: String,
|
|
12
|
+
refreshToken: String,
|
|
13
|
+
lastUsedAt: Date,
|
|
14
|
+
isActive: Boolean,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
timestamps: true,
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const ApiKey = mongoose.model("ApiKey", apiKeySchema);
|
|
22
|
+
|
|
23
23
|
export { apiKeySchema, ApiKey };
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import mongoose from 'mongoose';
|
|
2
|
-
|
|
3
|
-
const configurationsSchema = mongoose.Schema({
|
|
4
|
-
type: { type: String, enum: ['flag'] },
|
|
5
|
-
name: String,
|
|
6
|
-
properties: Object,
|
|
7
|
-
isActive: { type: Boolean, default: false },
|
|
8
|
-
firstRun: {type: Boolean, default: false}
|
|
9
|
-
}, {
|
|
10
|
-
timestamps: true
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
configurationsSchema.index({name: 1});
|
|
14
|
-
|
|
15
|
-
const Configurations = mongoose.model('Configurations', configurationsSchema);
|
|
16
|
-
|
|
17
|
-
export {configurationsSchema, Configurations};
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
|
|
3
|
+
const configurationsSchema = mongoose.Schema({
|
|
4
|
+
type: { type: String, enum: ['flag'] },
|
|
5
|
+
name: String,
|
|
6
|
+
properties: Object,
|
|
7
|
+
isActive: { type: Boolean, default: false },
|
|
8
|
+
firstRun: {type: Boolean, default: false}
|
|
9
|
+
}, {
|
|
10
|
+
timestamps: true
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
configurationsSchema.index({name: 1});
|
|
14
|
+
|
|
15
|
+
const Configurations = mongoose.model('Configurations', configurationsSchema);
|
|
16
|
+
|
|
17
|
+
export {configurationsSchema, Configurations};
|
package/src/models/contexts.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import mongoose from "mongoose";
|
|
2
|
-
|
|
3
|
-
const contextsSchema = mongoose.Schema(
|
|
4
|
-
{
|
|
5
|
-
name: String
|
|
6
|
-
},
|
|
7
|
-
{
|
|
8
|
-
timestamps: true
|
|
9
|
-
}
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
const Contexts = mongoose.model("Contexts", contextsSchema);
|
|
13
|
-
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
|
|
3
|
+
const contextsSchema = mongoose.Schema(
|
|
4
|
+
{
|
|
5
|
+
name: String
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
timestamps: true
|
|
9
|
+
}
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
const Contexts = mongoose.model("Contexts", contextsSchema);
|
|
13
|
+
|
|
14
14
|
export {contextsSchema, Contexts};
|
package/src/models/events.js
CHANGED
|
@@ -1,124 +1,124 @@
|
|
|
1
|
-
import mongoose from "mongoose";
|
|
2
|
-
|
|
3
|
-
// Events Audit Schema
|
|
4
|
-
const eventsAuditSchema = mongoose.Schema(
|
|
5
|
-
{
|
|
6
|
-
monitorId: { type: mongoose.Types.ObjectId, ref: "Monitors" },
|
|
7
|
-
parameter: {
|
|
8
|
-
type: String,
|
|
9
|
-
enum: ["AQI", "PID"],
|
|
10
|
-
},
|
|
11
|
-
values: Object,
|
|
12
|
-
alertLevels: Object,
|
|
13
|
-
currentMonitorState: {
|
|
14
|
-
type: String,
|
|
15
|
-
enum: ["Collocation", "Deployed", "Maintenance", "Pending Deployment"],
|
|
16
|
-
},
|
|
17
|
-
pollutantsFlags: {
|
|
18
|
-
type: Object,
|
|
19
|
-
default: {},
|
|
20
|
-
},
|
|
21
|
-
deletedAt: { type: Date, default: null },
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
timestamps: true,
|
|
25
|
-
}
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
const EventsAudit = mongoose.model("EventsAudit", eventsAuditSchema);
|
|
29
|
-
|
|
30
|
-
// Events Schema
|
|
31
|
-
const eventsSchema = mongoose.Schema(
|
|
32
|
-
{
|
|
33
|
-
monitorId: { type: mongoose.Types.ObjectId, ref: "Monitors" },
|
|
34
|
-
parameter: {
|
|
35
|
-
type: String,
|
|
36
|
-
enum: ["AQI", "PID"],
|
|
37
|
-
},
|
|
38
|
-
values: Object,
|
|
39
|
-
alertLevels: Object,
|
|
40
|
-
currentMonitorState: {
|
|
41
|
-
type: String,
|
|
42
|
-
enum: ["Collocation", "Deployed", "Maintenance", "Pending Deployment"],
|
|
43
|
-
},
|
|
44
|
-
pollutantsFlags: {
|
|
45
|
-
type: Object,
|
|
46
|
-
default: {},
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
timestamps: true,
|
|
51
|
-
}
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
eventsSchema.index({ monitorId: 1 });
|
|
55
|
-
eventsSchema.index({ parameter: 1 });
|
|
56
|
-
|
|
57
|
-
// Pre-hook to log single document deletions
|
|
58
|
-
eventsSchema.pre("findOneAndDelete", async function () {
|
|
59
|
-
const docToDelete = await this.model.findOne(this.getFilter());
|
|
60
|
-
if (docToDelete) {
|
|
61
|
-
console.log("Logging findOneAndDelete to events audit", docToDelete);
|
|
62
|
-
const auditLog = new EventsAudit({
|
|
63
|
-
...docToDelete.toObject(),
|
|
64
|
-
deletedAt: new Date(),
|
|
65
|
-
});
|
|
66
|
-
await auditLog.save();
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
// Pre-hook to log multiple document deletions
|
|
71
|
-
eventsSchema.pre("deleteMany", async function () {
|
|
72
|
-
const docsToDelete = await this.model.find(this.getFilter()).lean();
|
|
73
|
-
if (docsToDelete.length) {
|
|
74
|
-
console.log(`Logging ${docsToDelete.length} documents to events audit`);
|
|
75
|
-
const auditLogs = docsToDelete.map((doc) => ({
|
|
76
|
-
...doc,
|
|
77
|
-
deletedAt: new Date(),
|
|
78
|
-
}));
|
|
79
|
-
await EventsAudit.insertMany(auditLogs);
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
// Pre-hook to log a single document deletion (for deleteOne)
|
|
84
|
-
eventsSchema.pre("deleteOne", async function () {
|
|
85
|
-
const docToDelete = await this.model.findOne(this.getFilter()).lean();
|
|
86
|
-
if (docToDelete) {
|
|
87
|
-
console.log("Logging deleteOne to events audit", docToDelete);
|
|
88
|
-
const auditLog = new EventsAudit({
|
|
89
|
-
...docToDelete,
|
|
90
|
-
deletedAt: new Date(),
|
|
91
|
-
});
|
|
92
|
-
await auditLog.save();
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
// Pre-hook to log single document updates
|
|
97
|
-
eventsSchema.pre("findOneAndUpdate", async function () {
|
|
98
|
-
const docToUpdate = await this.model.findOne(this.getFilter()).lean();
|
|
99
|
-
if (docToUpdate) {
|
|
100
|
-
console.log("Logging findOneAndUpdate to events audit", docToUpdate);
|
|
101
|
-
const auditLog = new EventsAudit({
|
|
102
|
-
...docToUpdate,
|
|
103
|
-
deletedAt: null, // Not deleted
|
|
104
|
-
});
|
|
105
|
-
await auditLog.save();
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
// Pre-hook to log multiple document updates
|
|
110
|
-
eventsSchema.pre("updateMany", async function () {
|
|
111
|
-
const docsToUpdate = await this.model.find(this.getFilter()).lean();
|
|
112
|
-
if (docsToUpdate.length) {
|
|
113
|
-
console.log(`Logging ${docsToUpdate.length} documents to events audit`);
|
|
114
|
-
const auditLogs = docsToUpdate.map((doc) => ({
|
|
115
|
-
...doc,
|
|
116
|
-
deletedAt: null, // Not deleted
|
|
117
|
-
}));
|
|
118
|
-
await EventsAudit.insertMany(auditLogs);
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
const Events = mongoose.model("Events", eventsSchema);
|
|
123
|
-
|
|
124
|
-
export { eventsSchema, Events, EventsAudit, eventsAuditSchema };
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
|
|
3
|
+
// Events Audit Schema
|
|
4
|
+
const eventsAuditSchema = mongoose.Schema(
|
|
5
|
+
{
|
|
6
|
+
monitorId: { type: mongoose.Types.ObjectId, ref: "Monitors" },
|
|
7
|
+
parameter: {
|
|
8
|
+
type: String,
|
|
9
|
+
enum: ["AQI", "PID"],
|
|
10
|
+
},
|
|
11
|
+
values: Object,
|
|
12
|
+
alertLevels: Object,
|
|
13
|
+
currentMonitorState: {
|
|
14
|
+
type: String,
|
|
15
|
+
enum: ["Collocation", "Deployed", "Maintenance", "Pending Deployment"],
|
|
16
|
+
},
|
|
17
|
+
pollutantsFlags: {
|
|
18
|
+
type: Object,
|
|
19
|
+
default: {},
|
|
20
|
+
},
|
|
21
|
+
deletedAt: { type: Date, default: null },
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
timestamps: true,
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const EventsAudit = mongoose.model("EventsAudit", eventsAuditSchema);
|
|
29
|
+
|
|
30
|
+
// Events Schema
|
|
31
|
+
const eventsSchema = mongoose.Schema(
|
|
32
|
+
{
|
|
33
|
+
monitorId: { type: mongoose.Types.ObjectId, ref: "Monitors" },
|
|
34
|
+
parameter: {
|
|
35
|
+
type: String,
|
|
36
|
+
enum: ["AQI", "PID"],
|
|
37
|
+
},
|
|
38
|
+
values: Object,
|
|
39
|
+
alertLevels: Object,
|
|
40
|
+
currentMonitorState: {
|
|
41
|
+
type: String,
|
|
42
|
+
enum: ["Collocation", "Deployed", "Maintenance", "Pending Deployment"],
|
|
43
|
+
},
|
|
44
|
+
pollutantsFlags: {
|
|
45
|
+
type: Object,
|
|
46
|
+
default: {},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
timestamps: true,
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
eventsSchema.index({ monitorId: 1 });
|
|
55
|
+
eventsSchema.index({ parameter: 1 });
|
|
56
|
+
|
|
57
|
+
// Pre-hook to log single document deletions
|
|
58
|
+
eventsSchema.pre("findOneAndDelete", async function () {
|
|
59
|
+
const docToDelete = await this.model.findOne(this.getFilter());
|
|
60
|
+
if (docToDelete) {
|
|
61
|
+
console.log("Logging findOneAndDelete to events audit", docToDelete);
|
|
62
|
+
const auditLog = new EventsAudit({
|
|
63
|
+
...docToDelete.toObject(),
|
|
64
|
+
deletedAt: new Date(),
|
|
65
|
+
});
|
|
66
|
+
await auditLog.save();
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// Pre-hook to log multiple document deletions
|
|
71
|
+
eventsSchema.pre("deleteMany", async function () {
|
|
72
|
+
const docsToDelete = await this.model.find(this.getFilter()).lean();
|
|
73
|
+
if (docsToDelete.length) {
|
|
74
|
+
console.log(`Logging ${docsToDelete.length} documents to events audit`);
|
|
75
|
+
const auditLogs = docsToDelete.map((doc) => ({
|
|
76
|
+
...doc,
|
|
77
|
+
deletedAt: new Date(),
|
|
78
|
+
}));
|
|
79
|
+
await EventsAudit.insertMany(auditLogs);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// Pre-hook to log a single document deletion (for deleteOne)
|
|
84
|
+
eventsSchema.pre("deleteOne", async function () {
|
|
85
|
+
const docToDelete = await this.model.findOne(this.getFilter()).lean();
|
|
86
|
+
if (docToDelete) {
|
|
87
|
+
console.log("Logging deleteOne to events audit", docToDelete);
|
|
88
|
+
const auditLog = new EventsAudit({
|
|
89
|
+
...docToDelete,
|
|
90
|
+
deletedAt: new Date(),
|
|
91
|
+
});
|
|
92
|
+
await auditLog.save();
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// Pre-hook to log single document updates
|
|
97
|
+
eventsSchema.pre("findOneAndUpdate", async function () {
|
|
98
|
+
const docToUpdate = await this.model.findOne(this.getFilter()).lean();
|
|
99
|
+
if (docToUpdate) {
|
|
100
|
+
console.log("Logging findOneAndUpdate to events audit", docToUpdate);
|
|
101
|
+
const auditLog = new EventsAudit({
|
|
102
|
+
...docToUpdate,
|
|
103
|
+
deletedAt: null, // Not deleted
|
|
104
|
+
});
|
|
105
|
+
await auditLog.save();
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// Pre-hook to log multiple document updates
|
|
110
|
+
eventsSchema.pre("updateMany", async function () {
|
|
111
|
+
const docsToUpdate = await this.model.find(this.getFilter()).lean();
|
|
112
|
+
if (docsToUpdate.length) {
|
|
113
|
+
console.log(`Logging ${docsToUpdate.length} documents to events audit`);
|
|
114
|
+
const auditLogs = docsToUpdate.map((doc) => ({
|
|
115
|
+
...doc,
|
|
116
|
+
deletedAt: null, // Not deleted
|
|
117
|
+
}));
|
|
118
|
+
await EventsAudit.insertMany(auditLogs);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const Events = mongoose.model("Events", eventsSchema);
|
|
123
|
+
|
|
124
|
+
export { eventsSchema, Events, EventsAudit, eventsAuditSchema };
|
package/src/models/jobs.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import mongoose from "mongoose";
|
|
2
|
-
|
|
3
|
-
const jobsSchema = mongoose.Schema(
|
|
4
|
-
{
|
|
5
|
-
requestorId: { type: mongoose.Types.ObjectId, ref: "Admin" },
|
|
6
|
-
requestorEmail: String,
|
|
7
|
-
category: {
|
|
8
|
-
type: String,
|
|
9
|
-
enum: [
|
|
10
|
-
"Truck Detection",
|
|
11
|
-
"Backfill Monitor Data",
|
|
12
|
-
"AQI Network Summary",
|
|
13
|
-
"Multi Monitor Data Pull",
|
|
14
|
-
"Multi Monitor Average AQI Data Pull",
|
|
15
|
-
],
|
|
16
|
-
},
|
|
17
|
-
resourceURL: String,
|
|
18
|
-
publicResourceURL: String,
|
|
19
|
-
resourceMetaData: Object,
|
|
20
|
-
resultData: { type: mongoose.Schema.Types.Mixed, default: {} },
|
|
21
|
-
jobStatus: {
|
|
22
|
-
type: String,
|
|
23
|
-
enum: ["New", "In-Progress", "Complete", "Cancelled", "Failed"],
|
|
24
|
-
},
|
|
25
|
-
jobStatusHistory: [Object],
|
|
26
|
-
sharedWith: [{ type: mongoose.Types.ObjectId, ref: "Admin" }],
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
timestamps: true,
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
const Jobs = mongoose.model("Jobs", jobsSchema);
|
|
34
|
-
export { jobsSchema, Jobs };
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
|
|
3
|
+
const jobsSchema = mongoose.Schema(
|
|
4
|
+
{
|
|
5
|
+
requestorId: { type: mongoose.Types.ObjectId, ref: "Admin" },
|
|
6
|
+
requestorEmail: String,
|
|
7
|
+
category: {
|
|
8
|
+
type: String,
|
|
9
|
+
enum: [
|
|
10
|
+
"Truck Detection",
|
|
11
|
+
"Backfill Monitor Data",
|
|
12
|
+
"AQI Network Summary",
|
|
13
|
+
"Multi Monitor Data Pull",
|
|
14
|
+
"Multi Monitor Average AQI Data Pull",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
resourceURL: String,
|
|
18
|
+
publicResourceURL: String,
|
|
19
|
+
resourceMetaData: Object,
|
|
20
|
+
resultData: { type: mongoose.Schema.Types.Mixed, default: {} },
|
|
21
|
+
jobStatus: {
|
|
22
|
+
type: String,
|
|
23
|
+
enum: ["New", "In-Progress", "Complete", "Cancelled", "Failed"],
|
|
24
|
+
},
|
|
25
|
+
jobStatusHistory: [Object],
|
|
26
|
+
sharedWith: [{ type: mongoose.Types.ObjectId, ref: "Admin" }],
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
timestamps: true,
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const Jobs = mongoose.model("Jobs", jobsSchema);
|
|
34
|
+
export { jobsSchema, Jobs };
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import mongoose from "mongoose";
|
|
2
|
-
|
|
3
|
-
const lightMonitorSchema = mongoose.Schema(
|
|
4
|
-
{
|
|
5
|
-
monitorId: { type: mongoose.Types.ObjectId, ref: "Monitors" },
|
|
6
|
-
currentColor: { type: String, default: "16000" },
|
|
7
|
-
isActive: { type: Boolean, default: false },
|
|
8
|
-
configuration: {
|
|
9
|
-
hueUsername: { type: String },
|
|
10
|
-
clientId: { type: String, required: true },
|
|
11
|
-
clientSecret: { type: String, required: true },
|
|
12
|
-
lightId: { type: String, required: true },
|
|
13
|
-
accessTokenInfo: Object,
|
|
14
|
-
refreshTokenInfo: Object,
|
|
15
|
-
hueCode: { type: String, required: true },
|
|
16
|
-
hueCodeHistory: [Object],
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
timestamps: true,
|
|
21
|
-
}
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
lightMonitorSchema.index({ monitorId: 1 });
|
|
25
|
-
|
|
26
|
-
const LightMonitors = mongoose.model("LightMonitor", lightMonitorSchema);
|
|
27
|
-
|
|
28
|
-
export { lightMonitorSchema, LightMonitors };
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
|
|
3
|
+
const lightMonitorSchema = mongoose.Schema(
|
|
4
|
+
{
|
|
5
|
+
monitorId: { type: mongoose.Types.ObjectId, ref: "Monitors" },
|
|
6
|
+
currentColor: { type: String, default: "16000" },
|
|
7
|
+
isActive: { type: Boolean, default: false },
|
|
8
|
+
configuration: {
|
|
9
|
+
hueUsername: { type: String },
|
|
10
|
+
clientId: { type: String, required: true },
|
|
11
|
+
clientSecret: { type: String, required: true },
|
|
12
|
+
lightId: { type: String, required: true },
|
|
13
|
+
accessTokenInfo: Object,
|
|
14
|
+
refreshTokenInfo: Object,
|
|
15
|
+
hueCode: { type: String, required: true },
|
|
16
|
+
hueCodeHistory: [Object],
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
timestamps: true,
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
lightMonitorSchema.index({ monitorId: 1 });
|
|
25
|
+
|
|
26
|
+
const LightMonitors = mongoose.model("LightMonitor", lightMonitorSchema);
|
|
27
|
+
|
|
28
|
+
export { lightMonitorSchema, LightMonitors };
|