@oneuptime/common 10.0.36 → 10.0.37

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 (46) hide show
  1. package/Models/DatabaseModels/Index.ts +2 -0
  2. package/Models/DatabaseModels/WorkspaceNotificationSummary.ts +819 -0
  3. package/Server/API/StatusPageAPI.ts +7 -0
  4. package/Server/API/WorkspaceNotificationSummaryAPI.ts +67 -0
  5. package/Server/Infrastructure/Postgres/SchemaMigrations/1774355321449-MigrationName.ts +51 -0
  6. package/Server/Infrastructure/Postgres/SchemaMigrations/1774357353502-MigrationName.ts +29 -0
  7. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +4 -0
  8. package/Server/Middleware/MasterAdminAuthorization.ts +55 -0
  9. package/Server/Services/Index.ts +2 -0
  10. package/Server/Services/WorkspaceNotificationSummaryService.ts +1450 -0
  11. package/Server/Utils/Greenlock/Greenlock.ts +1 -0
  12. package/Types/Permission.ts +42 -0
  13. package/Types/Workspace/NotificationSummary/WorkspaceNotificationSummaryItem.ts +13 -0
  14. package/Types/Workspace/NotificationSummary/WorkspaceNotificationSummaryType.ts +8 -0
  15. package/UI/Components/GanttChart/Bar/Index.tsx +23 -5
  16. package/build/dist/Models/DatabaseModels/Index.js +2 -0
  17. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  18. package/build/dist/Models/DatabaseModels/WorkspaceNotificationSummary.js +857 -0
  19. package/build/dist/Models/DatabaseModels/WorkspaceNotificationSummary.js.map +1 -0
  20. package/build/dist/Server/API/StatusPageAPI.js +2 -0
  21. package/build/dist/Server/API/StatusPageAPI.js.map +1 -1
  22. package/build/dist/Server/API/WorkspaceNotificationSummaryAPI.js +40 -0
  23. package/build/dist/Server/API/WorkspaceNotificationSummaryAPI.js.map +1 -0
  24. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774355321449-MigrationName.js +24 -0
  25. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774355321449-MigrationName.js.map +1 -0
  26. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774357353502-MigrationName.js +16 -0
  27. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774357353502-MigrationName.js.map +1 -0
  28. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +4 -0
  29. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  30. package/build/dist/Server/Middleware/MasterAdminAuthorization.js +25 -0
  31. package/build/dist/Server/Middleware/MasterAdminAuthorization.js.map +1 -0
  32. package/build/dist/Server/Services/Index.js +2 -0
  33. package/build/dist/Server/Services/Index.js.map +1 -1
  34. package/build/dist/Server/Services/WorkspaceNotificationSummaryService.js +1122 -0
  35. package/build/dist/Server/Services/WorkspaceNotificationSummaryService.js.map +1 -0
  36. package/build/dist/Server/Utils/Greenlock/Greenlock.js +1 -0
  37. package/build/dist/Server/Utils/Greenlock/Greenlock.js.map +1 -1
  38. package/build/dist/Types/Permission.js +36 -0
  39. package/build/dist/Types/Permission.js.map +1 -1
  40. package/build/dist/Types/Workspace/NotificationSummary/WorkspaceNotificationSummaryItem.js +14 -0
  41. package/build/dist/Types/Workspace/NotificationSummary/WorkspaceNotificationSummaryItem.js.map +1 -0
  42. package/build/dist/Types/Workspace/NotificationSummary/WorkspaceNotificationSummaryType.js +9 -0
  43. package/build/dist/Types/Workspace/NotificationSummary/WorkspaceNotificationSummaryType.js.map +1 -0
  44. package/build/dist/UI/Components/GanttChart/Bar/Index.js +15 -3
  45. package/build/dist/UI/Components/GanttChart/Bar/Index.js.map +1 -1
  46. package/package.json +1 -1
@@ -718,6 +718,10 @@ export default class StatusPageAPI extends BaseAPI<
718
718
  .getCrudApiPath()
719
719
  ?.toString()}/.well-known/acme-challenge/:token`,
720
720
  async (req: ExpressRequest, res: ExpressResponse) => {
721
+ logger.debug(
722
+ `ACME challenge validation request received for token: ${req.params["token"]} from host: ${req.headers["host"]}`,
723
+ );
724
+
721
725
  const challenge: AcmeChallenge | null =
722
726
  await AcmeChallengeService.findOneBy({
723
727
  query: {
@@ -732,6 +736,9 @@ export default class StatusPageAPI extends BaseAPI<
732
736
  });
733
737
 
734
738
  if (!challenge) {
739
+ logger.error(
740
+ `ACME challenge not found for token: ${req.params["token"]} from host: ${req.headers["host"]}`,
741
+ );
735
742
  return Response.sendErrorResponse(
736
743
  req,
737
744
  res,
@@ -0,0 +1,67 @@
1
+ import UserMiddleware from "../Middleware/UserAuthorization";
2
+ import WorkspaceNotificationSummaryService, {
3
+ Service as WorkspaceNotificationSummaryServiceType,
4
+ } from "../Services/WorkspaceNotificationSummaryService";
5
+ import {
6
+ ExpressRequest,
7
+ ExpressResponse,
8
+ NextFunction,
9
+ } from "../Utils/Express";
10
+ import Response from "../Utils/Response";
11
+ import BaseAPI from "./BaseAPI";
12
+ import CommonAPI from "./CommonAPI";
13
+ import DatabaseCommonInteractionProps from "../../Types/BaseDatabase/DatabaseCommonInteractionProps";
14
+ import WorkspaceNotificationSummary from "../../Models/DatabaseModels/WorkspaceNotificationSummary";
15
+ import ObjectID from "../../Types/ObjectID";
16
+ import BadDataException from "../../Types/Exception/BadDataException";
17
+
18
+ export default class WorkspaceNotificationSummaryAPI extends BaseAPI<
19
+ WorkspaceNotificationSummary,
20
+ WorkspaceNotificationSummaryServiceType
21
+ > {
22
+ public constructor() {
23
+ super(WorkspaceNotificationSummary, WorkspaceNotificationSummaryService);
24
+
25
+ this.router.post(
26
+ `${new this.entityType().getCrudApiPath()?.toString()}/test/:workspaceNotificationSummaryId`,
27
+ UserMiddleware.getUserMiddleware,
28
+ async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
29
+ try {
30
+ const databaseProps: DatabaseCommonInteractionProps =
31
+ await CommonAPI.getDatabaseCommonInteractionProps(req);
32
+
33
+ const summaryId: ObjectID = new ObjectID(
34
+ req.params["workspaceNotificationSummaryId"] as string,
35
+ );
36
+
37
+ // Verify the summary belongs to the user's project
38
+ const summary: WorkspaceNotificationSummary | null =
39
+ await this.service.findOneById({
40
+ id: summaryId,
41
+ select: { projectId: true },
42
+ props: databaseProps,
43
+ });
44
+
45
+ if (!summary) {
46
+ return Response.sendErrorResponse(
47
+ req,
48
+ res,
49
+ new BadDataException("Summary not found or access denied"),
50
+ );
51
+ }
52
+
53
+ await this.service.testSummary({
54
+ summaryId: summaryId,
55
+ props: databaseProps,
56
+ projectId: databaseProps.tenantId!,
57
+ testByUserId: databaseProps.userId!,
58
+ });
59
+
60
+ return Response.sendEmptySuccessResponse(req, res);
61
+ } catch (e) {
62
+ next(e);
63
+ }
64
+ },
65
+ );
66
+ }
67
+ }
@@ -0,0 +1,51 @@
1
+ import { MigrationInterface, QueryRunner } from "typeorm";
2
+
3
+ export class MigrationName1774355321449 implements MigrationInterface {
4
+ public name = "MigrationName1774355321449";
5
+
6
+ public async up(queryRunner: QueryRunner): Promise<void> {
7
+ await queryRunner.query(
8
+ `CREATE TABLE "WorkspaceNotificationSummary" ("_id" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "deletedAt" TIMESTAMP WITH TIME ZONE, "version" integer NOT NULL, "projectId" uuid NOT NULL, "name" character varying(500) NOT NULL, "description" character varying(500), "workspaceType" character varying(500) NOT NULL, "summaryType" character varying NOT NULL, "recurringInterval" jsonb NOT NULL, "numberOfDaysOfData" integer NOT NULL DEFAULT '7', "channelNames" jsonb NOT NULL, "teamName" character varying(500), "summaryItems" jsonb NOT NULL, "filters" jsonb, "filterCondition" character varying, "nextSendAt" TIMESTAMP WITH TIME ZONE, "lastSentAt" TIMESTAMP WITH TIME ZONE, "isEnabled" boolean NOT NULL DEFAULT true, "createdByUserId" uuid, "deletedByUserId" uuid, CONSTRAINT "PK_c5bb0f644c5279e3781177ce819" PRIMARY KEY ("_id"))`,
9
+ );
10
+ await queryRunner.query(
11
+ `CREATE INDEX "IDX_d7f80977bcbac1b82c2beacc27" ON "WorkspaceNotificationSummary" ("projectId") `,
12
+ );
13
+ await queryRunner.query(
14
+ `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type":"Recurring","value":{"intervalType":"Day","intervalCount":{"_type":"PositiveNumber","value":1}}}'`,
15
+ );
16
+ await queryRunner.query(
17
+ `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type":"RestrictionTimes","value":{"restictionType":"None","dayRestrictionTimes":null,"weeklyRestrictionTimes":[]}}'`,
18
+ );
19
+ await queryRunner.query(
20
+ `ALTER TABLE "WorkspaceNotificationSummary" ADD CONSTRAINT "FK_d7f80977bcbac1b82c2beacc271" FOREIGN KEY ("projectId") REFERENCES "Project"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
21
+ );
22
+ await queryRunner.query(
23
+ `ALTER TABLE "WorkspaceNotificationSummary" ADD CONSTRAINT "FK_f9c24022445dbea5d8b2d104302" FOREIGN KEY ("createdByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
24
+ );
25
+ await queryRunner.query(
26
+ `ALTER TABLE "WorkspaceNotificationSummary" ADD CONSTRAINT "FK_a9f1c0c0d88abf1795d1c93c138" FOREIGN KEY ("deletedByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
27
+ );
28
+ }
29
+
30
+ public async down(queryRunner: QueryRunner): Promise<void> {
31
+ await queryRunner.query(
32
+ `ALTER TABLE "WorkspaceNotificationSummary" DROP CONSTRAINT "FK_a9f1c0c0d88abf1795d1c93c138"`,
33
+ );
34
+ await queryRunner.query(
35
+ `ALTER TABLE "WorkspaceNotificationSummary" DROP CONSTRAINT "FK_f9c24022445dbea5d8b2d104302"`,
36
+ );
37
+ await queryRunner.query(
38
+ `ALTER TABLE "WorkspaceNotificationSummary" DROP CONSTRAINT "FK_d7f80977bcbac1b82c2beacc271"`,
39
+ );
40
+ await queryRunner.query(
41
+ `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type": "RestrictionTimes", "value": {"restictionType": "None", "dayRestrictionTimes": null, "weeklyRestrictionTimes": []}}'`,
42
+ );
43
+ await queryRunner.query(
44
+ `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type": "Recurring", "value": {"intervalType": "Day", "intervalCount": {"_type": "PositiveNumber", "value": 1}}}'`,
45
+ );
46
+ await queryRunner.query(
47
+ `DROP INDEX "public"."IDX_d7f80977bcbac1b82c2beacc27"`,
48
+ );
49
+ await queryRunner.query(`DROP TABLE "WorkspaceNotificationSummary"`);
50
+ }
51
+ }
@@ -0,0 +1,29 @@
1
+ import { MigrationInterface, QueryRunner } from "typeorm";
2
+
3
+ export class MigrationName1774357353502 implements MigrationInterface {
4
+ public name: string = "MigrationName1774357353502";
5
+
6
+ public async up(queryRunner: QueryRunner): Promise<void> {
7
+ await queryRunner.query(
8
+ `ALTER TABLE "WorkspaceNotificationSummary" ADD "sendFirstReportAt" TIMESTAMP WITH TIME ZONE`,
9
+ );
10
+ await queryRunner.query(
11
+ `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type":"Recurring","value":{"intervalType":"Day","intervalCount":{"_type":"PositiveNumber","value":1}}}'`,
12
+ );
13
+ await queryRunner.query(
14
+ `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type":"RestrictionTimes","value":{"restictionType":"None","dayRestrictionTimes":null,"weeklyRestrictionTimes":[]}}'`,
15
+ );
16
+ }
17
+
18
+ public async down(queryRunner: QueryRunner): Promise<void> {
19
+ await queryRunner.query(
20
+ `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type": "RestrictionTimes", "value": {"restictionType": "None", "dayRestrictionTimes": null, "weeklyRestrictionTimes": []}}'`,
21
+ );
22
+ await queryRunner.query(
23
+ `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type": "Recurring", "value": {"intervalType": "Day", "intervalCount": {"_type": "PositiveNumber", "value": 1}}}'`,
24
+ );
25
+ await queryRunner.query(
26
+ `ALTER TABLE "WorkspaceNotificationSummary" DROP COLUMN "sendFirstReportAt"`,
27
+ );
28
+ }
29
+ }
@@ -268,6 +268,8 @@ import { MigrationName1773402621107 } from "./1773402621107-MigrationName";
268
268
  import { MigrationName1773676206197 } from "./1773676206197-MigrationName";
269
269
  import { MigrationName1774000000000 } from "./1774000000000-MigrationName";
270
270
  import { MigrationName1774000000001 } from "./1774000000001-MigrationName";
271
+ import { MigrationName1774355321449 } from "./1774355321449-MigrationName";
272
+ import { MigrationName1774357353502 } from "./1774357353502-MigrationName";
271
273
 
272
274
  export default [
273
275
  InitialMigration,
@@ -540,4 +542,6 @@ export default [
540
542
  MigrationName1773676206197,
541
543
  MigrationName1774000000000,
542
544
  MigrationName1774000000001,
545
+ MigrationName1774355321449,
546
+ MigrationName1774357353502,
543
547
  ];
@@ -0,0 +1,55 @@
1
+ import UserMiddleware from "./UserAuthorization";
2
+ import JSONWebToken from "../Utils/JsonWebToken";
3
+ import Response from "../Utils/Response";
4
+ import {
5
+ ExpressRequest,
6
+ ExpressResponse,
7
+ NextFunction,
8
+ } from "../Utils/Express";
9
+ import NotAuthorizedException from "../../Types/Exception/NotAuthorizedException";
10
+ import JSONWebTokenData from "../../Types/JsonWebTokenData";
11
+
12
+ export default class MasterAdminAuthorization {
13
+ public static async isAuthorizedMasterAdminMiddleware(
14
+ req: ExpressRequest,
15
+ res: ExpressResponse,
16
+ next: NextFunction,
17
+ ): Promise<void> {
18
+ try {
19
+ const accessToken: string | undefined =
20
+ UserMiddleware.getAccessTokenFromExpressRequest(req);
21
+
22
+ if (!accessToken) {
23
+ Response.sendErrorResponse(
24
+ req,
25
+ res,
26
+ new NotAuthorizedException("Unauthorized: Access token is required."),
27
+ );
28
+ return;
29
+ }
30
+
31
+ const authData: JSONWebTokenData = JSONWebToken.decode(accessToken);
32
+
33
+ if (!authData.isMasterAdmin) {
34
+ Response.sendErrorResponse(
35
+ req,
36
+ res,
37
+ new NotAuthorizedException(
38
+ "Unauthorized: Only master admins can perform this action.",
39
+ ),
40
+ );
41
+ return;
42
+ }
43
+
44
+ next();
45
+ } catch {
46
+ Response.sendErrorResponse(
47
+ req,
48
+ res,
49
+ new NotAuthorizedException(
50
+ "Unauthorized: Invalid or expired access token.",
51
+ ),
52
+ );
53
+ }
54
+ }
55
+ }
@@ -198,6 +198,7 @@ import WorkspaceUserAuthTokenService from "./WorkspaceUserAuthTokenService";
198
198
  import WorkspaceSettingService from "./WorkspaceSettingService";
199
199
  import WorkspaceNotificationRuleService from "./WorkspaceNotificationRuleService";
200
200
  import WorkspaceNotificationLogService from "./WorkspaceNotificationLogService";
201
+ import WorkspaceNotificationSummaryService from "./WorkspaceNotificationSummaryService";
201
202
  import OnCallDutyPolicyUserOverrideService from "./OnCallDutyPolicyUserOverrideService";
202
203
 
203
204
  import MonitorLogService from "./MonitorLogService";
@@ -416,6 +417,7 @@ const services: Array<BaseService> = [
416
417
  WorkspaceSettingService,
417
418
  WorkspaceNotificationRuleService,
418
419
  WorkspaceNotificationLogService,
420
+ WorkspaceNotificationSummaryService,
419
421
 
420
422
  ProjectSCIMLogService,
421
423
  StatusPageSCIMLogService,