diff --git a/shared/types/package.json b/shared/types/package.json index 36d580d36..d7b59f684 100644 --- a/shared/types/package.json +++ b/shared/types/package.json @@ -23,6 +23,7 @@ "type-check": "tsc --noEmit" }, "devDependencies": { + "@socialgouv/cdtn-utils": "^4.156.1", "@socialgouv/kali-data-types": "^2.127.0", "@socialgouv/legi-data-types": "^2.73.1", "typescript": "^5.4.3" diff --git a/shared/types/src/elastic/agreements.ts b/shared/types/src/elastic/agreements.ts index 750135783..1195c1a62 100644 --- a/shared/types/src/elastic/agreements.ts +++ b/shared/types/src/elastic/agreements.ts @@ -1,9 +1,10 @@ +import { SOURCES } from "@socialgouv/cdtn-utils"; import { AgreementDoc } from "../hasura"; import { DocumentElasticWithSource } from "./common"; export type ElasticAgreement = DocumentElasticWithSource & { articlesByTheme: ArticleByTheme[]; - source: "conventions_collectives"; + source: typeof SOURCES.CCN; description: string; answers: AnswerByTheme[]; contributions: boolean; diff --git a/shared/types/src/elastic/code-du-travail.ts b/shared/types/src/elastic/code-du-travail.ts index 6db89f6bc..66130ca54 100644 --- a/shared/types/src/elastic/code-du-travail.ts +++ b/shared/types/src/elastic/code-du-travail.ts @@ -1,6 +1,8 @@ +import { SOURCES } from "@socialgouv/cdtn-utils"; import { LaborCodeDoc } from "../hasura"; import { DocumentElasticWithSource } from "./common"; export type ElasticLaborCodeArticle = DocumentElasticWithSource< - Omit + Omit, + typeof SOURCES.CDT >; diff --git a/shared/types/src/elastic/common.ts b/shared/types/src/elastic/common.ts index 26681489c..a701d8d19 100644 --- a/shared/types/src/elastic/common.ts +++ b/shared/types/src/elastic/common.ts @@ -1,9 +1,9 @@ -import { SourceRoute } from "@socialgouv/cdtn-sources"; +import { SourceKeys } from "@socialgouv/cdtn-utils"; import { ContributionsAnswers } from "../hasura"; export type DocumentElasticWithSource< T, - U extends SourceRoute = SourceRoute + U extends SourceKeys = SourceKeys > = DocumentElastic & T; export type Breadcrumb = { @@ -12,7 +12,7 @@ export type Breadcrumb = { slug: string; }; -export type DocumentElastic = { +export type DocumentElastic = { id: string; cdtnId: string; breadcrumbs: Breadcrumb[]; @@ -27,7 +27,7 @@ export type DocumentElastic = { contribution?: ContributionsAnswers; }; -export type RelatedDocument = { +export type RelatedDocument = { id: string; cdtnId: string; breadcrumbs: Breadcrumb[]; @@ -40,7 +40,7 @@ export type RelatedDocument = { url?: string; // Pour les outils externes }; -export type DocumentRef = Omit< +export type DocumentRef = Omit< RelatedDocument, "action" | "url" | "id" >; diff --git a/shared/types/src/elastic/contributions.ts b/shared/types/src/elastic/contributions.ts index 0e24a0813..aff2a5350 100644 --- a/shared/types/src/elastic/contributions.ts +++ b/shared/types/src/elastic/contributions.ts @@ -1,5 +1,6 @@ import { ContributionDocumentJson, ContributionHighlight } from "../hasura"; import { Breadcrumb, DocumentElasticWithSource } from "./common"; +import { SOURCES } from "@socialgouv/cdtn-utils"; export interface ContributionConventionnelInfos { ccnSlug: string; @@ -101,7 +102,7 @@ type ElasticSearchContributionBase = { description: string; slug: string; breadcrumbs: Breadcrumb[]; - source: "contributions"; + source: typeof SOURCES.CONTRIBUTIONS; linkedContent: ContributionLinkedContent[]; references: ContributionRef[]; idcc: string; diff --git a/shared/types/src/elastic/editorial-content.ts b/shared/types/src/elastic/editorial-content.ts index 3191ce1b4..d63dced9a 100644 --- a/shared/types/src/elastic/editorial-content.ts +++ b/shared/types/src/elastic/editorial-content.ts @@ -1,11 +1,12 @@ import { EditorialContentDoc } from "../hasura"; import { KeysToCamelCase } from "../utility"; import { DocumentElasticWithSource } from "./common"; +import { SOURCES } from "@socialgouv/cdtn-utils"; export type EditorialContentElasticDocument = Omit< DocumentElasticWithSource< KeysToCamelCase, - "information" + typeof SOURCES.EDITORIAL_CONTENT >, "introWithGlossary" >; diff --git a/shared/types/src/elastic/fiche-travail.ts b/shared/types/src/elastic/fiche-travail.ts index f2d773043..63b52b470 100644 --- a/shared/types/src/elastic/fiche-travail.ts +++ b/shared/types/src/elastic/fiche-travail.ts @@ -1,8 +1,10 @@ import { DocumentElasticWithSource } from "./common"; import { FicheTravailEmploiDoc, Section } from "../hasura"; +import { SOURCES } from "@socialgouv/cdtn-utils"; export type ElasticFicheTravailEmploi = DocumentElasticWithSource< - Omit + Omit, + typeof SOURCES.SHEET_MT_PAGE > & { sections: ElasticFicheTravailEmploiSection[]; }; diff --git a/shared/types/src/elastic/highlights.ts b/shared/types/src/elastic/highlights.ts index 80c3344c5..115c39150 100644 --- a/shared/types/src/elastic/highlights.ts +++ b/shared/types/src/elastic/highlights.ts @@ -1,7 +1,8 @@ import { Highlight } from "../hasura"; import { DocumentElasticWithSource } from "./common"; +import { SOURCES } from "@socialgouv/cdtn-utils"; export type HighlightDocument = DocumentElasticWithSource< Highlight, - "highlights" + typeof SOURCES.HIGHLIGHTS >; diff --git a/shared/types/src/elastic/modeles-de-courrier.ts b/shared/types/src/elastic/modeles-de-courrier.ts index 8a56893cf..8c186b875 100644 --- a/shared/types/src/elastic/modeles-de-courrier.ts +++ b/shared/types/src/elastic/modeles-de-courrier.ts @@ -1,7 +1,8 @@ import { DocumentElasticWithSource } from "./common"; import { MailTemplateDoc } from "../hasura"; +import { SOURCES } from "@socialgouv/cdtn-utils"; export type MailElasticDocument = DocumentElasticWithSource< MailTemplateDoc, - "modeles_de_courriers" + typeof SOURCES.LETTERS >; diff --git a/shared/types/src/elastic/prequalified.ts b/shared/types/src/elastic/prequalified.ts index 7aa7fe411..c29469a70 100644 --- a/shared/types/src/elastic/prequalified.ts +++ b/shared/types/src/elastic/prequalified.ts @@ -1,8 +1,9 @@ import { PrequalifiedDoc } from "../hasura"; import { DocumentElasticWithSource, RelatedDocument } from "./common"; +import { SOURCES } from "@socialgouv/cdtn-utils"; export type PrequalifiedElasticDocument = Omit< - DocumentElasticWithSource, + DocumentElasticWithSource, "slug" | "refs" > & { refs: RelatedDocument[]; diff --git a/shared/types/src/elastic/theme.ts b/shared/types/src/elastic/theme.ts index c74807689..089e2b3c5 100644 --- a/shared/types/src/elastic/theme.ts +++ b/shared/types/src/elastic/theme.ts @@ -1,8 +1,9 @@ import { DocumentElasticWithSource } from "./common"; +import { SOURCES } from "@socialgouv/cdtn-utils"; export type ThemeElasticDocument = DocumentElasticWithSource< ThemeElastic, - "themes" + typeof SOURCES.THEMES >; export type ThemeElastic = { diff --git a/shared/types/src/elastic/tools.ts b/shared/types/src/elastic/tools.ts index 7285eb722..cc3ffde9c 100644 --- a/shared/types/src/elastic/tools.ts +++ b/shared/types/src/elastic/tools.ts @@ -1,3 +1,5 @@ +import { SOURCES } from "@socialgouv/cdtn-utils"; + export type Tool = { date: string; icon: string; @@ -14,7 +16,7 @@ export type Tool = { isPublished: boolean; metaDescription: string; slug: string; - source: "outils"; + source: typeof SOURCES.TOOLS; text: string; title: string; _id: string; diff --git a/shared/types/src/hasura/agreement.ts b/shared/types/src/hasura/agreement.ts index 9fcde9543..804adcf07 100644 --- a/shared/types/src/hasura/agreement.ts +++ b/shared/types/src/hasura/agreement.ts @@ -1,8 +1,9 @@ import { IndexedAgreement } from "@socialgouv/kali-data-types"; import { HasuraDocument } from "./common"; import { ContributionHighlight } from "./contributions"; +import { SOURCES } from "@socialgouv/cdtn-utils"; -export type Agreement = HasuraDocument; +export type Agreement = HasuraDocument; export type AgreementDoc = Pick< IndexedAgreement, diff --git a/shared/types/src/hasura/code-du-travail.ts b/shared/types/src/hasura/code-du-travail.ts index 7105c6252..b23113d5d 100644 --- a/shared/types/src/hasura/code-du-travail.ts +++ b/shared/types/src/hasura/code-du-travail.ts @@ -1,7 +1,8 @@ import { CodeArticleData } from "@socialgouv/legi-data-types"; import { HasuraDocument } from "./common"; +import { SOURCES } from "@socialgouv/cdtn-utils"; -export type LaborCodeArticle = HasuraDocument; +export type LaborCodeArticle = HasuraDocument; export type LaborCodeDoc = Pick & { description: string; diff --git a/shared/types/src/hasura/common.ts b/shared/types/src/hasura/common.ts index fe3b1f08b..a786de792 100644 --- a/shared/types/src/hasura/common.ts +++ b/shared/types/src/hasura/common.ts @@ -1,6 +1,6 @@ -import { SourceRoute } from "@socialgouv/cdtn-sources"; +import { SourceKeys } from "@socialgouv/cdtn-utils"; -export type HasuraDocument = { +export type HasuraDocument = { cdtn_id: string; initial_id: string; source: U; diff --git a/shared/types/src/hasura/editorial-content.ts b/shared/types/src/hasura/editorial-content.ts index 7f8f7d032..3b60b57a4 100644 --- a/shared/types/src/hasura/editorial-content.ts +++ b/shared/types/src/hasura/editorial-content.ts @@ -1,3 +1,4 @@ +import { SOURCES } from "@socialgouv/cdtn-utils"; import { HasuraDocument } from "./common"; export enum EditorialContentType { @@ -87,5 +88,5 @@ export type EditorialContentDoc = { export type EditorialContent = HasuraDocument< EditorialContentDoc, - "information" + typeof SOURCES.EDITORIAL_CONTENT >; diff --git a/shared/types/src/hasura/fiche-sp.ts b/shared/types/src/hasura/fiche-sp.ts index fcb01561f..d1d9ef8e8 100644 --- a/shared/types/src/hasura/fiche-sp.ts +++ b/shared/types/src/hasura/fiche-sp.ts @@ -1,8 +1,9 @@ +import { SOURCES } from "@socialgouv/cdtn-utils"; import { HasuraDocument } from "./common"; export type FicheServicePublic = HasuraDocument< FicheServicePublicDoc, - "fiches_service_public" + typeof SOURCES.SHEET_SP >; export interface FicheServicePublicDoc { diff --git a/shared/types/src/hasura/fiche-travail.ts b/shared/types/src/hasura/fiche-travail.ts index 3a18adfd7..345268e6c 100644 --- a/shared/types/src/hasura/fiche-travail.ts +++ b/shared/types/src/hasura/fiche-travail.ts @@ -1,8 +1,9 @@ +import { SOURCES } from "@socialgouv/cdtn-utils"; import { HasuraDocument } from "./common"; export type FicheTravailEmploi = HasuraDocument< FicheTravailEmploiDoc, - "fiches_ministere_travail" + typeof SOURCES.SHEET_MT_PAGE | typeof SOURCES.SHEET_MT >; export interface FicheTravailEmploiDoc { diff --git a/shared/types/src/hasura/highlights.ts b/shared/types/src/hasura/highlights.ts index f952d29cc..8d632a1d9 100644 --- a/shared/types/src/hasura/highlights.ts +++ b/shared/types/src/hasura/highlights.ts @@ -1,3 +1,4 @@ +import { SOURCES } from "@socialgouv/cdtn-utils"; import { HasuraDocument } from "./common"; -export type Highlight = HasuraDocument; +export type Highlight = HasuraDocument; diff --git a/shared/types/src/hasura/modeles-de-courrier.ts b/shared/types/src/hasura/modeles-de-courrier.ts index ae6f78fde..4c3eca30e 100644 --- a/shared/types/src/hasura/modeles-de-courrier.ts +++ b/shared/types/src/hasura/modeles-de-courrier.ts @@ -1,8 +1,9 @@ +import { SOURCES } from "@socialgouv/cdtn-utils"; import { HasuraDocument } from "./common"; export type MailTemplate = HasuraDocument< MailTemplateDoc, - "modeles_de_courriers" + typeof SOURCES.LETTERS >; export type MailTemplateDoc = { diff --git a/targets/export-elasticsearch/src/ingester/cdtnDocuments.ts b/targets/export-elasticsearch/src/ingester/cdtnDocuments.ts index ed608f1fc..eae9787da 100644 --- a/targets/export-elasticsearch/src/ingester/cdtnDocuments.ts +++ b/targets/export-elasticsearch/src/ingester/cdtnDocuments.ts @@ -192,6 +192,7 @@ export async function cdtnDocumentsGen( references: section.references, title: section.title, })), + source: SOURCES.SHEET_MT_PAGE, }) ); logger.info( diff --git a/yarn.lock b/yarn.lock index 99e5488c7..2bd68022c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5681,6 +5681,7 @@ __metadata: version: 0.0.0-use.local resolution: "@socialgouv/cdtn-types@workspace:shared/types" dependencies: + "@socialgouv/cdtn-utils": ^4.156.1 "@socialgouv/kali-data-types": ^2.127.0 "@socialgouv/legi-data-types": ^2.73.1 typescript: ^5.4.3 @@ -5716,6 +5717,13 @@ __metadata: languageName: node linkType: hard +"@socialgouv/cdtn-utils@npm:^4.156.1": + version: 4.156.1 + resolution: "@socialgouv/cdtn-utils@npm:4.156.1" + checksum: 3429e6f801e7bc748a7fc666972fee2855627fab13a32fe902f6f39cb9aff332248cf83a8cd061b6e303f75a9e5bdffcfe8c91681fbd8da7770e759a41a405f9 + languageName: node + linkType: hard + "@socialgouv/contributions-data-types@npm:3.27.0": version: 3.27.0 resolution: "@socialgouv/contributions-data-types@npm:3.27.0"