Fix DTO after updating cms

This commit is contained in:
DrMint 2024-06-15 15:40:02 +02:00
parent 4f23b02097
commit 3b3b6951fe
22 changed files with 349 additions and 286 deletions

View File

@ -1,14 +1,14 @@
--- ---
import type { import type {
EndpointImage, EndpointImage,
EndpointMediaThumbnail, EndpointPayloadImage,
EndpointScanImage, EndpointScanImage,
} from "src/shared/payload/payload-sdk"; } from "src/shared/payload/payload-sdk";
import { getRandomId } from "src/utils/random"; import { getRandomId } from "src/utils/random";
import { sizesToSrcset } from "src/utils/img"; import { sizesToSrcset } from "src/utils/img";
interface Props { interface Props {
img: EndpointImage | EndpointMediaThumbnail | EndpointScanImage; img: EndpointImage | EndpointPayloadImage | EndpointScanImage;
} }
const { const {

View File

@ -4,7 +4,7 @@ import { getI18n } from "src/i18n/i18n";
import type { import type {
EndpointAudio, EndpointAudio,
EndpointImage, EndpointImage,
EndpointMediaThumbnail, EndpointPayloadImage,
EndpointVideo, EndpointVideo,
} from "src/shared/payload/payload-sdk"; } from "src/shared/payload/payload-sdk";
import { cache } from "src/utils/payload"; import { cache } from "src/utils/payload";
@ -14,7 +14,7 @@ interface Props {
| { | {
title?: string | undefined; title?: string | undefined;
description?: string | undefined; description?: string | undefined;
thumbnail?: EndpointImage | EndpointMediaThumbnail | undefined; thumbnail?: EndpointImage | EndpointPayloadImage | undefined;
audio?: EndpointAudio | undefined; audio?: EndpointAudio | undefined;
video?: EndpointVideo | undefined; video?: EndpointVideo | undefined;
} }

View File

@ -1,8 +1,8 @@
--- ---
import type { EndpointAudio } from "src/shared/payload/payload-sdk"; import type { EndpointAudioPreview } from "src/shared/payload/payload-sdk";
interface Props { interface Props {
audio: EndpointAudio; audio: EndpointAudioPreview;
class?: string | undefined; class?: string | undefined;
} }

View File

@ -2,7 +2,7 @@
import { import {
type EndpointCredit, type EndpointCredit,
type EndpointImage, type EndpointImage,
type EndpointMediaThumbnail, type EndpointPayloadImage,
type EndpointScanImage, type EndpointScanImage,
type RichTextContent, type RichTextContent,
} from "src/shared/payload/payload-sdk"; } from "src/shared/payload/payload-sdk";
@ -18,7 +18,7 @@ import RichText from "./RichText/RichText.astro";
interface Props { interface Props {
previousImageHref?: string | undefined; previousImageHref?: string | undefined;
nextImageHref?: string | undefined; nextImageHref?: string | undefined;
image: EndpointImage | EndpointScanImage | EndpointMediaThumbnail; image: EndpointImage | EndpointScanImage | EndpointPayloadImage;
pretitle?: string | undefined; pretitle?: string | undefined;
title: string; title: string;
subtitle?: string | undefined; subtitle?: string | undefined;
@ -59,8 +59,7 @@ const hasNavigation = previousImageHref || nextImageHref;
<a <a
id="previous-button" id="previous-button"
class:list={{ hidden: !previousImageHref, pressable: true }} class:list={{ hidden: !previousImageHref, pressable: true }}
href={previousImageHref} href={previousImageHref}>
data-astro-history="replace">
<Icon name="material-symbols:chevron-left" /> <Icon name="material-symbols:chevron-left" />
</a> </a>
) )
@ -81,8 +80,7 @@ const hasNavigation = previousImageHref || nextImageHref;
<a <a
id="next-button" id="next-button"
class:list={{ hidden: !nextImageHref, pressable: true }} class:list={{ hidden: !nextImageHref, pressable: true }}
href={nextImageHref} href={nextImageHref}>
data-astro-history="replace">
<Icon name="material-symbols:chevron-right" /> <Icon name="material-symbols:chevron-right" />
</a> </a>
) )

View File

@ -1,10 +1,10 @@
--- ---
import GenericPreview from "components/Previews/GenericPreview.astro"; import GenericPreview from "components/Previews/GenericPreview.astro";
import { getI18n } from "src/i18n/i18n"; import { getI18n } from "src/i18n/i18n";
import type { EndpointAudio } from "src/shared/payload/payload-sdk"; import type { EndpointAudioPreview } from "src/shared/payload/payload-sdk";
interface Props { interface Props {
audio: EndpointAudio; audio: EndpointAudioPreview;
} }
const { getLocalizedMatch, getLocalizedUrl, t, formatDuration } = await getI18n( const { getLocalizedMatch, getLocalizedUrl, t, formatDuration } = await getI18n(

View File

@ -1,13 +1,13 @@
--- ---
import GenericPreview from "components/Previews/GenericPreview.astro"; import GenericPreview from "components/Previews/GenericPreview.astro";
import { getI18n } from "src/i18n/i18n"; import { getI18n } from "src/i18n/i18n";
import type { EndpointCollectible } from "src/shared/payload/payload-sdk"; import type { EndpointCollectiblePreview } from "src/shared/payload/payload-sdk";
import type { Attribute } from "src/utils/attributes"; import type { Attribute } from "src/utils/attributes";
import { convert } from "src/utils/currencies"; import { convert } from "src/utils/currencies";
import { formatLocale } from "src/utils/format"; import { formatLocale } from "src/utils/format";
interface Props { interface Props {
collectible: EndpointCollectible; collectible: EndpointCollectiblePreview;
} }
const { getLocalizedMatch, getLocalizedUrl, t, formatPrice, formatDate } = await getI18n( const { getLocalizedMatch, getLocalizedUrl, t, formatPrice, formatDate } = await getI18n(

View File

@ -2,8 +2,8 @@
import { import {
AttributeTypes, AttributeTypes,
type EndpointAttribute, type EndpointAttribute,
type EndpointImage, type EndpointImagePreview,
type EndpointMediaThumbnail, type EndpointPayloadImage,
type EndpointScanImage, type EndpointScanImage,
} from "src/shared/payload/payload-sdk"; } from "src/shared/payload/payload-sdk";
import Card from "components/Card.astro"; import Card from "components/Card.astro";
@ -15,7 +15,7 @@ import { sizesToSrcset, sizesForGridLayout } from "src/utils/img";
import type { Attribute } from "src/utils/attributes"; import type { Attribute } from "src/utils/attributes";
interface Props { interface Props {
thumbnail?: EndpointImage | EndpointMediaThumbnail | EndpointScanImage | undefined; thumbnail?: EndpointImagePreview | EndpointPayloadImage | EndpointScanImage | undefined;
pretitle?: string | undefined; pretitle?: string | undefined;
title: string; title: string;
subtitle?: string | undefined; subtitle?: string | undefined;

View File

@ -1,10 +1,10 @@
--- ---
import GenericPreview from "components/Previews/GenericPreview.astro"; import GenericPreview from "components/Previews/GenericPreview.astro";
import { getI18n } from "src/i18n/i18n"; import { getI18n } from "src/i18n/i18n";
import type { EndpointImage } from "src/shared/payload/payload-sdk"; import type { EndpointImagePreview } from "src/shared/payload/payload-sdk";
interface Props { interface Props {
image: EndpointImage; image: EndpointImagePreview;
} }
const { getLocalizedMatch, getLocalizedUrl, t } = await getI18n(Astro.locals.currentLocale); const { getLocalizedMatch, getLocalizedUrl, t } = await getI18n(Astro.locals.currentLocale);

View File

@ -1,11 +1,11 @@
--- ---
import GenericPreview from "components/Previews/GenericPreview.astro"; import GenericPreview from "components/Previews/GenericPreview.astro";
import { getI18n } from "src/i18n/i18n"; import { getI18n } from "src/i18n/i18n";
import type { EndpointPage } from "src/shared/payload/payload-sdk"; import type { EndpointPagePreview } from "src/shared/payload/payload-sdk";
import type { Attribute } from "src/utils/attributes"; import type { Attribute } from "src/utils/attributes";
interface Props { interface Props {
page: EndpointPage; page: EndpointPagePreview;
} }
const { getLocalizedMatch, getLocalizedUrl, t, formatDate } = await getI18n( const { getLocalizedMatch, getLocalizedUrl, t, formatDate } = await getI18n(

View File

@ -1,10 +1,10 @@
--- ---
import GenericPreview from "components/Previews/GenericPreview.astro"; import GenericPreview from "components/Previews/GenericPreview.astro";
import { getI18n } from "src/i18n/i18n"; import { getI18n } from "src/i18n/i18n";
import type { EndpointVideo } from "src/shared/payload/payload-sdk"; import type { EndpointVideoPreview } from "src/shared/payload/payload-sdk";
interface Props { interface Props {
video: EndpointVideo; video: EndpointVideoPreview;
} }
const { getLocalizedMatch, getLocalizedUrl, t, formatDuration } = await getI18n( const { getLocalizedMatch, getLocalizedUrl, t, formatDuration } = await getI18n(

View File

@ -1,9 +1,9 @@
--- ---
import type { EndpointVideo } from "src/shared/payload/payload-sdk"; import type { EndpointVideoPreview } from "src/shared/payload/payload-sdk";
import { formatLocale } from "src/utils/format"; import { formatLocale } from "src/utils/format";
interface Props { interface Props {
video: EndpointVideo; video: EndpointVideoPreview;
class?: string | undefined; class?: string | undefined;
} }

View File

@ -305,7 +305,7 @@ export const getI18n = async (locale: string) => {
return { return {
href: getLocalizedUrl(`/folders/${source.folder.slug}`), href: getLocalizedUrl(`/folders/${source.folder.slug}`),
typeLabel: t("global.sources.typeLabel.folder"), typeLabel: t("global.sources.typeLabel.folder"),
label: getLocalizedMatch(source.folder.translations).name, label: formatInlineTitle(translation),
lang: translation.language, lang: translation.language,
}; };
} }
@ -315,7 +315,7 @@ export const getI18n = async (locale: string) => {
return { return {
href: getLocalizedUrl(`/collectibles/${source.collectible.slug}/scans`), href: getLocalizedUrl(`/collectibles/${source.collectible.slug}/scans`),
typeLabel: t("global.sources.typeLabel.scans"), typeLabel: t("global.sources.typeLabel.scans"),
label: formatInlineTitle(getLocalizedMatch(source.collectible.translations)), label: formatInlineTitle(translation),
lang: translation.language, lang: translation.language,
}; };
} }
@ -325,7 +325,7 @@ export const getI18n = async (locale: string) => {
return { return {
href: getLocalizedUrl(`/collectibles/${source.collectible.slug}/gallery`), href: getLocalizedUrl(`/collectibles/${source.collectible.slug}/gallery`),
typeLabel: t("global.sources.typeLabel.gallery"), typeLabel: t("global.sources.typeLabel.gallery"),
label: formatInlineTitle(getLocalizedMatch(source.collectible.translations)), label: formatInlineTitle(translation),
lang: translation.language, lang: translation.language,
}; };
} }

View File

@ -1,9 +1,9 @@
--- ---
import type { EndpointImage } from "src/shared/payload/payload-sdk"; import type { EndpointPayloadImage } from "src/shared/payload/payload-sdk";
import { sizesForGridLayout, sizesToSrcset } from "src/utils/img"; import { sizesForGridLayout, sizesToSrcset } from "src/utils/img";
interface Props { interface Props {
img?: { light: EndpointImage; dark: EndpointImage } | undefined; img?: { light: EndpointPayloadImage; dark: EndpointPayloadImage } | undefined;
name: string; name: string;
href: string; href: string;
} }

View File

@ -14,7 +14,7 @@ const { getLocalizedUrl, getLocalizedMatch } = await getI18n(Astro.locals.curren
img={ img={
darkThumbnail && lightThumbnail ? { dark: darkThumbnail, light: lightThumbnail } : undefined darkThumbnail && lightThumbnail ? { dark: darkThumbnail, light: lightThumbnail } : undefined
} }
name={getLocalizedMatch(translations).name} name={getLocalizedMatch(translations).title}
href={getLocalizedUrl(`/folders/${slug}`)} href={getLocalizedUrl(`/folders/${slug}`)}
/> />
)) ))

View File

@ -1,13 +1,13 @@
--- ---
import type { import type {
EndpointImage, EndpointImage,
EndpointMediaThumbnail, EndpointPayloadImage,
EndpointScanImage, EndpointScanImage,
} from "src/shared/payload/payload-sdk"; } from "src/shared/payload/payload-sdk";
import { sizesToSrcset } from "src/utils/img"; import { sizesToSrcset } from "src/utils/img";
interface Props { interface Props {
image: EndpointImage | EndpointScanImage | EndpointMediaThumbnail; image: EndpointImage | EndpointScanImage | EndpointPayloadImage;
title: string; title: string;
subtitle: string; subtitle: string;
href: string; href: string;

View File

@ -17,7 +17,7 @@ if (scanPage instanceof Response) {
return scanPage; return scanPage;
} }
const { parentPages, previousIndex, nextIndex, image, translations, thumbnail } = scanPage; const { parentPages, previousIndex, nextIndex, image, translations } = scanPage;
const translation = getLocalizedMatch(translations); const translation = getLocalizedMatch(translations);
--- ---
@ -27,7 +27,6 @@ const translation = getLocalizedMatch(translations);
openGraph={{ openGraph={{
title: `${formatInlineTitle(translation)} (${index})`, title: `${formatInlineTitle(translation)} (${index})`,
description: translation.description && formatRichTextToString(translation.description), description: translation.description && formatRichTextToString(translation.description),
thumbnail,
}} }}
parentPages={parentPages}> parentPages={parentPages}>
<Lightbox <Lightbox

View File

@ -30,12 +30,12 @@ const meta = getLocalizedMatch(folder.translations);
<AppLayout <AppLayout
openGraph={{ openGraph={{
title: meta.name, title: meta.title,
description: meta.description && formatRichTextToString(meta.description), description: meta.description && formatRichTextToString(meta.description),
}} }}
parentPages={folder.parentPages} parentPages={folder.parentPages}
class="app"> class="app">
<AppLayoutTitle title={meta.name} lang={meta.language} /> <AppLayoutTitle title={meta.title} lang={meta.language} />
{meta.description && <RichText content={meta.description} context={{ lang: meta.language }} />} {meta.description && <RichText content={meta.description} context={{ lang: meta.language }} />}
<div id="main" class:list={{ complex: folder.sections.type === "multiple" }}> <div id="main" class:list={{ complex: folder.sections.type === "multiple" }}>

View File

@ -1,12 +1,12 @@
--- ---
import type { EndpointFolder } from "src/shared/payload/payload-sdk"; import type { EndpointFolderPreview } from "src/shared/payload/payload-sdk";
import FolderCard from "./FolderCard.astro"; import FolderCard from "./FolderCard.astro";
import { getI18n } from "src/i18n/i18n"; import { getI18n } from "src/i18n/i18n";
interface Props { interface Props {
title?: string | undefined; title?: string | undefined;
lang?: string | undefined; lang?: string | undefined;
folders: EndpointFolder[]; folders: EndpointFolderPreview[];
} }
const { title, folders, lang } = Astro.props; const { title, folders, lang } = Astro.props;
@ -27,10 +27,10 @@ const { getLocalizedUrl, getLocalizedMatch } = await getI18n(Astro.locals.curren
<section> <section>
{ {
folders.map(({ slug, translations, icon }) => { folders.map(({ slug, translations, icon }) => {
const { name, language } = getLocalizedMatch(translations); const { title, language } = getLocalizedMatch(translations);
return ( return (
<FolderCard <FolderCard
title={name} title={title}
lang={language} lang={language}
icon={icon} icon={icon}
href={getLocalizedUrl(`/folders/${slug}`)} href={getLocalizedUrl(`/folders/${slug}`)}

View File

@ -1,177 +1,177 @@
{ {
"disclaimer": "Usage subject to terms: https://openexchangerates.org/terms", "disclaimer": "Usage subject to terms: https://openexchangerates.org/terms",
"license": "https://openexchangerates.org/license", "license": "https://openexchangerates.org/license",
"timestamp": 1717740000, "timestamp": 1718449213,
"base": "USD", "base": "USD",
"rates": { "rates": {
"AED": 3.673, "AED": 3.673,
"AFN": 70.453638, "AFN": 70.629925,
"ALL": 91.912021, "ALL": 93.766029,
"AMD": 387.678915, "AMD": 387.09398,
"ANG": 1.79986, "ANG": 1.79792,
"AOA": 854.407667, "AOA": 855.5,
"ARS": 898.5413, "ARS": 901.78997,
"AUD": 1.498617, "AUD": 1.513088,
"AWG": 1.8, "AWG": 1.80125,
"AZN": 1.7, "AZN": 1.7,
"BAM": 1.795869, "BAM": 1.825818,
"BBD": 2, "BBD": 2,
"BDT": 117.294372, "BDT": 117.237829,
"BGN": 1.79491, "BGN": 1.828515,
"BHD": 0.376872, "BHD": 0.376276,
"BIF": 2869.308172, "BIF": 2867.428126,
"BMD": 1, "BMD": 1,
"BND": 1.345362, "BND": 1.350399,
"BOB": 6.901365, "BOB": 6.893272,
"BRL": 5.258701, "BRL": 5.3773,
"BSD": 1, "BSD": 1,
"BTC": 0.000014026029, "BTC": 0.000015094941,
"BTN": 83.367902, "BTN": 83.342478,
"BWP": 13.755584, "BWP": 13.582319,
"BYN": 3.268278, "BYN": 3.264326,
"BZD": 2.013085, "BZD": 2.010911,
"CAD": 1.366955, "CAD": 1.37535,
"CDF": 2822.733026, "CDF": 2819.794327,
"CHF": 0.89004, "CHF": 0.89102,
"CLF": 0.032927, "CLF": 0.033781,
"CLP": 908.55, "CLP": 932.13,
"CNH": 7.255147, "CNH": 7.27105,
"CNY": 7.2447, "CNY": 7.2548,
"COP": 3927.880338, "COP": 4140.0662,
"CRC": 527.874933, "CRC": 525.947274,
"CUC": 1, "CUC": 1,
"CUP": 25.75, "CUP": 25.75,
"CVE": 101.249236, "CVE": 102.825557,
"CZK": 22.552099, "CZK": 23.0983,
"DJF": 177.811501, "DJF": 177.628631,
"DKK": 6.849959, "DKK": 6.9657,
"DOP": 59.242392, "DOP": 59.234388,
"DZD": 134.471532, "DZD": 134.823,
"EGP": 47.5129, "EGP": 47.71,
"ERN": 15, "ERN": 15,
"ETB": 57.42215, "ETB": 57.057587,
"EUR": 0.918217, "EUR": 0.933053,
"FJD": 2.25895, "FJD": 2.2387,
"FKP": 0.782189, "FKP": 0.789079,
"GBP": 0.782189, "GBP": 0.789079,
"GEL": 2.785, "GEL": 2.87,
"GGP": 0.782189, "GGP": 0.789079,
"GHS": 14.880927, "GHS": 15.01562,
"GIP": 0.782189, "GIP": 0.789079,
"GMD": 67.775, "GMD": 67.75,
"GNF": 8600.013522, "GNF": 8588.587525,
"GTQ": 7.76001, "GTQ": 7.749335,
"GYD": 209.061081, "GYD": 208.737801,
"HKD": 7.809645, "HKD": 7.81055,
"HNL": 24.673005, "HNL": 24.65706,
"HRK": 6.918151, "HRK": 7.03975,
"HTG": 132.552876, "HTG": 132.335527,
"HUF": 358.085123, "HUF": 372.07,
"IDR": 16216.760923, "IDR": 16486.5,
"ILS": 3.720825, "ILS": 3.7242,
"IMP": 0.782189, "IMP": 0.789079,
"INR": 83.458757, "INR": 83.55155,
"IQD": 1308.290714, "IQD": 1306.849431,
"IRR": 42100, "IRR": 42100,
"ISK": 137.46, "ISK": 139.040389,
"JEP": 0.782189, "JEP": 0.789079,
"JMD": 155.295453, "JMD": 155.257148,
"JOD": 0.7088, "JOD": 0.7089,
"JPY": 155.5174, "JPY": 157.42503042,
"KES": 130, "KES": 129.202198,
"KGS": 87.3013, "KGS": 87.1182,
"KHR": 4101.618815, "KHR": 4108.729824,
"KMF": 452.450119, "KMF": 457.499995,
"KPW": 900, "KPW": 900,
"KRW": 1367.937913, "KRW": 1383.27,
"KWD": 0.306384, "KWD": 0.306225,
"KYD": 0.832281, "KYD": 0.831445,
"KZT": 446.221602, "KZT": 451.01908,
"LAK": 21498.895118, "LAK": 21788.785264,
"LBP": 89418.618549, "LBP": 89337.02505,
"LKR": 302.314319, "LKR": 303.408359,
"LRD": 193.950039, "LRD": 193.537555,
"LSL": 18.953322, "LSL": 18.318086,
"LYD": 4.829787, "LYD": 4.83704,
"MAD": 9.877784, "MAD": 10.025552,
"MDL": 17.619678, "MDL": 17.730591,
"MGA": 4467.052458, "MGA": 4440.702811,
"MKD": 56.57657, "MKD": 57.457919,
"MMK": 2101.212378, "MMK": 2201.379322,
"MNT": 3450, "MNT": 3450,
"MOP": 8.033479, "MOP": 8.026577,
"MRU": 39.126423, "MRU": 39.295939,
"MUR": 46.32, "MUR": 46.775637,
"MVR": 15.4, "MVR": 15.41,
"MWK": 1731.539932, "MWK": 1729.752588,
"MXN": 17.987572, "MXN": 18.4648,
"MYR": 4.6955, "MYR": 4.719499,
"MZN": 63.92499, "MZN": 63.899991,
"NAD": 18.953497, "NAD": 18.318086,
"NGN": 1485.31, "NGN": 1495.5,
"NIO": 36.764809, "NIO": 36.723084,
"NOK": 10.558218, "NOK": 10.68245,
"NPR": 133.383523, "NPR": 133.348263,
"NZD": 1.613954, "NZD": 1.627075,
"OMR": 0.384963, "OMR": 0.384948,
"PAB": 1, "PAB": 1,
"PEN": 3.738103, "PEN": 3.770504,
"PGK": 3.887667, "PGK": 3.887723,
"PHP": 58.519502, "PHP": 58.700001,
"PKR": 278.529362, "PKR": 277.884288,
"PLN": 3.932408, "PLN": 4.092232,
"PYG": 7514.698541, "PYG": 7503.069605,
"QAR": 3.642917, "QAR": 3.638178,
"RON": 4.569, "RON": 4.653,
"RSD": 107.495, "RSD": 109.359,
"RUB": 89.173363, "RUB": 89.307513,
"RWF": 1298.427641, "RWF": 1308.992161,
"SAR": 3.750551, "SAR": 3.752179,
"SBD": 8.482503, "SBD": 8.4616,
"SCR": 13.845723, "SCR": 13.560479,
"SDG": 586, "SDG": 586,
"SEK": 10.38479, "SEK": 10.63185,
"SGD": 1.34481, "SGD": 1.3535,
"SHP": 0.782189, "SHP": 0.789079,
"SLL": 20969.5, "SLL": 20969.5,
"SOS": 570.753969, "SOS": 570.149738,
"SRD": 31.7645, "SRD": 31.572,
"SSP": 130.26, "SSP": 130.26,
"STD": 22281.8, "STD": 22281.8,
"STN": 22.496155, "STN": 22.847018,
"SVC": 8.738769, "SVC": 8.729426,
"SYP": 2512.53, "SYP": 2512.53,
"SZL": 18.948934, "SZL": 18.307455,
"THB": 36.351667, "THB": 36.630765,
"TJS": 10.696062, "TJS": 10.669464,
"TMT": 3.51, "TMT": 3.5,
"TND": 3.10175, "TND": 3.122488,
"TOP": 2.352606, "TOP": 2.35645,
"TRY": 32.310647, "TRY": 32.7375,
"TTD": 6.757172, "TTD": 6.779503,
"TWD": 32.282, "TWD": 32.3458,
"TZS": 2615, "TZS": 2619.02838,
"UAH": 40.094667, "UAH": 40.593838,
"UGX": 3788.628608, "UGX": 3705.886831,
"USD": 1, "USD": 1,
"UYU": 38.896466, "UYU": 39.291418,
"UZS": 12659.755435, "UZS": 12584.375498,
"VES": 36.442787, "VES": 36.372315,
"VND": 25422.651993, "VND": 25455.008685,
"VUV": 118.722, "VUV": 118.722,
"WST": 2.8, "WST": 2.8,
"XAF": 602.310759, "XAF": 612.042932,
"XAG": 0.03205488, "XAG": 0.03380837,
"XAU": 0.0004209, "XAU": 0.00042863,
"XCD": 2.70255, "XCD": 2.70255,
"XDR": 0.75467, "XDR": 0.756096,
"XOF": 602.310759, "XOF": 612.042932,
"XPD": 0.00108737, "XPD": 0.00113108,
"XPF": 109.572414, "XPF": 111.342892,
"XPT": 0.00099467, "XPT": 0.00104433,
"YER": 250.425029, "YER": 250.33747,
"ZAR": 18.932716, "ZAR": 18.35321,
"ZMW": 26.240618, "ZMW": 26.168747,
"ZWL": 322 "ZWL": 322
} }
} }

View File

@ -1334,17 +1334,17 @@ export interface RichTextUploadNode extends RichTextNode {
export interface RichTextUploadImageNode extends RichTextUploadNode { export interface RichTextUploadImageNode extends RichTextUploadNode {
relationTo: Collections.Images; relationTo: Collections.Images;
value: EndpointImage; value: EndpointImagePreview;
} }
export interface RichTextUploadVideoNode extends RichTextUploadNode { export interface RichTextUploadVideoNode extends RichTextUploadNode {
relationTo: Collections.Videos; relationTo: Collections.Videos;
value: EndpointVideo; value: EndpointVideoPreview;
} }
export interface RichTextUploadAudioNode extends RichTextUploadNode { export interface RichTextUploadAudioNode extends RichTextUploadNode {
relationTo: Collections.Audios; relationTo: Collections.Audios;
value: EndpointAudio; value: EndpointAudioPreview;
} }
export interface RichTextTextNode extends RichTextNode { export interface RichTextTextNode extends RichTextNode {
@ -1496,43 +1496,49 @@ export const isBlockLineBlock = (block: GenericBlock): block is LineBlock =>
////////////////// SDK ////////////////// ////////////////// SDK //////////////////
export type EndpointFolder = { export type EndpointFolderPreview = {
id: string;
slug: string; slug: string;
icon?: string; icon?: string;
translations: { translations: {
language: string; language: string;
name: string; title: string;
description?: RichTextContent;
}[]; }[];
};
export type EndpointFolder = EndpointFolderPreview & {
translations: (EndpointFolderPreview["translations"][number] & {
description?: RichTextContent;
})[];
sections: sections:
| { type: "single"; subfolders: EndpointFolder[] } | { type: "single"; subfolders: EndpointFolderPreview[] }
| { | {
type: "multiple"; type: "multiple";
sections: { sections: {
translations: { language: string; name: string }[]; translations: { language: string; name: string }[];
subfolders: EndpointFolder[]; subfolders: EndpointFolderPreview[];
}[]; }[];
}; };
files: ( files: (
| { | {
relationTo: Collections.Collectibles; relationTo: Collections.Collectibles;
value: EndpointCollectible; value: EndpointCollectiblePreview;
} }
| { | {
relationTo: Collections.Pages; relationTo: Collections.Pages;
value: EndpointPage; value: EndpointPagePreview;
} }
| { | {
relationTo: Collections.Images; relationTo: Collections.Images;
value: EndpointImage; value: EndpointImagePreview;
} }
| { | {
relationTo: Collections.Audios; relationTo: Collections.Audios;
value: EndpointAudio; value: EndpointAudioPreview;
} }
| { | {
relationTo: Collections.Videos; relationTo: Collections.Videos;
value: EndpointVideo; value: EndpointVideoPreview;
} }
)[]; )[];
parentPages: EndpointSource[]; parentPages: EndpointSource[];
@ -1540,14 +1546,14 @@ export type EndpointFolder = {
export type EndpointWebsiteConfig = { export type EndpointWebsiteConfig = {
home: { home: {
backgroundImage?: EndpointImage; backgroundImage?: EndpointPayloadImage;
folders: (EndpointFolder & { folders: (EndpointFolderPreview & {
lightThumbnail?: EndpointImage; lightThumbnail?: EndpointPayloadImage;
darkThumbnail?: EndpointImage; darkThumbnail?: EndpointPayloadImage;
})[]; })[];
}; };
timeline: { timeline: {
backgroundImage?: EndpointImage; backgroundImage?: EndpointPayloadImage;
breaks: number[]; breaks: number[];
eventCount: number; eventCount: number;
eras: { eras: {
@ -1556,13 +1562,16 @@ export type EndpointWebsiteConfig = {
name: string; name: string;
}[]; }[];
}; };
defaultOpenGraphImage?: EndpointImage; defaultOpenGraphImage?: EndpointPayloadImage;
}; };
export type EndpointRecorder = { export type EndpointRecorderPreview = {
id: string; id: string;
username: string; username: string;
avatar?: EndpointImage; };
export type EndpointRecorder = EndpointRecorderPreview & {
avatar?: EndpointPayloadImage;
translations: { translations: {
language: string; language: string;
biography: RichTextContent; biography: RichTextContent;
@ -1579,8 +1588,9 @@ export type EndpointWording = {
}; };
export type EndpointTag = { export type EndpointTag = {
id: string;
slug: string; slug: string;
page?: EndpointPage; page?: { slug: string };
translations: { translations: {
language: string; language: string;
name: string; name: string;
@ -1588,6 +1598,7 @@ export type EndpointTag = {
}; };
export type EndpointGenericAttribute = { export type EndpointGenericAttribute = {
id: string;
slug: string; slug: string;
icon: string; icon: string;
translations: { translations: {
@ -1617,6 +1628,7 @@ export type EndpointAttribute =
| EndpointTagsAttribute; | EndpointTagsAttribute;
export type EndpointRole = { export type EndpointRole = {
id: string;
icon: string; icon: string;
translations: { translations: {
language: string; language: string;
@ -1626,53 +1638,65 @@ export type EndpointRole = {
export type EndpointCredit = { export type EndpointCredit = {
role: EndpointRole; role: EndpointRole;
recorders: EndpointRecorder[]; recorders: EndpointRecorderPreview[];
}; };
export type EndpointPage = { export type EndpointPagePreview = {
id: string;
slug: string; slug: string;
thumbnail?: EndpointImage; thumbnail?: EndpointPayloadImage;
attributes: EndpointAttribute[]; attributes: EndpointAttribute[];
backgroundImage?: EndpointImage;
translations: { translations: {
language: string; language: string;
pretitle?: string; pretitle?: string;
title: string; title: string;
subtitle?: string; subtitle?: string;
}[];
updatedAt: string;
};
export type EndpointPage = EndpointPagePreview & {
backgroundImage?: EndpointPayloadImage;
translations: (EndpointPagePreview["translations"][number] & {
sourceLanguage: string; sourceLanguage: string;
summary?: RichTextContent; summary?: RichTextContent;
content: RichTextContent; content: RichTextContent;
credits: EndpointCredit[]; credits: EndpointCredit[];
toc: TableOfContentEntry[]; toc: TableOfContentEntry[];
}[]; })[];
createdAt: string; createdAt: string;
updatedAt: string; updatedBy?: EndpointRecorderPreview;
updatedBy?: EndpointRecorder;
parentPages: EndpointSource[]; parentPages: EndpointSource[];
}; };
export type EndpointCollectible = { export type EndpointCollectiblePreview = {
id: string;
slug: string; slug: string;
thumbnail?: EndpointImage; thumbnail?: EndpointPayloadImage;
translations: { translations: {
language: string; language: string;
pretitle?: string; pretitle?: string;
title: string; title: string;
subtitle?: string; subtitle?: string;
description?: RichTextContent;
}[]; }[];
attributes: EndpointAttribute[]; attributes: EndpointAttribute[];
releaseDate?: string; releaseDate?: string;
languages: string[]; languages: string[];
backgroundImage?: EndpointImage;
nature: CollectibleNature;
gallery?: { count: number; thumbnail: EndpointImage };
scans?: { count: number; thumbnail: EndpointScanImage };
urls: { url: string; label: string }[];
price?: { price?: {
amount: number; amount: number;
currency: string; currency: string;
}; };
};
export type EndpointCollectible = EndpointCollectiblePreview & {
translations: (EndpointCollectiblePreview["translations"][number] & {
description?: RichTextContent;
})[];
backgroundImage?: EndpointPayloadImage;
nature: CollectibleNature;
gallery?: { count: number; thumbnail: EndpointPayloadImage };
scans?: { count: number; thumbnail: EndpointPayloadImage };
urls: { url: string; label: string }[];
size?: { size?: {
width: number; width: number;
height: number; height: number;
@ -1684,20 +1708,20 @@ export type EndpointCollectible = {
bindingType?: CollectibleBindingTypes; bindingType?: CollectibleBindingTypes;
pageOrder?: CollectiblePageOrders; pageOrder?: CollectiblePageOrders;
}; };
subitems: EndpointCollectible[]; subitems: EndpointCollectiblePreview[];
contents: { contents: {
content: content:
| { | {
relationTo: Collections.Pages; relationTo: Collections.Pages;
value: EndpointPage; value: EndpointPagePreview;
} }
| { | {
relationTo: Collections.Audios; relationTo: Collections.Audios;
value: EndpointAudio; value: EndpointAudioPreview;
} }
| { | {
relationTo: Collections.Videos; relationTo: Collections.Videos;
value: EndpointVideo; value: EndpointVideoPreview;
} }
| { | {
relationTo: Collections.GenericContents; relationTo: Collections.GenericContents;
@ -1730,13 +1754,13 @@ export type EndpointCollectible = {
}[]; }[];
createdAt: string; createdAt: string;
updatedAt: string; updatedAt: string;
updatedBy?: EndpointRecorder; updatedBy?: EndpointRecorderPreview;
parentPages: EndpointSource[]; parentPages: EndpointSource[];
}; };
export type EndpointCollectibleScans = { export type EndpointCollectibleScans = {
slug: string; slug: string;
thumbnail?: EndpointImage; thumbnail?: EndpointPayloadImage;
translations: { translations: {
language: string; language: string;
pretitle?: string; pretitle?: string;
@ -1786,7 +1810,7 @@ export type EndpointCollectibleScans = {
export type EndpointCollectibleGallery = { export type EndpointCollectibleGallery = {
slug: string; slug: string;
thumbnail?: EndpointImage; thumbnail?: EndpointPayloadImage;
translations: { translations: {
language: string; language: string;
pretitle?: string; pretitle?: string;
@ -1794,13 +1818,12 @@ export type EndpointCollectibleGallery = {
subtitle?: string; subtitle?: string;
description?: RichTextContent; description?: RichTextContent;
}[]; }[];
images: EndpointImage[]; images: EndpointPayloadImage[];
parentPages: EndpointSource[]; parentPages: EndpointSource[];
}; };
export type EndpointCollectibleGalleryImage = { export type EndpointCollectibleGalleryImage = {
slug: string; slug: string;
thumbnail?: EndpointImage;
translations: { translations: {
language: string; language: string;
pretitle?: string; pretitle?: string;
@ -1816,7 +1839,6 @@ export type EndpointCollectibleGalleryImage = {
export type EndpointCollectibleScanPage = { export type EndpointCollectibleScanPage = {
slug: string; slug: string;
thumbnail?: EndpointImage;
translations: { translations: {
language: string; language: string;
pretitle?: string; pretitle?: string;
@ -1863,40 +1885,58 @@ export type EndpointChronologyEvent = {
}[]; }[];
}; };
export type EndpointSourcePreview = {
id: string;
slug: string;
translations: { language: string; pretitle?: string; title: string; subtitle?: string }[];
};
export type EndpointSource = export type EndpointSource =
| { type: "url"; url: string; label: string } | { type: "url"; url: string; label: string }
| { | {
type: "collectible"; type: "collectible";
collectible: EndpointCollectible; collectible: EndpointSourcePreview;
range?: range?:
| { type: "page"; page: number } | { type: "page"; page: number }
| { type: "timestamp"; timestamp: string } | { type: "timestamp"; timestamp: string }
| { type: "custom"; translations: { language: string; note: string }[] }; | { type: "custom"; translations: { language: string; note: string }[] };
} }
| { type: "page"; page: EndpointPage } | { type: "page"; page: EndpointSourcePreview }
| { type: "folder"; folder: EndpointFolder } | { type: "folder"; folder: EndpointSourcePreview }
| { type: "scans"; collectible: EndpointCollectible } | { type: "scans"; collectible: EndpointSourcePreview }
| { type: "gallery"; collectible: EndpointCollectible }; | { type: "gallery"; collectible: EndpointSourcePreview };
export type EndpointMedia = { export type EndpointMediaPreview = {
id: string; id: string;
url: string; url: string;
filename: string; filename: string;
mimeType: string; mimeType: string;
filesize: number;
updatedAt: string;
createdAt: string;
attributes: EndpointAttribute[]; attributes: EndpointAttribute[];
translations: { translations: {
language: string; language: string;
pretitle?: string; pretitle?: string;
title: string; title: string;
subtitle?: string; subtitle?: string;
description?: RichTextContent;
}[]; }[];
};
export type EndpointMedia = EndpointMediaPreview & {
filesize: number;
updatedAt: string;
createdAt: string;
translations: (EndpointMediaPreview["translations"][number] & {
description?: RichTextContent;
})[];
credits: EndpointCredit[]; credits: EndpointCredit[];
}; };
export type EndpointImagePreview = EndpointMediaPreview & {
width: number;
height: number;
sizes: PayloadImage[];
openGraph?: PayloadImage;
};
export type EndpointImage = EndpointMedia & { export type EndpointImage = EndpointMedia & {
width: number; width: number;
height: number; height: number;
@ -1904,13 +1944,27 @@ export type EndpointImage = EndpointMedia & {
openGraph?: PayloadImage; openGraph?: PayloadImage;
}; };
export type EndpointAudioPreview = EndpointMediaPreview & {
thumbnail?: EndpointPayloadImage;
duration: number;
};
export type EndpointAudio = EndpointMedia & { export type EndpointAudio = EndpointMedia & {
thumbnail?: EndpointMediaThumbnail; thumbnail?: EndpointPayloadImage;
duration: number;
};
export type EndpointVideoPreview = EndpointMediaPreview & {
thumbnail?: EndpointPayloadImage;
subtitles: {
language: string;
url: string;
}[];
duration: number; duration: number;
}; };
export type EndpointVideo = EndpointMedia & { export type EndpointVideo = EndpointMedia & {
thumbnail?: EndpointMediaThumbnail; thumbnail?: EndpointPayloadImage;
subtitles: { subtitles: {
language: string; language: string;
url: string; url: string;
@ -1930,12 +1984,13 @@ export type EndpointVideo = EndpointMedia & {
duration: number; duration: number;
}; };
export type EndpointMediaThumbnail = PayloadImage & { export type EndpointPayloadImage = PayloadImage & {
sizes: PayloadImage[]; sizes: PayloadImage[];
openGraph?: PayloadImage; openGraph?: PayloadImage;
}; };
export type PayloadMedia = { export type PayloadMedia = {
id: string;
url: string; url: string;
mimeType: string; mimeType: string;
filename: string; filename: string;
@ -1953,17 +2008,25 @@ type GetPayloadSDKParams = {
apiURL: string; apiURL: string;
email: string; email: string;
password: string; password: string;
cache: Cache; tokenCache?: {
}; set: (token: string, expirationTimestamp: number) => void;
get: () => string | undefined;
type Cache = { };
set: (token: string, expirationTimestamp: number) => void; responseCache?: {
get: () => string | undefined; set: (url: string, response: any) => void;
get: (url: string) => any | undefined;
};
}; };
const logResponse = (res: Response) => console.log(res.status, res.statusText, res.url); const logResponse = (res: Response) => console.log(res.status, res.statusText, res.url);
export const getPayloadSDK = ({ apiURL, email, password, cache }: GetPayloadSDKParams) => { export const getPayloadSDK = ({
apiURL,
email,
password,
tokenCache,
responseCache,
}: GetPayloadSDKParams) => {
const refreshToken = async () => { const refreshToken = async () => {
const loginUrl = payloadApiUrl(Collections.Recorders, "login"); const loginUrl = payloadApiUrl(Collections.Recorders, "login");
const loginResult = await fetch(loginUrl, { const loginResult = await fetch(loginUrl, {
@ -1981,72 +2044,75 @@ export const getPayloadSDK = ({ apiURL, email, password, cache }: GetPayloadSDKP
token: string; token: string;
exp: number; exp: number;
}; };
cache.set(token, exp); tokenCache?.set(token, exp);
return token; return token;
}; };
const payloadApiUrl = (collection: Collections, endpoint?: string, isGlobal?: boolean): string => const payloadApiUrl = (collection: Collections, endpoint?: string, isGlobal?: boolean): string =>
`${apiURL}/${isGlobal === undefined ? "" : "globals/"}${collection}${endpoint === undefined ? "" : `/${endpoint}`}`; `${apiURL}/${isGlobal === undefined ? "" : "globals/"}${collection}${endpoint === undefined ? "" : `/${endpoint}`}`;
const request = async (url: string): Promise<Response> => { const request = async (url: string): Promise<any> => {
const cachedResponse = responseCache?.get(url);
if (cachedResponse) {
return cachedResponse;
}
const result = await fetch(url, { const result = await fetch(url, {
headers: { headers: {
Authorization: `JWT ${cache.get() ?? (await refreshToken())}`, Authorization: `JWT ${tokenCache?.get() ?? (await refreshToken())}`,
}, },
}); });
logResponse(result); logResponse(result);
if (result.status !== 200) { if (!result.ok) {
throw new Error("Unhandled fetch error"); throw new Error("Unhandled fetch error");
} }
return result; const data = await result.json();
responseCache?.set(url, data);
return data;
}; };
return { return {
getConfig: async (): Promise<EndpointWebsiteConfig> => getConfig: async (): Promise<EndpointWebsiteConfig> =>
await (await request(payloadApiUrl(Collections.WebsiteConfig, `config`, true))).json(), await request(payloadApiUrl(Collections.WebsiteConfig, `config`, true)),
getFolder: async (slug: string): Promise<EndpointFolder> => getFolder: async (slug: string): Promise<EndpointFolder> =>
await (await request(payloadApiUrl(Collections.Folders, `slug/${slug}`))).json(), await request(payloadApiUrl(Collections.Folders, `slug/${slug}`)),
getLanguages: async (): Promise<Language[]> => getLanguages: async (): Promise<Language[]> =>
await (await request(payloadApiUrl(Collections.Languages, `all`))).json(), await request(payloadApiUrl(Collections.Languages, `all`)),
getCurrencies: async (): Promise<Currency[]> => getCurrencies: async (): Promise<Currency[]> =>
await (await request(payloadApiUrl(Collections.Currencies, `all`))).json(), await request(payloadApiUrl(Collections.Currencies, `all`)),
getWordings: async (): Promise<EndpointWording[]> => getWordings: async (): Promise<EndpointWording[]> =>
await (await request(payloadApiUrl(Collections.Wordings, `all`))).json(), await request(payloadApiUrl(Collections.Wordings, `all`)),
getPage: async (slug: string): Promise<EndpointPage> => getPage: async (slug: string): Promise<EndpointPage> =>
await (await request(payloadApiUrl(Collections.Pages, `slug/${slug}`))).json(), await request(payloadApiUrl(Collections.Pages, `slug/${slug}`)),
getCollectible: async (slug: string): Promise<EndpointCollectible> => getCollectible: async (slug: string): Promise<EndpointCollectible> =>
await (await request(payloadApiUrl(Collections.Collectibles, `slug/${slug}`))).json(), await request(payloadApiUrl(Collections.Collectibles, `slug/${slug}`)),
getCollectibleScans: async (slug: string): Promise<EndpointCollectibleScans> => getCollectibleScans: async (slug: string): Promise<EndpointCollectibleScans> =>
await (await request(payloadApiUrl(Collections.Collectibles, `slug/${slug}/scans`))).json(), await request(payloadApiUrl(Collections.Collectibles, `slug/${slug}/scans`)),
getCollectibleScanPage: async ( getCollectibleScanPage: async (
slug: string, slug: string,
index: string index: string
): Promise<EndpointCollectibleScanPage> => ): Promise<EndpointCollectibleScanPage> =>
await ( await request(payloadApiUrl(Collections.Collectibles, `slug/${slug}/scans/${index}`)),
await request(payloadApiUrl(Collections.Collectibles, `slug/${slug}/scans/${index}`))
).json(),
getCollectibleGallery: async (slug: string): Promise<EndpointCollectibleGallery> => getCollectibleGallery: async (slug: string): Promise<EndpointCollectibleGallery> =>
await (await request(payloadApiUrl(Collections.Collectibles, `slug/${slug}/gallery`))).json(), await request(payloadApiUrl(Collections.Collectibles, `slug/${slug}/gallery`)),
getCollectibleGalleryImage: async ( getCollectibleGalleryImage: async (
slug: string, slug: string,
index: string index: string
): Promise<EndpointCollectibleGalleryImage> => ): Promise<EndpointCollectibleGalleryImage> =>
await ( await request(payloadApiUrl(Collections.Collectibles, `slug/${slug}/gallery/${index}`)),
await request(payloadApiUrl(Collections.Collectibles, `slug/${slug}/gallery/${index}`))
).json(),
getChronologyEvents: async (): Promise<EndpointChronologyEvent[]> => getChronologyEvents: async (): Promise<EndpointChronologyEvent[]> =>
await (await request(payloadApiUrl(Collections.ChronologyEvents, `all`))).json(), await request(payloadApiUrl(Collections.ChronologyEvents, `all`)),
getChronologyEventByID: async (id: string): Promise<EndpointChronologyEvent> => getChronologyEventByID: async (id: string): Promise<EndpointChronologyEvent> =>
await (await request(payloadApiUrl(Collections.ChronologyEvents, `id/${id}`))).json(), await request(payloadApiUrl(Collections.ChronologyEvents, `id/${id}`)),
getImageByID: async (id: string): Promise<EndpointImage> => getImageByID: async (id: string): Promise<EndpointImage> =>
await (await request(payloadApiUrl(Collections.Images, `id/${id}`))).json(), await request(payloadApiUrl(Collections.Images, `id/${id}`)),
getAudioByID: async (id: string): Promise<EndpointAudio> => getAudioByID: async (id: string): Promise<EndpointAudio> =>
await (await request(payloadApiUrl(Collections.Audios, `id/${id}`))).json(), await request(payloadApiUrl(Collections.Audios, `id/${id}`)),
getVideoByID: async (id: string): Promise<EndpointVideo> => getVideoByID: async (id: string): Promise<EndpointVideo> =>
await (await request(payloadApiUrl(Collections.Videos, `id/${id}`))).json(), await request(payloadApiUrl(Collections.Videos, `id/${id}`)),
getRecorderByID: async (id: string): Promise<EndpointRecorder> => getRecorderByID: async (id: string): Promise<EndpointRecorder> =>
await (await request(payloadApiUrl(Collections.Recorders, `id/${id}`))).json(), await request(payloadApiUrl(Collections.Recorders, `id/${id}`)),
}; };
}; };

View File

@ -19,7 +19,7 @@ export const payload = getPayloadSDK({
apiURL: import.meta.env.PAYLOAD_API_URL, apiURL: import.meta.env.PAYLOAD_API_URL,
email: import.meta.env.PAYLOAD_USER, email: import.meta.env.PAYLOAD_USER,
password: import.meta.env.PAYLOAD_PASSWORD, password: import.meta.env.PAYLOAD_PASSWORD,
cache: { tokenCache: {
get: () => { get: () => {
const cachedToken = nodeCache.get<string>(TOKEN_KEY); const cachedToken = nodeCache.get<string>(TOKEN_KEY);
if (cachedToken !== undefined) { if (cachedToken !== undefined) {