Skip to content

Commit

Permalink
refactor(common): merge common types & interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
pYassine committed Oct 30, 2023
1 parent 4cacf4a commit 61487af
Show file tree
Hide file tree
Showing 54 changed files with 86 additions and 163 deletions.
2 changes: 1 addition & 1 deletion packages/backend/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@domifa/backend",
"private": true,
"version": "2.140.5",
"version": "2.141.0",
"description": "",
"author": "",
"license": "MIT",
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion packages/backend/src/_common/model/_core/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
//@index('./*', f => `export * from '${f.path}'`)
export * from "./ApiMessage.type";
export * from "./AppEntity.type";
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ import { Telephone } from "./../telephone/Telephone.type";
import {
UsagerAyantDroit,
UsagerDecision,
UsagerLastInteractions,
UsagerOptions,
UsagerTypeDom,
} from "..";
import { AppEntity } from "../_core";
import { UsagerRdv, UsagerSexe } from "@domifa/common";
import { UsagerRdv, UsagerSexe, UsagerLastInteraction } from "@domifa/common";

export type PortailUsagerPublic = AppEntity & {
customRef: string; // valeur par défaut: 'ref'
Expand Down Expand Up @@ -45,7 +44,7 @@ export type PortailUsagerPublic = AppEntity & {
historique: UsagerDecision[];

// INTERACTIONS
lastInteraction: UsagerLastInteractions;
lastInteraction: UsagerLastInteraction;

options: UsagerOptions;
};
10 changes: 7 additions & 3 deletions packages/backend/src/_common/model/usager/Usager.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ import { AppEntity } from "../_core/AppEntity.type";
import { UsagerAyantDroit } from "./UsagerAyantDroit.type";
import { UsagerDecision } from "./UsagerDecision.type";
import { UsagerImport } from "./UsagerImport.type";
import { UsagerLastInteractions } from "./UsagerLastInteractions.type";
import { UsagerNote } from "./UsagerNote.type";
import { UsagerOptions } from "./options/UsagerOptions.type";

import { UsagerTypeDom } from "./UsagerTypeDom.type";
import { Telephone } from "../telephone/Telephone.type";
import { UsagerEntretien, UsagerRdv, UsagerSexe } from "@domifa/common";
import {
UsagerLastInteraction,
UsagerEntretien,
UsagerRdv,
UsagerSexe,
} from "@domifa/common";

export type Usager = AppEntity & {
ref: number; // unique par structure
Expand Down Expand Up @@ -52,7 +56,7 @@ export type Usager = AppEntity & {
numeroDistribution: string | null;

// INTERACTIONS
lastInteraction: UsagerLastInteractions;
lastInteraction: UsagerLastInteraction;
options: UsagerOptions;

migrated?: boolean;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { UserStructureResume } from "../user-structure/UserStructureResume.type";
import { UserStructureResume } from "@domifa/common";

export type UsagerNote = {
id: number;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { UserStructureResume } from "../../user-structure/UserStructureResume.type";

import { UserStructureResume } from "@domifa/common";
export type UsagerHistoryImport = {
createdAt: Date;
createdBy: UserStructureResume;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { UserStructureResume } from "../../user-structure/UserStructureResume.type";
import { UserStructureResume } from "@domifa/common";
import { Usager } from "../Usager.type";
import { UsagerHistoryStateCreationEvent } from "./UsagerHistoryStateCreationEvent.type";

Expand Down
1 change: 0 additions & 1 deletion packages/backend/src/_common/model/usager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export * from "./UsagerAyantDroit.type";
export * from "./UsagerDecision.type";
export * from "./UsagerDoc.type";
export * from "./UsagerImport.type";
export * from "./UsagerLastInteractions.type";
export * from "./UsagerLight.type";
export * from "./UsagerNote.type";
export * from "./UsagerTypeDom.type";
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { StructureCommon } from "../structure/StructureCommon.type";
import { AppEntity } from "../_core/AppEntity.type";
import { UserStructureMails } from "./UserStructureMails.type";
import { UserStructureRole } from "@domifa/common";
import { UserStructureRole, UserStructureMails } from "@domifa/common";

export type UserStructure = AppEntity & {
id: number;
Expand Down

This file was deleted.

This file was deleted.

4 changes: 1 addition & 3 deletions packages/backend/src/_common/model/user-structure/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// @index('./*', f => `export * from '${f.path}'`)
export * from "./_constants/USER_STRUCTURE_ROLE_ALL.const";
export * from "./_constants";
export * from "./UserStructure.type";
export * from "./UserStructureAuthenticated.type";
export * from "./UserStructureCreatedBy.type";
export * from "./UserStructureMails.type";
export * from "./UserStructureProfile.type";
export * from "./UserStructurePublic.type";
export * from "./UserStructureResume.type";
export * from "./UserStructureSecurity.type";
export * from "./UserStructureSecurityEvent.type";
export * from "./UserStructureSecurityEventType.type";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { UserStructureResume } from "../user-structure/UserStructureResume.type";
import { UserStructureResume } from "@domifa/common";
import { AppEntity } from "../_core/AppEntity.type";

export type UserUsager = AppEntity & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
import { AppTypeormTable } from "../_core/AppTypeormTable.typeorm";
import { StructureTable } from "../structure";
import { UsagerTable } from "./UsagerTable.typeorm";
import { UsagerNote, UserStructureResume } from "../../../_common/model";

import { UsagerNote } from "../../../_common/model";
import { UserStructureResume } from "@domifa/common";
// https://typeorm.io/#/entities/column-types-for-postgres
@Entity({ name: "usager_notes" })
export class UsagerNotesTable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
} from "typeorm";
import {
Usager,
UsagerLastInteractions,
UsagerOptions,
UsagerTypeDom,
Telephone,
Expand All @@ -24,7 +23,12 @@ import { StructureTable } from "../structure/StructureTable.typeorm";
import { AppTypeormTable } from "../_core/AppTypeormTable.typeorm";
import { UsagerImport } from "./../../../_common/model/usager/UsagerImport.type";
import { UsagerNotesTable } from "./UsagerNotesTable.typeorm";
import { UsagerEntretien, UsagerRdv, UsagerSexe } from "@domifa/common";
import {
UsagerEntretien,
UsagerRdv,
UsagerSexe,
UsagerLastInteraction,
} from "@domifa/common";

// https://typeorm.io/#/entities/column-types-for-postgres
@Entity({ name: "usager" })
Expand Down Expand Up @@ -108,7 +112,7 @@ export class UsagerTable
default:
'{"dateInteraction":"NOW()", "enAttente":"false", "courrierIn":"0", "recommandeIn":"0", "colisIn":"0"}',
})
public lastInteraction!: UsagerLastInteractions;
public lastInteraction!: UsagerLastInteraction;

@Column({ type: "integer", default: 0 })
public etapeDemande!: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
} from "typeorm";
import { titleCase } from "typeorm/util/StringUtils";
import { StructureTable } from "..";
import { UserStructure, UserStructureMails } from "../../../_common/model";
import { UserStructure } from "../../../_common/model";
import { AppTypeormTable } from "../_core/AppTypeormTable.typeorm";
import { UserStructureRole } from "@domifa/common";
import { UserStructureRole, UserStructureMails } from "@domifa/common";

// https://typeorm.io/#/entities/column-types-for-postgres
@Entity({ name: "user_structure" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
OneToOne,
} from "typeorm";
import { StructureTable, UsagerTable } from "..";

import { UserStructureResume, UserUsager } from "../../../_common/model";
import { UserStructureResume } from "@domifa/common";
import { UserUsager } from "../../../_common/model";
import { AppTypeormTable } from "../_core/AppTypeormTable.typeorm";

// https://typeorm.io/#/entities/column-types-for-postgres
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import {
Usager,
UsagerNote,
UserStructureAuthenticated,
UserStructureResume,
} from "../../_common/model";
import { UserStructureResume } from "@domifa/common";
import { CreateNoteDto } from "../dto/create-note.dto";
import {
AppLogTable,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { UsagerHistoryTable } from "../../database/entities/usager/UsagerHistoryTable.typeorm";
import { usagerHistoryRepository } from "../../database/services/usager/usagerHistoryRepository.service";

import {
Usager,
UsagerHistory,
UsagerHistoryState,
UserStructureResume,
} from "../../_common/model";
import { UserStructureResume } from "@domifa/common";
import { Usager, UsagerHistory, UsagerHistoryState } from "../../_common/model";
import { UsagerHistoryStateCreationEvent } from "../../_common/model/usager/history/UsagerHistoryStateCreationEvent.type";
import { v4 as uuidv4 } from "uuid";
import { endOfDay, startOfDay, subDays } from "date-fns";
Expand Down
4 changes: 2 additions & 2 deletions packages/common/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @index('./*', f => `export * from '${f.path}'`)
export * from "./_core";
export * from "./usager";
export * from "./structure";
export * from "./user";
export * from "./usager";
export * from "./user-structure";
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface UsagerLastInteractions {
export interface UsagerLastInteraction {
dateInteraction: Date;
enAttente: boolean;
courrierIn: number;
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/usager/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ export * from "./UsagerAyantDroit.interface";
export * from "./UsagerDecision.interface";
export * from "./UsagerDoc.interface";
export * from "./UsagerEntretien.interface";
export * from "./UsagerLastInteractions.interface";
export * from "./UsagerLastInteraction.interface";
export * from "./UsagerRdv.interface";
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// @index('./*', f => `export * from '${f.path}'`)
export * from "./interfaces";
export * from "./types";
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface UserStructureMails {
guide: boolean;
import: boolean;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type UserStructureResume = {
export interface UserStructureResume {
userId: number; // UserStructure.id
userName: string; // UserStructure.nom / prenom
};
}
3 changes: 3 additions & 0 deletions packages/common/src/user-structure/interfaces/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// @index('./*', f => `export * from '${f.path}'`)
export * from "./UserStructureMails.interface";
export * from "./UserStructureResume.interface";
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@domifa/frontend",
"version": "2.140.5",
"version": "2.141.0",
"main": "index.js",
"author": "Incubateur des Ministères Sociaux <[email protected]> (https://incubateur.social.gouv.fr)",
"license": "Apache-2.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/_common/mocks/USER_STRUCTURE.mock.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CountryISO } from "ngx-intl-tel-input";
import { UserStructure, UserStructureRole } from "../model";
import { StructureType } from "@domifa/common";
import { UserStructure } from "../model";
import { StructureType, UserStructureRole } from "@domifa/common";

export const USER_STRUCTURE_MOCK: UserStructure = {
password: "xxx",
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion packages/frontend/src/_common/model/_general/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//@index('./*', f => `export * from '${f.path}'`)
export * from "./ApiMessage.type";
export * from "./DEFAULT_MODAL_OPTIONS.const";
export * from "./FormEmailTakenValidator.type";
5 changes: 3 additions & 2 deletions packages/frontend/src/_common/model/usager/Usager.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { UsagerEntretien } from "./entretien";
import { UsagerDecision } from "./decision/types/UsagerDecision.type";

import { UsagerImport } from "./UsagerImport.type";
import { UsagerLastInteractions } from "./UsagerLastInteractions.type";

import { UsagerNote } from "./UsagerNote.type";
import { UsagerOptions } from "./options/UsagerOptions.type";

Expand All @@ -18,6 +18,7 @@ import {
UsagerRdv,
UsagerSexe,
UsagerTypeDom,
UsagerLastInteraction,
} from "@domifa/common";

export type Usager = AppEntity & {
Expand Down Expand Up @@ -59,7 +60,7 @@ export type Usager = AppEntity & {
historique: UsagerDecision[];

// INTERACTIONS
lastInteraction: UsagerLastInteractions;
lastInteraction: UsagerLastInteraction;

options: UsagerOptions;
numeroDistribution: string | null;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { UserStructureResume } from "../user-structure/UserStructureResume.type";
import { UserStructureResume } from "@domifa/common";

export type UsagerNote = {
id: number;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

5 changes: 0 additions & 5 deletions packages/frontend/src/_common/model/usager/history/index.ts

This file was deleted.

Loading

0 comments on commit 61487af

Please sign in to comment.