@justair/justair-library 4.9.2 → 4.10.0-alpha.4c10af7
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 +118 -0
- package/dist/config/db.d.ts +18 -0
- package/dist/config/db.d.ts.map +1 -0
- package/dist/config/logger.d.ts +33 -0
- package/dist/config/logger.d.ts.map +1 -0
- package/dist/index.d.ts +70 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/models/admin.d.ts +3 -0
- package/dist/models/admin.d.ts.map +1 -0
- package/dist/models/alerts.d.ts +5 -0
- package/dist/models/alerts.d.ts.map +1 -0
- package/dist/models/announcements.d.ts +3 -0
- package/dist/models/announcements.d.ts.map +1 -0
- package/dist/models/apiKey.d.ts +3 -0
- package/dist/models/apiKey.d.ts.map +1 -0
- package/dist/models/configurations.d.ts +3 -0
- package/dist/models/configurations.d.ts.map +1 -0
- package/dist/models/contexts.d.ts +3 -0
- package/dist/models/contexts.d.ts.map +1 -0
- package/dist/models/dataCompleteness.d.ts +3 -0
- package/dist/models/dataCompleteness.d.ts.map +1 -0
- package/dist/models/events.d.ts +5 -0
- package/dist/models/events.d.ts.map +1 -0
- package/dist/models/features.d.ts +3 -0
- package/dist/models/features.d.ts.map +1 -0
- package/dist/models/jobs.d.ts +3 -0
- package/dist/models/jobs.d.ts.map +1 -0
- package/dist/models/lightmonitors.d.ts +3 -0
- package/dist/models/lightmonitors.d.ts.map +1 -0
- package/dist/models/measurements.d.ts +54 -0
- package/dist/models/measurements.d.ts.map +1 -0
- package/dist/models/monitorRequests.d.ts +3 -0
- package/dist/models/monitorRequests.d.ts.map +1 -0
- package/dist/models/monitorSuppliers.d.ts +3 -0
- package/dist/models/monitorSuppliers.d.ts.map +1 -0
- package/dist/models/monitors.d.ts +10 -0
- package/dist/models/monitors.d.ts.map +1 -0
- package/dist/models/networkMetrics.d.ts +3 -0
- package/dist/models/networkMetrics.d.ts.map +1 -0
- package/dist/models/organizations.d.ts +3 -0
- package/dist/models/organizations.d.ts.map +1 -0
- package/dist/models/parameters.d.ts +3 -0
- package/dist/models/parameters.d.ts.map +1 -0
- package/dist/models/rateOfChange.d.ts +3 -0
- package/dist/models/rateOfChange.d.ts.map +1 -0
- package/dist/models/sampleSites.d.ts +18 -0
- package/dist/models/sampleSites.d.ts.map +1 -0
- package/dist/models/samples.d.ts +17 -0
- package/dist/models/samples.d.ts.map +1 -0
- package/dist/models/tests/admin.test.d.ts +2 -0
- package/dist/models/tests/admin.test.d.ts.map +1 -0
- package/dist/models/tests/configurations.test.d.ts +2 -0
- package/dist/models/tests/configurations.test.d.ts.map +1 -0
- package/dist/models/tests/measurements.test.d.ts +2 -0
- package/dist/models/tests/measurements.test.d.ts.map +1 -0
- package/dist/models/tests/monitorRequests.test.d.ts +2 -0
- package/dist/models/tests/monitorRequests.test.d.ts.map +1 -0
- package/dist/models/tests/monitors.test.d.ts +2 -0
- package/dist/models/tests/monitors.test.d.ts.map +1 -0
- package/dist/models/tests/organizations.test.d.ts +2 -0
- package/dist/models/tests/organizations.test.d.ts.map +1 -0
- package/dist/models/tests/users.test.d.ts +2 -0
- package/dist/models/tests/users.test.d.ts.map +1 -0
- package/dist/models/usageMetrics.d.ts +3 -0
- package/dist/models/usageMetrics.d.ts.map +1 -0
- package/dist/models/users.d.ts +3 -0
- package/dist/models/users.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/models/monitors.js +1 -0
- package/.github/workflows/publish.yml +0 -28
- package/README +0 -146
- package/src/models/tests/admin.test.js +0 -42
- package/src/models/tests/configurations.test.js +0 -44
- package/src/models/tests/measurements.test.js +0 -46
- package/src/models/tests/monitorRequests.test.js +0 -46
- package/src/models/tests/monitors.test.js +0 -62
- package/src/models/tests/organizations.test.js +0 -51
- package/src/models/tests/users.test.js +0 -54
package/README.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# justair-library
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
`@justair/justair-library` is the shared internal npm package installed across all JustAir backend
|
|
6
|
+
and Lambda services. It is the source of truth for all Mongoose schemas and models, the database
|
|
7
|
+
connection class, the Winston/Datadog logger factory, and shared enums.
|
|
8
|
+
|
|
9
|
+
**Consuming services:** JustAirService, Public-API-Service, JustAirUserService,
|
|
10
|
+
JustAirNotificationService, CalculateAQIService, Processing-Engine, MonitorUpdateLambda,
|
|
11
|
+
MonitorUpdateCoordinator, calcaqi-fan-scheduler.
|
|
12
|
+
|
|
13
|
+
## Prerequisites
|
|
14
|
+
|
|
15
|
+
You must be a member of the JustAir organization on npmjs.org to install this package.
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @justair/justair-library
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Authenticate with your npm access token if needed:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm set //registry.npmjs.org/:_authToken=YOUR_ACCESS_TOKEN
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
```javascript
|
|
32
|
+
import { Monitors, Measurements, createLoggerInstance, Database } from '@justair/justair-library';
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Development Workflow
|
|
36
|
+
|
|
37
|
+
### Testing locally (fast iteration)
|
|
38
|
+
|
|
39
|
+
For rapid local development without waiting for CI:
|
|
40
|
+
|
|
41
|
+
1. **Build and pack:**
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm run build
|
|
45
|
+
npm pack
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
This creates a `.tgz` file (e.g., `justair-justair-library-4.9.2.tgz`).
|
|
49
|
+
|
|
50
|
+
2. **Install in a consuming service:**
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npm install /path/to/justair-library/justair-justair-library-4.9.2.tgz
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Or use `npm link` for live development:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# In the justair-library directory
|
|
60
|
+
npm link
|
|
61
|
+
|
|
62
|
+
# In your consuming service directory
|
|
63
|
+
npm link @justair/justair-library
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
3. **Unlink when done:**
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# In your consuming service directory
|
|
70
|
+
npm unlink @justair/justair-library
|
|
71
|
+
|
|
72
|
+
# In the justair-library directory
|
|
73
|
+
npm unlink
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Testing against a published alpha
|
|
77
|
+
|
|
78
|
+
For validating changes against the actual published artifact before merging:
|
|
79
|
+
|
|
80
|
+
1. Push your changes to your `JA-*` branch — CI automatically publishes an alpha version
|
|
81
|
+
tagged `@alpha` with your commit SHA (e.g. `4.9.2-alpha.a1b2c3d`)
|
|
82
|
+
|
|
83
|
+
2. In the consuming service, install the alpha:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
npm install @justair/justair-library@alpha
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
3. When done testing, revert to the stable version:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
npm install @justair/justair-library@latest
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Publishing
|
|
96
|
+
|
|
97
|
+
Publishing is fully automated — do not publish manually.
|
|
98
|
+
|
|
99
|
+
| Event | Result |
|
|
100
|
+
|---|---|
|
|
101
|
+
| Push to `JA-*` branch (src changes) | Publishes `@alpha` pre-release |
|
|
102
|
+
| Merge to `master` (src changes) | Publishes `@latest` stable release |
|
|
103
|
+
|
|
104
|
+
Before merging, bump the version in `package.json` according to semver:
|
|
105
|
+
- `patch` — bug fixes, internal changes
|
|
106
|
+
- `minor` — new exports, new optional schema fields
|
|
107
|
+
- `major` — breaking changes (removed exports, required fields without defaults, renamed fields)
|
|
108
|
+
|
|
109
|
+
See `CLAUDE.md` for the full schema change and versioning policy.
|
|
110
|
+
|
|
111
|
+
## Contributing
|
|
112
|
+
|
|
113
|
+
All PRs require approval from the library owners (see `CODEOWNERS`). Every PR is automatically
|
|
114
|
+
reviewed by Claude with library-specific rules enforced — breaking changes block merge.
|
|
115
|
+
|
|
116
|
+
## License
|
|
117
|
+
|
|
118
|
+
This project is licensed under the MIT License.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export default Database;
|
|
2
|
+
declare class Database {
|
|
3
|
+
static instances: Map<any, any>;
|
|
4
|
+
static getInstance(config: any): Promise<any>;
|
|
5
|
+
static getCurrentDatabase(): string;
|
|
6
|
+
static closeAllConnections(): Promise<void>;
|
|
7
|
+
constructor({ CONNECTION_URL, database }: {
|
|
8
|
+
CONNECTION_URL: any;
|
|
9
|
+
database: any;
|
|
10
|
+
});
|
|
11
|
+
CONNECTION_URL: any;
|
|
12
|
+
database: any;
|
|
13
|
+
connectionKey: string;
|
|
14
|
+
isConnected: boolean;
|
|
15
|
+
connect(): Promise<void>;
|
|
16
|
+
disconnect(): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=db.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/config/db.js"],"names":[],"mappings":";AAEA;IACE,gCAA6B;IA+D7B,8CAqBC;IAED,oCAKC;IAED,4CAgBC;IA3GD;;;OAKC;IAJC,oBAAoC;IACpC,cAAwB;IACxB,sBAAoD;IACpD,qBAAwB;IAG1B,yBAuCC;IAED,4BAWC;CAiDF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export default CustomLogger;
|
|
2
|
+
declare class CustomLogger {
|
|
3
|
+
constructor({ DATADOG_API_KEY, APPLICATION_NAME }: {
|
|
4
|
+
DATADOG_API_KEY: any;
|
|
5
|
+
APPLICATION_NAME: any;
|
|
6
|
+
});
|
|
7
|
+
DATADOG_API_KEY: any;
|
|
8
|
+
APPLICATION_NAME: any;
|
|
9
|
+
logger: import("winston").Logger;
|
|
10
|
+
_createLogger(): import("winston").Logger;
|
|
11
|
+
getLogger(): import("winston").Logger;
|
|
12
|
+
_getServiceMetadata(): {
|
|
13
|
+
service: any;
|
|
14
|
+
env: string;
|
|
15
|
+
version: string;
|
|
16
|
+
k_service: string;
|
|
17
|
+
k_revision: string;
|
|
18
|
+
k_configuration: string;
|
|
19
|
+
pod: string;
|
|
20
|
+
namespace: string;
|
|
21
|
+
node: string;
|
|
22
|
+
pid: number;
|
|
23
|
+
nodeVersion: string;
|
|
24
|
+
platform: NodeJS.Platform;
|
|
25
|
+
timestamp: string;
|
|
26
|
+
};
|
|
27
|
+
logServiceStartup(metadata?: {}): void;
|
|
28
|
+
logGracefulShutdown(signal: any, metadata?: {}): void;
|
|
29
|
+
logCrash(error: any, source: any, metadata?: {}): void;
|
|
30
|
+
logExit(code: any, metadata?: {}): void;
|
|
31
|
+
setupLifecycleHooks(): void;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/config/logger.js"],"names":[],"mappings":";AAGA;IACE;;;OAIC;IAHC,qBAAsC;IACtC,sBAAwC;IACxC,iCAAkC;IAGpC,0CA2BC;IAED,sCAEC;IAED;;;;;;;;;;;;;;MAgBC;IAED,uCAMC;IAED,sDAOC;IAED,uDAYC;IAED,wCAOC;IAED,4BAsCC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export function createLoggerInstance({ DATADOG_API_KEY, APPLICATION_NAME }: {
|
|
2
|
+
DATADOG_API_KEY: any;
|
|
3
|
+
APPLICATION_NAME: any;
|
|
4
|
+
}): CustomLogger;
|
|
5
|
+
import CustomLogger from "./config/logger.js";
|
|
6
|
+
import Database from "./config/db.js";
|
|
7
|
+
import { adminSchema } from "./models/admin.js";
|
|
8
|
+
import { Admin } from "./models/admin.js";
|
|
9
|
+
import { configurationsSchema } from "./models/configurations.js";
|
|
10
|
+
import { Configurations } from "./models/configurations.js";
|
|
11
|
+
import { measurementsSchema } from "./models/measurements.js";
|
|
12
|
+
import { Measurements } from "./models/measurements.js";
|
|
13
|
+
import { monitorRequestsSchema } from "./models/monitorRequests.js";
|
|
14
|
+
import { MonitorRequests } from "./models/monitorRequests.js";
|
|
15
|
+
import { monitorsSchema } from "./models/monitors.js";
|
|
16
|
+
import { Monitors } from "./models/monitors.js";
|
|
17
|
+
import { organizationsSchema } from "./models/organizations.js";
|
|
18
|
+
import { Organizations } from "./models/organizations.js";
|
|
19
|
+
import { usersSchema } from "./models/users.js";
|
|
20
|
+
import { Users } from "./models/users.js";
|
|
21
|
+
import { eventsSchema } from "./models/events.js";
|
|
22
|
+
import { Events } from "./models/events.js";
|
|
23
|
+
import { lightMonitorSchema } from "./models/lightmonitors.js";
|
|
24
|
+
import { LightMonitors } from "./models/lightmonitors.js";
|
|
25
|
+
import { monitorSuppliersSchema } from "./models/monitorSuppliers.js";
|
|
26
|
+
import { MonitorSuppliers } from "./models/monitorSuppliers.js";
|
|
27
|
+
import { contextsSchema } from "./models/contexts.js";
|
|
28
|
+
import { Contexts } from "./models/contexts.js";
|
|
29
|
+
import { parametersSchema } from "./models/parameters.js";
|
|
30
|
+
import { Parameters } from "./models/parameters.js";
|
|
31
|
+
import { announcementSchema } from "./models/announcements.js";
|
|
32
|
+
import { Announcements } from "./models/announcements.js";
|
|
33
|
+
import { jobsSchema } from "./models/jobs.js";
|
|
34
|
+
import { Jobs } from "./models/jobs.js";
|
|
35
|
+
import { apiKeySchema } from "./models/apiKey.js";
|
|
36
|
+
import { ApiKey } from "./models/apiKey.js";
|
|
37
|
+
import { UsageMetrics } from "./models/usageMetrics.js";
|
|
38
|
+
import { usageMetricsSchema } from "./models/usageMetrics.js";
|
|
39
|
+
import { Audit } from "./models/measurements.js";
|
|
40
|
+
import { auditSchema } from "./models/measurements.js";
|
|
41
|
+
import { EventsAudit } from "./models/events.js";
|
|
42
|
+
import { eventsAuditSchema } from "./models/events.js";
|
|
43
|
+
import { MonitorAudit } from "./models/monitors.js";
|
|
44
|
+
import { monitorAuditSchema } from "./models/monitors.js";
|
|
45
|
+
import { parametersEnum } from "./models/monitors.js";
|
|
46
|
+
import { deploymentTypesEnum } from "./models/monitors.js";
|
|
47
|
+
import { AlertsAudit } from "./models/alerts.js";
|
|
48
|
+
import { Alerts } from "./models/alerts.js";
|
|
49
|
+
import { alertsSchema } from "./models/alerts.js";
|
|
50
|
+
import { alertsAuditSchema } from "./models/alerts.js";
|
|
51
|
+
import { Features } from "./models/features.js";
|
|
52
|
+
import { featuresSchema } from "./models/features.js";
|
|
53
|
+
import { dataCompletenessSchema } from "./models/dataCompleteness.js";
|
|
54
|
+
import { DataCompleteness } from "./models/dataCompleteness.js";
|
|
55
|
+
import { networkMetricsSchema } from "./models/networkMetrics.js";
|
|
56
|
+
import { NetworkMetrics } from "./models/networkMetrics.js";
|
|
57
|
+
import { rateOfChangeSchema } from "./models/rateOfChange.js";
|
|
58
|
+
import { RateOfChange } from "./models/rateOfChange.js";
|
|
59
|
+
import { sampleSitesSchema } from "./models/sampleSites.js";
|
|
60
|
+
import { SampleSites } from "./models/sampleSites.js";
|
|
61
|
+
import { sampleSiteAuditSchema } from "./models/sampleSites.js";
|
|
62
|
+
import { SampleSiteAudit } from "./models/sampleSites.js";
|
|
63
|
+
import { sampleParametersEnum } from "./models/sampleSites.js";
|
|
64
|
+
import { samplesSchema } from "./models/samples.js";
|
|
65
|
+
import { Samples } from "./models/samples.js";
|
|
66
|
+
import { samplesAuditSchema } from "./models/samples.js";
|
|
67
|
+
import { SamplesAudit } from "./models/samples.js";
|
|
68
|
+
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 };
|
|
70
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AA4EA;;;iBAEC;yBAtBwB,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;kCAWpE,yBAAyB;4BAAzB,yBAAyB;sCAAzB,yBAAyB;gCAAzB,yBAAyB;qCAAzB,yBAAyB;8BASzB,qBAAqB;wBAArB,qBAAqB;mCAArB,qBAAqB;6BAArB,qBAAqB;uDAArB,qBAAqB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../src/models/admin.js"],"names":[],"mappings":"AAEA,8BAaG;AAUH,wBAAmD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alerts.d.ts","sourceRoot":"","sources":["../../src/models/alerts.js"],"names":[],"mappings":"AAiBA,+BAgCE;AAwKF,yBAAsD;AA3HtD,8BAAqE;AAhCrE,oCA8BE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"announcements.d.ts","sourceRoot":"","sources":["../../src/models/announcements.js"],"names":[],"mappings":"AAcA,qCAWE;AAEF,gCAA0E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiKey.d.ts","sourceRoot":"","sources":["../../src/models/apiKey.js"],"names":[],"mappings":"AACA,+BAiBE;AAEF,yBAAsD"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataCompleteness.d.ts","sourceRoot":"","sources":["../../src/models/dataCompleteness.js"],"names":[],"mappings":"AAEA,yCAaE;AACF,mCAGE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/models/events.js"],"names":[],"mappings":"AA0BA,+BAmBE;AAgFF,yBAAsD;AAtGtD,8BAAqE;AApBrE,oCAkBE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../../src/models/features.js"],"names":[],"mappings":"AAEA,iCAOE;AAEF,2BAA4D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobs.d.ts","sourceRoot":"","sources":["../../src/models/jobs.js"],"names":[],"mappings":"AAEA,6BA4BE;AAEF,uBAAgD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lightmonitors.d.ts","sourceRoot":"","sources":["../../src/models/lightmonitors.js"],"names":[],"mappings":"AAEA,qCAqBE;AAIF,gCAAyE"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export const measurementsSchema: any;
|
|
2
|
+
export const Measurements: any;
|
|
3
|
+
export const Audit: any;
|
|
4
|
+
export const auditSchema: any;
|
|
5
|
+
export const annotationSchema: mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
6
|
+
_id: true;
|
|
7
|
+
timestamps: false;
|
|
8
|
+
}, {
|
|
9
|
+
source: "admin" | "processing_engine";
|
|
10
|
+
timestamp: Date;
|
|
11
|
+
comment: string;
|
|
12
|
+
measurementIdentifier: string;
|
|
13
|
+
adminId?: {
|
|
14
|
+
prototype?: mongoose.Types.ObjectId;
|
|
15
|
+
cacheHexString?: unknown;
|
|
16
|
+
generate?: {};
|
|
17
|
+
createFromTime?: {};
|
|
18
|
+
createFromHexString?: {};
|
|
19
|
+
createFromBase64?: {};
|
|
20
|
+
isValid?: {};
|
|
21
|
+
};
|
|
22
|
+
}, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
|
|
23
|
+
source: "admin" | "processing_engine";
|
|
24
|
+
timestamp: Date;
|
|
25
|
+
comment: string;
|
|
26
|
+
measurementIdentifier: string;
|
|
27
|
+
adminId?: {
|
|
28
|
+
prototype?: mongoose.Types.ObjectId;
|
|
29
|
+
cacheHexString?: unknown;
|
|
30
|
+
generate?: {};
|
|
31
|
+
createFromTime?: {};
|
|
32
|
+
createFromHexString?: {};
|
|
33
|
+
createFromBase64?: {};
|
|
34
|
+
isValid?: {};
|
|
35
|
+
};
|
|
36
|
+
}>> & mongoose.FlatRecord<{
|
|
37
|
+
source: "admin" | "processing_engine";
|
|
38
|
+
timestamp: Date;
|
|
39
|
+
comment: string;
|
|
40
|
+
measurementIdentifier: string;
|
|
41
|
+
adminId?: {
|
|
42
|
+
prototype?: mongoose.Types.ObjectId;
|
|
43
|
+
cacheHexString?: unknown;
|
|
44
|
+
generate?: {};
|
|
45
|
+
createFromTime?: {};
|
|
46
|
+
createFromHexString?: {};
|
|
47
|
+
createFromBase64?: {};
|
|
48
|
+
isValid?: {};
|
|
49
|
+
};
|
|
50
|
+
}> & {
|
|
51
|
+
_id: mongoose.Types.ObjectId;
|
|
52
|
+
}>;
|
|
53
|
+
import mongoose from "mongoose";
|
|
54
|
+
//# sourceMappingURL=measurements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"measurements.d.ts","sourceRoot":"","sources":["../../src/models/measurements.js"],"names":[],"mappings":"AA8FA,qCAyBE;AAgJF,+BAAwE;AA5KxE,wBAAmD;AAzBnD,8BAuBE;AAjEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCE;qBA5DmB,UAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monitorRequests.d.ts","sourceRoot":"","sources":["../../src/models/monitorRequests.js"],"names":[],"mappings":"AAEA,wCAeE;AAEF,kCAGE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monitorSuppliers.d.ts","sourceRoot":"","sources":["../../src/models/monitorSuppliers.js"],"names":[],"mappings":"AAaA,yCAmCE;AAEF,mCAGE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const monitorsSchema: any;
|
|
2
|
+
export const Monitors: any;
|
|
3
|
+
export const monitorAuditSchema: any;
|
|
4
|
+
export const MonitorAudit: any;
|
|
5
|
+
export const parametersEnum: string[];
|
|
6
|
+
export namespace deploymentTypesEnum {
|
|
7
|
+
let STATIONARY: string;
|
|
8
|
+
let MOBILE: string;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=monitors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monitors.d.ts","sourceRoot":"","sources":["../../src/models/monitors.js"],"names":[],"mappings":"AAiLA,iCAsHE;AA6IF,2BAA4D;AArS5D,qCA4BE;AAGF,+BAAwE;AA7KxE,sCAsBE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"networkMetrics.d.ts","sourceRoot":"","sources":["../../src/models/networkMetrics.js"],"names":[],"mappings":"AAEA,uCAWyB;AA2BzB,iCAA8E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organizations.d.ts","sourceRoot":"","sources":["../../src/models/organizations.js"],"names":[],"mappings":"AAyFA,sCAsBE;AAyDF,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":"rateOfChange.d.ts","sourceRoot":"","sources":["../../src/models/rateOfChange.js"],"names":[],"mappings":"AAEA,qCAeE;AAcF,+BAAwE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const sampleSitesSchema: any;
|
|
2
|
+
export const SampleSites: any;
|
|
3
|
+
export const sampleSiteAuditSchema: any;
|
|
4
|
+
export const SampleSiteAudit: any;
|
|
5
|
+
export const sampleParametersEnum: string[];
|
|
6
|
+
export namespace sampleParameterReferenceConcentrations {
|
|
7
|
+
let C6H6: number;
|
|
8
|
+
let PB: number;
|
|
9
|
+
let AS: number;
|
|
10
|
+
let CD: number;
|
|
11
|
+
let CR: number;
|
|
12
|
+
let NI: any;
|
|
13
|
+
let BA: any;
|
|
14
|
+
let FE: any;
|
|
15
|
+
let CU: any;
|
|
16
|
+
let ZN: any;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=sampleSites.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sampleSites.d.ts","sourceRoot":"","sources":["../../src/models/sampleSites.js"],"names":[],"mappings":"AA8EA,oCAmDE;AA2JF,8BAAqE;AApOrE,wCAgBE;AAGF,kCAAiF;AAvEjF,4CAWE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const samplesSchema: any;
|
|
2
|
+
export const Samples: any;
|
|
3
|
+
export const SamplesAudit: any;
|
|
4
|
+
export const samplesAuditSchema: any;
|
|
5
|
+
export namespace sampleParameterReferenceConcentrations {
|
|
6
|
+
let C6H6: number;
|
|
7
|
+
let PB: number;
|
|
8
|
+
let AS: number;
|
|
9
|
+
let CD: number;
|
|
10
|
+
let CR: number;
|
|
11
|
+
let NI: any;
|
|
12
|
+
let BA: any;
|
|
13
|
+
let FE: any;
|
|
14
|
+
let CU: any;
|
|
15
|
+
let ZN: any;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=samples.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"samples.d.ts","sourceRoot":"","sources":["../../src/models/samples.js"],"names":[],"mappings":"AA6CA,gCAkBE;AAoIF,0BAAyD;AAzJzD,+BAAwE;AAvBxE,qCAoBE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin.test.d.ts","sourceRoot":"","sources":["../../../src/models/tests/admin.test.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configurations.test.d.ts","sourceRoot":"","sources":["../../../src/models/tests/configurations.test.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"measurements.test.d.ts","sourceRoot":"","sources":["../../../src/models/tests/measurements.test.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monitorRequests.test.d.ts","sourceRoot":"","sources":["../../../src/models/tests/monitorRequests.test.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monitors.test.d.ts","sourceRoot":"","sources":["../../../src/models/tests/monitors.test.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organizations.test.d.ts","sourceRoot":"","sources":["../../../src/models/tests/organizations.test.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"users.test.d.ts","sourceRoot":"","sources":["../../../src/models/tests/users.test.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usageMetrics.d.ts","sourceRoot":"","sources":["../../src/models/usageMetrics.js"],"names":[],"mappings":"AAUA,qCAWE;AAEF,+BAAwE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../src/models/users.js"],"names":[],"mappings":"AAEA,8BA8CE;AAIF,wBAAmD"}
|
package/package.json
CHANGED
package/src/models/monitors.js
CHANGED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
name: Publish Package
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- 'JA-*'
|
|
7
|
-
|
|
8
|
-
permissions:
|
|
9
|
-
id-token: write # Required for OIDC
|
|
10
|
-
contents: read
|
|
11
|
-
|
|
12
|
-
jobs:
|
|
13
|
-
publish:
|
|
14
|
-
runs-on: ubuntu-latest
|
|
15
|
-
steps:
|
|
16
|
-
- uses: actions/checkout@v4
|
|
17
|
-
|
|
18
|
-
- uses: actions/setup-node@v4
|
|
19
|
-
with:
|
|
20
|
-
node-version: '20'
|
|
21
|
-
registry-url: 'https://registry.npmjs.org'
|
|
22
|
-
|
|
23
|
-
# Ensure npm 11.5.1 or later is installed
|
|
24
|
-
- name: Update npm
|
|
25
|
-
run: npm install -g npm@latest
|
|
26
|
-
- run: npm ci
|
|
27
|
-
- run: npm run build --if-present
|
|
28
|
-
- run: npm publish
|
package/README
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
# justair-library
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
The `justair-library` is an NPM package that is installed on all backend and AWS Lambda services within the JustAir ecosystem. It provides essential utilities and shared functionality used across various JustAir services.
|
|
6
|
-
|
|
7
|
-
## Prerequisites
|
|
8
|
-
|
|
9
|
-
To access and install the `justair-library`, you must be a part of the JustAir organization on npmjs.org. Ensure you have the following:
|
|
10
|
-
|
|
11
|
-
1. **NPM** - Node Package Manager
|
|
12
|
-
2. **Access Token** - Obtain your access token from the JustAir organization on npmjs.org
|
|
13
|
-
|
|
14
|
-
## Installation
|
|
15
|
-
|
|
16
|
-
To install the `justair-library`, use the following command:
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
npm install @justair/justair-library
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
Ensure you have authenticated with npmjs.org using your access token:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
npm login
|
|
26
|
-
# Follow the prompts to authenticate
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
Alternatively, you can set your token directly in your NPM configuration:
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
npm set //registry.npmjs.org/:_authToken=YOUR_ACCESS_TOKEN
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## Usage
|
|
36
|
-
|
|
37
|
-
After installation, you can import and use the library in your project:
|
|
38
|
-
|
|
39
|
-
```javascript
|
|
40
|
-
const justair = require("@justair/justair-library");
|
|
41
|
-
|
|
42
|
-
// Example usage
|
|
43
|
-
justair.someUtilityFunction();
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Upgrading Versions
|
|
47
|
-
|
|
48
|
-
To upgrade to a newer version of the justair-library, run:
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
npm update @justair/justair-library
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
Ensure you review the release notes and any potential breaking changes before upgrading.
|
|
55
|
-
|
|
56
|
-
## Publishing a New Version
|
|
57
|
-
|
|
58
|
-
### Testing Locally Before Publishing
|
|
59
|
-
|
|
60
|
-
Before publishing to npm, it's recommended to test your package locally:
|
|
61
|
-
|
|
62
|
-
1. **Build and pack the library locally:**
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
npm run build # If you have a build step
|
|
66
|
-
npm pack
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
This creates a `.tgz` file (e.g., `justair-justair-library-1.0.0.tgz`)
|
|
70
|
-
|
|
71
|
-
2. **Install in a test project:**
|
|
72
|
-
|
|
73
|
-
In your test project directory:
|
|
74
|
-
|
|
75
|
-
```bash
|
|
76
|
-
npm install /path/to/justair-library/justair-justair-library-1.0.0.tgz
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
Or using npm link for development:
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
# In the justair-library directory
|
|
83
|
-
npm link
|
|
84
|
-
|
|
85
|
-
# In your test project directory
|
|
86
|
-
npm link @justair/justair-library
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
3. **Test your changes:**
|
|
90
|
-
|
|
91
|
-
Import and test the library in your test project to ensure everything works as expected.
|
|
92
|
-
|
|
93
|
-
4. **Unlink when done (if using npm link):**
|
|
94
|
-
|
|
95
|
-
```bash
|
|
96
|
-
# In your test project directory
|
|
97
|
-
npm unlink @justair/justair-library
|
|
98
|
-
|
|
99
|
-
# In the justair-library directory
|
|
100
|
-
npm unlink
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
### Publishing to npm
|
|
104
|
-
|
|
105
|
-
Once you've tested locally and are ready to publish:
|
|
106
|
-
|
|
107
|
-
1. **Update the version number:**
|
|
108
|
-
|
|
109
|
-
Modify the version field in `package.json` according to semantic versioning guidelines.
|
|
110
|
-
|
|
111
|
-
2. **Build the package (if applicable):**
|
|
112
|
-
|
|
113
|
-
Ensure any build steps are completed:
|
|
114
|
-
|
|
115
|
-
```bash
|
|
116
|
-
npm run build
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
3. **Login to npm:**
|
|
120
|
-
|
|
121
|
-
Ensure you are authenticated with the JustAir organization on npmjs.org:
|
|
122
|
-
|
|
123
|
-
```bash
|
|
124
|
-
npm login
|
|
125
|
-
# Follow the prompts to authenticate
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
4. **Publish the package:**
|
|
129
|
-
|
|
130
|
-
Run the following command to publish the updated package:
|
|
131
|
-
|
|
132
|
-
```bash
|
|
133
|
-
npm publish --access public
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
## Contributing
|
|
137
|
-
|
|
138
|
-
If you would like to contribute to this project, please fork the repository and submit a pull request. For major changes, please open an issue first to discuss what you would like to change.
|
|
139
|
-
|
|
140
|
-
## License
|
|
141
|
-
|
|
142
|
-
This project is licensed under the MIT License - see the LICENSE file for details.
|
|
143
|
-
|
|
144
|
-
## Contact
|
|
145
|
-
|
|
146
|
-
For any inquiries or support, please contact the development team.
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import mongoose from 'mongoose';
|
|
2
|
-
import { MongoMemoryServer } from 'mongodb-memory-server';
|
|
3
|
-
import Admin from '../admins.js'; // Assuming this file is in the same directory
|
|
4
|
-
|
|
5
|
-
let mongoServer;
|
|
6
|
-
|
|
7
|
-
// Before running the tests, start the mock MongoDB server
|
|
8
|
-
beforeAll(async () => {
|
|
9
|
-
mongoServer = await MongoMemoryServer.create();
|
|
10
|
-
const mongoUri = mongoServer.getUri();
|
|
11
|
-
mongoose.connect(mongoUri, { useNewUrlParser: true, useUnifiedTopology: true });
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
// After running the tests, stop the mock MongoDB server and close the Mongoose connection
|
|
15
|
-
afterAll(async () => {
|
|
16
|
-
await mongoose.disconnect();
|
|
17
|
-
await mongoServer.stop();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
// Clear the database and reset the state before each test
|
|
21
|
-
beforeEach(async () => {
|
|
22
|
-
await mongoose.connection.dropDatabase();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// Sample test case
|
|
26
|
-
test('Create admin and fetch it from the database', async () => {
|
|
27
|
-
const adminData = {
|
|
28
|
-
name: 'John Doe',
|
|
29
|
-
phone: '1234567890',
|
|
30
|
-
email: 'john@example.com',
|
|
31
|
-
password: 'password123',
|
|
32
|
-
orgId: mongoose.Types.ObjectId(), // Generate a new ObjectId for orgId
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
// Create a new admin document
|
|
36
|
-
const createdAdmin = await Admin.create(adminData);
|
|
37
|
-
|
|
38
|
-
// Fetch the admin from the database
|
|
39
|
-
const fetchedAdmin = await Admin.findById(createdAdmin._id);
|
|
40
|
-
|
|
41
|
-
expect(fetchedAdmin).toMatchObject(adminData);
|
|
42
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import mongoose from 'mongoose';
|
|
2
|
-
import { MongoMemoryServer } from 'mongodb-memory-server';
|
|
3
|
-
import Configurations from '../configurations.js'; // Assuming this file is in the same directory
|
|
4
|
-
|
|
5
|
-
let mongoServer;
|
|
6
|
-
|
|
7
|
-
// Before running the tests, start the mock MongoDB server
|
|
8
|
-
beforeAll(async () => {
|
|
9
|
-
mongoServer = await MongoMemoryServer.create();
|
|
10
|
-
const mongoUri = mongoServer.getUri();
|
|
11
|
-
mongoose.connect(mongoUri, { useNewUrlParser: true, useUnifiedTopology: true });
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
// After running the tests, stop the mock MongoDB server and close the Mongoose connection
|
|
15
|
-
afterAll(async () => {
|
|
16
|
-
await mongoose.disconnect();
|
|
17
|
-
await mongoServer.stop();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
// Clear the database and reset the state before each test
|
|
21
|
-
beforeEach(async () => {
|
|
22
|
-
await mongoose.connection.dropDatabase();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// Sample test case
|
|
26
|
-
test('Create configuration and fetch it from the database', async () => {
|
|
27
|
-
const configurationData = {
|
|
28
|
-
type: 'flag',
|
|
29
|
-
name: 'FeatureA',
|
|
30
|
-
properties: {
|
|
31
|
-
enabled: true,
|
|
32
|
-
percentage: 50,
|
|
33
|
-
},
|
|
34
|
-
isActive: true,
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
// Create a new configuration document
|
|
38
|
-
const createdConfiguration = await Configurations.create(configurationData);
|
|
39
|
-
|
|
40
|
-
// Fetch the configuration from the database
|
|
41
|
-
const fetchedConfiguration = await Configurations.findById(createdConfiguration._id);
|
|
42
|
-
|
|
43
|
-
expect(fetchedConfiguration).toMatchObject(configurationData);
|
|
44
|
-
});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import mongoose from 'mongoose';
|
|
2
|
-
import { MongoMemoryServer } from 'mongodb-memory-server';
|
|
3
|
-
import Measurements from '../measurements.js'; // Assuming this file is in the same directory
|
|
4
|
-
|
|
5
|
-
let mongoServer;
|
|
6
|
-
|
|
7
|
-
// Before running the tests, start the mock MongoDB server
|
|
8
|
-
beforeAll(async () => {
|
|
9
|
-
mongoServer = await MongoMemoryServer.create();
|
|
10
|
-
const mongoUri = mongoServer.getUri();
|
|
11
|
-
mongoose.connect(mongoUri, { useNewUrlParser: true, useUnifiedTopology: true });
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
// After running the tests, stop the mock MongoDB server and close the Mongoose connection
|
|
15
|
-
afterAll(async () => {
|
|
16
|
-
await mongoose.disconnect();
|
|
17
|
-
await mongoServer.stop();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
// Clear the database and reset the state before each test
|
|
21
|
-
beforeEach(async () => {
|
|
22
|
-
await mongoose.connection.dropDatabase();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// Sample test case
|
|
26
|
-
test('Create measurement and fetch it from the database', async () => {
|
|
27
|
-
const measurementData = {
|
|
28
|
-
monitorId: mongoose.Types.ObjectId(), // Generate a new ObjectId for monitorId
|
|
29
|
-
orgId: mongoose.Types.ObjectId(), // Generate a new ObjectId for orgId
|
|
30
|
-
timeUpdated: new Date(),
|
|
31
|
-
measurements: {
|
|
32
|
-
temperature: 25,
|
|
33
|
-
humidity: 60,
|
|
34
|
-
},
|
|
35
|
-
alert: 'Good',
|
|
36
|
-
alertMessage: 'High temperature detected',
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
// Create a new measurement document
|
|
40
|
-
const createdMeasurement = await Measurements.create(measurementData);
|
|
41
|
-
|
|
42
|
-
// Fetch the measurement from the database
|
|
43
|
-
const fetchedMeasurement = await Measurements.findById(createdMeasurement._id);
|
|
44
|
-
|
|
45
|
-
expect(fetchedMeasurement).toMatchObject(measurementData);
|
|
46
|
-
});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import mongoose from 'mongoose';
|
|
2
|
-
import { MongoMemoryServer } from 'mongodb-memory-server';
|
|
3
|
-
import MonitorRequests from '../monitorRequests.js'; // Assuming this file is in the same directory
|
|
4
|
-
|
|
5
|
-
let mongoServer;
|
|
6
|
-
|
|
7
|
-
// Before running the tests, start the mock MongoDB server
|
|
8
|
-
beforeAll(async () => {
|
|
9
|
-
mongoServer = await MongoMemoryServer.create();
|
|
10
|
-
const mongoUri = mongoServer.getUri();
|
|
11
|
-
mongoose.connect(mongoUri, { useNewUrlParser: true, useUnifiedTopology: true });
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
// After running the tests, stop the mock MongoDB server and close the Mongoose connection
|
|
15
|
-
afterAll(async () => {
|
|
16
|
-
await mongoose.disconnect();
|
|
17
|
-
await mongoServer.stop();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
// Clear the database and reset the state before each test
|
|
21
|
-
beforeEach(async () => {
|
|
22
|
-
await mongoose.connection.dropDatabase();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// Sample test case
|
|
26
|
-
test('Create monitor request and fetch it from the database', async () => {
|
|
27
|
-
const monitorRequestData = {
|
|
28
|
-
monitorOwnerOrg: mongoose.Types.ObjectId(), // Generate a new ObjectId for monitorOwnerOrg
|
|
29
|
-
monitorOwnerOrgName: 'Organization A',
|
|
30
|
-
monitorSharerOrg: mongoose.Types.ObjectId(), // Generate a new ObjectId for monitorSharerOrg
|
|
31
|
-
monitorSharerOrgName: 'Organization B',
|
|
32
|
-
monitorList: [
|
|
33
|
-
mongoose.Types.ObjectId(), // Generate a new ObjectId for each monitor in the list
|
|
34
|
-
mongoose.Types.ObjectId(),
|
|
35
|
-
],
|
|
36
|
-
status: 'Requested',
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
// Create a new monitor request document
|
|
40
|
-
const createdMonitorRequest = await MonitorRequests.create(monitorRequestData);
|
|
41
|
-
|
|
42
|
-
// Fetch the monitor request from the database
|
|
43
|
-
const fetchedMonitorRequest = await MonitorRequests.findById(createdMonitorRequest._id);
|
|
44
|
-
|
|
45
|
-
expect(fetchedMonitorRequest).toMatchObject(monitorRequestData);
|
|
46
|
-
});
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { Decimal128 } from 'bson';
|
|
2
|
-
import mongoose from 'mongoose';
|
|
3
|
-
import { MongoMemoryServer } from 'mongodb-memory-server';
|
|
4
|
-
import Monitors from '../monitors.js'; // Assuming this file is in the same directory
|
|
5
|
-
|
|
6
|
-
let mongoServer;
|
|
7
|
-
|
|
8
|
-
// Before running the tests, start the mock MongoDB server
|
|
9
|
-
beforeAll(async () => {
|
|
10
|
-
mongoServer = await MongoMemoryServer.create();
|
|
11
|
-
const mongoUri = mongoServer.getUri();
|
|
12
|
-
mongoose.connect(mongoUri, { useNewUrlParser: true, useUnifiedTopology: true });
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
// After running the tests, stop the mock MongoDB server and close the Mongoose connection
|
|
16
|
-
afterAll(async () => {
|
|
17
|
-
await mongoose.disconnect();
|
|
18
|
-
await mongoServer.stop();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
// Clear the database and reset the state before each test
|
|
22
|
-
beforeEach(async () => {
|
|
23
|
-
await mongoose.connection.dropDatabase();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
// Sample test case
|
|
27
|
-
test('Create monitor and fetch it from the database', async () => {
|
|
28
|
-
const monitorData = {
|
|
29
|
-
monitorCode: 'ABC123',
|
|
30
|
-
monitorSupplier: 'clarity',
|
|
31
|
-
monitorIdFromSupplier: '123456',
|
|
32
|
-
measurementUpdate: new Date(),
|
|
33
|
-
monitorProperties: {
|
|
34
|
-
property1: 'value1',
|
|
35
|
-
property2: 'value2',
|
|
36
|
-
},
|
|
37
|
-
isPrivate: false,
|
|
38
|
-
monitorState: 'Collocation',
|
|
39
|
-
sponsor: mongoose.Types.ObjectId(), // Generate a new ObjectId for sponsor
|
|
40
|
-
sponsorName: 'Organization A',
|
|
41
|
-
monitorLatitude: 37.7749,
|
|
42
|
-
monitorLongitude: -122.4194,
|
|
43
|
-
location: {
|
|
44
|
-
city: 'San Francisco',
|
|
45
|
-
country: 'United States',
|
|
46
|
-
},
|
|
47
|
-
context: ['School'],
|
|
48
|
-
colocationDate: new Date(),
|
|
49
|
-
parameters: ['NO2', 'PM2.5', 'Temperature'],
|
|
50
|
-
latestPM2_5: Decimal128.fromString('10.5'), // Use Decimal128 for decimal values
|
|
51
|
-
latestAQI_PM2_5: 75,
|
|
52
|
-
isActive: true,
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
// Create a new monitor document
|
|
56
|
-
const createdMonitor = await Monitors.create(monitorData);
|
|
57
|
-
|
|
58
|
-
// Fetch the monitor from the database
|
|
59
|
-
const fetchedMonitor = await Monitors.findById(createdMonitor._id);
|
|
60
|
-
|
|
61
|
-
expect(fetchedMonitor).toMatchObject(monitorData);
|
|
62
|
-
});
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import mongoose from 'mongoose';
|
|
2
|
-
import { MongoMemoryServer } from 'mongodb-memory-server';
|
|
3
|
-
import Organizations from '../organizations.js'; // Assuming this file is in the same directory
|
|
4
|
-
|
|
5
|
-
let mongoServer;
|
|
6
|
-
|
|
7
|
-
// Before running the tests, start the mock MongoDB server
|
|
8
|
-
beforeAll(async () => {
|
|
9
|
-
mongoServer = await MongoMemoryServer.create();
|
|
10
|
-
const mongoUri = mongoServer.getUri();
|
|
11
|
-
mongoose.connect(mongoUri, { useNewUrlParser: true, useUnifiedTopology: true });
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
// After running the tests, stop the mock MongoDB server and close the Mongoose connection
|
|
15
|
-
afterAll(async () => {
|
|
16
|
-
await mongoose.disconnect();
|
|
17
|
-
await mongoServer.stop();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
// Clear the database and reset the state before each test
|
|
21
|
-
beforeEach(async () => {
|
|
22
|
-
await mongoose.connection.dropDatabase();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// Sample test case
|
|
26
|
-
test('Create organization and fetch it from the database', async () => {
|
|
27
|
-
const organizationData = {
|
|
28
|
-
name: 'Acme Corp',
|
|
29
|
-
website: 'https://www.example.com',
|
|
30
|
-
location: {
|
|
31
|
-
city: 'San Francisco',
|
|
32
|
-
country: 'United States',
|
|
33
|
-
},
|
|
34
|
-
authorized: false,
|
|
35
|
-
orgAPIKey: [{ key: 'ABC123' }],
|
|
36
|
-
orgCode: 'ACME123',
|
|
37
|
-
orgDescription: 'A sample organization',
|
|
38
|
-
orgLogo: 'https://www.example.com/logo.png',
|
|
39
|
-
connectedMonitors: [mongoose.Types.ObjectId()], // Generate a new ObjectId for each connected monitor
|
|
40
|
-
communityMessages: [{ message: 'Welcome to our community!' }],
|
|
41
|
-
isActive: true,
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
// Create a new organization document
|
|
45
|
-
const createdOrganization = await Organizations.create(organizationData);
|
|
46
|
-
|
|
47
|
-
// Fetch the organization from the database
|
|
48
|
-
const fetchedOrganization = await Organizations.findById(createdOrganization._id);
|
|
49
|
-
|
|
50
|
-
expect(fetchedOrganization).toMatchObject(organizationData);
|
|
51
|
-
});
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import mongoose from 'mongoose';
|
|
2
|
-
import { MongoMemoryServer } from 'mongodb-memory-server';
|
|
3
|
-
import Users from '../users.js'; // Assuming this file is in the same directory
|
|
4
|
-
|
|
5
|
-
let mongoServer;
|
|
6
|
-
|
|
7
|
-
// Before running the tests, start the mock MongoDB server
|
|
8
|
-
beforeAll(async () => {
|
|
9
|
-
mongoServer = await MongoMemoryServer.create();
|
|
10
|
-
const mongoUri = mongoServer.getUri();
|
|
11
|
-
mongoose.connect(mongoUri, { useNewUrlParser: true, useUnifiedTopology: true });
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
// After running the tests, stop the mock MongoDB server and close the Mongoose connection
|
|
15
|
-
afterAll(async () => {
|
|
16
|
-
await mongoose.disconnect();
|
|
17
|
-
await mongoServer.stop();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
// Clear the database and reset the state before each test
|
|
21
|
-
beforeEach(async () => {
|
|
22
|
-
await mongoose.connection.dropDatabase();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// Sample test case
|
|
26
|
-
test('Create user and fetch it from the database', async () => {
|
|
27
|
-
const userData = {
|
|
28
|
-
name: 'John Doe',
|
|
29
|
-
phone: '1234567890',
|
|
30
|
-
email: 'john.doe@example.com',
|
|
31
|
-
zipCode: '12345',
|
|
32
|
-
location: {
|
|
33
|
-
city: 'San Francisco',
|
|
34
|
-
country: 'United States',
|
|
35
|
-
},
|
|
36
|
-
organizations: [mongoose.Types.ObjectId()], // Generate a new ObjectId for each organization
|
|
37
|
-
alertPhone: '9876543210',
|
|
38
|
-
alertCount: 0,
|
|
39
|
-
subscribedMonitors: [mongoose.Types.ObjectId()], // Generate a new ObjectId for each subscribed monitor
|
|
40
|
-
currentAlertMode: 'Good',
|
|
41
|
-
latestAlerts: [{ message: 'Alert 1' }],
|
|
42
|
-
optInPhone: true,
|
|
43
|
-
optInEmail: true,
|
|
44
|
-
isActive: true,
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
// Create a new user document
|
|
48
|
-
const createdUser = await Users.create(userData);
|
|
49
|
-
|
|
50
|
-
// Fetch the user from the database
|
|
51
|
-
const fetchedUser = await Users.findById(createdUser._id);
|
|
52
|
-
|
|
53
|
-
expect(fetchedUser).toMatchObject(userData);
|
|
54
|
-
});
|