@justair/justair-library 4.7.21 → 4.7.22
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 +146 -146
- package/package.json +28 -28
- package/src/config/db.js +116 -116
- package/src/config/logger.js +44 -44
- package/src/index.js +116 -116
- package/src/models/admin.js +30 -30
- package/src/models/alerts.js +221 -221
- package/src/models/announcements.js +31 -31
- package/src/models/apiKey.js +22 -22
- package/src/models/configurations.js +17 -17
- package/src/models/contexts.js +13 -13
- package/src/models/dataCompleteness.js +42 -42
- package/src/models/events.js +123 -123
- package/src/models/features.js +14 -14
- package/src/models/jobs.js +49 -49
- package/src/models/lightmonitors.js +30 -30
- package/src/models/measurements.js +269 -269
- package/src/models/monitorRequests.js +25 -25
- package/src/models/monitorSuppliers.js +21 -21
- package/src/models/monitors.js +400 -399
- package/src/models/networkMetrics.js +42 -42
- package/src/models/organizations.js +97 -97
- package/src/models/parameters.js +11 -11
- package/src/models/referenceMonitorInfo.js +18 -18
- package/src/models/tests/admin.test.js +42 -42
- package/src/models/tests/configurations.test.js +44 -44
- package/src/models/tests/measurements.test.js +46 -46
- package/src/models/tests/monitorRequests.test.js +46 -46
- package/src/models/tests/monitors.test.js +62 -62
- package/src/models/tests/organizations.test.js +51 -51
- package/src/models/tests/users.test.js +54 -54
- package/src/models/usageMetrics.js +28 -28
- package/src/models/users.js +55 -55
- package/tsconfig.json +10 -10
package/src/index.js
CHANGED
|
@@ -1,116 +1,116 @@
|
|
|
1
|
-
import { adminSchema, Admin } from "./models/admin.js";
|
|
2
|
-
import {
|
|
3
|
-
configurationsSchema,
|
|
4
|
-
Configurations,
|
|
5
|
-
} from "./models/configurations.js";
|
|
6
|
-
import {
|
|
7
|
-
measurementsSchema,
|
|
8
|
-
Measurements,
|
|
9
|
-
Audit,
|
|
10
|
-
auditSchema,
|
|
11
|
-
} from "./models/measurements.js";
|
|
12
|
-
import {
|
|
13
|
-
monitorRequestsSchema,
|
|
14
|
-
MonitorRequests,
|
|
15
|
-
} from "./models/monitorRequests.js";
|
|
16
|
-
import {
|
|
17
|
-
monitorsSchema,
|
|
18
|
-
Monitors,
|
|
19
|
-
monitorAuditSchema,
|
|
20
|
-
MonitorAudit,
|
|
21
|
-
} from "./models/monitors.js";
|
|
22
|
-
import { organizationsSchema, Organizations } from "./models/organizations.js";
|
|
23
|
-
import {
|
|
24
|
-
referenceMonitorInfoSchema,
|
|
25
|
-
ReferenceMonitorInfo,
|
|
26
|
-
} from "./models/referenceMonitorInfo.js";
|
|
27
|
-
import { lightMonitorSchema, LightMonitors } from "./models/lightmonitors.js";
|
|
28
|
-
import {
|
|
29
|
-
monitorSuppliersSchema,
|
|
30
|
-
MonitorSuppliers,
|
|
31
|
-
} from "./models/monitorSuppliers.js";
|
|
32
|
-
import { contextsSchema, Contexts } from "./models/contexts.js";
|
|
33
|
-
import { parametersSchema, Parameters } from "./models/parameters.js";
|
|
34
|
-
import { usersSchema, Users } from "./models/users.js";
|
|
35
|
-
import {
|
|
36
|
-
eventsSchema,
|
|
37
|
-
Events,
|
|
38
|
-
eventsAuditSchema,
|
|
39
|
-
EventsAudit,
|
|
40
|
-
} from "./models/events.js";
|
|
41
|
-
import { announcementSchema, Announcements } from "./models/announcements.js";
|
|
42
|
-
import { jobsSchema, Jobs } from "./models/jobs.js";
|
|
43
|
-
import { apiKeySchema, ApiKey } from "./models/apiKey.js";
|
|
44
|
-
import { UsageMetrics, usageMetricsSchema } from "./models/usageMetrics.js";
|
|
45
|
-
import {
|
|
46
|
-
AlertsAudit,
|
|
47
|
-
Alerts,
|
|
48
|
-
alertsSchema,
|
|
49
|
-
alertsAuditSchema,
|
|
50
|
-
} from "./models/alerts.js";
|
|
51
|
-
import { Features, featuresSchema } from "./models/features.js";
|
|
52
|
-
import {
|
|
53
|
-
DataCompleteness,
|
|
54
|
-
dataCompletenessSchema,
|
|
55
|
-
} from "./models/dataCompleteness.js";
|
|
56
|
-
import { NetworkMetrics, networkMetricsSchema } from "./models/networkMetrics.js";
|
|
57
|
-
import Database from "./config/db.js"; // Import the new Database class
|
|
58
|
-
import CustomLogger from "./config/logger.js";
|
|
59
|
-
|
|
60
|
-
export function createLoggerInstance({ DATADOG_API_KEY, APPLICATION_NAME }) {
|
|
61
|
-
return new CustomLogger({ DATADOG_API_KEY, APPLICATION_NAME });
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export {
|
|
65
|
-
Database, // Export the Database class
|
|
66
|
-
adminSchema,
|
|
67
|
-
Admin,
|
|
68
|
-
configurationsSchema,
|
|
69
|
-
Configurations,
|
|
70
|
-
measurementsSchema,
|
|
71
|
-
Measurements,
|
|
72
|
-
monitorRequestsSchema,
|
|
73
|
-
MonitorRequests,
|
|
74
|
-
monitorsSchema,
|
|
75
|
-
Monitors,
|
|
76
|
-
organizationsSchema,
|
|
77
|
-
Organizations,
|
|
78
|
-
referenceMonitorInfoSchema,
|
|
79
|
-
ReferenceMonitorInfo,
|
|
80
|
-
usersSchema,
|
|
81
|
-
Users,
|
|
82
|
-
eventsSchema,
|
|
83
|
-
Events,
|
|
84
|
-
lightMonitorSchema,
|
|
85
|
-
LightMonitors,
|
|
86
|
-
monitorSuppliersSchema,
|
|
87
|
-
MonitorSuppliers,
|
|
88
|
-
contextsSchema,
|
|
89
|
-
Contexts,
|
|
90
|
-
parametersSchema,
|
|
91
|
-
Parameters,
|
|
92
|
-
announcementSchema,
|
|
93
|
-
Announcements,
|
|
94
|
-
jobsSchema,
|
|
95
|
-
Jobs,
|
|
96
|
-
apiKeySchema,
|
|
97
|
-
ApiKey,
|
|
98
|
-
UsageMetrics,
|
|
99
|
-
usageMetricsSchema,
|
|
100
|
-
Audit,
|
|
101
|
-
auditSchema,
|
|
102
|
-
EventsAudit,
|
|
103
|
-
eventsAuditSchema,
|
|
104
|
-
MonitorAudit,
|
|
105
|
-
monitorAuditSchema,
|
|
106
|
-
AlertsAudit,
|
|
107
|
-
Alerts,
|
|
108
|
-
alertsSchema,
|
|
109
|
-
alertsAuditSchema,
|
|
110
|
-
Features,
|
|
111
|
-
featuresSchema,
|
|
112
|
-
dataCompletenessSchema,
|
|
113
|
-
DataCompleteness,
|
|
114
|
-
networkMetricsSchema,
|
|
115
|
-
NetworkMetrics,
|
|
116
|
-
};
|
|
1
|
+
import { adminSchema, Admin } from "./models/admin.js";
|
|
2
|
+
import {
|
|
3
|
+
configurationsSchema,
|
|
4
|
+
Configurations,
|
|
5
|
+
} from "./models/configurations.js";
|
|
6
|
+
import {
|
|
7
|
+
measurementsSchema,
|
|
8
|
+
Measurements,
|
|
9
|
+
Audit,
|
|
10
|
+
auditSchema,
|
|
11
|
+
} from "./models/measurements.js";
|
|
12
|
+
import {
|
|
13
|
+
monitorRequestsSchema,
|
|
14
|
+
MonitorRequests,
|
|
15
|
+
} from "./models/monitorRequests.js";
|
|
16
|
+
import {
|
|
17
|
+
monitorsSchema,
|
|
18
|
+
Monitors,
|
|
19
|
+
monitorAuditSchema,
|
|
20
|
+
MonitorAudit,
|
|
21
|
+
} from "./models/monitors.js";
|
|
22
|
+
import { organizationsSchema, Organizations } from "./models/organizations.js";
|
|
23
|
+
import {
|
|
24
|
+
referenceMonitorInfoSchema,
|
|
25
|
+
ReferenceMonitorInfo,
|
|
26
|
+
} from "./models/referenceMonitorInfo.js";
|
|
27
|
+
import { lightMonitorSchema, LightMonitors } from "./models/lightmonitors.js";
|
|
28
|
+
import {
|
|
29
|
+
monitorSuppliersSchema,
|
|
30
|
+
MonitorSuppliers,
|
|
31
|
+
} from "./models/monitorSuppliers.js";
|
|
32
|
+
import { contextsSchema, Contexts } from "./models/contexts.js";
|
|
33
|
+
import { parametersSchema, Parameters } from "./models/parameters.js";
|
|
34
|
+
import { usersSchema, Users } from "./models/users.js";
|
|
35
|
+
import {
|
|
36
|
+
eventsSchema,
|
|
37
|
+
Events,
|
|
38
|
+
eventsAuditSchema,
|
|
39
|
+
EventsAudit,
|
|
40
|
+
} from "./models/events.js";
|
|
41
|
+
import { announcementSchema, Announcements } from "./models/announcements.js";
|
|
42
|
+
import { jobsSchema, Jobs } from "./models/jobs.js";
|
|
43
|
+
import { apiKeySchema, ApiKey } from "./models/apiKey.js";
|
|
44
|
+
import { UsageMetrics, usageMetricsSchema } from "./models/usageMetrics.js";
|
|
45
|
+
import {
|
|
46
|
+
AlertsAudit,
|
|
47
|
+
Alerts,
|
|
48
|
+
alertsSchema,
|
|
49
|
+
alertsAuditSchema,
|
|
50
|
+
} from "./models/alerts.js";
|
|
51
|
+
import { Features, featuresSchema } from "./models/features.js";
|
|
52
|
+
import {
|
|
53
|
+
DataCompleteness,
|
|
54
|
+
dataCompletenessSchema,
|
|
55
|
+
} from "./models/dataCompleteness.js";
|
|
56
|
+
import { NetworkMetrics, networkMetricsSchema } from "./models/networkMetrics.js";
|
|
57
|
+
import Database from "./config/db.js"; // Import the new Database class
|
|
58
|
+
import CustomLogger from "./config/logger.js";
|
|
59
|
+
|
|
60
|
+
export function createLoggerInstance({ DATADOG_API_KEY, APPLICATION_NAME }) {
|
|
61
|
+
return new CustomLogger({ DATADOG_API_KEY, APPLICATION_NAME });
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export {
|
|
65
|
+
Database, // Export the Database class
|
|
66
|
+
adminSchema,
|
|
67
|
+
Admin,
|
|
68
|
+
configurationsSchema,
|
|
69
|
+
Configurations,
|
|
70
|
+
measurementsSchema,
|
|
71
|
+
Measurements,
|
|
72
|
+
monitorRequestsSchema,
|
|
73
|
+
MonitorRequests,
|
|
74
|
+
monitorsSchema,
|
|
75
|
+
Monitors,
|
|
76
|
+
organizationsSchema,
|
|
77
|
+
Organizations,
|
|
78
|
+
referenceMonitorInfoSchema,
|
|
79
|
+
ReferenceMonitorInfo,
|
|
80
|
+
usersSchema,
|
|
81
|
+
Users,
|
|
82
|
+
eventsSchema,
|
|
83
|
+
Events,
|
|
84
|
+
lightMonitorSchema,
|
|
85
|
+
LightMonitors,
|
|
86
|
+
monitorSuppliersSchema,
|
|
87
|
+
MonitorSuppliers,
|
|
88
|
+
contextsSchema,
|
|
89
|
+
Contexts,
|
|
90
|
+
parametersSchema,
|
|
91
|
+
Parameters,
|
|
92
|
+
announcementSchema,
|
|
93
|
+
Announcements,
|
|
94
|
+
jobsSchema,
|
|
95
|
+
Jobs,
|
|
96
|
+
apiKeySchema,
|
|
97
|
+
ApiKey,
|
|
98
|
+
UsageMetrics,
|
|
99
|
+
usageMetricsSchema,
|
|
100
|
+
Audit,
|
|
101
|
+
auditSchema,
|
|
102
|
+
EventsAudit,
|
|
103
|
+
eventsAuditSchema,
|
|
104
|
+
MonitorAudit,
|
|
105
|
+
monitorAuditSchema,
|
|
106
|
+
AlertsAudit,
|
|
107
|
+
Alerts,
|
|
108
|
+
alertsSchema,
|
|
109
|
+
alertsAuditSchema,
|
|
110
|
+
Features,
|
|
111
|
+
featuresSchema,
|
|
112
|
+
dataCompletenessSchema,
|
|
113
|
+
DataCompleteness,
|
|
114
|
+
networkMetricsSchema,
|
|
115
|
+
NetworkMetrics,
|
|
116
|
+
};
|
package/src/models/admin.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
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
|
-
// Organization-based admin queries
|
|
19
|
-
adminSchema.index({ orgId: 1, isActive: 1 });
|
|
20
|
-
// Email-based login with active status (case-insensitive handled in app)
|
|
21
|
-
adminSchema.index({ email: 1, isActive: 1 });
|
|
22
|
-
// Permission-based queries
|
|
23
|
-
adminSchema.index({ orgId: 1, permissionName: 1 });
|
|
24
|
-
|
|
25
|
-
// Keep individual email index for backward compatibility
|
|
26
|
-
adminSchema.index({ email: 1 });
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const Admin = mongoose.model('Admin', adminSchema);
|
|
30
|
-
|
|
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
|
+
// Organization-based admin queries
|
|
19
|
+
adminSchema.index({ orgId: 1, isActive: 1 });
|
|
20
|
+
// Email-based login with active status (case-insensitive handled in app)
|
|
21
|
+
adminSchema.index({ email: 1, isActive: 1 });
|
|
22
|
+
// Permission-based queries
|
|
23
|
+
adminSchema.index({ orgId: 1, permissionName: 1 });
|
|
24
|
+
|
|
25
|
+
// Keep individual email index for backward compatibility
|
|
26
|
+
adminSchema.index({ email: 1 });
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
const Admin = mongoose.model('Admin', adminSchema);
|
|
30
|
+
|
|
31
31
|
export {adminSchema, Admin};
|