@justair/justair-library 3.1.4 → 3.1.5
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 +9 -9
- package/dist/index.d.ts +15 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/models/admin.d.ts.map +1 -1
- package/dist/models/announcements.d.ts +3 -0
- package/dist/models/announcements.d.ts.map +1 -0
- package/dist/models/configurations.d.ts.map +1 -1
- package/dist/models/contexts.d.ts +3 -0
- package/dist/models/contexts.d.ts.map +1 -0
- package/dist/models/events.d.ts.map +1 -1
- package/dist/models/lightmonitors.d.ts +3 -0
- package/dist/models/lightmonitors.d.ts.map +1 -0
- package/dist/models/measurements.d.ts.map +1 -1
- package/dist/models/monitorSuppliers.d.ts +3 -0
- package/dist/models/monitorSuppliers.d.ts.map +1 -0
- package/dist/models/monitors.d.ts.map +1 -1
- package/dist/models/organizations.d.ts.map +1 -1
- package/dist/models/parameters.d.ts +3 -0
- package/dist/models/parameters.d.ts.map +1 -0
- package/dist/models/qanotifications.d.ts +3 -0
- package/dist/models/qanotifications.d.ts.map +1 -0
- package/dist/models/users.d.ts.map +1 -1
- package/package.json +28 -28
- package/src/config/db.js +21 -21
- package/src/config/logger.js +44 -44
- package/src/index.js +42 -40
- package/src/models/admin.js +22 -22
- package/src/models/announcements.js +14 -0
- package/src/models/configurations.js +17 -17
- package/src/models/contexts.js +13 -13
- package/src/models/events.js +20 -20
- package/src/models/lightmonitors.js +24 -24
- 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 +17 -17
- 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/users.js +30 -30
- package/tsconfig.json +10 -10
package/README
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
# JustAir NPM Library
|
|
2
|
-
|
|
3
|
-
The JustAir NPM Library was created to share MongoDB models and other configurations that will be the same across services in the JustAir ecosystem.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
## Requirements
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
##
|
|
1
|
+
# JustAir NPM Library
|
|
2
|
+
|
|
3
|
+
The JustAir NPM Library was created to share MongoDB models and other configurations that will be the same across services in the JustAir ecosystem.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Requirements
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
##
|
package/dist/index.d.ts
CHANGED
|
@@ -24,5 +24,19 @@ import { referenceMonitorInfoSchema } from './models/referenceMonitorInfo.js';
|
|
|
24
24
|
import { ReferenceMonitorInfo } from './models/referenceMonitorInfo.js';
|
|
25
25
|
import { usersSchema } from './models/users.js';
|
|
26
26
|
import { Users } from './models/users.js';
|
|
27
|
-
|
|
27
|
+
import { eventsSchema } from './models/events.js';
|
|
28
|
+
import { Events } from './models/events.js';
|
|
29
|
+
import { lightMonitorSchema } from './models/lightmonitors.js';
|
|
30
|
+
import { LightMonitors } from './models/lightmonitors.js';
|
|
31
|
+
import { monitorSuppliersSchema } from './models/monitorSuppliers.js';
|
|
32
|
+
import { MonitorSuppliers } from './models/monitorSuppliers.js';
|
|
33
|
+
import { contextsSchema } from './models/contexts.js';
|
|
34
|
+
import { Contexts } from './models/contexts.js';
|
|
35
|
+
import { parametersSchema } from './models/parameters.js';
|
|
36
|
+
import { Parameters } from './models/parameters.js';
|
|
37
|
+
import { qaNotificationsSchema } from './models/qanotifications.js';
|
|
38
|
+
import { QANotifications } from './models/qanotifications.js';
|
|
39
|
+
import { announcementSchema } from './models/announcements.js';
|
|
40
|
+
import { Announcements } from './models/announcements.js';
|
|
41
|
+
export { adminSchema, Admin, configurationsSchema, Configurations, measurementsSchema, Measurements, monitorRequestsSchema, MonitorRequests, monitorsSchema, Monitors, organizationsSchema, Organizations, referenceMonitorInfoSchema, ReferenceMonitorInfo, usersSchema, Users, eventsSchema, Events, lightMonitorSchema, LightMonitors, monitorSuppliersSchema, MonitorSuppliers, contextsSchema, Contexts, parametersSchema, Parameters, qaNotificationsSchema, QANotifications, announcementSchema, Announcements };
|
|
28
42
|
//# 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":"AAkBA;;;aAEC;AAED;;;iBAEC;qBAToB,gBAAgB;yBACZ,oBAAoB;4BAhBV,mBAAmB;sBAAnB,mBAAmB;qCACH,4BAA4B;+BAA5B,4BAA4B;mCAChC,0BAA0B;6BAA1B,0BAA0B;sCACpB,6BAA6B;gCAA7B,6BAA6B;+BAC3C,sBAAsB;yBAAtB,sBAAsB;oCACZ,2BAA2B;8BAA3B,2BAA2B;2CACb,kCAAkC;qCAAlC,kCAAkC;4BAKhE,mBAAmB;sBAAnB,mBAAmB;6BACf,oBAAoB;uBAApB,oBAAoB;mCALP,2BAA2B;8BAA3B,2BAA2B;uCACpB,8BAA8B;iCAA9B,8BAA8B;+BAC9C,sBAAsB;yBAAtB,sBAAsB;iCAClB,wBAAwB;2BAAxB,wBAAwB;sCAGd,6BAA6B;gCAA7B,6BAA6B;mCAClC,2BAA2B;8BAA3B,2BAA2B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../src/models/admin.js"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../src/models/admin.js"],"names":[],"mappings":"AAEA,8BAaG;AAKH,wBAAmD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"announcements.d.ts","sourceRoot":"","sources":["../../src/models/announcements.js"],"names":[],"mappings":"AAEA,qCAOE;AAEF,gCAAyE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configurations.d.ts","sourceRoot":"","sources":["../../src/models/configurations.js"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"configurations.d.ts","sourceRoot":"","sources":["../../src/models/configurations.js"],"names":[],"mappings":"AAEA,uCAQG;AAIH,iCAA8E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contexts.d.ts","sourceRoot":"","sources":["../../src/models/contexts.js"],"names":[],"mappings":"AAEA,iCAOE;AAEF,2BAA4D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/models/events.js"],"names":[],"mappings":"AAEA,+
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/models/events.js"],"names":[],"mappings":"AAEA,+BAYE;AAKF,yBAAsD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lightmonitors.d.ts","sourceRoot":"","sources":["../../src/models/lightmonitors.js"],"names":[],"mappings":"AAEA,qCAgBG;AAIH,gCAAyE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"measurements.d.ts","sourceRoot":"","sources":["../../src/models/measurements.js"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"measurements.d.ts","sourceRoot":"","sources":["../../src/models/measurements.js"],"names":[],"mappings":"AAEA,qCAQG;AAKH,+BAAwE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monitorSuppliers.d.ts","sourceRoot":"","sources":["../../src/models/monitorSuppliers.js"],"names":[],"mappings":"AAEA,yCAKG;AAEH,mCAAoF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monitors.d.ts","sourceRoot":"","sources":["../../src/models/monitors.js"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"monitors.d.ts","sourceRoot":"","sources":["../../src/models/monitors.js"],"names":[],"mappings":"AAEA,iCA0FE;AAOF,2BAA4D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organizations.d.ts","sourceRoot":"","sources":["../../src/models/organizations.js"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"organizations.d.ts","sourceRoot":"","sources":["../../src/models/organizations.js"],"names":[],"mappings":"AAEA,sCAiBO;AAEP,gCAA2E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parameters.d.ts","sourceRoot":"","sources":["../../src/models/parameters.js"],"names":[],"mappings":"AAEA,mCAKG;AAEH,6BAAkE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qanotifications.d.ts","sourceRoot":"","sources":["../../src/models/qanotifications.js"],"names":[],"mappings":"AAEA,wCAWG;AAEH,kCAAiF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../src/models/users.js"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../src/models/users.js"],"names":[],"mappings":"AAEA,8BAsBG;AAIH,wBAAmD"}
|
package/package.json
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@justair/justair-library",
|
|
3
|
-
"version": "3.1.
|
|
4
|
-
"description": "JustAir Internal Library",
|
|
5
|
-
"main": "src/index.js",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
|
-
"scripts": {
|
|
9
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
10
|
-
"build": "tsc",
|
|
11
|
-
"prepublish": "npm run build"
|
|
12
|
-
},
|
|
13
|
-
"keywords": [
|
|
14
|
-
"JustAir"
|
|
15
|
-
],
|
|
16
|
-
"author": "Britney Epps",
|
|
17
|
-
"license": "ISC",
|
|
18
|
-
"dependencies": {
|
|
19
|
-
"mongoose": "^6.8.2",
|
|
20
|
-
"winston": "^3.10.0"
|
|
21
|
-
},
|
|
22
|
-
"devDependencies": {
|
|
23
|
-
"typescript": "^5.3.2",
|
|
24
|
-
"@types/node": "^16.0.0",
|
|
25
|
-
"@types/mongoose": "^6.0.0",
|
|
26
|
-
"ts-node": "^10.0.0"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@justair/justair-library",
|
|
3
|
+
"version": "3.1.5",
|
|
4
|
+
"description": "JustAir Internal Library",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"prepublish": "npm run build"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"JustAir"
|
|
15
|
+
],
|
|
16
|
+
"author": "Britney Epps",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"mongoose": "^6.8.2",
|
|
20
|
+
"winston": "^3.10.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"typescript": "^5.3.2",
|
|
24
|
+
"@types/node": "^16.0.0",
|
|
25
|
+
"@types/mongoose": "^6.0.0",
|
|
26
|
+
"ts-node": "^10.0.0"
|
|
27
|
+
}
|
|
28
|
+
}
|
package/src/config/db.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { set, connect } from 'mongoose';
|
|
2
|
-
|
|
3
|
-
class Database {
|
|
4
|
-
constructor({ CONNECTION_URL, database }) {
|
|
5
|
-
this.CONNECTION_URL = CONNECTION_URL;
|
|
6
|
-
this.database = database;
|
|
7
|
-
this._connect();
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
_connect() {
|
|
11
|
-
set('strictQuery', false);
|
|
12
|
-
connect(this.CONNECTION_URL, { authSource: "admin", ssl: true, dbName: this.database })
|
|
13
|
-
.then(() => {
|
|
14
|
-
console.log('Database connection successful');
|
|
15
|
-
})
|
|
16
|
-
.catch(err => {
|
|
17
|
-
console.error('Database connection error ' + err);
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
1
|
+
import { set, connect } from 'mongoose';
|
|
2
|
+
|
|
3
|
+
class Database {
|
|
4
|
+
constructor({ CONNECTION_URL, database }) {
|
|
5
|
+
this.CONNECTION_URL = CONNECTION_URL;
|
|
6
|
+
this.database = database;
|
|
7
|
+
this._connect();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
_connect() {
|
|
11
|
+
set('strictQuery', false);
|
|
12
|
+
connect(this.CONNECTION_URL, { authSource: "admin", ssl: true, dbName: this.database })
|
|
13
|
+
.then(() => {
|
|
14
|
+
console.log('Database connection successful');
|
|
15
|
+
})
|
|
16
|
+
.catch(err => {
|
|
17
|
+
console.error('Database connection error ' + err);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
22
|
export default Database;
|
package/src/config/logger.js
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import { createLogger, format, transports, config } from 'winston';
|
|
2
|
-
const { combine, timestamp, json, errors, prettyPrint } = format;
|
|
3
|
-
|
|
4
|
-
class CustomLogger {
|
|
5
|
-
constructor({ DATADOG_API_KEY, APPLICATION_NAME }) {
|
|
6
|
-
this.DATADOG_API_KEY = DATADOG_API_KEY;
|
|
7
|
-
this.APPLICATION_NAME = APPLICATION_NAME;
|
|
8
|
-
this.logger = this._createLogger();
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
_createLogger() {
|
|
12
|
-
const httpTransportOptions = {
|
|
13
|
-
host: 'http-intake.logs.us5.datadoghq.com',
|
|
14
|
-
path: `/api/v2/logs?dd-api-key=${this.DATADOG_API_KEY}&ddsource=nodejs&service=${this.APPLICATION_NAME}`,
|
|
15
|
-
ssl: true
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
return createLogger({
|
|
19
|
-
levels: config.syslog.levels,
|
|
20
|
-
exitOnError: false,
|
|
21
|
-
format: combine(
|
|
22
|
-
errors({ stack: true }),
|
|
23
|
-
timestamp({
|
|
24
|
-
format: 'YYYY-MM-DD HH:mm:ss'
|
|
25
|
-
}),
|
|
26
|
-
json(),
|
|
27
|
-
prettyPrint()
|
|
28
|
-
),
|
|
29
|
-
transports: [
|
|
30
|
-
new transports.Console(),
|
|
31
|
-
new transports.Http(httpTransportOptions),
|
|
32
|
-
],
|
|
33
|
-
exceptionHandlers: [
|
|
34
|
-
new transports.Console(),
|
|
35
|
-
new transports.Http(httpTransportOptions)
|
|
36
|
-
]
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
getLogger() {
|
|
41
|
-
return this.logger;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
1
|
+
import { createLogger, format, transports, config } from 'winston';
|
|
2
|
+
const { combine, timestamp, json, errors, prettyPrint } = format;
|
|
3
|
+
|
|
4
|
+
class CustomLogger {
|
|
5
|
+
constructor({ DATADOG_API_KEY, APPLICATION_NAME }) {
|
|
6
|
+
this.DATADOG_API_KEY = DATADOG_API_KEY;
|
|
7
|
+
this.APPLICATION_NAME = APPLICATION_NAME;
|
|
8
|
+
this.logger = this._createLogger();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
_createLogger() {
|
|
12
|
+
const httpTransportOptions = {
|
|
13
|
+
host: 'http-intake.logs.us5.datadoghq.com',
|
|
14
|
+
path: `/api/v2/logs?dd-api-key=${this.DATADOG_API_KEY}&ddsource=nodejs&service=${this.APPLICATION_NAME}`,
|
|
15
|
+
ssl: true
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
return createLogger({
|
|
19
|
+
levels: config.syslog.levels,
|
|
20
|
+
exitOnError: false,
|
|
21
|
+
format: combine(
|
|
22
|
+
errors({ stack: true }),
|
|
23
|
+
timestamp({
|
|
24
|
+
format: 'YYYY-MM-DD HH:mm:ss'
|
|
25
|
+
}),
|
|
26
|
+
json(),
|
|
27
|
+
prettyPrint()
|
|
28
|
+
),
|
|
29
|
+
transports: [
|
|
30
|
+
new transports.Console(),
|
|
31
|
+
new transports.Http(httpTransportOptions),
|
|
32
|
+
],
|
|
33
|
+
exceptionHandlers: [
|
|
34
|
+
new transports.Console(),
|
|
35
|
+
new transports.Http(httpTransportOptions)
|
|
36
|
+
]
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
getLogger() {
|
|
41
|
+
return this.logger;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
45
|
export default CustomLogger;
|
package/src/index.js
CHANGED
|
@@ -1,41 +1,43 @@
|
|
|
1
|
-
import { adminSchema, Admin } from './models/admin.js';
|
|
2
|
-
import {configurationsSchema, Configurations} from './models/configurations.js';
|
|
3
|
-
import {measurementsSchema, Measurements} from './models/measurements.js';
|
|
4
|
-
import {monitorRequestsSchema, MonitorRequests} from './models/monitorRequests.js';
|
|
5
|
-
import {monitorsSchema, Monitors} from './models/monitors.js';
|
|
6
|
-
import {organizationsSchema, Organizations} from './models/organizations.js';
|
|
7
|
-
import {referenceMonitorInfoSchema, ReferenceMonitorInfo} from './models/referenceMonitorInfo.js';
|
|
8
|
-
import { lightMonitorSchema, LightMonitors } from './models/lightmonitors.js';
|
|
9
|
-
import { monitorSuppliersSchema, MonitorSuppliers } from './models/monitorSuppliers.js';
|
|
10
|
-
import { contextsSchema, Contexts } from './models/contexts.js';
|
|
11
|
-
import { parametersSchema, Parameters } from './models/parameters.js';
|
|
12
|
-
import {usersSchema, Users} from './models/users.js';
|
|
13
|
-
import { eventsSchema, Events } from './models/events.js';
|
|
14
|
-
import { qaNotificationsSchema, QANotifications } from './models/qanotifications.js';
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
1
|
+
import { adminSchema, Admin } from './models/admin.js';
|
|
2
|
+
import {configurationsSchema, Configurations} from './models/configurations.js';
|
|
3
|
+
import {measurementsSchema, Measurements} from './models/measurements.js';
|
|
4
|
+
import {monitorRequestsSchema, MonitorRequests} from './models/monitorRequests.js';
|
|
5
|
+
import {monitorsSchema, Monitors} from './models/monitors.js';
|
|
6
|
+
import {organizationsSchema, Organizations} from './models/organizations.js';
|
|
7
|
+
import {referenceMonitorInfoSchema, ReferenceMonitorInfo} from './models/referenceMonitorInfo.js';
|
|
8
|
+
import { lightMonitorSchema, LightMonitors } from './models/lightmonitors.js';
|
|
9
|
+
import { monitorSuppliersSchema, MonitorSuppliers } from './models/monitorSuppliers.js';
|
|
10
|
+
import { contextsSchema, Contexts } from './models/contexts.js';
|
|
11
|
+
import { parametersSchema, Parameters } from './models/parameters.js';
|
|
12
|
+
import {usersSchema, Users} from './models/users.js';
|
|
13
|
+
import { eventsSchema, Events } from './models/events.js';
|
|
14
|
+
import { qaNotificationsSchema, QANotifications } from './models/qanotifications.js';
|
|
15
|
+
import { announcementSchema, Announcements } from './models/announcements.js';
|
|
16
|
+
import dbConfig from './config/db.js';
|
|
17
|
+
import CustomLogger from './config/logger.js';
|
|
18
|
+
|
|
19
|
+
export function createDatabaseInstance({CONNECTION_URL, database}){
|
|
20
|
+
return new dbConfig({CONNECTION_URL, database});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function createLoggerInstance({ DATADOG_API_KEY, APPLICATION_NAME }) {
|
|
24
|
+
return new CustomLogger({ DATADOG_API_KEY, APPLICATION_NAME });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
adminSchema, Admin,
|
|
29
|
+
configurationsSchema, Configurations,
|
|
30
|
+
measurementsSchema, Measurements,
|
|
31
|
+
monitorRequestsSchema, MonitorRequests,
|
|
32
|
+
monitorsSchema, Monitors,
|
|
33
|
+
organizationsSchema, Organizations,
|
|
34
|
+
referenceMonitorInfoSchema, ReferenceMonitorInfo,
|
|
35
|
+
usersSchema, Users,
|
|
36
|
+
eventsSchema, Events,
|
|
37
|
+
lightMonitorSchema, LightMonitors,
|
|
38
|
+
monitorSuppliersSchema, MonitorSuppliers,
|
|
39
|
+
contextsSchema, Contexts,
|
|
40
|
+
parametersSchema, Parameters,
|
|
41
|
+
qaNotificationsSchema, QANotifications,
|
|
42
|
+
announcementSchema, Announcements
|
|
41
43
|
};
|
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']},
|
|
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']},
|
|
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};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
|
|
3
|
+
const announcementSchema = mongoose.Schema({
|
|
4
|
+
type: String,
|
|
5
|
+
message: String,
|
|
6
|
+
link: String,
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
timestamps: true
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
const Announcements = mongoose.model('Announcements', announcementSchema)
|
|
13
|
+
|
|
14
|
+
export {announcementSchema, Announcements}
|
|
@@ -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,21 +1,21 @@
|
|
|
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
|
-
values: Object,
|
|
10
|
-
alertLevels: Object
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
timestamps: true,
|
|
14
|
-
}
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
eventsSchema.index({monitorId: 1});
|
|
18
|
-
eventsSchema.index({parameter: 1});
|
|
19
|
-
|
|
20
|
-
const Events = mongoose.model("Events", eventsSchema);
|
|
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
|
+
values: Object,
|
|
10
|
+
alertLevels: Object
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
timestamps: true,
|
|
14
|
+
}
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
eventsSchema.index({monitorId: 1});
|
|
18
|
+
eventsSchema.index({parameter: 1});
|
|
19
|
+
|
|
20
|
+
const Events = mongoose.model("Events", eventsSchema);
|
|
21
21
|
export {eventsSchema, Events};
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import mongoose from 'mongoose';
|
|
2
|
-
|
|
3
|
-
const lightMonitorSchema = mongoose.Schema({
|
|
4
|
-
monitorId: {type: mongoose.Types.ObjectId, ref: 'Monitors'},
|
|
5
|
-
currentColor: {type: String, default: '16000'},
|
|
6
|
-
isActive: { type: Boolean, default: false },
|
|
7
|
-
configuration: {
|
|
8
|
-
hueUsername: { type: String},
|
|
9
|
-
clientId: { type: String, required: true },
|
|
10
|
-
clientSecret: { type: String, required: true },
|
|
11
|
-
lightId: { type: String, required: true },
|
|
12
|
-
accessTokenInfo: Object,
|
|
13
|
-
refreshTokenInfo: Object,
|
|
14
|
-
hueCode: { type: String, required: true}
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
timestamps: true
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
lightMonitorSchema.index({monitorId: 1});
|
|
22
|
-
|
|
23
|
-
const LightMonitors = mongoose.model('LightMonitor', lightMonitorSchema);
|
|
24
|
-
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
|
|
3
|
+
const lightMonitorSchema = mongoose.Schema({
|
|
4
|
+
monitorId: {type: mongoose.Types.ObjectId, ref: 'Monitors'},
|
|
5
|
+
currentColor: {type: String, default: '16000'},
|
|
6
|
+
isActive: { type: Boolean, default: false },
|
|
7
|
+
configuration: {
|
|
8
|
+
hueUsername: { type: String},
|
|
9
|
+
clientId: { type: String, required: true },
|
|
10
|
+
clientSecret: { type: String, required: true },
|
|
11
|
+
lightId: { type: String, required: true },
|
|
12
|
+
accessTokenInfo: Object,
|
|
13
|
+
refreshTokenInfo: Object,
|
|
14
|
+
hueCode: { type: String, required: true}
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
timestamps: true
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
lightMonitorSchema.index({monitorId: 1});
|
|
22
|
+
|
|
23
|
+
const LightMonitors = mongoose.model('LightMonitor', lightMonitorSchema);
|
|
24
|
+
|
|
25
25
|
export {lightMonitorSchema, LightMonitors};
|