@oneuptime/common 9.1.3 → 9.2.1

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.
Files changed (28) hide show
  1. package/Models/DatabaseModels/Incident.ts +112 -0
  2. package/Server/API/IncidentAPI.ts +106 -0
  3. package/Server/API/StatusPageAPI.ts +134 -0
  4. package/Server/Infrastructure/Postgres/SchemaMigrations/1764762146063-MigrationName.ts +45 -0
  5. package/Server/Infrastructure/Postgres/SchemaMigrations/1764767371788-MigrationName.ts +23 -0
  6. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +4 -0
  7. package/Types/Icon/IconProp.ts +1 -0
  8. package/UI/Components/EventItem/EventItem.tsx +32 -14
  9. package/UI/Components/Icon/Icon.tsx +8 -0
  10. package/build/dist/Models/DatabaseModels/Incident.js +115 -0
  11. package/build/dist/Models/DatabaseModels/Incident.js.map +1 -1
  12. package/build/dist/Server/API/IncidentAPI.js +76 -0
  13. package/build/dist/Server/API/IncidentAPI.js.map +1 -0
  14. package/build/dist/Server/API/StatusPageAPI.js +154 -45
  15. package/build/dist/Server/API/StatusPageAPI.js.map +1 -1
  16. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1764762146063-MigrationName.js +22 -0
  17. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1764762146063-MigrationName.js.map +1 -0
  18. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1764767371788-MigrationName.js +14 -0
  19. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1764767371788-MigrationName.js.map +1 -0
  20. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +4 -0
  21. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  22. package/build/dist/Types/Icon/IconProp.js +1 -0
  23. package/build/dist/Types/Icon/IconProp.js.map +1 -1
  24. package/build/dist/UI/Components/EventItem/EventItem.js +10 -6
  25. package/build/dist/UI/Components/EventItem/EventItem.js.map +1 -1
  26. package/build/dist/UI/Components/Icon/Icon.js +3 -0
  27. package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
  28. package/package.json +1 -1
@@ -119,7 +119,7 @@ const resolveStatusPageIdOrThrow = async (statusPageIdOrDomain) => {
119
119
  };
120
120
  export default class StatusPageAPI extends BaseAPI {
121
121
  constructor() {
122
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
122
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5;
123
123
  super(StatusPage, StatusPageService);
124
124
  // get title, description of the page. This is used for SEO.
125
125
  this.router.get(`${(_a = new this.entityType().getCrudApiPath()) === null || _a === void 0 ? void 0 : _a.toString()}/seo/:statusPageIdOrDomain`, UserMiddleware.getUserMiddleware, async (req, res) => {
@@ -289,16 +289,25 @@ export default class StatusPageAPI extends BaseAPI {
289
289
  }
290
290
  });
291
291
  this.router.get(`${(_f = new this.entityType()
292
- .getCrudApiPath()) === null || _f === void 0 ? void 0 : _f.toString()}/scheduled-maintenance-public-note/attachment/:statusPageId/:scheduledMaintenanceId/:noteId/:fileId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
292
+ .getCrudApiPath()) === null || _f === void 0 ? void 0 : _f.toString()}/incident/postmortem/attachment/:statusPageId/:incidentId/:fileId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
293
293
  try {
294
- await this.getScheduledMaintenancePublicNoteAttachment(req, res);
294
+ await this.getIncidentPostmortemAttachment(req, res);
295
295
  }
296
296
  catch (err) {
297
297
  next(err);
298
298
  }
299
299
  });
300
300
  this.router.get(`${(_g = new this.entityType()
301
- .getCrudApiPath()) === null || _g === void 0 ? void 0 : _g.toString()}/status-page-announcement/attachment/:statusPageId/:announcementId/:fileId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
301
+ .getCrudApiPath()) === null || _g === void 0 ? void 0 : _g.toString()}/scheduled-maintenance-public-note/attachment/:statusPageId/:scheduledMaintenanceId/:noteId/:fileId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
302
+ try {
303
+ await this.getScheduledMaintenancePublicNoteAttachment(req, res);
304
+ }
305
+ catch (err) {
306
+ next(err);
307
+ }
308
+ });
309
+ this.router.get(`${(_h = new this.entityType()
310
+ .getCrudApiPath()) === null || _h === void 0 ? void 0 : _h.toString()}/status-page-announcement/attachment/:statusPageId/:announcementId/:fileId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
302
311
  try {
303
312
  await this.getStatusPageAnnouncementAttachment(req, res);
304
313
  }
@@ -307,8 +316,8 @@ export default class StatusPageAPI extends BaseAPI {
307
316
  }
308
317
  });
309
318
  // embedded overall status badge api
310
- this.router.get(`${(_h = new this.entityType()
311
- .getCrudApiPath()) === null || _h === void 0 ? void 0 : _h.toString()}/badge/:statusPageId`, async (req, res) => {
319
+ this.router.get(`${(_j = new this.entityType()
320
+ .getCrudApiPath()) === null || _j === void 0 ? void 0 : _j.toString()}/badge/:statusPageId`, async (req, res) => {
312
321
  var _a;
313
322
  try {
314
323
  const statusPageId = new ObjectID(req.params["statusPageId"]);
@@ -421,8 +430,8 @@ export default class StatusPageAPI extends BaseAPI {
421
430
  }
422
431
  });
423
432
  // confirm subscription api
424
- this.router.get(`${(_j = new this.entityType()
425
- .getCrudApiPath()) === null || _j === void 0 ? void 0 : _j.toString()}/confirm-subscription/:statusPageSubscriberId`, async (req, res) => {
433
+ this.router.get(`${(_k = new this.entityType()
434
+ .getCrudApiPath()) === null || _k === void 0 ? void 0 : _k.toString()}/confirm-subscription/:statusPageSubscriberId`, async (req, res) => {
426
435
  const token = req.query["verification-token"];
427
436
  const statusPageSubscriberId = new ObjectID(req.params["statusPageSubscriberId"]);
428
437
  const subscriber = await StatusPageSubscriberService.findOneBy({
@@ -459,8 +468,8 @@ export default class StatusPageAPI extends BaseAPI {
459
468
  return Response.sendEmptySuccessResponse(req, res);
460
469
  });
461
470
  // CNAME verification api
462
- this.router.get(`${(_k = new this.entityType()
463
- .getCrudApiPath()) === null || _k === void 0 ? void 0 : _k.toString()}/cname-verification/:token`, async (req, res) => {
471
+ this.router.get(`${(_l = new this.entityType()
472
+ .getCrudApiPath()) === null || _l === void 0 ? void 0 : _l.toString()}/cname-verification/:token`, async (req, res) => {
464
473
  const host = req.get("host");
465
474
  if (!host) {
466
475
  throw new BadDataException("Host not found");
@@ -485,8 +494,8 @@ export default class StatusPageAPI extends BaseAPI {
485
494
  return Response.sendEmptySuccessResponse(req, res);
486
495
  });
487
496
  // ACME Challenge Validation.
488
- this.router.get(`${(_l = new this.entityType()
489
- .getCrudApiPath()) === null || _l === void 0 ? void 0 : _l.toString()}/.well-known/acme-challenge/:token`, async (req, res) => {
497
+ this.router.get(`${(_m = new this.entityType()
498
+ .getCrudApiPath()) === null || _m === void 0 ? void 0 : _m.toString()}/.well-known/acme-challenge/:token`, async (req, res) => {
490
499
  const challenge = await AcmeChallengeService.findOneBy({
491
500
  query: {
492
501
  token: req.params["token"],
@@ -503,7 +512,7 @@ export default class StatusPageAPI extends BaseAPI {
503
512
  }
504
513
  return Response.sendTextResponse(req, res, challenge.challenge);
505
514
  });
506
- this.router.post(`${(_m = new this.entityType().getCrudApiPath()) === null || _m === void 0 ? void 0 : _m.toString()}/test-email-report`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
515
+ this.router.post(`${(_o = new this.entityType().getCrudApiPath()) === null || _o === void 0 ? void 0 : _o.toString()}/test-email-report`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
507
516
  try {
508
517
  const email = new Email(req.body["email"]);
509
518
  const statusPageId = new ObjectID(req.body["statusPageId"].toString());
@@ -517,7 +526,7 @@ export default class StatusPageAPI extends BaseAPI {
517
526
  next(err);
518
527
  }
519
528
  });
520
- this.router.post(`${(_o = new this.entityType().getCrudApiPath()) === null || _o === void 0 ? void 0 : _o.toString()}/domain`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
529
+ this.router.post(`${(_p = new this.entityType().getCrudApiPath()) === null || _p === void 0 ? void 0 : _p.toString()}/domain`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
521
530
  try {
522
531
  if (!req.body["domain"]) {
523
532
  throw new BadDataException("domain is required in request body");
@@ -549,8 +558,8 @@ export default class StatusPageAPI extends BaseAPI {
549
558
  next(err);
550
559
  }
551
560
  });
552
- this.router.post(`${(_p = new this.entityType()
553
- .getCrudApiPath()) === null || _p === void 0 ? void 0 : _p.toString()}/master-page/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
561
+ this.router.post(`${(_q = new this.entityType()
562
+ .getCrudApiPath()) === null || _q === void 0 ? void 0 : _q.toString()}/master-page/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
554
563
  try {
555
564
  const objectId = new ObjectID(req.params["statusPageId"]);
556
565
  const select = {
@@ -667,8 +676,8 @@ export default class StatusPageAPI extends BaseAPI {
667
676
  next(err);
668
677
  }
669
678
  });
670
- this.router.post(`${(_q = new this.entityType()
671
- .getCrudApiPath()) === null || _q === void 0 ? void 0 : _q.toString()}/master-password/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
679
+ this.router.post(`${(_r = new this.entityType()
680
+ .getCrudApiPath()) === null || _r === void 0 ? void 0 : _r.toString()}/master-password/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
672
681
  try {
673
682
  if (!req.params["statusPageId"]) {
674
683
  throw new BadDataException("Status Page ID not found");
@@ -714,7 +723,7 @@ export default class StatusPageAPI extends BaseAPI {
714
723
  next(err);
715
724
  }
716
725
  });
717
- this.router.post(`${(_r = new this.entityType().getCrudApiPath()) === null || _r === void 0 ? void 0 : _r.toString()}/sso/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
726
+ this.router.post(`${(_s = new this.entityType().getCrudApiPath()) === null || _s === void 0 ? void 0 : _s.toString()}/sso/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
718
727
  try {
719
728
  const objectId = new ObjectID(req.params["statusPageId"]);
720
729
  const sso = await StatusPageSsoService.findBy({
@@ -741,8 +750,8 @@ export default class StatusPageAPI extends BaseAPI {
741
750
  }
742
751
  });
743
752
  // Get all status page resources for subscriber to subscribe to.
744
- this.router.post(`${(_s = new this.entityType()
745
- .getCrudApiPath()) === null || _s === void 0 ? void 0 : _s.toString()}/resources/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
753
+ this.router.post(`${(_t = new this.entityType()
754
+ .getCrudApiPath()) === null || _t === void 0 ? void 0 : _t.toString()}/resources/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
746
755
  try {
747
756
  const statusPageId = new ObjectID(req.params["statusPageId"]);
748
757
  await this.checkHasReadAccess({
@@ -775,8 +784,8 @@ export default class StatusPageAPI extends BaseAPI {
775
784
  next(err);
776
785
  }
777
786
  });
778
- this.router.post(`${(_t = new this.entityType()
779
- .getCrudApiPath()) === null || _t === void 0 ? void 0 : _t.toString()}/uptime/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
787
+ this.router.post(`${(_u = new this.entityType()
788
+ .getCrudApiPath()) === null || _u === void 0 ? void 0 : _u.toString()}/uptime/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
780
789
  try {
781
790
  // This reosurce ID can be of a status page resource OR a status page group.
782
791
  const statusPageResourceId = new ObjectID(req.params["statusPageResourceId"]);
@@ -956,8 +965,8 @@ export default class StatusPageAPI extends BaseAPI {
956
965
  next(err);
957
966
  }
958
967
  });
959
- this.router.post(`${(_u = new this.entityType()
960
- .getCrudApiPath()) === null || _u === void 0 ? void 0 : _u.toString()}/overview/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
968
+ this.router.post(`${(_v = new this.entityType()
969
+ .getCrudApiPath()) === null || _v === void 0 ? void 0 : _v.toString()}/overview/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
961
970
  try {
962
971
  const statusPageId = new ObjectID(req.params["statusPageId"]);
963
972
  await this.checkHasReadAccess({
@@ -977,9 +986,17 @@ export default class StatusPageAPI extends BaseAPI {
977
986
  let select = {
978
987
  createdAt: true,
979
988
  declaredAt: true,
989
+ updatedAt: true,
980
990
  title: true,
981
991
  description: true,
982
992
  _id: true,
993
+ postmortemNote: true,
994
+ postmortemPostedAt: true,
995
+ showPostmortemOnStatusPage: true,
996
+ postmortemAttachments: {
997
+ _id: true,
998
+ name: true,
999
+ },
983
1000
  incidentSeverity: {
984
1001
  name: true,
985
1002
  color: true,
@@ -1301,8 +1318,8 @@ export default class StatusPageAPI extends BaseAPI {
1301
1318
  next(err);
1302
1319
  }
1303
1320
  });
1304
- this.router.put(`${(_v = new this.entityType()
1305
- .getCrudApiPath()) === null || _v === void 0 ? void 0 : _v.toString()}/update-subscription/:statusPageId/:subscriberId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
1321
+ this.router.put(`${(_w = new this.entityType()
1322
+ .getCrudApiPath()) === null || _w === void 0 ? void 0 : _w.toString()}/update-subscription/:statusPageId/:subscriberId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
1306
1323
  try {
1307
1324
  await this.subscribeToStatusPage(req);
1308
1325
  return Response.sendEmptySuccessResponse(req, res);
@@ -1311,8 +1328,8 @@ export default class StatusPageAPI extends BaseAPI {
1311
1328
  next(err);
1312
1329
  }
1313
1330
  });
1314
- this.router.post(`${(_w = new this.entityType()
1315
- .getCrudApiPath()) === null || _w === void 0 ? void 0 : _w.toString()}/get-subscription/:statusPageId/:subscriberId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
1331
+ this.router.post(`${(_x = new this.entityType()
1332
+ .getCrudApiPath()) === null || _x === void 0 ? void 0 : _x.toString()}/get-subscription/:statusPageId/:subscriberId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
1316
1333
  try {
1317
1334
  const subscriber = await this.getSubscriber(req);
1318
1335
  return Response.sendEntityResponse(req, res, subscriber, StatusPageSubscriber);
@@ -1321,8 +1338,8 @@ export default class StatusPageAPI extends BaseAPI {
1321
1338
  next(err);
1322
1339
  }
1323
1340
  });
1324
- this.router.post(`${(_x = new this.entityType()
1325
- .getCrudApiPath()) === null || _x === void 0 ? void 0 : _x.toString()}/subscribe/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
1341
+ this.router.post(`${(_y = new this.entityType()
1342
+ .getCrudApiPath()) === null || _y === void 0 ? void 0 : _y.toString()}/subscribe/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
1326
1343
  try {
1327
1344
  await this.subscribeToStatusPage(req);
1328
1345
  return Response.sendEmptySuccessResponse(req, res);
@@ -1331,8 +1348,8 @@ export default class StatusPageAPI extends BaseAPI {
1331
1348
  next(err);
1332
1349
  }
1333
1350
  });
1334
- this.router.post(`${(_y = new this.entityType()
1335
- .getCrudApiPath()) === null || _y === void 0 ? void 0 : _y.toString()}/manage-subscription/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
1351
+ this.router.post(`${(_z = new this.entityType()
1352
+ .getCrudApiPath()) === null || _z === void 0 ? void 0 : _z.toString()}/manage-subscription/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
1336
1353
  try {
1337
1354
  await this.manageExistingSubscription(req);
1338
1355
  return Response.sendEmptySuccessResponse(req, res);
@@ -1341,8 +1358,8 @@ export default class StatusPageAPI extends BaseAPI {
1341
1358
  next(err);
1342
1359
  }
1343
1360
  });
1344
- this.router.post(`${(_z = new this.entityType()
1345
- .getCrudApiPath()) === null || _z === void 0 ? void 0 : _z.toString()}/incidents/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
1361
+ this.router.post(`${(_0 = new this.entityType()
1362
+ .getCrudApiPath()) === null || _0 === void 0 ? void 0 : _0.toString()}/incidents/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
1346
1363
  try {
1347
1364
  const objectId = new ObjectID(req.params["statusPageId"]);
1348
1365
  const response = await this.getIncidents(objectId, null, req);
@@ -1352,8 +1369,8 @@ export default class StatusPageAPI extends BaseAPI {
1352
1369
  next(err);
1353
1370
  }
1354
1371
  });
1355
- this.router.post(`${(_0 = new this.entityType()
1356
- .getCrudApiPath()) === null || _0 === void 0 ? void 0 : _0.toString()}/scheduled-maintenance-events/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
1372
+ this.router.post(`${(_1 = new this.entityType()
1373
+ .getCrudApiPath()) === null || _1 === void 0 ? void 0 : _1.toString()}/scheduled-maintenance-events/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
1357
1374
  try {
1358
1375
  const objectId = new ObjectID(req.params["statusPageId"]);
1359
1376
  const response = await this.getScheduledMaintenanceEvents(objectId, null, req);
@@ -1363,8 +1380,8 @@ export default class StatusPageAPI extends BaseAPI {
1363
1380
  next(err);
1364
1381
  }
1365
1382
  });
1366
- this.router.post(`${(_1 = new this.entityType()
1367
- .getCrudApiPath()) === null || _1 === void 0 ? void 0 : _1.toString()}/announcements/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
1383
+ this.router.post(`${(_2 = new this.entityType()
1384
+ .getCrudApiPath()) === null || _2 === void 0 ? void 0 : _2.toString()}/announcements/:statusPageId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
1368
1385
  try {
1369
1386
  const objectId = new ObjectID(req.params["statusPageId"]);
1370
1387
  const response = await this.getAnnouncements(objectId, null, req);
@@ -1374,8 +1391,8 @@ export default class StatusPageAPI extends BaseAPI {
1374
1391
  next(err);
1375
1392
  }
1376
1393
  });
1377
- this.router.post(`${(_2 = new this.entityType()
1378
- .getCrudApiPath()) === null || _2 === void 0 ? void 0 : _2.toString()}/incidents/:statusPageId/:incidentId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
1394
+ this.router.post(`${(_3 = new this.entityType()
1395
+ .getCrudApiPath()) === null || _3 === void 0 ? void 0 : _3.toString()}/incidents/:statusPageId/:incidentId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
1379
1396
  try {
1380
1397
  const objectId = new ObjectID(req.params["statusPageId"]);
1381
1398
  const incidentId = new ObjectID(req.params["incidentId"]);
@@ -1386,8 +1403,8 @@ export default class StatusPageAPI extends BaseAPI {
1386
1403
  next(err);
1387
1404
  }
1388
1405
  });
1389
- this.router.post(`${(_3 = new this.entityType()
1390
- .getCrudApiPath()) === null || _3 === void 0 ? void 0 : _3.toString()}/scheduled-maintenance-events/:statusPageId/:scheduledMaintenanceId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
1406
+ this.router.post(`${(_4 = new this.entityType()
1407
+ .getCrudApiPath()) === null || _4 === void 0 ? void 0 : _4.toString()}/scheduled-maintenance-events/:statusPageId/:scheduledMaintenanceId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
1391
1408
  try {
1392
1409
  const objectId = new ObjectID(req.params["statusPageId"]);
1393
1410
  const scheduledMaintenanceId = new ObjectID(req.params["scheduledMaintenanceId"]);
@@ -1398,8 +1415,8 @@ export default class StatusPageAPI extends BaseAPI {
1398
1415
  next(err);
1399
1416
  }
1400
1417
  });
1401
- this.router.post(`${(_4 = new this.entityType()
1402
- .getCrudApiPath()) === null || _4 === void 0 ? void 0 : _4.toString()}/announcements/:statusPageId/:announcementId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
1418
+ this.router.post(`${(_5 = new this.entityType()
1419
+ .getCrudApiPath()) === null || _5 === void 0 ? void 0 : _5.toString()}/announcements/:statusPageId/:announcementId`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
1403
1420
  try {
1404
1421
  const objectId = new ObjectID(req.params["statusPageId"]);
1405
1422
  const announcementId = new ObjectID(req.params["announcementId"]);
@@ -2269,9 +2286,17 @@ export default class StatusPageAPI extends BaseAPI {
2269
2286
  let selectIncidents = {
2270
2287
  createdAt: true,
2271
2288
  declaredAt: true,
2289
+ updatedAt: true,
2272
2290
  title: true,
2273
2291
  description: true,
2274
2292
  _id: true,
2293
+ postmortemNote: true,
2294
+ postmortemPostedAt: true,
2295
+ showPostmortemOnStatusPage: true,
2296
+ postmortemAttachments: {
2297
+ _id: true,
2298
+ name: true,
2299
+ },
2275
2300
  incidentSeverity: {
2276
2301
  name: true,
2277
2302
  color: true,
@@ -2795,6 +2820,90 @@ export default class StatusPageAPI extends BaseAPI {
2795
2820
  Response.setNoCacheHeaders(res);
2796
2821
  return Response.sendFileResponse(req, res, attachment);
2797
2822
  }
2823
+ async getIncidentPostmortemAttachment(req, res) {
2824
+ var _a;
2825
+ const statusPageIdParam = req.params["statusPageId"];
2826
+ const incidentIdParam = req.params["incidentId"];
2827
+ const fileIdParam = req.params["fileId"];
2828
+ if (!statusPageIdParam || !incidentIdParam || !fileIdParam) {
2829
+ throw new NotFoundException("Attachment not found");
2830
+ }
2831
+ let statusPageId;
2832
+ let incidentId;
2833
+ let fileId;
2834
+ try {
2835
+ statusPageId = new ObjectID(statusPageIdParam);
2836
+ incidentId = new ObjectID(incidentIdParam);
2837
+ fileId = new ObjectID(fileIdParam);
2838
+ }
2839
+ catch (_b) {
2840
+ throw new NotFoundException("Attachment not found");
2841
+ }
2842
+ await this.checkHasReadAccess({
2843
+ statusPageId,
2844
+ req,
2845
+ });
2846
+ const statusPage = await StatusPageService.findOneBy({
2847
+ query: {
2848
+ _id: statusPageId.toString(),
2849
+ },
2850
+ select: {
2851
+ _id: true,
2852
+ projectId: true,
2853
+ showIncidentsOnStatusPage: true,
2854
+ },
2855
+ props: {
2856
+ isRoot: true,
2857
+ },
2858
+ });
2859
+ if (!statusPage ||
2860
+ !statusPage.projectId ||
2861
+ !statusPage.showIncidentsOnStatusPage) {
2862
+ throw new NotFoundException("Attachment not found");
2863
+ }
2864
+ const { monitorsOnStatusPage } = await StatusPageService.getMonitorIdsOnStatusPage({
2865
+ statusPageId,
2866
+ });
2867
+ if (!monitorsOnStatusPage || monitorsOnStatusPage.length === 0) {
2868
+ throw new NotFoundException("Attachment not found");
2869
+ }
2870
+ const incident = await IncidentService.findOneBy({
2871
+ query: {
2872
+ _id: incidentId.toString(),
2873
+ projectId: statusPage.projectId,
2874
+ isVisibleOnStatusPage: true,
2875
+ showPostmortemOnStatusPage: true,
2876
+ monitors: monitorsOnStatusPage,
2877
+ },
2878
+ select: {
2879
+ postmortemAttachments: {
2880
+ _id: true,
2881
+ file: true,
2882
+ fileType: true,
2883
+ name: true,
2884
+ },
2885
+ },
2886
+ props: {
2887
+ isRoot: true,
2888
+ },
2889
+ });
2890
+ if (!incident) {
2891
+ throw new NotFoundException("Attachment not found");
2892
+ }
2893
+ const attachment = (_a = incident.postmortemAttachments) === null || _a === void 0 ? void 0 : _a.find((file) => {
2894
+ const attachmentId = file._id
2895
+ ? file._id.toString()
2896
+ : file.id
2897
+ ? file.id.toString()
2898
+ : null;
2899
+ return attachmentId === fileId.toString();
2900
+ });
2901
+ if (!attachment || !attachment.file) {
2902
+ throw new NotFoundException("Attachment not found");
2903
+ }
2904
+ Response.setNoCacheHeaders(res);
2905
+ return Response.sendFileResponse(req, res, attachment);
2906
+ }
2798
2907
  async getIncidentPublicNoteAttachment(req, res) {
2799
2908
  var _a;
2800
2909
  const statusPageIdParam = req.params["statusPageId"];