Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REMANIEMENT][DIAGNOSTIC] Modifie le type DiagnosticLance afin d'introduire la notion d'Aidé #689

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { CapteurCommande, Commande } from '../domaine/commande';
import { Entrepots } from '../domaine/Entrepots';
import { BusEvenement, Evenement } from '../domaine/BusEvenement';
import { BusEvenement } from '../domaine/BusEvenement';
import { Diagnostic, initialiseDiagnostic } from './Diagnostic';
import { FournisseurHorloge } from '../infrastructure/horloge/FournisseurHorloge';
import { ErreurMAC } from '../domaine/erreurMAC';
import { Adaptateur } from '../adaptateurs/Adaptateur';
import { Referentiel } from './Referentiel';
import crypto from 'crypto';
import { ReferentielDeMesures } from './ReferentielDeMesures';
import { DiagnosticLance } from './evenements';

export class CapteurCommandeLanceDiagnostic
implements CapteurCommande<CommandeLanceDiagnostic, Diagnostic>
Expand All @@ -31,7 +32,10 @@ export class CapteurCommandeLanceDiagnostic
date: FournisseurHorloge.maintenant(),
corps: {
identifiantDiagnostic: diagnostic.identifiant,
identifiantAidant: commande.identifiantAidant,
origine: {
identifiant: commande.identifiantAidant,
type: 'AIDANT',
},
},
});
return diagnostic;
Expand All @@ -48,8 +52,3 @@ export type CommandeLanceDiagnostic = Omit<Commande, 'type'> & {
adaptateurReferentielDeMesures: Adaptateur<ReferentielDeMesures>;
identifiantAidant: crypto.UUID;
};

export type DiagnosticLance = Evenement<{
identifiantDiagnostic: crypto.UUID;
identifiantAidant: crypto.UUID;
}>;
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { CapteurCommande, Commande } from '../domaine/commande';
import { Entrepots } from '../domaine/Entrepots';
import { BusEvenement, Evenement } from '../domaine/BusEvenement';
import { genereLaRestitution, MesurePriorisee } from './Diagnostic';
import { BusEvenement } from '../domaine/BusEvenement';
import { genereLaRestitution } from './Diagnostic';
import { FournisseurHorloge } from '../infrastructure/horloge/FournisseurHorloge';
import { ErreurMAC } from '../domaine/erreurMAC';
import crypto from 'crypto';
import { RestitutionLancee } from './evenements';

export type CommandeLanceRestitution = Omit<Commande, 'type'> & {
type: 'CommandeLanceRestitution';
Expand Down Expand Up @@ -52,9 +52,3 @@ export class CapteurCommandeLanceRestitution
);
}
}

type RestitutionLancee = Evenement<{
identifiantDiagnostic: crypto.UUID;
indicateurs?: { [thematique: string]: { moyennePonderee: number } };
mesures?: MesurePriorisee[];
}>;
9 changes: 2 additions & 7 deletions mon-aide-cyber-api/src/diagnostic/CapteurSagaAjoutReponse.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import crypto from 'crypto';
import { Entrepots } from '../domaine/Entrepots';
import { BusEvenement, Evenement } from '../domaine/BusEvenement';
import { BusEvenement } from '../domaine/BusEvenement';
import { ajouteLaReponseAuDiagnostic, Diagnostic } from './Diagnostic';
import { FournisseurHorloge } from '../infrastructure/horloge/FournisseurHorloge';
import { ErreurMAC } from '../domaine/erreurMAC';
import { BusCommande, CapteurSaga, Saga } from '../domaine/commande';
import { CommandeLanceRestitution } from './CapteurCommandeLanceRestitution';
import { ReponseAjoutee } from './evenements';

class CapteurSagaAjoutReponse
implements CapteurSaga<SagaAjoutReponse, Diagnostic>
Expand Down Expand Up @@ -67,12 +68,6 @@ export type CorpsReponse = {
identifiant: string;
reponse: string | string[] | CorpsReponseQuestionATiroir;
};
export type ReponseAjoutee = Evenement<{
identifiantDiagnostic: crypto.UUID;
thematique: string;
identifiantQuestion: string;
reponse: string | string[] | CorpsReponseQuestionATiroir;
}>;
export type SagaAjoutReponse = Omit<Saga, 'type'> &
CorpsReponse & {
type: 'SagaAjoutReponse';
Expand Down
20 changes: 20 additions & 0 deletions mon-aide-cyber-api/src/diagnostic/evenements.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Evenement } from '../domaine/BusEvenement';
import crypto from 'crypto';
import { MesurePriorisee } from './Diagnostic';
import { CorpsReponseQuestionATiroir } from './CapteurSagaAjoutReponse';

export type DiagnosticLance = Evenement<{
identifiantDiagnostic: crypto.UUID;
origine: { identifiant: crypto.UUID; type: 'AIDANT' | 'AIDÉ' };
}>;
export type RestitutionLancee = Evenement<{
identifiantDiagnostic: crypto.UUID;
indicateurs?: { [thematique: string]: { moyennePonderee: number } };
mesures?: MesurePriorisee[];
}>;
export type ReponseAjoutee = Evenement<{
identifiantDiagnostic: crypto.UUID;
thematique: string;
identifiantQuestion: string;
reponse: string | string[] | CorpsReponseQuestionATiroir;
}>;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AdaptateurRelations } from '../../relation/AdaptateurRelations';
import { ConsommateurEvenement, Evenement } from '../../domaine/BusEvenement';
import { DiagnosticLance } from '../../diagnostic/CapteurCommandeLanceDiagnostic';
import { DiagnosticLance } from '../../diagnostic/evenements';
import { unTupleAidantInitieDiagnostic } from '../../diagnostic/tuples';

export const aidantInitieDiagnostic = (
Expand All @@ -12,7 +12,7 @@ export const aidantInitieDiagnostic = (
): Promise<void> {
const diagnosticLance = evenement as DiagnosticLance;
const tuple = unTupleAidantInitieDiagnostic(
diagnosticLance.corps.identifiantAidant,
diagnosticLance.corps.origine.identifiant,
diagnosticLance.corps.identifiantDiagnostic
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ import { ErreurMAC } from '../../src/domaine/erreurMAC';
import { AdaptateurReferentielDeTest } from '../adaptateurs/AdaptateurReferentielDeTest';
import { Entrepots } from '../../src/domaine/Entrepots';
import { EntrepotsMemoire } from '../../src/infrastructure/entrepots/memoire/EntrepotsMemoire';
import {
CapteurCommandeLanceDiagnostic,
DiagnosticLance,
} from '../../src/diagnostic/CapteurCommandeLanceDiagnostic';
import { CapteurCommandeLanceDiagnostic } from '../../src/diagnostic/CapteurCommandeLanceDiagnostic';
import { AdaptateurMesuresTest } from '../adaptateurs/AdaptateurMesuresTest';
import crypto from 'crypto';
import { DiagnosticLance } from '../../src/diagnostic/evenements';

describe('Capteur pour lancer un diagnostic', () => {
let adaptateurReferentiel: AdaptateurReferentielDeTest;
Expand Down Expand Up @@ -113,7 +111,7 @@ describe('Capteur pour lancer un diagnostic', () => {
date: maintenant,
corps: {
identifiantDiagnostic: diagnostic.identifiant,
identifiantAidant,
origine: { identifiant: identifiantAidant, type: 'AIDANT' },
},
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import { EntrepotsMemoire } from '../../src/infrastructure/entrepots/memoire/Ent
import {
CapteurSagaAjoutReponse,
CorpsReponseQuestionATiroir,
ReponseAjoutee,
SagaAjoutReponse,
} from '../../src/diagnostic/CapteurSagaAjoutReponse';
import { Constructeur } from '../constructeurs/constructeur';
import { fakerFR } from '@faker-js/faker';
import { BusCommandeTest } from '../infrastructure/bus/BusCommandeTest';
import { ReponseAjoutee } from '../../src/diagnostic/evenements';

describe("Capteur d'ajout de réponse au diagnostic", () => {
let entrepots: Entrepots;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { AdaptateurRelationsMAC } from '../../../src/relation/AdaptateurRelation
import { EntrepotRelationMemoire } from '../../../src/relation/infrastructure/EntrepotRelationMemoire';
import { aidantInitieDiagnostic } from '../../../src/espace-aidant/tableau-de-bord/consommateursEvenements';
import { FournisseurHorloge } from '../../../src/infrastructure/horloge/FournisseurHorloge';
import { DiagnosticLance } from '../../../src/diagnostic/CapteurCommandeLanceDiagnostic';
import crypto from 'crypto';
import { DiagnosticLance } from '../../../src/diagnostic/evenements';

describe("Les consommateurs d'évènements du tableau de bord", () => {
describe("Lorsque l'évènement 'DIAGNOSTIC_LANCE' est consommé", () => {
Expand All @@ -20,7 +20,7 @@ describe("Les consommateurs d'évènements du tableau de bord", () => {
).consomme<DiagnosticLance>({
corps: {
identifiantDiagnostic,
identifiantAidant,
origine: { identifiant: identifiantAidant, type: 'AIDANT' },
},
identifiant: crypto.randomUUID(),
type: 'DIAGNOSTIC_LANCE',
Expand Down
Loading