From 1518e07f7ad0541fe88351692ce482a281965608 Mon Sep 17 00:00:00 2001 From: "Yassine R." Date: Mon, 20 Nov 2023 23:22:21 +0100 Subject: [PATCH] fix(common): delete useless types --- .talismanrc | 2 + .../message-sms/MESSAGE_SMS_STATUS.const.ts | 11 ----- .../MESSAGE_SMS_SUIVI_INDEX.const.ts | 7 --- .../model/message-sms/MessageSms.type.ts | 6 +-- .../MessageSmsInteractionMetas.type.ts | 7 --- .../MessageSmsReminderMetas.type.ts | 4 -- .../message-sms/MessageSmsStatus.type.ts | 17 ------- .../src/_common/model/message-sms/index.ts | 5 -- .../1699910877010-auto-migration.ts | 31 +++++++----- .../message-sms/MessageSmsTable.typeorm.ts | 11 +++-- .../exportListeCourriersWorksheetRenderer.ts | 1 - .../interactionsCreator.service.spec.ts | 49 ------------------- .../model/message-sms/MessageSms.type.ts | 3 +- .../MessageSmsReminderMetas.type.ts | 4 -- .../src/_common/model/message-sms/index.ts | 1 - 15 files changed, 32 insertions(+), 127 deletions(-) delete mode 100644 packages/backend/src/_common/model/message-sms/MESSAGE_SMS_STATUS.const.ts delete mode 100644 packages/backend/src/_common/model/message-sms/MESSAGE_SMS_SUIVI_INDEX.const.ts delete mode 100644 packages/backend/src/_common/model/message-sms/MessageSmsInteractionMetas.type.ts delete mode 100644 packages/backend/src/_common/model/message-sms/MessageSmsReminderMetas.type.ts delete mode 100644 packages/backend/src/_common/model/message-sms/MessageSmsStatus.type.ts delete mode 100644 packages/frontend/src/_common/model/message-sms/MessageSmsReminderMetas.type.ts diff --git a/.talismanrc b/.talismanrc index af4dfb99c8..bc5d80e473 100644 --- a/.talismanrc +++ b/.talismanrc @@ -3,6 +3,8 @@ fileignoreconfig: checksum: 104c8036ca644bc51bb4c797e56b3a5b178a55b1c293a77308844e54ca7c404d - filename: _scripts/db/dumps/domifa_test.postgres.truncate-restore-data-only.sql checksum: 9976de417c719ab5c3bec9d4a1bafc40bfa8d4388d2dbd5da7d1ea4a11d2db75 +- filename: packages/backend/src/_migrations/1699910877010-auto-migration.ts + checksum: bd05dd6b68f7fe2ca36ab1180a0449878cf78f4e048d2e5979b3dbe5fba1db53 - filename: packages/backend/src/_migrations/_init-db/1603812391580-pr-env-create-database.ts checksum: 586e3b26481d71256a1b7626956aaf9e68211dfbda527dd862a2aad075b5cc04 - filename: yarn.lock diff --git a/packages/backend/src/_common/model/message-sms/MESSAGE_SMS_STATUS.const.ts b/packages/backend/src/_common/model/message-sms/MESSAGE_SMS_STATUS.const.ts deleted file mode 100644 index 040cd52ee6..0000000000 --- a/packages/backend/src/_common/model/message-sms/MESSAGE_SMS_STATUS.const.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { MessageSmsStatus } from "."; - -export const MESSAGE_SMS_STATUS: { [key: number]: MessageSmsStatus } = { - 0: "ON_HOLD", - 1: "SENT_AND_RECEIVED", - 2: "SENT_AND_NOT_RECEIVED", - 3: "IN_PROGRESS", - 4: "FAILURE", - 5: "EXPIRED", - 6: "DISABLED", -}; diff --git a/packages/backend/src/_common/model/message-sms/MESSAGE_SMS_SUIVI_INDEX.const.ts b/packages/backend/src/_common/model/message-sms/MESSAGE_SMS_SUIVI_INDEX.const.ts deleted file mode 100644 index ea60958c4e..0000000000 --- a/packages/backend/src/_common/model/message-sms/MESSAGE_SMS_SUIVI_INDEX.const.ts +++ /dev/null @@ -1,7 +0,0 @@ -export const INDEX_NUMERO = 0; // Numéro du destinataire -export const INDEX_STATUT = 1; // Statut du message -export const INDEX_DATE_EMISSION = 2; // Date d'émission du message (UNIX timestamp) -export const INDEX_DATE_MISE_A_JOUR = 3; // Date du dernier changement de statut du message (UNIX timestamp) -export const INDEX_STATUT_DETAILLE = 4; // Statut détaillé du message (disponible auprès de votre gestionnaire de compte). -export const INDEX_ID_MESSAGE = 5; // Identifiant du message. -export const INDEX_OPERATEUR = 6; // Code MCCMNC correspondant à l'opérateur du destinataire. diff --git a/packages/backend/src/_common/model/message-sms/MessageSms.type.ts b/packages/backend/src/_common/model/message-sms/MessageSms.type.ts index 56fc15875f..9eb54a5b78 100644 --- a/packages/backend/src/_common/model/message-sms/MessageSms.type.ts +++ b/packages/backend/src/_common/model/message-sms/MessageSms.type.ts @@ -1,9 +1,9 @@ -import { MessageSmsId } from "@domifa/common"; import { - MessageSmsInteractionMetas, + MessageSmsId, MessageSmsReminderMetas, MessageSmsStatus, -} from "."; + MessageSmsInteractionMetas, +} from "@domifa/common"; import { AppEntity } from "../../../_common/model"; export type MessageSms = AppEntity & { diff --git a/packages/backend/src/_common/model/message-sms/MessageSmsInteractionMetas.type.ts b/packages/backend/src/_common/model/message-sms/MessageSmsInteractionMetas.type.ts deleted file mode 100644 index 14cee5a09a..0000000000 --- a/packages/backend/src/_common/model/message-sms/MessageSmsInteractionMetas.type.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { InteractionType } from "@domifa/common"; - -export type MessageSmsInteractionMetas = { - nbCourrier: number; - interactionType: InteractionType; - date: Date; -}; diff --git a/packages/backend/src/_common/model/message-sms/MessageSmsReminderMetas.type.ts b/packages/backend/src/_common/model/message-sms/MessageSmsReminderMetas.type.ts deleted file mode 100644 index 8d2bac62b0..0000000000 --- a/packages/backend/src/_common/model/message-sms/MessageSmsReminderMetas.type.ts +++ /dev/null @@ -1,4 +0,0 @@ -export type MessageSmsReminderMetas = { - type: string; - date: Date; -}; diff --git a/packages/backend/src/_common/model/message-sms/MessageSmsStatus.type.ts b/packages/backend/src/_common/model/message-sms/MessageSmsStatus.type.ts deleted file mode 100644 index e8a83dc1b8..0000000000 --- a/packages/backend/src/_common/model/message-sms/MessageSmsStatus.type.ts +++ /dev/null @@ -1,17 +0,0 @@ -export type MessageSmsStatus = - | "TO_SEND" - | "ON_HOLD" - | "SENT_AND_RECEIVED" - | "SENT_AND_NOT_RECEIVED" - | "IN_PROGRESS" - | "FAILURE" - | "DISABLED" - | "EXPIRED"; - -export const ON_HOLD = 0; -export const SENT_AND_RECEIVED = 1; -export const SENT_AND_NOT_RECEIVED = 2; -export const IN_PROGRESS = 3; -export const FAILURE = 4; -export const EXPIRED = 5; -export const DISABLED = 6; diff --git a/packages/backend/src/_common/model/message-sms/index.ts b/packages/backend/src/_common/model/message-sms/index.ts index d00b4dee9b..e17627c2f2 100644 --- a/packages/backend/src/_common/model/message-sms/index.ts +++ b/packages/backend/src/_common/model/message-sms/index.ts @@ -1,10 +1,5 @@ //@index('./*', f => `export * from '${f.path}'`) export * from "./MESSAGE_SMS_RESPONSE_ERRORS.const"; -export * from "./MESSAGE_SMS_STATUS.const"; -export * from "./MESSAGE_SMS_SUIVI_INDEX.const"; export * from "./MessageSms.type"; -export * from "./MessageSmsInteractionMetas.type"; -export * from "./MessageSmsReminderMetas.type"; export * from "./MessageSmsSendResponse.type"; -export * from "./MessageSmsStatus.type"; export * from "./SuiviSmsErrors.type"; diff --git a/packages/backend/src/_migrations/1699910877010-auto-migration.ts b/packages/backend/src/_migrations/1699910877010-auto-migration.ts index 405cf0bec3..43e92009e6 100644 --- a/packages/backend/src/_migrations/1699910877010-auto-migration.ts +++ b/packages/backend/src/_migrations/1699910877010-auto-migration.ts @@ -1,20 +1,27 @@ import { MigrationInterface, QueryRunner } from "typeorm"; +import { domifaConfig } from "../config"; export class AutoMigration1699910877010 implements MigrationInterface { name = "AutoMigration1699910877010"; public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `CREATE TABLE "user_usager_login" ("uuid" 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(), "version" integer NOT NULL, "usagerUUID" uuid NOT NULL, "structureId" integer NOT NULL, CONSTRAINT "PK_cfb7dc4a81d1db054ab5b4d50bf" PRIMARY KEY ("uuid"))` - ); - await queryRunner.query( - `CREATE INDEX "idx_user_usager_login" ON "user_usager_login" ("structureId", "usagerUUID") ` - ); - await queryRunner.query( - `ALTER TABLE "user_usager_login" ADD CONSTRAINT "FK_4bf76763fec5203f945338a0377" FOREIGN KEY ("usagerUUID") REFERENCES "usager"("uuid") ON DELETE CASCADE ON UPDATE NO ACTION` - ); - await queryRunner.query( - `ALTER TABLE "user_usager_login" ADD CONSTRAINT "FK_8722e56ff917692645abcd29e7c" FOREIGN KEY ("structureId") REFERENCES "structure"("id") ON DELETE CASCADE ON UPDATE NO ACTION` - ); + if ( + domifaConfig().envId !== "preprod" && + domifaConfig().envId === "prod" && + domifaConfig().envId === "local" + ) { + await queryRunner.query( + `CREATE TABLE "user_usager_login" ("uuid" 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(), "version" integer NOT NULL, "usagerUUID" uuid NOT NULL, "structureId" integer NOT NULL, CONSTRAINT "PK_cfb7dc4a81d1db054ab5b4d50bf" PRIMARY KEY ("uuid"))` + ); + await queryRunner.query( + `CREATE INDEX "idx_user_usager_login" ON "user_usager_login" ("structureId", "usagerUUID") ` + ); + await queryRunner.query( + `ALTER TABLE "user_usager_login" ADD CONSTRAINT "FK_4bf76763fec5203f945338a0377" FOREIGN KEY ("usagerUUID") REFERENCES "usager"("uuid") ON DELETE CASCADE ON UPDATE NO ACTION` + ); + await queryRunner.query( + `ALTER TABLE "user_usager_login" ADD CONSTRAINT "FK_8722e56ff917692645abcd29e7c" FOREIGN KEY ("structureId") REFERENCES "structure"("id") ON DELETE CASCADE ON UPDATE NO ACTION` + ); + } } public async down(queryRunner: QueryRunner): Promise { diff --git a/packages/backend/src/database/entities/message-sms/MessageSmsTable.typeorm.ts b/packages/backend/src/database/entities/message-sms/MessageSmsTable.typeorm.ts index e6bdddd03a..31ed034197 100644 --- a/packages/backend/src/database/entities/message-sms/MessageSmsTable.typeorm.ts +++ b/packages/backend/src/database/entities/message-sms/MessageSmsTable.typeorm.ts @@ -1,12 +1,13 @@ import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm"; +import { MessageSms } from "../../../_common/model/message-sms"; +import { StructureTable } from "../structure"; +import { AppTypeormTable } from "../_core/AppTypeormTable.typeorm"; import { - MessageSms, + MessageSmsId, + MessageSmsStatus, MessageSmsInteractionMetas, MessageSmsReminderMetas, -} from "../../../_common/model/message-sms"; -import { StructureTable } from "../structure"; -import { AppTypeormTable } from "../_core/AppTypeormTable.typeorm"; -import { MessageSmsId, MessageSmsStatus } from "@domifa/common"; +} from "@domifa/common"; // https://typeorm.io/#/entities/column-types-for-postgres @Entity({ name: "message_sms" }) diff --git a/packages/backend/src/excel/export-structure-usagers/worksheet-renderer/exportListeCourriersWorksheetRenderer.ts b/packages/backend/src/excel/export-structure-usagers/worksheet-renderer/exportListeCourriersWorksheetRenderer.ts index 236c9f1e98..ed152a30a1 100644 --- a/packages/backend/src/excel/export-structure-usagers/worksheet-renderer/exportListeCourriersWorksheetRenderer.ts +++ b/packages/backend/src/excel/export-structure-usagers/worksheet-renderer/exportListeCourriersWorksheetRenderer.ts @@ -87,7 +87,6 @@ function renderWorksheet({ appel: usagersInteractionsCounts.appel, visite: usagersInteractionsCounts.visite, npai: usagersInteractionsCounts.npai, - // TODO: check loginPOrtail loginPortail: usagersInteractionsCounts.loginPortail, }, }; diff --git a/packages/backend/src/interactions/services/interactionsCreator.service.spec.ts b/packages/backend/src/interactions/services/interactionsCreator.service.spec.ts index 686946e9c0..529f1135d4 100644 --- a/packages/backend/src/interactions/services/interactionsCreator.service.spec.ts +++ b/packages/backend/src/interactions/services/interactionsCreator.service.spec.ts @@ -434,53 +434,4 @@ describe("interactionsCreator", () => { }); }); }); - - // describe("5. Création d'une interaction à la suite d'une connexion au portail", () => { - // it("Sans mise à jour de la date de dernier passage", async () => { - // const interaction: InteractionDto = { - // type: "loginPortail", - // nbCourrier: 0, - // }; - - // const resultat = await interactionsCreator.createInteraction({ - // usager, - // user, - // interaction, - // }); - - // expect(resultat.usager.lastInteraction.dateInteraction).toEqual( - // usager.lastInteraction.dateInteraction - // ); - // expect(resultat.interaction.nbCourrier).toEqual(0); - // }); - - // it("Avec mise à jour de la date de dernier passage", async () => { - // const interaction: InteractionDto = { - // type: "loginPortail", - // nbCourrier: 1111, // Test avec un faux numéro, on vérifie que c'est bien 0 qui est enregistré - // }; - - // user.structure.portailUsager.usagerLoginUpdateLastInteraction = true; - - // const resultat = await interactionsCreator.createInteraction({ - // usager, - // user, - // interaction, - // }); - - // expect(resultat.usager.lastInteraction.dateInteraction).toEqual( - // MOCKED_NEW_DATE - // ); - - // expect(resultat.interaction.nbCourrier).toEqual(0); - - // // Suppression de l'interaction sortante - // await interactionsDeletor.deleteInteraction({ - // interaction: resultat.interaction, - // structure: user.structure, - // usager, - // user, - // }); - // }); - // }); }); diff --git a/packages/frontend/src/_common/model/message-sms/MessageSms.type.ts b/packages/frontend/src/_common/model/message-sms/MessageSms.type.ts index 5abc4bbec7..448756991a 100644 --- a/packages/frontend/src/_common/model/message-sms/MessageSms.type.ts +++ b/packages/frontend/src/_common/model/message-sms/MessageSms.type.ts @@ -2,8 +2,9 @@ import { MessageSmsId, MessageSmsInteractionMetas, MessageSmsStatus, + MessageSmsReminderMetas, } from "@domifa/common"; -import { MessageSmsReminderMetas } from "."; + import { AppEntity } from "../../../_common/model"; export type MessageSms = AppEntity & { diff --git a/packages/frontend/src/_common/model/message-sms/MessageSmsReminderMetas.type.ts b/packages/frontend/src/_common/model/message-sms/MessageSmsReminderMetas.type.ts deleted file mode 100644 index 8d2bac62b0..0000000000 --- a/packages/frontend/src/_common/model/message-sms/MessageSmsReminderMetas.type.ts +++ /dev/null @@ -1,4 +0,0 @@ -export type MessageSmsReminderMetas = { - type: string; - date: Date; -}; diff --git a/packages/frontend/src/_common/model/message-sms/index.ts b/packages/frontend/src/_common/model/message-sms/index.ts index 760a6f0b76..4fca211a56 100644 --- a/packages/frontend/src/_common/model/message-sms/index.ts +++ b/packages/frontend/src/_common/model/message-sms/index.ts @@ -1,4 +1,3 @@ // @index('./*', f => `export * from '${f.path}'`) export * from "./MESSAGE_SMS_STATUS.const"; export * from "./MessageSms.type"; -export * from "./MessageSmsReminderMetas.type";