Skip to content

Commit

Permalink
fix(types): correction des derniers soucis d'harmonisation avec le fr…
Browse files Browse the repository at this point in the history
…ontend (#1382)

* fix: modif

* fix: modif

* fix: remaining type

* fix: types
  • Loading branch information
maxgfr authored May 7, 2024
1 parent 772f03a commit a368b99
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 8 deletions.
57 changes: 54 additions & 3 deletions shared/types/src/elastic/contributions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,62 @@ type ContributionElasticDocumentBase = Omit<
export type ContributionElasticDocument = ContributionElasticDocumentBase &
(ContributionGenericInfos | ContributionConventionnelInfos);

export type ElasticSearchContributionGeneric = ContributionElasticDocumentBase &
ContributionGenericInfos;
type ElasticSearchContributionFicheSp = {
type: "fiche-sp";
url: string;
date: string;
raw: string;
};

type ElasticSearchContributionGenericNoCDT = {
type: "generic-no-cdt";
messageBlockGenericNoCDT: string;
};

type ElasticSearchContributionContent = {
type: "content" | "cdt";
content: string;
};

type ContributionLinkedContent = {
slug: string;
source: string;
title: string;
description?: string;
};

type ContributionRef = {
url?: string | null;
title: string;
};

type ElasticSearchContributionBase = {
description: string;
title: string;
slug: string;
breadcrumbs: Breadcrumb[];
source: "contributions";
linkedContent: ContributionLinkedContent[];
references: ContributionRef[];
idcc: string;
messageBlock?: string;
} & (
| ElasticSearchContributionFicheSp
| ElasticSearchContributionContent
| ElasticSearchContributionGenericNoCDT
);

export type ElasticSearchContributionGeneric = ElasticSearchContributionBase & {
ccSupported: string[];
ccUnextended: string[];
};

export type ElasticSearchContributionConventionnelle =
ContributionElasticDocumentBase & ContributionConventionnelInfos;
ElasticSearchContributionBase & {
ccnSlug: string;
ccnShortTitle: string;
highlight?: ContributionHighlight;
};

export type ElasticSearchContribution =
| ElasticSearchContributionGeneric
Expand Down
5 changes: 5 additions & 0 deletions shared/types/src/hasura/editorial-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ export type EditorialContentBaseContentPart = {
export type MarkdownContentPart = {
type: EditorialContentType.markdown;
markdown: string;
html: string;
};

export type ContentItem = {
title: string;
source: string;
cdtnId: string;
slug: string;
description: string;
};

export type ContentContentPart = {
Expand All @@ -46,6 +49,7 @@ export type EditorialContentLink = {
url: string;
type: string;
title: string;
slug: string;
};

export type EditoralContentReferenceBloc = {
Expand All @@ -60,6 +64,7 @@ export type GraphicContentPart = {
altText: string;
fileUrl: string;
markdown: string;
html: string;
};

export enum EditorialSectionDisplayMode {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import type { DocumentReference } from "@socialgouv/cdtn-types";

import type { EditorialContentSubset } from "../editorialContents";
import { extractEditorialContentTemplateRef } from "../editorialContents";
import payload from "./mocks/editorialContent.payload.json";

Expand All @@ -22,9 +20,7 @@ jest.mock("@shared/utils", () => {
});

test("extractMailTemplateRef", async () => {
const references = await extractEditorialContentTemplateRef(
payload as EditorialContentSubset[]
);
const references = await extractEditorialContentTemplateRef(payload as any);

Check warning on line 23 in targets/alert-cli/src/diff/dila/extractReferences/__tests__/editorialContents.test.ts

View workflow job for this annotation

GitHub Actions / Lint (alert-cli)

Unsafe argument of type `any` assigned to a parameter of type `EditorialContentSubset[]`

Check warning on line 23 in targets/alert-cli/src/diff/dila/extractReferences/__tests__/editorialContents.test.ts

View workflow job for this annotation

GitHub Actions / Lint (alert-cli)

Unexpected any. Specify a different type
expect(references).toMatchInlineSnapshot(`
[
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ describe("function getContentBlockIds", () => {
cdtnId: "cdtnId",
title: "title",
source: "source",
description: "",
slug: "",
};
let props: EditorialContentBaseContentPart[];
let result: string[];
Expand Down

0 comments on commit a368b99

Please sign in to comment.