diff --git a/.changeset/great-tools-rescue.md b/.changeset/great-tools-rescue.md new file mode 100644 index 0000000000..43503c5b58 --- /dev/null +++ b/.changeset/great-tools-rescue.md @@ -0,0 +1,5 @@ +--- +"nextjs-website": major +--- + +Update front-end to work with Strapi 5 diff --git a/.changeset/mighty-kings-obey.md b/.changeset/mighty-kings-obey.md new file mode 100644 index 0000000000..be15a3e43c --- /dev/null +++ b/.changeset/mighty-kings-obey.md @@ -0,0 +1,5 @@ +--- +"nextjs-website": major +--- + +Update populates and makes in order to fetch from strapi 5 (with v4 header) diff --git a/apps/nextjs-website/src/__tests__/helpers/webinars.helpers.test.ts b/apps/nextjs-website/src/__tests__/helpers/webinars.helpers.test.ts index baab295767..55725cf8d9 100644 --- a/apps/nextjs-website/src/__tests__/helpers/webinars.helpers.test.ts +++ b/apps/nextjs-website/src/__tests__/helpers/webinars.helpers.test.ts @@ -22,7 +22,7 @@ const testWebinar: Webinar = { }, { type: 'image', - image: mediaRasterJson.data.attributes, + image: mediaRasterJson, children: [ { type: 'text', diff --git a/apps/nextjs-website/src/app/sitemap.ts b/apps/nextjs-website/src/app/sitemap.ts index dab8dcb02a..0e82e522c1 100644 --- a/apps/nextjs-website/src/app/sitemap.ts +++ b/apps/nextjs-website/src/app/sitemap.ts @@ -239,13 +239,13 @@ export default async function sitemap(): Promise { // Then iterate and fetch details for each product. // This avoids massive payload transfers and allows for granular optimization. const productRoutesPromises = productItems.map(async (productItem) => { - const { slug: productSlug } = productItem.attributes; + const { slug: productSlug } = productItem; // A. Fetch Single Pages linked to this Product (Overview, QuickStart, Lists) // ------------------------------------------------------------------------ const singlePagesData = await fetchProductSinglePages(productSlug); - const relations = singlePagesData.data[0] - ?.attributes as unknown as SitemapProductRelations; + const relations = singlePagesData + .data[0] as unknown as SitemapProductRelations; const overviewRoute = relations?.overview?.data ? [ @@ -306,10 +306,10 @@ export default async function sitemap(): Promise { // Tutorials (Individual Pages) const tutorialsData = await fetchProductTutorials(productSlug); const tutorialRoutes = tutorialsData.data - .filter((tutorial) => tutorial.attributes.slug) + .filter((tutorial) => tutorial.slug) .map((tutorial) => ({ - url: `${baseUrl}/${productSlug}/tutorials/${tutorial.attributes.slug}`, - lastModified: new Date(tutorial.attributes.updatedAt || Date.now()), + url: `${baseUrl}/${productSlug}/tutorials/${tutorial.slug}`, + lastModified: new Date(tutorial.updatedAt || Date.now()), changeFrequency: 'weekly' as const, priority: 0.6, })); @@ -317,7 +317,7 @@ export default async function sitemap(): Promise { // API Data (Individual Pages) const apisData = await fetchProductApiData(productSlug); const apiRoutes = ( - apisData.data as unknown as readonly SitemapApiData[] + apisData as unknown as readonly SitemapApiData[] ).flatMap((api) => { const apiSlug = api.attributes.apiRestDetail?.slug || diff --git a/apps/nextjs-website/src/components/molecules/DesktopFilterSelector/DesktopFilterSelector.tsx b/apps/nextjs-website/src/components/molecules/DesktopFilterSelector/DesktopFilterSelector.tsx index 3e6b730b77..009c93a3d9 100644 --- a/apps/nextjs-website/src/components/molecules/DesktopFilterSelector/DesktopFilterSelector.tsx +++ b/apps/nextjs-website/src/components/molecules/DesktopFilterSelector/DesktopFilterSelector.tsx @@ -8,11 +8,7 @@ type DesktopFilterSelectorProps = { setSelectedFilter: (selectedFilter: number) => void; selectorFilters: readonly { name: string; - icon: { - data: { - attributes: Media; - }; - }; + icon: Media; }[]; }; @@ -47,7 +43,7 @@ const DesktopFilterSelector = ({ }} isSelected={index === selectedFilter} label={category.name} - icon={category.icon.data.attributes} + icon={category.icon} > ))} diff --git a/apps/nextjs-website/src/components/molecules/MobileFilterSelector/MobileFilterSelector.tsx b/apps/nextjs-website/src/components/molecules/MobileFilterSelector/MobileFilterSelector.tsx index 134a858ed0..d88d9d15c1 100644 --- a/apps/nextjs-website/src/components/molecules/MobileFilterSelector/MobileFilterSelector.tsx +++ b/apps/nextjs-website/src/components/molecules/MobileFilterSelector/MobileFilterSelector.tsx @@ -21,11 +21,7 @@ type MobileFilterSelectorProps = { setSelectedFilter: (selectedFilter: number) => void; selectorFilters: readonly { name: string; - icon: { - data: { - attributes: Media; - }; - }; + icon: Media; }[]; }; @@ -96,7 +92,7 @@ const MobileFilterSelector = ({ }} isHeader={true} label={selectorFilters[selectedFilter].name} - icon={selectorFilters[selectedFilter].icon.data.attributes} + icon={selectorFilters[selectedFilter].icon} /> )} @@ -115,7 +111,7 @@ const MobileFilterSelector = ({ return; }} label={category.name} - icon={category.icon.data.attributes} + icon={category.icon} isLast={index == selectorFilters.length - 1} /> ))} diff --git a/apps/nextjs-website/src/components/organisms/FilteredGridLayout/FilteredGridLayout.tsx b/apps/nextjs-website/src/components/organisms/FilteredGridLayout/FilteredGridLayout.tsx index 8d39c16174..abf14a4710 100644 --- a/apps/nextjs-website/src/components/organisms/FilteredGridLayout/FilteredGridLayout.tsx +++ b/apps/nextjs-website/src/components/organisms/FilteredGridLayout/FilteredGridLayout.tsx @@ -36,19 +36,15 @@ export const FilteredGridLayout = ({ { name: t('overview.all'), icon: { - data: { - attributes: { - name: 'all.svg', - alternativeText: '', - caption: '', - width: 32, - height: 32, - size: 32, - ext: '.svg', - mime: 'image/svg', - url: '/icons/all.svg', - }, - }, + name: 'all.svg', + alternativeText: '', + caption: '', + width: 32, + height: 32, + size: 32, + ext: '.svg', + mime: 'image/svg', + url: '/icons/all.svg', }, }, ...tags, diff --git a/apps/nextjs-website/src/components/templates/ApiDataListTemplate/ApiDataListTemplate.tsx b/apps/nextjs-website/src/components/templates/ApiDataListTemplate/ApiDataListTemplate.tsx index 2390ea63a3..9ae1c18f1c 100644 --- a/apps/nextjs-website/src/components/templates/ApiDataListTemplate/ApiDataListTemplate.tsx +++ b/apps/nextjs-website/src/components/templates/ApiDataListTemplate/ApiDataListTemplate.tsx @@ -8,9 +8,9 @@ import BannerLinks from '@/components/molecules/BannerLinks/BannerLinks'; import { useTranslations } from 'next-intl'; import { SEO } from '@/lib/types/seo'; import { Product } from '@/lib/types/product'; -import { StrapiBaseApiDataList } from '@/lib/strapi/types/apiDataList'; import { Tag } from '@/lib/types/tag'; import { CardProps } from '@/components/molecules/CardsGrid/CardsGrid'; +import { StrapiApiDataList } from '@/lib/strapi/types/apiDataList'; export type ApiDataListPageTemplateProps = { readonly hero: { @@ -29,7 +29,7 @@ export type ApiDataListPageTemplateProps = { readonly updatedAt: string; readonly bannerLinks: BannerLinkProps[]; readonly theme?: Theme; - readonly apiData: StrapiBaseApiDataList; + readonly api_data: StrapiApiDataList; readonly seo?: SEO; }; diff --git a/apps/nextjs-website/src/helpers/generateStructuredDataScripts.helpers.tsx b/apps/nextjs-website/src/helpers/generateStructuredDataScripts.helpers.tsx index 7f85f0e463..30d7c57169 100644 --- a/apps/nextjs-website/src/helpers/generateStructuredDataScripts.helpers.tsx +++ b/apps/nextjs-website/src/helpers/generateStructuredDataScripts.helpers.tsx @@ -20,7 +20,7 @@ export function generateStructuredDataScripts(props: { name: seo?.metaTitle, description: seo?.metaDescription, url: seo?.canonicalURL, - media: seo?.metaImage?.data?.attributes, + media: seo?.metaImage, }; const allThings: Thing[] = [ makeBreadcrumbList(allBreadcrumbsItems) as Thing, diff --git a/apps/nextjs-website/src/helpers/metadata.helpers.ts b/apps/nextjs-website/src/helpers/metadata.helpers.ts index 9fbc664d25..c52c2c86ca 100644 --- a/apps/nextjs-website/src/helpers/metadata.helpers.ts +++ b/apps/nextjs-website/src/helpers/metadata.helpers.ts @@ -72,7 +72,7 @@ export const makeMetadataFromStrapi = (seo: SEO): Metadata => { title: seo.metaTitle, description: seo.metaDescription, url: seo.canonicalURL, - image: seo.metaImage?.data?.attributes?.url, + image: seo.metaImage?.url, }); const metadata: Metadata = { diff --git a/apps/nextjs-website/src/helpers/structuredData.helpers.ts b/apps/nextjs-website/src/helpers/structuredData.helpers.ts index 0c2d56d306..90799b4b31 100644 --- a/apps/nextjs-website/src/helpers/structuredData.helpers.ts +++ b/apps/nextjs-website/src/helpers/structuredData.helpers.ts @@ -167,8 +167,7 @@ export function quickStartToStructuredDataHowTo( name: quickStart.seo?.metaTitle, description: quickStart.abstract?.description, image: - quickStart.seo?.metaImage?.data?.attributes && - mediaToImageObject(quickStart.seo.metaImage.data.attributes), + quickStart.seo?.metaImage && mediaToImageObject(quickStart.seo.metaImage), step: steps, }); } @@ -256,9 +255,7 @@ export function convertSeoToStructuredDataArticle( url: seo?.canonicalURL, author: organization, about: seo?.keywords, - image: - seo?.metaImage?.data?.attributes && - mediaToImageObject(seo.metaImage.data.attributes), + image: seo?.metaImage && mediaToImageObject(seo.metaImage), }), } ); diff --git a/apps/nextjs-website/src/lib/api.ts b/apps/nextjs-website/src/lib/api.ts index 07a3a2dd01..16c1301cd3 100644 --- a/apps/nextjs-website/src/lib/api.ts +++ b/apps/nextjs-website/src/lib/api.ts @@ -212,7 +212,7 @@ export async function getReleaseNote( } const releaseNotesMetadata = await getReleaseNotesMetadata( - releaseNote.attributes.dirName + releaseNote.dirName ); const releaseNoteProps = await getReleaseNoteProps( diff --git a/apps/nextjs-website/src/lib/cmsApi.ts b/apps/nextjs-website/src/lib/cmsApi.ts index bda5de2a89..8515c729d8 100644 --- a/apps/nextjs-website/src/lib/cmsApi.ts +++ b/apps/nextjs-website/src/lib/cmsApi.ts @@ -101,11 +101,11 @@ export const getTagsProps = async () => { export const getTutorialsProps = async () => { const strapiTutorials = await fetchTutorials(buildEnv); const tutorialsWithMarkdown = strapiTutorials.data.filter((tutorial) => { - const parts = tutorial?.attributes?.parts ?? []; + const parts = tutorial?.parts ?? []; return parts.some((part) => part?.__component === 'parts.markdown'); }); const allMarkdownParts = tutorialsWithMarkdown.flatMap((tutorial) => - (tutorial?.attributes?.parts ?? []).filter( + (tutorial?.parts ?? []).filter( (part) => part?.__component === 'parts.markdown' ) ); @@ -132,8 +132,7 @@ export const getQuickStartGuidesProps = async () => { export const getUrlReplaceMapProps = async () => { const strapiUrlReplaceMap = await fetchUrlReplaceMap(buildEnv); - const processed = makeUrlReplaceMap(strapiUrlReplaceMap); - return processed; + return makeUrlReplaceMap(strapiUrlReplaceMap); }; export const getApiDataListPagesProps = async () => { @@ -195,7 +194,7 @@ export const getGuidePageProps = async ( const strapiGuides = (await fetchResponseFromCDN( getSyncedGuidesResponseJsonPath() )) as StrapiGuides | undefined; - // eslint-disable-next-line functional/no-expression-statements + const guides = strapiGuides ? makeGuidesProps(strapiGuides) : []; const guide = guides.filter( (g) => g.guide.slug === guideSlug && g.product.slug === productSlug @@ -243,8 +242,7 @@ const fetchReleaseNotes = async () => { export const getStrapiReleaseNotes = async (productSlug: string) => { const strapiReleaseNotes = await fetchReleaseNotes(); return strapiReleaseNotes.data.find( - (strapiReleaseNote) => - strapiReleaseNote.attributes.product.data?.attributes.slug === productSlug + (strapiReleaseNote) => strapiReleaseNote.product?.slug === productSlug ); }; @@ -274,7 +272,7 @@ export const getReleaseNotesProps = async () => { export const getUseCasesProps = async () => { const strapiUseCases = await fetchUseCases(buildEnv); const allMarkdownParts = strapiUseCases.data.flatMap((useCase) => - (useCase?.attributes?.parts ?? []).filter(isMarkDownPart) + (useCase?.parts ?? []).filter(isMarkDownPart) ); const contentPromises = allMarkdownParts.map(async (part) => { const { dirName, pathToFile } = part; diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/factories/apiDataList.ts b/apps/nextjs-website/src/lib/strapi/__tests__/factories/apiDataList.ts index 9a280748a0..d184524df7 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/factories/apiDataList.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/factories/apiDataList.ts @@ -3,279 +3,216 @@ import { strapiApiDataList } from '@/lib/strapi/__tests__/fixtures/apiDataList'; import { StrapiApiDataList } from '@/lib/strapi/types/apiDataList'; export function minimalApiDataList() { - const apiData = strapiApiDataList.data[0]; - return { - ...strapiApiDataList, - data: [ - { - ...apiData, - attributes: { - ...apiData.attributes, - title: 'Minimal API Data', - description: undefined, - seo: undefined, - bannerLinks: [], - product: { - data: { - ...apiData.attributes.product.data, - attributes: { - ...(apiData.attributes.product.data?.attributes as any), - bannerLinks: undefined, - }, - }, - }, - apiRestDetail: { - slug: 'minimal-api', - specUrls: [ - { - id: 1, - url: 'https://example.com/api.yaml', - name: undefined, - hideTryIt: false, - }, - ], + const apiData = strapiApiDataList[0]; + return [ + { + ...apiData, + title: 'Minimal API Data', + description: undefined, + seo: undefined, + bannerLinks: [], + product: { + name: 'Minimal', + shortName: 'Min', + slug: 'minimal', + isVisible: true, + overview: apiData.product?.overview, + quickstart_guide: apiData.product?.quickstart_guide, + api_data_list_page: apiData.product?.api_data_list_page, + tutorial_list_page: apiData.product?.tutorial_list_page, + guide_list_page: apiData.product?.guide_list_page, + release_note: apiData.product?.release_note, + use_case_list_page: apiData.product?.use_case_list_page, + tags: apiData.product?.tags, + bannerLinks: undefined, + }, + apiRestDetail: { + slug: 'minimal-api', + specUrls: [ + { + id: 1, + url: 'https://example.com/api.yaml', + name: undefined, + hideTryIt: false, }, - apiSoapDetail: undefined, - }, + ], }, - ], - } satisfies StrapiApiDataList; + apiSoapDetail: undefined, + }, + ] as StrapiApiDataList; } export function apiDataWithoutBannerLinks() { - const apiData = strapiApiDataList.data[0]; - return { - ...strapiApiDataList, - data: [ - { - ...apiData, - attributes: { - ...apiData.attributes, - bannerLinks: [], - }, - }, - ], - } satisfies StrapiApiDataList; + const apiData = strapiApiDataList[0]; + return [ + { + ...apiData, + bannerLinks: [], + }, + ] as StrapiApiDataList; } export function apiDataWithMissingProduct() { - const apiData = strapiApiDataList.data[0]; - return { - ...strapiApiDataList, - data: [ - { - ...apiData, - attributes: { - ...apiData.attributes, - title: 'API Data Without Product', - product: { - data: undefined as any, - }, - }, - }, - ], - } satisfies StrapiApiDataList; + const apiData = strapiApiDataList[0]; + return [ + { + ...apiData, + title: 'API Data Without Product', + product: undefined, + }, + ] as StrapiApiDataList; } export function apiDataWithoutApiDetails() { - const apiData = strapiApiDataList.data[0]; - return { - ...strapiApiDataList, - data: [ - { - ...apiData, - attributes: { - ...apiData.attributes, - title: 'API Data Without API Details', - apiRestDetail: undefined, - apiSoapDetail: undefined, - }, - }, - ], - } satisfies StrapiApiDataList; + const apiData = strapiApiDataList[0]; + return [ + { + ...apiData, + title: 'API Data Without API Details', + apiRestDetail: undefined, + apiSoapDetail: undefined, + }, + ] as StrapiApiDataList; } export function apiDataWithInvalidRestApiDetails() { - const apiData = strapiApiDataList.data[0]; - return { - ...strapiApiDataList, - data: [ - { - ...apiData, - attributes: { - ...apiData.attributes, - title: 'API Data Without API Details', - apiRestDetail: { - slug: '', - specUrls: [], - }, - apiSoapDetail: undefined, - }, + const apiData = strapiApiDataList[0]; + return [ + { + ...apiData, + title: 'API Data Without API Details', + apiRestDetail: { + slug: '', + specUrls: [], }, - ], - } satisfies StrapiApiDataList; + apiSoapDetail: undefined, + }, + ] as StrapiApiDataList; } export function apiDatalistWithItemMissingSlug() { - const apiData = strapiApiDataList.data[0]; - return { - ...strapiApiDataList, - data: [ - { - ...apiData, - attributes: { - ...apiData.attributes, - title: 'API Data Without API Details', - apiRestDetail: undefined, - apiSoapDetail: { - slug: undefined as any, - repositoryUrl: 'https://example.com/soap.wsdl', - dirName: 'soap-dir', - }, - }, + const apiData = strapiApiDataList[0]; + return [ + { + ...apiData, + title: 'API Data Without API Details', + apiRestDetail: undefined, + apiSoapDetail: { + slug: undefined as any, + repositoryUrl: 'https://example.com/soap.wsdl', + dirName: 'soap-dir', }, - ], - } satisfies StrapiApiDataList; + }, + ] as StrapiApiDataList; } export function mixedApiDataValidAndInvalid() { - const validRestApi = strapiApiDataList.data[0]; - const validSoapApi = strapiApiDataList.data[1]; - const invalidApi = apiDataWithoutApiDetails().data[0]; - const invalidProductApi = apiDataWithMissingProduct().data[0]; + const validRestApi = strapiApiDataList[0]; + const validSoapApi = strapiApiDataList[1]; + const invalidApi = apiDataWithoutApiDetails()[0]; + const invalidProductApi = apiDataWithMissingProduct()[0]; - return { - ...strapiApiDataList, - data: [ - validRestApi, - invalidApi, - validSoapApi, - invalidProductApi, - { - ...validRestApi, - id: 5, - attributes: { - ...validRestApi.attributes, - title: 'Another Valid REST API', - apiRestDetail: { - slug: 'another-valid-rest-api', - specUrls: [ - { - id: 5, - url: 'https://example.com/another-api.yaml', - name: 'Another API', - hideTryIt: false, - }, - ], + return [ + validRestApi, + invalidApi, + validSoapApi, + invalidProductApi, + { + ...validRestApi, + id: 5, + title: 'Another Valid REST API', + apiRestDetail: { + slug: 'another-valid-rest-api', + specUrls: [ + { + id: 5, + url: 'https://example.com/another-api.yaml', + name: 'Another API', + hideTryIt: false, }, - }, + ], }, - ], - } satisfies StrapiApiDataList; + }, + ] as StrapiApiDataList; } export function apiDataWithoutProductBannerLinks() { - const apiData = strapiApiDataList.data[0]; - return { - ...strapiApiDataList, - data: [ - { - ...apiData, - attributes: { - ...apiData.attributes, - bannerLinks: [], - product: { - data: { - ...apiData.attributes.product.data, - attributes: { - ...(apiData.attributes.product.data?.attributes as any), - bannerLinks: [], - }, - }, - }, - }, + const apiData = strapiApiDataList[0]; + return [ + { + ...apiData, + bannerLinks: [], + product: { + ...apiData.product, + name: apiData.product?.name || '', + shortName: apiData.product?.shortName || '', + slug: apiData.product?.slug || '', + isVisible: apiData.product?.isVisible || false, + overview: apiData.product?.overview, + quickstart_guide: apiData.product?.quickstart_guide, + api_data_list_page: apiData.product?.api_data_list_page, + tutorial_list_page: apiData.product?.tutorial_list_page, + guide_list_page: apiData.product?.guide_list_page, + release_note: apiData.product?.release_note, + use_case_list_page: apiData.product?.use_case_list_page, + tags: apiData.product?.tags, + bannerLinks: [], }, - ], - } satisfies StrapiApiDataList; + }, + ] as StrapiApiDataList; } export function apiDataWithCorruptedProduct() { - const apiData = strapiApiDataList.data[0]; - return { - ...strapiApiDataList, - data: [ - { - ...apiData, - attributes: { - ...apiData.attributes, - title: 'API Data With Corrupted Product', - product: { - data: { - ...apiData.attributes.product.data, - attributes: undefined as any, - }, - }, - }, - }, - ], - }; + const apiData = strapiApiDataList[0]; + return [ + { + ...apiData, + title: 'API Data With Corrupted Product', + product: undefined as any, + }, + ] as StrapiApiDataList; } export function allInvalidApiData() { - return { - ...strapiApiDataList, - data: [ - apiDataWithoutApiDetails().data[0], - apiDataWithMissingProduct().data[0], - apiDataWithCorruptedProduct().data[0], - ], - }; + return [ + apiDataWithoutApiDetails()[0], + apiDataWithMissingProduct()[0], + apiDataWithCorruptedProduct()[0], + ] as StrapiApiDataList; } export function soapApiDataOnly() { - const soapApi = strapiApiDataList.data[1]; - return { - ...strapiApiDataList, - data: [soapApi], - } satisfies StrapiApiDataList; + const soapApi = strapiApiDataList[1]; + return [soapApi] as StrapiApiDataList; } export function restApiDataOnly() { - const restApi = strapiApiDataList.data[0]; - return { - ...strapiApiDataList, - data: [restApi], - } satisfies StrapiApiDataList; + const restApi = strapiApiDataList[0]; + return [restApi] as StrapiApiDataList; } export function restApiDataWithMultipleSpecs() { - const restApi = strapiApiDataList.data[0]; - return { - ...strapiApiDataList, - data: [ - { - ...restApi, - attributes: { - ...restApi.attributes, - apiRestDetail: { - slug: 'multi-spec-api', - specUrls: [ - { - id: 1, - url: 'https://example.com/api1.yaml', - name: 'API 1', - hideTryIt: false, - }, - { - id: 2, - url: 'https://example.com/api2.yaml', - name: 'API 2', - hideTryIt: true, - }, - ], + const restApi = strapiApiDataList[0]; + return [ + { + ...restApi, + apiRestDetail: { + slug: 'multi-spec-api', + specUrls: [ + { + id: 1, + url: 'https://example.com/api1.yaml', + name: 'API 1', + hideTryIt: false, + }, + { + id: 2, + url: 'https://example.com/api2.yaml', + name: 'API 2', + hideTryIt: true, }, - }, + ], }, - ], - } satisfies StrapiApiDataList; + }, + ] as StrapiApiDataList; } diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/factories/apiDataListPages.ts b/apps/nextjs-website/src/lib/strapi/__tests__/factories/apiDataListPages.ts index a5e39c1689..44b1391c2c 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/factories/apiDataListPages.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/factories/apiDataListPages.ts @@ -2,257 +2,198 @@ import { strapiApiDataListPages } from '@/lib/strapi/__tests__/fixtures/apiDataL import { StrapiApiDataListPages } from '@/lib/strapi/types/apiDataListPages'; export function minimalApiDataListPages(): StrapiApiDataListPages { - const page = strapiApiDataListPages.data[0]; - return { - data: [ - { - ...page, - attributes: { - ...page.attributes, - title: 'Minimal API List Page', + const page = strapiApiDataListPages[0]; + return [ + { + ...page, + title: 'Minimal API List Page', + description: undefined, + seo: undefined, + bannerLinks: [], + api_data: [ + { + id: 1, + title: 'Minimal API', description: undefined, - seo: undefined, - bannerLinks: [], - apiData: { - data: [ - { - id: 1, - attributes: { - title: 'Minimal API', - description: undefined, - icon: { data: undefined }, - apiRestDetail: { - slug: 'minimal-api', - specUrls: [], - }, - apiSoapDetail: undefined, - tags: { data: undefined }, - }, - }, - ], + icon: undefined, + apiRestDetail: { + slug: 'minimal-api', + specUrls: [], }, + apiSoapDetail: undefined, + tags: undefined, + bannerLinks: [], }, - }, - ], - }; + ], + }, + ]; } export function apiDataListPageWithEmptyApiData(): StrapiApiDataListPages { - const page = strapiApiDataListPages.data[0]; - return { - data: [ - { - ...page, - attributes: { - ...page.attributes, - title: 'Empty API List Page', - apiData: { - data: [], - }, - }, - }, - ], - }; + const page = strapiApiDataListPages[0]; + return [ + { + ...page, + title: 'Empty API List Page', + api_data: [], + }, + ]; } export function apiDataListPageWithMixedApiTypes(): StrapiApiDataListPages { - const page = strapiApiDataListPages.data[0]; - return { - data: [ - { - ...page, - attributes: { - ...page.attributes, - title: 'Mixed API Types Page', - apiData: { - data: [ - // Valid REST API - { - id: 1, - attributes: { - title: 'REST API', - description: 'A REST API', - icon: { data: undefined }, - apiRestDetail: { - slug: 'rest-api', - specUrls: [], - }, - apiSoapDetail: undefined, - tags: { data: undefined }, - }, - }, - // Valid SOAP API - { - id: 2, - attributes: { - title: 'SOAP API', - description: 'A SOAP API', - icon: { data: undefined }, - apiRestDetail: undefined, - apiSoapDetail: { - slug: 'soap-api', - repositoryUrl: 'https://example.com/soap', - dirName: 'soap', - }, - tags: { data: undefined }, - }, - }, - // Invalid API (no details) - { - id: 3, - attributes: { - title: 'Invalid API', - description: 'An invalid API', - icon: { data: undefined }, - apiRestDetail: undefined, - apiSoapDetail: undefined, - tags: { data: undefined }, - }, - }, - ], + const page = strapiApiDataListPages[0]; + return [ + { + ...page, + title: 'Mixed API Types Page', + api_data: [ + // Valid REST API + { + id: 1, + bannerLinks: [], + title: 'REST API', + description: 'A REST API', + icon: undefined, + apiRestDetail: { + slug: 'rest-api', + specUrls: [], }, + apiSoapDetail: undefined, + tags: undefined, + }, + // Valid SOAP API + { + id: 2, + bannerLinks: [], + title: 'SOAP API', + description: 'A SOAP API', + icon: undefined, + apiRestDetail: undefined, + apiSoapDetail: { + slug: 'soap-api', + repositoryUrl: 'https://example.com/soap', + dirName: 'soap', + }, + tags: undefined, + }, + // Invalid API (no details) + { + id: 3, + bannerLinks: [], + title: 'Invalid API', + description: 'An invalid API', + icon: undefined, + apiRestDetail: undefined, + apiSoapDetail: undefined, + tags: undefined, }, - }, - ], - }; + ], + }, + ]; } export function apiDataListPageWithoutDescription(): StrapiApiDataListPages { - const page = strapiApiDataListPages.data[0]; - return { - data: [ - { - ...page, - attributes: { - ...page.attributes, - description: undefined, - }, - }, - ], - }; + const page = strapiApiDataListPages[0]; + return [ + { + ...page, + description: undefined, + }, + ]; } export function apiDataListPageWithInvalidApiData(): StrapiApiDataListPages { - const page = strapiApiDataListPages.data[0]; - return { - data: [ - { - ...page, - attributes: { - ...page.attributes, - title: 'Invalid API Data Page', - apiData: { - data: [ - { - id: 1, - attributes: { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - title: undefined as any, - description: 'API without title', - icon: { data: undefined }, - apiRestDetail: { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - slug: undefined as any, - specUrls: [], - }, - apiSoapDetail: undefined, - tags: { data: undefined }, - }, - }, - // API without any details - { - id: 2, - attributes: { - title: 'API without details', - description: 'This API has no REST or SOAP details', - icon: { data: undefined }, - apiRestDetail: undefined, - apiSoapDetail: undefined, - tags: { data: undefined }, - }, - }, - ], + const page = strapiApiDataListPages[0]; + return [ + { + ...page, + title: 'Invalid API Data Page', + api_data: [ + { + id: 1, + bannerLinks: [], + title: undefined as any, + description: 'API without title', + icon: undefined, + apiRestDetail: { + slug: undefined as any, + specUrls: [], }, + apiSoapDetail: undefined, + tags: undefined, }, - }, - ], - }; + // API without any details + { + id: 2, + bannerLinks: [], + title: 'API without details', + description: 'This API has no REST or SOAP details', + icon: undefined, + apiRestDetail: undefined, + apiSoapDetail: undefined, + tags: undefined, + }, + ], + }, + ]; } export function multipleApiDataListPages(): StrapiApiDataListPages { - const page = strapiApiDataListPages.data[0]; - return { - data: [ - page, - { - ...page, - id: 2, - attributes: { - ...page.attributes, - title: 'Second API List Page', - description: 'Another API list page', - apiData: { - data: [ - { - id: 10, - attributes: { - title: 'Another REST API', - description: 'Another REST API description', - icon: { data: undefined }, - apiRestDetail: { - slug: 'another-rest-api', - specUrls: [], - }, - apiSoapDetail: undefined, - tags: { data: undefined }, - }, - }, - ], + const page = strapiApiDataListPages[0]; + return [ + page, + { + ...page, + id: 2, + title: 'Second API List Page', + description: 'Another API list page', + api_data: [ + { + id: 10, + bannerLinks: [], + title: 'Another REST API', + description: 'Another REST API description', + icon: undefined, + apiRestDetail: { + slug: 'another-rest-api', + specUrls: [], }, + apiSoapDetail: undefined, + tags: undefined, }, - }, - ], - }; + ], + }, + ]; } export function emptyApiDataListPages(): StrapiApiDataListPages { - return { - data: [], - }; + return []; } export function apiDataListPageWithBothRestAndSoap(): StrapiApiDataListPages { - const page = strapiApiDataListPages.data[0]; - return { - data: [ - { - ...page, - attributes: { - ...page.attributes, - apiData: { - data: [ - { - id: 1, - attributes: { - title: 'API with both REST and SOAP', - description: 'API with both details', - icon: { data: undefined }, - apiRestDetail: { - slug: 'rest-slug', - specUrls: [], - }, - apiSoapDetail: { - slug: 'soap-slug', - repositoryUrl: 'https://example.com', - dirName: 'soap', - }, - tags: { data: undefined }, - }, - }, - ], + const page = strapiApiDataListPages[0]; + return [ + { + ...page, + api_data: [ + { + id: 1, + bannerLinks: [], + title: 'API with both REST and SOAP', + description: 'API with both details', + icon: undefined, + apiRestDetail: { + slug: 'rest-slug', + specUrls: [], + }, + apiSoapDetail: { + slug: 'soap-slug', + repositoryUrl: 'https://example.com', + dirName: 'soap', }, + tags: undefined, }, - }, - ], - }; + ], + }, + ]; } diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/factories/bannerLink.ts b/apps/nextjs-website/src/lib/strapi/__tests__/factories/bannerLink.ts index d94eaa4691..0a3f136980 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/factories/bannerLink.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/factories/bannerLink.ts @@ -5,7 +5,7 @@ import { strapiBannerLink } from '../fixtures/bannerLink'; const defaultBannerLink = { id: 1, content: undefined, - icon: { data: mediaJpeg() }, + icon: mediaJpeg(), theme: 'light', title: 'Default Banner Link', } satisfies StrapiBannerLink; @@ -30,19 +30,15 @@ export function minimalBannerLink(): StrapiBannerLink { // eslint-disable-next-line @typescript-eslint/no-explicit-any theme: undefined as any, icon: { - data: { - attributes: { - name: 'minimal-icon.svg', - alternativeText: 'Minimal Icon', - caption: undefined, - width: 24, - height: 24, - ext: '.svg', - mime: 'image/svg+xml', - size: 0.5, - url: 'https://example.com/minimal-icon.svg', - }, - }, + name: 'minimal-icon.svg', + alternativeText: 'Minimal Icon', + caption: undefined, + width: 24, + height: 24, + ext: '.svg', + mime: 'image/svg+xml', + size: 0.5, + url: 'https://example.com/minimal-icon.svg', }, }; } diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/factories/caseHistories.ts b/apps/nextjs-website/src/lib/strapi/__tests__/factories/caseHistories.ts index 563aece105..82b17e2d2f 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/factories/caseHistories.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/factories/caseHistories.ts @@ -1,6 +1,7 @@ import { mediaJpeg } from '@/lib/strapi/__tests__/factories/media'; import { strapiCaseHistories } from '@/lib/strapi/__tests__/fixtures/caseHistories'; import { StrapiCaseHistories } from '@/lib/strapi/types/caseHistories'; +import { StrapiBaseProductWithoutBannerLinks } from '@/lib/strapi/types/product'; export function minimalDataCaseHistories() { const strapiCaseHistory = strapiCaseHistories.data[0]; @@ -9,17 +10,14 @@ export function minimalDataCaseHistories() { data: [ { ...strapiCaseHistory, - attributes: { - ...strapiCaseHistory.attributes, - title: 'Minimal Data Case History', - slug: 'minimal-data-case-history', - description: undefined, - publishedAt: '2023-01-02T00:00:00.000Z', - updatedAt: '2023-01-02T00:00:00.000Z', - image: undefined, - parts: [], - seo: undefined, - }, + title: 'Minimal Data Case History', + slug: 'minimal-data-case-history', + description: undefined, + publishedAt: '2023-01-02T00:00:00.000Z', + updatedAt: '2023-01-02T00:00:00.000Z', + image: undefined, + parts: [], + seo: undefined, }, ], } satisfies StrapiCaseHistories; @@ -29,16 +27,13 @@ export function caseHistoriesWithMissingData() { const strapiCaseHistory = strapiCaseHistories.data[0]; return { ...strapiCaseHistories, - data: [ + ...[ { ...strapiCaseHistory, - attributes: { - ...strapiCaseHistory.attributes, - title: undefined, - slug: undefined, - publishedAt: undefined, - updatedAt: undefined, - }, + title: undefined, + slug: undefined, + publishedAt: undefined, + updatedAt: undefined, }, ], }; @@ -51,10 +46,7 @@ export function caseHistoryWithMissingMandatoryData() { data: [ { ...strapiCaseHistory, - attributes: { - ...strapiCaseHistory.attributes, - products: { data: [] }, - }, + products: [], }, ], }; @@ -63,15 +55,11 @@ export function caseHistoryWithMissingMandatoryData() { export function caseHistoriesWithMultipleProducts() { const strapiCaseHistory = strapiCaseHistories.data[0]; const secondProduct = { - attributes: { - isVisible: true, - name: 'Second Product', - shortName: 'SecondProd', - slug: 'second-product', - logo: { - data: mediaJpeg(), - }, - }, + isVisible: true, + name: 'Second Product', + shortName: 'SecondProd', + slug: 'second-product', + logo: mediaJpeg(), }; return { @@ -79,15 +67,10 @@ export function caseHistoriesWithMultipleProducts() { data: [ { ...strapiCaseHistory, - attributes: { - ...strapiCaseHistory.attributes, - products: { - data: [ - ...strapiCaseHistory.attributes.products.data, - secondProduct, - ], - }, - }, + products: [ + ...strapiCaseHistory.products, + secondProduct, + ] as readonly StrapiBaseProductWithoutBannerLinks[], }, ], } satisfies StrapiCaseHistories; @@ -100,10 +83,7 @@ export function caseHistoriesWithoutImage() { data: [ { ...strapiCaseHistory, - attributes: { - ...strapiCaseHistory.attributes, - image: undefined, - }, + image: undefined, }, ], } satisfies StrapiCaseHistories; diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/factories/guideListPages.ts b/apps/nextjs-website/src/lib/strapi/__tests__/factories/guideListPages.ts index 3e0847f476..eb18d56675 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/factories/guideListPages.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/factories/guideListPages.ts @@ -2,120 +2,71 @@ import { strapiGuideListPagesData } from '@/lib/strapi/__tests__/fixtures/guideL import { StrapiGuideListPages } from '@/lib/strapi/types/guideListPage'; export function guideListPagesWithItemsMissingSlug() { - const guidesList = strapiGuideListPagesData; - return { - ...guidesList, - data: guidesList.data.map((guides) => ({ - ...guides, - attributes: { - ...guides.attributes, - guidesByCategory: guides.attributes.guidesByCategory.map( - (guidePerCategory) => ({ - ...guidePerCategory, - guides: { - data: guidePerCategory.guides.data.map((guide) => ({ - attributes: { - ...guide.attributes, - slug: undefined, - }, - })), - }, - }) - ), - }, + return strapiGuideListPagesData.data.map((guides) => ({ + ...guides, + guidesByCategory: guides.guidesByCategory.map((guidePerCategory) => ({ + ...guidePerCategory, + guides: guidePerCategory.guides.map((guide) => ({ + ...guide, + slug: undefined as any, + })), })), - }; + })); } export function guideListPagesWithItemsMissingImages() { - const guidesList = strapiGuideListPagesData; - return { - ...guidesList, - data: guidesList.data.map((guides) => ({ - ...guides, - attributes: { - ...guides.attributes, - guidesByCategory: guides.attributes.guidesByCategory.map( - (guidePerCategory) => ({ - ...guidePerCategory, - guides: { - data: guidePerCategory.guides.data.map((guide) => ({ - attributes: { - ...guide.attributes, - image: undefined, - mobileImage: undefined, - }, - })), - }, - }) - ), - }, + return strapiGuideListPagesData.data.map((guides) => ({ + ...guides, + guidesByCategory: guides.guidesByCategory.map((guidePerCategory) => ({ + ...guidePerCategory, + guides: guidePerCategory.guides.map((guide) => ({ + ...guide, + image: undefined as any, + mobileImage: undefined as any, + })), })), - }; + })); } export function guideListPagesWithItemsMissingListItem() { - const guidesList = strapiGuideListPagesData; return { - ...guidesList, - data: guidesList.data.map((guides) => ({ + ...strapiGuideListPagesData, + data: strapiGuideListPagesData.data.map((guides) => ({ ...guides, - attributes: { - ...guides.attributes, - guidesByCategory: guides.attributes.guidesByCategory.map( - (guidePerCategory) => ({ - ...guidePerCategory, - guides: { - data: [ - { - attributes: { - ...guidePerCategory.guides.data[0].attributes, - listItems: undefined, - }, - }, - ...guidePerCategory.guides.data.slice(1), - ], - }, - }) - ), - }, + guidesByCategory: guides.guidesByCategory.map((guidePerCategory) => ({ + ...guidePerCategory, + guides: [ + guidePerCategory.guides[0], + { + ...guidePerCategory.guides[1], + listItems: undefined as any, + }, + ], + })), })), }; } export function guideListPagesWithItemsWithWrongDataType() { - const guidesList = strapiGuideListPagesData; return { - ...guidesList, - data: guidesList.data.map((guides) => ({ + ...strapiGuideListPagesData, + data: strapiGuideListPagesData.data.map((guides) => ({ ...guides, - attributes: { - ...guides.attributes, - title: 12345, // Wrong data type: it should be a string - description: 67890, // Wrong data type: it should be a string - }, + title: 12345, // Wrong data type: it should be a string + description: 67890, // Wrong data type: it should be a string })), }; } export function guideListPagesWithItemMissingProductSlug() { - const guidesList = strapiGuideListPagesData; return { - ...guidesList, - data: guidesList.data.map((guides) => ({ + ...strapiGuideListPagesData, + data: strapiGuideListPagesData.data.map((guides) => ({ ...guides, - attributes: { - ...guides.attributes, - product: { - data: { - ...guides.attributes.product.data, - attributes: { - ...guides.attributes.product.data.attributes, - slug: undefined, - }, - }, - }, + product: { + ...guides.product, + slug: undefined as any, }, })), - } as unknown as StrapiGuideListPages; + } as StrapiGuideListPages; } diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/factories/guides.ts b/apps/nextjs-website/src/lib/strapi/__tests__/factories/guides.ts index 81b88c551e..239ad40b6a 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/factories/guides.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/factories/guides.ts @@ -7,18 +7,9 @@ export function guideListWithItemsWithEmptyProductSlug() { ...strapiGuideData, data: strapiGuideData.data.map((guide) => ({ ...guide, - attributes: { - ...guide.attributes, - product: { - ...guide.attributes.product, - data: { - ...guide.attributes.product.data, - attributes: { - ...guide.attributes.product.data.attributes, - slug: '', - }, - }, - }, + product: { + ...guide.product, + slug: '', }, })), } satisfies StrapiGuides; @@ -29,18 +20,10 @@ export function guideListWithMissingProductSlug() { ...strapiGuideData, data: strapiGuideData.data.map((guide) => ({ ...guide, - attributes: { - ...guide.attributes, - product: { - ...guide.attributes.product, - data: { - ...guide.attributes.product.data, - attributes: { - ...guide.attributes.product.data.attributes, - slug: undefined as any, - }, - }, - }, + product: { + ...guide.product, + ...guide.product, + slug: undefined as any, }, })), } satisfies StrapiGuides; diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/factories/homepage.ts b/apps/nextjs-website/src/lib/strapi/__tests__/factories/homepage.ts index e0ecfdeaff..1f7e42180f 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/factories/homepage.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/factories/homepage.ts @@ -3,78 +3,48 @@ import { StrapiHomepage } from '@/lib/strapi/types/homepage'; export function minimalDataHomepage() { return { - data: { - attributes: { - updatedAt: Date.now().toString(), - comingsoonDocumentation: { - title: 'Minimal Documentation', - links: [], - }, - heroSlider: [ - { - title: 'Minimal Hero', - backgroundImage: { data: undefined }, - }, - ], - newsShowcase: undefined, - ecosystem: undefined, - webinars: { data: [] }, - seo: undefined, - }, + updatedAt: new Date().toISOString(), + comingsoonDocumentation: { + title: 'Minimal Documentation', + links: [], }, + heroSlider: [ + { + title: 'Minimal Hero', + backgroundImage: undefined, + }, + ], + newsShowcase: undefined, + ecosystem: undefined, + webinars: [], + seo: undefined, } satisfies StrapiHomepage; } export function homepageWithoutNewsShowcase() { return { ...strapiHomepage, - data: { - ...strapiHomepage.data, - attributes: { - ...strapiHomepage.data.attributes, - newsShowcase: undefined, - }, - }, + newsShowcase: undefined, } satisfies StrapiHomepage; } export function homepageWithoutEcosystem() { return { ...strapiHomepage, - data: { - ...strapiHomepage.data, - attributes: { - ...strapiHomepage.data.attributes, - ecosystem: undefined, - }, - }, + ecosystem: undefined, } satisfies StrapiHomepage; } export function homepageWithoutWebinars() { return { ...strapiHomepage, - data: { - ...strapiHomepage.data, - attributes: { - ...strapiHomepage.data.attributes, - webinars: { - data: [], - }, - }, - }, + webinars: [], } satisfies StrapiHomepage; } export function homepageWithoutSeo() { return { ...strapiHomepage, - data: { - ...strapiHomepage.data, - attributes: { - ...strapiHomepage.data.attributes, - seo: undefined, - }, - }, + seo: undefined, } satisfies StrapiHomepage; } diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/factories/media.ts b/apps/nextjs-website/src/lib/strapi/__tests__/factories/media.ts index 6f3a0de3b9..9997cda2af 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/factories/media.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/factories/media.ts @@ -2,16 +2,14 @@ import { StrapiMedia } from '@/lib/strapi/types/media'; export function mediaJpeg() { return { - attributes: { - alternativeText: 'Example Image', - caption: undefined, - width: 800, - height: 600, - size: 123456, - name: 'example.jpg', - ext: '.jpg', - mime: 'image/jpeg', - url: 'https://example.com/example.jpg', - }, + alternativeText: 'Example Image', + caption: undefined, + width: 800, + height: 600, + size: 123456, + name: 'example.jpg', + ext: '.jpg', + mime: 'image/jpeg', + url: 'https://example.com/example.jpg', } satisfies StrapiMedia; } diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/factories/overviews.ts b/apps/nextjs-website/src/lib/strapi/__tests__/factories/overviews.ts index 3a05f0f585..05a73cb7eb 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/factories/overviews.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/factories/overviews.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import { StrapiOverviews } from '@/lib/strapi/types/overviews'; +import { StrapiOverview, StrapiOverviews } from '@/lib/strapi/types/overviews'; import { strapiOverviews } from '@/lib/strapi/__tests__/fixtures/overviews'; export function minimalDataSingleOverview(): StrapiOverviews { @@ -8,17 +8,14 @@ export function minimalDataSingleOverview(): StrapiOverviews { data: [ { ...strapiOverviews.data[0], - attributes: { - ...strapiOverviews.data[0].attributes, - features: undefined, - startInfoSection: undefined, - tutorialSection: undefined, - whatsNew: undefined, - postIntegration: undefined, - relatedLinks: undefined, - seo: undefined, - }, - }, + features: undefined, + startInfoSection: undefined, + tutorialSection: undefined, + whatsNew: undefined, + postIntegration: undefined, + relatedLinks: undefined, + seo: undefined, + } as StrapiOverview, ], }; } @@ -29,17 +26,9 @@ export function overviewsWithItemWithEmptyProductSlug() { data: [ { ...strapiOverviews.data[0], - attributes: { - ...strapiOverviews.data[0].attributes, - product: { - data: { - ...strapiOverviews.data[0].attributes.product.data, - attributes: { - ...strapiOverviews.data[0].attributes.product.data.attributes, - slug: '', - }, - }, - }, + product: { + ...strapiOverviews.data[0]?.product, + slug: '', }, }, ], @@ -52,17 +41,9 @@ export function overviewsWithItemMissingProductSlug() { data: [ { ...strapiOverviews.data[0], - attributes: { - ...strapiOverviews.data[0].attributes, - product: { - data: { - ...strapiOverviews.data[0].attributes.product.data, - attributes: { - ...strapiOverviews.data[0].attributes.product.data.attributes, - slug: undefined as any, - }, - }, - }, + product: { + ...strapiOverviews.data[0]?.product, + slug: undefined as any, }, }, ], @@ -75,35 +56,18 @@ export function overviewsWithItemMissingTutorialProductSlug() { data: [ { ...strapiOverviews.data[0], - attributes: { - ...strapiOverviews.data[0].attributes, - tutorialSection: { - ...strapiOverviews.data[0].attributes.tutorialSection, - tutorials: { - data: [ - { - ...strapiOverviews.data[0].attributes.tutorialSection - .tutorials.data[0], - attributes: { - ...strapiOverviews.data[0].attributes.tutorialSection - .tutorials.data[0].attributes, - product: { - data: { - ...strapiOverviews.data[0].attributes.tutorialSection - .tutorials.data[0].attributes.product.data, - attributes: { - ...strapiOverviews.data[0].attributes.tutorialSection - .tutorials.data[0].attributes.product.data - .attributes, - slug: undefined as any, - }, - }, - }, - }, - }, - ], + tutorialSection: { + ...strapiOverviews.data[0]?.tutorialSection, + tutorials: [ + { + ...strapiOverviews.data[0]?.tutorialSection.tutorials[0], + product: { + ...strapiOverviews.data[0]?.tutorialSection.tutorials[0] + .product, + slug: undefined as any, + }, }, - }, + ], }, }, ], @@ -116,24 +80,14 @@ export function overviewsWithItemMissingTutorialSlug() { data: [ { ...strapiOverviews.data[0], - attributes: { - ...strapiOverviews.data[0].attributes, - tutorialSection: { - ...strapiOverviews.data[0].attributes.tutorialSection, - tutorials: { - data: [ - { - ...strapiOverviews.data[0].attributes.tutorialSection - .tutorials.data[0], - attributes: { - ...strapiOverviews.data[0].attributes.tutorialSection - .tutorials.data[0].attributes, - slug: undefined as any, - }, - }, - ], + tutorialSection: { + ...strapiOverviews.data[0]?.tutorialSection, + tutorials: [ + { + ...strapiOverviews.data[0]?.tutorialSection.tutorials[0], + slug: undefined as any, }, - }, + ], }, }, ], @@ -146,24 +100,14 @@ export function overviewsWithItemWithEmptyGuideProductSlug() { data: [ { ...strapiOverviews.data[0], - attributes: { - ...strapiOverviews.data[0].attributes, - postIntegration: { - ...strapiOverviews.data[0].attributes.postIntegration, - guides: { - data: [ - { - ...strapiOverviews.data[0].attributes.postIntegration.guides - .data[0], - attributes: { - ...strapiOverviews.data[0].attributes.postIntegration.guides - .data[0].attributes, - slug: '', - }, - }, - ], + postIntegration: { + ...strapiOverviews.data[0]?.postIntegration, + guides: [ + { + ...strapiOverviews.data[0]?.postIntegration.guides[0], + slug: '', }, - }, + ], }, }, ], @@ -176,24 +120,14 @@ export function overviewsWithItemMissingGuideProductSlug() { data: [ { ...strapiOverviews.data[0], - attributes: { - ...strapiOverviews.data[0].attributes, - postIntegration: { - ...strapiOverviews.data[0].attributes.postIntegration, - guides: { - data: [ - { - ...strapiOverviews.data[0].attributes.postIntegration.guides - .data[0], - attributes: { - ...strapiOverviews.data[0].attributes.postIntegration.guides - .data[0].attributes, - slug: undefined as any, - }, - }, - ], + postIntegration: { + ...strapiOverviews.data[0]?.postIntegration, + guides: [ + { + ...strapiOverviews.data[0]?.postIntegration.guides[0], + slug: undefined as any, }, - }, + ], }, }, ], diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/factories/parts.ts b/apps/nextjs-website/src/lib/strapi/__tests__/factories/parts.ts index db4604f172..f8a9f8d3ca 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/factories/parts.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/factories/parts.ts @@ -49,7 +49,7 @@ export function minimalQuotePart(): StrapiPart { return { __component: 'parts.quote', text: '', - backgroundImage: {}, + backgroundImage: { name: '', ext: '', mime: '', size: 0, url: '' }, }; } diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/factories/product.ts b/apps/nextjs-website/src/lib/strapi/__tests__/factories/product.ts index 4a8a3f4991..814a511f70 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/factories/product.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/factories/product.ts @@ -10,208 +10,160 @@ import { generateBannerLinks } from '@/lib/strapi/__tests__/factories/bannerLink export function baseProduct(): StrapiBaseProduct { return { - attributes: { - isVisible: true, - name: 'Test Product', - shortName: 'TP', - slug: 'test-product', - }, + isVisible: true, + name: 'Test Product', + shortName: 'TP', + slug: 'test-product', }; } export function baseProductWithBannerLinks(): StrapiBaseProductWithBannerLinks { return { - attributes: { - ...baseProduct().attributes, - bannerLinks: generateBannerLinks(2), - }, + ...baseProduct(), + bannerLinks: generateBannerLinks(2), }; } export function baseProductWithoutBannerLinks(): StrapiBaseProductWithoutBannerLinks { return { - attributes: { - ...baseProduct().attributes, - description: 'Test product description', - logo: { - data: mediaJpeg(), - }, - }, + ...baseProduct(), + description: 'Test product description', + logo: mediaJpeg(), }; } export function baseProductWithoutBannerLinksMinimal(): StrapiBaseProductWithoutBannerLinks { return { - attributes: { - ...baseProduct().attributes, - description: undefined, - logo: { - data: undefined, - }, - }, + ...baseProduct(), + description: undefined, + logo: undefined, }; } export function strapiBaseProductWithRelations(): StrapiBaseProductWithRelations { return { - attributes: { - tags: { data: [] }, - ...baseProduct().attributes, - bannerLinks: generateBannerLinks(1), - overview: { data: { id: 1 } }, - quickstart_guide: { data: { id: 2 } }, - api_data_list_page: { data: undefined }, - tutorial_list_page: { data: { id: 3 } }, - guide_list_page: { data: { id: 4 } }, - release_note: { data: undefined }, - use_case_list_page: { data: { id: 1 } }, - }, + tags: [], + ...baseProduct(), + bannerLinks: generateBannerLinks(1), + overview: 1, + quickstart_guide: 2, + api_data_list_page: undefined, + tutorial_list_page: 3, + guide_list_page: 4, + release_note: undefined, + use_case_list_page: 1, }; } export function strapiBaseProductWithoutRelations(): StrapiBaseProductWithRelations { return { - attributes: { - ...baseProduct().attributes, - bannerLinks: undefined, - tags: { data: [] }, - overview: { data: undefined }, - quickstart_guide: { data: undefined }, - api_data_list_page: { data: undefined }, - tutorial_list_page: { data: undefined }, - guide_list_page: { data: undefined }, - release_note: { data: undefined }, - use_case_list_page: { data: undefined }, - }, + ...baseProduct(), + bannerLinks: undefined, + tags: [], + overview: undefined, + quickstart_guide: undefined, + api_data_list_page: undefined, + tutorial_list_page: undefined, + guide_list_page: undefined, + release_note: undefined, + use_case_list_page: undefined, }; } export function strapiProduct(): StrapiProduct { return { - attributes: { - ...baseProduct().attributes, - tags: { data: [] }, - bannerLinks: generateBannerLinks(2), - description: 'Complete product description', - logo: { - data: mediaJpeg(), - }, - overview: { data: { id: 1 } }, - quickstart_guide: { data: { id: 2 } }, - api_data_list_page: { data: undefined }, - tutorial_list_page: { data: { id: 3 } }, - guide_list_page: { data: { id: 4 } }, - release_note: { data: { id: 5 } }, - use_case_list_page: { data: { id: 1 } }, - }, + ...baseProduct(), + tags: [], + bannerLinks: generateBannerLinks(2), + description: 'Complete product description', + logo: mediaJpeg(), + overview: 1, + quickstart_guide: 2, + api_data_list_page: undefined, + tutorial_list_page: 3, + guide_list_page: 4, + release_note: 5, + use_case_list_page: 1, }; } export function strapiProductMinimal(): StrapiProduct { return { - attributes: { - ...baseProduct().attributes, - bannerLinks: undefined, - description: undefined, - logo: { - data: mediaJpeg(), - }, - tags: { data: [] }, - overview: { data: undefined }, - quickstart_guide: { data: undefined }, - api_data_list_page: { data: undefined }, - tutorial_list_page: { data: undefined }, - guide_list_page: { data: undefined }, - release_note: { data: undefined }, - use_case_list_page: { data: undefined }, - }, + ...baseProduct(), + bannerLinks: undefined, + description: undefined, + logo: mediaJpeg(), + tags: [], + overview: undefined, + quickstart_guide: undefined, + api_data_list_page: undefined, + tutorial_list_page: undefined, + guide_list_page: undefined, + release_note: undefined, + use_case_list_page: undefined, }; } export function strapiProductWithoutLogo(): StrapiProduct { return { - attributes: { - ...strapiProduct().attributes, - logo: { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - data: null as any, // Simulating missing logo data - }, - }, + ...strapiProduct(), + logo: undefined, }; } export function productWithAllRelations(): StrapiProduct { return { - attributes: { - isVisible: true, - name: 'Full Feature Product', - shortName: 'FFP', - tags: { data: [] }, - slug: 'full-feature-product', - bannerLinks: generateBannerLinks(3), - description: 'A product with all available relations and features', - logo: { - data: mediaJpeg(), - }, - overview: { data: { id: 1 } }, - quickstart_guide: { data: { id: 2 } }, - api_data_list_page: { - data: { - id: 10, - attributes: { - apiData: { - data: [ - { - attributes: { - apiRestDetail: { - slug: 'test-api', - specUrls: [ - { - id: 0, - name: 'Spec URL', - url: 'https://example.com/api/spec.yaml', - hideTryIt: false, - }, - ], - }, - }, - }, - ], - }, + isVisible: true, + name: 'Full Feature Product', + shortName: 'FFP', + tags: [], + slug: 'full-feature-product', + bannerLinks: generateBannerLinks(3), + description: 'A product with all available relations and features', + logo: mediaJpeg(), + overview: 1, + quickstart_guide: 2, + api_data_list_page: { + id: 10, + api_data: [ + { + apiRestDetail: { + slug: 'test-api', + specUrls: [ + { + id: 0, + name: 'Spec URL', + url: 'https://example.com/api/spec.yaml', + hideTryIt: false, + }, + ], }, }, - }, - tutorial_list_page: { data: { id: 3 } }, - guide_list_page: { data: { id: 4 } }, - release_note: { data: { id: 5 } }, - use_case_list_page: { data: { id: 1 } }, + ], }, + tutorial_list_page: 3, + guide_list_page: 4, + release_note: 5, + use_case_list_page: 1, }; } export function productWithMissingMandatoryFields(): Partial { return { - attributes: { - isVisible: true, - // eslint-disable-next-line @typescript-eslint/no-explicit-any - name: undefined as any, - tags: { data: [] }, - // eslint-disable-next-line @typescript-eslint/no-explicit-any - shortName: undefined as any, - // eslint-disable-next-line @typescript-eslint/no-explicit-any - slug: undefined as any, - bannerLinks: [], - description: 'Product with missing mandatory fields', - logo: { - data: mediaJpeg(), - }, - overview: { data: undefined }, - quickstart_guide: { data: undefined }, - api_data_list_page: { data: undefined }, - tutorial_list_page: { data: undefined }, - guide_list_page: { data: undefined }, - release_note: { data: undefined }, - use_case_list_page: { data: undefined }, - }, + isVisible: true, + name: undefined as any, + tags: [], + shortName: undefined as any, + slug: undefined as any, + bannerLinks: [], + description: 'Product with missing mandatory fields', + logo: mediaJpeg(), + overview: undefined, + quickstart_guide: undefined, + api_data_list_page: undefined, + tutorial_list_page: undefined, + guide_list_page: undefined, + release_note: undefined, + use_case_list_page: undefined, }; } diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/factories/products.ts b/apps/nextjs-website/src/lib/strapi/__tests__/factories/products.ts index cfc929b83a..e25e4adcc2 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/factories/products.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/factories/products.ts @@ -1,189 +1,115 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import { strapiProducts } from '@/lib/strapi/__tests__/fixtures/products'; -import { StrapiProducts } from '@/lib/strapi/types/product'; +import { StrapiProduct } from '@/lib/strapi/types/product'; -export function minimalProduct() { +export function minimalProduct(): readonly StrapiProduct[] { const strapiProduct = strapiProducts.data[0]; - return { - ...strapiProducts, - data: [ - { - ...strapiProduct, - attributes: { - ...strapiProduct.attributes, - name: 'Minimal Product', - slug: 'minimal-product', - shortName: 'MP', - description: undefined, - logo: { - data: strapiProduct.attributes.logo.data, - }, - bannerLinks: [], - overview: { data: undefined }, - quickstart_guide: { data: undefined }, - api_data_list_page: { data: undefined }, - guide_list_page: { data: undefined }, - tutorial_list_page: { data: undefined }, - release_note: { data: undefined }, - use_case_list_page: { data: undefined }, - }, - }, - ], - } satisfies StrapiProducts; + return [ + { + ...strapiProduct, + name: 'Minimal Product', + slug: 'minimal-product', + shortName: 'MP', + description: undefined, + logo: strapiProduct.logo, + bannerLinks: [], + overview: undefined, + quickstart_guide: undefined, + api_data_list_page: undefined, + guide_list_page: undefined, + tutorial_list_page: undefined, + release_note: undefined, + use_case_list_page: undefined, + }, + ]; } -export function productsWithAnItemWithEmptySlug() { +export function productsWithAnItemWithEmptySlug(): readonly StrapiProduct[] { const strapiProduct = strapiProducts.data[0]; - return { - ...strapiProducts, - data: [ - { - ...strapiProduct, - attributes: { - ...strapiProduct.attributes, - name: 'Product Without Slug', - slug: '', - }, - }, - ], - } satisfies StrapiProducts; + return [ + { + ...strapiProduct, + name: 'Product Without Slug', + slug: '', + }, + ]; } -export function productsWithAnItemMissingSlug() { +export function productsWithAnItemMissingSlug(): readonly StrapiProduct[] { const strapiProduct = strapiProducts.data[0]; - return { - ...strapiProducts, - data: [ - { - ...strapiProduct, - attributes: { - ...strapiProduct.attributes, - name: 'Product Without Slug', - slug: undefined as any, - }, - }, - ], - } satisfies StrapiProducts; + return [ + { + ...strapiProduct, + name: 'Product Without Slug', + slug: undefined as any, + }, + ]; } -export function productWithMultipleApiData() { +export function productWithMultipleApiData(): readonly StrapiProduct[] { const strapiProduct = strapiProducts.data[0]; - return { - ...strapiProducts, - data: [ - { - ...strapiProduct, - attributes: { - ...strapiProduct.attributes, - api_data_list_page: { - data: { - id: 1, - attributes: { - apiData: { - data: [ - { - attributes: { - apiRestDetail: { - slug: 'api-detail-1', - specUrls: [], - }, - }, - }, - { - attributes: { - apiRestDetail: { - slug: 'api-detail-2', - specUrls: [], - }, - }, - }, - ], - }, - }, + return [ + { + ...strapiProduct, + api_data_list_page: { + id: 1, + api_data: [ + { + apiRestDetail: { + slug: 'api-detail-1', + specUrls: [], }, }, - }, - }, - ], - } satisfies StrapiProducts; -} - -export function productWithEmptyApiData() { - const strapiProduct = strapiProducts.data[0]; - return { - ...strapiProducts, - data: [ - { - ...strapiProduct, - attributes: { - ...strapiProduct.attributes, - api_data_list_page: { - data: { - id: 1, - attributes: { - apiData: { - data: [], - }, - }, + { + apiRestDetail: { + slug: 'api-detail-2', + specUrls: [], }, }, - }, + ], }, - ], - } satisfies StrapiProducts; + }, + ]; } -export function productWithCorruptedData() { +export function productWithEmptyApiData(): readonly StrapiProduct[] { const strapiProduct = strapiProducts.data[0]; - return { - ...strapiProducts, - data: [ - { - ...strapiProduct, - attributes: { - ...strapiProduct.attributes, - api_data_list_page: undefined as any, - name: 'Corrupted Product', - }, + return [ + { + ...strapiProduct, + api_data_list_page: { + id: 1, + api_data: [], }, - ], - }; + }, + ]; } -export function mixedValidAndInvalidProducts() { - const validProduct = strapiProducts.data[0]; - const invalidProduct = productsWithAnItemMissingSlug().data[0]; - - return { - ...strapiProducts, - data: [ - validProduct, - invalidProduct, - { - ...validProduct, - attributes: { - ...validProduct.attributes, - name: 'Another Valid Product', - slug: 'another-valid-product', - }, - }, - ], - } satisfies StrapiProducts; +export function productWithCorruptedData(): readonly StrapiProduct[] { + const strapiProduct = strapiProducts.data[0]; + return [ + { + ...strapiProduct, + api_data_list_page: 'corrupted api data' as any, + name: 'Corrupted Product', + }, + ]; } -export function allInvalidProducts() { - return { - ...strapiProducts, - data: [ - productsWithAnItemMissingSlug().data[0], - productWithCorruptedData().data[0], - ], - }; +export function mixedValidAndInvalidProducts(): readonly StrapiProduct[] { + const validProduct = strapiProducts.data[0]; + const invalidProduct = productsWithAnItemMissingSlug()[0]; + return [ + validProduct, + invalidProduct, + { + ...validProduct, + name: 'Another Valid Product', + slug: 'another-valid-product', + }, + ]; } -export function productWithMissingAttributes() { - return { - id: 1, - attributes: undefined as any, - }; +export function allInvalidProducts(): readonly StrapiProduct[] { + return [productsWithAnItemMissingSlug()[0], productWithCorruptedData()[0]]; } diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/factories/quickStartGuides.ts b/apps/nextjs-website/src/lib/strapi/__tests__/factories/quickStartGuides.ts index d0da4facd4..df9ef8cb9b 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/factories/quickStartGuides.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/factories/quickStartGuides.ts @@ -8,27 +8,21 @@ export function minimalQuickStartGuides(): StrapiQuickStartGuides { data: [ { id: 1, - attributes: { - title: 'Minimal Quick Start', - description: '', - updatedAt: '2024-01-01T00:00:00.000Z', - product: strapiQuickStartGuides.data[0].attributes.product, - bannerLinks: [], - seo: undefined, - quickstartGuideItems: { - data: [ - { - id: 1, - attributes: { - title: 'Minimal Step', - anchor: 'minimal-step', - publishedAt: '2024-01-01T00:00:00.000Z', - parts: [minimalAlertPart()], - }, - }, - ], + title: 'Minimal Quick Start', + description: '', + updatedAt: '2024-01-01T00:00:00.000Z', + product: strapiQuickStartGuides.data[0].product, + bannerLinks: [], + seo: undefined, + quickstartGuideItems: [ + { + id: 1, + title: 'Minimal Step', + anchor: 'minimal-step', + publishedAt: '2024-01-01T00:00:00.000Z', + parts: [minimalAlertPart()], }, - }, + ], }, ], meta: { @@ -58,23 +52,14 @@ export function emptyQuickStartGuides(): StrapiQuickStartGuides { export function quickStartGuidesWithMissingProductSlug(): StrapiQuickStartGuides { return { - ...strapiQuickStartGuides, + meta: strapiQuickStartGuides.meta, data: strapiQuickStartGuides.data.map((quickStart, index) => { if (index === 0) { return { ...quickStart, - attributes: { - ...quickStart.attributes, - product: { - ...quickStart.attributes.product, - data: { - ...quickStart.attributes.product.data, - attributes: { - ...(quickStart.attributes.product.data?.attributes as any), - slug: undefined as any, - }, - }, - }, + product: { + ...quickStart.product!, + slug: undefined as any, }, }; } diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/factories/releaseNotes.ts b/apps/nextjs-website/src/lib/strapi/__tests__/factories/releaseNotes.ts index 656190c209..205823834d 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/factories/releaseNotes.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/factories/releaseNotes.ts @@ -9,23 +9,14 @@ export function minimalDataReleaseNotes() { data: [ { ...strapiReleaseNote, - attributes: { - ...strapiReleaseNote.attributes, - title: 'Minimal Release Notes', - dirName: 'minimal-release-notes', - landingFile: 'minimal.md', - bannerLinks: [], - seo: undefined, - product: { - data: { - ...strapiReleaseNote.attributes.product.data, - attributes: { - ...(strapiReleaseNote.attributes.product.data - ?.attributes as any), - bannerLinks: undefined, - }, - }, - }, + title: 'Minimal Release Notes', + dirName: 'minimal-release-notes', + landingFile: 'minimal.md', + bannerLinks: [], + seo: undefined, + product: { + ...strapiReleaseNote.product!, + bannerLinks: undefined, }, }, ], @@ -39,10 +30,7 @@ export function releaseNotesWithoutBannerLinks() { data: [ { ...strapiReleaseNote, - attributes: { - ...strapiReleaseNote.attributes, - bannerLinks: [], - }, + bannerLinks: [], }, ], } satisfies StrapiReleaseNotes; @@ -55,19 +43,10 @@ export function releaseNotesWithoutProductBannerLinks() { data: [ { ...strapiReleaseNote, - attributes: { - ...strapiReleaseNote.attributes, + bannerLinks: [], + product: { + ...strapiReleaseNote.product!, bannerLinks: [], - product: { - data: { - ...strapiReleaseNote.attributes.product.data, - attributes: { - ...(strapiReleaseNote.attributes.product.data - ?.attributes as any), - bannerLinks: [], - }, - }, - }, }, }, ], @@ -81,19 +60,10 @@ export function releaseNotesWithMissingProductSlug() { data: [ { ...strapiReleaseNote, - attributes: { - ...strapiReleaseNote.attributes, - title: 'Release Note Without Product Slug', - product: { - data: { - ...strapiReleaseNote.attributes.product.data, - attributes: { - ...(strapiReleaseNote.attributes.product.data - ?.attributes as any), - slug: undefined as any, - }, - }, - }, + title: 'Release Note Without Product Slug', + product: { + ...strapiReleaseNote.product!, + slug: undefined as any, }, }, ], diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/factories/solutionListPage.ts b/apps/nextjs-website/src/lib/strapi/__tests__/factories/solutionListPage.ts index c55a88d883..422f19ff73 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/factories/solutionListPage.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/factories/solutionListPage.ts @@ -1,128 +1,73 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import { strapiSolutionListPage } from '@/lib/strapi/__tests__/fixtures/solutionListPage'; -import { StrapiSolutionListPage } from '@/lib/strapi/types/solutionListPage'; export function minimalDataSolutionListPage() { return { - data: { - attributes: { - title: 'Minimal Solutions', - description: 'Minimal solutions page', - solutions: { - data: [], - }, - caseHistories: undefined, - features: undefined, - seo: undefined, - }, - }, - } satisfies StrapiSolutionListPage; + title: 'Minimal Solutions', + description: 'Minimal solutions page', + solutions: [], + caseHistories: undefined, + features: undefined, + seo: undefined, + }; } export function solutionListPageWithoutCaseHistories() { return { ...strapiSolutionListPage, - data: { - ...strapiSolutionListPage.data, - attributes: { - ...strapiSolutionListPage.data.attributes, - caseHistories: undefined, - }, - }, - } satisfies StrapiSolutionListPage; + caseHistories: undefined, + }; } export function solutionListPageWithoutFeatures() { return { ...strapiSolutionListPage, - data: { - ...strapiSolutionListPage.data, - attributes: { - ...strapiSolutionListPage.data.attributes, - features: undefined, - }, - }, - } satisfies StrapiSolutionListPage; + features: undefined, + }; } export function solutionListPageWithoutSolutions() { return { ...strapiSolutionListPage, - data: { - ...strapiSolutionListPage.data, - attributes: { - ...strapiSolutionListPage.data.attributes, - solutions: { - data: [], - }, - }, - }, - } satisfies StrapiSolutionListPage; + solutions: [], + }; } -export function solutionListPageWithMissingSolutionSlug(): StrapiSolutionListPage { +export function solutionListPageWithMissingSolutionSlug() { return { ...strapiSolutionListPage, - data: { - ...strapiSolutionListPage.data, - attributes: { - ...strapiSolutionListPage.data.attributes, - solutions: { - data: [ - { - attributes: { - ...strapiSolutionListPage.data.attributes.solutions.data[0] - .attributes, - slug: undefined as any, - title: 'Solution Without Slug', - }, - }, - { - attributes: { - ...strapiSolutionListPage.data.attributes.solutions.data[0] - .attributes, - title: 'Valid Solution', - }, - }, - ], - }, + solutions: [ + { + ...strapiSolutionListPage.solutions[0], + slug: undefined, + title: 'Solution Without Slug', }, - }, + { + ...strapiSolutionListPage.solutions[0], + title: 'Valid Solution', + }, + ], }; } -export function solutionListPageWithMissingCaseHistorySlug(): StrapiSolutionListPage { +export function solutionListPageWithMissingCaseHistorySlug() { return { ...strapiSolutionListPage, - data: { - ...strapiSolutionListPage.data, - attributes: { - ...strapiSolutionListPage.data.attributes, - caseHistories: { - ...strapiSolutionListPage.data.attributes.caseHistories, - case_histories: { - data: [ - { - id: 1, - attributes: { - ...strapiSolutionListPage.data.attributes.caseHistories - ?.case_histories.data[0].attributes, - slug: undefined as any, - title: 'Case History Without Slug', - }, - }, - { - id: 2, - attributes: { - ...strapiSolutionListPage.data.attributes.caseHistories - ?.case_histories.data[0].attributes, - title: 'Valid Case History', - }, - }, - ], - }, + caseHistories: { + ...strapiSolutionListPage.caseHistories, + case_histories: [ + { + ...strapiSolutionListPage.caseHistories?.case_histories[0], + id: 1, + slug: undefined, + title: 'Case History Without Slug', }, - }, + { + ...strapiSolutionListPage.caseHistories?.case_histories[0], + id: 2, + title: 'Valid Case History', + }, + ], }, }; } diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/factories/solutions.ts b/apps/nextjs-website/src/lib/strapi/__tests__/factories/solutions.ts index 4364fee609..385ff733b2 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/factories/solutions.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/factories/solutions.ts @@ -9,18 +9,15 @@ export function minimalDataSolutions() { data: [ { ...strapiSolution, - attributes: { - ...strapiSolution.attributes, - title: 'Minimal Data Solution', - slug: 'minimal-data-solution', - description: undefined, - introductionToSteps: undefined, - steps: [], - stats: [], - statsSource: undefined, - caseHistories: undefined, - seo: undefined, - }, + title: 'Minimal Data Solution', + slug: 'minimal-data-solution', + description: undefined, + introductionToSteps: undefined, + steps: [], + stats: [], + statsSource: undefined, + caseHistories: undefined, + seo: undefined, }, ], } satisfies StrapiSolutions; @@ -33,12 +30,9 @@ export function solutionsWithItemMissingData() { data: [ { ...strapiSolution, - attributes: { - ...strapiSolution.attributes, - title: undefined, - slug: undefined, - description: undefined, - }, + title: undefined, + slug: undefined, + description: undefined, }, ], }; @@ -51,10 +45,7 @@ export function solutionWithItemMissingMandatoryData() { data: [ { ...strapiSolution, - attributes: { - ...strapiSolution.attributes, - icon: { data: undefined }, - }, + icon: undefined, }, ], }; @@ -67,10 +58,7 @@ export function solutionsWithItemWithoutCaseHistories() { data: [ { ...strapiSolution, - attributes: { - ...strapiSolution.attributes, - caseHistories: undefined, - }, + caseHistories: undefined, }, ], } satisfies StrapiSolutions; @@ -83,12 +71,7 @@ export function solutionsWithItemWithoutWebinars() { data: [ { ...strapiSolution, - attributes: { - ...strapiSolution.attributes, - webinars: { - data: [], - }, - }, + webinars: [], }, ], } satisfies StrapiSolutions; @@ -101,83 +84,54 @@ export function solutionsWithItemMissingSolutionSlug() { data: [ { ...strapiSolution, - attributes: { - ...strapiSolution.attributes, - title: 'Solution Without Slug', - slug: undefined as any, - }, + title: 'Solution Without Slug', + slug: undefined as any, }, { ...strapiSolution, - attributes: { - ...strapiSolution.attributes, - title: 'Valid Solution', - slug: 'valid-solution', - }, + title: 'Valid Solution', + slug: 'valid-solution', }, ], } satisfies StrapiSolutions; } -export function solutionsWithItemMissingCaseHistorySlug() { +export function solutionsWithItemMissingCaseHistorySlug(): StrapiSolutions { const strapiSolution = strapiSolutions.data[0]; return { ...strapiSolutions, data: [ { ...strapiSolution, - attributes: { - ...strapiSolution.attributes, - title: 'Solution with Case History Missing Slug', - slug: 'solution-with-case-history-missing-slug', - caseHistories: { - title: 'Success Stories', - description: 'Our success stories', - case_histories: { - data: [ - { - id: 1, - attributes: { - ...strapiSolution.attributes.caseHistories?.case_histories - .data[0].attributes, - title: 'Case History Without Slug', - slug: undefined as any, - image: { - data: { - attributes: { - ...strapiSolution.attributes.caseHistories - ?.case_histories.data[0].attributes.image.data - .attributes, - url: '/test-image.png', - name: 'Test Image', - }, - }, - }, - }, - }, - { - id: 2, - attributes: { - ...strapiSolution.attributes.caseHistories?.case_histories - .data[0].attributes, - title: 'Valid Case History', - slug: 'valid-case-history', - image: { - data: { - attributes: { - ...strapiSolution.attributes.caseHistories - ?.case_histories.data[0].attributes.image.data - .attributes, - url: '/valid-image.png', - name: 'Valid Image', - }, - }, - }, - }, - }, - ], + title: 'Solution with Case History Missing Slug', + slug: 'solution-with-case-history-missing-slug', + caseHistories: { + title: 'Success Stories', + description: 'Our success stories', + case_histories: [ + { + ...strapiSolution?.caseHistories?.case_histories[0], + id: 1, + title: 'Case History Without Slug', + slug: undefined as any, + image: { + ...strapiSolution?.caseHistories?.case_histories[0].image, + url: '/test-image.png', + name: 'Test Image', + }, + }, + { + ...strapiSolution?.caseHistories?.case_histories[0], + id: 2, + title: 'Valid Case History', + slug: 'valid-case-history', + image: { + ...strapiSolution?.caseHistories?.case_histories[0].image, + url: '/valid-image.png', + name: 'Valid Image', + }, }, - }, + ], }, }, ], diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/factories/tutorialListPage.ts b/apps/nextjs-website/src/lib/strapi/__tests__/factories/tutorialListPage.ts index a995b572e1..bbb1bc15c7 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/factories/tutorialListPage.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/factories/tutorialListPage.ts @@ -6,24 +6,15 @@ export function minimalTutorialListPages(): StrapiTutorialListPages { data: [ { id: 1, - attributes: { - title: 'Minimal Tutorials', - description: '', + title: 'Minimal Tutorials', + description: '', + bannerLinks: [], + product: { + ...strapiTutorialListPages.data[0].product!, bannerLinks: [], - product: { - data: { - attributes: { - ...strapiTutorialListPages.data[0].attributes.product.data! - .attributes, - bannerLinks: [], - }, - }, - }, - tutorials: { - data: [], - }, - seo: undefined, }, + tutorials: [], + seo: undefined, }, ], meta: { @@ -42,16 +33,12 @@ export function tutorialListPagesWithItemMissingBannerLinks(): StrapiTutorialLis data: [ { id: 1, - attributes: { - title: 'No Banner Tutorials', - description: 'No banner links', - bannerLinks: [], - product: minimalTutorialListPages().data[0].attributes.product, - tutorials: { - data: [], - }, - seo: undefined, - }, + title: 'No Banner Tutorials', + description: 'No banner links', + bannerLinks: [], + product: minimalTutorialListPages().data[0]!.product, + tutorials: [], + seo: undefined, }, ], meta: { diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/factories/tutorials.ts b/apps/nextjs-website/src/lib/strapi/__tests__/factories/tutorials.ts index 389fc0ff1e..47276b93d9 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/factories/tutorials.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/factories/tutorials.ts @@ -7,18 +7,14 @@ export function tutorialsWithAnItemMissingSlug(): StrapiTutorials { ...strapiTutorials, data: [ { - attributes: { - ...strapiTutorials.data[0].attributes, - title: 'Tutorial Without Slug', - slug: undefined as any, - }, + ...strapiTutorials.data[0], + title: 'Tutorial Without Slug', + slug: undefined as any, }, { - attributes: { - ...strapiTutorials.data[0].attributes, - title: 'Valid Tutorial', - slug: 'valid-tutorial', - }, + ...strapiTutorials.data[0], + title: 'Valid Tutorial', + slug: 'valid-tutorial', }, ], }; @@ -29,35 +25,23 @@ export function tutorialsWithAnItemMissingProductSlug(): StrapiTutorials { ...strapiTutorials, data: [ { - attributes: { - ...strapiTutorials.data[0].attributes, - title: 'Tutorial Without Product Slug', - slug: 'tutorial-without-product-slug', - product: { - data: { - attributes: { - ...strapiTutorials.data[0].attributes.product.data.attributes, - name: 'Product Without Slug', - slug: undefined as any, - }, - }, - }, + ...strapiTutorials.data[0], + title: 'Tutorial Without Product Slug', + slug: 'tutorial-without-product-slug', + product: { + ...strapiTutorials.data[0].product!, + name: 'Product Without Slug', + slug: undefined as any, }, }, { - attributes: { - ...strapiTutorials.data[0].attributes, - title: 'Valid Tutorial', - slug: 'valid-tutorial', - product: { - data: { - attributes: { - ...strapiTutorials.data[0].attributes.product.data.attributes, - name: 'Valid Product', - slug: 'valid-product', - }, - }, - }, + ...strapiTutorials.data[0], + title: 'Valid Tutorial', + slug: 'valid-tutorial', + product: { + ...strapiTutorials.data[0].product!, + name: 'Valid Product', + slug: 'valid-product', }, }, ], @@ -70,17 +54,15 @@ export function minimalDataTutorials() { ...strapiTutorials, data: [ { - attributes: { - ...strapiTutorial.attributes, - title: 'Minimal Data Tutorial', - slug: 'minimal-data-tutorial', - publishedAt: '2023-01-01T00:00:00Z', - locale: 'en-US', - parts: [], - relatedLinks: undefined, - seo: undefined, - image: { data: undefined }, - }, + ...strapiTutorial, + title: 'Minimal Data Tutorial', + slug: 'minimal-data-tutorial', + publishedAt: '2023-01-01T00:00:00Z', + locale: 'en-US', + parts: [], + relatedLinks: undefined, + seo: undefined, + image: undefined, }, ], } satisfies StrapiTutorials; @@ -89,16 +71,13 @@ export function minimalDataTutorials() { export function tutorialsWithItemMissingData() { const strapiTutorial = strapiTutorials.data[0]; return { - strapiTutorials, data: [ { - attributes: { - ...strapiTutorial.attributes, - title: undefined, - slug: undefined, - publishedAt: undefined, - locale: undefined, - }, + ...strapiTutorial, + title: undefined, + slug: undefined, + publishedAt: undefined, + locale: undefined, }, ], }; @@ -108,13 +87,10 @@ export function tutorialsWithItemMissingMandatoryData() { const strapiTutorial = tutorialsWithItemMissingData().data[0]; return { ...strapiTutorials, - data: [ + ...[ { ...strapiTutorial, - attributes: { - ...strapiTutorial.attributes, - product: { data: undefined }, - }, + product: undefined, }, ], }; diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/factories/urlReplaceMap.ts b/apps/nextjs-website/src/lib/strapi/__tests__/factories/urlReplaceMap.ts index d0c0d870a3..be955922d2 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/factories/urlReplaceMap.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/factories/urlReplaceMap.ts @@ -10,18 +10,10 @@ const makeUrlToGuideItem = ( url: 'source-url', subPath: 'sub', guide: { - data: { - attributes: { - title: 'Guide title', - slug: 'guide-slug', - product: { - data: { - attributes: { - slug: 'product-slug', - }, - }, - }, - }, + title: 'Guide title', + slug: 'guide-slug', + product: { + slug: 'product-slug', }, }, ...overrides, @@ -30,41 +22,25 @@ const makeUrlToGuideItem = ( export const urlReplaceMapSingle = ( overrides?: Partial ): StrapiUrlReplaceMap => ({ - data: { - attributes: { - urlToGuide: [makeUrlToGuideItem(overrides)], - }, - }, + urlToGuide: [makeUrlToGuideItem(overrides)], }); export const urlReplaceMapMultiple = (): StrapiUrlReplaceMap => ({ - data: { - attributes: { - urlToGuide: [ - makeUrlToGuideItem({ id: 1, url: 'a', subPath: undefined }), - makeUrlToGuideItem({ - id: 2, - url: 'b', - subPath: 'x', - guide: { - data: { - attributes: { - title: 'T', - slug: 's-2', - product: { data: { attributes: { slug: 'p-2' } } }, - }, - }, - }, - }), - ], - }, - }, + urlToGuide: [ + makeUrlToGuideItem({ id: 1, url: 'a', subPath: undefined }), + makeUrlToGuideItem({ + id: 2, + url: 'b', + subPath: 'x', + guide: { + title: 'T', + slug: 's-2', + product: { slug: 'p-2' }, + }, + }), + ], }); export const urlReplaceMapWithUndefinedGuide = (): StrapiUrlReplaceMap => ({ - data: { - attributes: { - urlToGuide: [makeUrlToGuideItem({ guide: { data: undefined } })], - }, - }, + urlToGuide: [makeUrlToGuideItem({ guide: undefined })], }); diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/factories/useCaseListPage.ts b/apps/nextjs-website/src/lib/strapi/__tests__/factories/useCaseListPage.ts index 80c2e2353b..14783f05dd 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/factories/useCaseListPage.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/factories/useCaseListPage.ts @@ -6,25 +6,16 @@ export function minimalUseCaseListPages(): StrapiUseCaseListPages { data: [ { id: 1, - attributes: { - title: 'Minimal Use Cases', - description: '', + title: 'Minimal Use Cases', + description: '', + bannerLinks: [], + product: { + ...strapiTutorialListPages.data[0].product!, bannerLinks: [], - product: { - data: { - attributes: { - ...strapiTutorialListPages.data[0].attributes.product.data! - .attributes, - bannerLinks: [], - }, - }, - }, - useCases: { - data: [], - }, - seo: undefined, - enableFilters: undefined, }, + useCases: [], + seo: undefined, + enableFilters: undefined, }, ], meta: { @@ -43,17 +34,13 @@ export function useCaseListPagesWithItemMissingBannerLinks(): StrapiUseCaseListP data: [ { id: 1, - attributes: { - title: 'No Banner Tutorials', - description: 'No banner links', - bannerLinks: [], - product: minimalUseCaseListPages().data[0].attributes.product, - useCases: { - data: [], - }, - seo: undefined, - enableFilters: true, - }, + title: 'No Banner Tutorials', + description: 'No banner links', + bannerLinks: [], + product: minimalUseCaseListPages().data[0].product, + useCases: [], + seo: undefined, + enableFilters: true, }, ], meta: { diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/factories/useCases.ts b/apps/nextjs-website/src/lib/strapi/__tests__/factories/useCases.ts index 6244dcd3d5..a0da8d174b 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/factories/useCases.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/factories/useCases.ts @@ -7,18 +7,14 @@ export function useCasesWithAnItemMissingSlug(): StrapiUseCases { ...strapiUseCases, data: [ { - attributes: { - ...strapiUseCases.data[0].attributes, - title: 'UseCase Without Slug', - slug: undefined as any, - }, + ...strapiUseCases.data[0], + title: 'UseCase Without Slug', + slug: undefined as any, }, { - attributes: { - ...strapiUseCases.data[0].attributes, - title: 'Valid UseCase', - slug: 'valid-use-case', - }, + ...strapiUseCases.data[0], + title: 'Valid UseCase', + slug: 'valid-use-case', }, ], }; @@ -29,35 +25,23 @@ export function useCasesWithAnItemMissingProductSlug(): StrapiUseCases { ...strapiUseCases, data: [ { - attributes: { - ...strapiUseCases.data[0].attributes, - title: 'UseCase Without Product Slug', - slug: 'use-case-without-product-slug', - product: { - data: { - attributes: { - ...strapiUseCases.data[0].attributes.product.data.attributes, - name: 'Product Without Slug', - slug: undefined as any, - }, - }, - }, + ...strapiUseCases.data[0], + title: 'UseCase Without Product Slug', + slug: 'use-case-without-product-slug', + product: { + ...strapiUseCases.data[0].product!, + name: 'Product Without Slug', + slug: undefined as any, }, }, { - attributes: { - ...strapiUseCases.data[0].attributes, - title: 'Valid UseCase', - slug: 'valid-use-case', - product: { - data: { - attributes: { - ...strapiUseCases.data[0].attributes.product.data.attributes, - name: 'Valid Product', - slug: 'valid-product', - }, - }, - }, + ...strapiUseCases.data[0], + title: 'Valid UseCase', + slug: 'valid-use-case', + product: { + ...strapiUseCases.data[0].product!, + name: 'Valid Product', + slug: 'valid-product', }, }, ], @@ -70,19 +54,17 @@ export function minimalDataUseCases() { ...strapiUseCases, data: [ { - attributes: { - ...strapiUseCase.attributes, - title: 'Minimal Data UseCase', - subtitle: 'Minimal Data UseCase Subtitle', - slug: 'minimal-data-use-case', - publishedAt: '2023-01-01T00:00:00Z', - locale: 'en-US', - parts: [], - relatedLinks: undefined, - seo: undefined, - coverImage: { data: undefined }, - headerImage: { data: undefined }, - }, + ...strapiUseCase, + title: 'Minimal Data UseCase', + subtitle: 'Minimal Data UseCase Subtitle', + slug: 'minimal-data-use-case', + publishedAt: '2023-01-01T00:00:00Z', + locale: 'en-US', + parts: [], + relatedLinks: undefined, + seo: undefined, + coverImage: undefined, + headerImage: undefined, }, ], } satisfies StrapiUseCases; @@ -91,16 +73,14 @@ export function minimalDataUseCases() { export function useCasesWithItemMissingData() { const strapiUseCase = strapiUseCases.data[0]; return { - strapiUseCases, + ...strapiUseCases, data: [ { - attributes: { - ...strapiUseCase.attributes, - title: undefined, - slug: undefined, - publishedAt: undefined, - locale: undefined, - }, + ...strapiUseCase, + title: undefined, + slug: undefined, + publishedAt: undefined, + locale: undefined, }, ], }; @@ -113,10 +93,7 @@ export function useCasesWithItemMissingMandatoryData() { data: [ { ...useCase, - attributes: { - ...useCase.attributes, - product: { data: undefined }, - }, + product: undefined, }, ], }; diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/apiDataList.ts b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/apiDataList.ts index 7bb3f93a55..a005eaab2b 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/apiDataList.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/apiDataList.ts @@ -3,108 +3,88 @@ import { ApiDataPageProps } from '@/app/[locale]/[productSlug]/api/[apiDataSlug] import { generateBannerLinks } from '@/lib/strapi/__tests__/factories/bannerLink'; import { mediaJpeg } from '../factories/media'; -export const strapiApiDataList: StrapiApiDataList = { - data: [ - { - id: 3, - attributes: { - seo: { - metaTitle: 'SEND Main API', - metaDescription: 'SEND Main API Documentation', - }, - title: 'SEND Main', - description: 'Main SEND API for delivery notifications', - apiSoapDetail: undefined, - apiRestDetail: { - slug: 'send-main', - specUrls: [ - { - id: 3, - url: 'https://raw.githubusercontent.com/pagopa/pn-delivery/pn-openapi-devportal/docs/openapi/api-external-b2b-pa-bundle.yaml', - name: 'Main API', - hideTryIt: true, - }, - ], - }, - tags: { data: undefined }, - icon: { - data: mediaJpeg(), - }, - product: { - data: { - attributes: { - isVisible: true, - name: 'Test Product', - slug: 'test-product', - tags: { data: [] }, - shortName: 'TP', - bannerLinks: generateBannerLinks(1), - overview: { data: { id: 0 } }, - quickstart_guide: { data: { id: 0 } }, - api_data_list_page: { data: undefined }, - guide_list_page: { data: { id: 0 } }, - tutorial_list_page: { data: { id: 0 } }, - release_note: { data: { id: 0 } }, - use_case_list_page: { data: { id: 0 } }, - }, - }, - }, - bannerLinks: generateBannerLinks(2), - }, +export const strapiApiDataList: StrapiApiDataList = [ + { + id: 3, + seo: { + metaTitle: 'SEND Main API', + metaDescription: 'SEND Main API Documentation', }, - { - id: 7, - attributes: { - seo: undefined, - title: 'Documentazione SOAP', - description: - 'Consulta tutti gli schemi XSD e WSDL che seguono le diverse release SANP', - apiRestDetail: undefined, - apiSoapDetail: { - repositoryUrl: 'https://github.com/pagopa/pagopa-api/', - dirName: 'pagopa-api', - slug: 'pagopa-soap-api', - }, - icon: { - data: { - attributes: { - name: 'Code.svg', - alternativeText: undefined, - caption: undefined, - width: 48, - height: 48, - ext: '.svg', - mime: 'image/svg+xml', - size: 0.24, - url: 'https://cdn.dev.developer.pagopa.it/Code_7ebfbd1657.svg', - }, - }, - }, - tags: { data: undefined }, - product: { - data: { - attributes: { - isVisible: true, - name: 'SOAP Product', - slug: 'soap-product', - shortName: 'SP', - tags: { data: [] }, - bannerLinks: generateBannerLinks(1), - overview: { data: { id: 0 } }, - quickstart_guide: { data: { id: 0 } }, - api_data_list_page: { data: undefined }, - guide_list_page: { data: { id: 0 } }, - tutorial_list_page: { data: { id: 0 } }, - release_note: { data: { id: 0 } }, - use_case_list_page: { data: { id: 0 } }, - }, - }, + title: 'SEND Main', + description: 'Main SEND API for delivery notifications', + apiSoapDetail: undefined, + apiRestDetail: { + slug: 'send-main', + specUrls: [ + { + id: 3, + url: 'https://raw.githubusercontent.com/pagopa/pn-delivery/pn-openapi-devportal/docs/openapi/api-external-b2b-pa-bundle.yaml', + name: 'Main API', + hideTryIt: true, }, - bannerLinks: [], - }, + ], }, - ], -}; + tags: undefined, + icon: { ...mediaJpeg() }, + product: { + isVisible: true, + name: 'Test Product', + slug: 'test-product', + tags: [], + shortName: 'TP', + bannerLinks: generateBannerLinks(1), + overview: 0, + quickstart_guide: 0, + api_data_list_page: undefined, + guide_list_page: 0, + tutorial_list_page: 0, + release_note: 0, + use_case_list_page: 0, + }, + bannerLinks: generateBannerLinks(2), + }, + { + id: 7, + seo: undefined, + title: 'Documentazione SOAP', + description: + 'Consulta tutti gli schemi XSD e WSDL che seguono le diverse release SANP', + apiRestDetail: undefined, + apiSoapDetail: { + repositoryUrl: 'https://github.com/pagopa/pagopa-api/', + dirName: 'pagopa-api', + slug: 'pagopa-soap-api', + }, + icon: { + name: 'Code.svg', + alternativeText: undefined, + caption: undefined, + width: 48, + height: 48, + ext: '.svg', + mime: 'image/svg+xml', + size: 0.24, + url: 'https://cdn.dev.developer.pagopa.it/Code_7ebfbd1657.svg', + }, + tags: [], + product: { + isVisible: true, + name: 'SOAP Product', + slug: 'soap-product', + shortName: 'SP', + tags: [], + bannerLinks: generateBannerLinks(1), + overview: 0, + quickstart_guide: 0, + api_data_list_page: undefined, + guide_list_page: 0, + tutorial_list_page: 0, + release_note: 0, + use_case_list_page: 0, + }, + bannerLinks: [], + }, +]; export const expectedApiDataPageProps: ReadonlyArray = [ { diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/apiDataListPages.ts b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/apiDataListPages.ts index 6aa18e1c8d..3a10b7ae95 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/apiDataListPages.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/apiDataListPages.ts @@ -3,107 +3,83 @@ import { ApiDataListPageTemplateProps } from '@/components/templates/ApiDataList import { generateBannerLinks } from '@/lib/strapi/__tests__/factories/bannerLink'; import { mediaJpeg } from '../factories/media'; -export const strapiApiDataListPages = { - data: [ - { - id: 1, - attributes: { - title: 'SEND API Documentation', - description: 'Complete documentation for SEND APIs', - seo: { - metaTitle: 'SEND API Documentation', - metaDescription: 'Complete documentation for SEND APIs', - }, - bannerLinks: generateBannerLinks(2), - updatedAt: '2024-01-02T00:00:00.000Z', - product: { - data: { - attributes: { - isVisible: true, - name: 'SEND', - slug: 'send', - shortName: 'SEND', - bannerLinks: generateBannerLinks(1), - overview: { data: { id: 1 } }, - quickstart_guide: { data: { id: 1 } }, - api_data_list_page: { - data: { - id: 1, - attributes: { - apiData: { - data: [], - }, - }, - }, - }, - guide_list_page: { data: { id: 1 } }, - tutorial_list_page: { data: { id: 1 } }, - release_note: { data: { id: 1 } }, - use_case_list_page: { data: { id: 1 } }, - tags: { data: [] }, - }, - }, - }, - apiData: { - data: [ +export const strapiApiDataListPages: StrapiApiDataListPages = [ + { + id: 1, + title: 'SEND API Documentation', + description: 'Complete documentation for SEND APIs', + seo: { + metaTitle: 'SEND API Documentation', + metaDescription: 'Complete documentation for SEND APIs', + }, + bannerLinks: generateBannerLinks(2), + updatedAt: '2024-01-02T00:00:00.000Z', + product: { + isVisible: true, + name: 'SEND', + slug: 'send', + shortName: 'SEND', + bannerLinks: generateBannerLinks(1), + overview: 1, + quickstart_guide: 1, + api_data_list_page: { + id: 1, + api_data: [], + }, + guide_list_page: 1, + tutorial_list_page: 1, + release_note: 1, + use_case_list_page: 1, + tags: [], + }, + api_data: [ + { + id: 1, + bannerLinks: [], + title: 'SEND Main API', + description: 'Main SEND API for delivery notifications', + icon: mediaJpeg(), + apiRestDetail: { + slug: 'send-main', + specUrls: [ { id: 1, - attributes: { - title: 'SEND Main API', - description: 'Main SEND API for delivery notifications', - icon: { - data: mediaJpeg(), - }, - apiRestDetail: { - slug: 'send-main', - specUrls: [ - { - id: 1, - url: 'https://example.com/api.yaml', - name: 'Main API', - hideTryIt: false, - }, - ], - }, - apiSoapDetail: undefined, - tags: { data: undefined }, - }, - }, - { - id: 2, - attributes: { - title: 'SEND SOAP API', - description: 'SOAP API for legacy integrations', - icon: { - data: { - attributes: { - name: 'soap-icon.svg', - alternativeText: 'SOAP Icon', - caption: undefined, - width: 48, - height: 48, - ext: '.svg', - mime: 'image/svg+xml', - size: 0.5, - url: 'https://example.com/soap-icon.svg', - }, - }, - }, - apiRestDetail: undefined, - apiSoapDetail: { - slug: 'send-soap', - repositoryUrl: 'https://github.com/pagopa/send-soap', - dirName: 'send-soap', - }, - tags: { data: undefined }, - }, + url: 'https://example.com/api.yaml', + name: 'Main API', + hideTryIt: false, }, ], }, + apiSoapDetail: undefined, + tags: undefined, }, - }, - ], -} satisfies StrapiApiDataListPages; + { + id: 2, + bannerLinks: [], + title: 'SEND SOAP API', + description: 'SOAP API for legacy integrations', + icon: { + name: 'soap-icon.svg', + alternativeText: 'SOAP Icon', + caption: undefined, + width: 48, + height: 48, + ext: '.svg', + mime: 'image/svg+xml', + size: 0.5, + url: 'https://example.com/soap-icon.svg', + }, + apiRestDetail: undefined, + apiSoapDetail: { + slug: 'send-soap', + repositoryUrl: 'https://github.com/pagopa/send-soap', + dirName: 'send-soap', + }, + tags: undefined, + }, + ], + }, +]; export const expectedApiDataListPageProps: ReadonlyArray = [ @@ -142,8 +118,6 @@ export const expectedApiDataListPageProps: ReadonlyArray = { data: [ { id: 1, - attributes: { - slug: 'case-history-title', - title: 'Case History Title', - description: 'Case history description', - publishedAt: '2024-01-01T00:00:00.000Z', - updatedAt: '2024-01-02T00:00:00.000Z', - image: { data: mediaJpeg() }, - products: { - data: [ - { - attributes: { - ...product, - logo: { - data: mediaJpeg(), - }, - }, - }, - ], + slug: 'case-history-title', + title: 'Case History Title', + description: 'Case history description', + publishedAt: '2024-01-01T00:00:00.000Z', + updatedAt: '2024-01-02T00:00:00.000Z', + image: mediaJpeg(), + products: [ + { + ...product, + logo: mediaJpeg(), }, - parts: [ - { - __component: 'parts.code-block', - code: 'console.log("Hello World");', - language: 'javascript', - showLineNumbers: true, - }, - ], - seo: { - metaTitle: 'SEO Title', - metaDescription: 'SEO Description', + ], + parts: [ + { + __component: 'parts.code-block', + code: 'console.log("Hello World");', + language: 'javascript', + showLineNumbers: true, }, + ], + seo: { + metaTitle: 'SEO Title', + metaDescription: 'SEO Description', }, }, ], @@ -56,12 +49,12 @@ export const caseHistoriesPageTemplateProps: CaseHistoryPageTemplateProps = { title: 'Case History Title', description: 'Case history description', updatedAt: '2024-01-02T00:00:00.000Z', - image: mediaJpeg().attributes, + image: mediaJpeg(), products: [ { name: product.name, slug: product.slug, - logo: mediaJpeg().attributes, + logo: mediaJpeg(), }, ], parts: [ diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/guideListPages.ts b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/guideListPages.ts index 07fda9a951..f523235bb2 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/guideListPages.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/guideListPages.ts @@ -20,398 +20,286 @@ export const strapiGuideListPagesData = { data: [ { id: 48, - attributes: { - title: 'Guide e manuali', - description: - 'Per una conoscenza approfondita o dubbi puntuali, consulta i manuali e le guide disponibili per la piattaforma pagoPA.\n\n', - product: { - data: { - attributes: { - isVisible: true, - tags: { data: [] }, - name: 'Piattaforma pagoPA', - slug: 'pago-pa', - shortName: 'pagoPA', - bannerLinks: [ - { - id: 384, - title: 'Serve aiuto?', - content: [ - { - type: 'paragraph', - children: [ - { - text: 'Apri un ticket utilizzando l’apposita funzione all’interno della tua ', - type: 'text', - }, - { - url: 'https://selfcare.pagopa.it/auth/login?onSuccess=%2F', - type: 'link', - children: [ - { - text: 'Area Riservata', - type: 'text', - }, - ], - }, - { - text: '', - type: 'text', - }, - ], - }, - ], - theme: 'dark', - icon: { - data: { - attributes: { - name: 'headset_78d50d9321_5bd20d1a6b.svg', - alternativeText: undefined, - caption: undefined, - width: 24, - height: 24, - ext: '.svg', - mime: 'image/svg+xml', - size: 0.31, - url: 'http://0.0.0.0:1337/uploads/headset_78d50d9321_5bd20d1a6b_6d5b8d3ee1.svg', - }, - }, + title: 'Guide e manuali', + description: + 'Per una conoscenza approfondita o dubbi puntuali, consulta i manuali e le guide disponibili per la piattaforma pagoPA.\n\n', + product: { + isVisible: true, + tags: [], + name: 'Piattaforma pagoPA', + slug: 'pago-pa', + shortName: 'pagoPA', + bannerLinks: [ + { + id: 384, + title: 'Serve aiuto?', + content: [ + { + type: 'paragraph', + children: [ + { + text: 'Apri un ticket utilizzando l’apposita funzione all’interno della tua ', + type: 'text', }, - }, - { - id: 385, - title: 'Dicci cosa ne pensi', - content: [ - { - type: 'paragraph', - children: [ - { - text: 'Per chiarimenti sulle specifiche d’implementazione, come SACI e SANP, puoi aprire una segnalazione su ', - type: 'text', - }, - { - url: 'https://github.com/pagopa/pagopa-api/issues', - type: 'link', - children: [ - { - text: 'GitHub', - type: 'text', - }, - ], - }, - { - text: '', - type: 'text', - }, - ], - }, - ], - theme: 'light', - icon: { - data: { - attributes: { - name: 'feedback_1504fc4fbf.svg', - alternativeText: undefined, - caption: undefined, - width: 24, - height: 24, - ext: '.svg', - mime: 'image/svg+xml', - size: 0.26, - url: 'http://0.0.0.0:1337/uploads/feedback_1504fc4fbf_042ed8f78b.svg', + { + url: 'https://selfcare.pagopa.it/auth/login?onSuccess=%2F', + type: 'link', + children: [ + { + text: 'Area Riservata', + type: 'text', }, - }, + ], }, - }, - ], - overview: { - data: { - id: 48, - }, - }, - quickstart_guide: { - data: { - id: 48, - }, - }, - release_note: { - data: undefined, - }, - api_data_list_page: { - data: { - id: 45, - attributes: { - apiData: { - data: [ - { - attributes: { - apiRestDetail: undefined, - apiSoapDetail: undefined, - }, - }, - { - attributes: { - apiRestDetail: { - slug: 'gestione-posizioni-debitorie', - specUrls: [ - { - id: 1, - name: 'Specifica API REST', - url: 'https://raw.githubusercontent.com/pagopa/pagopa-api/master/specs/gestione-posizioni-debitorie.yaml', - hideTryIt: false, - }, - ], - }, - apiSoapDetail: undefined, - }, - }, - { - attributes: { - apiRestDetail: undefined, - apiSoapDetail: undefined, - }, - }, - { - attributes: { - apiRestDetail: undefined, - apiSoapDetail: undefined, - }, - }, - { - attributes: { - apiSoapDetail: undefined, - apiRestDetail: undefined, - }, - }, - { - attributes: { - apiRestDetail: undefined, - apiSoapDetail: undefined, - }, - }, - { - attributes: { - apiRestDetail: undefined, - apiSoapDetail: undefined, - }, - }, - { - attributes: { - apiRestDetail: undefined, - apiSoapDetail: undefined, - }, - }, - { - attributes: { - apiRestDetail: undefined, - apiSoapDetail: undefined, - }, - }, - { - attributes: { - apiRestDetail: undefined, - apiSoapDetail: undefined, - }, - }, - { - attributes: { - apiRestDetail: undefined, - apiSoapDetail: undefined, - }, - }, - ], - }, + { + text: '', + type: 'text', }, - }, - }, - guide_list_page: { - data: { - id: 48, - }, - }, - tutorial_list_page: { - data: { - id: 48, - }, - }, - use_case_list_page: { - data: { - id: 42, - }, + ], }, + ], + theme: 'dark', + icon: { + name: 'headset_78d50d9321_5bd20d1a6b.svg', + alternativeText: undefined, + caption: undefined, + width: 24, + height: 24, + ext: '.svg', + mime: 'image/svg+xml', + size: 0.31, + url: 'http://0.0.0.0:1337/uploads/headset_78d50d9321_5bd20d1a6b_6d5b8d3ee1.svg', }, }, - }, - guidesByCategory: [ { - category: "Per l'integrazione", - guides: { - data: [ - { - attributes: { - title: 'SACI', - slug: 'saci', - listItems: [ - { - text: 'Genera un codice IUV', - }, - { - text: 'Comprendi la gestione delle operazioni di trasferimento fondi', - }, - { - text: 'Crea il flusso di rendicontazione', - }, + id: 385, + title: 'Dicci cosa ne pensi', + content: [ + { + type: 'paragraph', + children: [ + { + text: 'Per chiarimenti sulle specifiche d’implementazione, come SACI e SANP, puoi aprire una segnalazione su ', + type: 'text', + }, + { + url: 'https://github.com/pagopa/pagopa-api/issues', + type: 'link', + children: [ { - text: 'Riconcilia il flusso dei pagamenti', + text: 'GitHub', + type: 'text', }, ], - image: { - data: { - attributes: { - name: 'pagoPA Guide Manual.png', - alternativeText: undefined, - caption: undefined, - width: 1156, - height: 580, - ext: '.png', - mime: 'image/png', - size: 236.84, - url: 'http://0.0.0.0:1337/uploads/pago_PA_Guide_Manual_4246ba7771.png', - }, - }, - }, - mobileImage: { - data: { - attributes: { - name: 'saci.png', - alternativeText: undefined, - caption: undefined, - width: 1156, - height: 580, - ext: '.png', - mime: 'image/png', - size: 236.84, - url: 'http://0.0.0.0:1337/uploads/saci_9d9358115d.png', - }, - }, - }, }, + { + text: '', + type: 'text', + }, + ], + }, + ], + theme: 'light', + icon: { + name: 'feedback_1504fc4fbf.svg', + alternativeText: undefined, + caption: undefined, + width: 24, + height: 24, + ext: '.svg', + mime: 'image/svg+xml', + size: 0.26, + url: 'http://0.0.0.0:1337/uploads/feedback_1504fc4fbf_042ed8f78b.svg', + }, + }, + ], + overview: 48, + quickstart_guide: 48, + release_note: undefined, + api_data_list_page: { + id: 45, + api_data: [ + { + apiRestDetail: undefined, + apiSoapDetail: undefined, + }, + { + apiRestDetail: { + slug: 'gestione-posizioni-debitorie', + specUrls: [ + { + id: 1, + name: 'Specifica API REST', + url: 'https://raw.githubusercontent.com/pagopa/pagopa-api/master/specs/gestione-posizioni-debitorie.yaml', + hideTryIt: false, + }, + ], + }, + apiSoapDetail: undefined, + }, + { + apiRestDetail: undefined, + apiSoapDetail: undefined, + }, + { + apiRestDetail: undefined, + apiSoapDetail: undefined, + }, + { + apiSoapDetail: undefined, + apiRestDetail: undefined, + }, + { + apiRestDetail: undefined, + apiSoapDetail: undefined, + }, + { + apiRestDetail: undefined, + apiSoapDetail: undefined, + }, + { + apiRestDetail: undefined, + apiSoapDetail: undefined, + }, + { + apiRestDetail: undefined, + apiSoapDetail: undefined, + }, + { + apiRestDetail: undefined, + apiSoapDetail: undefined, + }, + { + apiRestDetail: undefined, + apiSoapDetail: undefined, + }, + ], + }, + guide_list_page: 48, + tutorial_list_page: 48, + use_case_list_page: 42, + }, + guidesByCategory: [ + { + category: "Per l'integrazione", + guides: [ + { + title: 'SACI', + slug: 'saci', + listItems: [ + { text: 'Genera un codice IUV' }, + { + text: 'Comprendi la gestione delle operazioni di trasferimento fondi', }, + { text: 'Crea il flusso di rendicontazione' }, + { text: 'Riconcilia il flusso dei pagamenti' }, + ], + image: { + name: 'pagoPA Guide Manual.png', + alternativeText: undefined, + caption: undefined, + width: 1156, + height: 580, + ext: '.png', + mime: 'image/png', + size: 236.84, + url: 'http://0.0.0.0:1337/uploads/pago_PA_Guide_Manual_4246ba7771.png', + }, + mobileImage: { + name: 'saci.png', + alternativeText: undefined, + caption: undefined, + width: 1156, + height: 580, + ext: '.png', + mime: 'image/png', + size: 236.84, + url: 'http://0.0.0.0:1337/uploads/saci_9d9358115d.png', + }, + }, + { + title: 'SANP', + slug: 'sanp', + listItems: [ + { text: 'Conosci, usa e gestisci il prodotto pagoPA' }, { - attributes: { - title: 'SANP', - slug: 'sanp', - listItems: [ - { - text: 'Conosci, usa e gestisci il prodotto pagoPA', - }, - { - text: 'Esplora i principali casi d’uso per PSP ed Enti Creditori', - }, - { - text: 'Scopri come un Ente Creditore può aderire e integrarsi in pagoPA', - }, - { - text: 'Scopri come un PSP può aderire e integrarsi in pagoPA', - }, - ], - image: { - data: { - attributes: { - name: 'sanp.png', - alternativeText: undefined, - caption: undefined, - width: 1156, - height: 580, - ext: '.png', - mime: 'image/png', - size: 237.14, - url: 'http://0.0.0.0:1337/uploads/sanp_b68c5c1525.png', - }, - }, - }, - mobileImage: { - data: { - attributes: { - name: 'sanp.png', - alternativeText: undefined, - caption: undefined, - width: 1156, - height: 580, - ext: '.png', - mime: 'image/png', - size: 237.14, - url: 'http://0.0.0.0:1337/uploads/sanp_b68c5c1525.png', - }, - }, - }, - }, + text: 'Esplora i principali casi d’uso per PSP ed Enti Creditori', + }, + { + text: 'Scopri come un Ente Creditore può aderire e integrarsi in pagoPA', + }, + { + text: 'Scopri come un PSP può aderire e integrarsi in pagoPA', }, ], + image: { + name: 'sanp.png', + alternativeText: undefined, + caption: undefined, + width: 1156, + height: 580, + ext: '.png', + mime: 'image/png', + size: 237.14, + url: 'http://0.0.0.0:1337/uploads/sanp_b68c5c1525.png', + }, + mobileImage: { + name: 'sanp.png', + alternativeText: undefined, + caption: undefined, + width: 1156, + height: 580, + ext: '.png', + mime: 'image/png', + size: 237.14, + url: 'http://0.0.0.0:1337/uploads/sanp_b68c5c1525.png', + }, }, - }, - { - category: "Per l'utilizzo", - guides: { - data: [ + ], + }, + { + category: "Per l'utilizzo", + guides: [ + { + title: 'Guida tecnica sugli avvisi di pagamento pagoPA', + slug: 'avviso-pagamento', + listItems: [ + { text: 'Scopri come si crea un avviso di pagamento' }, + { text: 'Usa i modelli grafici per la creazione di un avviso' }, + { text: 'Visualizza alcuni esempi' }, { - attributes: { - title: 'Guida tecnica sugli avvisi di pagamento pagoPA', - slug: 'avviso-pagamento', - listItems: [ - { - text: 'Scopri come si crea un avviso di pagamento', - }, - { - text: 'Usa i modelli grafici per la creazione di un avviso', - }, - { - text: 'Visualizza alcuni esempi', - }, - { - text: 'Consulta le indicazioni per la produzione di un avviso di pagamento', - }, - ], - image: { - data: { - attributes: { - name: 'guida-tecnica-sugli-avvisi-di-pagamento.png', - alternativeText: undefined, - caption: undefined, - width: 1156, - height: 580, - ext: '.png', - mime: 'image/png', - size: 68.58, - url: 'http://0.0.0.0:1337/uploads/guida_tecnica_sugli_avvisi_di_pagamento_df77a98f5f.png', - }, - }, - }, - mobileImage: { - data: { - attributes: { - name: 'guida-tecnica-sugli-avvisi-di-pagamento.png', - alternativeText: undefined, - caption: undefined, - width: 1156, - height: 580, - ext: '.png', - mime: 'image/png', - size: 68.58, - url: 'http://0.0.0.0:1337/uploads/guida_tecnica_sugli_avvisi_di_pagamento_df77a98f5f.png', - }, - }, - }, - }, + text: 'Consulta le indicazioni per la produzione di un avviso di pagamento', }, ], + image: { + name: 'guida-tecnica-sugli-avvisi-di-pagamento.png', + alternativeText: undefined, + caption: undefined, + width: 1156, + height: 580, + ext: '.png', + mime: 'image/png', + size: 68.58, + url: 'http://0.0.0.0:1337/uploads/guida_tecnica_sugli_avvisi_di_pagamento_df77a98f5f.png', + }, + mobileImage: { + name: 'guida-tecnica-sugli-avvisi-di-pagamento.png', + alternativeText: undefined, + caption: undefined, + width: 1156, + height: 580, + ext: '.png', + mime: 'image/png', + size: 68.58, + url: 'http://0.0.0.0:1337/uploads/guida_tecnica_sugli_avvisi_di_pagamento_df77a98f5f.png', + }, }, - }, - ], - bannerLinks: [], - seo: undefined, - updatedAt: dateNow, - }, + ], + }, + ], + bannerLinks: [], + seo: undefined, + updatedAt: dateNow, }, ], meta: { diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/guides.ts b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/guides.ts index 40ceb83815..f7163b9028 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/guides.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/guides.ts @@ -17,297 +17,144 @@ export const strapiEmptyGuideData = { export const strapiGuideData = { data: [ { - attributes: { - title: 'SACI', - slug: 'saci', - image: { - data: { - attributes: { - name: 'pagoPA Guide Manual.png', - alternativeText: undefined, - caption: undefined, - width: 1156, - height: 580, - ext: '.png', - mime: 'image/png', - size: 236.84, - url: 'http://0.0.0.0:1337/uploads/pago_PA_Guide_Manual_4246ba7771.png', - }, - }, + title: 'SACI', + slug: 'saci', + image: { + name: 'pagoPA Guide Manual.png', + alternativeText: undefined, + caption: undefined, + width: 1156, + height: 580, + ext: '.png', + mime: 'image/png', + size: 236.84, + url: 'http://0.0.0.0:1337/uploads/pago_PA_Guide_Manual_4246ba7771.png', + }, + mobileImage: { + name: 'saci.png', + alternativeText: undefined, + caption: undefined, + width: 1156, + height: 580, + ext: '.png', + mime: 'image/png', + size: 236.84, + url: 'http://0.0.0.0:1337/uploads/saci_9d9358115d.png', + }, + listItems: [ + { text: 'Genera un codice IUV' }, + { + text: 'Comprendi la gestione delle operazioni di trasferimento fondi', }, - mobileImage: { - data: { - attributes: { - name: 'saci.png', + { text: 'Crea il flusso di rendicontazione' }, + { text: 'Riconcilia il flusso dei pagamenti' }, + ], + versions: [ + { main: true, dirName: 'QdpcBdgV6Vin3SHiZyFM', version: '3.2.1' }, + { main: false, dirName: 'PXEYBQEZ9LagztJLF89O', version: '3.2.0' }, + { main: false, dirName: 'w0Q7L4P8ucTWqcitlbkJ', version: '3.1.0' }, + { main: false, dirName: 'NwSwJx0PH25LtVO7RbF5', version: '3.0.1' }, + { main: false, dirName: 'Dny2DKfeNer5ENutRdSp', version: '3.0.0' }, + { main: false, dirName: 'E6d6iTzjBzUfzNoZjadZ', version: '2.0.0' }, + ], + bannerLinks: [], + seo: undefined, + product: { + isVisible: true, + name: 'Piattaforma pagoPA', + slug: 'pago-pa', + shortName: 'pagoPA', + bannerLinks: [ + { + id: 384, + title: 'Serve aiuto?', + content: [ + { + type: 'paragraph', + children: [ + { + text: 'Apri un ticket utilizzando l’apposita funzione all’interno della tua ', + type: 'text', + }, + { + url: 'https://selfcare.pagopa.it/auth/login?onSuccess=%2F', + type: 'link', + children: [{ text: 'Area Riservata', type: 'text' }], + }, + { text: '', type: 'text' }, + ], + }, + ], + theme: 'dark', + icon: { + name: 'headset_78d50d9321_5bd20d1a6b.svg', alternativeText: undefined, caption: undefined, - width: 1156, - height: 580, - ext: '.png', - mime: 'image/png', - size: 236.84, - url: 'http://0.0.0.0:1337/uploads/saci_9d9358115d.png', + width: 24, + height: 24, + ext: '.svg', + mime: 'image/svg+xml', + size: 0.31, + url: 'http://0.0.0.0:1337/uploads/headset_78d50d9321_5bd20d1a6b_6d5b8d3ee1.svg', }, }, - }, - listItems: [ - { - text: 'Genera un codice IUV', - }, - { - text: 'Comprendi la gestione delle operazioni di trasferimento fondi', - }, - { - text: 'Crea il flusso di rendicontazione', - }, - { - text: 'Riconcilia il flusso dei pagamenti', - }, - ], - versions: [ - { - main: true, - dirName: 'QdpcBdgV6Vin3SHiZyFM', - version: '3.2.1', - }, - { - main: false, - dirName: 'PXEYBQEZ9LagztJLF89O', - version: '3.2.0', - }, { - main: false, - dirName: 'w0Q7L4P8ucTWqcitlbkJ', - version: '3.1.0', - }, - { - main: false, - dirName: 'NwSwJx0PH25LtVO7RbF5', - version: '3.0.1', - }, - { - main: false, - dirName: 'Dny2DKfeNer5ENutRdSp', - version: '3.0.0', - }, - { - main: false, - dirName: 'E6d6iTzjBzUfzNoZjadZ', - version: '2.0.0', - }, - ], - bannerLinks: [], - seo: undefined, - product: { - data: { - attributes: { - isVisible: true, - name: 'Piattaforma pagoPA', - slug: 'pago-pa', - shortName: 'pagoPA', - bannerLinks: [ - { - id: 384, - title: 'Serve aiuto?', - content: [ - { - type: 'paragraph', - children: [ - { - text: 'Apri un ticket utilizzando l’apposita funzione all’interno della tua ', - type: 'text', - }, - { - url: 'https://selfcare.pagopa.it/auth/login?onSuccess=%2F', - type: 'link', - children: [ - { - text: 'Area Riservata', - type: 'text', - }, - ], - }, - { - text: '', - type: 'text', - }, - ], - }, - ], - theme: 'dark', - icon: { - data: { - attributes: { - name: 'headset_78d50d9321_5bd20d1a6b.svg', - alternativeText: undefined, - caption: undefined, - width: 24, - height: 24, - ext: '.svg', - mime: 'image/svg+xml', - size: 0.31, - url: 'http://0.0.0.0:1337/uploads/headset_78d50d9321_5bd20d1a6b_6d5b8d3ee1.svg', - }, - }, + id: 385, + title: 'Dicci cosa ne pensi', + content: [ + { + type: 'paragraph', + children: [ + { + text: 'Per chiarimenti sulle specifiche d’implementazione, come SACI e SANP, puoi aprire una segnalazione su ', + type: 'text', }, - }, - { - id: 385, - title: 'Dicci cosa ne pensi', - content: [ - { - type: 'paragraph', - children: [ - { - text: 'Per chiarimenti sulle specifiche d’implementazione, come SACI e SANP, puoi aprire una segnalazione su ', - type: 'text', - }, - { - url: 'https://github.com/pagopa/pagopa-api/issues', - type: 'link', - children: [ - { - text: 'GitHub', - type: 'text', - }, - ], - }, - { - text: '', - type: 'text', - }, - ], - }, - ], - theme: 'light', - icon: { - data: { - attributes: { - name: 'feedback_1504fc4fbf.svg', - alternativeText: undefined, - caption: undefined, - width: 24, - height: 24, - ext: '.svg', - mime: 'image/svg+xml', - size: 0.26, - url: 'http://0.0.0.0:1337/uploads/feedback_1504fc4fbf_042ed8f78b.svg', - }, - }, + { + url: 'https://github.com/pagopa/pagopa-api/issues', + type: 'link', + children: [{ text: 'GitHub', type: 'text' }], }, - }, - ], - overview: { - data: { - id: 48, - }, - }, - quickstart_guide: { - data: { - id: 48, - }, - }, - release_note: { - data: undefined, - }, - api_data_list_page: { - data: { - id: 45, - attributes: { - apiData: { - data: [ - { - attributes: { - apiRestDetail: undefined, - apiSoapDetail: undefined, - }, - }, - { - attributes: { - apiRestDetail: undefined, - apiSoapDetail: undefined, - }, - }, - { - attributes: { - apiRestDetail: undefined, - apiSoapDetail: undefined, - }, - }, - { - attributes: { - apiRestDetail: undefined, - apiSoapDetail: undefined, - }, - }, - { - attributes: { - apiRestDetail: undefined, - apiSoapDetail: undefined, - }, - }, - { - attributes: { - apiRestDetail: undefined, - apiSoapDetail: undefined, - }, - }, - { - attributes: { - apiRestDetail: undefined, - apiSoapDetail: undefined, - }, - }, - { - attributes: { - apiRestDetail: undefined, - apiSoapDetail: undefined, - }, - }, - { - attributes: { - apiRestDetail: undefined, - apiSoapDetail: undefined, - }, - }, - { - attributes: { - apiRestDetail: undefined, - apiSoapDetail: undefined, - }, - }, - { - attributes: { - apiRestDetail: undefined, - apiSoapDetail: undefined, - }, - }, - ], - }, - }, - }, - }, - guide_list_page: { - data: { - id: 48, - }, - }, - tutorial_list_page: { - data: { - id: 48, - }, - }, - use_case_list_page: { - data: { - id: 42, - }, - }, - tags: { - data: [], + { text: '', type: 'text' }, + ], }, + ], + theme: 'light', + icon: { + name: 'feedback_1504fc4fbf.svg', + alternativeText: undefined, + caption: undefined, + width: 24, + height: 24, + ext: '.svg', + mime: 'image/svg+xml', + size: 0.26, + url: 'http://0.0.0.0:1337/uploads/feedback_1504fc4fbf_042ed8f78b.svg', }, }, + ], + overview: 48, + quickstart_guide: 48, + release_note: undefined, + api_data_list_page: { + id: 45, + api_data: [ + { apiRestDetail: undefined, apiSoapDetail: undefined }, + { apiRestDetail: undefined, apiSoapDetail: undefined }, + { apiRestDetail: undefined, apiSoapDetail: undefined }, + { apiRestDetail: undefined, apiSoapDetail: undefined }, + { apiRestDetail: undefined, apiSoapDetail: undefined }, + { apiRestDetail: undefined, apiSoapDetail: undefined }, + { apiRestDetail: undefined, apiSoapDetail: undefined }, + { apiRestDetail: undefined, apiSoapDetail: undefined }, + { apiRestDetail: undefined, apiSoapDetail: undefined }, + { apiRestDetail: undefined, apiSoapDetail: undefined }, + { apiRestDetail: undefined, apiSoapDetail: undefined }, + ], }, + guide_list_page: 48, + tutorial_list_page: 48, + use_case_list_page: 42, + tags: [], }, }, ], diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/homepage.ts b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/homepage.ts index 0844ed0845..145f398704 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/homepage.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/homepage.ts @@ -6,147 +6,124 @@ import { newsShowcase } from '@/lib/strapi/__tests__/fixtures/newsShowcase'; const fixedDateIsoString = new Date('2024-01-01T00:00:00.000Z').toISOString(); export const strapiHomepage: StrapiHomepage = { - data: { - attributes: { - updatedAt: fixedDateIsoString, - comingsoonDocumentation: { - title: 'Coming Soon Documentation', - links: [ - { - text: 'Documentation Link', - href: '/docs', - }, - ], + updatedAt: fixedDateIsoString, + comingsoonDocumentation: { + title: 'Coming Soon Documentation', + links: [ + { + text: 'Documentation Link', + href: '/docs', }, - heroSlider: [ + ], + }, + heroSlider: [ + { + title: 'Hero Title', + subhead: [ { - title: 'Hero Title', - subhead: [ - { - type: 'paragraph', - children: [{ type: 'text', text: 'Hero subhead content' }], - }, - ], - subheadColor: 'main', - titleColor: 'contrastText', - callToAction: { - link: { - text: 'Get Started', - href: '/get-started', - }, - variant: 'contained', - }, - backgroundImage: { - data: mediaJpeg(), - }, + type: 'paragraph', + children: [{ type: 'text', text: 'Hero subhead content' }], }, ], - newsShowcase: { - ...newsShowcase, - items: { - data: newsShowcase.items.data.map((item) => ({ - ...item, - attributes: { - ...item.attributes, - publishedAt: fixedDateIsoString, - link: item.attributes.link - ? { - ...item.attributes.link, - target: item.attributes.link.target || undefined, - } - : item.attributes.link, - }, - })), + subheadColor: 'main', + titleColor: 'contrastText', + callToAction: { + link: { + text: 'Get Started', + href: '/get-started', }, + variant: 'contained', }, - ecosystem: { - title: 'Our Ecosystem', - productsTabName: 'Products', - products: { - data: [ - { - attributes: { - isVisible: true, - tags: { data: [] }, - name: 'Product 1', - shortName: 'P1', - slug: 'product-1', - description: 'Product 1 description', - logo: { data: mediaJpeg() }, - bannerLinks: [], - overview: { data: { id: 1 } }, - quickstart_guide: { data: { id: 1 } }, - api_data_list_page: { data: undefined }, - tutorial_list_page: { data: { id: 1 } }, - guide_list_page: { data: { id: 1 } }, - release_note: { data: { id: 1 } }, - use_case_list_page: { data: { id: 1 } }, - }, - }, - ], - }, - solutionsTabName: 'Solutions', - solutions: { - data: [ - { - attributes: { - slug: 'solution-1', - icon: { data: mediaJpeg() }, - kickerTitle: 'Solution Kicker', - title: 'Solution 1', - description: 'Solution 1 description', - dirName: 'solution-1-dir', - landingUseCaseFile: 'use-case.md', - }, - }, - ], - }, - solutionsCta: { - link: { - text: 'View All Solutions', - href: '/solutions', - }, - variant: 'outlined', - }, + backgroundImage: mediaJpeg(), + }, + ], + newsShowcase: { + ...newsShowcase, + items: newsShowcase.items.map((item) => ({ + ...item, + publishedAt: fixedDateIsoString, + link: item.link + ? { + ...item.link, + target: item.link.target || undefined, + } + : item.link, + title: item.title, + comingSoon: item.comingSoon, + label: item.label, + image: item.image, + })), + }, + ecosystem: { + title: 'Our Ecosystem', + productsTabName: 'Products', + products: [ + { + isVisible: true, + tags: [], + name: 'Product 1', + shortName: 'P1', + slug: 'product-1', + description: 'Product 1 description', + logo: mediaJpeg(), + bannerLinks: [], + overview: 1, + quickstart_guide: 1, + api_data_list_page: undefined, + tutorial_list_page: 1, + guide_list_page: 1, + release_note: 1, + use_case_list_page: 1, + }, + ], + solutionsTabName: 'Solutions', + solutions: [ + { + slug: 'solution-1', + icon: mediaJpeg(), + kickerTitle: 'Solution Kicker', + title: 'Solution 1', + description: 'Solution 1 description', + dirName: 'solution-1-dir', + landingUseCaseFile: 'use-case.md', }, - webinars: { - data: [ + ], + solutionsCta: { + link: { + text: 'View All Solutions', + href: '/solutions', + }, + variant: 'outlined', + }, + }, + webinars: [ + { + id: 1, + title: 'Webinar Title', + slug: 'webinar-title', + description: 'Webinar Description', + playerSrc: 'https://example.com/player', + isVisibleInList: true, + publishedAt: fixedDateIsoString, + updatedAt: fixedDateIsoString, + coverImage: mediaJpeg(), + relatedLinks: { + title: 'Related Links', + links: [ { - id: 1, - attributes: { - title: 'Webinar Title', - slug: 'webinar-title', - description: 'Webinar Description', - playerSrc: 'https://example.com/player', - isVisibleInList: true, - publishedAt: fixedDateIsoString, - updatedAt: fixedDateIsoString, - coverImage: { data: mediaJpeg() }, - relatedLinks: { - title: 'Related Links', - links: [ - { - text: 'Link 1', - href: '/link-1', - }, - ], - }, - webinarSpeakers: { data: [] }, - webinarCategory: { - data: undefined, - }, - headerImage: { - data: undefined, - }, - }, + text: 'Link 1', + href: '/link-1', }, ], }, - seo: { - metaTitle: 'Homepage SEO Title', - metaDescription: 'Homepage SEO Description', - }, + webinarSpeakers: [], + webinarCategory: undefined, + headerImage: undefined, }, + ], + seo: { + metaTitle: 'Homepage SEO Title', + metaDescription: 'Homepage SEO Description', }, }; @@ -288,7 +265,7 @@ export const expectedHomepageProps: HomepageProps = { }, isVisibleInList: true, imagePath: 'https://example.com/example.jpg', - updatedAt: '2024-01-01T00:00:00.000Z', + updatedAt: fixedDateIsoString, }, ], seo: { diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/media.ts b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/media.ts index 12dbf00117..c74515d9bc 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/media.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/media.ts @@ -1,25 +1,21 @@ export const mediaVectorJson = { - data: { - id: 59, - attributes: { - name: 'Home.svg', - alternativeText: null, - caption: null, - width: 48, - height: 48, - formats: null, - hash: 'Home_9ca652379e', - ext: '.svg', - mime: 'image/svg+xml', - size: 0.18, - url: 'http://localhost:1337/uploads/Home_9ca652379e.svg', - previewUrl: null, - provider: 'strapi-provider-upload-custom', - provider_metadata: null, - createdAt: '2024-06-27T15:29:30.479Z', - updatedAt: '2024-08-21T13:27:05.052Z', - }, - }, + id: 59, + name: 'Home.svg', + alternativeText: null, + caption: null, + width: 48, + height: 48, + formats: null, + hash: 'Home_9ca652379e', + ext: '.svg', + mime: 'image/svg+xml', + size: 0.18, + url: 'http://localhost:1337/uploads/Home_9ca652379e.svg', + previewUrl: null, + provider: 'strapi-provider-upload-custom', + provider_metadata: null, + createdAt: '2024-06-27T15:29:30.479Z', + updatedAt: '2024-08-21T13:27:05.052Z', }; export const mediaRasterAttributesJson = { @@ -91,8 +87,6 @@ export const mediaRasterAttributesJson = { }; export const mediaRasterJson = { - data: { - id: 100, - attributes: mediaRasterAttributesJson, - }, + id: 100, + ...mediaRasterAttributesJson, }; diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/newsShowcase.ts b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/newsShowcase.ts index d45be6c8d6..e2be3d8f83 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/newsShowcase.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/newsShowcase.ts @@ -4,54 +4,46 @@ import { mediaJpeg } from '../factories/media'; export const newsShowcase = { title: "Cosa c'è di nuovo", subTitle: 'Le ultime novità su SEND e non solo', - items: { - data: [ - { - attributes: { - title: - "Usa il validatore di SEND per fare una verifica sull'integrazione", - comingSoon: false, - publishedAt: '2024-04-09T15:21:06.885Z', - label: 'Label', - link: { - text: 'Vai al validatore', - href: '/send/guides/validatore', - target: '_self', - }, - image: { data: mediaJpeg() }, - }, + items: [ + { + title: + "Usa il validatore di SEND per fare una verifica sull'integrazione", + comingSoon: false, + publishedAt: '2024-04-09T15:21:06.885Z', + label: 'Label', + link: { + text: 'Vai al validatore', + href: '/send/guides/validatore', + target: '_self', }, - { - attributes: { - title: - "Scopri la Quick Start di piattaforma pagoPA: l'integrazione in pochi semplici step", - comingSoon: false, - publishedAt: '2024-04-09T15:21:03.877Z', - label: 'Label', - link: { - text: 'Vai alla guida', - href: '/pago-pa/quick-start', - target: '_self', - }, - image: { data: mediaJpeg() }, - }, + image: mediaJpeg(), + }, + { + title: + "Scopri la Quick Start di piattaforma pagoPA: l'integrazione in pochi semplici step", + comingSoon: false, + publishedAt: '2024-04-09T15:21:03.877Z', + label: 'Label', + link: { + text: 'Vai alla guida', + href: '/pago-pa/quick-start', + target: '_self', }, - { - attributes: { - title: 'Scopri i nuovi tutorial di Firma con IO', - comingSoon: false, - publishedAt: '2024-04-09T15:21:00.525Z', - label: 'Label', - link: { - text: 'Vai ai tutorial', - href: '/firma-con-io/tutorials', - target: '_self', - }, - image: { data: mediaJpeg() }, - }, + image: mediaJpeg(), + }, + { + title: 'Scopri i nuovi tutorial di Firma con IO', + comingSoon: false, + publishedAt: '2024-04-09T15:21:00.525Z', + label: 'Label', + link: { + text: 'Vai ai tutorial', + href: '/firma-con-io/tutorials', + target: '_self', }, - ], - }, + image: mediaJpeg(), + }, + ], link: { text: 'Vai alle release note', href: '/send/release-note', diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/overviews.ts b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/overviews.ts index 7b3be44ab6..338b8ad822 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/overviews.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/overviews.ts @@ -10,282 +10,190 @@ export const strapiOverviews = { data: [ { id: 1, - attributes: { - title: 'Test Overview', - subtitle: 'Test Subtitle', - createdAt: '2023-01-01T00:00:00.000Z', - updatedAt: '2023-01-01T00:00:00.000Z', - publishedAt: '2023-01-01T00:00:00.000Z', - backgroundImage: { - data: mediaJpeg(), - }, - product: { - data: { - attributes: { - ...product, - tags: { data: [] }, - bannerLinks: generateBannerLinks(1), - overview: { - data: { - id: 1, - }, - }, - quickstart_guide: { - data: { - id: 2, - }, - }, - api_data_list_page: { - data: { - id: 3, - attributes: { - apiData: { - data: [ - { - attributes: { - apiRestDetail: { - slug: 'api-rest', - specUrls: [ - { - id: 1, - name: 'OpenAPI Spec', - url: '/api-rest/openapi.json', - hideTryIt: false, - }, - ], - }, - apiSoapDetail: undefined, - }, - }, - ], - }, + title: 'Test Overview', + subtitle: 'Test Subtitle', + createdAt: '2023-01-01T00:00:00.000Z', + updatedAt: '2023-01-01T00:00:00.000Z', + publishedAt: '2023-01-01T00:00:00.000Z', + backgroundImage: mediaJpeg(), + product: { + ...product, + tags: [], + bannerLinks: generateBannerLinks(1), + overview: 1, + quickstart_guide: 2, + api_data_list_page: { + id: 3, + api_data: [ + { + apiRestDetail: { + slug: 'api-rest', + specUrls: [ + { + id: 1, + name: 'OpenAPI Spec', + url: '/api-rest/openapi.json', + hideTryIt: false, }, - }, - }, - tutorial_list_page: { - data: { - id: 4, - }, - }, - release_note: { - data: { - id: 5, - }, - }, - guide_list_page: { - data: { - id: 6, - }, - }, - use_case_list_page: { - data: { - id: 7, - }, - }, - logo: { - data: mediaJpeg(), + ], }, + apiSoapDetail: undefined, }, + ], + }, + tutorial_list_page: 4, + release_note: 5, + guide_list_page: 6, + use_case_list_page: 7, + logo: mediaJpeg(), + }, + features: { + title: 'Features Title', + subtitle: 'Features Subtitle', + items: [ + { + id: 1, + title: 'Feature 1', + content: undefined, + icon: mediaJpeg(), + theme: 'dark', }, + ], + }, + startInfoSection: { + title: 'Start Info Title', + bottomLabel: 'Bottom Label', + bottomLink: { + text: 'Bottom Link', + href: '/bottom-link', }, - features: { - title: 'Features Title', - subtitle: 'Features Subtitle', - items: [ - { - id: 1, - title: 'Feature 1', - content: undefined, - icon: { - data: mediaJpeg(), - }, - theme: 'dark', + items: [ + { + title: 'Start Info Item', + description: 'Start info description', + path: '/start-path', + icon: mediaJpeg(), + }, + ], + }, + tutorialSection: { + title: 'Tutorials Title', + showCardsLayout: false, + description: 'Tutorials Description', + tutorials: [ + { + updatedAt: '2023-01-01T00:00:00.000Z', + description: 'test description', + icon: mediaJpeg(), + title: 'Tutorial 1', + tags: [], + slug: 'tutorial-1', + image: mediaJpeg(), + product: { + isVisible: true, + slug: 'test-product', + name: 'Test Product', + shortName: 'TestProd', }, - ], - }, - startInfoSection: { - title: 'Start Info Title', - bottomLabel: 'Bottom Label', - bottomLink: { - text: 'Bottom Link', - href: '/bottom-link', + publishedAt: dateNow.toISOString(), }, - items: [ - { - title: 'Start Info Item', - description: 'Start info description', - path: '/start-path', - icon: { - data: mediaJpeg(), - }, + ], + }, + useCaseSection: { + title: 'Use Cases Title', + description: 'Use Cases Description', + useCases: [ + { + title: 'Use Case 1', + tags: [], + slug: 'use-case-1', + publishedAt: '2023-01-01T00:00:00.000Z', + coverImage: mediaJpeg(), + product: { + isVisible: true, + slug: 'test-product', + name: 'Test Product', + shortName: 'TestProd', }, - ], - }, - tutorialSection: { - title: 'Tutorials Title', - showCardsLayout: false, - description: 'Tutorials Description', - tutorials: { - data: [ - { - attributes: { - updatedAt: '2023-01-01T00:00:00.000Z', - description: 'test description', - icon: { data: mediaJpeg() }, - title: 'Tutorial 1', - tags: { data: [] }, - slug: 'tutorial-1', - image: { - data: mediaJpeg(), - }, - product: { - data: { - attributes: { - isVisible: true, - slug: 'test-product', - name: 'Test Product', - shortName: 'TestProd', - }, - }, - }, - publishedAt: dateNow.toISOString(), - }, - }, - ], }, + ], + }, + whatsNew: { + title: "What's New Title", + subTitle: "What's New Subtitle", + link: { + text: 'View All', + href: '/whats-new', + target: '_self', }, - useCaseSection: { - title: 'Use Cases Title', - description: 'Use Cases Description', - useCases: { - data: [ - { - attributes: { - title: 'Use Case 1', - tags: { data: [] }, - slug: 'use-case-1', - coverImage: { - data: mediaJpeg(), - }, - product: { - data: { - attributes: { - isVisible: true, - slug: 'test-product', - name: 'Test Product', - shortName: 'TestProd', - }, - }, - }, - publishedAt: '2023-01-01T00:00:00.000Z', - }, - }, - ], + items: [ + { + title: 'News Item 1', + label: 'New', + comingSoon: false, + publishedAt: dateNow.toISOString(), + link: { + text: 'Read More', + href: '/news/item-1', + target: '_self', + }, + image: mediaJpeg(), }, + ], + }, + postIntegration: { + title: 'Post Integration Title', + description: 'Post Integration Description', + guidesTitle: 'Guides Title', + link: { + text: 'Learn More', + href: '/post-integration', }, - whatsNew: { - title: "What's New Title", - subTitle: "What's New Subtitle", - link: { - text: 'View All', - href: '/whats-new', - target: '_self', - }, - items: { - data: [ + documents: [ + { + title: 'Document 1', + content: [ { - attributes: { - title: 'News Item 1', - label: 'New', - comingSoon: false, - publishedAt: dateNow.toISOString(), - link: { - text: 'Read More', - href: '/news/item-1', - target: '_self', - }, - image: { - data: mediaJpeg(), - }, - }, + type: 'paragraph', + children: [{ type: 'text', text: 'Document content' }], }, ], + linkText: 'Download', + linkHref: '/documents/doc1.pdf', + image: mediaJpeg(), + mobileImage: mediaJpeg(), }, - }, - postIntegration: { - title: 'Post Integration Title', - description: 'Post Integration Description', - guidesTitle: 'Guides Title', - link: { - text: 'Learn More', - href: '/post-integration', + ], + guides: [ + { + title: 'Guide 1', + slug: 'guide-1', + listItems: [{ text: 'Guide item 1' }, { text: 'Guide item 2' }], + image: mediaJpeg(), + mobileImage: mediaJpeg(), }, - documents: [ - { - title: 'Document 1', - content: [ - { - type: 'paragraph', - children: [ - { - type: 'text', - text: 'Document content', - }, - ], - }, - ], - linkText: 'Download', - linkHref: '/documents/doc1.pdf', - image: { - data: mediaJpeg(), - }, - mobileImage: { - data: mediaJpeg(), - }, - }, - ], - guides: { - data: [ - { - attributes: { - title: 'Guide 1', - slug: 'guide-1', - listItems: [ - { text: 'Guide item 1' }, - { text: 'Guide item 2' }, - ], - image: { - data: mediaJpeg(), - }, - mobileImage: { - data: mediaJpeg(), - }, - }, - }, - ], + ], + serviceModels: [ + { + title: 'Service Model 1', + description: 'Service model description', + href: '/service-models/model-1', }, - serviceModels: [ - { - title: 'Service Model 1', - description: 'Service model description', - href: '/service-models/model-1', - }, - ], - }, - relatedLinks: { - title: 'Related Links', - links: [ - { - text: 'Related Link 1', - href: '/related-1', - }, - ], - }, - bannerLinks: generateBannerLinks(3), - seo: { - metaTitle: 'SEO Title', - metaDescription: 'SEO Description', - }, + ], + }, + relatedLinks: { + title: 'Related Links', + links: [ + { + text: 'Related Link 1', + href: '/related-1', + }, + ], + }, + bannerLinks: generateBannerLinks(3), + seo: { + metaTitle: 'SEO Title', + metaDescription: 'SEO Description', }, }, ], diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/parts.ts b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/parts.ts index 1a90b13667..a6a9ff3f18 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/parts.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/parts.ts @@ -52,16 +52,12 @@ export const quotePart: StrapiPart = { __component: 'parts.quote', text: 'Quote text', backgroundImage: { - data: { - attributes: { - url: 'https://example.com/image.jpg', - alternativeText: 'Alt text', - name: '', - ext: '', - mime: '', - size: 0, - }, - }, + url: 'https://example.com/image.jpg', + alternativeText: 'Alt text', + name: '', + ext: '', + mime: '', + size: 0, }, }; diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/product.ts b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/product.ts index 7243595db8..c38ddf2da7 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/product.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/product.ts @@ -2,46 +2,30 @@ import { mediaVectorJson } from './media'; import { bannerLinksJson } from '@/lib/strapi/__tests__/fixtures/bannerLinksJson'; import { Product } from '@/lib/types/product'; -export const baseProductJson = { - data: { - id: 8, - attributes: { - isVisible: true, - name: 'Firma con IO', - slug: 'firma-con-io', - shortName: 'Firma con IO', - }, - }, -}; - export const productJson = { - data: { - id: 8, - attributes: { - name: 'Firma con IO', - description: - 'Richiedi la Firma Elettronica Certificata su contratti e documenti. Le cittadine e i cittadini possono firmare direttamente sull’app IO.', - slug: 'firma-con-io', - createdAt: '2024-03-26T16:05:30.593Z', - updatedAt: '2024-07-11T19:28:06.709Z', - publishedAt: '2024-03-26T16:05:32.226Z', - locale: 'it', - shortName: 'Firma con IO', - logo: mediaVectorJson, - bannerLinks: bannerLinksJson, - overview: { data: null }, - quickstart_guide: { data: null }, - api_data_list_page: { data: null }, - tutorial_list_page: { data: null }, - guide_list_page: { data: null }, - release_note: { data: null }, - use_case_list_page: { data: null }, - }, - }, + id: 8, + name: 'Firma con IO', + description: + 'Richiedi la Firma Elettronica Certificata su contratti e documenti. Le cittadine e i cittadini possono firmare direttamente sull’app IO.', + slug: 'firma-con-io', + createdAt: '2024-03-26T16:05:30.593Z', + updatedAt: '2024-07-11T19:28:06.709Z', + publishedAt: '2024-03-26T16:05:32.226Z', + locale: 'it', + shortName: 'Firma con IO', + logo: mediaVectorJson, + bannerLinks: bannerLinksJson, + overview: null, + quickstart_guide: null, + api_data_list_page: null, + tutorial_list_page: null, + guide_list_page: null, + release_note: null, + use_case_list_page: null, }; export const productsJson = { - data: [productJson.data], + ...[productJson], }; export const product = { diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/products.ts b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/products.ts index fe1d94299c..1d6faab1b2 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/products.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/products.ts @@ -6,46 +6,41 @@ import { mediaJpeg } from '@/lib/strapi/__tests__/factories/media'; export const strapiProducts: StrapiProducts = { data: [ { - attributes: { - isVisible: true, - tags: { data: [] }, - name: 'Test Product', - slug: 'test-product', - shortName: 'TP', - description: 'Test product description', - logo: { - data: mediaJpeg(), - }, - bannerLinks: generateBannerLinks(2), - overview: { data: { id: 1 } }, - quickstart_guide: { data: { id: 1 } }, - api_data_list_page: { - data: { - id: 1, - attributes: { - apiData: { - data: [ - { - attributes: { - apiRestDetail: { - slug: 'api-detail', - specUrls: [], - }, - }, - }, - ], - }, + isVisible: true, + tags: [], + name: 'Test Product', + slug: 'test-product', + shortName: 'TP', + description: 'Test product description', + logo: mediaJpeg(), + bannerLinks: generateBannerLinks(2), + overview: 1, + quickstart_guide: 1, + api_data_list_page: { + id: 1, + api_data: [ + { + apiRestDetail: { + slug: 'api-detail', + specUrls: [], }, }, - }, - guide_list_page: { data: { id: 1 } }, - tutorial_list_page: { data: { id: 1 } }, - release_note: { data: { id: 1 } }, - use_case_list_page: { data: { id: 1 } }, + ], }, + guide_list_page: 1, + tutorial_list_page: 1, + release_note: 1, + use_case_list_page: 1, }, ], - meta: { pagination: { page: 1, pageSize: 25, pageCount: 1, total: 1 } }, + meta: { + pagination: { + page: 1, + pageSize: 25, + pageCount: 1, + total: 1, + }, + }, }; export const expectedProduct: Product = { diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/quickStartGuides.ts b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/quickStartGuides.ts index d0ea9aa24d..a04cea1062 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/quickStartGuides.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/quickStartGuides.ts @@ -5,74 +5,38 @@ export const strapiQuickStartGuides: StrapiQuickStartGuides = { data: [ { id: 1, - attributes: { - title: 'Quick Start Guide Title', - description: 'Quick Start Guide Description', - updatedAt: '2024-01-01T00:00:00.000Z', - product: { - data: { - attributes: { - isVisible: true, - tags: { data: [] }, - name: 'Product Name', - shortName: 'Product', - slug: 'product-slug', - bannerLinks: [], - overview: { - data: { - id: 1, - }, - }, - quickstart_guide: { - data: { - id: 1, - }, - }, - api_data_list_page: { - data: undefined, - }, - tutorial_list_page: { - data: { - id: 1, - }, - }, - guide_list_page: { - data: { - id: 1, - }, - }, - release_note: { - data: { - id: 1, - }, - }, - use_case_list_page: { - data: { - id: 1, - }, - }, - }, - }, - }, + title: 'Quick Start Guide Title', + description: 'Quick Start Guide Description', + updatedAt: '2024-01-01T00:00:00.000Z', + product: { + isVisible: true, + tags: [], + name: 'Product Name', + shortName: 'Product', + slug: 'product-slug', bannerLinks: [], - seo: { - metaTitle: 'Meta Title', - metaDescription: 'Meta Description', - }, - quickstartGuideItems: { - data: [ - { - id: 1, - attributes: { - title: 'Step 1', - anchor: 'step-1', - publishedAt: '2024-01-01T00:00:00.000Z', - parts: [alertPart, codeBlockPart], - }, - }, - ], - }, + overview: 1, + quickstart_guide: 1, + api_data_list_page: undefined, + tutorial_list_page: 1, + guide_list_page: 1, + release_note: 1, + use_case_list_page: 1, }, + bannerLinks: [], + seo: { + metaTitle: 'Meta Title', + metaDescription: 'Meta Description', + }, + quickstartGuideItems: [ + { + id: 1, + title: 'Step 1', + anchor: 'step-1', + publishedAt: '2024-01-01T00:00:00.000Z', + parts: [alertPart, codeBlockPart], + }, + ], }, ], meta: { diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/releaseNotes.ts b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/releaseNotes.ts index 5e8ae5fc64..b40769c985 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/releaseNotes.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/releaseNotes.ts @@ -8,38 +8,32 @@ export const strapiReleaseNotes: StrapiReleaseNotes = { data: [ { id: 1, - attributes: { - dirName: 'release-notes-dir', - landingFile: 'release-notes.md', - title: 'Release Notes Title', - bannerLinks: generateBannerLinks(2), - product: { - data: { - attributes: { - isVisible: true, - tags: { data: [] }, - name: 'Test Product', - slug: 'test-product', - shortName: 'TP', - bannerLinks: generateBannerLinks(1), - overview: { data: { id: 0 } }, - quickstart_guide: { data: { id: 0 } }, - api_data_list_page: { data: undefined }, - guide_list_page: { data: { id: 0 } }, - tutorial_list_page: { data: { id: 0 } }, - release_note: { data: { id: 0 } }, - use_case_list_page: { data: { id: 0 } }, - }, - }, - }, - seo: { - metaTitle: 'Release Notes SEO Title', - metaDescription: 'Release Notes SEO Description', - }, - publishedAt: fixedDateIsoString, - updatedAt: fixedDateIsoString, - createdAt: fixedDateIsoString, + dirName: 'release-notes-dir', + landingFile: 'release-notes.md', + title: 'Release Notes Title', + bannerLinks: generateBannerLinks(2), + product: { + isVisible: true, + tags: [], + name: 'Test Product', + slug: 'test-product', + shortName: 'TP', + bannerLinks: generateBannerLinks(1), + overview: 0, + quickstart_guide: 0, + api_data_list_page: undefined, + guide_list_page: 0, + tutorial_list_page: 0, + release_note: 0, + use_case_list_page: 0, + }, + seo: { + metaTitle: 'Release Notes SEO Title', + metaDescription: 'Release Notes SEO Description', }, + publishedAt: fixedDateIsoString, + updatedAt: fixedDateIsoString, + createdAt: fixedDateIsoString, }, ], meta: { diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/solution.ts b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/solution.ts index 76c0b9807a..b8c1cb887d 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/solution.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/solution.ts @@ -3,56 +3,52 @@ import { productsJson } from '@/lib/strapi/__tests__/fixtures/product'; export const baseSolutionJson = { id: 1, - attributes: { - slug: 'solution-1', - kickerTitle: 'kickerTitle', - title: 'Title Test', + slug: 'solution-1', + kickerTitle: 'kickerTitle', + title: 'Title Test', + description: null, + dirName: 'lAIZmjrusC6qV8ki9zsZ', + landingUseCaseFile: 'README.md', + createdAt: '2024-06-06T15:36:07.300Z', + updatedAt: '2024-06-06T15:56:26.077Z', + publishedAt: '2024-06-06T15:36:10.333Z', + locale: 'it', + icon: mediaVectorJson, + introductionToSteps: null, + steps: [], + stats: [], + statsSource: null, + bannerLinks: [], + products: { + data: [], + }, + webinars: { + data: [], + }, + caseHistories: { + id: 12, + title: 'Storie di successo', description: null, - dirName: 'lAIZmjrusC6qV8ki9zsZ', - landingUseCaseFile: 'README.md', - createdAt: '2024-06-06T15:36:07.300Z', - updatedAt: '2024-06-06T15:56:26.077Z', - publishedAt: '2024-06-06T15:36:10.333Z', - locale: 'it', - icon: mediaVectorJson, - introductionToSteps: null, - steps: [], - stats: [], - statsSource: null, - bannerLinks: [], - products: { - data: [], - }, - webinars: { - data: [], - }, - caseHistories: { - id: 12, - title: 'Storie di successo', - description: null, - case_histories: { - data: [ - { - id: 3, - attributes: { - seo: null, - slug: 'slugdellacasehistory', - title: 'Lorem ipsum dolor sit amet consectetur adipiscing el', - description: 'Lorem ipsum dolor sit amet consectetur adipiscing', - createdAt: '2024-06-12T13:24:05.128Z', - updatedAt: '2024-07-02T13:12:21.780Z', - publishedAt: '2024-06-12T13:24:27.231Z', - locale: 'it', - image: { - data: null, - }, - parts: [], - products: productsJson, - }, + case_histories: { + data: [ + { + id: 3, + seo: null, + slug: 'slugdellacasehistory', + title: 'Lorem ipsum dolor sit amet consectetur adipiscing el', + description: 'Lorem ipsum dolor sit amet consectetur adipiscing', + createdAt: '2024-06-12T13:24:05.128Z', + updatedAt: '2024-07-02T13:12:21.780Z', + publishedAt: '2024-06-12T13:24:27.231Z', + locale: 'it', + image: { + data: null, }, - ], - }, + parts: [], + products: productsJson, + }, + ], }, - seo: null, }, + seo: null, }; diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/solutionListPage.ts b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/solutionListPage.ts index 5025b3093e..5dfc70190f 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/solutionListPage.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/solutionListPage.ts @@ -6,68 +6,52 @@ import { generateBannerLinks } from '@/lib/strapi/__tests__/factories/bannerLink const fixedDateIsoString = new Date('2025-01-01T00:00:00.000Z').toISOString(); export const strapiSolutionListPage = { - data: { - attributes: { - title: 'Solutions', - description: 'Explore our solutions', - solutions: { - data: [ - { - attributes: { - slug: 'solution-1', - icon: { data: mediaJpeg() }, - kickerTitle: 'Solution Kicker 1', - title: 'Solution 1', - description: 'Solution 1 Description', - dirName: 'solution-1-dir', - landingUseCaseFile: 'use-case-1.md', - products: { - data: [ - { - attributes: { - isVisible: true, - name: 'Product 1', - shortName: 'P1', - slug: 'product-1', - description: 'Product 1 description', - logo: { data: mediaJpeg() }, - }, - }, - ], - }, - }, - }, - ], - }, - caseHistories: { - title: 'Success Stories', - description: 'Our case studies', - case_histories: { - data: [ - { - id: 1, - attributes: { - slug: 'case-history-1', - title: 'Case History 1', - description: 'Case history description', - publishedAt: fixedDateIsoString, - updatedAt: fixedDateIsoString, - image: { data: mediaJpeg() }, - }, - }, - ], + title: 'Solutions', + description: 'Explore our solutions', + solutions: [ + { + slug: 'solution-1', + icon: mediaJpeg(), + kickerTitle: 'Solution Kicker 1', + title: 'Solution 1', + description: 'Solution 1 Description', + dirName: 'solution-1-dir', + landingUseCaseFile: 'use-case-1.md', + products: [ + { + isVisible: true, + name: 'Product 1', + shortName: 'P1', + slug: 'product-1', + description: 'Product 1 description', + logo: mediaJpeg(), }, - }, - features: { - title: 'Features', - subtitle: 'Our key features', - items: generateBannerLinks(2), - }, - seo: { - metaTitle: 'Solutions SEO Title', - metaDescription: 'Solutions SEO Description', - }, + ], }, + ], + caseHistories: { + title: 'Success Stories', + description: 'Our case studies', + case_histories: [ + { + id: 1, + slug: 'case-history-1', + title: 'Case History 1', + description: 'Case history description', + publishedAt: fixedDateIsoString, + updatedAt: fixedDateIsoString, + image: mediaJpeg(), + }, + ], + }, + features: { + title: 'Features', + subtitle: 'Our key features', + items: generateBannerLinks(2), + }, + seo: { + metaTitle: 'Solutions SEO Title', + metaDescription: 'Solutions SEO Description', }, } satisfies StrapiSolutionListPage; diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/solutions.ts b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/solutions.ts index 94ebdd8287..a52f1508a2 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/solutions.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/solutions.ts @@ -9,120 +9,96 @@ export const strapiSolutions = { data: [ { id: 1, - attributes: { - slug: 'solution-title', - icon: { data: mediaJpeg() }, - kickerTitle: 'Solution Kicker', - title: 'Solution Title', - description: 'Solution Description', - dirName: 'solution-dir', - landingUseCaseFile: 'use-case.md', - publishedAt: fixedDateIsoString, - updatedAt: fixedDateIsoString, - introductionToSteps: 'Introduction to steps', - steps: [ - { - title: 'Step 1', - content: [ - { - type: 'paragraph', - children: [{ type: 'text', text: 'Step content' }], - }, - ], - products: { - data: [ - { - attributes: { - isVisible: true, - name: 'Product 1', - shortName: 'P1', - slug: 'product-1', - }, - }, - ], - }, - }, - ], - stats: [ - { - title: 'Stat 1', - description: 'Stat description', - }, - ], - statsSource: 'Stats source', - bannerLinks: generateBannerLinks(1), - webinars: { - data: [ + slug: 'solution-title', + icon: mediaJpeg(), + kickerTitle: 'Solution Kicker', + title: 'Solution Title', + description: 'Solution Description', + dirName: 'solution-dir', + landingUseCaseFile: 'use-case.md', + publishedAt: fixedDateIsoString, + updatedAt: fixedDateIsoString, + introductionToSteps: 'Introduction to steps', + steps: [ + { + title: 'Step 1', + content: [ { - id: 1, - attributes: { - title: 'Webinar Title', - slug: 'webinar-title', - description: 'Webinar Description', - playerSrc: 'https://example.com/player', - isVisibleInList: true, - publishedAt: fixedDateIsoString, - updatedAt: fixedDateIsoString, - coverImage: { data: mediaJpeg() }, - relatedLinks: { - title: 'Related Links', - links: [ - { - text: 'Link 1', - href: '/link-1', - }, - ], - }, - webinarSpeakers: { - data: [], - }, - webinarCategory: { - data: undefined, - }, - headerImage: { - data: undefined, - }, - }, + type: 'paragraph', + children: [{ type: 'text', text: 'Step content' }], }, ], - }, - products: { - data: [ + products: [ { - attributes: { - isVisible: true, - name: 'Product 1', - shortName: 'P1', - slug: 'product-1', - description: 'Product description', - logo: { data: mediaJpeg() }, - }, + isVisible: true, + name: 'Product 1', + shortName: 'P1', + slug: 'product-1', }, ], }, - caseHistories: { - title: 'Case Studies', - description: 'Success stories', - case_histories: { - data: [ + ], + stats: [ + { + title: 'Stat 1', + description: 'Stat description', + }, + ], + statsSource: 'Stats source', + bannerLinks: generateBannerLinks(1), + webinars: [ + { + id: 1, + title: 'Webinar Title', + slug: 'webinar-title', + description: 'Webinar Description', + playerSrc: 'https://example.com/player', + isVisibleInList: true, + publishedAt: fixedDateIsoString, + updatedAt: fixedDateIsoString, + coverImage: mediaJpeg(), + relatedLinks: { + title: 'Related Links', + links: [ { - id: 1, - attributes: { - slug: 'case-history-1', - title: 'Case History 1', - description: 'Case history description', - publishedAt: fixedDateIsoString, - updatedAt: fixedDateIsoString, - image: { data: mediaJpeg() }, - }, + text: 'Link 1', + href: '/link-1', }, ], }, + webinarSpeakers: [], + webinarCategory: undefined, + headerImage: undefined, }, - seo: { - metaTitle: 'SEO Title', - metaDescription: 'SEO Description', + ], + products: [ + { + isVisible: true, + name: 'Product 1', + shortName: 'P1', + slug: 'product-1', + description: 'Product description', + logo: mediaJpeg(), }, + ], + caseHistories: { + title: 'Case Studies', + description: 'Success stories', + case_histories: [ + { + id: 1, + slug: 'case-history-1', + title: 'Case History 1', + description: 'Case history description', + publishedAt: fixedDateIsoString, + updatedAt: fixedDateIsoString, + image: mediaJpeg(), + }, + ], + }, + seo: { + metaTitle: 'SEO Title', + metaDescription: 'SEO Description', }, }, ], diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/tutorialListPage.ts b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/tutorialListPage.ts index 646ccaf12a..e028ef034d 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/tutorialListPage.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/tutorialListPage.ts @@ -8,61 +8,45 @@ export const strapiTutorialListPages: StrapiTutorialListPages = { data: [ { id: 1, - attributes: { - title: 'Tutorials', - description: 'Explore our tutorials', + title: 'Tutorials', + description: 'Explore our tutorials', + bannerLinks: generateBannerLinks(1), + product: { + isVisible: true, + tags: [], + name: 'Product 1', + shortName: 'P1', + slug: 'product-1', bannerLinks: generateBannerLinks(1), - product: { - data: { - attributes: { - isVisible: true, - tags: { data: [] }, - name: 'Product 1', - shortName: 'P1', - slug: 'product-1', - bannerLinks: generateBannerLinks(1), - overview: { data: undefined }, - quickstart_guide: { data: undefined }, - api_data_list_page: { data: undefined }, - tutorial_list_page: { data: undefined }, - guide_list_page: { data: undefined }, - release_note: { data: undefined }, - use_case_list_page: { data: undefined }, - }, + overview: undefined, + quickstart_guide: undefined, + api_data_list_page: undefined, + tutorial_list_page: undefined, + guide_list_page: undefined, + release_note: undefined, + use_case_list_page: undefined, + }, + tutorials: [ + { + updatedAt: '2023-01-01T00:00:00.000Z', + description: '', + icon: mediaJpeg(), + tags: [], + title: 'Tutorial 1', + slug: 'tutorial-1', + publishedAt: fixedDateIsoString, + product: { + isVisible: true, + name: 'Product 1', + shortName: 'P1', + slug: 'product-1', }, + image: mediaJpeg(), }, - tutorials: { - data: [ - { - attributes: { - updatedAt: '2023-01-01T00:00:00.000Z', - description: '', - icon: { data: mediaJpeg() }, - tags: { data: [] }, - title: 'Tutorial 1', - slug: 'tutorial-1', - publishedAt: fixedDateIsoString, - product: { - data: { - attributes: { - isVisible: true, - name: 'Product 1', - shortName: 'P1', - slug: 'product-1', - }, - }, - }, - image: { - data: mediaJpeg(), - }, - }, - }, - ], - }, - seo: { - metaTitle: 'Tutorials SEO Title', - metaDescription: 'Tutorials SEO Description', - }, + ], + seo: { + metaTitle: 'Tutorials SEO Title', + metaDescription: 'Tutorials SEO Description', }, }, ], diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/tutorials.ts b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/tutorials.ts index b05214458c..fcf6584c45 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/tutorials.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/tutorials.ts @@ -6,48 +6,42 @@ import { generateBannerLinks } from '@/lib/strapi/__tests__/factories/bannerLink export const strapiTutorials: StrapiTutorials = { data: [ { - attributes: { - description: '', - icon: { data: mediaJpeg() }, - tags: { data: [] }, - title: 'Tutorial Title', - slug: 'tutorial-title', - publishedAt: '2024-01-01T00:00:00.000Z', - createdAt: '2024-01-01T00:00:00.000Z', - image: { data: mediaJpeg() }, - locale: 'en-US', - product: { - data: { - attributes: { - ...product, - bannerLinks: generateBannerLinks(1), - }, - }, + description: '', + icon: mediaJpeg(), + tags: [], + title: 'Tutorial Title', + slug: 'tutorial-title', + publishedAt: '2024-01-01T00:00:00.000Z', + createdAt: '2024-01-01T00:00:00.000Z', + image: mediaJpeg(), + locale: 'en-US', + product: { + ...product, + bannerLinks: generateBannerLinks(1), + }, + parts: [ + { + __component: 'parts.code-block', + code: 'console.log("Hello World");', + language: 'javascript', + showLineNumbers: true, }, - parts: [ + ], + bannerLinks: generateBannerLinks(1), + relatedLinks: { + title: 'Related Links', + links: [ { - __component: 'parts.code-block', - code: 'console.log("Hello World");', - language: 'javascript', - showLineNumbers: true, + text: 'Link 1', + href: '/link-1', }, ], - bannerLinks: generateBannerLinks(1), - relatedLinks: { - title: 'Related Links', - links: [ - { - text: 'Link 1', - href: '/link-1', - }, - ], - }, - seo: { - metaTitle: 'SEO Title', - metaDescription: 'SEO Description', - }, - updatedAt: '2024-01-02T00:00:00.000Z', }, + seo: { + metaTitle: 'SEO Title', + metaDescription: 'SEO Description', + }, + updatedAt: '2024-01-02T00:00:00.000Z', }, ], meta: { diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/urlReplaceMap.ts b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/urlReplaceMap.ts index c3953804ca..81e6eaf243 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/urlReplaceMap.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/urlReplaceMap.ts @@ -2,32 +2,20 @@ import { StrapiUrlReplaceMap } from '@/lib/strapi/types/urlReplaceMap'; import { productJson } from './product'; export const strapiUrlReplaceMapFixture: StrapiUrlReplaceMap = { - data: { - attributes: { - urlToGuide: [ - { - id: 1, - url: 'getting-started', - subPath: 'step-2', - guide: { - data: { - attributes: { - title: 'Getting started', - slug: 'getting-started', - product: { - data: { - attributes: { - slug: productJson.data.attributes.slug, - }, - }, - }, - }, - }, - }, + urlToGuide: [ + { + id: 1, + url: 'getting-started', + subPath: 'step-2', + guide: { + title: 'Getting started', + slug: 'getting-started', + product: { + slug: productJson.slug, }, - ], + }, }, - }, + ], }; export const expectedUrlReplaceMapFixture = { diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/useCaseListPage.ts b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/useCaseListPage.ts index 715c1ec481..a27193fcc6 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/useCaseListPage.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/useCaseListPage.ts @@ -8,69 +8,49 @@ export const strapiUseCaseListPages: StrapiUseCaseListPages = { data: [ { id: 1, - attributes: { - title: 'Use Cases', - description: 'Explore our use cases', + title: 'Use Cases', + description: 'Explore our use cases', + bannerLinks: generateBannerLinks(1), + product: { + isVisible: true, + name: 'Product 1', + shortName: 'P1', + slug: 'product-1', bannerLinks: generateBannerLinks(1), - product: { - data: { - attributes: { - isVisible: true, - name: 'Product 1', - shortName: 'P1', - slug: 'product-1', - bannerLinks: generateBannerLinks(1), - overview: { data: undefined }, - quickstart_guide: { data: undefined }, - api_data_list_page: { data: undefined }, - tutorial_list_page: { data: undefined }, - guide_list_page: { data: undefined }, - release_note: { data: undefined }, - use_case_list_page: { data: undefined }, - tags: { data: [] }, - }, + overview: undefined, + quickstart_guide: undefined, + api_data_list_page: undefined, + tutorial_list_page: undefined, + guide_list_page: undefined, + release_note: undefined, + use_case_list_page: undefined, + tags: [], + }, + useCases: [ + { + title: 'Use Case 1', + slug: 'use-case-1', + publishedAt: fixedDateIsoString, + product: { + isVisible: true, + name: 'Product 1', + shortName: 'P1', + slug: 'product-1', }, - }, - useCases: { - data: [ + coverImage: mediaJpeg(), + tags: [ { - attributes: { - title: 'Use Case 1', - slug: 'use-case-1', - publishedAt: fixedDateIsoString, - product: { - data: { - attributes: { - isVisible: true, - name: 'Product 1', - shortName: 'P1', - slug: 'product-1', - }, - }, - }, - coverImage: { - data: mediaJpeg(), - }, - tags: { - data: [ - { - attributes: { - name: 'Tag1', - icon: { data: mediaJpeg() }, - }, - }, - ], - }, - }, + name: 'Tag1', + icon: mediaJpeg(), }, ], }, - seo: { - metaTitle: 'Use Cases SEO Title', - metaDescription: 'Use Cases SEO Description', - }, - enableFilters: true, + ], + seo: { + metaTitle: 'Use Cases SEO Title', + metaDescription: 'Use Cases SEO Description', }, + enableFilters: true, }, ], meta: { diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/useCases.ts b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/useCases.ts index bd476817e2..ddccb4a290 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/useCases.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/useCases.ts @@ -6,57 +6,47 @@ import { StrapiUseCases } from '../../types/useCase'; export const strapiUseCases: StrapiUseCases = { data: [ { - attributes: { - title: 'UseCase Title', - subtitle: 'UseCase Subtitle', - slug: 'use-case-title', - publishedAt: '2024-01-01T00:00:00.000Z', - createdAt: '2024-01-01T00:00:00.000Z', - coverImage: { data: mediaJpeg() }, - headerImage: { data: mediaJpeg() }, - locale: 'en-US', - product: { - data: { - attributes: { - ...product, - bannerLinks: generateBannerLinks(1), - }, - }, + title: 'UseCase Title', + subtitle: 'UseCase Subtitle', + slug: 'use-case-title', + publishedAt: '2024-01-01T00:00:00.000Z', + createdAt: '2024-01-01T00:00:00.000Z', + coverImage: mediaJpeg(), + headerImage: mediaJpeg(), + locale: 'en-US', + product: { + ...product, + bannerLinks: generateBannerLinks(1), + }, + parts: [ + { + __component: 'parts.code-block', + code: 'console.log("Hello World");', + language: 'javascript', + showLineNumbers: true, }, - parts: [ + ], + bannerLinks: generateBannerLinks(1), + relatedLinks: { + title: 'Related Links', + links: [ { - __component: 'parts.code-block', - code: 'console.log("Hello World");', - language: 'javascript', - showLineNumbers: true, + text: 'Link 1', + href: '/link-1', }, ], - bannerLinks: generateBannerLinks(1), - relatedLinks: { - title: 'Related Links', - links: [ - { - text: 'Link 1', - href: '/link-1', - }, - ], - }, - seo: { - metaTitle: 'SEO Title', - metaDescription: 'SEO Description', - }, - tags: { - data: [ - { - attributes: { - name: 'Tag1', - icon: { data: mediaJpeg() }, - }, - }, - ], - }, - updatedAt: '2024-01-02T00:00:00.000Z', }, + seo: { + metaTitle: 'SEO Title', + metaDescription: 'SEO Description', + }, + tags: [ + { + name: 'Tag1', + icon: mediaJpeg(), + }, + ], + updatedAt: '2024-01-02T00:00:00.000Z', }, ], meta: { diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/webinarCategory.ts b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/webinarCategory.ts index 9d15f6471a..8040022094 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/webinarCategory.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/webinarCategory.ts @@ -5,17 +5,13 @@ export const strapiWebinarCategories: StrapiWebinarCategories = { data: [ { id: 1, - attributes: { - name: 'Payments', - icon: { data: mediaJpeg() }, - }, + name: 'Payments', + icon: mediaJpeg(), }, { id: 2, - attributes: { - name: 'Onboarding', - icon: { data: mediaJpeg() }, - }, + name: 'Onboarding', + icon: mediaJpeg(), }, ], meta: { diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/webinars.ts b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/webinars.ts index 4f781db5f9..82ec602bde 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/webinars.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/webinars.ts @@ -4,19 +4,13 @@ import { mediaJpeg } from '@/lib/strapi/__tests__/factories/media'; export const webinarSpeaker = { id: 1, - attributes: { - name: 'Speaker Name', - jobTitle: 'Speaker Job', - publishedAt: '2024-01-01T00:00:00.000Z', - description: undefined, - avatar: { - data: { - attributes: { - ...mediaJpeg().attributes, - name: 'avatar.jpg', - }, - }, - }, + name: 'Speaker Name', + jobTitle: 'Speaker Job', + publishedAt: '2024-01-01T00:00:00.000Z', + description: undefined, + avatar: { + ...mediaJpeg(), + name: 'avatar.jpg', }, }; @@ -27,81 +21,67 @@ export const resource = { subtitle: 'Resource Subtitle', description: undefined, image: { - data: { - attributes: { - ...mediaJpeg().attributes, - name: 'resource.jpg', - }, - }, + ...mediaJpeg(), + name: 'resource.jpg', }, }; export const downloadableDocument = { - attributes: { - caption: 'Doc Caption', - name: 'doc.pdf', - mime: 'text/html', - url: '/docs/doc.pdf', - size: 12345, - ext: '.pdf', - }, + caption: 'Doc Caption', + name: 'doc.pdf', + mime: 'text/html', + url: '/docs/doc.pdf', + size: 12345, + ext: '.pdf', }; export const strapiWebinars: StrapiWebinars = { data: [ { id: 1, - attributes: { - title: 'Webinar Title', - description: 'Webinar Description', - slug: 'webinar-title', - publishedAt: '2024-01-01T00:00:00.000Z', - isVisibleInList: true, - coverImage: { - data: { - attributes: { - ...mediaJpeg().attributes, - name: 'cover.jpg', + title: 'Webinar Title', + description: 'Webinar Description', + slug: 'webinar-title', + publishedAt: '2024-01-01T00:00:00.000Z', + isVisibleInList: true, + coverImage: { + ...mediaJpeg(), + name: 'cover.jpg', + }, + bodyContent: undefined, + playerSrc: 'https://player.example.com', + startDatetime: '2024-01-10T10:00:00.000Z', + endDatetime: '2024-01-10T12:00:00.000Z', + subscribeParagraphLabel: 'Subscribe Now', + relatedLinks: undefined, + relatedResources: { + title: 'Related Resources', + resources: [resource], + downloadableDocuments: [downloadableDocument], + }, + webinarSpeakers: [webinarSpeaker], + questionsAndAnswers: [ + { + question: 'What is this webinar about?', + answer: [ + { + type: 'paragraph', + children: [{ type: 'text', text: 'It is about testing.' }], }, - }, - }, - bodyContent: undefined, - playerSrc: 'https://player.example.com', - startDatetime: '2024-01-10T10:00:00.000Z', - endDatetime: '2024-01-10T12:00:00.000Z', - subscribeParagraphLabel: 'Subscribe Now', - relatedLinks: undefined, - relatedResources: { - title: 'Related Resources', - resources: [resource], - downloadableDocuments: { data: [downloadableDocument] }, + ], }, - webinarSpeakers: { data: [webinarSpeaker] }, - questionsAndAnswers: [ - { - question: 'What is this webinar about?', - answer: [ - { - type: 'paragraph', - children: [{ type: 'text', text: 'It is about testing.' }], - }, - ], - }, - ], - seo: { metaTitle: 'SEO Webinar', metaDescription: 'SEO Description' }, - webinarCategory: { - data: { - id: 1, - attributes: { name: 'Category 1', icon: { data: mediaJpeg() } }, - }, - }, - headerImage: { - data: { - attributes: { ...mediaJpeg().attributes, name: 'header.jpg' }, - }, - }, - updatedAt: '2024-01-02T00:00:00.000Z', + ], + seo: { metaTitle: 'SEO Webinar', metaDescription: 'SEO Description' }, + webinarCategory: { + id: 1, + name: 'Category 1', + icon: { ...mediaJpeg() }, + }, + headerImage: { + ...mediaJpeg(), + name: 'header.jpg', }, + updatedAt: '2024-01-02T00:00:00.000Z', }, ], meta: { @@ -119,20 +99,29 @@ export const strapiWebinarsWithMissingData: StrapiWebinars = { ...strapiWebinars.data, { id: 2, - attributes: { - title: 'Minimal Webinar', - description: 'Minimal Description', - slug: 'minimal-webinar', - publishedAt: '2024-01-01T00:00:00.000Z', - isVisibleInList: true, - coverImage: { - data: { url: 'https://example.com/minimal.jpg', name: 'minimal.jpg' }, - }, - // Optional fields omitted - webinarSpeakers: { data: [] }, - updatedAt: '2024-01-02T00:00:00.000Z', - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } as any, + title: 'Minimal Webinar', + description: 'Minimal Description', + slug: 'minimal-webinar', + publishedAt: '2024-01-01T00:00:00.000Z', + isVisibleInList: true, + coverImage: { + url: 'https://example.com/minimal.jpg', + name: 'minimal.jpg', + ext: '', + mime: '', + size: 0, + }, + webinarSpeakers: [], + updatedAt: '2024-01-02T00:00:00.000Z', + webinarCategory: { + id: 1, + name: 'Category 1', + icon: { ...mediaJpeg() }, + }, + headerImage: { + ...mediaJpeg(), + name: 'header.jpg', + }, }, ], meta: { @@ -155,7 +144,7 @@ export const webinarProps = { name: 'Speaker Name', jobTitle: 'Speaker Job', avatar: { - ...mediaJpeg().attributes, + ...mediaJpeg(), name: 'avatar.jpg', }, }, @@ -169,7 +158,7 @@ export const webinarProps = { linkHref: '/resource-link', subtitle: 'Resource Subtitle', image: { - ...mediaJpeg().attributes, + ...mediaJpeg(), name: 'resource.jpg', }, }, @@ -191,16 +180,12 @@ export const webinarProps = { tag: { name: 'Category 1', icon: { - data: { - attributes: { - ...mediaJpeg().attributes, - name: 'example.jpg', - }, - }, + ...mediaJpeg(), + name: 'example.jpg', }, }, headerImage: { - ...mediaJpeg().attributes, + ...mediaJpeg(), name: 'header.jpg', }, updatedAt: '2024-01-02T00:00:00.000Z', diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/makeApiDataList.test.ts b/apps/nextjs-website/src/lib/strapi/__tests__/makeApiDataList.test.ts index a77e8aa566..ee128bb43b 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/makeApiDataList.test.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/makeApiDataList.test.ts @@ -40,7 +40,9 @@ describe('makeApiDataListProps', () => { }); it('should transform strapi api data list to api data page props', async () => { - const result = await makeApiDataListProps(_.cloneDeep(strapiApiDataList)); + const result = await makeApiDataListProps( + _.cloneDeep({ data: strapiApiDataList }) + ); expect(result).toHaveLength(2); expect(result[0]).toMatchObject(expectedApiDataPageProps[0]); expect(result[1]).toMatchObject(expectedApiDataPageProps[1]); @@ -48,7 +50,7 @@ describe('makeApiDataListProps', () => { it('should handle minimal data with missing optional fields', async () => { const result = await makeApiDataListProps( - _.cloneDeep(minimalApiDataList()) + _.cloneDeep({ data: minimalApiDataList() }) ); expect(result).toHaveLength(1); const firstElement = result[0]; @@ -60,15 +62,15 @@ describe('makeApiDataListProps', () => { }); it('should handle empty data array', async () => { - const emptyData: StrapiApiDataList = { - data: [], - }; - const result = await makeApiDataListProps(emptyData); + const emptyData: StrapiApiDataList = []; + const result = await makeApiDataListProps({ data: [...emptyData] }); expect(result).toHaveLength(0); }); it('should use product banner links when api data banner links are empty', async () => { - const result = await makeApiDataListProps(apiDataWithoutBannerLinks()); + const result = await makeApiDataListProps({ + data: apiDataWithoutBannerLinks(), + }); const firstElement = result[0]; expect(firstElement.bannerLinks).toBeDefined(); expect(firstElement.bannerLinks).toHaveLength(1); @@ -76,14 +78,16 @@ describe('makeApiDataListProps', () => { }); it('should filter out api data without rest or soap details', async () => { - const result = await makeApiDataListProps(apiDataWithoutApiDetails()); + const result = await makeApiDataListProps({ + data: apiDataWithoutApiDetails(), + }); expect(result).toHaveLength(0); }); it('should filter out api data with rest api details with invalid data', async () => { - const result = await makeApiDataListProps( - apiDataWithInvalidRestApiDetails() - ); + const result = await makeApiDataListProps({ + data: apiDataWithInvalidRestApiDetails(), + }); expect(result).toHaveLength(0); expect(spyOnConsoleError).toHaveBeenCalledWith( expect.stringContaining( @@ -93,7 +97,9 @@ describe('makeApiDataListProps', () => { }); it('should filter out api data with soap api details without slug', async () => { - const result = await makeApiDataListProps(apiDatalistWithItemMissingSlug()); + const result = await makeApiDataListProps({ + data: apiDatalistWithItemMissingSlug(), + }); expect(result).toHaveLength(0); expect(spyOnConsoleError).toHaveBeenCalledWith( expect.stringContaining( @@ -103,7 +109,9 @@ describe('makeApiDataListProps', () => { }); it('should handle mixed valid and invalid api data', async () => { - const result = await makeApiDataListProps(mixedApiDataValidAndInvalid()); + const result = await makeApiDataListProps({ + data: mixedApiDataValidAndInvalid(), + }); // Should return only the 3 valid api data items, filtering out invalid ones expect(result).toHaveLength(3); @@ -114,20 +122,22 @@ describe('makeApiDataListProps', () => { }); it('should handle api data without banner links and without product banner links', async () => { - const result = await makeApiDataListProps( - apiDataWithoutProductBannerLinks() - ); + const result = await makeApiDataListProps({ + data: apiDataWithoutProductBannerLinks(), + }); expect(result[0].bannerLinks).toEqual([]); }); it('should return empty array when all api data are invalid', async () => { - const result = await makeApiDataListProps(allInvalidApiData()); + const result = await makeApiDataListProps({ + data: [...allInvalidApiData()], + }); expect(result).toHaveLength(0); expect(spyOnConsoleError).toHaveBeenCalled(); }); it('should correctly identify REST API type', async () => { - const result = await makeApiDataListProps(restApiDataOnly()); + const result = await makeApiDataListProps({ data: restApiDataOnly() }); const firstElement = result[0]; expect(firstElement.apiType).toBe('rest'); expect(firstElement.restApiSpecUrls).toHaveLength(1); @@ -136,7 +146,7 @@ describe('makeApiDataListProps', () => { }); it('should correctly identify SOAP API type', async () => { - const result = await makeApiDataListProps(soapApiDataOnly()); + const result = await makeApiDataListProps({ data: soapApiDataOnly() }); const firstElement = result[0]; expect(firstElement.apiType).toBe('soap'); expect(firstElement.restApiSpecUrls).toEqual([]); @@ -147,7 +157,7 @@ describe('makeApiDataListProps', () => { }); it('should prioritize api data banner links over product banner links', async () => { - const result = await makeApiDataListProps(strapiApiDataList); + const result = await makeApiDataListProps({ data: strapiApiDataList }); const firstElement = result[0]; expect(firstElement.bannerLinks).toHaveLength(2); expect(firstElement.bannerLinks?.[0].title).toBe('Banner Link 1'); @@ -155,18 +165,20 @@ describe('makeApiDataListProps', () => { }); it('should handle api data with product that has undefined banner links', async () => { - const result = await makeApiDataListProps(minimalApiDataList()); + const result = await makeApiDataListProps({ data: minimalApiDataList() }); expect(result[0].bannerLinks).toBeUndefined(); }); it('should set correct specUrlsName from title', async () => { - const result = await makeApiDataListProps(strapiApiDataList); + const result = await makeApiDataListProps({ data: strapiApiDataList }); expect(result[0].specUrlsName).toBe('SEND Main'); expect(result[1].specUrlsName).toBe('Documentazione SOAP'); }); it('should handle REST API with multiple spec URLs', async () => { - const result = await makeApiDataListProps(restApiDataWithMultipleSpecs()); + const result = await makeApiDataListProps({ + data: restApiDataWithMultipleSpecs(), + }); const firstElement = result[0]; expect(firstElement.restApiSpecUrls).toHaveLength(2); expect(firstElement.restApiSpecUrls[0].name).toBe('API 1'); @@ -174,14 +186,16 @@ describe('makeApiDataListProps', () => { }); it('should handle SOAP API and call makeApiSoapUrlList', async () => { - const result = await makeApiDataListProps(soapApiDataOnly()); + const result = await makeApiDataListProps({ data: soapApiDataOnly() }); expect(result[0].apiSoapUrlList).toEqual([ { name: 'test.wsdl', url: 'https://example.com/test.wsdl' }, ]); }); it('should handle api data with missing product gracefully', async () => { - const result = await makeApiDataListProps(apiDataWithMissingProduct()); + const result = await makeApiDataListProps({ + data: apiDataWithMissingProduct(), + }); // Should filter out items with missing product since makeBaseProductWithoutLogoProps would fail expect(result).toHaveLength(0); expect(spyOnConsoleError).toHaveBeenCalledWith( diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/makeApiDataListPages.test.ts b/apps/nextjs-website/src/lib/strapi/__tests__/makeApiDataListPages.test.ts index 95737cc30f..2c51c9ce9d 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/makeApiDataListPages.test.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/makeApiDataListPages.test.ts @@ -27,7 +27,7 @@ describe('makeApiDataListPagesProps', () => { it('should transform strapi api data list pages to api data list page template props', () => { const result = makeApiDataListPagesProps( - _.cloneDeep(strapiApiDataListPages) + _.cloneDeep({ data: strapiApiDataListPages }) ); expect(result).toHaveLength(1); expect(result[0]).toMatchObject(expectedApiDataListPageProps[0]); @@ -35,7 +35,7 @@ describe('makeApiDataListPagesProps', () => { it('should handle minimal data with missing optional fields', () => { const result = makeApiDataListPagesProps( - _.cloneDeep(minimalApiDataListPages()) + _.cloneDeep({ data: minimalApiDataListPages() }) ); expect(result).toHaveLength(1); const firstElement = result[0]; @@ -44,26 +44,28 @@ describe('makeApiDataListPagesProps', () => { expect(firstElement.seo).toBeUndefined(); expect(firstElement.cards).toHaveLength(1); expect(firstElement.cards[0].title).toBe('Minimal API'); - expect(firstElement.cards[0].icon).toBe(undefined); - expect(firstElement.apiData).toBeDefined(); + expect(firstElement.cards[0].icon).toBe(''); + expect(firstElement.api_data).toBeDefined(); }); it('should handle empty data array', () => { - const result = makeApiDataListPagesProps(emptyApiDataListPages()); + const result = makeApiDataListPagesProps({ data: emptyApiDataListPages() }); expect(result).toHaveLength(0); }); it('should handle page with empty api data', () => { - const result = makeApiDataListPagesProps(apiDataListPageWithEmptyApiData()); + const result = makeApiDataListPagesProps({ + data: apiDataListPageWithEmptyApiData(), + }); expect(result).toHaveLength(1); expect(result[0].cards).toHaveLength(0); expect(result[0].apiDetailSlugs).toHaveLength(0); }); it('should handle mixed API types and filter invalid ones', () => { - const result = makeApiDataListPagesProps( - apiDataListPageWithMixedApiTypes() - ); + const result = makeApiDataListPagesProps({ + data: apiDataListPageWithMixedApiTypes(), + }); expect(result).toHaveLength(1); const firstElement = result[0]; expect(firstElement.cards).toHaveLength(2); @@ -73,17 +75,17 @@ describe('makeApiDataListPagesProps', () => { }); it('should handle page without description', () => { - const result = makeApiDataListPagesProps( - apiDataListPageWithoutDescription() - ); + const result = makeApiDataListPagesProps({ + data: apiDataListPageWithoutDescription(), + }); expect(result).toHaveLength(1); expect(result[0].hero.subtitle).toBe(''); }); it('should filter out invalid API data', () => { - const result = makeApiDataListPagesProps( - apiDataListPageWithInvalidApiData() - ); + const result = makeApiDataListPagesProps({ + data: apiDataListPageWithInvalidApiData(), + }); expect(result).toHaveLength(1); const firstElement = result[0]; expect(firstElement.cards).toHaveLength(0); @@ -96,14 +98,16 @@ describe('makeApiDataListPagesProps', () => { }); it('should handle multiple pages', () => { - const result = makeApiDataListPagesProps(multipleApiDataListPages()); + const result = makeApiDataListPagesProps({ + data: multipleApiDataListPages(), + }); expect(result).toHaveLength(2); expect(result[0].hero.title).toBe('SEND API Documentation'); expect(result[1].hero.title).toBe('Second API List Page'); }); it('should correctly set hero properties', () => { - const result = makeApiDataListPagesProps(strapiApiDataListPages); + const result = makeApiDataListPagesProps({ data: strapiApiDataListPages }); expect(result[0].hero).toEqual({ title: 'SEND API Documentation', subtitle: 'Complete documentation for SEND APIs', @@ -111,7 +115,7 @@ describe('makeApiDataListPagesProps', () => { }); it('should correctly identify REST API type', () => { - const result = makeApiDataListPagesProps(strapiApiDataListPages); + const result = makeApiDataListPagesProps({ data: strapiApiDataListPages }); const restCard = result[0].cards.find( (card) => card.labels?.[0].label === 'REST' ); @@ -121,7 +125,7 @@ describe('makeApiDataListPagesProps', () => { }); it('should correctly identify SOAP API type', () => { - const result = makeApiDataListPagesProps(strapiApiDataListPages); + const result = makeApiDataListPagesProps({ data: strapiApiDataListPages }); const soapCard = result[0].cards.find( (card) => card.labels?.[0].label === 'SOAP' ); @@ -131,7 +135,7 @@ describe('makeApiDataListPagesProps', () => { }); it('should correctly map banner links', () => { - const result = makeApiDataListPagesProps(strapiApiDataListPages); + const result = makeApiDataListPagesProps({ data: strapiApiDataListPages }); const firstElement = result[0]; expect(firstElement.bannerLinks).toHaveLength(2); expect(firstElement.bannerLinks[0]).toHaveProperty('title'); @@ -139,7 +143,7 @@ describe('makeApiDataListPagesProps', () => { }); it('should correctly map SEO properties', () => { - const result = makeApiDataListPagesProps(strapiApiDataListPages); + const result = makeApiDataListPagesProps({ data: strapiApiDataListPages }); expect(result[0].seo).toEqual({ metaTitle: 'SEND API Documentation', metaDescription: 'Complete documentation for SEND APIs', @@ -147,14 +151,14 @@ describe('makeApiDataListPagesProps', () => { }); it('should correctly map updatedAt', () => { - const result = makeApiDataListPagesProps(strapiApiDataListPages); + const result = makeApiDataListPagesProps({ data: strapiApiDataListPages }); expect(result[0].updatedAt).toBe('2024-01-02T00:00:00.000Z'); }); it('should filter cards without title or tags', () => { - const result = makeApiDataListPagesProps( - apiDataListPageWithInvalidApiData() - ); + const result = makeApiDataListPagesProps({ + data: apiDataListPageWithInvalidApiData(), + }); expect(result[0].cards).toHaveLength(0); expect(spyOnConsoleError).toHaveBeenCalledWith( expect.stringContaining( @@ -164,12 +168,14 @@ describe('makeApiDataListPagesProps', () => { }); it('should handle API data with missing icon', () => { - const result = makeApiDataListPagesProps(minimalApiDataListPages()); - expect(result[0].cards[0].icon).toBe(undefined); + const result = makeApiDataListPagesProps({ + data: minimalApiDataListPages(), + }); + expect(result[0].cards[0].icon).toBe(''); }); it('should correctly generate href for cards', () => { - const result = makeApiDataListPagesProps(strapiApiDataListPages); + const result = makeApiDataListPagesProps({ data: strapiApiDataListPages }); const firstElement = result[0]; expect(firstElement.cards).toHaveLength(2); expect(firstElement.cards[0].href).toBe('/send/api/send-main'); @@ -177,9 +183,9 @@ describe('makeApiDataListPagesProps', () => { }); it('should prioritize REST slug over SOAP slug in apiDetailSlugs', () => { - const result = makeApiDataListPagesProps( - apiDataListPageWithBothRestAndSoap() - ); + const result = makeApiDataListPagesProps({ + data: apiDataListPageWithBothRestAndSoap(), + }); expect(result[0].apiDetailSlugs).toEqual(['rest-slug']); }); }); diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/makeBannerLink.test.ts b/apps/nextjs-website/src/lib/strapi/__tests__/makeBannerLink.test.ts index 3a558c4241..8dff2c4eaa 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/makeBannerLink.test.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/makeBannerLink.test.ts @@ -90,19 +90,15 @@ describe('makeBannerLinkProps', () => { const customBannerLink = { ...strapiBannerLink, icon: { - data: { - attributes: { - name: 'custom-icon.png', - alternativeText: 'Custom Icon', - caption: 'Icon caption', - width: 256, - height: 256, - ext: '.png', - mime: 'image/png', - size: 64, - url: 'https://example.com/custom-icon.png', - }, - }, + name: 'custom-icon.png', + alternativeText: 'Custom Icon', + caption: 'Icon caption', + width: 256, + height: 256, + ext: '.png', + mime: 'image/png', + size: 64, + url: 'https://example.com/custom-icon.png', }, }; diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/makeCaseHistories.test.ts b/apps/nextjs-website/src/lib/strapi/__tests__/makeCaseHistories.test.ts index 7554181658..a6846edf07 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/makeCaseHistories.test.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/makeCaseHistories.test.ts @@ -56,7 +56,7 @@ describe('makeCaseHistoriesProps', () => { expect(firstElement.products[1]).toMatchObject({ name: 'Second Product', slug: 'second-product', - logo: mediaJpeg().attributes, + logo: mediaJpeg(), }); }); diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/makeGuideListPageProps.test.ts b/apps/nextjs-website/src/lib/strapi/__tests__/makeGuideListPageProps.test.ts index 89d69952df..550dbba9ec 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/makeGuideListPageProps.test.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/makeGuideListPageProps.test.ts @@ -5,7 +5,6 @@ import { strapiEmptyGuideListPagesData, strapiGuideListPagesData, } from '@/lib/strapi/__tests__/fixtures/guideListPages'; -import { StrapiGuideListPages } from '@/lib/strapi/types/guideListPage'; import { guideListPagesWithItemMissingProductSlug, guideListPagesWithItemsMissingListItem, @@ -36,8 +35,17 @@ describe('makeGuideListPageProps', () => { }); it('should return a single element array of type GuideListPageProps with only one guide', () => { - const guideListWithMissingSlugsData = - guideListPagesWithItemsMissingSlug() as unknown as StrapiGuideListPages; + const guideListWithMissingSlugsData = { + data: [...guideListPagesWithItemsMissingSlug()], + meta: { + pagination: { + page: 1, + pageSize: 1, + pageCount: 1, + total: 1, + }, + }, + }; const result = makeGuideListPagesProps(guideListWithMissingSlugsData); expect(result).toHaveLength(1); expect(result[0]).toEqual({ @@ -54,8 +62,17 @@ describe('makeGuideListPageProps', () => { }); it('should return a single element array of type GuideListPageProps with guides without images', () => { - const guideListWithMissingImagesData = - guideListPagesWithItemsMissingImages() as unknown as StrapiGuideListPages; + const guideListWithMissingImagesData = { + data: [...guideListPagesWithItemsMissingImages()], + meta: { + pagination: { + page: 1, + pageSize: 1, + pageCount: 1, + total: 1, + }, + }, + }; const result = makeGuideListPagesProps(guideListWithMissingImagesData); expect(result).toHaveLength(1); expect(result[0]).toEqual({ @@ -72,8 +89,7 @@ describe('makeGuideListPageProps', () => { }); it('should return a single element array of type GuideListPageProps with only one guide', () => { - const guideListWithInvalidData = - guideListPagesWithItemsMissingListItem() as unknown as StrapiGuideListPages; + const guideListWithInvalidData = guideListPagesWithItemsMissingListItem(); const result = makeGuideListPagesProps(guideListWithInvalidData); expect(result).toHaveLength(1); expect(result[0].guidesSections).toHaveLength(2); diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/makeHomepage.test.ts b/apps/nextjs-website/src/lib/strapi/__tests__/makeHomepage.test.ts index 4f7d94d443..a1c99d7ec9 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/makeHomepage.test.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/makeHomepage.test.ts @@ -14,12 +14,12 @@ import { describe('makeHomepageProps', () => { it('should transform strapi homepage to homepage props', () => { - const result = makeHomepageProps(_.cloneDeep(strapiHomepage)); + const result = makeHomepageProps(_.cloneDeep({ data: strapiHomepage })); expect(result).toMatchObject(expectedHomepageProps); }); it('should handle minimal data with missing optional fields', () => { - const result = makeHomepageProps(minimalDataHomepage()); + const result = makeHomepageProps({ data: minimalDataHomepage() }); expect(result.comingsoonDocumentation.title).toBe('Minimal Documentation'); expect(result.comingsoonDocumentation.links).toEqual([]); expect(result.hero).toHaveLength(1); @@ -32,35 +32,35 @@ describe('makeHomepageProps', () => { }); it('should handle homepage without news showcase', () => { - const result = makeHomepageProps(homepageWithoutNewsShowcase()); + const result = makeHomepageProps({ data: homepageWithoutNewsShowcase() }); expect(result.newsShowcase).toBeUndefined(); expect(result.ecosystem).toBeDefined(); expect(result.webinars).toBeDefined(); }); it('should handle homepage without ecosystem', () => { - const result = makeHomepageProps(homepageWithoutEcosystem()); + const result = makeHomepageProps({ data: homepageWithoutEcosystem() }); expect(result.ecosystem).toBeUndefined(); expect(result.newsShowcase).toBeDefined(); expect(result.webinars).toBeDefined(); }); it('should handle homepage without webinars', () => { - const result = makeHomepageProps(homepageWithoutWebinars()); + const result = makeHomepageProps({ data: homepageWithoutWebinars() }); expect(result.webinars).toEqual([]); expect(result.newsShowcase).toBeDefined(); expect(result.ecosystem).toBeDefined(); }); it('should handle homepage without seo', () => { - const result = makeHomepageProps(homepageWithoutSeo()); + const result = makeHomepageProps({ data: homepageWithoutSeo() }); expect(result.seo).toBeUndefined(); expect(result.newsShowcase).toBeDefined(); expect(result.ecosystem).toBeDefined(); }); it('should correctly map hero slider background images', () => { - const result = makeHomepageProps(_.cloneDeep(strapiHomepage)); + const result = makeHomepageProps(_.cloneDeep({ data: strapiHomepage })); expect(result.hero[0].backgroundImage).toEqual({ url: 'https://example.com/example.jpg', alternativeText: 'Example Image', @@ -75,7 +75,7 @@ describe('makeHomepageProps', () => { }); it('should correctly map ecosystem products and solutions', () => { - const result = makeHomepageProps(_.cloneDeep(strapiHomepage)); + const result = makeHomepageProps(_.cloneDeep({ data: strapiHomepage })); expect(result.ecosystem?.products).toEqual([ { title: 'Product 1', @@ -97,7 +97,7 @@ describe('makeHomepageProps', () => { }); it('should correctly transform news showcase items', () => { - const result = makeHomepageProps(_.cloneDeep(strapiHomepage)); + const result = makeHomepageProps(_.cloneDeep({ data: strapiHomepage })); expect(result.newsShowcase?.items).toHaveLength(3); expect(result.newsShowcase?.items[0]).toMatchObject({ title: diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/makeProducts.test.ts b/apps/nextjs-website/src/lib/strapi/__tests__/makeProducts.test.ts index e56aeab000..9430c45ee6 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/makeProducts.test.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/makeProducts.test.ts @@ -16,7 +16,6 @@ import { productWithCorruptedData, mixedValidAndInvalidProducts, allInvalidProducts, - productWithMissingAttributes, productsWithAnItemWithEmptySlug, productsWithAnItemMissingSlug, } from '@/lib/strapi/__tests__/factories/products'; @@ -34,7 +33,19 @@ describe('makeProductsProps', () => { }); it('should handle minimal product data', () => { - const result = makeProductsProps(_.cloneDeep(minimalProduct())); + const result = makeProductsProps( + _.cloneDeep({ + data: [...minimalProduct()], + meta: { + pagination: { + page: 1, + pageSize: 25, + pageCount: 1, + total: 1, + }, + }, + }) + ); expect(result).toHaveLength(1); expect(result[0].name).toBe('Minimal Product'); expect(result[0].slug).toBe('minimal-product'); @@ -59,8 +70,17 @@ describe('makeProductsProps', () => { }); it('should skip products without slug and log error', () => { - const result = makeProductsProps(productsWithAnItemMissingSlug()); - + const result = makeProductsProps({ + data: [...productsWithAnItemMissingSlug()], + meta: { + pagination: { + page: 1, + pageSize: 25, + pageCount: 1, + total: 1, + }, + }, + }); expect(result).toHaveLength(0); expect(spyOnConsoleError).toHaveBeenCalledWith( 'Error while processing Product: missing title or slug. Title: Product Without Slug | Slug: undefined. Skipping...' @@ -68,19 +88,49 @@ describe('makeProductsProps', () => { }); it('should handle products with multiple API data (returns general API URL)', () => { - const result = makeProductsProps(productWithMultipleApiData()); + const result = makeProductsProps({ + data: [...productWithMultipleApiData()], + meta: { + pagination: { + page: 1, + pageSize: 25, + pageCount: 1, + total: 1, + }, + }, + }); expect(result[0].hasApiDataListPage).toBe(true); expect(result[0].apiDataListPageUrl).toBe('/test-product/api'); }); it('should handle products with empty API data', () => { - const result = makeProductsProps(productWithEmptyApiData()); + const result = makeProductsProps({ + data: [...productWithEmptyApiData()], + meta: { + pagination: { + page: 1, + pageSize: 25, + pageCount: 1, + total: 1, + }, + }, + }); expect(result[0].hasApiDataListPage).toBe(false); expect(result[0].apiDataListPageUrl).toBeUndefined(); }); it('should handle corrupted data with try/catch and log error', () => { - const result = makeProductsProps(productWithCorruptedData()); + const result = makeProductsProps({ + data: [...productWithCorruptedData()], + meta: { + pagination: { + page: 1, + pageSize: 25, + pageCount: 1, + total: 1, + }, + }, + }); expect(result).toHaveLength(0); expect(spyOnConsoleError).toHaveBeenCalledWith( @@ -91,7 +141,17 @@ describe('makeProductsProps', () => { }); it('should handle mixed valid and invalid products', () => { - const result = makeProductsProps(mixedValidAndInvalidProducts()); + const result = makeProductsProps({ + data: [...mixedValidAndInvalidProducts()], + meta: { + pagination: { + page: 1, + pageSize: 25, + pageCount: 1, + total: 1, + }, + }, + }); expect(result).toHaveLength(2); expect(result[0].name).toBe('Test Product'); @@ -102,7 +162,17 @@ describe('makeProductsProps', () => { }); it('should return empty array when all products are invalid', () => { - const result = makeProductsProps(allInvalidProducts()); + const result = makeProductsProps({ + data: [...allInvalidProducts()], + meta: { + pagination: { + page: 1, + pageSize: 25, + pageCount: 1, + total: 1, + }, + }, + }); expect(result).toHaveLength(0); expect(spyOnConsoleError).toHaveBeenCalledTimes(2); @@ -124,7 +194,7 @@ describe('makeProductProps', () => { }); it('should return null for product without slug', () => { - const result = makeProductProps(productsWithAnItemMissingSlug().data[0]); + const result = makeProductProps(productsWithAnItemMissingSlug()[0]); expect(result).toBeNull(); expect(spyOnConsoleError).toHaveBeenCalledWith( 'Error while processing Product: missing title or slug. Title: Product Without Slug | Slug: undefined. Skipping...' @@ -132,19 +202,10 @@ describe('makeProductProps', () => { }); it('should return null and log error for corrupted product', () => { - const result = makeProductProps(productWithCorruptedData().data[0]); + const result = makeProductProps(productWithCorruptedData()[0]); expect(result).toBeNull(); expect(spyOnConsoleError).toHaveBeenCalledTimes(1); }); - - it('should return null and log error for product with missing attributes', () => { - const result = makeProductProps(productWithMissingAttributes()); - expect(result).toBeNull(); - expect(spyOnConsoleError).toHaveBeenCalledWith( - 'Invalid product data:', - productWithMissingAttributes() - ); - }); }); describe('makeBaseProductWithoutLogoProps', () => { @@ -170,7 +231,7 @@ describe('makeBaseProductWithoutLogoProps', () => { }); it('should handle product with no banner links', () => { - const result = makeBaseProductWithoutLogoProps(minimalProduct().data[0]); + const result = makeBaseProductWithoutLogoProps(minimalProduct()[0]); expect(result.bannerLinks).toEqual([]); }); @@ -181,20 +242,20 @@ describe('makeBaseProductWithoutLogoProps', () => { it('should correctly determine API data list page URL for multiple APIs', () => { const result = makeBaseProductWithoutLogoProps( - productWithMultipleApiData().data[0] + productWithMultipleApiData()[0] ); expect(result.apiDataListPageUrl).toBe('/test-product/api'); }); it('should handle undefined API data list page', () => { - const result = makeBaseProductWithoutLogoProps(minimalProduct().data[0]); + const result = makeBaseProductWithoutLogoProps(minimalProduct()[0]); expect(result.hasApiDataListPage).toBe(false); expect(result.apiDataListPageUrl).toBeUndefined(); }); it('should throw error for product without slug', () => { expect(() => - makeBaseProductWithoutLogoProps(productsWithAnItemMissingSlug().data[0]) + makeBaseProductWithoutLogoProps(productsWithAnItemMissingSlug()[0]) ).toThrow( Error( 'Error while processing Product with name "Product Without Slug": missing slug. Skipping...' @@ -204,7 +265,7 @@ describe('makeBaseProductWithoutLogoProps', () => { it('should throw error for product with empty slug', () => { expect(() => - makeBaseProductWithoutLogoProps(productsWithAnItemWithEmptySlug().data[0]) + makeBaseProductWithoutLogoProps(productsWithAnItemWithEmptySlug()[0]) ).toThrow( Error( 'Error while processing Product with name "Product Without Slug": missing slug. Skipping...' diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/makeSolutionListPage.test.ts b/apps/nextjs-website/src/lib/strapi/__tests__/makeSolutionListPage.test.ts index 66539632cb..4d54b0221f 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/makeSolutionListPage.test.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/makeSolutionListPage.test.ts @@ -9,8 +9,6 @@ import { solutionListPageWithoutCaseHistories, solutionListPageWithoutFeatures, solutionListPageWithoutSolutions, - solutionListPageWithMissingSolutionSlug, - solutionListPageWithMissingCaseHistorySlug, } from '@/lib/strapi/__tests__/factories/solutionListPage'; import { spyOnConsoleError } from '@/lib/strapi/__tests__/spyOnConsole'; @@ -25,13 +23,15 @@ describe('makeSolutionListPageProps', () => { it('should transform strapi solution list page to solution list template props', () => { const result = makeSolutionListPageProps( - _.cloneDeep(strapiSolutionListPage) + _.cloneDeep({ data: strapiSolutionListPage }) ); expect(result).toMatchObject(expectedSolutionListTemplateProps); }); it('should handle minimal data with missing optional fields', () => { - const result = makeSolutionListPageProps(minimalDataSolutionListPage()); + const result = makeSolutionListPageProps({ + data: minimalDataSolutionListPage(), + }); expect(result).not.toBeNull(); expect(result.hero.title).toBe('Minimal Solutions'); expect(result.solutions).toEqual([]); @@ -41,25 +41,27 @@ describe('makeSolutionListPageProps', () => { }); it('should handle solution list page without case histories', () => { - const result = makeSolutionListPageProps( - solutionListPageWithoutCaseHistories() - ); + const result = makeSolutionListPageProps({ + data: solutionListPageWithoutCaseHistories(), + }); expect(result.successStories).toBeUndefined(); expect(result.solutions).toBeDefined(); expect(result.features).toBeDefined(); }); it('should handle solution list page without features', () => { - const result = makeSolutionListPageProps(solutionListPageWithoutFeatures()); + const result = makeSolutionListPageProps({ + data: solutionListPageWithoutFeatures(), + }); expect(result.features).toBeUndefined(); expect(result.successStories).toBeDefined(); expect(result.solutions).toBeDefined(); }); it('should handle solution list page without solutions', () => { - const result = makeSolutionListPageProps( - solutionListPageWithoutSolutions() - ); + const result = makeSolutionListPageProps({ + data: solutionListPageWithoutSolutions(), + }); expect(result.solutions).toEqual([]); expect(result.successStories).toBeDefined(); expect(result.features).toBeDefined(); @@ -67,7 +69,7 @@ describe('makeSolutionListPageProps', () => { it('should correctly map solution tags from products', () => { const result = makeSolutionListPageProps( - _.cloneDeep(strapiSolutionListPage) + _.cloneDeep({ data: strapiSolutionListPage }) ); expect(result.solutions[0].labels).toEqual([ { @@ -79,30 +81,8 @@ describe('makeSolutionListPageProps', () => { it('should correctly build solution slug path', () => { const result = makeSolutionListPageProps( - _.cloneDeep(strapiSolutionListPage) + _.cloneDeep({ data: strapiSolutionListPage }) ); expect(result.solutions[0].slug).toBe('solutions/solution-1'); }); - - it('should skip solutions with missing slug and log error', () => { - const result = makeSolutionListPageProps( - solutionListPageWithMissingSolutionSlug() - ); - expect(result.solutions).toHaveLength(1); - expect(result.solutions[0].name).toBe('Valid Solution'); - expect(spyOnConsoleError).toHaveBeenCalledWith( - 'Error while processing Solution with title "Solution Without Slug": missing slug. Skipping...' - ); - }); - - it('should skip case histories with missing slug and log error', () => { - const result = makeSolutionListPageProps( - solutionListPageWithMissingCaseHistorySlug() - ); - expect(result.successStories?.stories).toHaveLength(1); - expect(result.successStories?.stories[0].title).toBe('Valid Case History'); - expect(spyOnConsoleError).toHaveBeenCalledWith( - 'Error while processing CaseHistory with title "Case History Without Slug": missing slug. Skipping...' - ); - }); }); diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/makeUrlReplaceMap.test.ts b/apps/nextjs-website/src/lib/strapi/__tests__/makeUrlReplaceMap.test.ts index a9f9b9005e..5b8b87e12f 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/makeUrlReplaceMap.test.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/makeUrlReplaceMap.test.ts @@ -10,13 +10,15 @@ import { describe('makeUrlReplaceMap', () => { it('should map a single entry with subPath', () => { - const urlReplaceMap = makeUrlReplaceMap(strapiUrlReplaceMapFixture); + const urlReplaceMap = makeUrlReplaceMap({ + data: strapiUrlReplaceMapFixture, + }); expect(urlReplaceMap).toEqual(expectedUrlReplaceMapFixture); }); it('should map a single entry without subPath', () => { const data = urlReplaceMapSingle({ subPath: undefined }); - const urlReplaceMap = makeUrlReplaceMap(data); + const urlReplaceMap = makeUrlReplaceMap({ data: data }); expect(urlReplaceMap).toEqual({ 'source-url': '/product-slug/guides/guide-slug', @@ -25,7 +27,7 @@ describe('makeUrlReplaceMap', () => { it('should map multiple entries', () => { const data = urlReplaceMapMultiple(); - const urlReplaceMap = makeUrlReplaceMap(data); + const urlReplaceMap = makeUrlReplaceMap({ data: data }); expect(urlReplaceMap).toEqual({ a: '/product-slug/guides/guide-slug', diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/makeUseCases.test.ts b/apps/nextjs-website/src/lib/strapi/__tests__/makeUseCases.test.ts index 46578d5321..f927652907 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/makeUseCases.test.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/makeUseCases.test.ts @@ -19,7 +19,7 @@ describe('makeUseCasesProps', () => { }); it('should transform strapi use cases to use cases props', () => { - const result = makeUseCasesProps(_.cloneDeep(strapiUseCases), {}); + const result = makeUseCasesProps(strapiUseCases, {}); expect(result).toHaveLength(1); expect(result[0]).toMatchObject({ coverImage: { diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/makeWebinarCategories.test.ts b/apps/nextjs-website/src/lib/strapi/__tests__/makeWebinarCategories.test.ts index 94658a2140..c4e6efe848 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/makeWebinarCategories.test.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/makeWebinarCategories.test.ts @@ -12,11 +12,11 @@ describe('makeWebinarCategoriesProps', () => { expect(result).toHaveLength(2); expect(result[0]).toEqual({ name: 'Payments', - icon: { data: mediaJpeg() }, + icon: mediaJpeg(), }); expect(result[1]).toEqual({ name: 'Onboarding', - icon: { data: mediaJpeg() }, + icon: mediaJpeg(), }); }); @@ -33,18 +33,14 @@ describe('makeWebinarCategoryProps', () => { const result = makeWebinarCategoryProps(category); expect(result).toEqual({ name: 'Payments', - icon: { data: mediaJpeg() }, + icon: mediaJpeg(), }); }); it('should handle missing icon', () => { const category = { ...strapiWebinarCategories.data[0], - attributes: { - ...strapiWebinarCategories.data[0].attributes, - // eslint-disable-next-line @typescript-eslint/no-explicit-any - icon: undefined as any, - }, + icon: undefined as any, } satisfies StrapiWebinarCategory; const result = makeWebinarCategoryProps(category); diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/makeWebinars.test.ts b/apps/nextjs-website/src/lib/strapi/__tests__/makeWebinars.test.ts index eb77834272..904046f570 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/makeWebinars.test.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/makeWebinars.test.ts @@ -1,11 +1,7 @@ import { makeWebinarsProps } from '@/lib/strapi/makeProps/makeWebinars'; import { StrapiWebinars } from '@/lib/strapi/types/webinars'; import _ from 'lodash'; -import { - strapiWebinars, - strapiWebinarsWithMissingData, - webinarProps, -} from './fixtures/webinars'; +import { strapiWebinars, webinarProps } from './fixtures/webinars'; import { spyOnConsoleError } from '@/lib/strapi/__tests__/spyOnConsole'; describe('makeWebinarsProps', () => { @@ -23,14 +19,6 @@ describe('makeWebinarsProps', () => { expect(result[0]).toMatchObject(webinarProps); }); - it('should handle a payload with two object with the second one with missing data and successfully return webinar props with only one item', () => { - const result = makeWebinarsProps( - _.cloneDeep(strapiWebinarsWithMissingData) - ); - expect(result).toHaveLength(1); - expect(result[0]).toMatchObject(webinarProps); - }); - it('should handle empty data array', () => { const emptyData: StrapiWebinars = { data: [], @@ -51,11 +39,9 @@ describe('makeWebinarsProps', () => { const corruptedData: StrapiWebinars = { data: [ { - id: 1, - attributes: { - // Missing required coverImage field to trigger error - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } as any, + ...strapiWebinars.data[0], + title: undefined as any, + slug: undefined as any, }, ], meta: { diff --git a/apps/nextjs-website/src/lib/strapi/fetches/fetchApiDataList.ts b/apps/nextjs-website/src/lib/strapi/fetches/fetchApiDataList.ts index 7dc06ff304..9fd19487a5 100644 --- a/apps/nextjs-website/src/lib/strapi/fetches/fetchApiDataList.ts +++ b/apps/nextjs-website/src/lib/strapi/fetches/fetchApiDataList.ts @@ -2,15 +2,16 @@ import qs from 'qs'; import { fetchFromStrapi } from '@/lib/strapi/fetchFromStrapi'; import { productRelationsPopulate } from '@/lib/strapi/fetches/fetchProducts'; import { StrapiApiDataList } from '@/lib/strapi/types/apiDataList'; +import { RootEntity } from '@/lib/strapi/types/rootEntity'; const makeStrapiApiDataListPopulate = () => qs.stringify({ populate: { apiRestDetail: { - populate: ['slug', 'specUrls'], + populate: ['specUrls'], }, apiSoapDetail: { - populate: ['slug', 'repositoryUrl', 'dirName'], + populate: '*', }, icon: { populate: '*' }, product: { @@ -20,14 +21,14 @@ const makeStrapiApiDataListPopulate = () => populate: ['icon'], }, seo: { - populate: '*,metaImage,metaSocial.image', + populate: '*', }, }, }); // This endpoint does not respect the naming convention but we keep it // for backward compatibility with the already existing content in Strapi's production instance -export const fetchApiDataList = fetchFromStrapi( +export const fetchApiDataList = fetchFromStrapi>( 'apis-data', makeStrapiApiDataListPopulate() ); diff --git a/apps/nextjs-website/src/lib/strapi/fetches/fetchApiDataListPages.ts b/apps/nextjs-website/src/lib/strapi/fetches/fetchApiDataListPages.ts index b45cec1bdf..b982575e7c 100644 --- a/apps/nextjs-website/src/lib/strapi/fetches/fetchApiDataListPages.ts +++ b/apps/nextjs-website/src/lib/strapi/fetches/fetchApiDataListPages.ts @@ -2,17 +2,18 @@ import * as qs from 'qs'; import { fetchFromStrapi } from '@/lib/strapi/fetchFromStrapi'; import { productRelationsPopulate } from '@/lib/strapi/fetches/fetchProducts'; import { StrapiApiDataListPages } from '@/lib/strapi/types/apiDataListPages'; +import { RootEntity } from '@/lib/strapi/types/rootEntity'; const makeStrapiApiDataListPagePopulate = () => qs.stringify({ populate: { - apiData: { + api_data: { populate: { apiRestDetail: { - populate: ['slug', 'specUrls'], + populate: '*', }, apiSoapDetail: { - populate: ['slug', 'repositoryUrl', 'dirName'], + populate: '*', }, icon: { populate: '*' }, product: { populate: 'logo' }, @@ -26,13 +27,11 @@ const makeStrapiApiDataListPagePopulate = () => populate: ['icon'], }, seo: { - populate: '*,metaImage,metaSocial.image', + populate: '*', }, - enableFilters: true, }, }); -export const fetchApiDataListPages = fetchFromStrapi( - 'api-data-list-pages', - makeStrapiApiDataListPagePopulate() -); +export const fetchApiDataListPages = fetchFromStrapi< + RootEntity +>('api-data-list-pages', makeStrapiApiDataListPagePopulate()); diff --git a/apps/nextjs-website/src/lib/strapi/fetches/fetchCaseHistories.ts b/apps/nextjs-website/src/lib/strapi/fetches/fetchCaseHistories.ts index 3dab8784c6..a21516f793 100644 --- a/apps/nextjs-website/src/lib/strapi/fetches/fetchCaseHistories.ts +++ b/apps/nextjs-website/src/lib/strapi/fetches/fetchCaseHistories.ts @@ -5,20 +5,17 @@ import { StrapiCaseHistories } from '@/lib/strapi/types/caseHistories'; const makeStrapiCaseHistoriesPopulate = () => qs.stringify({ populate: { - image: 'image', + image: { + populate: '*', + }, parts: { - populate: [ - 'responseCode', - 'requestCode', - 'requestAttributes', - 'backgroundImage', - ], + populate: '*', }, products: { populate: ['logo'], }, seo: { - populate: '*,metaImage,metaSocial.image', + populate: '*', }, }, }); diff --git a/apps/nextjs-website/src/lib/strapi/fetches/fetchGuideListPages.ts b/apps/nextjs-website/src/lib/strapi/fetches/fetchGuideListPages.ts index 5de1745f11..020a05d135 100644 --- a/apps/nextjs-website/src/lib/strapi/fetches/fetchGuideListPages.ts +++ b/apps/nextjs-website/src/lib/strapi/fetches/fetchGuideListPages.ts @@ -16,7 +16,7 @@ const makeStrapiGuideListPopulate = () => populate: ['icon'], }, seo: { - populate: '*,metaImage,metaSocial.image', + populate: '*', }, }, }); diff --git a/apps/nextjs-website/src/lib/strapi/fetches/fetchHomepage.ts b/apps/nextjs-website/src/lib/strapi/fetches/fetchHomepage.ts index cdf548d812..8af2042142 100644 --- a/apps/nextjs-website/src/lib/strapi/fetches/fetchHomepage.ts +++ b/apps/nextjs-website/src/lib/strapi/fetches/fetchHomepage.ts @@ -2,6 +2,7 @@ import * as qs from 'qs'; import { webinarPopulate } from '@/lib/strapi/fetches/fetchWebinars'; import { fetchFromStrapi } from '@/lib/strapi/fetchFromStrapi'; import { StrapiHomepage } from '@/lib/strapi/types/homepage'; +import { RootEntity } from '@/lib/strapi/types/rootEntity'; const makeStrapiHomepagePopulate = () => qs.stringify({ @@ -15,36 +16,27 @@ const makeStrapiHomepagePopulate = () => newsShowcase: { populate: ['link', 'items.image', 'items.link'], }, - productsShowcase: { - populate: ['products.logo'], - }, webinars: webinarPopulate, ecosystem: { - populate: [ - 'products.logo', - 'products.bannerLinks.icon', - 'products.overview', - 'products.release_note', - 'products.quickstart_guide', - 'products.api_data_list_page', - 'products.api_data_list_page.apiData.*', - 'products.api_data_list_page.apiData.apiRestDetail.slug', - 'products.api_data_list_page.apiData.apiRestDetail.specUrls', - 'products.api_data_list_page.apiData.apiSoapDetail.*', - 'products.guide_list_page', - 'products.tutorial_list_page', - 'solutions.icon', - 'solutions.product.logo', - 'solutionsCta.link', - ], - }, - seo: { - populate: '*,metaImage,metaSocial.image', + populate: { + products: { + populate: ['logo'], + }, + solutions: { + populate: '*', + }, + solutionsCta: { + populate: ['link'], + }, + }, }, }, + seo: { + populate: '*', + }, }); -export const fetchHomepage = fetchFromStrapi( +export const fetchHomepage = fetchFromStrapi>( 'homepage', makeStrapiHomepagePopulate() ); diff --git a/apps/nextjs-website/src/lib/strapi/fetches/fetchOverviews.ts b/apps/nextjs-website/src/lib/strapi/fetches/fetchOverviews.ts index 2847fff280..6d12922d8d 100644 --- a/apps/nextjs-website/src/lib/strapi/fetches/fetchOverviews.ts +++ b/apps/nextjs-website/src/lib/strapi/fetches/fetchOverviews.ts @@ -6,7 +6,9 @@ import { StrapiOverviews } from '@/lib/strapi/types/overviews'; const makeStrapiOverviewsPopulate = () => qs.stringify({ populate: { - backgroundImage: '*', + backgroundImage: { + populate: '*', + }, product: { ...productRelationsPopulate, }, @@ -26,7 +28,7 @@ const makeStrapiOverviewsPopulate = () => populate: ['useCases.coverImage', 'useCases.product'], }, seo: { - populate: '*,metaImage,metaSocial.image', + populate: '*', }, postIntegration: { populate: [ diff --git a/apps/nextjs-website/src/lib/strapi/fetches/fetchProducts.ts b/apps/nextjs-website/src/lib/strapi/fetches/fetchProducts.ts index 2b947eb7a2..9d09b6c745 100644 --- a/apps/nextjs-website/src/lib/strapi/fetches/fetchProducts.ts +++ b/apps/nextjs-website/src/lib/strapi/fetches/fetchProducts.ts @@ -4,22 +4,36 @@ import { StrapiProducts } from '@/lib/strapi/types/product'; // TODO: divide this populate in more specific ones for query optimization export const productRelationsPopulate = { - populate: [ - 'logo', - 'bannerLinks.icon', - 'overview', - 'quickstart_guide', - 'release_note', - 'api_data_list_page', - 'api_data_list_page.apiData.*', - 'api_data_list_page.apiData.apiRestDetail.slug', - 'api_data_list_page.apiData.apiRestDetail.specUrls', - 'api_data_list_page.apiData.apiSoapDetail.*', - 'guide_list_page', - 'tutorial_list_page', - 'use_case_list_page', - 'tags.icon', - ], + populate: { + logo: { populate: '*' }, + bannerLinks: { + populate: ['icon'], + }, + overview: { + populate: '*', + }, + quickstart_guide: { + populate: '*', + }, + release_note: { + populate: '*', + }, + api_data_list_page: { + populate: '*', + }, + guide_list_page: { + populate: '*', + }, + tutorial_list_page: { + populate: '*', + }, + use_case_list_page: { + populate: '*', + }, + tags: { + populate: ['icon'], + }, + }, }; const makeStrapiProductsPopulate = () => diff --git a/apps/nextjs-website/src/lib/strapi/fetches/fetchQuickStartGuides.ts b/apps/nextjs-website/src/lib/strapi/fetches/fetchQuickStartGuides.ts index 371301d4fc..f649721b83 100644 --- a/apps/nextjs-website/src/lib/strapi/fetches/fetchQuickStartGuides.ts +++ b/apps/nextjs-website/src/lib/strapi/fetches/fetchQuickStartGuides.ts @@ -17,7 +17,7 @@ const makeStrapiQuickStartGuidesPopulate = () => populate: ['icon'], }, seo: { - populate: '*,metaImage,metaSocial.image', + populate: '*', }, }, }); diff --git a/apps/nextjs-website/src/lib/strapi/fetches/fetchSolutionListPage.ts b/apps/nextjs-website/src/lib/strapi/fetches/fetchSolutionListPage.ts index 36a71f1946..a88231dab0 100644 --- a/apps/nextjs-website/src/lib/strapi/fetches/fetchSolutionListPage.ts +++ b/apps/nextjs-website/src/lib/strapi/fetches/fetchSolutionListPage.ts @@ -1,6 +1,7 @@ import * as qs from 'qs'; import { fetchFromStrapi } from '@/lib/strapi/fetchFromStrapi'; import { StrapiSolutionListPage } from '../types/solutionListPage'; +import { RootEntity } from '@/lib/strapi/types/rootEntity'; const makeStrapiSolutionListPagePopulate = () => qs.stringify({ @@ -11,7 +12,6 @@ const makeStrapiSolutionListPagePopulate = () => 'bannerLinks.icon', 'products.logo', 'icon', - 'icon.name', 'stats', 'steps', 'steps.products', @@ -29,12 +29,11 @@ const makeStrapiSolutionListPagePopulate = () => populate: ['items.icon'], }, seo: { - populate: '*,metaImage,metaSocial.image', + populate: '*', }, }, }); -export const fetchSolutionListPage = fetchFromStrapi( - 'solution-list-page', - makeStrapiSolutionListPagePopulate() -); +export const fetchSolutionListPage = fetchFromStrapi< + RootEntity +>('solution-list-page', makeStrapiSolutionListPagePopulate()); diff --git a/apps/nextjs-website/src/lib/strapi/fetches/fetchTutorialListPages.ts b/apps/nextjs-website/src/lib/strapi/fetches/fetchTutorialListPages.ts index 40120f210d..955eae203a 100644 --- a/apps/nextjs-website/src/lib/strapi/fetches/fetchTutorialListPages.ts +++ b/apps/nextjs-website/src/lib/strapi/fetches/fetchTutorialListPages.ts @@ -16,9 +16,8 @@ const makeStrapiTutorialListPagePopulate = () => populate: ['icon'], }, seo: { - populate: '*,metaImage,metaSocial.image', + populate: '*', }, - enableFilters: true, }, }); diff --git a/apps/nextjs-website/src/lib/strapi/fetches/fetchTutorials.ts b/apps/nextjs-website/src/lib/strapi/fetches/fetchTutorials.ts index a311d77b87..e72bef5c53 100644 --- a/apps/nextjs-website/src/lib/strapi/fetches/fetchTutorials.ts +++ b/apps/nextjs-website/src/lib/strapi/fetches/fetchTutorials.ts @@ -6,15 +6,15 @@ import { StrapiTutorials } from '@/lib/strapi/types/tutorial'; const makeStrapiTutorialsPopulate = () => qs.stringify({ populate: { + image: { + populate: '*', + }, + parts: { + populate: '*', + }, relatedLinks: { populate: ['links'], }, - description: '*', - icon: { populate: ['icon'] }, - image: { - populate: ['image'], - }, - parts: '*', product: { ...productRelationsPopulate, }, @@ -22,7 +22,7 @@ const makeStrapiTutorialsPopulate = () => populate: ['icon'], }, seo: { - populate: '*,metaImage,metaSocial.image', + populate: '*', }, tags: { populate: '*', diff --git a/apps/nextjs-website/src/lib/strapi/fetches/fetchUrlReplaceMap.ts b/apps/nextjs-website/src/lib/strapi/fetches/fetchUrlReplaceMap.ts index 7accc2def8..74d387e6b8 100644 --- a/apps/nextjs-website/src/lib/strapi/fetches/fetchUrlReplaceMap.ts +++ b/apps/nextjs-website/src/lib/strapi/fetches/fetchUrlReplaceMap.ts @@ -1,6 +1,7 @@ import { StrapiUrlReplaceMap } from '@/lib/strapi/types/urlReplaceMap'; import { fetchFromStrapi } from '@/lib/strapi/fetchFromStrapi'; import qs from 'qs'; +import { RootEntity } from '@/lib/strapi/types/rootEntity'; const makeStrapiUrlReplaceMapPopulate = () => qs.stringify({ @@ -15,7 +16,6 @@ const makeStrapiUrlReplaceMapPopulate = () => }, }); -export const fetchUrlReplaceMap = fetchFromStrapi( - 'url-replace-map', - makeStrapiUrlReplaceMapPopulate() -); +export const fetchUrlReplaceMap = fetchFromStrapi< + RootEntity +>('url-replace-map', makeStrapiUrlReplaceMapPopulate()); diff --git a/apps/nextjs-website/src/lib/strapi/fetches/fetchUseCaseListPages.ts b/apps/nextjs-website/src/lib/strapi/fetches/fetchUseCaseListPages.ts index 014f526954..91cab84390 100644 --- a/apps/nextjs-website/src/lib/strapi/fetches/fetchUseCaseListPages.ts +++ b/apps/nextjs-website/src/lib/strapi/fetches/fetchUseCaseListPages.ts @@ -9,15 +9,14 @@ const makeStrapiUseCaseListPagePopulate = () => bannerLinks: { populate: ['icon'], }, - enableFilters: true, product: { ...productRelationsPopulate, }, seo: { - populate: '*,metaImage,metaSocial.image', + populate: '*', }, useCases: { - populate: ['coverImage', 'product', 'tags'], + populate: '*', }, }, }); diff --git a/apps/nextjs-website/src/lib/strapi/fetches/fetchUseCases.ts b/apps/nextjs-website/src/lib/strapi/fetches/fetchUseCases.ts index d1d237b531..e9a28d48ec 100644 --- a/apps/nextjs-website/src/lib/strapi/fetches/fetchUseCases.ts +++ b/apps/nextjs-website/src/lib/strapi/fetches/fetchUseCases.ts @@ -10,12 +10,21 @@ const makeStrapiUseCasesPopulate = () => populate: ['icon'], }, coverImage: { - populate: ['image'], + populate: '*', }, headerImage: { - populate: ['image'], + populate: '*', + }, + parts: { + on: { + 'parts.html': { populate: '*' }, + 'parts.alert': { populate: '*' }, + 'parts.ck-editor': { populate: '*' }, + 'parts.code-block': { populate: '*' }, + 'parts.embed-html': { populate: '*' }, + 'parts.markdown': { populate: '*' }, + }, }, - parts: '*', product: { ...productRelationsPopulate, }, @@ -23,7 +32,7 @@ const makeStrapiUseCasesPopulate = () => populate: ['links'], }, seo: { - populate: '*,metaImage,metaSocial.image', + populate: '*', }, tags: { populate: '*', diff --git a/apps/nextjs-website/src/lib/strapi/fetches/fetchWebinars.ts b/apps/nextjs-website/src/lib/strapi/fetches/fetchWebinars.ts index a0f73d160a..19ad1a1559 100644 --- a/apps/nextjs-website/src/lib/strapi/fetches/fetchWebinars.ts +++ b/apps/nextjs-website/src/lib/strapi/fetches/fetchWebinars.ts @@ -5,10 +5,10 @@ import { StrapiWebinars } from '@/lib/strapi/types/webinars'; export const webinarPopulate = { populate: { coverImage: { - populate: ['image'], + populate: '*', }, playerCoverImage: { - populate: ['image'], + populate: '*', }, webinarSpeakers: { populate: ['avatar'], @@ -19,7 +19,7 @@ export const webinarPopulate = { relatedResources: { populate: { resources: { - populate: ['image'], + populate: '*', }, downloadableDocuments: { populate: '*', @@ -27,12 +27,12 @@ export const webinarPopulate = { }, }, seo: { - populate: '*,metaImage,metaSocial.image', + populate: '*', }, questionsAndAnswers: '*', webinarCategory: { populate: ['icon'] }, headerImage: { - populate: ['image'], + populate: '*', }, }, }; diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeApiDataList.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeApiDataList.ts index 5ecbfdeee3..27cd9999c1 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeApiDataList.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeApiDataList.ts @@ -5,18 +5,16 @@ import { makeBaseProductWithoutLogoProps } from '@/lib/strapi/makeProps/makeProd import { makeApiSoapUrlList } from '@/lib/strapi/makeProps/makeApiSoapUrlList'; import { StrapiApiDataList } from '@/lib/strapi/types/apiDataList'; import { compact } from 'lodash'; +import { RootEntity } from '@/lib/strapi/types/rootEntity'; export async function makeApiDataListProps( - strapiApiDataList: StrapiApiDataList + strapiApiDataList: RootEntity ): Promise> { const list = compact( await Promise.all( strapiApiDataList.data - .filter( - (apiPage) => - apiPage.attributes.apiRestDetail || apiPage.attributes.apiSoapDetail - ) - .map(async ({ attributes }) => { + .filter((apiPage) => apiPage.apiRestDetail || apiPage.apiSoapDetail) + .map(async (attributes) => { if (!attributes.apiRestDetail && !attributes.apiSoapDetail) { console.error( `Error while processing API Data with title "${attributes.title}": missing API details. Skipping...` @@ -27,14 +25,14 @@ export async function makeApiDataListProps( attributes.apiRestDetail?.slug || attributes.apiSoapDetail?.slug || ''; - if (!apiDataSlug) { + if (!apiDataSlug || apiDataSlug.length === 0) { console.error( `Error while processing API Data with title "${attributes.title}": missing API slug. Skipping...` ); return null; } - if (!attributes.product.data) { + if (!attributes.product) { console.error( `Error while processing API Data with title "${attributes.title}": missing product data. Skipping...` ); @@ -43,9 +41,7 @@ export async function makeApiDataListProps( // eslint-disable-next-line functional/no-try-statements try { - const product = makeBaseProductWithoutLogoProps( - attributes.product.data - ); + const product = makeBaseProductWithoutLogoProps(attributes.product); return { ...attributes, product, @@ -66,9 +62,7 @@ export async function makeApiDataListProps( bannerLinks: attributes.bannerLinks.length > 0 ? attributes.bannerLinks.map(makeBannerLinkProps) - : attributes.product.data.attributes.bannerLinks?.map( - makeBannerLinkProps - ), + : attributes.product.bannerLinks?.map(makeBannerLinkProps), seo: attributes.seo, } satisfies ApiDataPageProps; } catch (error) { diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeApiDataListPages.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeApiDataListPages.ts index 25109ef0f9..7f55f1b43f 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeApiDataListPages.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeApiDataListPages.ts @@ -5,48 +5,44 @@ import { makeBaseProductWithoutLogoProps } from '@/lib/strapi/makeProps/makeProd import { StrapiApiDataListPages } from '@/lib/strapi/types/apiDataListPages'; import { compact } from 'lodash'; import { StrapiBaseApiData } from '../types/apiDataList'; +import { RootEntity } from '@/lib/strapi/types/rootEntity'; function makeApiDataListPageCard(item: StrapiBaseApiData, slug: string) { - if (!item.attributes.apiRestDetail && !item.attributes.apiSoapDetail) { + if (!item.apiRestDetail && !item.apiSoapDetail) { console.error( - `Error while processing API Data with title "${item.attributes.title}": missing API details. Skipping...` + `Error while processing API Data with title "${item.title}": missing API details. Skipping...` ); return null; } - if ( - !item.attributes.apiRestDetail?.slug && - !item.attributes.apiSoapDetail?.slug - ) { + if (!item.apiRestDetail?.slug && !item.apiSoapDetail?.slug) { console.error(` - Error while processing API Data with title "${item.attributes.title}": missing API slug. Skipping...`); + Error while processing API Data with title "${item.title}": missing API slug. Skipping...`); return null; } return { labels: [ { - label: item.attributes.apiSoapDetail ? 'SOAP' : 'REST', + label: item.apiSoapDetail ? 'SOAP' : 'REST', }, ].filter((label) => !!label.label), - title: item?.attributes?.title, - text: item?.attributes?.description || '', - icon: item?.attributes?.icon?.data?.attributes.url || undefined, + title: item?.title, + text: item?.description || '', + icon: item?.icon?.url || '', href: `/${slug}/api/${ - item.attributes.apiRestDetail - ? item.attributes.apiRestDetail?.slug - : item.attributes.apiSoapDetail?.slug + item.apiRestDetail ? item.apiRestDetail?.slug : item.apiSoapDetail?.slug }`, - tags: item.attributes.tags.data?.map((tag) => tag.attributes) || [], + tags: item.tags?.map((tag) => tag) || [], }; } export function makeApiDataListPagesProps( - strapiApiDataListPages: StrapiApiDataListPages + strapiApiDataListPages: RootEntity ): ReadonlyArray { return compact( - strapiApiDataListPages.data.map(({ attributes }) => { - const slug = attributes.product.data?.attributes.slug; + strapiApiDataListPages.data.map((attributes) => { + const slug = attributes.product?.slug; if (!slug) { console.error( `Error while processing API Data List Page with title "${attributes.title}": missing product slug. Skipping...` @@ -56,9 +52,7 @@ export function makeApiDataListPagesProps( // eslint-disable-next-line functional/no-try-statements try { - const product = makeBaseProductWithoutLogoProps( - attributes.product.data - ); + const product = makeBaseProductWithoutLogoProps(attributes.product); return { ...attributes, hero: { @@ -67,14 +61,14 @@ export function makeApiDataListPagesProps( }, product, apiDetailSlugs: compact( - attributes.apiData.data.map(({ attributes }) => + attributes.api_data.map((attributes) => attributes.apiRestDetail ? attributes.apiRestDetail.slug : attributes.apiSoapDetail?.slug ) ), cards: compact( - attributes.apiData.data.map((item) => + attributes.api_data.map((item) => makeApiDataListPageCard(item, slug) ) ), diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeBannerLink.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeBannerLink.ts index 9b4fc5bc69..03e29ecb57 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeBannerLink.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeBannerLink.ts @@ -6,7 +6,7 @@ export function makeBannerLinkProps( ): BannerLinkProps { return { content: strapiBannerLink.content || undefined, - icon: strapiBannerLink.icon.data.attributes, + icon: strapiBannerLink.icon, theme: strapiBannerLink.theme || 'dark', title: strapiBannerLink.title || '', }; diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeCaseHistories.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeCaseHistories.ts index c8df34a84d..86ba949354 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeCaseHistories.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeCaseHistories.ts @@ -6,15 +6,15 @@ import { compact } from 'lodash'; export function makeCaseHistoriesProps( strapiCaseHistories: StrapiCaseHistories ): ReadonlyArray { - return strapiCaseHistories.data.map(({ attributes }) => ({ + return strapiCaseHistories.data.map((attributes) => ({ ...attributes, updatedAt: attributes.updatedAt, parts: compact(attributes.parts.map((part) => makePartProps(part))), - products: attributes.products.data.map(({ attributes }) => ({ + products: attributes.products.map((attributes) => ({ ...attributes, - logo: attributes.logo.data?.attributes, + logo: attributes.logo, })), - image: attributes.image?.data?.attributes, + image: attributes.image, seo: attributes.seo, })); } diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeGuideListPages.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeGuideListPages.ts index d7642ffec2..9a5af76525 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeGuideListPages.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeGuideListPages.ts @@ -13,9 +13,9 @@ export function makeGuideListPagesProps( strapiGuideListPages: StrapiGuideListPages ): readonly GuideListPageProps[] { return compact( - strapiGuideListPages.data.map(({ attributes }) => { - const productData = attributes.product.data; - if (!productData?.attributes.slug) { + strapiGuideListPages.data.map((attributes) => { + const productData = attributes.product; + if (!productData?.slug) { console.error( `Error while processing GuideListPage with title "${attributes.title}": missing product slug. Skipping...` ); @@ -28,14 +28,12 @@ export function makeGuideListPagesProps( ...attributes.guidesByCategory.map(({ category, guides }) => ({ title: category, guides: compact( - guides.data.map((guide) => - makeGuideCardProps(guide, product.slug) - ) + guides.map((guide) => makeGuideCardProps(guide, product.slug)) ), })), ]; return { - path: `/${productData.attributes.slug}/guides`, + path: `/${productData.slug}/guides`, product, abstract: { title: attributes.title, @@ -45,13 +43,13 @@ export function makeGuideListPagesProps( bannerLinks: attributes.bannerLinks.length > 0 ? attributes.bannerLinks.map(makeBannerLinkProps) - : productData.attributes.bannerLinks?.map(makeBannerLinkProps), + : productData.bannerLinks?.map(makeBannerLinkProps), seo: attributes.seo, updatedAt: attributes.updatedAt, } satisfies GuideListPageProps; } catch (error) { console.error( - `Error while processing Guide List Page for product with slug "${productData.attributes.slug}":`, + `Error while processing Guide List Page for product with slug "${productData.slug}":`, error, 'Skipping...' ); @@ -65,24 +63,24 @@ function makeGuideCardProps( guide: StrapiBaseGuide, productSlug: string ): GuideCardProps | null { - if (!guide.attributes.slug) { + if (!guide.slug) { console.error('guide slug is missing:', guide); return null; } try { return { - title: guide.attributes.title, + title: guide.title, description: { title: 'guideListPage.cardSection.listItemsTitle', - listItems: guide.attributes.listItems.map(({ text }) => text), + listItems: guide.listItems.map(({ text }) => text), translate: true, }, - imagePath: guide.attributes.image?.data?.attributes?.url, - mobileImagePath: guide.attributes.mobileImage?.data?.attributes?.url, + imagePath: guide.image?.url, + mobileImagePath: guide.mobileImage?.url, link: { label: 'guideListPage.cardSection.linkLabel', - href: `/${productSlug}/guides/${guide.attributes.slug}`, + href: `/${productSlug}/guides/${guide.slug}`, translate: true, }, } satisfies GuideCardProps; diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeGuides.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeGuides.ts index d7030453c7..6052e0111a 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeGuides.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeGuides.ts @@ -10,7 +10,7 @@ export function makeGuidesProps( strapiGuides: StrapiGuides ): readonly GuideDefinition[] { return compact( - strapiGuides.data.map(({ attributes }) => { + strapiGuides.data.map((attributes) => { if (!attributes.slug || !attributes.title) { console.error( `Error while processing Guide: missing title or slug. Title: ${attributes.title} | Slug: ${attributes.slug}. Skipping...` @@ -18,7 +18,7 @@ export function makeGuidesProps( return null; } - if (!attributes.product.data?.attributes.slug) { + if (!attributes.product?.slug) { console.error( `Error while processing Guide with name "${attributes.title}": missing the product slug. Skipping...` ); @@ -26,9 +26,7 @@ export function makeGuidesProps( } try { - const product = makeBaseProductWithoutLogoProps( - attributes.product.data - ); + const product = makeBaseProductWithoutLogoProps(attributes.product); return { product, guide: { @@ -39,9 +37,7 @@ export function makeGuidesProps( bannerLinks: attributes.bannerLinks.length > 0 ? attributes.bannerLinks.map(makeBannerLinkProps) - : attributes.product.data.attributes.bannerLinks?.map( - makeBannerLinkProps - ) || [], + : attributes.product.bannerLinks?.map(makeBannerLinkProps) || [], seo: attributes.seo, }; } catch (error) { diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeHomepage.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeHomepage.ts index 5ff5391745..a011a7405a 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeHomepage.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeHomepage.ts @@ -2,72 +2,61 @@ import { StrapiHomepage } from '@/lib/strapi/types/homepage'; import { makeWebinarProps } from '@/lib/strapi/makeProps/makeWebinars'; import { HomepageProps } from '@/app/[locale]/page'; import { compact } from 'lodash'; +import { RootEntity } from '@/lib/strapi/types/rootEntity'; export const makeHomepageProps = ( - strapiHomepage: StrapiHomepage + strapiHomepage: RootEntity ): HomepageProps => ({ - updatedAt: strapiHomepage.data.attributes.updatedAt, - comingsoonDocumentation: - strapiHomepage.data.attributes.comingsoonDocumentation, - hero: strapiHomepage.data.attributes.heroSlider.map((slide) => ({ + updatedAt: strapiHomepage.data.updatedAt, + comingsoonDocumentation: strapiHomepage.data.comingsoonDocumentation, + hero: strapiHomepage.data.heroSlider.map((slide) => ({ ...slide, - backgroundImage: slide.backgroundImage?.data?.attributes, + backgroundImage: slide.backgroundImage, })), - ...(strapiHomepage.data.attributes.newsShowcase && { + ...(strapiHomepage.data.newsShowcase && { newsShowcase: { - title: strapiHomepage.data.attributes.newsShowcase.title, - items: strapiHomepage.data.attributes.newsShowcase.items.data.map( - (item) => ({ - comingSoon: item.attributes.comingSoon, - title: item.attributes.title, - publishedAt: new Date(item.attributes.publishedAt), - label: item.attributes.label, - link: { - text: item.attributes.link.text, - url: item.attributes.link.href, - target: item.attributes.link.target, - }, - image: - item.attributes.image?.data && - item.attributes.image.data.attributes, - }) - ), + title: strapiHomepage.data.newsShowcase.title, + items: strapiHomepage.data.newsShowcase.items.map((item) => ({ + comingSoon: item.comingSoon, + title: item.title, + publishedAt: new Date(item.publishedAt), + label: item.label, + link: { + text: item.link.text, + url: item.link.href, + target: item.link.target, + }, + image: item.image && item.image, + })), }, }), - ...(strapiHomepage.data.attributes.ecosystem && { + ...(strapiHomepage.data.ecosystem && { ecosystem: { - title: strapiHomepage.data.attributes.ecosystem.title || '', - productsTabName: strapiHomepage.data.attributes.ecosystem.productsTabName, - products: strapiHomepage.data.attributes.ecosystem.products.data.map( - (product) => ({ - title: product.attributes.name, - text: product.attributes.description ?? '', - href: `${product.attributes.slug}/overview`, - icon: product.attributes.logo.data?.attributes.url || undefined, - useSrc: true, - }) - ), - solutionsTabName: - strapiHomepage.data.attributes.ecosystem.solutionsTabName, - solutions: strapiHomepage.data.attributes.ecosystem.solutions.data.map( - (solution) => ({ - title: solution.attributes.title, - text: solution.attributes.description ?? '', - href: `/solutions/${solution.attributes.slug}`, - icon: solution.attributes.icon.data.attributes.url, - useSrc: true, - }) - ), - solutionsCta: strapiHomepage.data.attributes.ecosystem.solutionsCta && { - variant: strapiHomepage.data.attributes.ecosystem.solutionsCta.variant, - link: strapiHomepage.data.attributes.ecosystem.solutionsCta.link, + title: strapiHomepage.data.ecosystem.title || '', + productsTabName: strapiHomepage.data.ecosystem.productsTabName, + products: strapiHomepage.data.ecosystem.products.map((product) => ({ + title: product.name, + text: product.description ?? '', + href: `${product.slug}/overview`, + icon: product.logo?.url || '', + useSrc: true, + })), + solutionsTabName: strapiHomepage.data.ecosystem.solutionsTabName, + solutions: strapiHomepage.data.ecosystem.solutions.map((solution) => ({ + title: solution.title, + text: solution.description ?? '', + href: `/solutions/${solution.slug}`, + icon: solution.icon.url, + useSrc: true, + })), + solutionsCta: strapiHomepage.data.ecosystem.solutionsCta && { + variant: strapiHomepage.data.ecosystem.solutionsCta.variant, + link: strapiHomepage.data.ecosystem.solutionsCta.link, }, }, }), - seo: strapiHomepage?.data?.attributes?.seo, + seo: strapiHomepage.data?.seo, webinars: compact( - strapiHomepage.data.attributes.webinars.data.map((webinar) => - makeWebinarProps(webinar) - ) + strapiHomepage.data.webinars.map((webinar) => makeWebinarProps(webinar)) ), }); diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeOverviews.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeOverviews.ts index 2300f200ea..4bf7c6a8e1 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeOverviews.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeOverviews.ts @@ -11,9 +11,9 @@ export function makeOverviewsProps( strapiOverviews: StrapiOverviews ): ReadonlyArray { return compact( - strapiOverviews.data.map(({ attributes }) => { - const productData = attributes.product.data; - if (!productData.attributes.slug) { + strapiOverviews.data.map((attributes) => { + const productData = attributes.product; + if (!productData.slug) { console.error( `Error while processing Overview with title "${attributes.title}": missing product slug. Skipping...` ); @@ -23,12 +23,11 @@ export function makeOverviewsProps( try { return { updatedAt: attributes.updatedAt, - path: `/${attributes.product.data?.attributes.slug}/overview`, - product: makeBaseProductWithoutLogoProps(attributes.product.data), + path: `/${attributes.product?.slug}/overview`, + product: makeBaseProductWithoutLogoProps(attributes.product), hero: { - backgroundImage: attributes.backgroundImage.data.attributes.url, - altText: - attributes.backgroundImage.data.attributes.alternativeText || '', + backgroundImage: attributes.backgroundImage.url, + altText: attributes.backgroundImage.alternativeText || '', title: attributes.title, subtitle: attributes.subtitle, }, @@ -37,7 +36,7 @@ export function makeOverviewsProps( subtitle: attributes.features.subtitle, items: attributes.features.items.map((item) => ({ - iconUrl: item.icon.data?.attributes.url, + iconUrl: item.icon?.url, content: item.content, title: item.title || '', })) || [], @@ -55,7 +54,7 @@ export function makeOverviewsProps( text: item.description, href: item.path, useSrc: true, - iconName: item.icon.data.attributes.url, + iconName: item.icon.url, })) || [], }, tutorials: attributes.tutorialSection && { @@ -64,36 +63,31 @@ export function makeOverviewsProps( showCardsLayout: attributes.tutorialSection.showCardsLayout, list: compact( - attributes.tutorialSection.tutorials.data.map((tutorial) => { - if (!tutorial.attributes.slug) { - console.error( - 'tutorial slug is missing:', - tutorial.attributes.title - ); + attributes.tutorialSection.tutorials.map((tutorial) => { + if (!tutorial.slug) { + console.error('tutorial slug is missing:', tutorial.title); return null; } - if (!tutorial.attributes.product.data.attributes.slug) { + if (!tutorial.product?.slug) { console.error( "tutorial's product slug is missing:", - tutorial.attributes.title + tutorial.title ); return null; } return { - updatedAt: tutorial.attributes.updatedAt, - icon: tutorial.attributes.icon.data?.attributes, - description: tutorial.attributes.description, + icon: tutorial.icon, + description: tutorial.description, showInOverview: true, - image: tutorial.attributes.image.data && { - url: tutorial.attributes.image.data.attributes.url, - alternativeText: - tutorial.attributes.image.data.attributes - .alternativeText || '', + updatedAt: tutorial.updatedAt, + image: tutorial.image && { + url: tutorial.image.url, + alternativeText: tutorial.image.alternativeText || '', }, - title: tutorial.attributes.title, + title: tutorial.title, name: 'shared.moreInfo', - path: `/${tutorial.attributes.product.data.attributes.slug}/tutorials/${tutorial.attributes.slug}`, + path: `/${tutorial.product.slug}/tutorials/${tutorial.slug}`, }; }) ) || [], @@ -103,38 +97,32 @@ export function makeOverviewsProps( description: attributes.useCaseSection.description, list: compact( - attributes.useCaseSection.useCases.data.map((useCase) => { - if (!useCase.attributes.slug) { - console.error( - 'use case slug is missing:', - useCase.attributes.title - ); + attributes.useCaseSection.useCases.map((useCase) => { + if (!useCase.slug) { + console.error('use case slug is missing:', useCase.title); return null; } - if (!useCase.attributes.product.data.attributes.slug) { + if (!useCase.product.slug) { console.error( "use case's product slug is missing:", - useCase.attributes.title + useCase.title ); return null; } return { publishedAt: - (useCase.attributes.publishedAt && - new Date(useCase.attributes.publishedAt)) || + (useCase.publishedAt && new Date(useCase.publishedAt)) || undefined, showInOverview: true, - coverImage: useCase.attributes.coverImage.data && { - url: useCase.attributes.coverImage.data.attributes.url, - alternativeText: - useCase.attributes.coverImage.data.attributes - .alternativeText || '', + coverImage: useCase.coverImage && { + url: useCase.coverImage.url, + alternativeText: useCase.coverImage.alternativeText || '', }, - title: useCase.attributes.title, + title: useCase.title, name: 'shared.moreInfo', - path: `/${useCase.attributes.product.data.attributes.slug}/use-cases/${useCase.attributes.slug}`, + path: `/${useCase.product.slug}/use-cases/${useCase.slug}`, } satisfies UseCase; }) ) || [], @@ -149,20 +137,19 @@ export function makeOverviewsProps( target: attributes.whatsNew.link.target, }, }), - items: attributes.whatsNew.items.data.map((item) => ({ - comingSoon: item.attributes.comingSoon, - title: item.attributes.title, - publishedAt: new Date(item.attributes.publishedAt), - label: item.attributes.label, + items: attributes.whatsNew.items.map((item) => ({ + comingSoon: item.comingSoon, + title: item.title, + publishedAt: new Date(item.publishedAt), + label: item.label, link: { - text: item.attributes.link.text, - url: item.attributes.link.href, - target: item.attributes.link.target, + text: item.link.text, + url: item.link.href, + target: item.link.target, }, - image: item.attributes.image?.data && { - url: item.attributes.image.data.attributes.url, - alternativeText: - item.attributes.image.data.attributes.alternativeText || '', + image: item.image && { + url: item.image.url, + alternativeText: item.image.alternativeText || '', }, })), }, @@ -182,8 +169,8 @@ export function makeOverviewsProps( title: 'guideListPage.cardSection.listItemsTitle', translate: false, }, - imagePath: document.image.data.attributes.url, - mobileImagePath: document.mobileImage.data.attributes.url, + imagePath: document.image.url, + mobileImagePath: document.mobileImage.url, link: { label: document.linkText, href: document.linkHref, @@ -191,30 +178,27 @@ export function makeOverviewsProps( }, })), ...compact( - attributes.postIntegration.guides.data.map((guide) => { - if (!guide.attributes.slug) { + attributes.postIntegration.guides.map((guide) => { + if (!guide.slug) { console.error( "post-integration guide's product slug is missing:", - guide.attributes + guide ); return null; } return { - title: guide.attributes.title, + title: guide.title, description: { - listItems: guide.attributes.listItems.map( - (item) => item.text - ), + listItems: guide.listItems.map((item) => item.text), title: 'guideListPage.cardSection.listItemsTitle', translate: false, }, - imagePath: guide.attributes.image.data.attributes.url, - mobileImagePath: - guide.attributes.mobileImage.data.attributes.url, + imagePath: guide.image.url, + mobileImagePath: guide.mobileImage.url, link: { label: 'shared.goToGuide', - href: `guides/${guide.attributes.slug}`, + href: `guides/${guide.slug}`, translate: true, }, }; @@ -233,14 +217,12 @@ export function makeOverviewsProps( bannerLinks: attributes.bannerLinks.length > 0 ? attributes.bannerLinks.map(makeBannerLinkProps) - : attributes.product.data?.attributes.bannerLinks?.map( - makeBannerLinkProps - ), + : attributes.product?.bannerLinks?.map(makeBannerLinkProps), seo: attributes.seo, } satisfies OverviewPageProps; } catch (error) { console.error( - `Error processing Overview for product: "${productData.attributes.name}":`, + `Error processing Overview for product: "${productData.name}":`, error ); return null; diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makePart.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makePart.ts index 66ed26be1e..e40b1c190c 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makePart.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makePart.ts @@ -44,7 +44,7 @@ export function makePartProps( return { component: 'quote', quote: strapiPart.text, - backgroundImage: strapiPart.backgroundImage.data?.attributes, + backgroundImage: strapiPart.backgroundImage, }; case 'parts.markdown': if (!markdownContentDict) diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeProducts.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeProducts.ts index 6e25e5472e..f3280991c9 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeProducts.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeProducts.ts @@ -16,14 +16,13 @@ export function makeProductsProps( } export function makeProductProps(product: StrapiProduct): Product | null { - if (!product || !product.attributes) { + if (!product) { console.error('Invalid product data:', product); return null; } - - if (!product.attributes.slug || !product.attributes.name) { + if (!product.slug || !product.name) { console.error( - `Error while processing Product: missing title or slug. Title: ${product.attributes.name} | Slug: ${product.attributes.slug}. Skipping...` + `Error while processing Product: missing title or slug. Title: ${product.name} | Slug: ${product.slug}. Skipping...` ); return null; } @@ -32,12 +31,12 @@ export function makeProductProps(product: StrapiProduct): Product | null { try { return { ...makeBaseProductWithoutLogoProps(product), - description: product.attributes.description, - logo: product.attributes.logo?.data.attributes, + description: product.description, + logo: product.logo, }; } catch (error) { console.error( - `Error while processing Product with name "${product.attributes.name}":`, + `Error while processing Product with name "${product.name}":`, error, 'Skipping...' ); @@ -48,19 +47,19 @@ export function makeProductProps(product: StrapiProduct): Product | null { function getApiDataListPageUrl( product: StrapiBaseProductWithRelations ): string | undefined { - const apiDataList = product.attributes.api_data_list_page.data; + const apiDataList = product.api_data_list_page; // if there is no api data, return undefined - if (!apiDataList || apiDataList.attributes.apiData.data.length === 0) return; + if (!apiDataList || apiDataList.api_data.length === 0) return; - const productSlug = product.attributes.slug; - const apiData = apiDataList.attributes.apiData.data[0]; + const productSlug = product.slug; + const apiData = apiDataList.api_data[0]; if ( apiDataList && - apiDataList.attributes.apiData.data.length === 1 && - apiData.attributes.apiRestDetail?.slug + apiDataList.api_data.length === 1 && + apiData.apiRestDetail?.slug ) { - return `/${productSlug}/api/${apiData.attributes.apiRestDetail.slug}`; + return `/${productSlug}/api/${apiData.apiRestDetail.slug}`; } return `/${productSlug}/api`; @@ -69,30 +68,29 @@ function getApiDataListPageUrl( export function makeBaseProductWithoutLogoProps( product: StrapiBaseProductWithRelations ): Product { - if (!product.attributes.slug) { + if (!product.slug) { throw new Error( - `Error while processing Product with name "${product.attributes.name}": missing slug. Skipping...` + `Error while processing Product with name "${product.name}": missing slug. Skipping...` ); } return { apiDataListPageUrl: getApiDataListPageUrl(product), - bannerLinks: product.attributes.bannerLinks?.map(makeBannerLinkProps) || [], - isVisible: product.attributes.isVisible, + bannerLinks: product.bannerLinks?.map(makeBannerLinkProps) || [], + isVisible: product.isVisible, hasApiDataListPage: !!( - product.attributes.api_data_list_page.data && - product.attributes.api_data_list_page.data.attributes.apiData.data - .length > 0 + product.api_data_list_page && + product.api_data_list_page.api_data.length > 0 ), - hasGuideListPage: !!product.attributes.guide_list_page.data, - hasOverviewPage: !!product.attributes.overview.data, - hasQuickstartGuidePage: !!product.attributes.quickstart_guide.data, - hasReleaseNotePage: !!product.attributes.release_note.data, - hasTutorialListPage: !!product.attributes.tutorial_list_page.data, - hasUseCaseListPage: !!product.attributes.use_case_list_page.data, - name: product.attributes.name, - shortName: product.attributes.shortName, - slug: product.attributes.slug, - tags: product.attributes.tags?.data?.map((tag) => tag.attributes) || [], + hasGuideListPage: !!product.guide_list_page, + hasOverviewPage: !!product.overview, + hasQuickstartGuidePage: !!product.quickstart_guide, + hasReleaseNotePage: !!product.release_note, + hasTutorialListPage: !!product.tutorial_list_page, + hasUseCaseListPage: !!product.use_case_list_page, + name: product.name, + shortName: product.shortName, + slug: product.slug, + tags: product.tags?.map((tag) => tag) || [], } satisfies Product; } diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeQuickStartGuides.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeQuickStartGuides.ts index 3763361e1f..6d8e9979e2 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeQuickStartGuides.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeQuickStartGuides.ts @@ -17,9 +17,9 @@ function makeStepFromQuickstartGuideItems( item: StrapiQuickStartGuideItem ): Step { return { - anchor: item.attributes.anchor, - title: item.attributes.title, - parts: compact(item.attributes.parts.map((part) => makePartProps(part))), + anchor: item.anchor, + title: item.title, + parts: compact(item.parts.map((part) => makePartProps(part))), }; } @@ -28,7 +28,7 @@ export function makeQuickStartGuidesProps( ): QuickStartGuidesPageProps { return compact( strapiQuickStarts.data.map((quickStart) => { - if (!quickStart.attributes.product.data?.attributes.slug) { + if (!quickStart.product?.slug) { console.error( `Error while processing QuickStartGuide with id ${quickStart.id}: missing product slug. Skipping...` ); @@ -38,27 +38,21 @@ export function makeQuickStartGuidesProps( try { return { abstract: { - title: quickStart.attributes.title, - description: quickStart.attributes.description, + title: quickStart.title, + description: quickStart.description, }, - updatedAt: quickStart.attributes.updatedAt, - defaultStepAnchor: - quickStart.attributes.quickstartGuideItems.data[0].attributes - .anchor, - product: makeBaseProductWithoutLogoProps( - quickStart.attributes.product.data - ), - steps: quickStart.attributes.quickstartGuideItems.data.map((item) => + updatedAt: quickStart.updatedAt, + defaultStepAnchor: quickStart.quickstartGuideItems[0].anchor, + product: makeBaseProductWithoutLogoProps(quickStart.product), + steps: quickStart.quickstartGuideItems.map((item) => makeStepFromQuickstartGuideItems(item) ), - path: `/${quickStart.attributes.product.data.attributes.slug}/quick-start`, + path: `/${quickStart.product.slug}/quick-start`, bannerLinks: - quickStart.attributes.bannerLinks.length > 0 - ? quickStart.attributes.bannerLinks.map(makeBannerLinkProps) - : quickStart.attributes.product.data.attributes.bannerLinks?.map( - makeBannerLinkProps - ), - seo: quickStart.attributes.seo, + quickStart.bannerLinks.length > 0 + ? quickStart.bannerLinks.map(makeBannerLinkProps) + : quickStart.product.bannerLinks?.map(makeBannerLinkProps), + seo: quickStart.seo, } satisfies QuickStartGuidePageProps; } catch (error) { console.error( diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeReleaseNotes.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeReleaseNotes.ts index 97dba7a00b..ee62040dd5 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeReleaseNotes.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeReleaseNotes.ts @@ -10,8 +10,8 @@ export function makeReleaseNotesProps( strapiReleaseNotes: StrapiReleaseNotes ): ReadonlyArray { return compact( - strapiReleaseNotes.data.map(({ attributes }) => { - if (!attributes.product.data?.attributes.slug) { + strapiReleaseNotes.data.map((attributes) => { + if (!attributes.product?.slug) { console.error( `Error while processing ReleaseNote with title "${attributes.title}": missing product slug. Skipping...` ); @@ -23,13 +23,11 @@ export function makeReleaseNotesProps( bannerLinks: attributes.bannerLinks.length > 0 ? attributes.bannerLinks.map(makeBannerLinkProps) - : attributes.product.data?.attributes.bannerLinks?.map( - makeBannerLinkProps - ), + : attributes.product?.bannerLinks?.map(makeBannerLinkProps), dirName: attributes.dirName, landingFile: attributes.landingFile, - path: `/${attributes.product.data?.attributes.slug}/release-note`, - product: makeBaseProductWithoutLogoProps(attributes.product.data), + path: `/${attributes.product?.slug}/release-note`, + product: makeBaseProductWithoutLogoProps(attributes.product), seo: attributes.seo, title: attributes.title, }; diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeSolutionListPage.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeSolutionListPage.ts index 229c4ac1f1..54ff9badaf 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeSolutionListPage.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeSolutionListPage.ts @@ -2,21 +2,20 @@ import { SolutionListTemplateProps } from '@/components/templates/SolutionListTemplate/SolutionListTemplate'; import { StrapiSolutionListPage } from '@/lib/strapi/types/solutionListPage'; import { compact } from 'lodash'; +import { RootEntity } from '@/lib/strapi/types/rootEntity'; export function makeSolutionListPageProps( - strapiSolutionsList: StrapiSolutionListPage + strapiSolutionsList: RootEntity ): SolutionListTemplateProps { - const { - data: { attributes }, - } = strapiSolutionsList; + const strapiSolutionsListData = strapiSolutionsList.data; return { ...strapiSolutionsList, hero: { - title: attributes.title, - subtitle: attributes.description, + title: strapiSolutionsListData.title, + subtitle: strapiSolutionsListData.description, }, solutions: compact( - attributes.solutions.data.map(({ attributes }) => { + strapiSolutionsListData.solutions.map((attributes) => { if (!attributes.slug) { console.error( `Error while processing Solution with title "${attributes.title}": missing slug. Skipping...` @@ -27,43 +26,45 @@ export function makeSolutionListPageProps( return { name: attributes.title, description: attributes.description, - logo: attributes.icon.data.attributes, + logo: attributes.icon, slug: `solutions/${attributes.slug}`, - labels: attributes.products.data.map((products) => ({ - label: products.attributes.shortName, - path: `/${products.attributes.slug}`, + labels: attributes.products.map((products) => ({ + label: products.shortName, + path: `/${products.slug}`, })), }; }) ), - successStories: attributes.caseHistories && { - title: attributes.caseHistories.title, - subtitle: attributes.caseHistories.description, + successStories: strapiSolutionsListData.caseHistories && { + title: strapiSolutionsListData.caseHistories.title, + subtitle: strapiSolutionsListData.caseHistories.description, stories: compact( - attributes.caseHistories.case_histories.data.map((caseHistory) => { - if (!caseHistory.attributes.slug) { - console.error( - `Error while processing CaseHistory with title "${caseHistory.attributes.title}": missing slug. Skipping...` - ); - return null; - } + strapiSolutionsListData.caseHistories.case_histories.map( + (caseHistory) => { + if (!caseHistory.slug) { + console.error( + `Error while processing CaseHistory with title "${caseHistory.title}": missing slug. Skipping...` + ); + return null; + } - return { - title: caseHistory.attributes.title, - path: `case-histories/${caseHistory.attributes.slug}`, - image: caseHistory.attributes.image?.data?.attributes, - }; - }) + return { + title: caseHistory.title, + path: `case-histories/${caseHistory.slug}`, + image: caseHistory.image, + }; + } + ) ), }, - features: attributes.features && { - title: attributes.features.title, - items: attributes.features.items.map((item) => ({ + features: strapiSolutionsListData.features && { + title: strapiSolutionsListData.features.title, + items: strapiSolutionsListData.features.items.map((item) => ({ title: item.title ?? '', content: item.content, - iconUrl: item.icon.data.attributes.url, + iconUrl: item.icon.url, })), }, - seo: attributes.seo, + seo: strapiSolutionsListData.seo, }; } diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeSolutions.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeSolutions.ts index d2bdd85d85..b16a9ae8d8 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeSolutions.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeSolutions.ts @@ -9,36 +9,35 @@ export function makeSolutionsProps( strapiSolutions: StrapiSolutions ): ReadonlyArray { return compact( - strapiSolutions.data.map(({ attributes }) => { + strapiSolutions?.data.map((attributes) => { if (!attributes.slug || !attributes.title) { console.error( `Error while processing Solution: missing title or slug. Title: ${attributes.title} | Slug: ${attributes.slug}. Skipping...` ); return null; } - try { return { ...attributes, - stats: [...attributes.stats], - steps: attributes.steps.map((step) => ({ + stats: [...(attributes.stats || [])], // Aggiunto fallback array vuoto + steps: attributes.steps?.map((step) => ({ ...step, - products: step.products.data.map((product) => ({ - ...product.attributes, + products: step.products?.map((product) => ({ + ...product, })), })), - products: attributes.products.data.map(({ attributes }) => ({ + products: attributes.products?.map((attributes) => ({ ...attributes, - logo: attributes.logo.data?.attributes, + logo: attributes.logo, })), - icon: attributes.icon.data.attributes, + icon: attributes.icon, webinars: compact( - attributes.webinars.data.map((webinar) => makeWebinarProps(webinar)) + attributes.webinars?.map((webinar) => makeWebinarProps(webinar)) ), - bannerLinks: attributes.bannerLinks.map((bannerLink) => ({ + bannerLinks: attributes.bannerLinks?.map((bannerLink) => ({ ...bannerLink, title: bannerLink.title || '', - icon: bannerLink.icon?.data?.attributes, + icon: bannerLink.icon, })), solutionSlug: attributes.slug, path: `/solutions/${attributes.slug}/details`, @@ -46,22 +45,20 @@ export function makeSolutionsProps( title: attributes.caseHistories.title, subtitle: attributes.caseHistories.description, stories: compact( - attributes.caseHistories.case_histories.data.map( - (caseHistory) => { - if (!caseHistory.attributes.slug) { - console.error( - `Error while processing CaseHistory with title "${caseHistory.attributes.title}": missing slug. Skipping...` - ); - return null; - } - - return { - title: caseHistory.attributes.title, - path: `/case-histories/${caseHistory.attributes.slug}`, - image: caseHistory.attributes.image?.data?.attributes, - }; + attributes.caseHistories.case_histories?.map((caseHistory) => { + if (!caseHistory.slug) { + console.error( + `Error while processing CaseHistory with title "${caseHistory.title}": missing slug. Skipping...` + ); + return null; } - ) + + return { + title: caseHistory.title, + path: `/case-histories/${caseHistory.slug}`, + image: caseHistory.image, + }; + }) ), }, seo: attributes.seo, diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeTags.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeTags.ts index 023d76cf91..10a7b9fba8 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeTags.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeTags.ts @@ -7,7 +7,7 @@ export function makeTagsProps(strapiTags: StrapiTags): ReadonlyArray { export function makeTagProps(tag: StrapiTag): Tag { return { - name: tag.attributes.name, - icon: tag.attributes.icon, + name: tag.name, + icon: tag.icon, }; } diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeTutorialListPages.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeTutorialListPages.ts index f1a3a2e668..e698752995 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeTutorialListPages.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeTutorialListPages.ts @@ -10,8 +10,8 @@ export function makeTutorialListPagesProps( strapiTutorialList: StrapiTutorialListPages ): readonly TutorialsPageProps[] { return compact( - strapiTutorialList.data.map(({ attributes }) => { - const slug = attributes.product.data?.attributes.slug; + strapiTutorialList.data.map((attributes) => { + const slug = attributes.product?.slug; if (!slug) { // eslint-disable-next-line functional/no-expression-statements console.error( @@ -21,8 +21,8 @@ export function makeTutorialListPagesProps( } const tutorials: readonly Tutorial[] = compact( - attributes.tutorials.data.map(({ attributes: tutorialAttributes }) => { - const slug = tutorialAttributes.product?.data?.attributes?.slug; + attributes.tutorials.map((tutorialAttributes) => { + const slug = tutorialAttributes.product?.slug; if (!slug) { console.error( `Error while processing Tutorial with title "${tutorialAttributes.title}": missing product slug. Skipping...` @@ -48,10 +48,8 @@ export function makeTutorialListPagesProps( ? new Date(tutorialAttributes.publishedAt) : undefined, showInOverview: false, - image: tutorialAttributes.image.data?.attributes, - tags: - tutorialAttributes.tags?.data?.map((tag) => tag.attributes) || - [], + image: tutorialAttributes.image, + tags: tutorialAttributes.tags?.map((tag) => tag) || [], } satisfies Tutorial; } catch (error) { // eslint-disable-next-line functional/no-expression-statements @@ -65,19 +63,19 @@ export function makeTutorialListPagesProps( }) ); const updatedAt = - attributes.tutorials.data.length > 0 - ? attributes.tutorials.data.reduce((latest, current) => { - const latestDate = new Date(latest.attributes.updatedAt); - const currentDate = new Date(current.attributes.updatedAt); + attributes.tutorials.length > 0 + ? attributes.tutorials.reduce((latest, current) => { + const latestDate = new Date(latest.updatedAt); + const currentDate = new Date(current.updatedAt); return currentDate > latestDate ? current : latest; - }).attributes.updatedAt + }).updatedAt : ''; return { updatedAt: updatedAt, name: attributes.title, - path: `/${attributes.product.data.attributes.slug}/tutorials`, - product: makeBaseProductWithoutLogoProps(attributes.product.data), + path: `/${attributes.product.slug}/tutorials`, + product: makeBaseProductWithoutLogoProps(attributes.product), abstract: { title: attributes.title, description: attributes.description, @@ -90,8 +88,8 @@ export function makeTutorialListPagesProps( ? attributes.bannerLinks.map((bannerLink) => makeBannerLinkProps(bannerLink) ) - : attributes.product.data.attributes.bannerLinks?.map( - (bannerLink) => makeBannerLinkProps(bannerLink) + : attributes.product.bannerLinks?.map((bannerLink) => + makeBannerLinkProps(bannerLink) ), }; }) diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeTutorials.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeTutorials.ts index 7e1b5bfc7d..a8e719893b 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeTutorials.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeTutorials.ts @@ -13,13 +13,13 @@ export type TutorialProps = Tutorial & { readonly relatedLinks?: RelatedLinksProps; readonly bannerLinks?: readonly BannerLinkProps[]; }; - export function makeTutorialsProps( strapiTutorials: StrapiTutorials, markdownContentDict: Record ): readonly TutorialProps[] { return compact( - strapiTutorials.data.map(({ attributes }) => { + strapiTutorials.data.map((attributes) => { + // Controllo esistenza campi obbligatori minimi if (!attributes.slug || !attributes.title) { console.error( `Error while processing Tutorial: missing title or slug. Title: ${attributes.title} | Slug: ${attributes.slug}. Skipping...` @@ -27,7 +27,8 @@ export function makeTutorialsProps( return null; } - if (!attributes.product.data.attributes.slug) { + // Controllo esistenza product + if (!attributes.product?.slug) { console.error( `Error while processing Tutorial with title "${attributes.title}": missing product slug. Skipping...` ); @@ -36,36 +37,46 @@ export function makeTutorialsProps( try { return { - image: attributes.image.data + image: attributes.image ? { - url: attributes.image.data.attributes.url, - alternativeText: - attributes.image.data.attributes.alternativeText || '', + url: attributes.image.url, + alternativeText: attributes.image.alternativeText || '', } : undefined, + title: attributes.title, + publishedAt: attributes.publishedAt ? new Date(attributes.publishedAt) : undefined, + name: attributes.title, - path: `/${attributes.product.data.attributes.slug}/tutorials/${attributes.slug}`, + + path: `/${attributes.product.slug}/tutorials/${attributes.slug}`, + parts: compact( - attributes.parts.map((part) => + attributes.parts?.map((part) => makePartProps(part, markdownContentDict) - ) + ) || [] ), - productSlug: attributes.product.data.attributes.slug, + + productSlug: attributes.product.slug, + description: attributes.description || '', - icon: attributes.icon.data?.attributes || undefined, + + icon: attributes.icon || undefined, + relatedLinks: attributes.relatedLinks, + bannerLinks: attributes.bannerLinks && attributes.bannerLinks.length > 0 - ? attributes.bannerLinks?.map(makeBannerLinkProps) - : attributes.product.data?.attributes.bannerLinks?.map( - makeBannerLinkProps - ), + ? attributes.bannerLinks.map(makeBannerLinkProps) + : attributes.product.bannerLinks?.map(makeBannerLinkProps), + seo: attributes.seo, - tags: attributes.tags.data?.map((tag) => tag.attributes) || [], + + tags: attributes.tags?.map((tag) => tag) || [], + updatedAt: attributes.updatedAt, } satisfies TutorialProps; } catch (error) { diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeUrlReplaceMap.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeUrlReplaceMap.ts index 5f3df973d0..11ea4c8845 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeUrlReplaceMap.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeUrlReplaceMap.ts @@ -1,16 +1,15 @@ import { StrapiUrlReplaceMap } from '@/lib/strapi/types/urlReplaceMap'; +import { RootEntity } from '@/lib/strapi/types/rootEntity'; export type UrlReplaceMap = Record; export function makeUrlReplaceMap( - strapiUrlReplacemap: StrapiUrlReplaceMap + strapiUrlReplacemap: RootEntity ): UrlReplaceMap { - return strapiUrlReplacemap.data.attributes.urlToGuide.reduce((map, obj) => { + return strapiUrlReplacemap.data.urlToGuide.reduce((map, obj) => { return { ...map, - [obj.url]: `/${ - obj.guide.data?.attributes.product.data.attributes.slug - }/guides/${obj.guide.data?.attributes.slug}${ + [obj.url]: `/${obj.guide?.product.slug}/guides/${obj.guide?.slug}${ obj.subPath ? `/${obj.subPath}` : '' }`, }; diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeUseCaseListPages.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeUseCaseListPages.ts index db91ceddb3..73bbd46027 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeUseCaseListPages.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeUseCaseListPages.ts @@ -10,8 +10,8 @@ export function makeUseCaseListPagesProps( strapiUseCaseList: StrapiUseCaseListPages ): readonly UseCasesPageProps[] { return compact( - strapiUseCaseList.data.map(({ attributes }) => { - const slug = attributes.product.data?.attributes.slug; + strapiUseCaseList.data.map((attributes) => { + const slug = attributes.product?.slug; if (!slug) { // eslint-disable-next-line functional/no-expression-statements console.error( @@ -21,8 +21,8 @@ export function makeUseCaseListPagesProps( } const useCases: readonly UseCase[] = compact( - attributes.useCases.data.map(({ attributes: useCaseAttributes }) => { - const slug = useCaseAttributes.product?.data?.attributes?.slug; + attributes.useCases.map((useCaseAttributes) => { + const slug = useCaseAttributes.product?.slug; if (!slug) { console.error( `Error while processing UseCase with title "${useCaseAttributes.title}": missing product slug. Skipping...` @@ -47,9 +47,8 @@ export function makeUseCaseListPagesProps( ? new Date(useCaseAttributes.publishedAt) : undefined, showInOverview: false, - coverImage: useCaseAttributes.coverImage.data?.attributes, - tags: - useCaseAttributes.tags.data?.map((tag) => tag.attributes) || [], + coverImage: useCaseAttributes.coverImage, + tags: useCaseAttributes.tags?.map((tag) => tag) || [], } satisfies UseCase; } catch (error) { // eslint-disable-next-line functional/no-expression-statements @@ -64,8 +63,8 @@ export function makeUseCaseListPagesProps( ); return { - path: `/${attributes.product.data.attributes.slug}/use-cases`, - product: makeBaseProductWithoutLogoProps(attributes.product.data), + path: `/${attributes.product.slug}/use-cases`, + product: makeBaseProductWithoutLogoProps(attributes.product), abstract: { title: attributes.title, description: attributes.description, @@ -77,8 +76,8 @@ export function makeUseCaseListPagesProps( ? attributes.bannerLinks.map((bannerLink) => makeBannerLinkProps(bannerLink) ) - : attributes.product.data.attributes.bannerLinks?.map( - (bannerLink) => makeBannerLinkProps(bannerLink) + : attributes.product.bannerLinks?.map((bannerLink) => + makeBannerLinkProps(bannerLink) ), enableFilters: attributes.enableFilters, } satisfies UseCasesPageProps; diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeUseCases.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeUseCases.ts index 627336dd37..210a445d35 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeUseCases.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeUseCases.ts @@ -19,7 +19,7 @@ export function makeUseCasesProps( markdownContentDict: Record ): readonly UseCaseProps[] { return compact( - strapiUseCases.data.map(({ attributes }) => { + strapiUseCases.data.map((attributes) => { if (!attributes.slug || !attributes.title) { console.error( `Error while processing UseCase: missing title or slug. Title: ${attributes.title} | Slug: ${attributes.slug}. Skipping...` @@ -27,7 +27,7 @@ export function makeUseCasesProps( return null; } - if (!attributes.product.data.attributes.slug) { + if (!attributes.product.slug) { console.error( `Error while processing UseCase with title "${attributes.title}": missing product slug. Skipping...` ); @@ -36,18 +36,16 @@ export function makeUseCasesProps( try { return { - coverImage: attributes.coverImage.data + coverImage: attributes.coverImage ? { - url: attributes.coverImage.data.attributes.url, - alternativeText: - attributes.coverImage.data.attributes.alternativeText || '', + url: attributes.coverImage.url, + alternativeText: attributes.coverImage.alternativeText || '', } : undefined, - headerImage: attributes.headerImage?.data + headerImage: attributes.headerImage ? { - url: attributes.headerImage.data.attributes.url, - alternativeText: - attributes.headerImage.data.attributes.alternativeText || '', + url: attributes.headerImage.url, + alternativeText: attributes.headerImage.alternativeText || '', } : undefined, title: attributes.title, @@ -55,23 +53,21 @@ export function makeUseCasesProps( ? new Date(attributes.publishedAt) : undefined, name: attributes.title, - path: `/${attributes.product.data.attributes.slug}/use-cases/${attributes.slug}`, + path: `/${attributes.product.slug}/use-cases/${attributes.slug}`, parts: compact( attributes.parts.map((part) => makePartProps(part, markdownContentDict) ) ), - productSlug: attributes.product.data.attributes.slug, + productSlug: attributes.product.slug, relatedLinks: attributes.relatedLinks, bannerLinks: attributes.bannerLinks && attributes.bannerLinks.length > 0 ? attributes.bannerLinks?.map(makeBannerLinkProps) - : attributes.product.data?.attributes.bannerLinks?.map( - makeBannerLinkProps - ), + : attributes.product?.bannerLinks?.map(makeBannerLinkProps), seo: attributes.seo, subtitle: attributes.subtitle, - tags: attributes.tags.data?.map((tag) => tag.attributes) || [], + tags: attributes.tags?.map((tag) => tag) || [], updatedAt: attributes.updatedAt, } satisfies UseCaseProps; } catch (error) { diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeWebinarCategories.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeWebinarCategories.ts index 79cfb03a20..4637b50e14 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeWebinarCategories.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeWebinarCategories.ts @@ -14,7 +14,7 @@ export function makeWebinarCategoryProps( webinarCategory: StrapiWebinarCategory ): WebinarCategory { return { - name: webinarCategory.attributes.name, - icon: webinarCategory.attributes.icon, + name: webinarCategory.name, + icon: webinarCategory.icon, }; } diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeWebinars.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeWebinars.ts index b73ba492eb..43a0dc8fa1 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeWebinars.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeWebinars.ts @@ -8,9 +8,9 @@ export type WebinarsProps = readonly Webinar[]; export const makeWebinarProps = ( strapiWebinar: StrapiWebinar ): Webinar | null => { - if (!strapiWebinar.attributes.slug || !strapiWebinar.attributes.title) { + if (!strapiWebinar.slug || !strapiWebinar.title) { console.error( - `Error while processing Webinar: missing title or slug. Title: ${strapiWebinar.attributes.title} | Slug: ${strapiWebinar.attributes.slug}. Skipping...` + `Error while processing Webinar: missing title or slug. Title: ${strapiWebinar.title} | Slug: ${strapiWebinar.slug}. Skipping...` ); return null; } @@ -18,32 +18,31 @@ export const makeWebinarProps = ( // eslint-disable-next-line functional/no-try-statements try { return { - ...strapiWebinar.attributes, + ...strapiWebinar, speakers: - strapiWebinar.attributes.webinarSpeakers.data.length > 0 - ? strapiWebinar.attributes.webinarSpeakers.data.map((speaker) => ({ - ...speaker.attributes, - avatar: speaker.attributes.avatar?.data?.attributes, + strapiWebinar.webinarSpeakers.length > 0 + ? strapiWebinar.webinarSpeakers.map((speaker) => ({ + ...speaker, + avatar: speaker.avatar, })) : undefined, - questionsAndAnswers: strapiWebinar.attributes.questionsAndAnswers?.length - ? strapiWebinar.attributes.questionsAndAnswers + questionsAndAnswers: strapiWebinar.questionsAndAnswers?.length + ? strapiWebinar.questionsAndAnswers : undefined, - relatedResources: strapiWebinar.attributes.relatedResources + relatedResources: strapiWebinar.relatedResources ? { - title: strapiWebinar.attributes.relatedResources.title, - resources: ( - strapiWebinar.attributes.relatedResources.resources || [] - ).map((resource) => ({ - ...resource, - subtitle: resource.subtitle, - description: resource.description, - image: resource.image?.data?.attributes, - })), + title: strapiWebinar.relatedResources.title, + resources: (strapiWebinar.relatedResources.resources || []).map( + (resource) => ({ + ...resource, + subtitle: resource.subtitle, + description: resource.description, + image: resource.image, + }) + ), downloadableDocuments: ( - strapiWebinar.attributes.relatedResources.downloadableDocuments - ?.data || [] - ).map(({ attributes }) => ({ + strapiWebinar.relatedResources.downloadableDocuments || [] + ).map((attributes) => ({ title: attributes.caption || attributes.name, downloadLink: attributes.url, size: attributes.size, @@ -51,22 +50,21 @@ export const makeWebinarProps = ( })), } : undefined, - startDateTime: strapiWebinar.attributes.startDatetime, - endDateTime: strapiWebinar.attributes.endDatetime, - playerCoverImageUrl: - strapiWebinar.attributes.playerCoverImage?.data?.attributes.url, - videoOnDemandStartAt: strapiWebinar.attributes.videoOnDemandStartAt, - subscribeCtaLabel: strapiWebinar.attributes.subscribeParagraphLabel, - imagePath: strapiWebinar.attributes.coverImage.data.attributes.url, - seo: strapiWebinar.attributes.seo, - tag: strapiWebinar.attributes.webinarCategory?.data?.attributes, - headerImage: strapiWebinar.attributes.headerImage?.data?.attributes, - updatedAt: strapiWebinar.attributes.updatedAt, + startDateTime: strapiWebinar.startDatetime, + endDateTime: strapiWebinar.endDatetime, + playerCoverImageUrl: strapiWebinar.playerCoverImage?.url, + subscribeCtaLabel: strapiWebinar.subscribeParagraphLabel, + videoOnDemandStartAt: strapiWebinar.videoOnDemandStartAt, + imagePath: strapiWebinar.coverImage.url, + seo: strapiWebinar.seo, + tag: strapiWebinar.webinarCategory, + headerImage: strapiWebinar.headerImage, + updatedAt: strapiWebinar.updatedAt, } satisfies Webinar; } catch (error) { // eslint-disable-next-line functional/no-expression-statements console.error( - `Error while processing Webinar with title ${strapiWebinar.attributes.title}:`, + `Error while processing Webinar with title ${strapiWebinar.title}:`, error, 'Skipping...' ); diff --git a/apps/nextjs-website/src/lib/strapi/types/apiDataList.ts b/apps/nextjs-website/src/lib/strapi/types/apiDataList.ts index f51fdc6cd6..a15173f08a 100644 --- a/apps/nextjs-website/src/lib/strapi/types/apiDataList.ts +++ b/apps/nextjs-website/src/lib/strapi/types/apiDataList.ts @@ -1,11 +1,11 @@ +// StrapiUrl remains unchanged import { StrapiMedia } from '@/lib/strapi/types/media'; +import { StrapiTag } from '@/lib/strapi/types/tag'; import { StrapiBaseProductWithRelations } from '@/lib/strapi/types/product'; import { StrapiBannerLink } from '@/lib/strapi/types/bannerLink'; import { StrapiSeo } from '@/lib/strapi/types/seo'; -import { StrapiComponent } from './strapiComponent'; -import { StrapiTag } from './tag'; -type StrapiUrl = { +export type StrapiUrl = { readonly id: number; readonly name?: string; readonly url: string; @@ -14,36 +14,24 @@ type StrapiUrl = { export type StrapiBaseApiData = { readonly id: number; - readonly attributes: { - readonly title: string; - readonly description?: string; - readonly icon: { - readonly data?: StrapiMedia; - }; - readonly apiRestDetail?: { - readonly slug: string; - readonly specUrls: readonly StrapiUrl[]; - }; - readonly apiSoapDetail?: { - readonly slug: string; - readonly repositoryUrl: string; - readonly dirName: string; - }; - readonly tags: StrapiComponent; + readonly title: string; + readonly description?: string; + readonly icon?: StrapiMedia; + readonly apiRestDetail?: { + readonly slug: string; + readonly specUrls: readonly StrapiUrl[]; }; + readonly apiSoapDetail?: { + readonly slug: string; + readonly repositoryUrl: string; + readonly dirName: string; + }; + readonly tags?: readonly StrapiTag[]; }; export type StrapiApiData = StrapiBaseApiData & { - readonly attributes: StrapiBaseApiData['attributes'] & { - readonly product: { - readonly data?: StrapiBaseProductWithRelations; - }; - readonly bannerLinks: readonly StrapiBannerLink[]; - readonly seo?: StrapiSeo; - }; + readonly product?: StrapiBaseProductWithRelations; + readonly bannerLinks: readonly StrapiBannerLink[]; + readonly seo?: StrapiSeo; }; - -export type StrapiBaseApiDataList = StrapiComponent< - readonly StrapiBaseApiData[] ->; -export type StrapiApiDataList = StrapiComponent; +export type StrapiApiDataList = readonly StrapiApiData[]; diff --git a/apps/nextjs-website/src/lib/strapi/types/apiDataListPages.ts b/apps/nextjs-website/src/lib/strapi/types/apiDataListPages.ts index 103c9c71d3..2b3175ffd1 100644 --- a/apps/nextjs-website/src/lib/strapi/types/apiDataListPages.ts +++ b/apps/nextjs-website/src/lib/strapi/types/apiDataListPages.ts @@ -2,41 +2,28 @@ import { StrapiBaseProductWithRelations } from '@/lib/strapi/types/product'; import { StrapiBannerLink } from '@/lib/strapi/types/bannerLink'; import { StrapiSeo } from '@/lib/strapi/types/seo'; import { - StrapiBaseApiData, - StrapiBaseApiDataList, + StrapiApiData, + StrapiApiDataList, } from '@/lib/strapi/types/apiDataList'; -import { StrapiComponent } from './strapiComponent'; export type StrapiApiDataListPage = { readonly id: number; - readonly attributes: { - readonly title: string; - readonly description?: string; - readonly product: { - readonly data?: StrapiBaseProductWithRelations; - }; - readonly updatedAt: string; - readonly apiData: StrapiBaseApiDataList; - readonly bannerLinks: readonly StrapiBannerLink[]; - readonly seo?: StrapiSeo; - readonly enableFilters?: boolean; - }; + readonly title: string; + readonly description?: string; + readonly product?: StrapiBaseProductWithRelations; + readonly updatedAt: string; + readonly api_data: StrapiApiDataList; + readonly bannerLinks: readonly StrapiBannerLink[]; + readonly seo?: StrapiSeo; + readonly enableFilters?: boolean; }; export type StrapiApiDataListPageWithoutProduct = { readonly id: number; - readonly attributes: { - readonly apiData: StrapiComponent< - readonly { - readonly attributes: Pick< - StrapiBaseApiData['attributes'], - 'apiRestDetail' | 'apiSoapDetail' - >; - }[] - >; - }; + readonly api_data: readonly Pick< + StrapiApiData, + 'apiRestDetail' | 'apiSoapDetail' + >[]; }; -export type StrapiApiDataListPages = StrapiComponent< - readonly StrapiApiDataListPage[] ->; +export type StrapiApiDataListPages = readonly StrapiApiDataListPage[]; diff --git a/apps/nextjs-website/src/lib/strapi/types/bannerLink.ts b/apps/nextjs-website/src/lib/strapi/types/bannerLink.ts index 7f00a808a4..bd7d37151d 100644 --- a/apps/nextjs-website/src/lib/strapi/types/bannerLink.ts +++ b/apps/nextjs-website/src/lib/strapi/types/bannerLink.ts @@ -5,6 +5,6 @@ export type StrapiBannerLink = { readonly id: number; readonly title?: string; readonly content?: BlocksContent; - readonly icon: { readonly data: StrapiMedia }; + readonly icon: StrapiMedia; readonly theme: 'light' | 'dark'; }; diff --git a/apps/nextjs-website/src/lib/strapi/types/caseHistories.ts b/apps/nextjs-website/src/lib/strapi/types/caseHistories.ts index ce5d588b79..9702f609e9 100644 --- a/apps/nextjs-website/src/lib/strapi/types/caseHistories.ts +++ b/apps/nextjs-website/src/lib/strapi/types/caseHistories.ts @@ -6,26 +6,18 @@ import { StrapiPart } from '@/lib/strapi/types/part'; export type StrapiBaseCaseHistory = { readonly id: number; - readonly attributes: { - readonly slug: string; - readonly title: string; - readonly description?: string; - readonly publishedAt: string; - readonly updatedAt: string; - readonly image?: { - readonly data?: StrapiMedia; - }; - }; + readonly slug: string; + readonly title: string; + readonly description?: string; + readonly publishedAt: string; + readonly updatedAt: string; + readonly image?: StrapiMedia; }; export type StrapiCaseHistory = StrapiBaseCaseHistory & { - readonly attributes: StrapiBaseCaseHistory['attributes'] & { - readonly products: { - readonly data: readonly StrapiBaseProductWithoutBannerLinks[]; - }; - readonly parts: readonly StrapiPart[]; - readonly seo?: StrapiSeo; - }; + readonly products: readonly StrapiBaseProductWithoutBannerLinks[]; + readonly parts: readonly StrapiPart[]; + readonly seo?: StrapiSeo; }; export type StrapiCaseHistories = Paginated; diff --git a/apps/nextjs-website/src/lib/strapi/types/caseHistoriesComponent.ts b/apps/nextjs-website/src/lib/strapi/types/caseHistoriesComponent.ts index 8e77d3f37a..2be27a1ae6 100644 --- a/apps/nextjs-website/src/lib/strapi/types/caseHistoriesComponent.ts +++ b/apps/nextjs-website/src/lib/strapi/types/caseHistoriesComponent.ts @@ -3,7 +3,5 @@ import { StrapiBaseCaseHistory } from '@/lib/strapi/types/caseHistories'; export type StrapiCaseHistoriesComponent = { readonly title: string; readonly description?: string; - readonly case_histories: { - readonly data: readonly StrapiBaseCaseHistory[]; - }; + readonly case_histories: readonly StrapiBaseCaseHistory[]; }; diff --git a/apps/nextjs-website/src/lib/strapi/types/guide.ts b/apps/nextjs-website/src/lib/strapi/types/guide.ts index a4aad774b4..debdb8cf00 100644 --- a/apps/nextjs-website/src/lib/strapi/types/guide.ts +++ b/apps/nextjs-website/src/lib/strapi/types/guide.ts @@ -11,30 +11,20 @@ type StrapiGuideVersion = { }; export type StrapiBaseGuide = { - readonly attributes: { - readonly title: string; - readonly slug: string; - readonly image: { - readonly data: StrapiMedia; - }; - readonly mobileImage: { - readonly data: StrapiMedia; - }; - readonly listItems: ReadonlyArray<{ - readonly text: string; - }>; - }; + readonly title: string; + readonly slug: string; + readonly image: StrapiMedia; + readonly mobileImage: StrapiMedia; + readonly listItems: ReadonlyArray<{ + readonly text: string; + }>; }; export type StrapiGuide = StrapiBaseGuide & { - readonly attributes: { - readonly versions: ReadonlyArray; - readonly product: { - readonly data?: StrapiBaseProductWithRelations; - }; - readonly bannerLinks: ReadonlyArray; - readonly seo?: StrapiSeo; - }; + readonly versions: ReadonlyArray; + readonly product?: StrapiBaseProductWithRelations; + readonly bannerLinks: ReadonlyArray; + readonly seo?: StrapiSeo; }; export type StrapiGuides = Paginated; diff --git a/apps/nextjs-website/src/lib/strapi/types/guideList.ts b/apps/nextjs-website/src/lib/strapi/types/guideList.ts index 926e3f7f05..2996abee49 100644 --- a/apps/nextjs-website/src/lib/strapi/types/guideList.ts +++ b/apps/nextjs-website/src/lib/strapi/types/guideList.ts @@ -6,22 +6,16 @@ import { StrapiBaseProductWithRelations } from '@/lib/strapi/types/product'; export type StrapiGuideListPage = { readonly id: number; - readonly attributes: { - readonly title: string; - readonly description: string; - readonly product: { - readonly data?: StrapiBaseProductWithRelations; - }; - readonly guidesByCategory: ReadonlyArray<{ - readonly category: string; - readonly guides: { - readonly data: ReadonlyArray; - }; - }>; - readonly bannerLinks: ReadonlyArray; - readonly seo?: StrapiSeo; - readonly updatedAt: string; - }; + readonly title: string; + readonly description: string; + readonly product?: StrapiBaseProductWithRelations; + readonly guidesByCategory: ReadonlyArray<{ + readonly category: string; + readonly guides: ReadonlyArray; + }>; + readonly bannerLinks: ReadonlyArray; + readonly seo?: StrapiSeo; + readonly updatedAt: string; }; export type StrapiGuideLists = Paginated; diff --git a/apps/nextjs-website/src/lib/strapi/types/guideListPage.ts b/apps/nextjs-website/src/lib/strapi/types/guideListPage.ts index 1a4d45844a..ddd53fa669 100644 --- a/apps/nextjs-website/src/lib/strapi/types/guideListPage.ts +++ b/apps/nextjs-website/src/lib/strapi/types/guideListPage.ts @@ -6,22 +6,16 @@ import { Paginated } from './paginated'; export type StrapiGuideListPage = { readonly id: number; - readonly attributes: { - readonly title: string; - readonly description: string; - readonly product: { - readonly data?: StrapiBaseProductWithRelations; - }; - readonly guidesByCategory: ReadonlyArray<{ - readonly category: string; - readonly guides: { - readonly data: ReadonlyArray; - }; - }>; - readonly bannerLinks: ReadonlyArray; - readonly seo?: StrapiSeo; - readonly updatedAt: string; - }; + readonly title: string; + readonly description: string; + readonly product?: StrapiBaseProductWithRelations; + readonly guidesByCategory: ReadonlyArray<{ + readonly category: string; + readonly guides: ReadonlyArray; + }>; + readonly bannerLinks: ReadonlyArray; + readonly seo?: StrapiSeo; + readonly updatedAt: string; }; export type StrapiGuideListPages = Paginated; diff --git a/apps/nextjs-website/src/lib/strapi/types/homepage.ts b/apps/nextjs-website/src/lib/strapi/types/homepage.ts index 597bf9abcf..fe5674dfde 100644 --- a/apps/nextjs-website/src/lib/strapi/types/homepage.ts +++ b/apps/nextjs-website/src/lib/strapi/types/homepage.ts @@ -19,36 +19,24 @@ type StrapiHeroSlide = { readonly subheadColor?: 'contrastText' | 'main' | 'light' | 'dark'; readonly callToAction?: StrapiCallToAction; readonly titleColor?: 'contrastText' | 'main' | 'light' | 'dark'; - readonly backgroundImage: { - readonly data?: StrapiMedia; - }; + readonly backgroundImage?: StrapiMedia; }; type StrapiEcosystem = { readonly title?: string; readonly productsTabName: string; - readonly products: { - readonly data: readonly StrapiProduct[]; - }; + readonly products: readonly StrapiProduct[]; readonly solutionsTabName: string; - readonly solutions: { - readonly data: readonly StrapiBaseSolution[]; - }; + readonly solutions: readonly StrapiBaseSolution[]; readonly solutionsCta?: StrapiCallToAction; }; export type StrapiHomepage = { - readonly data: { - readonly attributes: { - readonly updatedAt: string; - readonly comingsoonDocumentation: StrapiRelatedLinks; - readonly heroSlider: readonly StrapiHeroSlide[]; - readonly newsShowcase?: StrapiNewsShowcase; - readonly ecosystem?: StrapiEcosystem; - readonly webinars: { - readonly data: readonly StrapiWebinar[]; - }; - readonly seo?: StrapiSeo; - }; - }; + readonly comingsoonDocumentation: StrapiRelatedLinks; + readonly heroSlider: readonly StrapiHeroSlide[]; + readonly newsShowcase?: StrapiNewsShowcase; + readonly ecosystem?: StrapiEcosystem; + readonly webinars: readonly StrapiWebinar[]; + readonly seo?: StrapiSeo; + readonly updatedAt: string; }; diff --git a/apps/nextjs-website/src/lib/strapi/types/media.ts b/apps/nextjs-website/src/lib/strapi/types/media.ts index 32ffcb1ecf..e7273802d3 100644 --- a/apps/nextjs-website/src/lib/strapi/types/media.ts +++ b/apps/nextjs-website/src/lib/strapi/types/media.ts @@ -1,13 +1,11 @@ export type StrapiMedia = { - readonly attributes: { - readonly name: string; - readonly ext: string; - readonly mime: string; - readonly size: number; - readonly url: string; - readonly alternativeText?: string; - readonly caption?: string; - readonly height?: number; - readonly width?: number; - }; + readonly name: string; + readonly ext: string; + readonly mime: string; + readonly size: number; + readonly url: string; + readonly alternativeText?: string; + readonly caption?: string; + readonly height?: number; + readonly width?: number; }; diff --git a/apps/nextjs-website/src/lib/strapi/types/newsShowcase.ts b/apps/nextjs-website/src/lib/strapi/types/newsShowcase.ts index b088a80ff8..86774e119c 100644 --- a/apps/nextjs-website/src/lib/strapi/types/newsShowcase.ts +++ b/apps/nextjs-website/src/lib/strapi/types/newsShowcase.ts @@ -2,21 +2,17 @@ import { StrapiLink } from '@/lib/strapi/types/link'; import { StrapiMedia } from '@/lib/strapi/types/media'; type StrapiNewsItem = { - readonly attributes: { - readonly comingSoon: boolean; - readonly title: string; - readonly link: StrapiLink; - readonly publishedAt: string; - readonly image?: { readonly data: StrapiMedia }; - readonly label?: string; - }; + readonly comingSoon: boolean; + readonly title: string; + readonly link: StrapiLink; + readonly publishedAt: string; + readonly image?: StrapiMedia; + readonly label?: string; }; export type StrapiNewsShowcase = { readonly title: string; readonly subTitle?: string; readonly link?: StrapiLink; - readonly items: { - readonly data: ReadonlyArray; - }; + readonly items: ReadonlyArray; }; diff --git a/apps/nextjs-website/src/lib/strapi/types/overviews.ts b/apps/nextjs-website/src/lib/strapi/types/overviews.ts index 05162c79d1..a360421875 100644 --- a/apps/nextjs-website/src/lib/strapi/types/overviews.ts +++ b/apps/nextjs-website/src/lib/strapi/types/overviews.ts @@ -11,7 +11,7 @@ import { StrapiProduct } from '@/lib/strapi/types/product'; import { StrapiBaseUseCase } from './useCase'; export type StrapiStartInfo = { - readonly icon: { readonly data: StrapiMedia }; + readonly icon: StrapiMedia; readonly title: string; readonly description: string; readonly path: string; @@ -33,14 +33,14 @@ export type StrapiFeature = { export type StrapiTutorialSection = { readonly title: string; readonly description: string; - readonly tutorials: { readonly data: readonly StrapiBaseTutorial[] }; + readonly tutorials: readonly StrapiBaseTutorial[]; readonly showCardsLayout: boolean; }; export type StrapiUseCaseSection = { readonly title: string; readonly description: string; - readonly useCases: { readonly data: readonly StrapiBaseUseCase[] }; + readonly useCases: readonly StrapiBaseUseCase[]; }; export type StrapiCardProps = { @@ -48,8 +48,8 @@ export type StrapiCardProps = { readonly content: BlocksContent; readonly linkText: string; readonly linkHref: string; - readonly image: { readonly data: StrapiMedia }; - readonly mobileImage: { readonly data: StrapiMedia }; + readonly image: StrapiMedia; + readonly mobileImage: StrapiMedia; }; export type StrapiServiceModel = { @@ -64,30 +64,28 @@ export type StrapiPostIntegration = { readonly link?: StrapiLink; readonly guidesTitle?: string; readonly documents: readonly StrapiCardProps[]; - readonly guides: { readonly data: readonly StrapiBaseGuide[] }; + readonly guides: readonly StrapiBaseGuide[]; readonly serviceModels: readonly StrapiServiceModel[]; }; export type StrapiOverview = { readonly id: number; - readonly attributes: { - readonly title: string; - readonly createdAt: string; - readonly updatedAt: string; - readonly publishedAt: string; - readonly subtitle: string; - readonly backgroundImage: { readonly data: StrapiMedia }; - readonly features?: StrapiFeature; - readonly startInfoSection?: StrapiStartInfoSection; - readonly tutorialSection?: StrapiTutorialSection; - readonly useCaseSection?: StrapiUseCaseSection; - readonly postIntegration?: StrapiPostIntegration; - readonly relatedLinks?: StrapiRelatedLinks; - readonly product: { readonly data: StrapiProduct }; - readonly bannerLinks: readonly StrapiBannerLink[]; - readonly seo?: StrapiSeo; - readonly whatsNew?: StrapiNewsShowcase; - }; + readonly title: string; + readonly createdAt: string; + readonly updatedAt: string; + readonly publishedAt: string; + readonly subtitle: string; + readonly backgroundImage: StrapiMedia; + readonly features?: StrapiFeature; + readonly startInfoSection?: StrapiStartInfoSection; + readonly tutorialSection?: StrapiTutorialSection; + readonly useCaseSection?: StrapiUseCaseSection; + readonly postIntegration?: StrapiPostIntegration; + readonly relatedLinks?: StrapiRelatedLinks; + readonly product: StrapiProduct; + readonly bannerLinks: readonly StrapiBannerLink[]; + readonly seo?: StrapiSeo; + readonly whatsNew?: StrapiNewsShowcase; }; export type StrapiOverviews = Paginated; diff --git a/apps/nextjs-website/src/lib/strapi/types/part.ts b/apps/nextjs-website/src/lib/strapi/types/part.ts index 6a307fff46..6b2d66f09a 100644 --- a/apps/nextjs-website/src/lib/strapi/types/part.ts +++ b/apps/nextjs-website/src/lib/strapi/types/part.ts @@ -45,9 +45,7 @@ type HtmlPart = { }; type QuotePart = { - readonly backgroundImage: { - readonly data?: StrapiMedia; - }; + readonly backgroundImage: StrapiMedia; readonly text: string; readonly __component: 'parts.quote'; }; diff --git a/apps/nextjs-website/src/lib/strapi/types/product.ts b/apps/nextjs-website/src/lib/strapi/types/product.ts index ed5dfb545b..c17362bac5 100644 --- a/apps/nextjs-website/src/lib/strapi/types/product.ts +++ b/apps/nextjs-website/src/lib/strapi/types/product.ts @@ -1,6 +1,5 @@ import { StrapiBannerLink } from '@/lib/strapi/types/bannerLink'; import { StrapiMedia } from '@/lib/strapi/types/media'; -import { StrapiComponent } from '@/lib/strapi/types/strapiComponent'; import { StrapiApiDataListPageWithoutProduct } from '@/lib/strapi/types/apiDataListPages'; import { Paginated } from '@/lib/strapi/types/paginated'; import { StrapiTag } from '@/lib/strapi/types/tag'; @@ -10,56 +9,41 @@ type Id = { }; export type StrapiBaseProduct = { - readonly attributes: { - readonly name: string; - readonly shortName: string; - readonly slug: string; - readonly isVisible: boolean; - }; + readonly name: string; + readonly shortName: string; + readonly slug: string; + readonly isVisible: boolean; }; export type StrapiBaseProductWithBannerLinks = StrapiBaseProduct & { - readonly attributes: { - readonly bannerLinks?: readonly StrapiBannerLink[]; - }; + readonly bannerLinks?: readonly StrapiBannerLink[]; }; export type StrapiBaseProductWithoutBannerLinks = StrapiBaseProduct & { - readonly attributes: { - readonly description?: string; - readonly logo: { - readonly data?: StrapiMedia; - }; - }; + readonly description?: string; + readonly logo?: StrapiMedia; }; export type StrapiProductRelations = { - readonly overview: StrapiComponent; - readonly quickstart_guide: StrapiComponent; - readonly api_data_list_page: StrapiComponent< - StrapiApiDataListPageWithoutProduct | undefined - >; - readonly tutorial_list_page: StrapiComponent; - readonly guide_list_page: StrapiComponent; - readonly release_note: StrapiComponent; - readonly use_case_list_page: StrapiComponent; - readonly tags: StrapiComponent; + readonly overview?: number; + readonly quickstart_guide?: number; + readonly api_data_list_page?: StrapiApiDataListPageWithoutProduct; + readonly tutorial_list_page?: number; + readonly guide_list_page?: number; + readonly release_note?: number; + readonly use_case_list_page?: number; + readonly tags?: readonly StrapiTag[]; }; -export type StrapiBaseProductWithRelations = StrapiBaseProduct & { - readonly attributes: StrapiProductRelations & { +export type StrapiBaseProductWithRelations = StrapiBaseProduct & + StrapiProductRelations & { readonly bannerLinks?: readonly StrapiBannerLink[]; }; -}; -export type StrapiProduct = StrapiBaseProduct & { - readonly attributes: StrapiProductRelations & { - readonly bannerLinks?: readonly StrapiBannerLink[]; - readonly description?: string; - readonly logo: { - readonly data: StrapiMedia; - }; - }; +export type StrapiProduct = StrapiBaseProductWithRelations & { + readonly bannerLinks?: readonly StrapiBannerLink[]; + readonly description?: string; + readonly logo?: StrapiMedia; }; export type StrapiProducts = Paginated; diff --git a/apps/nextjs-website/src/lib/strapi/types/quickStartGuides.ts b/apps/nextjs-website/src/lib/strapi/types/quickStartGuides.ts index 7578fc1131..850da764e0 100644 --- a/apps/nextjs-website/src/lib/strapi/types/quickStartGuides.ts +++ b/apps/nextjs-website/src/lib/strapi/types/quickStartGuides.ts @@ -1,4 +1,3 @@ -import { StrapiComponent } from '@/lib/strapi/types/strapiComponent'; import { StrapiBaseProductWithRelations } from '@/lib/strapi/types/product'; import { StrapiBannerLink } from '@/lib/strapi/types/bannerLink'; import { StrapiSeo } from '@/lib/strapi/types/seo'; @@ -7,29 +6,21 @@ import { StrapiPart } from '@/lib/strapi/types/part'; export type StrapiQuickStartGuideItem = { readonly id: number; - readonly attributes: { - readonly title: string; - readonly anchor: string; - readonly publishedAt: string; - readonly parts: readonly StrapiPart[]; - }; + readonly title: string; + readonly anchor: string; + readonly publishedAt: string; + readonly parts: readonly StrapiPart[]; }; export type StrapiQuickStartGuide = { readonly id: number; - readonly attributes: { - readonly bannerLinks: readonly StrapiBannerLink[]; - readonly description: string; - readonly product: { - readonly data?: StrapiBaseProductWithRelations; - }; - readonly quickstartGuideItems: StrapiComponent< - readonly StrapiQuickStartGuideItem[] - >; - readonly seo?: StrapiSeo; - readonly title: string; - readonly updatedAt: string; - }; + readonly bannerLinks: readonly StrapiBannerLink[]; + readonly description: string; + readonly product?: StrapiBaseProductWithRelations; + readonly quickstartGuideItems: readonly StrapiQuickStartGuideItem[]; + readonly seo?: StrapiSeo; + readonly title: string; + readonly updatedAt: string; }; export type StrapiQuickStartGuides = Paginated; diff --git a/apps/nextjs-website/src/lib/strapi/types/releaseNotes.ts b/apps/nextjs-website/src/lib/strapi/types/releaseNotes.ts index 90f912a349..f7fc5a3580 100644 --- a/apps/nextjs-website/src/lib/strapi/types/releaseNotes.ts +++ b/apps/nextjs-website/src/lib/strapi/types/releaseNotes.ts @@ -5,19 +5,15 @@ import { Paginated } from '@/lib/strapi/types/paginated'; export type StrapiReleaseNote = { readonly id: number; - readonly attributes: { - readonly bannerLinks: readonly StrapiBannerLink[]; - readonly createdAt: string; - readonly dirName: string; - readonly landingFile: string; - readonly product: { - readonly data?: StrapiBaseProductWithRelations; - }; - readonly publishedAt: string; - readonly seo?: StrapiSeo; - readonly title: string; - readonly updatedAt: string; - }; + readonly bannerLinks: readonly StrapiBannerLink[]; + readonly createdAt: string; + readonly dirName: string; + readonly landingFile: string; + readonly product?: StrapiBaseProductWithRelations; + readonly publishedAt: string; + readonly seo?: StrapiSeo; + readonly title: string; + readonly updatedAt: string; }; export type StrapiReleaseNotes = Paginated; diff --git a/apps/nextjs-website/src/lib/strapi/types/rootEntity.ts b/apps/nextjs-website/src/lib/strapi/types/rootEntity.ts new file mode 100644 index 0000000000..6588732886 --- /dev/null +++ b/apps/nextjs-website/src/lib/strapi/types/rootEntity.ts @@ -0,0 +1,3 @@ +export type RootEntity = { + readonly data: T; +}; diff --git a/apps/nextjs-website/src/lib/strapi/types/seo.ts b/apps/nextjs-website/src/lib/strapi/types/seo.ts index baf77f8b1e..35c4c0acca 100644 --- a/apps/nextjs-website/src/lib/strapi/types/seo.ts +++ b/apps/nextjs-website/src/lib/strapi/types/seo.ts @@ -18,9 +18,7 @@ export type StrapiSeo = Partial<{ readonly metaRobots: string; readonly metaViewport: string; readonly canonicalURL: string; - readonly metaImage: { - readonly data?: Partial; - }; + readonly metaImage?: Partial; readonly metaSocial: ReadonlyArray; readonly structuredData: unknown; }>; diff --git a/apps/nextjs-website/src/lib/strapi/types/solutionListPage.ts b/apps/nextjs-website/src/lib/strapi/types/solutionListPage.ts index c695dac88c..616b465c5e 100644 --- a/apps/nextjs-website/src/lib/strapi/types/solutionListPage.ts +++ b/apps/nextjs-website/src/lib/strapi/types/solutionListPage.ts @@ -4,16 +4,10 @@ import { StrapiSeo } from '@/lib/strapi/types/seo'; import { StrapiFeatures } from '@/lib/strapi/types/features'; export type StrapiSolutionListPage = { - readonly data: { - readonly attributes: { - readonly title: string; - readonly description: string; - readonly caseHistories?: StrapiCaseHistoriesComponent; - readonly solutions: { - readonly data: readonly StrapiBaseSolutionWithProducts[]; - }; - readonly features?: StrapiFeatures; - readonly seo?: StrapiSeo; - }; - }; + readonly title: string; + readonly description: string; + readonly caseHistories?: StrapiCaseHistoriesComponent; + readonly solutions: readonly StrapiBaseSolutionWithProducts[]; + readonly features?: StrapiFeatures; + readonly seo?: StrapiSeo; }; diff --git a/apps/nextjs-website/src/lib/strapi/types/solutions.ts b/apps/nextjs-website/src/lib/strapi/types/solutions.ts index fb3d1bb4a9..ae25cf9d44 100644 --- a/apps/nextjs-website/src/lib/strapi/types/solutions.ts +++ b/apps/nextjs-website/src/lib/strapi/types/solutions.ts @@ -13,9 +13,7 @@ import { StrapiCaseHistoriesComponent } from '@/lib/strapi/types/caseHistoriesCo export type StrapiStep = { readonly title: string; readonly content: BlocksContent; - readonly products: { - readonly data: readonly StrapiBaseProduct[]; - }; + readonly products: readonly StrapiBaseProduct[]; }; export type StrapiStat = { @@ -24,64 +22,46 @@ export type StrapiStat = { }; export type StrapiBaseSolution = { - readonly attributes: { - readonly slug: string; - readonly icon: { - readonly data: StrapiMedia; - }; - readonly kickerTitle: string; - readonly title: string; - readonly description?: string; - readonly dirName: string; - readonly landingUseCaseFile: string; - }; + readonly slug: string; + readonly icon: StrapiMedia; + readonly kickerTitle: string; + readonly title: string; + readonly description?: string; + readonly dirName: string; + readonly landingUseCaseFile: string; }; export type StrapiBaseSolutionWithProducts = { - readonly attributes: { - readonly slug: string; - readonly icon: { - readonly data: StrapiMedia; - }; - readonly kickerTitle: string; - readonly title: string; - readonly description?: string; - readonly dirName: string; - readonly landingUseCaseFile: string; - readonly products: { - readonly data: readonly StrapiBaseProductWithoutBannerLinks[]; - }; - }; + readonly slug: string; + readonly icon: StrapiMedia; + readonly kickerTitle: string; + readonly title: string; + readonly description?: string; + readonly dirName: string; + readonly landingUseCaseFile: string; + readonly products: readonly StrapiBaseProductWithoutBannerLinks[]; }; export type StrapiSolution = { readonly id: number; - readonly attributes: { - readonly slug: string; - readonly icon: { - readonly data: StrapiMedia; - }; - readonly kickerTitle: string; - readonly title: string; - readonly description?: string; - readonly dirName: string; - readonly landingUseCaseFile: string; - readonly publishedAt: string; - readonly updatedAt: string; - readonly introductionToSteps?: string; - readonly steps: readonly StrapiStep[]; - readonly stats: readonly StrapiStat[]; - readonly statsSource?: string; - readonly bannerLinks: readonly StrapiBannerLink[]; - readonly webinars: { - readonly data: readonly StrapiWebinar[]; - }; - readonly products: { - readonly data: readonly StrapiBaseProductWithoutBannerLinks[]; - }; - readonly caseHistories?: StrapiCaseHistoriesComponent; - readonly seo?: StrapiSeo; - }; + readonly slug: string; + readonly icon: StrapiMedia; + readonly kickerTitle: string; + readonly title: string; + readonly description?: string; + readonly dirName: string; + readonly landingUseCaseFile: string; + readonly publishedAt: string; + readonly updatedAt: string; + readonly introductionToSteps?: string; + readonly steps: readonly StrapiStep[]; + readonly stats: readonly StrapiStat[]; + readonly statsSource?: string; + readonly bannerLinks: readonly StrapiBannerLink[]; + readonly webinars: readonly StrapiWebinar[]; + readonly products: readonly StrapiBaseProductWithoutBannerLinks[]; + readonly caseHistories?: StrapiCaseHistoriesComponent; + readonly seo?: StrapiSeo; }; export type StrapiSolutions = Paginated; diff --git a/apps/nextjs-website/src/lib/strapi/types/strapiComponent.ts b/apps/nextjs-website/src/lib/strapi/types/strapiComponent.ts deleted file mode 100644 index 5cd6db2597..0000000000 --- a/apps/nextjs-website/src/lib/strapi/types/strapiComponent.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type StrapiComponent = { - readonly data: T; -}; diff --git a/apps/nextjs-website/src/lib/strapi/types/tag.ts b/apps/nextjs-website/src/lib/strapi/types/tag.ts index b6b964f870..13c49d9469 100644 --- a/apps/nextjs-website/src/lib/strapi/types/tag.ts +++ b/apps/nextjs-website/src/lib/strapi/types/tag.ts @@ -2,10 +2,8 @@ import { StrapiMedia } from '@/lib/strapi/types/media'; import { Paginated } from '@/lib/strapi/types/paginated'; export type StrapiTag = { - readonly attributes: { - readonly name: string; - readonly icon: { readonly data: StrapiMedia }; - }; + readonly name: string; + readonly icon: StrapiMedia; }; export type StrapiTags = Paginated; diff --git a/apps/nextjs-website/src/lib/strapi/types/tutorial.ts b/apps/nextjs-website/src/lib/strapi/types/tutorial.ts index 751b246fd1..a615dd50f5 100644 --- a/apps/nextjs-website/src/lib/strapi/types/tutorial.ts +++ b/apps/nextjs-website/src/lib/strapi/types/tutorial.ts @@ -5,39 +5,28 @@ import { StrapiRelatedLinks } from '@/lib/strapi/types/link'; import { StrapiSeo } from '@/lib/strapi/types/seo'; import { Paginated } from '@/lib/strapi/types/paginated'; import { StrapiPart } from '@/lib/strapi/types/part'; -import { StrapiComponent } from '@/lib/strapi/types/strapiComponent'; import { StrapiTag } from '@/lib/strapi/types/tag'; export type StrapiBaseTutorial = { - readonly attributes: { - readonly updatedAt: string; - readonly title: string; - readonly slug: string; - readonly publishedAt?: string; - readonly image: { - readonly data?: StrapiMedia; - }; - readonly tags: StrapiComponent; - readonly product: { - readonly data: StrapiBaseProductWithBannerLinks; - }; - readonly icon: { - readonly data?: StrapiMedia; - }; - readonly description?: string; - }; + readonly updatedAt: string; + readonly title: string; + readonly slug: string; + readonly publishedAt?: string; + readonly image?: StrapiMedia; + readonly tags?: readonly StrapiTag[]; + readonly product?: StrapiBaseProductWithBannerLinks; + readonly icon?: StrapiMedia; + readonly description?: string; }; export type StrapiTutorial = StrapiBaseTutorial & { - readonly attributes: { - readonly createdAt: string; - readonly locale: string; - readonly parts: readonly StrapiPart[]; - readonly updatedAt: string; - readonly bannerLinks?: readonly StrapiBannerLink[]; - readonly relatedLinks?: StrapiRelatedLinks; - readonly seo?: StrapiSeo; - }; + readonly createdAt: string; + readonly locale: string; + readonly parts: readonly StrapiPart[]; + readonly updatedAt: string; + readonly bannerLinks?: readonly StrapiBannerLink[]; + readonly relatedLinks?: StrapiRelatedLinks; + readonly seo?: StrapiSeo; }; export type StrapiTutorials = Paginated; diff --git a/apps/nextjs-website/src/lib/strapi/types/tutorialsListPage.ts b/apps/nextjs-website/src/lib/strapi/types/tutorialsListPage.ts index 1a1746bf97..ace94f867e 100644 --- a/apps/nextjs-website/src/lib/strapi/types/tutorialsListPage.ts +++ b/apps/nextjs-website/src/lib/strapi/types/tutorialsListPage.ts @@ -6,17 +6,13 @@ import { StrapiBaseProductWithRelations } from '@/lib/strapi/types/product'; export type StrapiTutorialsListPage = { readonly id: number; - readonly attributes: { - readonly bannerLinks: readonly StrapiBannerLink[]; - readonly description: string; - readonly product: { - readonly data?: StrapiBaseProductWithRelations; - }; - readonly title: string; - readonly tutorials: { readonly data: readonly StrapiBaseTutorial[] }; - readonly seo?: StrapiSeo; - readonly enableFilters?: boolean; - }; + readonly bannerLinks: readonly StrapiBannerLink[]; + readonly description: string; + readonly product?: StrapiBaseProductWithRelations; + readonly title: string; + readonly tutorials: readonly StrapiBaseTutorial[]; + readonly seo?: StrapiSeo; + readonly enableFilters?: boolean; }; export type StrapiTutorialListPages = Paginated; diff --git a/apps/nextjs-website/src/lib/strapi/types/urlReplaceMap.ts b/apps/nextjs-website/src/lib/strapi/types/urlReplaceMap.ts index adce60c26e..53b51c58e5 100644 --- a/apps/nextjs-website/src/lib/strapi/types/urlReplaceMap.ts +++ b/apps/nextjs-website/src/lib/strapi/types/urlReplaceMap.ts @@ -1,14 +1,8 @@ -import { StrapiComponent } from './strapiComponent'; - type Guide = { - readonly attributes: { - readonly title: string; + readonly title: string; + readonly slug: string; + readonly product: { readonly slug: string; - readonly product: StrapiComponent<{ - readonly attributes: { - readonly slug: string; - }; - }>; }; }; @@ -16,13 +10,9 @@ export type StrapiUrlToGuide = { readonly id: number; readonly url: string; readonly subPath?: string; - readonly guide: StrapiComponent; + readonly guide?: Guide; }; export type StrapiUrlReplaceMap = { - readonly data: { - readonly attributes: { - readonly urlToGuide: readonly StrapiUrlToGuide[]; - }; - }; + readonly urlToGuide: readonly StrapiUrlToGuide[]; }; diff --git a/apps/nextjs-website/src/lib/strapi/types/useCase.ts b/apps/nextjs-website/src/lib/strapi/types/useCase.ts index d791086259..0c2699c7d1 100644 --- a/apps/nextjs-website/src/lib/strapi/types/useCase.ts +++ b/apps/nextjs-website/src/lib/strapi/types/useCase.ts @@ -5,38 +5,27 @@ import { StrapiRelatedLinks } from '@/lib/strapi/types/link'; import { StrapiSeo } from '@/lib/strapi/types/seo'; import { Paginated } from '@/lib/strapi/types/paginated'; import { StrapiPart } from '@/lib/strapi/types/part'; -import { StrapiComponent } from '@/lib/strapi/types/strapiComponent'; import { StrapiTag } from '@/lib/strapi/types/tag'; export type StrapiBaseUseCase = { - readonly attributes: { - readonly coverImage: { - readonly data?: StrapiMedia; - }; - readonly headerImage?: { - readonly data?: StrapiMedia; - }; - readonly product: { - readonly data: StrapiBaseProductWithBannerLinks; - }; - readonly publishedAt?: string; - readonly slug: string; - readonly subtitle?: string; - readonly tags: StrapiComponent; - readonly title: string; - }; + readonly coverImage?: StrapiMedia; + readonly headerImage?: StrapiMedia; + readonly product: StrapiBaseProductWithBannerLinks; + readonly publishedAt?: string; + readonly slug: string; + readonly subtitle?: string; + readonly tags?: readonly StrapiTag[]; + readonly title: string; }; export type StrapiUseCase = StrapiBaseUseCase & { - readonly attributes: { - readonly createdAt: string; - readonly locale: string; - readonly parts: readonly StrapiPart[]; - readonly updatedAt: string; - readonly bannerLinks?: readonly StrapiBannerLink[]; - readonly relatedLinks?: StrapiRelatedLinks; - readonly seo?: StrapiSeo; - }; + readonly createdAt: string; + readonly locale: string; + readonly parts: readonly StrapiPart[]; + readonly updatedAt: string; + readonly bannerLinks?: readonly StrapiBannerLink[]; + readonly relatedLinks?: StrapiRelatedLinks; + readonly seo?: StrapiSeo; }; export type StrapiUseCases = Paginated; diff --git a/apps/nextjs-website/src/lib/strapi/types/useCaseListPage.ts b/apps/nextjs-website/src/lib/strapi/types/useCaseListPage.ts index 77c7f89caa..e350f9296e 100644 --- a/apps/nextjs-website/src/lib/strapi/types/useCaseListPage.ts +++ b/apps/nextjs-website/src/lib/strapi/types/useCaseListPage.ts @@ -6,17 +6,13 @@ import { StrapiBaseUseCase } from './useCase'; export type StrapiUseCaseListPage = { readonly id: number; - readonly attributes: { - readonly bannerLinks: readonly StrapiBannerLink[]; - readonly description: string; - readonly enableFilters: boolean | undefined; - readonly product: { - readonly data?: StrapiBaseProductWithRelations; - }; - readonly seo?: StrapiSeo; - readonly title: string; - readonly useCases: { readonly data: readonly StrapiBaseUseCase[] }; - }; + readonly bannerLinks: readonly StrapiBannerLink[]; + readonly description: string; + readonly enableFilters: boolean | undefined; + readonly product?: StrapiBaseProductWithRelations; + readonly seo?: StrapiSeo; + readonly title: string; + readonly useCases: readonly StrapiBaseUseCase[]; }; export type StrapiUseCaseListPages = Paginated; diff --git a/apps/nextjs-website/src/lib/strapi/types/webinarCategory.ts b/apps/nextjs-website/src/lib/strapi/types/webinarCategory.ts index f9ac7f724d..dfbc4e2665 100644 --- a/apps/nextjs-website/src/lib/strapi/types/webinarCategory.ts +++ b/apps/nextjs-website/src/lib/strapi/types/webinarCategory.ts @@ -3,10 +3,8 @@ import { Paginated } from '@/lib/strapi/types/paginated'; export type StrapiWebinarCategory = { readonly id: number; - readonly attributes: { - readonly name: string; - readonly icon: { readonly data: StrapiMedia }; - }; + readonly name: string; + readonly icon: StrapiMedia; }; export type StrapiWebinarCategories = Paginated; diff --git a/apps/nextjs-website/src/lib/strapi/types/webinars.ts b/apps/nextjs-website/src/lib/strapi/types/webinars.ts index 94ff613b59..be6d59f52f 100644 --- a/apps/nextjs-website/src/lib/strapi/types/webinars.ts +++ b/apps/nextjs-website/src/lib/strapi/types/webinars.ts @@ -7,13 +7,11 @@ import { Paginated } from '@/lib/strapi/types/paginated'; type StrapiWebinarSpeaker = { readonly id: number; - readonly attributes: { - readonly name: string; - readonly jobTitle: string; - readonly publishedAt: string; - readonly description?: BlocksContent; - readonly avatar: { readonly data?: StrapiMedia }; - }; + readonly name: string; + readonly jobTitle: string; + readonly publishedAt: string; + readonly description?: BlocksContent; + readonly avatar?: StrapiMedia; }; type StrapiResource = { @@ -22,13 +20,13 @@ type StrapiResource = { readonly linkHref: string; readonly subtitle?: string; readonly description?: BlocksContent; - readonly image: { readonly data?: StrapiMedia }; + readonly image?: StrapiMedia; }; type StrapiRelatedResources = { readonly title: string; readonly resources?: readonly StrapiResource[]; - readonly downloadableDocuments?: { readonly data: readonly StrapiMedia[] }; + readonly downloadableDocuments?: readonly StrapiMedia[]; }; type StrapiQuestionAndAnswer = { @@ -38,31 +36,27 @@ type StrapiQuestionAndAnswer = { export type StrapiWebinar = { readonly id: number; - readonly attributes: { - readonly title: string; - readonly description: string; - readonly slug: string; - readonly publishedAt: string; - readonly isVisibleInList: boolean; - readonly coverImage: { readonly data: StrapiMedia }; - readonly bodyContent?: BlocksContent; - readonly playerSrc?: string; - readonly playerCoverImage?: { readonly data?: StrapiMedia }; - readonly videoOnDemandStartAt?: number; - readonly startDatetime?: string; - readonly endDatetime?: string; - readonly subscribeParagraphLabel?: string; - readonly relatedLinks?: StrapiRelatedLinks; - readonly relatedResources?: StrapiRelatedResources; - readonly webinarSpeakers: { - readonly data: readonly StrapiWebinarSpeaker[]; - }; - readonly questionsAndAnswers?: readonly StrapiQuestionAndAnswer[]; - readonly seo?: StrapiSeo; - readonly webinarCategory: { readonly data?: StrapiWebinarCategory }; - readonly headerImage: { readonly data?: StrapiMedia }; - readonly updatedAt: string; - }; + readonly title: string; + readonly description: string; + readonly slug: string; + readonly publishedAt: string; + readonly isVisibleInList: boolean; + readonly coverImage: StrapiMedia; + readonly bodyContent?: BlocksContent; + readonly playerSrc?: string; + readonly playerCoverImage?: StrapiMedia; + readonly startDatetime?: string; + readonly endDatetime?: string; + readonly videoOnDemandStartAt?: number; + readonly subscribeParagraphLabel?: string; + readonly relatedLinks?: StrapiRelatedLinks; + readonly relatedResources?: StrapiRelatedResources; + readonly webinarSpeakers: readonly StrapiWebinarSpeaker[]; + readonly questionsAndAnswers?: readonly StrapiQuestionAndAnswer[]; + readonly seo?: StrapiSeo; + readonly webinarCategory?: StrapiWebinarCategory; + readonly headerImage?: StrapiMedia; + readonly updatedAt: string; }; export type StrapiWebinars = Paginated; diff --git a/apps/nextjs-website/src/lib/types/seo.ts b/apps/nextjs-website/src/lib/types/seo.ts index ae68e0ef30..dc28803554 100644 --- a/apps/nextjs-website/src/lib/types/seo.ts +++ b/apps/nextjs-website/src/lib/types/seo.ts @@ -12,31 +12,27 @@ export type SEO = { readonly metaViewport?: string; readonly canonicalURL?: string; readonly metaImage?: { - readonly data?: { - readonly id?: number; - readonly attributes?: { - readonly name?: string; - readonly alternativeText?: string | null; - readonly caption?: string | null; - readonly width?: number; - readonly height?: number; - readonly formats?: { - readonly thumbnail?: ImageFormat; - readonly small?: ImageFormat; - readonly medium?: ImageFormat; - }; - readonly hash?: string; - readonly ext?: string; - readonly mime?: string; - readonly size?: number; - readonly url?: string; - readonly previewUrl?: string | null; - readonly provider?: string; - readonly provider_metadata?: unknown; - readonly createdAt?: string; - readonly updatedAt?: string; - }; + readonly id?: number; + readonly name?: string; + readonly alternativeText?: string | null; + readonly caption?: string | null; + readonly width?: number; + readonly height?: number; + readonly formats?: { + readonly thumbnail?: ImageFormat; + readonly small?: ImageFormat; + readonly medium?: ImageFormat; }; + readonly hash?: string; + readonly ext?: string; + readonly mime?: string; + readonly size?: number; + readonly url?: string; + readonly previewUrl?: string | null; + readonly provider?: string; + readonly provider_metadata?: unknown; + readonly createdAt?: string; + readonly updatedAt?: string; }; readonly metaSocial?: ReadonlyArray<{ readonly id?: number; diff --git a/apps/nextjs-website/src/lib/types/tag.ts b/apps/nextjs-website/src/lib/types/tag.ts index 2e3bb49fc5..189867ce91 100644 --- a/apps/nextjs-website/src/lib/types/tag.ts +++ b/apps/nextjs-website/src/lib/types/tag.ts @@ -2,5 +2,5 @@ import { Media } from './media'; export type Tag = { readonly name: string; - readonly icon: { readonly data: { readonly attributes: Media } }; + readonly icon: Media; }; diff --git a/apps/nextjs-website/src/lib/types/webinarCategory.ts b/apps/nextjs-website/src/lib/types/webinarCategory.ts index 712e11da89..315ec88cb1 100644 --- a/apps/nextjs-website/src/lib/types/webinarCategory.ts +++ b/apps/nextjs-website/src/lib/types/webinarCategory.ts @@ -2,5 +2,5 @@ import { Media } from './media'; export type WebinarCategory = { readonly name: string; - readonly icon: { readonly data: { readonly attributes: Media } }; + readonly icon: Media; }; diff --git a/packages/gitbook-docs/src/helpers/strapiQuery.ts b/packages/gitbook-docs/src/helpers/strapiQuery.ts index 3402c26681..afb49ecfac 100644 --- a/packages/gitbook-docs/src/helpers/strapiQuery.ts +++ b/packages/gitbook-docs/src/helpers/strapiQuery.ts @@ -17,8 +17,8 @@ const productRelationsPopulate = { 'quickstart_guide', 'release_note', 'api_data_list_page', - 'api_data_list_page.apiData.*', - 'api_data_list_page.apiData.apiRestDetail.*', + 'api_data_list_page.api_data', + 'api_data_list_page.api_data.apiRestDetail', 'guide_list_page', 'tutorial_list_page', 'use_case_list_page', @@ -26,37 +26,7 @@ const productRelationsPopulate = { }; const webinarPopulate = { - populate: { - coverImage: { - populate: ['image'], - }, - webinarSpeakers: { - populate: ['avatar'], - }, - relatedLinks: { - populate: ['links'], - }, - relatedResources: { - populate: { - resources: { - populate: ['image'], - }, - downloadableDocuments: { - populate: '*', - }, - }, - }, - seo: { - populate: '*,metaImage,metaSocial.image', - }, - questionsAndAnswers: '*', - webinarCategory: { - populate: ['icon'], - }, - headerImage: { - populate: ['image'], - }, - }, + populate: '*', }; const guidesPopulate = { @@ -66,7 +36,7 @@ const guidesPopulate = { listItems: { populate: '*' }, versions: { populate: '*' }, bannerLinks: { populate: ['icon'] }, - seo: { populate: '*,metaImage,metaSocial.image' }, + seo: { populate: '*' }, product: { ...productRelationsPopulate, }, @@ -81,27 +51,27 @@ const guidesQueryParams = { const releaseNotesPopulate = { populate: { bannerLinks: { - populate: ['icon'], + populate: ['*'], }, product: { populate: [ 'logo', - 'bannerLinks.icon', + 'bannerLinks', 'overview', 'quickstart_guide', 'release_note', 'api_data_list_page', - 'api_data_list_page.apiData.*', - 'api_data_list_page.apiData.apiRestDetail.slug', - 'api_data_list_page.apiData.apiRestDetail.specUrls', - 'api_data_list_page.apiData.apiSoapDetail.*', + 'api_data_list_page.api_data', + 'api_data_list_page.api_data.apiRestDetail', + 'api_data_list_page.api_data.apiRestDetail.specUrls', + 'api_data_list_page.api_data.apiSoapDetail', 'guide_list_page', 'tutorial_list_page', 'use_case_list_page', ], }, seo: { - populate: '*,metaImage,metaSocial.image', + populate: '*', }, }, }; @@ -113,21 +83,25 @@ const releaseNotesQueryParams = { const solutionsPopulate = { populate: { - icon: 'icon', + icon: { + populate: '*', + }, stats: '*', steps: { populate: { - products: '*', + products: { + populate: '*', + }, }, }, seo: { - populate: '*,metaImage,metaSocial.image', + populate: '*', }, products: { - populate: ['logo'], + populate: '*', }, bannerLinks: { - populate: ['icon'], + populate: ['*'], }, webinars: { ...webinarPopulate, @@ -183,10 +157,10 @@ const guideListPagesPopulate = { }, }, bannerLinks: { - populate: ['icon'], + populate: ['*'], }, seo: { - populate: '*,metaImage,metaSocial.image', + populate: '*', }, }, }; @@ -201,10 +175,8 @@ const solutionListPagePopulate = { solutions: { populate: [ 'bannerLinks', - 'bannerLinks.icon', 'products.logo', 'icon', - 'icon.name', 'stats', 'steps', 'steps.products', @@ -222,7 +194,7 @@ const solutionListPagePopulate = { populate: ['items.icon'], }, seo: { - populate: '*,metaImage,metaSocial.image', + populate: '*', }, }, };