Skip to content

Commit

Permalink
refactor(common): migrate interaction types
Browse files Browse the repository at this point in the history
  • Loading branch information
pYassine committed Oct 30, 2023
1 parent 61487af commit 36f2089
Show file tree
Hide file tree
Showing 50 changed files with 76 additions and 78 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
export type InteractionType =
| "courrierIn"
| "courrierOut"
| "recommandeIn"
| "recommandeOut"
| "colisIn"
| "colisOut"
| "appel"
| "visite"
| "npai"
| "loginPortail";
import { InteractionType } from "@domifa/common";

export const ALL_INTERACTION_TYPES: InteractionType[] = [
"courrierIn",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AppEntity, InteractionEvent } from "..";
import { InteractionType } from "./InteractionType.type";
import { InteractionType, InteractionEvent } from "@domifa/common";
import { AppEntity } from "..";

export type Interactions = AppEntity & {
content?: string;
Expand Down
3 changes: 1 addition & 2 deletions packages/backend/src/_common/model/interaction/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// @index('./*', f => `export * from '${f.path}'`)
export * from "./InteractionBaseDirectionalType.type";
export * from "./InteractionDirection.type";
export * from "./InteractionEvent.type";
export * from "./INTERACTIONS_OK.const";
export * from "./Interactions.type";
export * from "./InteractionType.type";
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MessageSmsId } from "@domifa/common";
import {
MessageSmsId,
MessageSmsInteractionMetas,
MessageSmsReminderMetas,
MessageSmsStatus,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InteractionType } from "../interaction";
import { InteractionType } from "@domifa/common";

export type MessageSmsInteractionMetas = {
nbCourrier: number;
Expand Down
2 changes: 0 additions & 2 deletions packages/backend/src/_common/model/message-sms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ 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 "./MessageSmsId.type";
export * from "./MessageSmsInteractionMetas.type";
export * from "./MessageSmsReminderMetas.type";
export * from "./MessageSmsReminders.type";
export * from "./MessageSmsSendResponse.type";
export * from "./MessageSmsStatus.type";
export * from "./SuiviSmsErrors.type";
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { InteractionType } from "./../interaction/InteractionType.type";
import { InteractionType } from "@domifa/common";

export type AdminStructureStatsData = {
usersCount: number;
structuresCount: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@ import { FranceRegion } from "../../../util/territoires";
import {
AdminStructureListData,
AdminStructureStatsData,
InteractionType,
StatsByLocality,
StatsByMonth,
StructureAdmin,
} from "../../../_common/model";
import { StructureType, UsagerDecisionStatut } from "@domifa/common";
import {
StructureType,
InteractionType,
UsagerDecisionStatut,
} from "@domifa/common";

@Injectable()
export class AdminStructuresService {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm";
import {
InteractionEvent,
Interactions,
InteractionType,
} from "../../../_common/model/interaction";
import { Interactions } from "../../../_common/model/interaction";
import { InteractionType, InteractionEvent } from "@domifa/common";

import { StructureTable } from "../structure/StructureTable.typeorm";
import { UsagerTable } from "../usager";
import { AppTypeormTable } from "../_core/AppTypeormTable.typeorm";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm";
import {
MessageSms,
MessageSmsId,
MessageSmsInteractionMetas,
MessageSmsReminderMetas,
MessageSmsStatus,
} from "../../../_common/model/message-sms";
import { StructureTable } from "../structure";
import { AppTypeormTable } from "../_core/AppTypeormTable.typeorm";
import { MessageSmsId, MessageSmsStatus } from "@domifa/common";

// https://typeorm.io/#/entities/column-types-for-postgres
@Entity({ name: "message_sms" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ import {
UserStructureAuthenticated,
} from "../../../_common/model";
import {
InteractionEvent,
Interactions,
InteractionType,
INTERACTION_OK_LIST,
Interactions,
} from "../../../_common/model/interaction";
import { InteractionsTable } from "../../entities";
import { myDataSource } from "../_postgres";
import { InteractionType, InteractionEvent } from "@domifa/common";

export const interactionRepository = myDataSource
.getRepository<Interactions>(InteractionsTable)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { InteractionType } from "@domifa/common";
import { myDataSource } from "..";
import { MessageSms, InteractionType } from "../../../_common/model";
import { MessageSms } from "../../../_common/model";
import { MessageSmsTable } from "./../../entities/message-sms/MessageSmsTable.typeorm";

export const messageSmsRepository = myDataSource
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Column, Workbook } from "exceljs";
import { REGIONS_LISTE } from "../../../util/territoires";

import { InteractionType } from "../../../_common/model/interaction";
import { WorksheetRenderer, xlFormater, xlRenderer } from "../../xlLib";
import { StatsDeploiementExportModel } from "../StatsDeploiementExportModel.type";
import { StructureType } from "@domifa/common";
import { InteractionType, StructureType } from "@domifa/common";

export const exportStatsGlobalesWorksheetRenderer = {
renderWorksheet,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InteractionType } from "./../../_common/model/interaction/InteractionType.type";
import { InteractionType } from "@domifa/common";
import { Usager } from "../../_common/model";

export type StructureUsagersExportModel = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ALL_INTERACTION_TYPES } from "./../../_common/model/interaction/InteractionType.type";
import { IsIn, IsNotEmpty, IsNumber, IsOptional } from "class-validator";
import { ALL_INTERACTION_TYPES } from "../../_common/model";

export class InteractionSearchDto {
@IsIn(ALL_INTERACTION_TYPES)
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/interactions/dto/interactions.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import {
import { TrimOrNullTransform } from "../../_common/decorators";
import {
ALL_INTERACTION_TYPES,
InteractionType,
INTERACTION_IN_CREATE_SMS,
INTERACTION_OUT_REMOVE_SMS,
} from "../../_common/model";
import { InteractionType } from "@domifa/common";

export class InteractionDto {
@ApiProperty({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import {
UserStructure,
Structure,
UsagerLight,
InteractionEvent,
INTERACTION_OK_LIST,
} from "../../_common/model";
import { interactionsCreator } from "./interactionsCreator.service";
import { interactionsTypeManager } from "./interactionsTypeManager.service";
import { InteractionEvent } from "@domifa/common";

@Injectable()
export class InteractionsDeletor {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { InteractionType } from "@domifa/common";
import {
InteractionBaseDirectionalType,
InteractionDirection,
InteractionType,
} from "../../_common/model/interaction";

export const interactionsTypeManager = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InteractionType } from "./../../../_common/model/interaction/InteractionType.type";
import { InteractionType } from "@domifa/common";
import { InteractionDto } from "../../../interactions/dto";

export function generateSmsInteraction(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Between } from "typeorm";
import { interactionRepository } from "../../database";
import { InteractionType } from "../../_common/model";

import { StructureStatsQuestionsInPeriodInteractions } from "../../_common/model/structure-stats";
import { InteractionType } from "@domifa/common";

export const structureStatsQuestionsInPeriodInteractionsRepository = {
getStats,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { interactionRepository } from "./../../database/services/interaction/interactionRepository.service";
import { InteractionType } from "./../../_common/model/interaction/InteractionType.type";

import { Controller, Get, Res, UseGuards } from "@nestjs/common";
import { AuthGuard } from "@nestjs/passport";
import { ApiBearerAuth, ApiTags } from "@nestjs/swagger";
Expand All @@ -21,6 +21,7 @@ import {
import { UsagersService } from "../services/usagers.service";

import { format } from "date-fns";
import { InteractionType } from "@domifa/common";

@UseGuards(AuthGuard("jwt"), AppUserGuard)
@ApiTags("export")
Expand Down
2 changes: 2 additions & 0 deletions packages/common/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// @index('./*', f => `export * from '${f.path}'`)
export * from "./_core";
export * from "./interactions";
export * from "./message-sms";
export * from "./structure";
export * from "./usager";
export * from "./user-structure";
2 changes: 2 additions & 0 deletions packages/common/src/interactions/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// @index('./*', f => `export * from '${f.path}'`)
export * from "./types";
3 changes: 3 additions & 0 deletions packages/common/src/interactions/types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// @index('./*', f => `export * from '${f.path}'`)
export * from "./InteractionEvent.type";
export * from "./InteractionType.type";
3 changes: 3 additions & 0 deletions packages/common/src/message-sms/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +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,7 @@
import { type InteractionType } from "../../interactions";

export interface MessageSmsInteractionMetas {
nbCourrier: number;
interactionType: InteractionType;
date: Date;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface MessageSmsReminderMetas {
type: string;
date: Date;
}
3 changes: 3 additions & 0 deletions packages/common/src/message-sms/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 "./MessageSmsInteractionMetas.interface";
export * from "./MessageSmsReminderMetas.interface";
4 changes: 4 additions & 0 deletions packages/common/src/message-sms/types/MessageSmsId.type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { type InteractionType } from "../../interactions";
import { type MessageSmsReminders } from "./MessageSmsReminders.type";

export type MessageSmsId = InteractionType | MessageSmsReminders;
4 changes: 4 additions & 0 deletions packages/common/src/message-sms/types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// @index('./*', f => `export * from '${f.path}'`)
export * from "./MessageSmsId.type";
export * from "./MessageSmsReminders.type";
export * from "./MessageSmsStatus.type";
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { type UsagerDecisionStatut } from "..";

/* DÉCISIONS */
export const USAGER_DECISION_STATUT_LABELS_PROFIL: {
[key in UsagerDecisionStatut]: string;
} = {
Expand Down

This file was deleted.

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

export type InteractionInForApi = {
nbCourrier: number;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AppEntity } from "..";
import { InteractionEvent } from "./InteractionEvent.type";
import { InteractionType } from "./InteractionType.type";

import { InteractionType, InteractionEvent } from "@domifa/common";

export type Interactions = AppEntity & {
id?: number | null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InteractionType } from "../InteractionType.type";
import { InteractionType } from "@domifa/common";

export const INTERACTIONS_LABELS_SINGULIER: {
[key in InteractionType]: string;
Expand Down
2 changes: 0 additions & 2 deletions packages/frontend/src/_common/model/interaction/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
//@index('./*', f => `export * from '${f.path}'`)
export * from "./constants";
export * from "./InteractionEvent.type";
export * from "./InteractionForApi.type";
export * from "./InteractionForms.type";
export * from "./InteractionIn.type";
export * from "./InteractionOut.type";
export * from "./Interactions.type";
export * from "./InteractionType.type";
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { MessageSmsId } from "./MessageSmsId.type";
import { MessageSmsId } from "@domifa/common";

export const SMS_LABELS: {
[key in MessageSmsId]: string;
} = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {
MessageSmsId,
MessageSmsInteractionMetas,
MessageSmsReminderMetas,
MessageSmsStatus,
} from ".";
} from "@domifa/common";
import { MessageSmsReminderMetas } from ".";
import { AppEntity } from "../../../_common/model";

export type MessageSms = AppEntity & {
Expand Down

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions packages/frontend/src/_common/model/message-sms/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// @index('./*', f => `export * from '${f.path}'`)
export * from "./MESSAGE_SMS_STATUS.const";
export * from "./MessageSms.type";
export * from "./MessageSmsId.type";
export * from "./MessageSmsInteractionMetas.type";
export * from "./MessageSmsReminderMetas.type";
export * from "./MessageSmsReminders.type";
export * from "./MessageSmsStatus.type";
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import {
import { NgbModalRef, NgbModal } from "@ng-bootstrap/ng-bootstrap";
import { Subscription } from "rxjs";
import {
InteractionType,
InteractionInForApi,
INTERACTIONS_LABELS_SINGULIER,
DEFAULT_MODAL_OPTIONS,
} from "../../../../../_common/model";
import { CustomToastService } from "../../../shared/services";
import { UsagerFormModel } from "../../../usager-shared/interfaces";
import { InteractionService } from "../../../usager-shared/services";
import { InteractionType } from "@domifa/common";

@Component({
selector: "app-manage-usagers-interactions",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
import { CustomToastService } from "src/app/modules/shared/services/custom-toast.service";
import {
DEFAULT_MODAL_OPTIONS,
InteractionEvent,
UserStructure,
} from "../../../../../../_common/model";
import {
Expand All @@ -20,6 +19,7 @@ import {
} from "../../../../usager-shared/interfaces";
import { InteractionService } from "../../../../usager-shared/services/interaction.service";
import { Subscription } from "rxjs";
import { InteractionEvent } from "@domifa/common";

@Component({
selector: "app-profil-historique-courriers",
Expand Down
Loading

0 comments on commit 36f2089

Please sign in to comment.