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): correction des derniers soucis d'harmonisation avec le frontend #1382

Merged
merged 4 commits into from
May 7, 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
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,11 +1,9 @@
import type { DocumentReference } from "@socialgouv/cdtn-types";

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

jest.mock("@shared/utils", () => {
return {

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

View workflow job for this annotation

GitHub Actions / Lint (alert-cli)

Unsafe return of an `any` typed value
...jest.requireActual("@shared/utils"),
gqlClient: jest.fn(),
createGetArticleReference: () =>
Expand All @@ -22,9 +20,7 @@
});

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
Loading