Skip to content

Commit

Permalink
♻️ Switch de la partie Event Sourcing sur le nouveau schéma + changem…
Browse files Browse the repository at this point in the history
…ent du séparateur de catégorie (#1217)

* ♻️ Refacto requete SQL

* 🗃️ Execution de la migration sur un env non prod pour creer la table event_store.event_stream

* ✅ Fix tests

* ✅ Mise a jour subscribe

* ♻️ Remplacer # par | pour separer la category de l'identifiant

* 🗃️ Ajout script creation app_views.projection

* ♻️ Creation table app_views.projection

* 🗃️ Mise a jour script pour preparation de la release

* 🗃️ Mise a jour script pour preparation de la release

* ✨ Ajout vue pour la partie analytic

* ✅ Fix test load aggregate
  • Loading branch information
spontoreau authored Jul 27, 2023
1 parent b0bae9d commit 4951a03
Show file tree
Hide file tree
Showing 44 changed files with 282 additions and 249 deletions.
18 changes: 17 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"prepare": "husky install",
"lint": "eslint ./src --ext .ts,.tsx",
"format": "prettier '**/*.{ts,tsx,css}' --write",
"migrate": "sequelize-cli db:migrate",
"migrate": "npm run build:migrations && sequelize-cli db:migrate",
"migrate:undo": "npm run build:migrations && sequelize-cli db:migrate:undo",
"seed": "npm run build:migrations && sequelize-cli db:seed:all",
"start:dev": "docker compose --profile app up -d && until docker exec potentiel_db pg_isready -U potadmindb -d potentiel; do sleep 1; done && npm run migrate && npm run seed && npm run build:packages && concurrently \"ts-node-dev --transpile-only -r tsconfig-paths/register src/index.ts\" \"webpack --config=webpack.config.js --watch\" \"npm run build:css -- --watch\" \"watch 'npm run build:packages' ./packages/**/src/\"",
Expand Down Expand Up @@ -178,4 +178,4 @@
"engines": {
"node": "^18.0.0"
}
}
}
8 changes: 4 additions & 4 deletions packages/domain-views/src/common.port.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ReadModel } from '@potentiel/core-domain';
import { Option } from '@potentiel/monads';

export type Find = <TReadModel extends ReadModel>(
id: `${TReadModel['type']}#${string}`,
id: `${TReadModel['type']}|${string}`,
) => Promise<Option<TReadModel>>;

export type ListOptions<TReadModel extends ReadModel> = {
Expand All @@ -23,15 +23,15 @@ export type Search = <TReadModel extends ReadModel>(
) => Promise<ReadonlyArray<SearchResult<TReadModel>>>;

export type Create = <TReadModel extends ReadModel>(
id: `${TReadModel['type']}#${string}`,
id: `${TReadModel['type']}|${string}`,
readModel: Omit<TReadModel, 'type'>,
) => Promise<void>;

export type Update = <TReadModel extends ReadModel>(
id: `${TReadModel['type']}#${string}`,
id: `${TReadModel['type']}|${string}`,
readModel: Omit<TReadModel, 'type'>,
) => Promise<void>;

export type Remove = <TReadModel extends ReadModel>(
id: `${TReadModel['type']}#${string}`,
id: `${TReadModel['type']}|${string}`,
) => Promise<void>;
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const registerConsulterGestionnaireRéseauQuery = ({
)
? convertirEnIdentifiantGestionnaireRéseau(identifiantGestionnaireRéseau).formatter()
: identifiantGestionnaireRéseau;
const key: GestionnaireRéseauReadModelKey = `gestionnaire-réseau#${rawIdentifiantGestionnaireRéseau}`;
const key: GestionnaireRéseauReadModelKey = `gestionnaire-réseau|${rawIdentifiantGestionnaireRéseau}`;
const result = await find<GestionnaireRéseauReadModel>(key);

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ export const registerGestionnaireRéseauProjector = ({
const handler: MessageHandler<ExecuteGestionnaireRéseauProjector> = async (event) => {
switch (event.type) {
case 'GestionnaireRéseauAjouté':
await create<GestionnaireRéseauReadModel>(`gestionnaire-réseau#${event.payload.codeEIC}`, {
await create<GestionnaireRéseauReadModel>(`gestionnaire-réseau|${event.payload.codeEIC}`, {
...event.payload,
});
break;
case 'GestionnaireRéseauModifié':
await update<GestionnaireRéseauReadModel>(`gestionnaire-réseau#${event.payload.codeEIC}`, {
await update<GestionnaireRéseauReadModel>(`gestionnaire-réseau|${event.payload.codeEIC}`, {
...event.payload,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ReadModel } from '@potentiel/core-domain';
import { RawIdentifiantGestionnaireRéseau } from '@potentiel/domain';

export type GestionnaireRéseauReadModelKey =
`gestionnaire-réseau#${RawIdentifiantGestionnaireRéseau}`;
`gestionnaire-réseau|${RawIdentifiantGestionnaireRéseau}`;

export type GestionnaireRéseauReadModel = ReadModel<
'gestionnaire-réseau',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const registerConsulterProjetQuery = ({
? convertirEnIdentifiantProjet(identifiantProjet).formatter()
: identifiantProjet;

const key: ProjetReadModelKey = `projet#${rawIdentifiantProjet}`;
const key: ProjetReadModelKey = `projet|${rawIdentifiantProjet}`;
const result = await find<ProjetReadModel>(key);

return {
Expand Down
2 changes: 1 addition & 1 deletion packages/domain-views/src/projet/project.projector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type ProjetProjectorDependencies = {

export const registerProjetProjector = ({ create, update, find }: ProjetProjectorDependencies) => {
const handler: MessageHandler<ExecuteProjetProjector> = async (event) => {
const key: ProjetReadModelKey = `projet#${
const key: ProjetReadModelKey = `projet|${
event.payload.identifiantProjet as `${string}#${string}#${string}#${string}`
}`;
switch (event.type) {
Expand Down
2 changes: 1 addition & 1 deletion packages/domain-views/src/projet/projet.readModel.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ReadModel } from '@potentiel/core-domain';
import { RawIdentifiantProjet } from '@potentiel/domain';

export type ProjetReadModelKey = `projet#${RawIdentifiantProjet}`;
export type ProjetReadModelKey = `projet|${RawIdentifiantProjet}`;

export type ProjetReadModel = ReadModel<
'projet',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const registerConsulterAccuséRéceptionDemandeComplèteRaccordementQuery
? convertirEnRéférenceDossierRaccordement(référenceDossierRaccordement).formatter()
: référenceDossierRaccordement;

const key: DossierRaccordementReadModelKey = `dossier-raccordement#${rawIdentifiantProjet}#${rawRéférenceDossierRaccordement}`;
const key: DossierRaccordementReadModelKey = `dossier-raccordement|${rawIdentifiantProjet}#${rawRéférenceDossierRaccordement}`;

const dossierRaccordement = await find<LegacyDossierRaccordementReadModel>(key);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const registerConsulterDossierRaccordementQuery = ({
)
? convertirEnRéférenceDossierRaccordement(référenceDossierRaccordement).formatter()
: référenceDossierRaccordement;
const key: DossierRaccordementReadModelKey = `dossier-raccordement#${rawIdentifiantProjet}#${rawRéférenceDossierRaccordement}`;
const key: DossierRaccordementReadModelKey = `dossier-raccordement|${rawIdentifiantProjet}#${rawRéférenceDossierRaccordement}`;
const result = await find<LegacyDossierRaccordementReadModel>(key);

if (isNone(result)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const registerConsulterPropositionTechniqueEtFinancièreSignéeQuery = ({
? convertirEnRéférenceDossierRaccordement(référenceDossierRaccordement).formatter()
: référenceDossierRaccordement;

const key: DossierRaccordementReadModelKey = `dossier-raccordement#${rawIdentifiantProjet}#${rawRéférenceDossierRaccordement}`;
const key: DossierRaccordementReadModelKey = `dossier-raccordement|${rawIdentifiantProjet}#${rawRéférenceDossierRaccordement}`;

const dossierRaccordement = await find<LegacyDossierRaccordementReadModel>(key);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const registerListerDossiersRaccordementQuery = ({
identifiantProjet,
}) => {
const result = await find<ListeDossiersRaccordementReadModel>(
`liste-dossiers-raccordement#${
`liste-dossiers-raccordement|${
estUnIdentifiantProjet(identifiantProjet)
? convertirEnIdentifiantProjet(identifiantProjet).formatter()
: identifiantProjet
Expand Down
Loading

0 comments on commit 4951a03

Please sign in to comment.