diff --git a/shared/types/src/elastic/code-du-travail.ts b/shared/types/src/elastic/code-du-travail.ts new file mode 100644 index 000000000..6db89f6bc --- /dev/null +++ b/shared/types/src/elastic/code-du-travail.ts @@ -0,0 +1,6 @@ +import { LaborCodeDoc } from "../hasura"; +import { DocumentElasticWithSource } from "./common"; + +export type ElasticLaborCodeArticle = DocumentElasticWithSource< + Omit +>; diff --git a/shared/types/src/elastic/fiche-travail.ts b/shared/types/src/elastic/fiche-travail.ts new file mode 100644 index 000000000..f2d773043 --- /dev/null +++ b/shared/types/src/elastic/fiche-travail.ts @@ -0,0 +1,13 @@ +import { DocumentElasticWithSource } from "./common"; +import { FicheTravailEmploiDoc, Section } from "../hasura"; + +export type ElasticFicheTravailEmploi = DocumentElasticWithSource< + Omit +> & { + sections: ElasticFicheTravailEmploiSection[]; +}; + +export type ElasticFicheTravailEmploiSection = Omit< + Section, + "htmlWithGlossary" | "text" | "description" +>; diff --git a/shared/types/src/elastic/index.ts b/shared/types/src/elastic/index.ts index 0c1224218..41ca7aa0c 100644 --- a/shared/types/src/elastic/index.ts +++ b/shared/types/src/elastic/index.ts @@ -4,3 +4,5 @@ export * from "./common"; export * from "./prequalified"; export * from "./tools"; export * from "./editorial-content"; +export * from "./fiche-travail"; +export * from "./code-du-travail"; diff --git a/targets/export-elasticsearch/src/ingester/cdtnDocuments.ts b/targets/export-elasticsearch/src/ingester/cdtnDocuments.ts index 45571085d..ed608f1fc 100644 --- a/targets/export-elasticsearch/src/ingester/cdtnDocuments.ts +++ b/targets/export-elasticsearch/src/ingester/cdtnDocuments.ts @@ -2,11 +2,12 @@ import { AgreementDoc, ContributionDocumentJson, ContributionHighlight, + DocumentElasticWithSource, + DocumentRef, EditorialContentDoc, + ElasticFicheTravailEmploi, ExportEsStatus, FicheTravailEmploiDoc, - DocumentElasticWithSource, - DocumentRef, } from "@socialgouv/cdtn-types"; import { logger } from "@shared/utils"; import { SOURCES } from "@socialgouv/cdtn-sources"; @@ -182,16 +183,17 @@ export async function cdtnDocumentsGen( getBreadcrumbs ); logger.info(`Fetched ${fichesMT.length} fiches travail`); - const fichesMTWithGlossary = fichesMT.map(({ sections, ...infos }) => ({ - ...infos, - sections: sections.map(({ ...section }: any) => { - const html = section.htmlWithGlossary; - delete section.description; - delete section.text; - delete section.htmlWithGlossary; - return { ...section, html }; - }), - })); + const fichesMTWithGlossary: ElasticFicheTravailEmploi[] = fichesMT.map( + ({ sections, ...infos }): ElasticFicheTravailEmploi => ({ + ...infos, + sections: sections.map((section) => ({ + html: section.htmlWithGlossary, + anchor: section.anchor, + references: section.references, + title: section.title, + })), + }) + ); logger.info( `Mapped ${fichesMTWithGlossary.length} fiches travail with glossary` );