diff --git a/Common/Models/DatabaseModels/IncidentInternalNote.ts b/Common/Models/DatabaseModels/IncidentInternalNote.ts index 085851e0ff..761e36d99e 100644 --- a/Common/Models/DatabaseModels/IncidentInternalNote.ts +++ b/Common/Models/DatabaseModels/IncidentInternalNote.ts @@ -18,7 +18,15 @@ import TenantColumn from "../../Types/Database/TenantColumn"; import IconProp from "../../Types/Icon/IconProp"; import ObjectID from "../../Types/ObjectID"; import Permission from "../../Types/Permission"; -import { Column, Entity, Index, JoinColumn, JoinTable, ManyToMany, ManyToOne } from "typeorm"; +import { + Column, + Entity, + Index, + JoinColumn, + JoinTable, + ManyToMany, + ManyToOne, +} from "typeorm"; @EnableDocumentation() @CanAccessIfCanReadOn("incident") diff --git a/Common/Models/DatabaseModels/IncidentPublicNote.ts b/Common/Models/DatabaseModels/IncidentPublicNote.ts index dddd508310..e27397d65b 100644 --- a/Common/Models/DatabaseModels/IncidentPublicNote.ts +++ b/Common/Models/DatabaseModels/IncidentPublicNote.ts @@ -19,7 +19,15 @@ import IconProp from "../../Types/Icon/IconProp"; import ObjectID from "../../Types/ObjectID"; import Permission from "../../Types/Permission"; import StatusPageSubscriberNotificationStatus from "../../Types/StatusPage/StatusPageSubscriberNotificationStatus"; -import { Column, Entity, Index, JoinColumn, JoinTable, ManyToMany, ManyToOne } from "typeorm"; +import { + Column, + Entity, + Index, + JoinColumn, + JoinTable, + ManyToMany, + ManyToOne, +} from "typeorm"; @EnableDocumentation() @CanAccessIfCanReadOn("incident") diff --git a/Common/Models/DatabaseModels/ScheduledMaintenanceInternalNote.ts b/Common/Models/DatabaseModels/ScheduledMaintenanceInternalNote.ts index 27c8d5447f..29b7161f19 100644 --- a/Common/Models/DatabaseModels/ScheduledMaintenanceInternalNote.ts +++ b/Common/Models/DatabaseModels/ScheduledMaintenanceInternalNote.ts @@ -17,7 +17,15 @@ import TenantColumn from "../../Types/Database/TenantColumn"; import IconProp from "../../Types/Icon/IconProp"; import ObjectID from "../../Types/ObjectID"; import Permission from "../../Types/Permission"; -import { Column, Entity, Index, JoinColumn, JoinTable, ManyToMany, ManyToOne } from "typeorm"; +import { + Column, + Entity, + Index, + JoinColumn, + JoinTable, + ManyToMany, + ManyToOne, +} from "typeorm"; @CanAccessIfCanReadOn("scheduledMaintenance") @TenantColumn("projectId") diff --git a/Common/Models/DatabaseModels/ScheduledMaintenancePublicNote.ts b/Common/Models/DatabaseModels/ScheduledMaintenancePublicNote.ts index 6f2f51e0be..8d0f8ffa73 100644 --- a/Common/Models/DatabaseModels/ScheduledMaintenancePublicNote.ts +++ b/Common/Models/DatabaseModels/ScheduledMaintenancePublicNote.ts @@ -19,7 +19,15 @@ import IconProp from "../../Types/Icon/IconProp"; import ObjectID from "../../Types/ObjectID"; import Permission from "../../Types/Permission"; import StatusPageSubscriberNotificationStatus from "../../Types/StatusPage/StatusPageSubscriberNotificationStatus"; -import { Column, Entity, Index, JoinColumn, JoinTable, ManyToMany, ManyToOne } from "typeorm"; +import { + Column, + Entity, + Index, + JoinColumn, + JoinTable, + ManyToMany, + ManyToOne, +} from "typeorm"; @EnableDocumentation() @CanAccessIfCanReadOn("scheduledMaintenance") diff --git a/Common/Server/API/IncidentInternalNoteAPI.ts b/Common/Server/API/IncidentInternalNoteAPI.ts index 59261d5e2c..0111137b96 100644 --- a/Common/Server/API/IncidentInternalNoteAPI.ts +++ b/Common/Server/API/IncidentInternalNoteAPI.ts @@ -57,21 +57,20 @@ export default class IncidentInternalNoteAPI extends BaseAPI< const props = await CommonAPI.getDatabaseCommonInteractionProps(req); - const note: IncidentInternalNote | null = - await this.service.findOneBy({ - query: { - _id: noteId, + const note: IncidentInternalNote | null = await this.service.findOneBy({ + query: { + _id: noteId, + }, + select: { + attachments: { + _id: true, + file: true, + fileType: true, + name: true, }, - select: { - attachments: { - _id: true, - file: true, - fileType: true, - name: true, - }, - }, - props, - }); + }, + props, + }); const attachment = note?.attachments?.find((file) => { const attachmentId: string | null = file._id diff --git a/Common/Server/API/IncidentPublicNoteAPI.ts b/Common/Server/API/IncidentPublicNoteAPI.ts index 8a2e6387db..20395015aa 100644 --- a/Common/Server/API/IncidentPublicNoteAPI.ts +++ b/Common/Server/API/IncidentPublicNoteAPI.ts @@ -67,7 +67,7 @@ export default class IncidentPublicNoteAPI extends BaseAPI< name: true, }, }, - props + props, }); const attachment = note?.attachments?.find((file) => { diff --git a/Common/Server/API/ScheduledMaintenancePublicNoteAPI.ts b/Common/Server/API/ScheduledMaintenancePublicNoteAPI.ts index 1b8b39a347..6ab9dccf05 100644 --- a/Common/Server/API/ScheduledMaintenancePublicNoteAPI.ts +++ b/Common/Server/API/ScheduledMaintenancePublicNoteAPI.ts @@ -18,7 +18,10 @@ export default class ScheduledMaintenancePublicNoteAPI extends BaseAPI< ScheduledMaintenancePublicNoteServiceType > { public constructor() { - super(ScheduledMaintenancePublicNote, ScheduledMaintenancePublicNoteService); + super( + ScheduledMaintenancePublicNote, + ScheduledMaintenancePublicNoteService, + ); this.router.get( `${new this.entityType().getCrudApiPath()?.toString()}/attachment/:noteId/:fileId`, diff --git a/Common/Server/API/StatusPageAnnouncementAPI.ts b/Common/Server/API/StatusPageAnnouncementAPI.ts index 5480253eaf..b02c719f9d 100644 --- a/Common/Server/API/StatusPageAnnouncementAPI.ts +++ b/Common/Server/API/StatusPageAnnouncementAPI.ts @@ -36,7 +36,8 @@ export default class StatusPageAnnouncementAPI extends BaseAPI< req: ExpressRequest, res: ExpressResponse, ): Promise { - const announcementIdParam: string | undefined = req.params["announcementId"]; + const announcementIdParam: string | undefined = + req.params["announcementId"]; const fileIdParam: string | undefined = req.params["fileId"]; if (!announcementIdParam || !fileIdParam) { diff --git a/Common/Server/Infrastructure/Postgres/SchemaMigrations/1763471659817-MigrationName.ts b/Common/Server/Infrastructure/Postgres/SchemaMigrations/1763471659817-MigrationName.ts index c064c0203b..d9192aba2c 100644 --- a/Common/Server/Infrastructure/Postgres/SchemaMigrations/1763471659817-MigrationName.ts +++ b/Common/Server/Infrastructure/Postgres/SchemaMigrations/1763471659817-MigrationName.ts @@ -1,36 +1,79 @@ import { MigrationInterface, QueryRunner } from "typeorm"; export class MigrationName1763471659817 implements MigrationInterface { - public name = 'MigrationName1763471659817' + public name = "MigrationName1763471659817"; - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE "IncidentInternalNoteFile" ("incidentInternalNoteId" uuid NOT NULL, "fileId" uuid NOT NULL, CONSTRAINT "PK_1e97a749db84f9dc65ee162dd6b" PRIMARY KEY ("incidentInternalNoteId", "fileId"))`); - await queryRunner.query(`CREATE INDEX "IDX_0edb0291ff3e97197269d77dc4" ON "IncidentInternalNoteFile" ("incidentInternalNoteId") `); - await queryRunner.query(`CREATE INDEX "IDX_b30b49d21a553c06bd0ff3acf5" ON "IncidentInternalNoteFile" ("fileId") `); - await queryRunner.query(`CREATE TABLE "IncidentPublicNoteFile" ("incidentPublicNoteId" uuid NOT NULL, "fileId" uuid NOT NULL, CONSTRAINT "PK_42d2fe75b663f8fa20421f31e78" PRIMARY KEY ("incidentPublicNoteId", "fileId"))`); - await queryRunner.query(`CREATE INDEX "IDX_e5c4a5671b2bb51a9918f1f203" ON "IncidentPublicNoteFile" ("incidentPublicNoteId") `); - await queryRunner.query(`CREATE INDEX "IDX_81a5bc92f59cb5577746ee51ba" ON "IncidentPublicNoteFile" ("fileId") `); - await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type":"Recurring","value":{"intervalType":"Day","intervalCount":{"_type":"PositiveNumber","value":1}}}'`); - await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type":"RestrictionTimes","value":{"restictionType":"None","dayRestrictionTimes":null,"weeklyRestrictionTimes":[]}}'`); - await queryRunner.query(`ALTER TABLE "IncidentInternalNoteFile" ADD CONSTRAINT "FK_0edb0291ff3e97197269d77dc48" FOREIGN KEY ("incidentInternalNoteId") REFERENCES "IncidentInternalNote"("_id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "IncidentInternalNoteFile" ADD CONSTRAINT "FK_b30b49d21a553c06bd0ff3acf5f" FOREIGN KEY ("fileId") REFERENCES "File"("_id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "IncidentPublicNoteFile" ADD CONSTRAINT "FK_e5c4a5671b2bb51a9918f1f203d" FOREIGN KEY ("incidentPublicNoteId") REFERENCES "IncidentPublicNote"("_id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "IncidentPublicNoteFile" ADD CONSTRAINT "FK_81a5bc92f59cb5577746ee51baf" FOREIGN KEY ("fileId") REFERENCES "File"("_id") ON DELETE CASCADE ON UPDATE CASCADE`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "IncidentPublicNoteFile" DROP CONSTRAINT "FK_81a5bc92f59cb5577746ee51baf"`); - await queryRunner.query(`ALTER TABLE "IncidentPublicNoteFile" DROP CONSTRAINT "FK_e5c4a5671b2bb51a9918f1f203d"`); - await queryRunner.query(`ALTER TABLE "IncidentInternalNoteFile" DROP CONSTRAINT "FK_b30b49d21a553c06bd0ff3acf5f"`); - await queryRunner.query(`ALTER TABLE "IncidentInternalNoteFile" DROP CONSTRAINT "FK_0edb0291ff3e97197269d77dc48"`); - await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type": "RestrictionTimes", "value": {"restictionType": "None", "dayRestrictionTimes": null, "weeklyRestrictionTimes": []}}'`); - await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type": "Recurring", "value": {"intervalType": "Day", "intervalCount": {"_type": "PositiveNumber", "value": 1}}}'`); - await queryRunner.query(`DROP INDEX "public"."IDX_81a5bc92f59cb5577746ee51ba"`); - await queryRunner.query(`DROP INDEX "public"."IDX_e5c4a5671b2bb51a9918f1f203"`); - await queryRunner.query(`DROP TABLE "IncidentPublicNoteFile"`); - await queryRunner.query(`DROP INDEX "public"."IDX_b30b49d21a553c06bd0ff3acf5"`); - await queryRunner.query(`DROP INDEX "public"."IDX_0edb0291ff3e97197269d77dc4"`); - await queryRunner.query(`DROP TABLE "IncidentInternalNoteFile"`); - } + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `CREATE TABLE "IncidentInternalNoteFile" ("incidentInternalNoteId" uuid NOT NULL, "fileId" uuid NOT NULL, CONSTRAINT "PK_1e97a749db84f9dc65ee162dd6b" PRIMARY KEY ("incidentInternalNoteId", "fileId"))`, + ); + await queryRunner.query( + `CREATE INDEX "IDX_0edb0291ff3e97197269d77dc4" ON "IncidentInternalNoteFile" ("incidentInternalNoteId") `, + ); + await queryRunner.query( + `CREATE INDEX "IDX_b30b49d21a553c06bd0ff3acf5" ON "IncidentInternalNoteFile" ("fileId") `, + ); + await queryRunner.query( + `CREATE TABLE "IncidentPublicNoteFile" ("incidentPublicNoteId" uuid NOT NULL, "fileId" uuid NOT NULL, CONSTRAINT "PK_42d2fe75b663f8fa20421f31e78" PRIMARY KEY ("incidentPublicNoteId", "fileId"))`, + ); + await queryRunner.query( + `CREATE INDEX "IDX_e5c4a5671b2bb51a9918f1f203" ON "IncidentPublicNoteFile" ("incidentPublicNoteId") `, + ); + await queryRunner.query( + `CREATE INDEX "IDX_81a5bc92f59cb5577746ee51ba" ON "IncidentPublicNoteFile" ("fileId") `, + ); + await queryRunner.query( + `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type":"Recurring","value":{"intervalType":"Day","intervalCount":{"_type":"PositiveNumber","value":1}}}'`, + ); + await queryRunner.query( + `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type":"RestrictionTimes","value":{"restictionType":"None","dayRestrictionTimes":null,"weeklyRestrictionTimes":[]}}'`, + ); + await queryRunner.query( + `ALTER TABLE "IncidentInternalNoteFile" ADD CONSTRAINT "FK_0edb0291ff3e97197269d77dc48" FOREIGN KEY ("incidentInternalNoteId") REFERENCES "IncidentInternalNote"("_id") ON DELETE CASCADE ON UPDATE CASCADE`, + ); + await queryRunner.query( + `ALTER TABLE "IncidentInternalNoteFile" ADD CONSTRAINT "FK_b30b49d21a553c06bd0ff3acf5f" FOREIGN KEY ("fileId") REFERENCES "File"("_id") ON DELETE CASCADE ON UPDATE CASCADE`, + ); + await queryRunner.query( + `ALTER TABLE "IncidentPublicNoteFile" ADD CONSTRAINT "FK_e5c4a5671b2bb51a9918f1f203d" FOREIGN KEY ("incidentPublicNoteId") REFERENCES "IncidentPublicNote"("_id") ON DELETE CASCADE ON UPDATE CASCADE`, + ); + await queryRunner.query( + `ALTER TABLE "IncidentPublicNoteFile" ADD CONSTRAINT "FK_81a5bc92f59cb5577746ee51baf" FOREIGN KEY ("fileId") REFERENCES "File"("_id") ON DELETE CASCADE ON UPDATE CASCADE`, + ); + } + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "IncidentPublicNoteFile" DROP CONSTRAINT "FK_81a5bc92f59cb5577746ee51baf"`, + ); + await queryRunner.query( + `ALTER TABLE "IncidentPublicNoteFile" DROP CONSTRAINT "FK_e5c4a5671b2bb51a9918f1f203d"`, + ); + await queryRunner.query( + `ALTER TABLE "IncidentInternalNoteFile" DROP CONSTRAINT "FK_b30b49d21a553c06bd0ff3acf5f"`, + ); + await queryRunner.query( + `ALTER TABLE "IncidentInternalNoteFile" DROP CONSTRAINT "FK_0edb0291ff3e97197269d77dc48"`, + ); + await queryRunner.query( + `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type": "RestrictionTimes", "value": {"restictionType": "None", "dayRestrictionTimes": null, "weeklyRestrictionTimes": []}}'`, + ); + await queryRunner.query( + `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type": "Recurring", "value": {"intervalType": "Day", "intervalCount": {"_type": "PositiveNumber", "value": 1}}}'`, + ); + await queryRunner.query( + `DROP INDEX "public"."IDX_81a5bc92f59cb5577746ee51ba"`, + ); + await queryRunner.query( + `DROP INDEX "public"."IDX_e5c4a5671b2bb51a9918f1f203"`, + ); + await queryRunner.query(`DROP TABLE "IncidentPublicNoteFile"`); + await queryRunner.query( + `DROP INDEX "public"."IDX_b30b49d21a553c06bd0ff3acf5"`, + ); + await queryRunner.query( + `DROP INDEX "public"."IDX_0edb0291ff3e97197269d77dc4"`, + ); + await queryRunner.query(`DROP TABLE "IncidentInternalNoteFile"`); + } } diff --git a/Common/Server/Infrastructure/Postgres/SchemaMigrations/1763477560906-MigrationName.ts b/Common/Server/Infrastructure/Postgres/SchemaMigrations/1763477560906-MigrationName.ts index 798cf4d70c..605c128494 100644 --- a/Common/Server/Infrastructure/Postgres/SchemaMigrations/1763477560906-MigrationName.ts +++ b/Common/Server/Infrastructure/Postgres/SchemaMigrations/1763477560906-MigrationName.ts @@ -1,36 +1,81 @@ import { MigrationInterface, QueryRunner } from "typeorm"; export class MigrationName1763477560906 implements MigrationInterface { - public name = 'MigrationName1763477560906' + public name = "MigrationName1763477560906"; - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE "ScheduledMaintenanceInternalNoteFile" ("scheduledMaintenanceInternalNoteId" uuid NOT NULL, "fileId" uuid NOT NULL, CONSTRAINT "PK_fddb744dc7cf400724befe5ba91" PRIMARY KEY ("scheduledMaintenanceInternalNoteId", "fileId"))`); - await queryRunner.query(`CREATE INDEX "IDX_ac92a60535a6d598c9619fd199" ON "ScheduledMaintenanceInternalNoteFile" ("scheduledMaintenanceInternalNoteId") `); - await queryRunner.query(`CREATE INDEX "IDX_daee340befeece208b507a4242" ON "ScheduledMaintenanceInternalNoteFile" ("fileId") `); - await queryRunner.query(`CREATE TABLE "ScheduledMaintenancePublicNoteFile" ("scheduledMaintenancePublicNoteId" uuid NOT NULL, "fileId" uuid NOT NULL, CONSTRAINT "PK_373f78b83aa76e5250df8ebaed7" PRIMARY KEY ("scheduledMaintenancePublicNoteId", "fileId"))`); - await queryRunner.query(`CREATE INDEX "IDX_af6905f89ca8108ed0f478fd37" ON "ScheduledMaintenancePublicNoteFile" ("scheduledMaintenancePublicNoteId") `); - await queryRunner.query(`CREATE INDEX "IDX_f09af6332e0b89f134472f0442" ON "ScheduledMaintenancePublicNoteFile" ("fileId") `); - await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type":"Recurring","value":{"intervalType":"Day","intervalCount":{"_type":"PositiveNumber","value":1}}}'`); - await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type":"RestrictionTimes","value":{"restictionType":"None","dayRestrictionTimes":null,"weeklyRestrictionTimes":[]}}'`); - await queryRunner.query(`ALTER TABLE "ScheduledMaintenanceInternalNoteFile" ADD CONSTRAINT "FK_ac92a60535a6d598c9619fd1999" FOREIGN KEY ("scheduledMaintenanceInternalNoteId") REFERENCES "ScheduledMaintenanceInternalNote"("_id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "ScheduledMaintenanceInternalNoteFile" ADD CONSTRAINT "FK_daee340befeece208b507a42423" FOREIGN KEY ("fileId") REFERENCES "File"("_id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "ScheduledMaintenancePublicNoteFile" ADD CONSTRAINT "FK_af6905f89ca8108ed0f478fd376" FOREIGN KEY ("scheduledMaintenancePublicNoteId") REFERENCES "ScheduledMaintenancePublicNote"("_id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "ScheduledMaintenancePublicNoteFile" ADD CONSTRAINT "FK_f09af6332e0b89f134472f0442a" FOREIGN KEY ("fileId") REFERENCES "File"("_id") ON DELETE CASCADE ON UPDATE CASCADE`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "ScheduledMaintenancePublicNoteFile" DROP CONSTRAINT "FK_f09af6332e0b89f134472f0442a"`); - await queryRunner.query(`ALTER TABLE "ScheduledMaintenancePublicNoteFile" DROP CONSTRAINT "FK_af6905f89ca8108ed0f478fd376"`); - await queryRunner.query(`ALTER TABLE "ScheduledMaintenanceInternalNoteFile" DROP CONSTRAINT "FK_daee340befeece208b507a42423"`); - await queryRunner.query(`ALTER TABLE "ScheduledMaintenanceInternalNoteFile" DROP CONSTRAINT "FK_ac92a60535a6d598c9619fd1999"`); - await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type": "RestrictionTimes", "value": {"restictionType": "None", "dayRestrictionTimes": null, "weeklyRestrictionTimes": []}}'`); - await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type": "Recurring", "value": {"intervalType": "Day", "intervalCount": {"_type": "PositiveNumber", "value": 1}}}'`); - await queryRunner.query(`DROP INDEX "public"."IDX_f09af6332e0b89f134472f0442"`); - await queryRunner.query(`DROP INDEX "public"."IDX_af6905f89ca8108ed0f478fd37"`); - await queryRunner.query(`DROP TABLE "ScheduledMaintenancePublicNoteFile"`); - await queryRunner.query(`DROP INDEX "public"."IDX_daee340befeece208b507a4242"`); - await queryRunner.query(`DROP INDEX "public"."IDX_ac92a60535a6d598c9619fd199"`); - await queryRunner.query(`DROP TABLE "ScheduledMaintenanceInternalNoteFile"`); - } + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `CREATE TABLE "ScheduledMaintenanceInternalNoteFile" ("scheduledMaintenanceInternalNoteId" uuid NOT NULL, "fileId" uuid NOT NULL, CONSTRAINT "PK_fddb744dc7cf400724befe5ba91" PRIMARY KEY ("scheduledMaintenanceInternalNoteId", "fileId"))`, + ); + await queryRunner.query( + `CREATE INDEX "IDX_ac92a60535a6d598c9619fd199" ON "ScheduledMaintenanceInternalNoteFile" ("scheduledMaintenanceInternalNoteId") `, + ); + await queryRunner.query( + `CREATE INDEX "IDX_daee340befeece208b507a4242" ON "ScheduledMaintenanceInternalNoteFile" ("fileId") `, + ); + await queryRunner.query( + `CREATE TABLE "ScheduledMaintenancePublicNoteFile" ("scheduledMaintenancePublicNoteId" uuid NOT NULL, "fileId" uuid NOT NULL, CONSTRAINT "PK_373f78b83aa76e5250df8ebaed7" PRIMARY KEY ("scheduledMaintenancePublicNoteId", "fileId"))`, + ); + await queryRunner.query( + `CREATE INDEX "IDX_af6905f89ca8108ed0f478fd37" ON "ScheduledMaintenancePublicNoteFile" ("scheduledMaintenancePublicNoteId") `, + ); + await queryRunner.query( + `CREATE INDEX "IDX_f09af6332e0b89f134472f0442" ON "ScheduledMaintenancePublicNoteFile" ("fileId") `, + ); + await queryRunner.query( + `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type":"Recurring","value":{"intervalType":"Day","intervalCount":{"_type":"PositiveNumber","value":1}}}'`, + ); + await queryRunner.query( + `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type":"RestrictionTimes","value":{"restictionType":"None","dayRestrictionTimes":null,"weeklyRestrictionTimes":[]}}'`, + ); + await queryRunner.query( + `ALTER TABLE "ScheduledMaintenanceInternalNoteFile" ADD CONSTRAINT "FK_ac92a60535a6d598c9619fd1999" FOREIGN KEY ("scheduledMaintenanceInternalNoteId") REFERENCES "ScheduledMaintenanceInternalNote"("_id") ON DELETE CASCADE ON UPDATE CASCADE`, + ); + await queryRunner.query( + `ALTER TABLE "ScheduledMaintenanceInternalNoteFile" ADD CONSTRAINT "FK_daee340befeece208b507a42423" FOREIGN KEY ("fileId") REFERENCES "File"("_id") ON DELETE CASCADE ON UPDATE CASCADE`, + ); + await queryRunner.query( + `ALTER TABLE "ScheduledMaintenancePublicNoteFile" ADD CONSTRAINT "FK_af6905f89ca8108ed0f478fd376" FOREIGN KEY ("scheduledMaintenancePublicNoteId") REFERENCES "ScheduledMaintenancePublicNote"("_id") ON DELETE CASCADE ON UPDATE CASCADE`, + ); + await queryRunner.query( + `ALTER TABLE "ScheduledMaintenancePublicNoteFile" ADD CONSTRAINT "FK_f09af6332e0b89f134472f0442a" FOREIGN KEY ("fileId") REFERENCES "File"("_id") ON DELETE CASCADE ON UPDATE CASCADE`, + ); + } + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "ScheduledMaintenancePublicNoteFile" DROP CONSTRAINT "FK_f09af6332e0b89f134472f0442a"`, + ); + await queryRunner.query( + `ALTER TABLE "ScheduledMaintenancePublicNoteFile" DROP CONSTRAINT "FK_af6905f89ca8108ed0f478fd376"`, + ); + await queryRunner.query( + `ALTER TABLE "ScheduledMaintenanceInternalNoteFile" DROP CONSTRAINT "FK_daee340befeece208b507a42423"`, + ); + await queryRunner.query( + `ALTER TABLE "ScheduledMaintenanceInternalNoteFile" DROP CONSTRAINT "FK_ac92a60535a6d598c9619fd1999"`, + ); + await queryRunner.query( + `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type": "RestrictionTimes", "value": {"restictionType": "None", "dayRestrictionTimes": null, "weeklyRestrictionTimes": []}}'`, + ); + await queryRunner.query( + `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type": "Recurring", "value": {"intervalType": "Day", "intervalCount": {"_type": "PositiveNumber", "value": 1}}}'`, + ); + await queryRunner.query( + `DROP INDEX "public"."IDX_f09af6332e0b89f134472f0442"`, + ); + await queryRunner.query( + `DROP INDEX "public"."IDX_af6905f89ca8108ed0f478fd37"`, + ); + await queryRunner.query(`DROP TABLE "ScheduledMaintenancePublicNoteFile"`); + await queryRunner.query( + `DROP INDEX "public"."IDX_daee340befeece208b507a4242"`, + ); + await queryRunner.query( + `DROP INDEX "public"."IDX_ac92a60535a6d598c9619fd199"`, + ); + await queryRunner.query( + `DROP TABLE "ScheduledMaintenanceInternalNoteFile"`, + ); + } } diff --git a/Common/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts b/Common/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts index d1968902af..48c05c860b 100644 --- a/Common/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +++ b/Common/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts @@ -371,5 +371,5 @@ export default [ MigrationName1762554602716, MigrationName1762890441920, MigrationName1763471659817, - MigrationName1763477560906 + MigrationName1763477560906, ]; diff --git a/Common/Server/Services/AlertInternalNoteService.ts b/Common/Server/Services/AlertInternalNoteService.ts index c7dcdbf246..32c6d9edff 100644 --- a/Common/Server/Services/AlertInternalNoteService.ts +++ b/Common/Server/Services/AlertInternalNoteService.ts @@ -183,7 +183,9 @@ ${(updatedItem.note || "") + attachmentsMarkdown} return null; }) - .filter((id): id is ObjectID => Boolean(id)); + .filter((id): id is ObjectID => { + return Boolean(id); + }); if (!attachmentIds.length) { return ""; diff --git a/Common/Server/Services/IncidentInternalNoteService.ts b/Common/Server/Services/IncidentInternalNoteService.ts index bb10e4bf32..5d0fbb239b 100644 --- a/Common/Server/Services/IncidentInternalNoteService.ts +++ b/Common/Server/Services/IncidentInternalNoteService.ts @@ -185,7 +185,9 @@ ${(updatedItem.note || "") + attachmentsMarkdown} return null; }) - .filter((id): id is ObjectID => Boolean(id)); + .filter((id): id is ObjectID => { + return Boolean(id); + }); if (!attachmentIds.length) { return ""; diff --git a/Common/Server/Services/IncidentPublicNoteService.ts b/Common/Server/Services/IncidentPublicNoteService.ts index de8a07ca7e..09cc9bdb20 100644 --- a/Common/Server/Services/IncidentPublicNoteService.ts +++ b/Common/Server/Services/IncidentPublicNoteService.ts @@ -218,7 +218,9 @@ ${(updatedItem.note || "") + attachmentsMarkdown} return null; }) - .filter((id): id is ObjectID => Boolean(id)); + .filter((id): id is ObjectID => { + return Boolean(id); + }); if (!attachmentIds.length) { return ""; diff --git a/Common/Server/Services/ScheduledMaintenanceInternalNoteService.ts b/Common/Server/Services/ScheduledMaintenanceInternalNoteService.ts index 0da1ed7ddf..8aafc67c10 100644 --- a/Common/Server/Services/ScheduledMaintenanceInternalNoteService.ts +++ b/Common/Server/Services/ScheduledMaintenanceInternalNoteService.ts @@ -192,7 +192,9 @@ ${(updatedItem.note || "") + attachmentsMarkdown} return null; }) - .filter((id): id is ObjectID => Boolean(id)); + .filter((id): id is ObjectID => { + return Boolean(id); + }); if (!attachmentIds.length) { return ""; diff --git a/Common/Server/Services/ScheduledMaintenancePublicNoteService.ts b/Common/Server/Services/ScheduledMaintenancePublicNoteService.ts index 33cceb73c2..95dde9a0f0 100644 --- a/Common/Server/Services/ScheduledMaintenancePublicNoteService.ts +++ b/Common/Server/Services/ScheduledMaintenancePublicNoteService.ts @@ -224,7 +224,9 @@ ${(updatedItem.note || "") + attachmentsMarkdown} return null; }) - .filter((id): id is ObjectID => Boolean(id)); + .filter((id): id is ObjectID => { + return Boolean(id); + }); if (!attachmentIds.length) { return ""; diff --git a/Common/Server/Utils/FileAttachmentMarkdownUtil.ts b/Common/Server/Utils/FileAttachmentMarkdownUtil.ts index eac4f9f171..5b632a5bd9 100644 --- a/Common/Server/Utils/FileAttachmentMarkdownUtil.ts +++ b/Common/Server/Utils/FileAttachmentMarkdownUtil.ts @@ -16,15 +16,23 @@ export default class FileAttachmentMarkdownUtil { public static async buildAttachmentMarkdown( input: FileAttachmentMarkdownInput, ): Promise { - if (!input.modelId || !input.attachmentIds || input.attachmentIds.length === 0) { + if ( + !input.modelId || + !input.attachmentIds || + input.attachmentIds.length === 0 + ) { return ""; } const uniqueIds: Array = Array.from( new Set( input.attachmentIds - .map((id: ObjectID) => id.toString()) - .filter((value: string) => Boolean(value)), + .map((id: ObjectID) => { + return id.toString(); + }) + .filter((value: string) => { + return Boolean(value); + }), ), ); @@ -53,8 +61,12 @@ export default class FileAttachmentMarkdownUtil { const fileById: Map = new Map( files - .filter((file: File) => Boolean(file._id)) - .map((file: File) => [file._id!.toString(), file]), + .filter((file: File) => { + return Boolean(file._id); + }) + .map((file: File) => { + return [file._id!.toString(), file]; + }), ); const attachmentLines: Array = []; diff --git a/Common/UI/Components/Forms/Fields/FormField.tsx b/Common/UI/Components/Forms/Fields/FormField.tsx index e25698c887..4d57289a65 100644 --- a/Common/UI/Components/Forms/Fields/FormField.tsx +++ b/Common/UI/Components/Forms/Fields/FormField.tsx @@ -617,12 +617,7 @@ const FormField: ( props.field.fileTypes ? props.field.fileTypes : props.field.fieldType === FormFieldSchemaType.ImageFile - ? [ - MimeType.png, - MimeType.jpeg, - MimeType.jpg, - MimeType.svg, - ] + ? [MimeType.png, MimeType.jpeg, MimeType.jpg, MimeType.svg] : [] } isMultiFilePicker={isMultiFileField}