Skip to content

Commit

Permalink
Bump @ndla/types-backend
Browse files Browse the repository at this point in the history
  • Loading branch information
jnatten committed Dec 10, 2024
1 parent 602052a commit 366c5c7
Show file tree
Hide file tree
Showing 35 changed files with 105 additions and 101 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@fontsource/source-code-pro": "^4.5.9",
"@fontsource/source-sans-pro": "^4.5.9",
"@fontsource/source-serif-pro": "^4.5.7",
"@ndla/types-backend": "^0.2.86",
"@ndla/types-backend": "^1.0.1",
"@pandacss/dev": "^0.48.0",
"@storybook/addon-a11y": "^8.4.7",
"@storybook/addon-docs": "^8.4.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/article-converter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"src"
],
"devDependencies": {
"@ndla/types-backend": "^0.2.86",
"@ndla/types-backend": "^1.0.1",
"@ndla/types-embed": "^5.0.5-alpha.0"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/ndla-audio-search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"devDependencies": {
"@ndla/preset-panda": "workspace:^",
"@ndla/types-backend": "^0.2.86",
"@ndla/types-backend": "^1.0.1",
"@pandacss/dev": "^0.48.0"
},
"peerDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/ndla-audio-search/src/AudioBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
/* eslint jsx-a11y/media-has-caption: 0 */

import { useEffect, useState } from "react";
import type { IAudioMetaInformation } from "@ndla/types-backend/audio-api";
import type { IAudioMetaInformationDTO } from "@ndla/types-backend/audio-api";

interface Props {
audio: { id: number };
fetchAudio: (id: number) => Promise<IAudioMetaInformation>;
fetchAudio: (id: number) => Promise<IAudioMetaInformationDTO>;
onError: (err: any) => void;
}

Expand Down
6 changes: 3 additions & 3 deletions packages/ndla-audio-search/src/AudioSearch.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { useRef } from "react";
import type { Meta, StoryFn } from "@storybook/react";
import type { IAudioMetaInformation, IAudioSummarySearchResult } from "@ndla/types-backend/audio-api";
import type { IAudioMetaInformationDTO, IAudioSummarySearchResultDTO } from "@ndla/types-backend/audio-api";
import AudioSearch, { type QueryObject } from "./AudioSearch";

export default {
Expand Down Expand Up @@ -46,7 +46,7 @@ export default {

export const Default: StoryFn<typeof AudioSearch> = ({ ...args }) => {
const ref = useRef<HTMLDivElement>(null);
const fetchAudios = (queryObject: QueryObject): Promise<IAudioSummarySearchResult> => {
const fetchAudios = (queryObject: QueryObject): Promise<IAudioSummarySearchResultDTO> => {
ref.current?.scrollIntoView({
block: "start",
});
Expand All @@ -63,7 +63,7 @@ export const Default: StoryFn<typeof AudioSearch> = ({ ...args }) => {
});
};

const fetchAudio = (id: number): Promise<IAudioMetaInformation> =>
const fetchAudio = (id: number): Promise<IAudioMetaInformationDTO> =>
new Promise((resolve, reject) => {
fetch(`https://api.test.ndla.no/audio-api/v1/audio/${id}`, {
method: "GET",
Expand Down
14 changes: 9 additions & 5 deletions packages/ndla-audio-search/src/AudioSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ import {
type PaginationRootProps,
} from "@ndla/primitives";
import { styled } from "@ndla/styled-system/jsx";
import type { IAudioMetaInformation, IAudioSummary, IAudioSummarySearchResult } from "@ndla/types-backend/audio-api";
import type {
IAudioMetaInformationDTO,
IAudioSummaryDTO,
IAudioSummarySearchResultDTO,
} from "@ndla/types-backend/audio-api";
import AudioSearchInput from "./AudioSearchInput";
import AudioSearchList from "./AudioSearchList";

Expand Down Expand Up @@ -73,11 +77,11 @@ export interface AudioSearchTranslations {

interface Props {
queryObject: QueryObject;
fetchAudio: (id: number) => Promise<IAudioMetaInformation>;
searchAudios: (queryObject: QueryObject) => Promise<IAudioSummarySearchResult>;
fetchAudio: (id: number) => Promise<IAudioMetaInformationDTO>;
searchAudios: (queryObject: QueryObject) => Promise<IAudioSummarySearchResultDTO>;
onError: (err: any) => void;
translations: AudioSearchTranslations;
onAudioSelect: (audio: IAudioSummary) => void;
onAudioSelect: (audio: IAudioSummaryDTO) => void;
loadingIndicator?: ReactNode;
}

Expand All @@ -101,7 +105,7 @@ const AudioSearch = ({
}: Props) => {
const [queryObject, setQueryObject] = useState<QueryObject>(query);
const [searching, setSearching] = useState(false);
const [searchResult, setSearchResult] = useState<IAudioSummarySearchResult | undefined>();
const [searchResult, setSearchResult] = useState<IAudioSummarySearchResultDTO | undefined>();
const noResultsFound = !searching && searchResult?.results.length === 0;

const { locale } = queryObject ?? {};
Expand Down
8 changes: 4 additions & 4 deletions packages/ndla-audio-search/src/AudioSearchList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import type { ReactNode } from "react";
import { Text } from "@ndla/primitives";
import { styled } from "@ndla/styled-system/jsx";
import type { IAudioMetaInformation, IAudioSummary } from "@ndla/types-backend/audio-api";
import type { IAudioMetaInformationDTO, IAudioSummaryDTO } from "@ndla/types-backend/audio-api";
import AudioSearchResult from "./AudioSearchResult";

const StyledList = styled("ul", {
Expand All @@ -19,16 +19,16 @@ const StyledList = styled("ul", {
});

interface Props {
audios: IAudioSummary[];
audios: IAudioSummaryDTO[];
searching: boolean;
locale: string;
translations: {
noResults: string;
useAudio: string;
};
onError: (err: any) => void;
fetchAudio: (id: number) => Promise<IAudioMetaInformation>;
onAudioSelect: (audio: IAudioSummary) => void;
fetchAudio: (id: number) => Promise<IAudioMetaInformationDTO>;
onAudioSelect: (audio: IAudioSummaryDTO) => void;
loadingIndicator: ReactNode;
}

Expand Down
8 changes: 4 additions & 4 deletions packages/ndla-audio-search/src/AudioSearchResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { getLicenseByAbbreviation, type LicenseLocaleType } from "@ndla/licenses";
import { Text, ListItemContent, ListItemRoot, Button } from "@ndla/primitives";
import { styled } from "@ndla/styled-system/jsx";
import type { IAudioMetaInformation, IAudioSummary } from "@ndla/types-backend/audio-api";
import type { IAudioMetaInformationDTO, IAudioSummaryDTO } from "@ndla/types-backend/audio-api";
import AudioBar from "./AudioBar";

const StyledAudioMeta = styled("div", {
Expand Down Expand Up @@ -42,12 +42,12 @@ const LicenseLink = ({ license }: LicenseLinkProps) => {
};

interface Props {
audio: IAudioSummary;
audio: IAudioSummaryDTO;
translations: { useAudio: string };
fetchAudio: (id: number) => Promise<IAudioMetaInformation>;
fetchAudio: (id: number) => Promise<IAudioMetaInformationDTO>;
onError: (err: any) => void;
locale: string;
onAudioSelect: (audio: IAudioSummary) => void;
onAudioSelect: (audio: IAudioSummaryDTO) => void;
}

export default function AudioSearchResult({ audio, fetchAudio, onError, locale, translations, onAudioSelect }: Props) {
Expand Down
2 changes: 1 addition & 1 deletion packages/ndla-image-search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
"devDependencies": {
"@ndla/preset-panda": "workspace:^",
"@ndla/types-backend": "^0.2.86",
"@ndla/types-backend": "^1.0.1",
"@pandacss/dev": "^0.48.0"
},
"peerDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/ndla-image-search/src/ImageMeta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

import { useMemo } from "react";
import { Text } from "@ndla/primitives";
import type { IImageDimensions } from "@ndla/types-backend/image-api";
import type { IImageDimensionsDTO } from "@ndla/types-backend/image-api";
import { humanFileSize } from "@ndla/util";

interface Props {
contentType: string;
fileSize: number;
imageDimensions?: IImageDimensions;
imageDimensions?: IImageDimensionsDTO;
locale: string;
}

Expand Down
6 changes: 3 additions & 3 deletions packages/ndla-image-search/src/ImageSearch.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import type { Meta, StoryFn } from "@storybook/react";
import type { IImageMetaInformationV3, ISearchResultV3 } from "@ndla/types-backend/image-api";
import type { IImageMetaInformationV3DTO, ISearchResultV3DTO } from "@ndla/types-backend/image-api";
import ImageSearch from "./ImageSearch";

export default {
Expand Down Expand Up @@ -42,7 +42,7 @@ export default {
} as Meta<typeof ImageSearch>;

export const Default: StoryFn<typeof ImageSearch> = ({ ...args }) => {
const fetchImages = (query?: string, page?: number): Promise<ISearchResultV3> => {
const fetchImages = (query?: string, page?: number): Promise<ISearchResultV3DTO> => {
const queryString = query ? `query=${query}&page=${page}&page-size=15` : `page=${page}&page-size=15`;
return new Promise((resolve, reject) => {
fetch(`https://api.test.ndla.no/image-api/v3/images/?${queryString}`, {
Expand All @@ -56,7 +56,7 @@ export const Default: StoryFn<typeof ImageSearch> = ({ ...args }) => {
});
};

const fetchImage = (id: string | number): Promise<IImageMetaInformationV3> =>
const fetchImage = (id: string | number): Promise<IImageMetaInformationV3DTO> =>
new Promise((resolve, reject) => {
fetch(`https://api.test.ndla.no/image-api/v3/images/${id}`, {
method: "GET",
Expand Down
22 changes: 11 additions & 11 deletions packages/ndla-image-search/src/ImageSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
type PaginationRootProps,
} from "@ndla/primitives";
import { styled } from "@ndla/styled-system/jsx";
import type { IImageMetaInformationV3, ISearchResultV3, ISearchParams } from "@ndla/types-backend/image-api";
import type { IImageMetaInformationV3DTO, ISearchResultV3DTO, ISearchParamsDTO } from "@ndla/types-backend/image-api";
import ImageSearchResult from "./ImageSearchResult";

const ImageSearchWrapper = styled("div", {
Expand Down Expand Up @@ -100,13 +100,13 @@ export interface ImageSearchTranslations {
}

interface Props {
onImageSelect: (image: IImageMetaInformationV3) => void;
searchImages: (query: string | undefined, page: number | undefined) => Promise<ISearchResultV3>;
fetchImage: (id: number) => Promise<IImageMetaInformationV3>;
onImageSelect: (image: IImageMetaInformationV3DTO) => void;
searchImages: (query: string | undefined, page: number | undefined) => Promise<ISearchResultV3DTO>;
fetchImage: (id: number) => Promise<IImageMetaInformationV3DTO>;
onError?: (err: any) => void;
locale: string;
noResults?: ReactNode;
checkboxAction?: (image: IImageMetaInformationV3) => void;
checkboxAction?: (image: IImageMetaInformationV3DTO) => void;
showCheckbox?: boolean;
translations: ImageSearchTranslations;
}
Expand All @@ -122,19 +122,19 @@ const ImageSearch = ({
showCheckbox,
translations,
}: Props) => {
const [queryObject, setQueryObject] = useState<ISearchParams>({
const [queryObject, setQueryObject] = useState<ISearchParamsDTO>({
query: undefined,
page: 1,
pageSize: 16,
});
const [selectedImage, setSelectedImage] = useState<IImageMetaInformationV3 | undefined>();
const [selectedImage, setSelectedImage] = useState<IImageMetaInformationV3DTO | undefined>();
const [searching, setSearching] = useState<boolean>(false);
const [searchResult, setSearchResult] = useState<ISearchResultV3 | undefined>();
const [searchResult, setSearchResult] = useState<ISearchResultV3DTO | undefined>();

const { page } = queryObject;
const noResultsFound = !searching && searchResult?.results.length === 0;

const onImageClick = (image: IImageMetaInformationV3) => {
const onImageClick = (image: IImageMetaInformationV3DTO) => {
if (!selectedImage || image.id !== selectedImage.id) {
fetchImage(Number.parseInt(image.id))
.then((result) => {
Expand All @@ -146,7 +146,7 @@ const ImageSearch = ({
}
};

const onSelectImage = (image: IImageMetaInformationV3 | undefined, saveAsMetaImage?: boolean) => {
const onSelectImage = (image: IImageMetaInformationV3DTO | undefined, saveAsMetaImage?: boolean) => {
setSelectedImage(undefined);
if (!image) return;
onImageSelect(image);
Expand All @@ -155,7 +155,7 @@ const ImageSearch = ({
}
};

const searchImages = (queryObject: ISearchParams) => {
const searchImages = (queryObject: ISearchParamsDTO) => {
setSearching(true);
search(queryObject.query, queryObject.page)
.then((result) => {
Expand Down
10 changes: 5 additions & 5 deletions packages/ndla-image-search/src/ImageSearchResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { Text, Image, Button } from "@ndla/primitives";
import { styled } from "@ndla/styled-system/jsx";
import type { IImageMetaInformationV3 } from "@ndla/types-backend/image-api";
import type { IImageMetaInformationV3DTO } from "@ndla/types-backend/image-api";
import type { PreviewTranslations } from "./ImageSearch";
import PreviewImage from "./PreviewImage";
import { getPreviewSrcSets } from "./util/imageUtil";
Expand Down Expand Up @@ -36,10 +36,10 @@ const StyledText = styled(Text, {
});

interface Props {
image: IImageMetaInformationV3;
onImageClick: (image: IImageMetaInformationV3) => void;
selectedImage?: IImageMetaInformationV3;
onSelectImage: (image: IImageMetaInformationV3 | undefined, saveAsMetaImage?: boolean) => void;
image: IImageMetaInformationV3DTO;
onImageClick: (image: IImageMetaInformationV3DTO) => void;
selectedImage?: IImageMetaInformationV3DTO;
onSelectImage: (image: IImageMetaInformationV3DTO | undefined, saveAsMetaImage?: boolean) => void;
showCheckbox: boolean;
translations: PreviewTranslations;
locale: string;
Expand Down
6 changes: 3 additions & 3 deletions packages/ndla-image-search/src/PreviewImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
IconButton,
} from "@ndla/primitives";
import { styled } from "@ndla/styled-system/jsx";
import type { IImageMetaInformationV3 } from "@ndla/types-backend/image-api";
import type { IImageMetaInformationV3DTO } from "@ndla/types-backend/image-api";
import ImageMeta from "./ImageMeta";
import type { PreviewTranslations } from "./ImageSearch";
import { getSrcSets } from "./util/imageUtil";
Expand Down Expand Up @@ -109,8 +109,8 @@ const ActionsWrapper = styled("div", {

interface Props {
id: string;
image: IImageMetaInformationV3;
onSelectImage: (image: IImageMetaInformationV3 | undefined, saveAsMetaImage?: boolean) => void;
image: IImageMetaInformationV3DTO;
onSelectImage: (image: IImageMetaInformationV3DTO | undefined, saveAsMetaImage?: boolean) => void;
showCheckbox: boolean;
translations: PreviewTranslations;
locale: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/ndla-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
},
"devDependencies": {
"@ndla/preset-panda": "workspace:^",
"@ndla/types-backend": "^0.2.86",
"@ndla/types-backend": "^1.0.1",
"@ndla/types-embed": "^5.0.5-alpha.0",
"@pandacss/dev": "^0.48.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/ndla-ui/src/Concept/Concept.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { type ComponentPropsWithRef, type ReactNode, forwardRef } from "react";
import { Figure } from "@ndla/primitives";
import { styled } from "@ndla/styled-system/jsx";
import type { IDraftCopyright as ConceptCopyright } from "@ndla/types-backend/concept-api";
import type { IDraftCopyrightDTO as ConceptCopyright } from "@ndla/types-backend/concept-api";
import type { ConceptVisualElementMeta } from "@ndla/types-embed";
import { BrightcoveEmbed, ExternalEmbed, H5pEmbed, IframeEmbed, ImageEmbed } from "../Embed";
import { EmbedByline } from "../LicenseByline/EmbedByline";
Expand Down
4 changes: 2 additions & 2 deletions packages/ndla-ui/src/ContactBlock/ContactBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useTranslation } from "react-i18next";
import { Text } from "@ndla/primitives";
import { styled } from "@ndla/styled-system/jsx";
import type { SystemStyleObject } from "@ndla/styled-system/types";
import type { IImageMetaInformationV3 } from "@ndla/types-backend/image-api";
import type { IImageMetaInformationV3DTO } from "@ndla/types-backend/image-api";
import { LicenseContainerContent } from "../LicenseByline/EmbedByline";

export type ContactBlockBackground = "strong" | "moderate" | "subtle";
Expand Down Expand Up @@ -143,7 +143,7 @@ const StyledDescription = styled(Text, {
});

interface Props {
image?: IImageMetaInformationV3;
image?: IImageMetaInformationV3DTO;
jobTitle: string;
description: string;
backgroundColor?: ContactBlockBackground;
Expand Down
4 changes: 2 additions & 2 deletions packages/ndla-ui/src/Embed/ImageEmbed.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { ReactNode } from "react";
import type { Meta, StoryFn, StoryObj } from "@storybook/react";
import { PageContent, Text } from "@ndla/primitives";
import { styled } from "@ndla/styled-system/jsx";
import type { IImageMetaInformationV3 } from "@ndla/types-backend/image-api";
import type { IImageMetaInformationV3DTO } from "@ndla/types-backend/image-api";
import type { ImageEmbedData } from "@ndla/types-embed";
import ImageEmbed from "./ImageEmbed";
import { ArticleWrapper, ArticleContent } from "../Article";
Expand All @@ -27,7 +27,7 @@ const embedData: ImageEmbedData = {
url: "https://api.test.ndla.no/image-api/v2/images/61181",
};

const metaData: IImageMetaInformationV3 = {
const metaData: IImageMetaInformationV3DTO = {
id: "61181",
metaUrl: "https://api.test.ndla.no/image-api/v3/images/61181",
title: {
Expand Down
4 changes: 2 additions & 2 deletions packages/ndla-ui/src/Embed/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import type { ElementType } from "react";
import type { IImageMetaInformationV3 } from "@ndla/types-backend/image-api";
import type { IImageMetaInformationV3DTO } from "@ndla/types-backend/image-api";
import type { EmbedMetaData } from "@ndla/types-embed";

export type HeartButtonType = ElementType<{
Expand All @@ -19,7 +19,7 @@ export type EmbedParameter<T extends EmbedMetaData["resource"]> = Partial<
>;

export type CanonicalUrlFuncs = {
image?: (image: IImageMetaInformationV3) => string;
image?: (image: IImageMetaInformationV3DTO) => string;
};

export type RenderContext = "article" | "embed";
Loading

0 comments on commit 366c5c7

Please sign in to comment.