Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(types): utilisation de cdtn-utils au lieu de cdtn-source qui n'est plus d'actualité #1492

Merged
merged 4 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions shared/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion shared/types/src/elastic/agreements.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { SOURCES } from "@socialgouv/cdtn-utils";
import { AgreementDoc } from "../hasura";
import { DocumentElasticWithSource } from "./common";

export type ElasticAgreement = DocumentElasticWithSource<AgreementDoc> & {
articlesByTheme: ArticleByTheme[];
source: "conventions_collectives";
source: typeof SOURCES.CCN;
description: string;
answers: AnswerByTheme[];
contributions: boolean;
Expand Down
4 changes: 3 additions & 1 deletion shared/types/src/elastic/code-du-travail.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { SOURCES } from "@socialgouv/cdtn-utils";
import { LaborCodeDoc } from "../hasura";
import { DocumentElasticWithSource } from "./common";

export type ElasticLaborCodeArticle = DocumentElasticWithSource<
Omit<LaborCodeDoc, "cid">
Omit<LaborCodeDoc, "cid">,
typeof SOURCES.CDT
>;
10 changes: 5 additions & 5 deletions shared/types/src/elastic/common.ts
Original file line number Diff line number Diff line change
@@ -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<U> & T;

export type Breadcrumb = {
Expand All @@ -12,7 +12,7 @@ export type Breadcrumb = {
slug: string;
};

export type DocumentElastic<T extends SourceRoute = SourceRoute> = {
export type DocumentElastic<T extends SourceKeys = SourceKeys> = {
id: string;
cdtnId: string;
breadcrumbs: Breadcrumb[];
Expand All @@ -27,7 +27,7 @@ export type DocumentElastic<T extends SourceRoute = SourceRoute> = {
contribution?: ContributionsAnswers;
};

export type RelatedDocument<T extends SourceRoute = SourceRoute> = {
export type RelatedDocument<T extends SourceKeys = SourceKeys> = {
id: string;
cdtnId: string;
breadcrumbs: Breadcrumb[];
Expand All @@ -40,7 +40,7 @@ export type RelatedDocument<T extends SourceRoute = SourceRoute> = {
url?: string; // Pour les outils externes
};

export type DocumentRef<T extends SourceRoute = SourceRoute> = Omit<
export type DocumentRef<T extends SourceKeys = SourceKeys> = Omit<
RelatedDocument<T>,
"action" | "url" | "id"
>;
3 changes: 2 additions & 1 deletion shared/types/src/elastic/contributions.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -101,7 +102,7 @@ type ElasticSearchContributionBase = {
description: string;
slug: string;
breadcrumbs: Breadcrumb[];
source: "contributions";
source: typeof SOURCES.CONTRIBUTIONS;
linkedContent: ContributionLinkedContent[];
references: ContributionRef[];
idcc: string;
Expand Down
3 changes: 2 additions & 1 deletion shared/types/src/elastic/editorial-content.ts
Original file line number Diff line number Diff line change
@@ -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<EditorialContentDoc>,
"information"
typeof SOURCES.EDITORIAL_CONTENT
>,
"introWithGlossary"
>;
4 changes: 3 additions & 1 deletion shared/types/src/elastic/fiche-travail.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { DocumentElasticWithSource } from "./common";
import { FicheTravailEmploiDoc, Section } from "../hasura";
import { SOURCES } from "@socialgouv/cdtn-utils";

export type ElasticFicheTravailEmploi = DocumentElasticWithSource<
Omit<FicheTravailEmploiDoc, "sections">
Omit<FicheTravailEmploiDoc, "sections">,
typeof SOURCES.SHEET_MT_PAGE
> & {
sections: ElasticFicheTravailEmploiSection[];
};
Expand Down
3 changes: 2 additions & 1 deletion shared/types/src/elastic/highlights.ts
Original file line number Diff line number Diff line change
@@ -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
>;
3 changes: 2 additions & 1 deletion shared/types/src/elastic/modeles-de-courrier.ts
Original file line number Diff line number Diff line change
@@ -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
>;
3 changes: 2 additions & 1 deletion shared/types/src/elastic/prequalified.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { PrequalifiedDoc } from "../hasura";
import { DocumentElasticWithSource, RelatedDocument } from "./common";
import { SOURCES } from "@socialgouv/cdtn-utils";

export type PrequalifiedElasticDocument = Omit<
DocumentElasticWithSource<PrequalifiedDoc, "prequalified">,
DocumentElasticWithSource<PrequalifiedDoc, typeof SOURCES.PREQUALIFIED>,
"slug" | "refs"
> & {
refs: RelatedDocument[];
Expand Down
3 changes: 2 additions & 1 deletion shared/types/src/elastic/theme.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
4 changes: 3 additions & 1 deletion shared/types/src/elastic/tools.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { SOURCES } from "@socialgouv/cdtn-utils";

export type Tool = {
date: string;
icon: string;
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion shared/types/src/hasura/agreement.ts
Original file line number Diff line number Diff line change
@@ -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<AgreementDoc, "conventions_collectives">;
export type Agreement = HasuraDocument<AgreementDoc, typeof SOURCES.CCN>;

export type AgreementDoc = Pick<
IndexedAgreement,
Expand Down
3 changes: 2 additions & 1 deletion shared/types/src/hasura/code-du-travail.ts
Original file line number Diff line number Diff line change
@@ -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<LaborCodeDoc, "code_du_travail">;
export type LaborCodeArticle = HasuraDocument<LaborCodeDoc, typeof SOURCES.CDT>;

export type LaborCodeDoc = Pick<CodeArticleData, "cid" | "dateDebut" | "id"> & {
description: string;
Expand Down
4 changes: 2 additions & 2 deletions shared/types/src/hasura/common.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SourceRoute } from "@socialgouv/cdtn-sources";
import { SourceKeys } from "@socialgouv/cdtn-utils";

export type HasuraDocument<T, U extends SourceRoute = SourceRoute> = {
export type HasuraDocument<T, U extends SourceKeys = SourceKeys> = {
cdtn_id: string;
initial_id: string;
source: U;
Expand Down
3 changes: 2 additions & 1 deletion shared/types/src/hasura/editorial-content.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { SOURCES } from "@socialgouv/cdtn-utils";
import { HasuraDocument } from "./common";

export enum EditorialContentType {
Expand Down Expand Up @@ -87,5 +88,5 @@ export type EditorialContentDoc = {

export type EditorialContent = HasuraDocument<
EditorialContentDoc,
"information"
typeof SOURCES.EDITORIAL_CONTENT
>;
3 changes: 2 additions & 1 deletion shared/types/src/hasura/fiche-sp.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion shared/types/src/hasura/fiche-travail.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion shared/types/src/hasura/highlights.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { SOURCES } from "@socialgouv/cdtn-utils";
import { HasuraDocument } from "./common";

export type Highlight = HasuraDocument<any, "highlights">;
export type Highlight = HasuraDocument<any, typeof SOURCES.HIGHLIGHTS>;
3 changes: 2 additions & 1 deletion shared/types/src/hasura/modeles-de-courrier.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
1 change: 1 addition & 0 deletions targets/export-elasticsearch/src/ingester/cdtnDocuments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ export async function cdtnDocumentsGen(
references: section.references,
title: section.title,
})),
source: SOURCES.SHEET_MT_PAGE,
})
Comment on lines 194 to 196
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Avant il n'y avait pas de types, j'en ai mis un car le typescript me pose soucis.... J'ai l'impression que c'est iso, mais bon chelou. Pourquoi n'avions nous pas de types avant ???

);
logger.info(
Expand Down
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
Loading