@oneuptime/common 8.0.5440 → 8.0.5466
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/Models/DatabaseModels/StatusPage.ts +80 -0
- package/Models/DatabaseModels/TelemetryUsageBilling.ts +1 -1
- package/Server/API/StatusPageAPI.ts +138 -52
- package/Server/EnvironmentConfig.ts +37 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1761232578396-MigrationName.ts +29 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +2 -0
- package/Server/Services/AnalyticsDatabaseService.ts +71 -11
- package/Server/Services/OpenTelemetryIngestService.ts +1 -39
- package/Server/Services/StatusPageService.ts +117 -0
- package/Server/Services/TelemetryUsageBillingService.ts +268 -15
- package/Server/Types/Billing/MeteredPlan/TelemetryMeteredPlan.ts +5 -0
- package/Server/Utils/Telemetry/Telemetry.ts +135 -81
- package/Server/Utils/VM/VMRunner.ts +3 -4
- package/Types/Date.ts +5 -0
- package/UI/Components/LogsViewer/LogItem.tsx +12 -4
- package/UI/Components/LogsViewer/LogsViewer.tsx +131 -29
- package/UI/Components/Markdown.tsx/MarkdownViewer.tsx +2 -2
- package/UI/Components/Table/TableRow.tsx +89 -77
- package/UI/esbuild-config.js +32 -1
- package/build/dist/Models/DatabaseModels/StatusPage.js +82 -0
- package/build/dist/Models/DatabaseModels/StatusPage.js.map +1 -1
- package/build/dist/Models/DatabaseModels/TelemetryUsageBilling.js +1 -1
- package/build/dist/Models/DatabaseModels/TelemetryUsageBilling.js.map +1 -1
- package/build/dist/Server/API/StatusPageAPI.js +157 -74
- package/build/dist/Server/API/StatusPageAPI.js.map +1 -1
- package/build/dist/Server/EnvironmentConfig.js +15 -0
- package/build/dist/Server/EnvironmentConfig.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1761232578396-MigrationName.js +16 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1761232578396-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +2 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Services/AnalyticsDatabaseService.js +55 -8
- package/build/dist/Server/Services/AnalyticsDatabaseService.js.map +1 -1
- package/build/dist/Server/Services/OpenTelemetryIngestService.js +0 -30
- package/build/dist/Server/Services/OpenTelemetryIngestService.js.map +1 -1
- package/build/dist/Server/Services/StatusPageService.js +95 -0
- package/build/dist/Server/Services/StatusPageService.js.map +1 -1
- package/build/dist/Server/Services/TelemetryUsageBillingService.js +211 -8
- package/build/dist/Server/Services/TelemetryUsageBillingService.js.map +1 -1
- package/build/dist/Server/Types/Billing/MeteredPlan/TelemetryMeteredPlan.js +4 -0
- package/build/dist/Server/Types/Billing/MeteredPlan/TelemetryMeteredPlan.js.map +1 -1
- package/build/dist/Server/Utils/Telemetry/Telemetry.js +84 -60
- package/build/dist/Server/Utils/Telemetry/Telemetry.js.map +1 -1
- package/build/dist/Server/Utils/VM/VMRunner.js +2 -2
- package/build/dist/Server/Utils/VM/VMRunner.js.map +1 -1
- package/build/dist/Types/Date.js +4 -0
- package/build/dist/Types/Date.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/LogItem.js +5 -3
- package/build/dist/UI/Components/LogsViewer/LogItem.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/LogsViewer.js +73 -22
- package/build/dist/UI/Components/LogsViewer/LogsViewer.js.map +1 -1
- package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js +2 -2
- package/build/dist/UI/Components/Table/TableRow.js +18 -6
- package/build/dist/UI/Components/Table/TableRow.js.map +1 -1
- package/package.json +4 -4
|
@@ -82,7 +82,7 @@ import ProjectSmtpConfigService from "../Services/ProjectSmtpConfigService";
|
|
|
82
82
|
import SlackUtil from "../Utils/Workspace/Slack/Slack";
|
|
83
83
|
export default class StatusPageAPI extends BaseAPI {
|
|
84
84
|
constructor() {
|
|
85
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
85
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
86
86
|
super(StatusPage, StatusPageService);
|
|
87
87
|
// get title, description of the page. This is used for SEO.
|
|
88
88
|
this.router.get(`${(_a = new this.entityType().getCrudApiPath()) === null || _a === void 0 ? void 0 : _a.toString()}/seo/:statusPageIdOrDomain`, UserMiddleware.getUserMiddleware, async (req, res) => {
|
|
@@ -202,9 +202,123 @@ export default class StatusPageAPI extends BaseAPI {
|
|
|
202
202
|
logger.debug(`Favicon file found. Sending file: ${statusPage.faviconFile.name}`);
|
|
203
203
|
return Response.sendFileResponse(req, res, statusPage.faviconFile);
|
|
204
204
|
});
|
|
205
|
-
//
|
|
205
|
+
// embedded overall status badge api
|
|
206
206
|
this.router.get(`${(_c = new this.entityType()
|
|
207
|
-
.getCrudApiPath()) === null || _c === void 0 ? void 0 : _c.toString()}/
|
|
207
|
+
.getCrudApiPath()) === null || _c === void 0 ? void 0 : _c.toString()}/badge/:statusPageId`, async (req, res) => {
|
|
208
|
+
var _a;
|
|
209
|
+
try {
|
|
210
|
+
const statusPageId = new ObjectID(req.params["statusPageId"]);
|
|
211
|
+
const token = req.query["token"];
|
|
212
|
+
if (!token) {
|
|
213
|
+
return res.status(400).send("Token is required");
|
|
214
|
+
}
|
|
215
|
+
// Fetch status page with security token
|
|
216
|
+
const statusPage = await StatusPageService.findOneBy({
|
|
217
|
+
query: {
|
|
218
|
+
_id: statusPageId,
|
|
219
|
+
enableEmbeddedOverallStatus: true,
|
|
220
|
+
embeddedOverallStatusToken: token,
|
|
221
|
+
},
|
|
222
|
+
select: {
|
|
223
|
+
_id: true,
|
|
224
|
+
projectId: true,
|
|
225
|
+
downtimeMonitorStatuses: {
|
|
226
|
+
_id: true,
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
props: {
|
|
230
|
+
isRoot: true,
|
|
231
|
+
},
|
|
232
|
+
});
|
|
233
|
+
if (!statusPage) {
|
|
234
|
+
return res.status(404).send("Status badge not found or disabled");
|
|
235
|
+
}
|
|
236
|
+
// Get status page resources and current statuses
|
|
237
|
+
const statusPageResources = await StatusPageResourceService.findBy({
|
|
238
|
+
query: {
|
|
239
|
+
statusPageId: statusPageId,
|
|
240
|
+
},
|
|
241
|
+
select: {
|
|
242
|
+
_id: true,
|
|
243
|
+
monitor: {
|
|
244
|
+
_id: true,
|
|
245
|
+
currentMonitorStatusId: true,
|
|
246
|
+
},
|
|
247
|
+
monitorGroupId: true,
|
|
248
|
+
},
|
|
249
|
+
limit: LIMIT_PER_PROJECT,
|
|
250
|
+
skip: 0,
|
|
251
|
+
props: {
|
|
252
|
+
isRoot: true,
|
|
253
|
+
},
|
|
254
|
+
});
|
|
255
|
+
// Get monitor statuses
|
|
256
|
+
const monitorStatuses = await MonitorStatusService.findBy({
|
|
257
|
+
query: {
|
|
258
|
+
projectId: statusPage.projectId,
|
|
259
|
+
},
|
|
260
|
+
select: {
|
|
261
|
+
_id: true,
|
|
262
|
+
name: true,
|
|
263
|
+
color: true,
|
|
264
|
+
priority: true,
|
|
265
|
+
isOperationalState: true,
|
|
266
|
+
},
|
|
267
|
+
sort: {
|
|
268
|
+
priority: SortOrder.Ascending,
|
|
269
|
+
},
|
|
270
|
+
skip: 0,
|
|
271
|
+
limit: LIMIT_PER_PROJECT,
|
|
272
|
+
props: {
|
|
273
|
+
isRoot: true,
|
|
274
|
+
},
|
|
275
|
+
});
|
|
276
|
+
// Get monitor group current statuses
|
|
277
|
+
const monitorGroupCurrentStatuses = await StatusPageService.getMonitorGroupCurrentStatuses({
|
|
278
|
+
statusPageResources,
|
|
279
|
+
monitorStatuses,
|
|
280
|
+
});
|
|
281
|
+
// Calculate overall status
|
|
282
|
+
const overallStatus = StatusPageService.getOverallMonitorStatus({
|
|
283
|
+
statusPageResources,
|
|
284
|
+
monitorStatuses,
|
|
285
|
+
monitorGroupCurrentStatuses,
|
|
286
|
+
});
|
|
287
|
+
// Generate SVG badge
|
|
288
|
+
const statusName = (overallStatus === null || overallStatus === void 0 ? void 0 : overallStatus.name) || "Unknown";
|
|
289
|
+
const statusColor = ((_a = overallStatus === null || overallStatus === void 0 ? void 0 : overallStatus.color) === null || _a === void 0 ? void 0 : _a.toString()) || "#808080";
|
|
290
|
+
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="150" height="20">
|
|
291
|
+
<linearGradient id="b" x2="0" y2="100%">
|
|
292
|
+
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
|
293
|
+
<stop offset="1" stop-opacity=".1"/>
|
|
294
|
+
</linearGradient>
|
|
295
|
+
<mask id="a">
|
|
296
|
+
<rect width="150" height="20" rx="3" fill="#fff"/>
|
|
297
|
+
</mask>
|
|
298
|
+
<g mask="url(#a)">
|
|
299
|
+
<path fill="#555" d="M0 0h50v20H0z"/>
|
|
300
|
+
<path fill="${statusColor}" d="M50 0h100v20H50z"/>
|
|
301
|
+
<path fill="url(#b)" d="M0 0h150v20H0z"/>
|
|
302
|
+
</g>
|
|
303
|
+
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
|
|
304
|
+
<text x="25" y="15" fill="#010101" fill-opacity=".3">status</text>
|
|
305
|
+
<text x="25" y="14">status</text>
|
|
306
|
+
<text x="100" y="15" fill="#010101" fill-opacity=".3">${statusName}</text>
|
|
307
|
+
<text x="100" y="14">${statusName}</text>
|
|
308
|
+
</g>
|
|
309
|
+
</svg>`;
|
|
310
|
+
res.setHeader("Content-Type", "image/svg+xml");
|
|
311
|
+
res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
|
|
312
|
+
return res.send(svg);
|
|
313
|
+
}
|
|
314
|
+
catch (err) {
|
|
315
|
+
logger.error(err);
|
|
316
|
+
return res.status(500).send("Internal Server Error");
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
// confirm subscription api
|
|
320
|
+
this.router.get(`${(_d = new this.entityType()
|
|
321
|
+
.getCrudApiPath()) === null || _d === void 0 ? void 0 : _d.toString()}/confirm-subscription/:statusPageSubscriberId`, async (req, res) => {
|
|
208
322
|
const token = req.query["verification-token"];
|
|
209
323
|
const statusPageSubscriberId = new ObjectID(req.params["statusPageSubscriberId"]);
|
|
210
324
|
const subscriber = await StatusPageSubscriberService.findOneBy({
|
|
@@ -241,8 +355,8 @@ export default class StatusPageAPI extends BaseAPI {
|
|
|
241
355
|
return Response.sendEmptySuccessResponse(req, res);
|
|
242
356
|
});
|
|
243
357
|
// CNAME verification api
|
|
244
|
-
this.router.get(`${(
|
|
245
|
-
.getCrudApiPath()) === null ||
|
|
358
|
+
this.router.get(`${(_e = new this.entityType()
|
|
359
|
+
.getCrudApiPath()) === null || _e === void 0 ? void 0 : _e.toString()}/cname-verification/:token`, async (req, res) => {
|
|
246
360
|
const host = req.get("host");
|
|
247
361
|
if (!host) {
|
|
248
362
|
throw new BadDataException("Host not found");
|
|
@@ -267,8 +381,8 @@ export default class StatusPageAPI extends BaseAPI {
|
|
|
267
381
|
return Response.sendEmptySuccessResponse(req, res);
|
|
268
382
|
});
|
|
269
383
|
// ACME Challenge Validation.
|
|
270
|
-
this.router.get(`${(
|
|
271
|
-
.getCrudApiPath()) === null ||
|
|
384
|
+
this.router.get(`${(_f = new this.entityType()
|
|
385
|
+
.getCrudApiPath()) === null || _f === void 0 ? void 0 : _f.toString()}/.well-known/acme-challenge/:token`, async (req, res) => {
|
|
272
386
|
const challenge = await AcmeChallengeService.findOneBy({
|
|
273
387
|
query: {
|
|
274
388
|
token: req.params["token"],
|
|
@@ -285,7 +399,7 @@ export default class StatusPageAPI extends BaseAPI {
|
|
|
285
399
|
}
|
|
286
400
|
return Response.sendTextResponse(req, res, challenge.challenge);
|
|
287
401
|
});
|
|
288
|
-
this.router.post(`${(
|
|
402
|
+
this.router.post(`${(_g = new this.entityType().getCrudApiPath()) === null || _g === void 0 ? void 0 : _g.toString()}/test-email-report`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
|
|
289
403
|
try {
|
|
290
404
|
const email = new Email(req.body["email"]);
|
|
291
405
|
const statusPageId = new ObjectID(req.body["statusPageId"].toString());
|
|
@@ -299,7 +413,7 @@ export default class StatusPageAPI extends BaseAPI {
|
|
|
299
413
|
next(err);
|
|
300
414
|
}
|
|
301
415
|
});
|
|
302
|
-
this.router.post(`${(
|
|
416
|
+
this.router.post(`${(_h = new this.entityType().getCrudApiPath()) === null || _h === void 0 ? void 0 : _h.toString()}/domain`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
|
|
303
417
|
try {
|
|
304
418
|
if (!req.body["domain"]) {
|
|
305
419
|
throw new BadDataException("domain is required in request body");
|
|
@@ -331,8 +445,8 @@ export default class StatusPageAPI extends BaseAPI {
|
|
|
331
445
|
next(err);
|
|
332
446
|
}
|
|
333
447
|
});
|
|
334
|
-
this.router.post(`${(
|
|
335
|
-
.getCrudApiPath()) === null ||
|
|
448
|
+
this.router.post(`${(_j = new this.entityType()
|
|
449
|
+
.getCrudApiPath()) === null || _j === void 0 ? void 0 : _j.toString()}/master-page/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
|
|
336
450
|
try {
|
|
337
451
|
const objectId = new ObjectID(req.params["statusPageId"]);
|
|
338
452
|
const select = {
|
|
@@ -448,7 +562,7 @@ export default class StatusPageAPI extends BaseAPI {
|
|
|
448
562
|
next(err);
|
|
449
563
|
}
|
|
450
564
|
});
|
|
451
|
-
this.router.post(`${(
|
|
565
|
+
this.router.post(`${(_k = new this.entityType().getCrudApiPath()) === null || _k === void 0 ? void 0 : _k.toString()}/sso/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
|
|
452
566
|
try {
|
|
453
567
|
const objectId = new ObjectID(req.params["statusPageId"]);
|
|
454
568
|
const sso = await StatusPageSsoService.findBy({
|
|
@@ -475,8 +589,8 @@ export default class StatusPageAPI extends BaseAPI {
|
|
|
475
589
|
}
|
|
476
590
|
});
|
|
477
591
|
// Get all status page resources for subscriber to subscribe to.
|
|
478
|
-
this.router.post(`${(
|
|
479
|
-
.getCrudApiPath()) === null ||
|
|
592
|
+
this.router.post(`${(_l = new this.entityType()
|
|
593
|
+
.getCrudApiPath()) === null || _l === void 0 ? void 0 : _l.toString()}/resources/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
|
|
480
594
|
try {
|
|
481
595
|
const statusPageId = new ObjectID(req.params["statusPageId"]);
|
|
482
596
|
await this.checkHasReadAccess({
|
|
@@ -509,8 +623,8 @@ export default class StatusPageAPI extends BaseAPI {
|
|
|
509
623
|
next(err);
|
|
510
624
|
}
|
|
511
625
|
});
|
|
512
|
-
this.router.post(`${(
|
|
513
|
-
.getCrudApiPath()) === null ||
|
|
626
|
+
this.router.post(`${(_m = new this.entityType()
|
|
627
|
+
.getCrudApiPath()) === null || _m === void 0 ? void 0 : _m.toString()}/uptime/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
|
|
514
628
|
try {
|
|
515
629
|
// This reosurce ID can be of a status page resource OR a status page group.
|
|
516
630
|
const statusPageResourceId = new ObjectID(req.params["statusPageResourceId"]);
|
|
@@ -690,8 +804,8 @@ export default class StatusPageAPI extends BaseAPI {
|
|
|
690
804
|
next(err);
|
|
691
805
|
}
|
|
692
806
|
});
|
|
693
|
-
this.router.post(`${(
|
|
694
|
-
.getCrudApiPath()) === null ||
|
|
807
|
+
this.router.post(`${(_o = new this.entityType()
|
|
808
|
+
.getCrudApiPath()) === null || _o === void 0 ? void 0 : _o.toString()}/overview/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
|
|
695
809
|
try {
|
|
696
810
|
const statusPageId = new ObjectID(req.params["statusPageId"]);
|
|
697
811
|
await this.checkHasReadAccess({
|
|
@@ -994,7 +1108,11 @@ export default class StatusPageAPI extends BaseAPI {
|
|
|
994
1108
|
isRoot: true,
|
|
995
1109
|
},
|
|
996
1110
|
});
|
|
997
|
-
const overallStatus =
|
|
1111
|
+
const overallStatus = StatusPageService.getOverallMonitorStatus({
|
|
1112
|
+
statusPageResources,
|
|
1113
|
+
monitorStatuses,
|
|
1114
|
+
monitorGroupCurrentStatuses,
|
|
1115
|
+
});
|
|
998
1116
|
const response = {
|
|
999
1117
|
overallStatus: overallStatus
|
|
1000
1118
|
? BaseModel.toJSON(overallStatus, MonitorStatus)
|
|
@@ -1021,8 +1139,8 @@ export default class StatusPageAPI extends BaseAPI {
|
|
|
1021
1139
|
next(err);
|
|
1022
1140
|
}
|
|
1023
1141
|
});
|
|
1024
|
-
this.router.put(`${(
|
|
1025
|
-
.getCrudApiPath()) === null ||
|
|
1142
|
+
this.router.put(`${(_p = new this.entityType()
|
|
1143
|
+
.getCrudApiPath()) === null || _p === void 0 ? void 0 : _p.toString()}/update-subscription/:statusPageId/:subscriberId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
|
|
1026
1144
|
try {
|
|
1027
1145
|
await this.subscribeToStatusPage(req);
|
|
1028
1146
|
return Response.sendEmptySuccessResponse(req, res);
|
|
@@ -1031,8 +1149,8 @@ export default class StatusPageAPI extends BaseAPI {
|
|
|
1031
1149
|
next(err);
|
|
1032
1150
|
}
|
|
1033
1151
|
});
|
|
1034
|
-
this.router.post(`${(
|
|
1035
|
-
.getCrudApiPath()) === null ||
|
|
1152
|
+
this.router.post(`${(_q = new this.entityType()
|
|
1153
|
+
.getCrudApiPath()) === null || _q === void 0 ? void 0 : _q.toString()}/get-subscription/:statusPageId/:subscriberId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
|
|
1036
1154
|
try {
|
|
1037
1155
|
const subscriber = await this.getSubscriber(req);
|
|
1038
1156
|
return Response.sendEntityResponse(req, res, subscriber, StatusPageSubscriber);
|
|
@@ -1041,8 +1159,8 @@ export default class StatusPageAPI extends BaseAPI {
|
|
|
1041
1159
|
next(err);
|
|
1042
1160
|
}
|
|
1043
1161
|
});
|
|
1044
|
-
this.router.post(`${(
|
|
1045
|
-
.getCrudApiPath()) === null ||
|
|
1162
|
+
this.router.post(`${(_r = new this.entityType()
|
|
1163
|
+
.getCrudApiPath()) === null || _r === void 0 ? void 0 : _r.toString()}/subscribe/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
|
|
1046
1164
|
try {
|
|
1047
1165
|
await this.subscribeToStatusPage(req);
|
|
1048
1166
|
return Response.sendEmptySuccessResponse(req, res);
|
|
@@ -1051,8 +1169,8 @@ export default class StatusPageAPI extends BaseAPI {
|
|
|
1051
1169
|
next(err);
|
|
1052
1170
|
}
|
|
1053
1171
|
});
|
|
1054
|
-
this.router.post(`${(
|
|
1055
|
-
.getCrudApiPath()) === null ||
|
|
1172
|
+
this.router.post(`${(_s = new this.entityType()
|
|
1173
|
+
.getCrudApiPath()) === null || _s === void 0 ? void 0 : _s.toString()}/manage-subscription/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
|
|
1056
1174
|
try {
|
|
1057
1175
|
await this.manageExistingSubscription(req);
|
|
1058
1176
|
return Response.sendEmptySuccessResponse(req, res);
|
|
@@ -1061,8 +1179,8 @@ export default class StatusPageAPI extends BaseAPI {
|
|
|
1061
1179
|
next(err);
|
|
1062
1180
|
}
|
|
1063
1181
|
});
|
|
1064
|
-
this.router.post(`${(
|
|
1065
|
-
.getCrudApiPath()) === null ||
|
|
1182
|
+
this.router.post(`${(_t = new this.entityType()
|
|
1183
|
+
.getCrudApiPath()) === null || _t === void 0 ? void 0 : _t.toString()}/incidents/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
|
|
1066
1184
|
try {
|
|
1067
1185
|
const objectId = new ObjectID(req.params["statusPageId"]);
|
|
1068
1186
|
const response = await this.getIncidents(objectId, null, req);
|
|
@@ -1072,8 +1190,8 @@ export default class StatusPageAPI extends BaseAPI {
|
|
|
1072
1190
|
next(err);
|
|
1073
1191
|
}
|
|
1074
1192
|
});
|
|
1075
|
-
this.router.post(`${(
|
|
1076
|
-
.getCrudApiPath()) === null ||
|
|
1193
|
+
this.router.post(`${(_u = new this.entityType()
|
|
1194
|
+
.getCrudApiPath()) === null || _u === void 0 ? void 0 : _u.toString()}/scheduled-maintenance-events/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
|
|
1077
1195
|
try {
|
|
1078
1196
|
const objectId = new ObjectID(req.params["statusPageId"]);
|
|
1079
1197
|
const response = await this.getScheduledMaintenanceEvents(objectId, null, req);
|
|
@@ -1083,8 +1201,8 @@ export default class StatusPageAPI extends BaseAPI {
|
|
|
1083
1201
|
next(err);
|
|
1084
1202
|
}
|
|
1085
1203
|
});
|
|
1086
|
-
this.router.post(`${(
|
|
1087
|
-
.getCrudApiPath()) === null ||
|
|
1204
|
+
this.router.post(`${(_v = new this.entityType()
|
|
1205
|
+
.getCrudApiPath()) === null || _v === void 0 ? void 0 : _v.toString()}/announcements/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
|
|
1088
1206
|
try {
|
|
1089
1207
|
const objectId = new ObjectID(req.params["statusPageId"]);
|
|
1090
1208
|
const response = await this.getAnnouncements(objectId, null, req);
|
|
@@ -1094,8 +1212,8 @@ export default class StatusPageAPI extends BaseAPI {
|
|
|
1094
1212
|
next(err);
|
|
1095
1213
|
}
|
|
1096
1214
|
});
|
|
1097
|
-
this.router.post(`${(
|
|
1098
|
-
.getCrudApiPath()) === null ||
|
|
1215
|
+
this.router.post(`${(_w = new this.entityType()
|
|
1216
|
+
.getCrudApiPath()) === null || _w === void 0 ? void 0 : _w.toString()}/incidents/:statusPageId/:incidentId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
|
|
1099
1217
|
try {
|
|
1100
1218
|
const objectId = new ObjectID(req.params["statusPageId"]);
|
|
1101
1219
|
const incidentId = new ObjectID(req.params["incidentId"]);
|
|
@@ -1106,8 +1224,8 @@ export default class StatusPageAPI extends BaseAPI {
|
|
|
1106
1224
|
next(err);
|
|
1107
1225
|
}
|
|
1108
1226
|
});
|
|
1109
|
-
this.router.post(`${(
|
|
1110
|
-
.getCrudApiPath()) === null ||
|
|
1227
|
+
this.router.post(`${(_x = new this.entityType()
|
|
1228
|
+
.getCrudApiPath()) === null || _x === void 0 ? void 0 : _x.toString()}/scheduled-maintenance-events/:statusPageId/:scheduledMaintenanceId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
|
|
1111
1229
|
try {
|
|
1112
1230
|
const objectId = new ObjectID(req.params["statusPageId"]);
|
|
1113
1231
|
const scheduledMaintenanceId = new ObjectID(req.params["scheduledMaintenanceId"]);
|
|
@@ -1118,8 +1236,8 @@ export default class StatusPageAPI extends BaseAPI {
|
|
|
1118
1236
|
next(err);
|
|
1119
1237
|
}
|
|
1120
1238
|
});
|
|
1121
|
-
this.router.post(`${(
|
|
1122
|
-
.getCrudApiPath()) === null ||
|
|
1239
|
+
this.router.post(`${(_y = new this.entityType()
|
|
1240
|
+
.getCrudApiPath()) === null || _y === void 0 ? void 0 : _y.toString()}/announcements/:statusPageId/:announcementId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
|
|
1123
1241
|
try {
|
|
1124
1242
|
const objectId = new ObjectID(req.params["statusPageId"]);
|
|
1125
1243
|
const announcementId = new ObjectID(req.params["announcementId"]);
|
|
@@ -2122,41 +2240,6 @@ export default class StatusPageAPI extends BaseAPI {
|
|
|
2122
2240
|
};
|
|
2123
2241
|
return response;
|
|
2124
2242
|
}
|
|
2125
|
-
getOverallMonitorStatus(statusPageResources, monitorStatuses, monitorGroupCurrentStatuses) {
|
|
2126
|
-
var _a, _b, _c, _d;
|
|
2127
|
-
let currentStatus = monitorStatuses.length > 0 && monitorStatuses[0]
|
|
2128
|
-
? monitorStatuses[0]
|
|
2129
|
-
: null;
|
|
2130
|
-
const dict = {};
|
|
2131
|
-
for (const resource of statusPageResources) {
|
|
2132
|
-
if ((_a = resource.monitor) === null || _a === void 0 ? void 0 : _a.currentMonitorStatusId) {
|
|
2133
|
-
if (!Object.keys(dict).includes(((_b = resource.monitor) === null || _b === void 0 ? void 0 : _b.currentMonitorStatusId.toString()) || "")) {
|
|
2134
|
-
dict[(_d = (_c = resource.monitor) === null || _c === void 0 ? void 0 : _c.currentMonitorStatusId) === null || _d === void 0 ? void 0 : _d.toString()] = 1;
|
|
2135
|
-
}
|
|
2136
|
-
else {
|
|
2137
|
-
dict[resource.monitor.currentMonitorStatusId.toString()]++;
|
|
2138
|
-
}
|
|
2139
|
-
}
|
|
2140
|
-
}
|
|
2141
|
-
// check status of monitor groups.
|
|
2142
|
-
for (const groupId in monitorGroupCurrentStatuses) {
|
|
2143
|
-
const statusId = monitorGroupCurrentStatuses[groupId];
|
|
2144
|
-
if (statusId) {
|
|
2145
|
-
if (!Object.keys(dict).includes(statusId.toString() || "")) {
|
|
2146
|
-
dict[statusId.toString()] = 1;
|
|
2147
|
-
}
|
|
2148
|
-
else {
|
|
2149
|
-
dict[statusId.toString()]++;
|
|
2150
|
-
}
|
|
2151
|
-
}
|
|
2152
|
-
}
|
|
2153
|
-
for (const monitorStatus of monitorStatuses) {
|
|
2154
|
-
if (monitorStatus._id && dict[monitorStatus._id]) {
|
|
2155
|
-
currentStatus = monitorStatus;
|
|
2156
|
-
}
|
|
2157
|
-
}
|
|
2158
|
-
return currentStatus;
|
|
2159
|
-
}
|
|
2160
2243
|
async getStatusPageResourcesAndTimelines(data) {
|
|
2161
2244
|
const objectId = data.statusPageId;
|
|
2162
2245
|
const statusPage = await StatusPageService.findOneBy({
|