@justair/justair-library 3.1.34 → 3.1.36-alpha
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/dist/index.d.ts +39 -33
- package/dist/index.d.ts.map +1 -1
- package/dist/models/announcements.d.ts.map +1 -1
- package/dist/models/apiKey.d.ts +3 -0
- package/dist/models/apiKey.d.ts.map +1 -0
- package/dist/models/events.d.ts.map +1 -1
- package/dist/models/jobs.d.ts +3 -0
- package/dist/models/jobs.d.ts.map +1 -0
- package/dist/models/lightmonitors.d.ts.map +1 -1
- package/dist/models/qanotifications.d.ts.map +1 -1
- package/dist/models/usageMetrics.d.ts +3 -0
- package/dist/models/usageMetrics.d.ts.map +1 -0
- package/package.json +27 -27
- package/src/config/db.js +21 -21
- package/src/config/logger.js +44 -44
- package/src/index.js +82 -76
- package/src/models/admin.js +22 -22
- package/src/models/announcements.js +31 -31
- package/src/models/apiKey.js +22 -0
- package/src/models/configurations.js +17 -17
- package/src/models/contexts.js +13 -13
- package/src/models/events.js +26 -26
- package/src/models/jobs.js +33 -28
- package/src/models/lightmonitors.js +28 -28
- package/src/models/measurements.js +17 -17
- package/src/models/monitorRequests.js +15 -15
- package/src/models/monitorSuppliers.js +11 -11
- package/src/models/monitors.js +101 -101
- 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 +26 -0
- package/src/models/users.js +30 -30
- package/tsconfig.json +10 -10
package/src/index.js
CHANGED
|
@@ -1,76 +1,82 @@
|
|
|
1
|
-
import { adminSchema, Admin } from "./models/admin.js";
|
|
2
|
-
import {
|
|
3
|
-
configurationsSchema,
|
|
4
|
-
Configurations,
|
|
5
|
-
} from "./models/configurations.js";
|
|
6
|
-
import { measurementsSchema, Measurements } from "./models/measurements.js";
|
|
7
|
-
import {
|
|
8
|
-
monitorRequestsSchema,
|
|
9
|
-
MonitorRequests,
|
|
10
|
-
} from "./models/monitorRequests.js";
|
|
11
|
-
import { monitorsSchema, Monitors } from "./models/monitors.js";
|
|
12
|
-
import { organizationsSchema, Organizations } from "./models/organizations.js";
|
|
13
|
-
import {
|
|
14
|
-
referenceMonitorInfoSchema,
|
|
15
|
-
ReferenceMonitorInfo,
|
|
16
|
-
} from "./models/referenceMonitorInfo.js";
|
|
17
|
-
import { lightMonitorSchema, LightMonitors } from "./models/lightmonitors.js";
|
|
18
|
-
import {
|
|
19
|
-
monitorSuppliersSchema,
|
|
20
|
-
MonitorSuppliers,
|
|
21
|
-
} from "./models/monitorSuppliers.js";
|
|
22
|
-
import { contextsSchema, Contexts } from "./models/contexts.js";
|
|
23
|
-
import { parametersSchema, Parameters } from "./models/parameters.js";
|
|
24
|
-
import { usersSchema, Users } from "./models/users.js";
|
|
25
|
-
import { eventsSchema, Events } from "./models/events.js";
|
|
26
|
-
import {
|
|
27
|
-
qaNotificationsSchema,
|
|
28
|
-
QANotifications,
|
|
29
|
-
} from "./models/qanotifications.js";
|
|
30
|
-
import { announcementSchema, Announcements } from "./models/announcements.js";
|
|
31
|
-
import { jobsSchema, Jobs } from "./models/jobs.js";
|
|
32
|
-
import
|
|
33
|
-
import
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
1
|
+
import { adminSchema, Admin } from "./models/admin.js";
|
|
2
|
+
import {
|
|
3
|
+
configurationsSchema,
|
|
4
|
+
Configurations,
|
|
5
|
+
} from "./models/configurations.js";
|
|
6
|
+
import { measurementsSchema, Measurements } from "./models/measurements.js";
|
|
7
|
+
import {
|
|
8
|
+
monitorRequestsSchema,
|
|
9
|
+
MonitorRequests,
|
|
10
|
+
} from "./models/monitorRequests.js";
|
|
11
|
+
import { monitorsSchema, Monitors } from "./models/monitors.js";
|
|
12
|
+
import { organizationsSchema, Organizations } from "./models/organizations.js";
|
|
13
|
+
import {
|
|
14
|
+
referenceMonitorInfoSchema,
|
|
15
|
+
ReferenceMonitorInfo,
|
|
16
|
+
} from "./models/referenceMonitorInfo.js";
|
|
17
|
+
import { lightMonitorSchema, LightMonitors } from "./models/lightmonitors.js";
|
|
18
|
+
import {
|
|
19
|
+
monitorSuppliersSchema,
|
|
20
|
+
MonitorSuppliers,
|
|
21
|
+
} from "./models/monitorSuppliers.js";
|
|
22
|
+
import { contextsSchema, Contexts } from "./models/contexts.js";
|
|
23
|
+
import { parametersSchema, Parameters } from "./models/parameters.js";
|
|
24
|
+
import { usersSchema, Users } from "./models/users.js";
|
|
25
|
+
import { eventsSchema, Events } from "./models/events.js";
|
|
26
|
+
import {
|
|
27
|
+
qaNotificationsSchema,
|
|
28
|
+
QANotifications,
|
|
29
|
+
} from "./models/qanotifications.js";
|
|
30
|
+
import { announcementSchema, Announcements } from "./models/announcements.js";
|
|
31
|
+
import { jobsSchema, Jobs } from "./models/jobs.js";
|
|
32
|
+
import { apiKeySchema, ApiKey } from "./models/apiKey.js";
|
|
33
|
+
import { UsageMetrics, usageMetricsSchema } from "./models/usageMetrics.js";
|
|
34
|
+
import dbConfig from "./config/db.js";
|
|
35
|
+
import CustomLogger from "./config/logger.js";
|
|
36
|
+
|
|
37
|
+
export function createDatabaseInstance({ CONNECTION_URL, database }) {
|
|
38
|
+
return new dbConfig({ CONNECTION_URL, database });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function createLoggerInstance({ DATADOG_API_KEY, APPLICATION_NAME }) {
|
|
42
|
+
return new CustomLogger({ DATADOG_API_KEY, APPLICATION_NAME });
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export {
|
|
46
|
+
adminSchema,
|
|
47
|
+
Admin,
|
|
48
|
+
configurationsSchema,
|
|
49
|
+
Configurations,
|
|
50
|
+
measurementsSchema,
|
|
51
|
+
Measurements,
|
|
52
|
+
monitorRequestsSchema,
|
|
53
|
+
MonitorRequests,
|
|
54
|
+
monitorsSchema,
|
|
55
|
+
Monitors,
|
|
56
|
+
organizationsSchema,
|
|
57
|
+
Organizations,
|
|
58
|
+
referenceMonitorInfoSchema,
|
|
59
|
+
ReferenceMonitorInfo,
|
|
60
|
+
usersSchema,
|
|
61
|
+
Users,
|
|
62
|
+
eventsSchema,
|
|
63
|
+
Events,
|
|
64
|
+
lightMonitorSchema,
|
|
65
|
+
LightMonitors,
|
|
66
|
+
monitorSuppliersSchema,
|
|
67
|
+
MonitorSuppliers,
|
|
68
|
+
contextsSchema,
|
|
69
|
+
Contexts,
|
|
70
|
+
parametersSchema,
|
|
71
|
+
Parameters,
|
|
72
|
+
qaNotificationsSchema,
|
|
73
|
+
QANotifications,
|
|
74
|
+
announcementSchema,
|
|
75
|
+
Announcements,
|
|
76
|
+
jobsSchema,
|
|
77
|
+
Jobs,
|
|
78
|
+
apiKeySchema,
|
|
79
|
+
ApiKey,
|
|
80
|
+
UsageMetrics,
|
|
81
|
+
usageMetricsSchema,
|
|
82
|
+
};
|
package/src/models/admin.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import mongoose from 'mongoose';
|
|
2
|
-
|
|
3
|
-
const adminSchema = mongoose.Schema({
|
|
4
|
-
name: String,
|
|
5
|
-
phone: String,
|
|
6
|
-
email: String,
|
|
7
|
-
password: String,
|
|
8
|
-
orgId: { type: mongoose.Types.ObjectId, ref: 'Organizations' },
|
|
9
|
-
permissionName: {type: String, enum: ['Super Admin', 'Admin', 'Member', 'Partner']},
|
|
10
|
-
permissions: [{type: String, enum: ['create', 'read', 'update', 'delete', 'communicate']}],
|
|
11
|
-
authorized: { type: Boolean, default: false },
|
|
12
|
-
isActive: { type: Boolean, default: false },
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
timestamps: true
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
adminSchema.index({email: 1});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const Admin = mongoose.model('Admin', adminSchema);
|
|
22
|
-
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
|
|
3
|
+
const adminSchema = mongoose.Schema({
|
|
4
|
+
name: String,
|
|
5
|
+
phone: String,
|
|
6
|
+
email: String,
|
|
7
|
+
password: String,
|
|
8
|
+
orgId: { type: mongoose.Types.ObjectId, ref: 'Organizations' },
|
|
9
|
+
permissionName: {type: String, enum: ['Super Admin', 'Admin', 'Member', 'Partner']},
|
|
10
|
+
permissions: [{type: String, enum: ['create', 'read', 'update', 'delete', 'communicate']}],
|
|
11
|
+
authorized: { type: Boolean, default: false },
|
|
12
|
+
isActive: { type: Boolean, default: false },
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
timestamps: true
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
adminSchema.index({email: 1});
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
const Admin = mongoose.model('Admin', adminSchema);
|
|
22
|
+
|
|
23
23
|
export {adminSchema, Admin};
|
|
@@ -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
|
+
|
|
@@ -0,0 +1,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: Map,
|
|
8
|
+
of: [{ type: mongoose.Schema.Types.ObjectId }],
|
|
9
|
+
default: new Map(),
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
lastUsedAt: Date,
|
|
13
|
+
isActive: Boolean,
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
timestamps: true,
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const ApiKey = mongoose.model("ApiKey", apiKeySchema);
|
|
21
|
+
|
|
22
|
+
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,26 +1,26 @@
|
|
|
1
|
-
import mongoose from "mongoose";
|
|
2
|
-
//TODO: Capture historical data, every hour record AQI values for monitors
|
|
3
|
-
const eventsSchema = mongoose.Schema(
|
|
4
|
-
{
|
|
5
|
-
monitorId: { type: mongoose.Types.ObjectId, ref: "Monitors" },
|
|
6
|
-
parameter: {
|
|
7
|
-
type: String,
|
|
8
|
-
enum: ["AQI", "PID"],
|
|
9
|
-
},
|
|
10
|
-
values: Object,
|
|
11
|
-
alertLevels: Object,
|
|
12
|
-
currentMonitorState: {
|
|
13
|
-
type: String,
|
|
14
|
-
enum: ["Collocation", "Deployed", "Maintenance", "Pending Deployment"],
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
timestamps: true,
|
|
19
|
-
}
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
eventsSchema.index({ monitorId: 1 });
|
|
23
|
-
eventsSchema.index({ parameter: 1 });
|
|
24
|
-
|
|
25
|
-
const Events = mongoose.model("Events", eventsSchema);
|
|
26
|
-
export { eventsSchema, Events };
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
//TODO: Capture historical data, every hour record AQI values for monitors
|
|
3
|
+
const eventsSchema = mongoose.Schema(
|
|
4
|
+
{
|
|
5
|
+
monitorId: { type: mongoose.Types.ObjectId, ref: "Monitors" },
|
|
6
|
+
parameter: {
|
|
7
|
+
type: String,
|
|
8
|
+
enum: ["AQI", "PID"],
|
|
9
|
+
},
|
|
10
|
+
values: Object,
|
|
11
|
+
alertLevels: Object,
|
|
12
|
+
currentMonitorState: {
|
|
13
|
+
type: String,
|
|
14
|
+
enum: ["Collocation", "Deployed", "Maintenance", "Pending Deployment"],
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
timestamps: true,
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
eventsSchema.index({ monitorId: 1 });
|
|
23
|
+
eventsSchema.index({ parameter: 1 });
|
|
24
|
+
|
|
25
|
+
const Events = mongoose.model("Events", eventsSchema);
|
|
26
|
+
export { eventsSchema, Events };
|
package/src/models/jobs.js
CHANGED
|
@@ -1,28 +1,33 @@
|
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
+
],
|
|
15
|
+
},
|
|
16
|
+
resourceURL: String,
|
|
17
|
+
publicResourceURL: String,
|
|
18
|
+
resourceMetaData: Object,
|
|
19
|
+
resultData: { type: mongoose.Schema.Types.Mixed, default: {} },
|
|
20
|
+
jobStatus: {
|
|
21
|
+
type: String,
|
|
22
|
+
enum: ["New", "In-Progress", "Complete", "Cancelled", "Failed"],
|
|
23
|
+
},
|
|
24
|
+
jobStatusHistory: [Object],
|
|
25
|
+
sharedWith: [{ type: mongoose.Types.ObjectId, ref: "Admin" }],
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
timestamps: true,
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const Jobs = mongoose.model("Jobs", jobsSchema);
|
|
33
|
+
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 };
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import mongoose from 'mongoose';
|
|
2
|
-
|
|
3
|
-
const measurementsSchema = mongoose.Schema({
|
|
4
|
-
monitorId: { type: mongoose.Types.ObjectId, ref: 'Monitors' },
|
|
5
|
-
orgId: { type: mongoose.Types.ObjectId, ref: 'Organizations' },
|
|
6
|
-
timeUpdated: Date,
|
|
7
|
-
measurements: Object,
|
|
8
|
-
monitorState: String
|
|
9
|
-
}, {
|
|
10
|
-
timestamps: true
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
measurementsSchema.index({monitorId: 1});
|
|
14
|
-
measurementsSchema.index({timeUpdated: 1});
|
|
15
|
-
|
|
16
|
-
const Measurements = mongoose.model('Measurements', measurementsSchema);
|
|
17
|
-
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
|
|
3
|
+
const measurementsSchema = mongoose.Schema({
|
|
4
|
+
monitorId: { type: mongoose.Types.ObjectId, ref: 'Monitors' },
|
|
5
|
+
orgId: { type: mongoose.Types.ObjectId, ref: 'Organizations' },
|
|
6
|
+
timeUpdated: Date,
|
|
7
|
+
measurements: Object,
|
|
8
|
+
monitorState: String
|
|
9
|
+
}, {
|
|
10
|
+
timestamps: true
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
measurementsSchema.index({monitorId: 1});
|
|
14
|
+
measurementsSchema.index({timeUpdated: 1});
|
|
15
|
+
|
|
16
|
+
const Measurements = mongoose.model('Measurements', measurementsSchema);
|
|
17
|
+
|
|
18
18
|
export {measurementsSchema, Measurements};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import mongoose from 'mongoose';
|
|
2
|
-
|
|
3
|
-
const monitorRequestsSchema = mongoose.Schema({
|
|
4
|
-
monitorOwnerOrg: { type: mongoose.Types.ObjectId, ref: 'Organizations' },
|
|
5
|
-
monitorOwnerOrgName: String,
|
|
6
|
-
monitorSharerOrg: { type: mongoose.Types.ObjectId, ref: 'Organizations' },
|
|
7
|
-
monitorSharerOrgName: String,
|
|
8
|
-
monitorList: [{ type: mongoose.Types.ObjectId, ref: 'Monitors' }],
|
|
9
|
-
status: { type: String, enum: ['Requested', 'Approved', 'Denied', 'Cancel', 'Deleted'] }
|
|
10
|
-
}, {
|
|
11
|
-
timestamps: true
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
const MonitorRequests = mongoose.model('MonitorRequests', monitorRequestsSchema);
|
|
15
|
-
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
|
|
3
|
+
const monitorRequestsSchema = mongoose.Schema({
|
|
4
|
+
monitorOwnerOrg: { type: mongoose.Types.ObjectId, ref: 'Organizations' },
|
|
5
|
+
monitorOwnerOrgName: String,
|
|
6
|
+
monitorSharerOrg: { type: mongoose.Types.ObjectId, ref: 'Organizations' },
|
|
7
|
+
monitorSharerOrgName: String,
|
|
8
|
+
monitorList: [{ type: mongoose.Types.ObjectId, ref: 'Monitors' }],
|
|
9
|
+
status: { type: String, enum: ['Requested', 'Approved', 'Denied', 'Cancel', 'Deleted'] }
|
|
10
|
+
}, {
|
|
11
|
+
timestamps: true
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const MonitorRequests = mongoose.model('MonitorRequests', monitorRequestsSchema);
|
|
15
|
+
|
|
16
16
|
export {monitorRequestsSchema, MonitorRequests};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import mongoose from "mongoose";
|
|
2
|
-
|
|
3
|
-
const monitorSuppliersSchema = mongoose.Schema({
|
|
4
|
-
name : String
|
|
5
|
-
},
|
|
6
|
-
{
|
|
7
|
-
timestamps: true
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
const MonitorSuppliers = mongoose.model("MonitorSuppliers", monitorSuppliersSchema);
|
|
11
|
-
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
|
|
3
|
+
const monitorSuppliersSchema = mongoose.Schema({
|
|
4
|
+
name : String
|
|
5
|
+
},
|
|
6
|
+
{
|
|
7
|
+
timestamps: true
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const MonitorSuppliers = mongoose.model("MonitorSuppliers", monitorSuppliersSchema);
|
|
11
|
+
|
|
12
12
|
export {monitorSuppliersSchema, MonitorSuppliers};
|