@justair/justair-library 3.1.39 → 3.2.0
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/package.json +1 -1
- package/src/config/db.js +36 -15
- package/src/index.js +6 -0
- package/src/models/apiKey.js +23 -0
- package/src/models/usageMetrics.js +28 -0
- package/dist/config/db.d.ts +0 -11
- package/dist/config/db.d.ts.map +0 -1
- package/dist/config/logger.d.ts +0 -13
- package/dist/config/logger.d.ts.map +0 -1
- package/dist/index.d.ts +0 -44
- package/dist/index.d.ts.map +0 -1
- package/dist/models/admin.d.ts +0 -3
- package/dist/models/admin.d.ts.map +0 -1
- package/dist/models/announcements.d.ts +0 -3
- package/dist/models/announcements.d.ts.map +0 -1
- package/dist/models/configurations.d.ts +0 -3
- package/dist/models/configurations.d.ts.map +0 -1
- package/dist/models/contexts.d.ts +0 -3
- package/dist/models/contexts.d.ts.map +0 -1
- package/dist/models/events.d.ts +0 -3
- package/dist/models/events.d.ts.map +0 -1
- package/dist/models/jobs.d.ts +0 -3
- package/dist/models/jobs.d.ts.map +0 -1
- package/dist/models/lightmonitors.d.ts +0 -3
- package/dist/models/lightmonitors.d.ts.map +0 -1
- package/dist/models/measurements.d.ts +0 -3
- package/dist/models/measurements.d.ts.map +0 -1
- package/dist/models/monitorRequests.d.ts +0 -3
- package/dist/models/monitorRequests.d.ts.map +0 -1
- package/dist/models/monitorSuppliers.d.ts +0 -3
- package/dist/models/monitorSuppliers.d.ts.map +0 -1
- package/dist/models/monitors.d.ts +0 -3
- package/dist/models/monitors.d.ts.map +0 -1
- package/dist/models/organizations.d.ts +0 -3
- package/dist/models/organizations.d.ts.map +0 -1
- package/dist/models/parameters.d.ts +0 -3
- package/dist/models/parameters.d.ts.map +0 -1
- package/dist/models/qanotifications.d.ts +0 -3
- package/dist/models/qanotifications.d.ts.map +0 -1
- package/dist/models/referenceMonitorInfo.d.ts +0 -3
- package/dist/models/referenceMonitorInfo.d.ts.map +0 -1
- package/dist/models/tests/admin.test.d.ts +0 -2
- package/dist/models/tests/admin.test.d.ts.map +0 -1
- package/dist/models/tests/configurations.test.d.ts +0 -2
- package/dist/models/tests/configurations.test.d.ts.map +0 -1
- package/dist/models/tests/measurements.test.d.ts +0 -2
- package/dist/models/tests/measurements.test.d.ts.map +0 -1
- package/dist/models/tests/monitorRequests.test.d.ts +0 -2
- package/dist/models/tests/monitorRequests.test.d.ts.map +0 -1
- package/dist/models/tests/monitors.test.d.ts +0 -2
- package/dist/models/tests/monitors.test.d.ts.map +0 -1
- package/dist/models/tests/organizations.test.d.ts +0 -2
- package/dist/models/tests/organizations.test.d.ts.map +0 -1
- package/dist/models/tests/users.test.d.ts +0 -2
- package/dist/models/tests/users.test.d.ts.map +0 -1
- package/dist/models/users.d.ts +0 -3
- package/dist/models/users.d.ts.map +0 -1
package/package.json
CHANGED
package/src/config/db.js
CHANGED
|
@@ -1,22 +1,43 @@
|
|
|
1
|
-
import
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
2
|
|
|
3
3
|
class Database {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
static instance = null;
|
|
5
|
+
constructor({ CONNECTION_URL, database }) {
|
|
6
|
+
this.CONNECTION_URL = CONNECTION_URL;
|
|
7
|
+
this.database = database;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async connect() {
|
|
11
|
+
if (mongoose.connection.readyState === 1) {
|
|
12
|
+
// If there's an active connection, close it first
|
|
13
|
+
await mongoose.disconnect();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
mongoose.set("strictQuery", false);
|
|
17
|
+
try {
|
|
18
|
+
await mongoose.connect(this.CONNECTION_URL, {
|
|
19
|
+
authSource: "admin",
|
|
20
|
+
ssl: true,
|
|
21
|
+
dbName: this.database,
|
|
22
|
+
});
|
|
23
|
+
console.log("Database connection successful");
|
|
24
|
+
} catch (err) {
|
|
25
|
+
console.error("Database connection error " + err);
|
|
26
|
+
throw err;
|
|
8
27
|
}
|
|
28
|
+
}
|
|
9
29
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
});
|
|
30
|
+
static async getInstance(config) {
|
|
31
|
+
if (
|
|
32
|
+
!Database.instance ||
|
|
33
|
+
Database.instance.CONNECTION_URL !== config.CONNECTION_URL ||
|
|
34
|
+
Database.instance.database !== config.database
|
|
35
|
+
) {
|
|
36
|
+
Database.instance = new Database(config);
|
|
37
|
+
await Database.instance.connect();
|
|
19
38
|
}
|
|
39
|
+
return Database.instance;
|
|
40
|
+
}
|
|
20
41
|
}
|
|
21
42
|
|
|
22
|
-
export default Database;
|
|
43
|
+
export default Database;
|
package/src/index.js
CHANGED
|
@@ -29,6 +29,8 @@ import {
|
|
|
29
29
|
} from "./models/qanotifications.js";
|
|
30
30
|
import { announcementSchema, Announcements } from "./models/announcements.js";
|
|
31
31
|
import { jobsSchema, Jobs } from "./models/jobs.js";
|
|
32
|
+
import { apiKeySchema, ApiKey } from "./models/apiKey.js";
|
|
33
|
+
import { UsageMetrics, usageMetricsSchema } from "./models/usageMetrics.js";
|
|
32
34
|
import dbConfig from "./config/db.js";
|
|
33
35
|
import CustomLogger from "./config/logger.js";
|
|
34
36
|
|
|
@@ -73,4 +75,8 @@ export {
|
|
|
73
75
|
Announcements,
|
|
74
76
|
jobsSchema,
|
|
75
77
|
Jobs,
|
|
78
|
+
apiKeySchema,
|
|
79
|
+
ApiKey,
|
|
80
|
+
UsageMetrics,
|
|
81
|
+
usageMetricsSchema,
|
|
76
82
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
const apiKeySchema = mongoose.Schema(
|
|
3
|
+
{
|
|
4
|
+
adminId: { type: mongoose.Schema.Types.ObjectId, ref: "Admin" },
|
|
5
|
+
clientKey: { type: String, unique: true },
|
|
6
|
+
permissions: {
|
|
7
|
+
type: Object,
|
|
8
|
+
of: [{ type: mongoose.Schema.Types.ObjectId }],
|
|
9
|
+
default: new Map(),
|
|
10
|
+
},
|
|
11
|
+
accessToken: String,
|
|
12
|
+
refreshToken: String,
|
|
13
|
+
lastUsedAt: Date,
|
|
14
|
+
isActive: Boolean,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
timestamps: true,
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const ApiKey = mongoose.model("ApiKey", apiKeySchema);
|
|
22
|
+
|
|
23
|
+
export { apiKeySchema, ApiKey };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import mongoose, { Schema } from "mongoose";
|
|
2
|
+
|
|
3
|
+
const requestSchema = new Schema(
|
|
4
|
+
{
|
|
5
|
+
endpoint: String,
|
|
6
|
+
count: Number,
|
|
7
|
+
},
|
|
8
|
+
{ timestamps: true }
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
const usageMetricsSchema = mongoose.Schema(
|
|
12
|
+
{
|
|
13
|
+
apiKeyId: { type: mongoose.Schema.Types.ObjectId, ref: "ApiKey" },
|
|
14
|
+
endpoint: String,
|
|
15
|
+
response: {
|
|
16
|
+
sizeInMB: Number,
|
|
17
|
+
sizeInKB: Number,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
},
|
|
21
|
+
{ timestamps: true }
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const UsageMetrics = mongoose.model("UsageMetrics", usageMetricsSchema);
|
|
25
|
+
|
|
26
|
+
export { usageMetricsSchema, UsageMetrics };
|
|
27
|
+
|
|
28
|
+
|
package/dist/config/db.d.ts
DELETED
package/dist/config/db.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/config/db.js"],"names":[],"mappings":";AAEA;IACI;;;OAIC;IAHG,oBAAoC;IACpC,cAAwB;IAI5B,iBASC;CACJ"}
|
package/dist/config/logger.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
}
|
|
13
|
-
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/config/logger.js"],"names":[],"mappings":";AAGA;IACI;;;OAIC;IAHG,qBAAsC;IACtC,sBAAwC;IACxC,iCAAkC;IAGtC,0CA2BC;IAED,sCAEC;CACJ"}
|
package/dist/index.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export function createDatabaseInstance({ CONNECTION_URL, database }: {
|
|
2
|
-
CONNECTION_URL: any;
|
|
3
|
-
database: any;
|
|
4
|
-
}): dbConfig;
|
|
5
|
-
export function createLoggerInstance({ DATADOG_API_KEY, APPLICATION_NAME }: {
|
|
6
|
-
DATADOG_API_KEY: any;
|
|
7
|
-
APPLICATION_NAME: any;
|
|
8
|
-
}): CustomLogger;
|
|
9
|
-
import dbConfig from "./config/db.js";
|
|
10
|
-
import CustomLogger from "./config/logger.js";
|
|
11
|
-
import { adminSchema } from "./models/admin.js";
|
|
12
|
-
import { Admin } from "./models/admin.js";
|
|
13
|
-
import { configurationsSchema } from "./models/configurations.js";
|
|
14
|
-
import { Configurations } from "./models/configurations.js";
|
|
15
|
-
import { measurementsSchema } from "./models/measurements.js";
|
|
16
|
-
import { Measurements } from "./models/measurements.js";
|
|
17
|
-
import { monitorRequestsSchema } from "./models/monitorRequests.js";
|
|
18
|
-
import { MonitorRequests } from "./models/monitorRequests.js";
|
|
19
|
-
import { monitorsSchema } from "./models/monitors.js";
|
|
20
|
-
import { Monitors } from "./models/monitors.js";
|
|
21
|
-
import { organizationsSchema } from "./models/organizations.js";
|
|
22
|
-
import { Organizations } from "./models/organizations.js";
|
|
23
|
-
import { referenceMonitorInfoSchema } from "./models/referenceMonitorInfo.js";
|
|
24
|
-
import { ReferenceMonitorInfo } from "./models/referenceMonitorInfo.js";
|
|
25
|
-
import { usersSchema } from "./models/users.js";
|
|
26
|
-
import { Users } from "./models/users.js";
|
|
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
|
-
import { jobsSchema } from "./models/jobs.js";
|
|
42
|
-
import { Jobs } from "./models/jobs.js";
|
|
43
|
-
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, jobsSchema, Jobs };
|
|
44
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAkCA;;;aAEC;AAED;;;iBAEC;qBAToB,gBAAgB;yBACZ,oBAAoB;4BAhCV,mBAAmB;sBAAnB,mBAAmB;qCAI/C,4BAA4B;+BAA5B,4BAA4B;mCACc,0BAA0B;6BAA1B,0BAA0B;sCAIpE,6BAA6B;gCAA7B,6BAA6B;+BACK,sBAAsB;yBAAtB,sBAAsB;oCACZ,2BAA2B;8BAA3B,2BAA2B;2CAIvE,kCAAkC;qCAAlC,kCAAkC;4BAQN,mBAAmB;sBAAnB,mBAAmB;6BACjB,oBAAoB;uBAApB,oBAAoB;mCARP,2BAA2B;8BAA3B,2BAA2B;uCAItE,8BAA8B;iCAA9B,8BAA8B;+BACI,sBAAsB;yBAAtB,sBAAsB;iCAClB,wBAAwB;2BAAxB,wBAAwB;sCAM9D,6BAA6B;gCAA7B,6BAA6B;mCACc,2BAA2B;8BAA3B,2BAA2B;2BAC5C,kBAAkB;qBAAlB,kBAAkB"}
|
package/dist/models/admin.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../src/models/admin.js"],"names":[],"mappings":"AAEA,8BAaG;AAKH,wBAAmD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"announcements.d.ts","sourceRoot":"","sources":["../../src/models/announcements.js"],"names":[],"mappings":"AAcA,qCAWE;AAEF,gCAA0E"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configurations.d.ts","sourceRoot":"","sources":["../../src/models/configurations.js"],"names":[],"mappings":"AAEA,uCAQG;AAIH,iCAA8E"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contexts.d.ts","sourceRoot":"","sources":["../../src/models/contexts.js"],"names":[],"mappings":"AAEA,iCAOE;AAEF,2BAA4D"}
|
package/dist/models/events.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/models/events.js"],"names":[],"mappings":"AAEA,+BAiBE;AAKF,yBAAsD"}
|
package/dist/models/jobs.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jobs.d.ts","sourceRoot":"","sources":["../../src/models/jobs.js"],"names":[],"mappings":"AAEA,6BA4BE;AAEF,uBAAgD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lightmonitors.d.ts","sourceRoot":"","sources":["../../src/models/lightmonitors.js"],"names":[],"mappings":"AAEA,qCAmBE;AAIF,gCAAyE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"measurements.d.ts","sourceRoot":"","sources":["../../src/models/measurements.js"],"names":[],"mappings":"AAEA,qCAQG;AAKH,+BAAwE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"monitorRequests.d.ts","sourceRoot":"","sources":["../../src/models/monitorRequests.js"],"names":[],"mappings":"AAEA,wCASG;AAEH,kCAAiF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"monitorSuppliers.d.ts","sourceRoot":"","sources":["../../src/models/monitorSuppliers.js"],"names":[],"mappings":"AAEA,yCAKG;AAEH,mCAAoF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"monitors.d.ts","sourceRoot":"","sources":["../../src/models/monitors.js"],"names":[],"mappings":"AAEA,iCA0FE;AAOF,2BAA4D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"organizations.d.ts","sourceRoot":"","sources":["../../src/models/organizations.js"],"names":[],"mappings":"AAEA,sCAiBO;AAEP,gCAA2E"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parameters.d.ts","sourceRoot":"","sources":["../../src/models/parameters.js"],"names":[],"mappings":"AAEA,mCAKG;AAEH,6BAAkE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"qanotifications.d.ts","sourceRoot":"","sources":["../../src/models/qanotifications.js"],"names":[],"mappings":"AAEA,wCAmBE;AAEF,kCAGE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"referenceMonitorInfo.d.ts","sourceRoot":"","sources":["../../src/models/referenceMonitorInfo.js"],"names":[],"mappings":"AAEA,6CAYG;AAEH,uCAAgG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"admin.test.d.ts","sourceRoot":"","sources":["../../../src/models/tests/admin.test.js"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configurations.test.d.ts","sourceRoot":"","sources":["../../../src/models/tests/configurations.test.js"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"measurements.test.d.ts","sourceRoot":"","sources":["../../../src/models/tests/measurements.test.js"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"monitorRequests.test.d.ts","sourceRoot":"","sources":["../../../src/models/tests/monitorRequests.test.js"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"monitors.test.d.ts","sourceRoot":"","sources":["../../../src/models/tests/monitors.test.js"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"organizations.test.d.ts","sourceRoot":"","sources":["../../../src/models/tests/organizations.test.js"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"users.test.d.ts","sourceRoot":"","sources":["../../../src/models/tests/users.test.js"],"names":[],"mappings":""}
|
package/dist/models/users.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../src/models/users.js"],"names":[],"mappings":"AAEA,8BAsBG;AAIH,wBAAmD"}
|