Skip to content

Commit

Permalink
rename Pe to Ft
Browse files Browse the repository at this point in the history
  • Loading branch information
JeromeBu committed Jan 20, 2025
1 parent 5291b91 commit fe67842
Show file tree
Hide file tree
Showing 58 changed files with 472 additions and 478 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,11 @@ describe("Add Convention Notifications, then checks the mails are sent (trigerre
await processEventsForEmailToBeSent(eventCrawler);

expect(inMemoryUow.notificationRepository.notifications).toHaveLength(3);
const peNotification = gateways.franceTravailGateway.notifications[0];
expect(peNotification.id).toBe(externalId);
expectToEqual(peNotification.statut, "DEMANDE_A_SIGNER");
expect(peNotification.originalId).toBe(convention.id);
expect(peNotification.email).toBe(convention.signatories.beneficiary.email);
const ftNotification = gateways.franceTravailGateway.notifications[0];
expect(ftNotification.id).toBe(externalId);
expectToEqual(ftNotification.statut, "DEMANDE_A_SIGNER");
expect(ftNotification.originalId).toBe(convention.id);
expect(ftNotification.email).toBe(convention.signatories.beneficiary.email);
const sentEmails = gateways.notification.getSentEmails();
expect(sentEmails).toHaveLength(numberOfEmailInitialySent - 1);
expectArraysToEqualIgnoringOrder(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { Router } from "express";
import { ManagedRedirectError, loginPeConnect, peConnect } from "shared";
import { ManagedRedirectError, ftConnect, loginFtConnect } from "shared";
import { AppDependencies } from "../../../../config/bootstrap/createAppDependencies";
import { sendRedirectResponseWithManagedErrors } from "../../../../config/helpers/sendRedirectResponseWithManagedErrors";
import { makePeConnectLoginPageUrl } from "../../../../domains/core/authentication/ft-connect/adapters/ft-connect-gateway/ftConnectApi.routes";
import { makeFtConnectLoginPageUrl } from "../../../../domains/core/authentication/ft-connect/adapters/ft-connect-gateway/ftConnectApi.routes";

export const createPeConnectRouter = (deps: AppDependencies) => {
const peConnectRouter = Router({ mergeParams: true });
export const createFtConnectRouter = (deps: AppDependencies) => {
const ftConnectRouter = Router({ mergeParams: true });

peConnectRouter.route(`/${loginPeConnect}`).get(async (req, res) =>
ftConnectRouter.route(`/${loginFtConnect}`).get(async (req, res) =>
sendRedirectResponseWithManagedErrors(
req,
res,

async () => makePeConnectLoginPageUrl(deps.config),
async () => makeFtConnectLoginPageUrl(deps.config),
deps.errorHandlers.handleManagedRedirectResponseError,
deps.errorHandlers.handleRawRedirectResponseError,
),
);

peConnectRouter.route(`/${peConnect}`).get(async (req, res) =>
ftConnectRouter.route(`/${ftConnect}`).get(async (req, res) =>
sendRedirectResponseWithManagedErrors(
req,
res,
Expand All @@ -35,5 +35,5 @@ export const createPeConnectRouter = (deps: AppDependencies) => {
),
);

return peConnectRouter;
return ftConnectRouter;
};
16 changes: 8 additions & 8 deletions back/src/config/bootstrap/createGateways.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { InMemoryAddressGateway } from "../../domains/core/address/adapters/InMe
import { HttpSubscribersGateway } from "../../domains/core/api-consumer/adapters/HttpSubscribersGateway";
import { InMemorySubscribersGateway } from "../../domains/core/api-consumer/adapters/InMemorySubscribersGateway";
import { HttpFtConnectGateway } from "../../domains/core/authentication/ft-connect/adapters/ft-connect-gateway/HttpFtConnectGateway";
import { InMemoryPeConnectGateway } from "../../domains/core/authentication/ft-connect/adapters/ft-connect-gateway/InMemoryPeConnectGateway";
import { makePeConnectExternalRoutes } from "../../domains/core/authentication/ft-connect/adapters/ft-connect-gateway/ftConnectApi.routes";
import { InMemoryFtConnectGateway } from "../../domains/core/authentication/ft-connect/adapters/ft-connect-gateway/InMemoryFtConnectGateway";
import { makeFtConnectExternalRoutes } from "../../domains/core/authentication/ft-connect/adapters/ft-connect-gateway/ftConnectApi.routes";
import { FtConnectGateway } from "../../domains/core/authentication/ft-connect/port/FtConnectGateway";
import { HttpOAuthGateway } from "../../domains/core/authentication/inclusion-connect/adapters/oauth-gateway/HttpOAuthGateway";
import { InMemoryOAuthGateway } from "../../domains/core/authentication/inclusion-connect/adapters/oauth-gateway/InMemoryOAuthGateway";
Expand Down Expand Up @@ -188,14 +188,14 @@ export const createGateways = async (

const { withCache, disconnectCache } = await getWithCache(config);

const peConnectGateway: FtConnectGateway =
const ftConnectGateway: FtConnectGateway =
config.ftConnectGateway === "HTTPS"
? new HttpFtConnectGateway(
createLegacyAxiosHttpClientForExternalAPIs({
partnerName: partnerNames.franceTravailConnect,
routes: makePeConnectExternalRoutes({
peApiUrl: config.ftApiUrl,
peAuthCandidatUrl: config.ftAuthCandidatUrl,
routes: makeFtConnectExternalRoutes({
ftApiUrl: config.ftApiUrl,
ftAuthCandidatUrl: config.ftAuthCandidatUrl,
}),
}),
{
Expand All @@ -204,7 +204,7 @@ export const createGateways = async (
franceTravailClientSecret: config.franceTravailClientSecret,
},
)
: new InMemoryPeConnectGateway();
: new InMemoryFtConnectGateway();

const oAuthGateway: OAuthGateway =
config.inclusionConnectGateway === "HTTPS"
Expand Down Expand Up @@ -412,7 +412,7 @@ export const createGateways = async (
? new HttpPassEmploiGateway(config.passEmploiUrl, config.passEmploiKey)
: new InMemoryPassEmploiGateway(),
pdfGeneratorGateway: createPdfGeneratorGateway(),
peConnectGateway,
ftConnectGateway,
franceTravailGateway,
timeGateway,
establishmentMarketingGateway:
Expand Down
2 changes: 1 addition & 1 deletion back/src/config/bootstrap/createUseCases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ export const createUseCases = (
linkFranceTravailAdvisorAndRedirectToConvention:
new LinkFranceTravailAdvisorAndRedirectToConvention(
uowPerformer,
gateways.peConnectGateway,
gateways.ftConnectGateway,
config.immersionFacileBaseUrl,
),

Expand Down
4 changes: 2 additions & 2 deletions back/src/config/bootstrap/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { createConventionRouter } from "../../adapters/primary/routers/conventio
import { createEstablishmentRouter } from "../../adapters/primary/routers/establishment/createEstablishmentRouter";
import { createEstablishmentLeadRouter } from "../../adapters/primary/routers/establishmentLead/createEstablishmentLeadRouter";
import { createFormCompletionRouter } from "../../adapters/primary/routers/formCompletion/createFormCompletionRouter";
import { createFtConnectRouter } from "../../adapters/primary/routers/ftConnect/createFtConnectRouter";
import { createInclusionConnectRouter } from "../../adapters/primary/routers/inclusionConnect/createInclusionConnectRouter";
import { createInclusionConnectedAllowedRouter } from "../../adapters/primary/routers/inclusionConnect/createInclusionConnectedAllowedRouter";
import { createMagicLinkRouter } from "../../adapters/primary/routers/magicLink/createMagicLinkRouter";
import { createPeConnectRouter } from "../../adapters/primary/routers/peConnect/createPeConnectRouter";
import { createRootApiRouter } from "../../adapters/primary/routers/rootApi/createRootApiRouter";
import { createSearchRouter } from "../../adapters/primary/routers/search/createSearchRouter";
import { createTechnicalRouter } from "../../adapters/primary/routers/technical/createTechnicalRouter";
Expand Down Expand Up @@ -90,7 +90,7 @@ export const createApp = async (
app.use(createAddressRouter(deps));
app.use(createConventionRouter(deps));
app.use(createAgenciesRouter(deps));
app.use(createPeConnectRouter(deps));
app.use(createFtConnectRouter(deps));
app.use(createInclusionConnectRouter(deps));
// Auth issues below this last router
app.use(createEstablishmentRouter(deps));
Expand Down
2 changes: 1 addition & 1 deletion back/src/config/helpers/createAxiosSharedClients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createAxiosSharedClient } from "shared-routes/axios";
import { createFranceTravailRoutes } from "../../domains/convention/adapters/france-travail-gateway/FrancetTravailRoutes";
import { AppConfig } from "../bootstrap/appConfig";

export const createPeAxiosSharedClient = (
export const createFtAxiosSharedClient = (
config: AppConfig,
axiosInstance = axios.create({ timeout: config.externalAxiosTimeout }),
) => {
Expand Down
2 changes: 1 addition & 1 deletion back/src/config/helpers/createFetchSharedClients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createFetchSharedClient } from "shared-routes/fetch";
import { createFranceTravailRoutes } from "../../domains/convention/adapters/france-travail-gateway/FrancetTravailRoutes";
import { AppConfig } from "../bootstrap/appConfig";

export const createPeFetchSharedClient = (config: AppConfig) => {
export const createFtFetchSharedClient = (config: AppConfig) => {
const franceTravailRoutes = createFranceTravailRoutes(config.ftApiUrl);
return createFetchSharedClient(franceTravailRoutes, fetch);
};
4 changes: 2 additions & 2 deletions back/src/config/pg/kysely/model/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export interface Database {
outbox_failures: OutboxFailures;
outbox_publications: OutboxPublications;
outbox: Outbox;
partners_pe_connect: PartnersPeConnect;
partners_pe_connect: PartnersFtConnect;
public_appellations_data: PublicAppellationsData;
public_department_region: PublicDepartmentRegion;
public_naf_classes_2008: PublicNafClasses2008;
Expand Down Expand Up @@ -276,7 +276,7 @@ interface Actors {
id: Generated<number>;
}

interface PartnersPeConnect {
interface PartnersFtConnect {
user_pe_external_id: string;
convention_id: Generated<string>;
firstname: string | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import {
AccessTokenResponse,
AppConfig,
} from "../../../../config/bootstrap/appConfig";
import { createPeAxiosSharedClient } from "../../../../config/helpers/createAxiosSharedClients";
import { createFtAxiosSharedClient } from "../../../../config/helpers/createAxiosSharedClients";
import { HttpFranceTravailGateway } from "../../../convention/adapters/france-travail-gateway/HttpFranceTravailGateway";
import { InMemoryCachingGateway } from "../../../core/caching-gateway/adapters/InMemoryCachingGateway";
import { noRetries } from "../../../core/retry-strategy/ports/RetryStrategy";
import { RealTimeGateway } from "../../../core/time-gateway/adapters/RealTimeGateway";
import { HttpPeAgenciesReferential } from "./HttpPeAgenciesReferential";
import { HttpFtAgenciesReferential } from "./HttpFtAgenciesReferential";

const config = AppConfig.createFromEnv();
const axiosHttpClient = createPeAxiosSharedClient(config);
const axiosHttpClient = createFtAxiosSharedClient(config);

const referencielAgencesPE = new HttpPeAgenciesReferential(
const referencielAgencesPE = new HttpFtAgenciesReferential(
config.ftApiUrl,
new HttpFranceTravailGateway(
axiosHttpClient,
Expand All @@ -29,7 +29,7 @@ const referencielAgencesPE = new HttpPeAgenciesReferential(

describe("HttpReferencielAgencesPe", () => {
it("Should return PE agencies", async () => {
const a = await referencielAgencesPE.getPeAgencies();
const a = await referencielAgencesPE.getFtAgencies();
expect(a.length).toBeGreaterThan(10);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ import { createAxiosInstance } from "../../../../utils/axiosUtils";
import { createLogger } from "../../../../utils/logger";
import { FranceTravailGateway } from "../../../convention/ports/FranceTravailGateway";
import {
PeAgenciesReferential,
PeAgencyFromReferenciel,
} from "../../../establishment/ports/PeAgenciesReferential";
FtAgenciesReferential,
FtAgencyFromReferential,
} from "../../../establishment/ports/FtAgenciesReferential";

const logger = createLogger(__filename);

export class HttpPeAgenciesReferential implements PeAgenciesReferential {
export class HttpFtAgenciesReferential implements FtAgenciesReferential {
#axios: AxiosInstance;

readonly #referencielAgenceUrl: AbsoluteUrl;

constructor(
peApiUrl: AbsoluteUrl,
ftApiUrl: AbsoluteUrl,
private readonly franceTravailGateway: FranceTravailGateway,
private readonly franceTravailClientId: string,
) {
this.#axios = createAxiosInstance(logger);
this.#referencielAgenceUrl = `${peApiUrl}/partenaire/referentielagences/v1/agences`;
this.#referencielAgenceUrl = `${ftApiUrl}/partenaire/referentielagences/v1/agences`;
}

public async getPeAgencies(): Promise<PeAgencyFromReferenciel[]> {
public async getFtAgencies(): Promise<FtAgencyFromReferential[]> {
const accessToken = await this.franceTravailGateway.getAccessToken(
`application_${this.franceTravailClientId} api_referentielagencesv1 organisationpe`,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
AccessTokenResponse,
AppConfig,
} from "../../../../config/bootstrap/appConfig";
import { createPeAxiosSharedClient } from "../../../../config/helpers/createAxiosSharedClients";
import { createFtAxiosSharedClient } from "../../../../config/helpers/createAxiosSharedClients";
import { HttpFranceTravailGateway } from "../../../convention/adapters/france-travail-gateway/HttpFranceTravailGateway";
import { InMemoryCachingGateway } from "../../../core/caching-gateway/adapters/InMemoryCachingGateway";
import { noRetries } from "../../../core/retry-strategy/ports/RetryStrategy";
Expand All @@ -21,7 +21,7 @@ describe("HttpRome3Gateway", () => {
);

const franceTravailGateway = new HttpFranceTravailGateway(
createPeAxiosSharedClient(config),
createFtAxiosSharedClient(config),
cachingGateway,
config.ftApiUrl,
config.franceTravailAccessTokenConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ interface Rome3Gateway {
}

type Rome4Routes = ReturnType<typeof makeRome3Routes>;
export const makeRome3Routes = (peApiUrl: AbsoluteUrl) =>
export const makeRome3Routes = (ftApiUrl: AbsoluteUrl) =>
defineRoutes({
getAppellations: defineRoute({
method: "get",
url: `${peApiUrl}/partenaire/rome/v1/appellation?champs=code,libelle,libelleCourt,metier(code)`,
url: `${ftApiUrl}/partenaire/rome/v1/appellation?champs=code,libelle,libelleCourt,metier(code)`,
...withAuthorizationHeaders,
responses: {
200: z.array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
AccessTokenResponse,
AppConfig,
} from "../../../../config/bootstrap/appConfig";
import { createPeAxiosSharedClient } from "../../../../config/helpers/createAxiosSharedClients";
import { createFtAxiosSharedClient } from "../../../../config/helpers/createAxiosSharedClients";
import { HttpFranceTravailGateway } from "../../../convention/adapters/france-travail-gateway/HttpFranceTravailGateway";
import { InMemoryCachingGateway } from "../../../core/caching-gateway/adapters/InMemoryCachingGateway";
import { noRetries } from "../../../core/retry-strategy/ports/RetryStrategy";
Expand All @@ -21,7 +21,7 @@ describe("HttpRome4Gateway", () => {
);

const franceTravailGateway = new HttpFranceTravailGateway(
createPeAxiosSharedClient(config),
createFtAxiosSharedClient(config),
cachingGateway,
config.ftApiUrl,
config.franceTravailAccessTokenConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ interface Rome4Gateway {
}

type Rome4Routes = ReturnType<typeof makeRome4Routes>;
export const makeRome4Routes = (peApiUrl: AbsoluteUrl) =>
export const makeRome4Routes = (ftApiUrl: AbsoluteUrl) =>
defineRoutes({
getRomes: defineRoute({
method: "get",
url: `${peApiUrl}/partenaire/rome-metiers/v1/metiers/metier?champs=code,libelle`,
url: `${ftApiUrl}/partenaire/rome-metiers/v1/metiers/metier?champs=code,libelle`,
...withAuthorizationHeaders,
responses: {
200: z.array(z.object({ code: z.string(), libelle: z.string() })),
},
}),
getAppellations: defineRoute({
method: "get",
url: `${peApiUrl}/partenaire/rome-metiers/v1/metiers/appellation?champs=code,libelle,libelleCourt,metier(code)`,
url: `${ftApiUrl}/partenaire/rome-metiers/v1/metiers/appellation?champs=code,libelle,libelleCourt,metier(code)`,
...withAuthorizationHeaders,
responses: {
200: z.array(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {
FtAgenciesReferential,
FtAgencyFromReferential,
} from "../../../establishment/ports/FtAgenciesReferential";

export class InMemoryFtAgenciesReferential implements FtAgenciesReferential {
#peAgencies: FtAgencyFromReferential[] = [];

public async getFtAgencies(): Promise<FtAgencyFromReferential[]> {
return this.#peAgencies;
}

public setFtAgencies(peAgencies: FtAgencyFromReferential[]) {
this.#peAgencies = peAgencies;
}
}

This file was deleted.

Loading

0 comments on commit fe67842

Please sign in to comment.