Skip to content

Commit

Permalink
feat(formation): ajout extraction flux onisep (#302)
Browse files Browse the repository at this point in the history
Co-authored-by: gmoizan <guillaume.moizan@octo.com>
  • Loading branch information
Naorid and gmoocto authored Jul 25, 2023
1 parent 1069362 commit ae7529e
Show file tree
Hide file tree
Showing 37 changed files with 1,047 additions and 44 deletions.
8 changes: 8 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ EVENTS_TOUS_MOBILISES_CLIENT_ID=
EVENTS_TOUS_MOBILISES_CLIENT_SECRET=
EVENTS_TOUS_MOBILISES_SCOPE=

FORMATIONS_INITIALES_ONISEP_NAME=
FORMATIONS_INITIALES_ONISEP_DIRECTORY_NAME=
FORMATIONS_INITIALES_ONISEP_FLUX_URL=
FORMATIONS_INITIALES_ONISEP_RAW_FILE_EXTENSION=
FORMATIONS_INITIALES_EXTRACT_LOG_LEVEL=

FORMATIONS_INITIALES_MINIO_RAW_BUCKET_NAME=

HOUSING_EXTRACT_LOG_LEVEL=
HOUSING_LOAD_LOG_LEVEL=
HOUSING_TRANSFORM_LOG_LEVEL=
Expand Down
8 changes: 8 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ EVENTS_TOUS_MOBILISES_CLIENT_ID=tousMobilises
EVENTS_TOUS_MOBILISES_CLIENT_SECRET=s0m3P4$$word
EVENTS_TOUS_MOBILISES_SCOPE=someScope

FORMATIONS_INITIALES_ONISEP_NAME=onisep
FORMATIONS_INITIALES_ONISEP_DIRECTORY_NAME=onisep
FORMATIONS_INITIALES_ONISEP_FLUX_URL=https://some.url.com/onisep
FORMATIONS_INITIALES_ONISEP_RAW_FILE_EXTENSION=.xml
FORMATIONS_INITIALES_EXTRACT_LOG_LEVEL=debug

FORMATIONS_INITIALES_MINIO_RAW_BUCKET_NAME=formations-initiales-raw

HOUSING_EXTRACT_LOG_LEVEL=debug
HOUSING_LOAD_LOG_LEVEL=debug
HOUSING_TRANSFORM_LOG_LEVEL=debug
Expand Down
132 changes: 103 additions & 29 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,92 @@
"@typescript-eslint/explicit-function-return-type": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-unused-vars": ["error"],
"@typescript-eslint/no-unused-vars": [
"error"
],
"@typescript-eslint/unbound-method": "off",
"comma-dangle": ["error", "always-multiline"],
"complexity": ["error", 10],
"comma-dangle": [
"error",
"always-multiline"
],
"complexity": [
"error",
10
],
"eol-last": "error",
"max-depth": ["error", 2],
"no-multiple-empty-lines": ["error", { "max": 1 }],
"max-depth": [
"error",
2
],
"no-multiple-empty-lines": [
"error",
{
"max": 1
}
],
"no-multi-spaces": "error",
"object-curly-spacing": ["error", "always"],
"quotes": ["error", "double"],
"object-curly-spacing": [
"error",
"always"
],
"quotes": [
"error",
"double"
],
"semi": "error",
"space-infix-ops": "error",
"simple-import-sort/imports": [
"error",
{
"groups": [
["^\\u0000"],
["^node:"],
["^(@(?!(api|cli|configuration|evenements|logements|shared|stages)))"],
["^[a-zA-Z0-9]?"],
["^@test"],
["^@api"],
["^@cli"],
["^@evenements"],
["^@gestion-des-contacts"],
["^@logements"],
["^@maintenance"],
["^@shared"],
["^@stages"],
["^@?"],
["^\\."]
[
"^\\u0000"
],
[
"^node:"
],
[
"^(@(?!(api|cli|configuration|evenements|formations-initiales|logements|shared|stages)))"
],
[
"^[a-zA-Z0-9]?"
],
[
"^@test"
],
[
"^@api"
],
[
"^@cli"
],
[
"^@evenements"
],
[
"^@formations-initiales"
],
[
"^@gestion-des-contacts"
],
[
"^@logements"
],
[
"^@maintenance"
],
[
"^@shared"
],
[
"^@stages"
],
[
"^@?"
],
[
"^\\."
]
]
}
],
Expand All @@ -65,7 +120,8 @@
"@evenements",
"@logements",
"@maintenance",
"@stages"
"@stages",
"@formations-initiales"
]
},
{
Expand All @@ -74,7 +130,8 @@
"@gestion-des-contacts",
"@logements",
"@maintenance",
"@stages"
"@stages",
"@formations-initiales"
]
},
{
Expand All @@ -83,7 +140,8 @@
"@evenements",
"@gestion-des-contacts",
"@maintenance",
"@stages"
"@stages",
"@formations-initiales"
]
},
{
Expand All @@ -92,7 +150,8 @@
"@evenements",
"@gestion-des-contacts",
"@logements",
"@stages"
"@stages",
"@formations-initiales"
]
},
{
Expand All @@ -102,7 +161,8 @@
"@gestion-des-contacts",
"@logements",
"@maintenance",
"@stages"
"@stages",
"@formations-initiales"
]
},
{
Expand All @@ -111,15 +171,29 @@
"@evenements",
"@gestion-des-contacts",
"@logements",
"@maintenance"
"@maintenance",
"@formations-initiales"
]
},
{
"domain": "@formations-initiales",
"domainsToExclude": [
"@evenements",
"@gestion-des-contacts",
"@logements",
"@maintenance",
"@stages"
]
}
]
]
},
"overrides": [
{
"files": ["**/src/**/application-service/index.ts", "**/*.test.ts"],
"files": [
"**/src/**/application-service/index.ts",
"**/*.test.ts"
],
"rules": {
"@sefr/no-onion-architecture-violation": "off"
}
Expand Down
4 changes: 3 additions & 1 deletion apps/cli/src/cli.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { TransformCommand } from "@cli/src/command/transform.command";

import { Evenements } from "@evenements/src";

import { FormationsInitiales } from "@formations-initiales/src";

import { GestionDesContacts } from "@gestion-des-contacts/src";

import { Logements } from "@logements/src";
Expand All @@ -17,7 +19,7 @@ import { Maintenance } from "@maintenance/src";
import { Stages } from "@stages/src";

@Module({
imports: [Evenements, GestionDesContacts, Logements, Maintenance, Stages],
imports: [Evenements, GestionDesContacts, Logements, Maintenance, Stages, FormationsInitiales],
providers: [
ExtractCommand,
TransformCommand,
Expand Down
5 changes: 5 additions & 0 deletions apps/cli/src/command/extract.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import {
ExtractFlowTousMobilisesSubCommand,
} from "@evenements/src/extraction/infrastructure/sub-command/extract-flow-tous-mobilises.sub-command";

import {
ExtractFlowOnisepSubCommand,
} from "@formations-initiales/src/extraction/infrastructure/sub-command/extract-flow-onisep.sub-command";

import {
ExtractFlowImmojeuneSubCommand,
} from "@logements/src/extraction/infrastructure/sub-command/extract-flow-immojeune.sub-command";
Expand All @@ -24,6 +28,7 @@ import {
@Command({
name: "extract",
subCommands: [
ExtractFlowOnisepSubCommand,
ExtractFlowTousMobilisesSubCommand,
ExtractFlowImmojeuneSubCommand,
ExtractFlowStudapartSubCommand,
Expand Down
1 change: 1 addition & 0 deletions apps/cli/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"@cli/*": ["apps/cli/*"],
"@configuration/*": ["apps/configuration/*"],
"@evenements/*": ["apps/evenements/*"],
"@formations-initiales/*": ["apps/formations-initiales/*"],
"@gestion-des-contacts/*": ["apps/gestion-des-contacts/*"],
"@logements/*": ["apps/logements/*"],
"@maintenance/*": ["apps/maintenance/*"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class MinioHttpFlowRepository implements FluxRepository {
public async recuperer(flow: FluxExtraction): Promise<string> {
const logger = this.loggerStrategy.get(flow.nom);
return this.flowClient.pull(this.configuration.TOUS_MOBILISES.FLUX_URL, logger);
}
}

public async enregistrer(
cheminFichierIncluantNom: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe("MinioHttpFlowRepositoryTest", () => {

flow = new FluxExtraction(
"tousmobilises",
".json",
".xml",
"history",
"http://some.url",
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { FluxExtraction } from "@formations-initiales/src/extraction/domain/model/flux";
import {
ExtraireFluxDomainService,
} from "@formations-initiales/src/extraction/domain/service/extraire-flux.domain-service";

import { Usecase } from "@shared/src/application-service/usecase";

export class ExtraireFluxFormationsInitialesOnisep implements Usecase {
constructor(private readonly extraireFlux: ExtraireFluxDomainService) {
}

public executer(flux: FluxExtraction): Promise<void> {
return this.extraireFlux.extraire(flux);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Module } from "@nestjs/common";

import {
ExtraireFluxFormationsInitialesOnisep,
} from "@formations-initiales/src/extraction/application-service/extraire-flux-formations-initiales-onisep.usecase";
import {
ExtraireFluxDomainService,
} from "@formations-initiales/src/extraction/domain/service/extraire-flux.domain-service";
import { FluxRepository } from "@formations-initiales/src/extraction/domain/service/flux.repository";
import { Gateways } from "@formations-initiales/src/extraction/infrastructure/gateway";

import { Shared } from "@shared/src";
import { DateService } from "@shared/src/domain/service/date.service";

@Module({
imports: [Gateways, Shared],
providers: [{
provide: ExtraireFluxDomainService,
inject: ["FluxRepository", DateService],
useFactory: (fluxRepository: FluxRepository, dateService: DateService): ExtraireFluxDomainService => {
return new ExtraireFluxDomainService(fluxRepository, dateService);
},
}, {
provide: ExtraireFluxFormationsInitialesOnisep,
inject: [ExtraireFluxDomainService],
useFactory: (extraireFluxDomainService: ExtraireFluxDomainService): ExtraireFluxFormationsInitialesOnisep => {
return new ExtraireFluxFormationsInitialesOnisep(extraireFluxDomainService);
},
}],
exports: [ExtraireFluxFormationsInitialesOnisep],
})
export class Usecases {
}
14 changes: 14 additions & 0 deletions apps/formations-initiales/src/extraction/domain/model/flux.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Flux } from "@shared/src/domain/model/flux";

export class FluxExtraction extends Flux {
constructor(
nomDuFlux: string,
extension: string,
public readonly dossierHistorisation: string,
public readonly url: string
) {
super(nomDuFlux, extension);
this.dossierHistorisation = dossierHistorisation;
this.url = url;
}
}
Loading

0 comments on commit ae7529e

Please sign in to comment.