diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..2c28f1e --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "src/shared"] + path = src/shared + url = https://github.com/Accords-Library/shared-library.git diff --git a/.vscode/settings.json b/.vscode/settings.json index d720b65..b4fabdc 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,7 +4,7 @@ "typescript.preferences.importModuleSpecifier": "non-relative", "explorer.fileNesting.enabled": true, "explorer.fileNesting.patterns": { - "package.json": "package-lock.json, yarn.lock, pnpm-lock.yaml, bun.lockb, .ncurc.*, .nvmrc, *.config.cjs, *.config.js, *.config.ts, *config.json, .*ignore", + "package.json": ".git*, package-lock.json, yarn.lock, pnpm-lock.yaml, bun.lockb, .ncurc.*, .nvmrc, *.config.cjs, *.config.js, *.config.ts, *config.json, .*ignore", ".env": ".env.*", "README.md": "*.md" } diff --git a/package.json b/package.json index ddfcad6..7c9c191 100644 --- a/package.json +++ b/package.json @@ -8,10 +8,11 @@ "preview": "astro preview", "astro": "astro", "upgrade": "ncu", + "fetch-submodules": "git submodule update --recursive --remote", "script:download-currencies": "node --env-file=.env scripts/download-currencies.mjs", "script:download-wording-keys": "npm run scripts/download-wording-keys.ts", "prettier": "prettier --write --list-different --plugin=prettier-plugin-astro .", - "precommit": "npm run script:download-currencies && npm run script:download-wording-keys && npm run prettier && npm run astro check" + "precommit": "npm run fetch-submodules && npm run script:download-currencies && npm run script:download-wording-keys && npm run prettier && npm run astro check" }, "engines": { "npm": ">=10.0.0", diff --git a/scripts/download-payload-sdk.ts b/scripts/download-payload-sdk.ts deleted file mode 100644 index d262bb3..0000000 --- a/scripts/download-payload-sdk.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { writeFileSync } from "fs"; - -const PAYLOAD_FOLDER = `${process.cwd()}/src/shared/payload`; - -const sdk = await fetch(`${import.meta.env.PAYLOAD_API_URL}/sdk`); - -if (!sdk.ok) { - console.error("Failed to get the sdk", sdk.status, sdk.statusText); -} else { - const sdkFile = await sdk.text(); - writeFileSync(`${PAYLOAD_FOLDER}/payload-sdk.ts`, sdkFile, { - encoding: "utf-8", - }); -} diff --git a/scripts/download-wording-keys.ts b/scripts/download-wording-keys.ts index ac0f0ef..d315f31 100644 --- a/scripts/download-wording-keys.ts +++ b/scripts/download-wording-keys.ts @@ -1,5 +1,5 @@ import { writeFileSync } from "fs"; -import { PayloadSDK } from "src/shared/payload/payload-sdk"; +import { PayloadSDK } from "src/shared/payload/sdk"; const TRANSLATION_FOLDER = `${process.cwd()}/src/i18n`; diff --git a/src/cache/contextCache.ts b/src/cache/contextCache.ts index 5ee83ab..241fc7f 100644 --- a/src/cache/contextCache.ts +++ b/src/cache/contextCache.ts @@ -1,9 +1,9 @@ import type { + EndpointLanguage, EndpointWebsiteConfig, EndpointWording, - Language, - PayloadSDK, -} from "src/shared/payload/payload-sdk"; +} from "src/shared/payload/endpoint-types"; +import type { PayloadSDK } from "src/shared/payload/sdk"; import { getLogger } from "src/utils/logger"; export class ContextCache { @@ -12,7 +12,7 @@ export class ContextCache { constructor(private readonly payload: PayloadSDK) {} - languages: Language[] = []; + languages: EndpointLanguage[] = []; locales: string[] = []; currencies: string[] = []; wordings: EndpointWording[] = []; diff --git a/src/cache/dataCache.ts b/src/cache/dataCache.ts index 5547311..ddc11fc 100644 --- a/src/cache/dataCache.ts +++ b/src/cache/dataCache.ts @@ -1,7 +1,7 @@ -import type { PayloadSDK } from "src/shared/payload/payload-sdk"; import { getLogger } from "src/utils/logger"; import { writeFile, mkdir, readFile } from "fs/promises"; import { existsSync } from "fs"; +import type { PayloadSDK } from "src/shared/payload/sdk"; const ON_DISK_ROOT = `.cache/dataCache`; const ON_DISK_RESPONSE_CACHE_FILE = `${ON_DISK_ROOT}/responseCache.json`; diff --git a/src/cache/pageCache.ts b/src/cache/pageCache.ts index 43d94be..3031ef9 100644 --- a/src/cache/pageCache.ts +++ b/src/cache/pageCache.ts @@ -1,4 +1,3 @@ -import type { PayloadSDK } from "src/shared/payload/payload-sdk"; import { getLogger } from "src/utils/logger"; import { writeFile, mkdir, readFile } from "fs/promises"; import { existsSync } from "fs"; @@ -7,6 +6,7 @@ import { serializeResponse, type SerializableResponse, } from "src/utils/responses"; +import type { PayloadSDK } from "src/shared/payload/sdk"; const ON_DISK_ROOT = `.cache/pageCache`; const ON_DISK_RESPONSE_CACHE_FILE = `${ON_DISK_ROOT}/responseCache.json`; diff --git a/src/components/AppLayout/AppLayout.astro b/src/components/AppLayout/AppLayout.astro index a4c05cb..462202b 100644 --- a/src/components/AppLayout/AppLayout.astro +++ b/src/components/AppLayout/AppLayout.astro @@ -2,9 +2,10 @@ import Html from "./components/Html.astro"; import Topbar from "./components/Topbar/Topbar.astro"; import Footer from "./components/Footer.astro"; -import { getSDKEndpoint, type EndpointSource } from "src/shared/payload/payload-sdk"; import AppLayoutBackgroundImg from "./components/AppLayoutBackgroundImg.astro"; import type { ComponentProps } from "astro/types"; +import type { EndpointSource } from "src/shared/payload/endpoint-types"; +import { getSDKEndpoint } from "src/shared/payload/sdk"; interface Props { openGraph?: ComponentProps["openGraph"]; diff --git a/src/components/AppLayout/components/AppLayoutBackgroundImg.astro b/src/components/AppLayout/components/AppLayoutBackgroundImg.astro index 58202ac..291d85c 100644 --- a/src/components/AppLayout/components/AppLayoutBackgroundImg.astro +++ b/src/components/AppLayout/components/AppLayoutBackgroundImg.astro @@ -1,11 +1,11 @@ --- +import { getRandomId } from "src/utils/random"; +import { sizesToSrcset } from "src/utils/img"; import type { EndpointImage, EndpointPayloadImage, EndpointScanImage, -} from "src/shared/payload/payload-sdk"; -import { getRandomId } from "src/utils/random"; -import { sizesToSrcset } from "src/utils/img"; +} from "src/shared/payload/endpoint-types"; interface Props { img: EndpointImage | EndpointPayloadImage | EndpointScanImage; diff --git a/src/components/AppLayout/components/Html.astro b/src/components/AppLayout/components/Html.astro index 951fe99..9b2950d 100644 --- a/src/components/AppLayout/components/Html.astro +++ b/src/components/AppLayout/components/Html.astro @@ -1,14 +1,14 @@ --- import { UAParser } from "ua-parser-js"; import { getI18n } from "src/i18n/i18n"; +import { contextCache } from "src/utils/payload"; +import { PostProcessingTags } from "src/middleware/postProcessing"; import type { EndpointAudio, EndpointImage, EndpointPayloadImage, EndpointVideo, -} from "src/shared/payload/payload-sdk"; -import { contextCache } from "src/utils/payload"; -import { PostProcessingTags } from "src/middleware/postProcessing"; +} from "src/shared/payload/endpoint-types"; interface Props { openGraph?: diff --git a/src/components/AppLayout/components/Topbar/Topbar.astro b/src/components/AppLayout/components/Topbar/Topbar.astro index dfa932c..6bf3c5f 100644 --- a/src/components/AppLayout/components/Topbar/Topbar.astro +++ b/src/components/AppLayout/components/Topbar/Topbar.astro @@ -6,7 +6,7 @@ import LanguageSelector from "./components/LanguageSelector.astro"; import CurrencySelector from "./components/CurrencySelector.astro"; import ParentPagesButton from "./components/ParentPagesButton.astro"; import { getI18n } from "src/i18n/i18n"; -import type { EndpointSource } from "src/shared/payload/payload-sdk"; +import type { EndpointSource } from "src/shared/payload/endpoint-types"; interface Props { parentPages?: EndpointSource[] | undefined; diff --git a/src/components/AppLayout/components/Topbar/components/ParentPagesButton.astro b/src/components/AppLayout/components/Topbar/components/ParentPagesButton.astro index 865e143..5711ca2 100644 --- a/src/components/AppLayout/components/Topbar/components/ParentPagesButton.astro +++ b/src/components/AppLayout/components/Topbar/components/ParentPagesButton.astro @@ -3,8 +3,8 @@ import Tooltip from "components/Tooltip.astro"; import { Icon } from "astro-icon/components"; import { getI18n } from "src/i18n/i18n"; import ReturnToButton from "./ReturnToButton.astro"; -import type { EndpointSource } from "src/shared/payload/payload-sdk"; import SourceRow from "components/SourceRow.astro"; +import type { EndpointSource } from "src/shared/payload/endpoint-types"; interface Props { parentPages: EndpointSource[]; diff --git a/src/components/AppLayout/components/Topbar/components/ReturnToButton.astro b/src/components/AppLayout/components/Topbar/components/ReturnToButton.astro index 8da616a..af6a20d 100644 --- a/src/components/AppLayout/components/Topbar/components/ReturnToButton.astro +++ b/src/components/AppLayout/components/Topbar/components/ReturnToButton.astro @@ -1,7 +1,7 @@ --- import { Icon } from "astro-icon/components"; import { getI18n } from "src/i18n/i18n"; -import type { EndpointSource } from "src/shared/payload/payload-sdk"; +import type { EndpointSource } from "src/shared/payload/endpoint-types"; interface Props { parentPage: EndpointSource; diff --git a/src/components/Attributes.astro b/src/components/Attributes.astro index 881b1d7..d61a92a 100644 --- a/src/components/Attributes.astro +++ b/src/components/Attributes.astro @@ -1,9 +1,10 @@ --- -import { AttributeTypes, type EndpointAttribute } from "src/shared/payload/payload-sdk"; import Metadata from "./Metadata.astro"; import { getI18n } from "src/i18n/i18n"; import ErrorMessage from "./ErrorMessage.astro"; import type { Attribute } from "src/utils/attributes"; +import type { EndpointAttribute } from "src/shared/payload/endpoint-types"; +import { AttributeTypes } from "src/shared/payload/constants"; interface Props { attributes: (EndpointAttribute | Attribute)[]; diff --git a/src/components/AudioPlayer.astro b/src/components/AudioPlayer.astro index 25bc1fb..ae77fab 100644 --- a/src/components/AudioPlayer.astro +++ b/src/components/AudioPlayer.astro @@ -1,5 +1,5 @@ --- -import type { EndpointAudioPreview } from "src/shared/payload/payload-sdk"; +import type { EndpointAudioPreview } from "src/shared/payload/endpoint-types"; interface Props { audio: EndpointAudioPreview; diff --git a/src/components/Blocks/Block.astro b/src/components/Blocks/Block.astro index c9aba1e..36433ba 100644 --- a/src/components/Blocks/Block.astro +++ b/src/components/Blocks/Block.astro @@ -1,13 +1,8 @@ --- -import { - isBlockLineBlock, - type GenericBlock, - isBlockCueBlock, -} from "src/shared/payload/payload-sdk"; - import LineBlock from "./components/LineBlock.astro"; import CueBlock from "./components/CueBlock.astro"; import ErrorMessage from "components/ErrorMessage.astro"; +import { type GenericBlock, isBlockLineBlock, isBlockCueBlock } from "src/shared/payload/blocks"; interface Props { block: GenericBlock; diff --git a/src/components/Blocks/components/CueBlock.astro b/src/components/Blocks/components/CueBlock.astro index f733dd3..0645212 100644 --- a/src/components/Blocks/components/CueBlock.astro +++ b/src/components/Blocks/components/CueBlock.astro @@ -1,6 +1,6 @@ --- import RichText from "components/RichText/RichText.astro"; -import type { CueBlock } from "src/shared/payload/payload-sdk"; +import type { CueBlock } from "src/shared/payload/blocks"; interface Props { block: CueBlock; diff --git a/src/components/Blocks/components/LineBlock.astro b/src/components/Blocks/components/LineBlock.astro index ebc8c28..7144cbc 100644 --- a/src/components/Blocks/components/LineBlock.astro +++ b/src/components/Blocks/components/LineBlock.astro @@ -1,6 +1,6 @@ --- import RichText from "components/RichText/RichText.astro"; -import type { LineBlock } from "src/shared/payload/payload-sdk"; +import type { LineBlock } from "src/shared/payload/blocks"; interface Props { block: LineBlock; diff --git a/src/components/Credits.astro b/src/components/Credits.astro index 08f06dc..eb4a3ee 100644 --- a/src/components/Credits.astro +++ b/src/components/Credits.astro @@ -1,5 +1,5 @@ --- -import type { EndpointCredit } from "src/shared/payload/payload-sdk"; +import type { EndpointCredit } from "src/shared/payload/endpoint-types"; import Metadata from "./Metadata.astro"; import { getI18n } from "src/i18n/i18n"; diff --git a/src/components/InlineAttributes.astro b/src/components/InlineAttributes.astro index f3ba8c7..9e5359c 100644 --- a/src/components/InlineAttributes.astro +++ b/src/components/InlineAttributes.astro @@ -1,9 +1,10 @@ --- -import { AttributeTypes, type EndpointAttribute } from "src/shared/payload/payload-sdk"; import InlineMetadata from "./InlineMetadata.astro"; import { getI18n } from "src/i18n/i18n"; import ErrorMessage from "./ErrorMessage.astro"; import type { Attribute } from "src/utils/attributes"; +import { AttributeTypes } from "src/shared/payload/constants"; +import type { EndpointAttribute } from "src/shared/payload/endpoint-types"; interface Props { attributes: (EndpointAttribute | Attribute)[]; diff --git a/src/components/InlineCredits.astro b/src/components/InlineCredits.astro index 7621a25..fc5514f 100644 --- a/src/components/InlineCredits.astro +++ b/src/components/InlineCredits.astro @@ -1,7 +1,7 @@ --- -import type { EndpointCredit } from "src/shared/payload/payload-sdk"; import { getI18n } from "src/i18n/i18n"; import InlineMetadata from "./InlineMetadata.astro"; +import type { EndpointCredit } from "src/shared/payload/endpoint-types"; interface Props { credits: EndpointCredit[]; diff --git a/src/components/Lightbox.astro b/src/components/Lightbox.astro index 3a09f79..7c89ed5 100644 --- a/src/components/Lightbox.astro +++ b/src/components/Lightbox.astro @@ -1,11 +1,4 @@ --- -import { - type EndpointCredit, - type EndpointImage, - type EndpointPayloadImage, - type EndpointScanImage, - type RichTextContent, -} from "src/shared/payload/payload-sdk"; import Credits from "./Credits.astro"; import DownloadButton from "./DownloadButton.astro"; import AppLayoutTitle from "./AppLayout/components/AppLayoutTitle.astro"; @@ -14,6 +7,13 @@ import Attributes from "./Attributes.astro"; import { sizesToSrcset } from "src/utils/img"; import { Icon } from "astro-icon/components"; import RichText from "./RichText/RichText.astro"; +import type { + EndpointImage, + EndpointScanImage, + EndpointPayloadImage, + EndpointCredit, +} from "src/shared/payload/endpoint-types"; +import type { RichTextContent } from "src/shared/payload/rich-text"; interface Props { previousImageHref?: string | undefined; diff --git a/src/components/Previews/AudioPreview.astro b/src/components/Previews/AudioPreview.astro index 5426fd6..78e4b59 100644 --- a/src/components/Previews/AudioPreview.astro +++ b/src/components/Previews/AudioPreview.astro @@ -1,7 +1,7 @@ --- import GenericPreview from "components/Previews/GenericPreview.astro"; import { getI18n } from "src/i18n/i18n"; -import type { EndpointAudioPreview } from "src/shared/payload/payload-sdk"; +import type { EndpointAudioPreview } from "src/shared/payload/endpoint-types"; interface Props { audio: EndpointAudioPreview; diff --git a/src/components/Previews/ChronologyEventPreview.astro b/src/components/Previews/ChronologyEventPreview.astro index b578938..ec0aadc 100644 --- a/src/components/Previews/ChronologyEventPreview.astro +++ b/src/components/Previews/ChronologyEventPreview.astro @@ -1,7 +1,7 @@ --- import GenericPreview from "components/Previews/GenericPreview.astro"; import { getI18n } from "src/i18n/i18n"; -import type { EndpointChronologyEvent } from "src/shared/payload/payload-sdk"; +import type { EndpointChronologyEvent } from "src/shared/payload/endpoint-types"; import { formatRichTextToString, formatTimelineDateToId } from "src/utils/format"; interface Props { diff --git a/src/components/Previews/CollectiblePreview.astro b/src/components/Previews/CollectiblePreview.astro index f01dc15..820e48e 100644 --- a/src/components/Previews/CollectiblePreview.astro +++ b/src/components/Previews/CollectiblePreview.astro @@ -2,7 +2,7 @@ import GenericPreview from "components/Previews/GenericPreview.astro"; import { getI18n } from "src/i18n/i18n"; import { formatPriceForPostProcessing } from "src/middleware/postProcessing"; -import type { EndpointCollectiblePreview } from "src/shared/payload/payload-sdk"; +import type { EndpointCollectiblePreview } from "src/shared/payload/endpoint-types"; import type { Attribute } from "src/utils/attributes"; import { formatLocale } from "src/utils/format"; diff --git a/src/components/Previews/FilePreview.astro b/src/components/Previews/FilePreview.astro index 23ec6be..81123ff 100644 --- a/src/components/Previews/FilePreview.astro +++ b/src/components/Previews/FilePreview.astro @@ -1,7 +1,7 @@ --- import GenericPreview from "components/Previews/GenericPreview.astro"; import { getI18n } from "src/i18n/i18n"; -import type { EndpointFilePreview } from "src/shared/payload/payload-sdk"; +import type { EndpointFilePreview } from "src/shared/payload/endpoint-types"; import { getFileIcon } from "src/utils/attributes"; interface Props { diff --git a/src/components/Previews/FolderPreview.astro b/src/components/Previews/FolderPreview.astro index cf0837b..1ca1d2d 100644 --- a/src/components/Previews/FolderPreview.astro +++ b/src/components/Previews/FolderPreview.astro @@ -1,7 +1,7 @@ --- import GenericPreview from "components/Previews/GenericPreview.astro"; import { getI18n } from "src/i18n/i18n"; -import type { EndpointFolder } from "src/shared/payload/payload-sdk"; +import type { EndpointFolder } from "src/shared/payload/endpoint-types"; import type { Attribute } from "src/utils/attributes"; interface Props { diff --git a/src/components/Previews/GenericPreview.astro b/src/components/Previews/GenericPreview.astro index 8e211fb..9888cff 100644 --- a/src/components/Previews/GenericPreview.astro +++ b/src/components/Previews/GenericPreview.astro @@ -1,11 +1,4 @@ --- -import { - AttributeTypes, - type EndpointAttribute, - type EndpointImagePreview, - type EndpointPayloadImage, - type EndpointScanImage, -} from "src/shared/payload/payload-sdk"; import Card from "components/Card.astro"; import { Icon } from "astro-icon/components"; import type { ComponentProps } from "astro/types"; @@ -13,6 +6,13 @@ import { getI18n } from "src/i18n/i18n"; import InlineAttributes from "components/InlineAttributes.astro"; import { sizesToSrcset, sizesForGridLayout } from "src/utils/img"; import type { Attribute } from "src/utils/attributes"; +import type { + EndpointAttribute, + EndpointImagePreview, + EndpointPayloadImage, + EndpointScanImage, +} from "src/shared/payload/endpoint-types"; +import { AttributeTypes } from "src/shared/payload/constants"; interface Props { thumbnail?: EndpointImagePreview | EndpointPayloadImage | EndpointScanImage | undefined; diff --git a/src/components/Previews/ImagePreview.astro b/src/components/Previews/ImagePreview.astro index eb42094..af966ec 100644 --- a/src/components/Previews/ImagePreview.astro +++ b/src/components/Previews/ImagePreview.astro @@ -1,7 +1,7 @@ --- import GenericPreview from "components/Previews/GenericPreview.astro"; import { getI18n } from "src/i18n/i18n"; -import type { EndpointImagePreview } from "src/shared/payload/payload-sdk"; +import type { EndpointImagePreview } from "src/shared/payload/endpoint-types"; interface Props { image: EndpointImagePreview; diff --git a/src/components/Previews/PagePreview.astro b/src/components/Previews/PagePreview.astro index b210761..e3f988e 100644 --- a/src/components/Previews/PagePreview.astro +++ b/src/components/Previews/PagePreview.astro @@ -1,7 +1,7 @@ --- import GenericPreview from "components/Previews/GenericPreview.astro"; import { getI18n } from "src/i18n/i18n"; -import type { EndpointPagePreview } from "src/shared/payload/payload-sdk"; +import type { EndpointPagePreview } from "src/shared/payload/endpoint-types"; import type { Attribute } from "src/utils/attributes"; interface Props { diff --git a/src/components/Previews/RecorderPreview.astro b/src/components/Previews/RecorderPreview.astro index 2ce5d03..0fc0eae 100644 --- a/src/components/Previews/RecorderPreview.astro +++ b/src/components/Previews/RecorderPreview.astro @@ -1,7 +1,7 @@ --- import GenericPreview from "components/Previews/GenericPreview.astro"; import { getI18n } from "src/i18n/i18n"; -import type { EndpointRecorder } from "src/shared/payload/payload-sdk"; +import type { EndpointRecorder } from "src/shared/payload/endpoint-types"; import type { Attribute } from "src/utils/attributes"; import { formatLocale } from "src/utils/format"; diff --git a/src/components/Previews/VideoPreview.astro b/src/components/Previews/VideoPreview.astro index 2d44042..a499ebb 100644 --- a/src/components/Previews/VideoPreview.astro +++ b/src/components/Previews/VideoPreview.astro @@ -1,7 +1,7 @@ --- import GenericPreview from "components/Previews/GenericPreview.astro"; import { getI18n } from "src/i18n/i18n"; -import type { EndpointVideoPreview } from "src/shared/payload/payload-sdk"; +import type { EndpointVideoPreview } from "src/shared/payload/endpoint-types"; interface Props { video: EndpointVideoPreview; diff --git a/src/components/RichText/RichText.astro b/src/components/RichText/RichText.astro index 307715e..4cdb2dd 100644 --- a/src/components/RichText/RichText.astro +++ b/src/components/RichText/RichText.astro @@ -1,9 +1,9 @@ --- -import type { RichTextContent } from "src/shared/payload/payload-sdk"; import RTNode from "./components/RTNode.astro"; import RTProse from "./components/RTProse.astro"; import { type RichTextContext } from "src/utils/richText"; import ConditionalWrapper from "components/ConditionalWrapper.astro"; +import type { RichTextContent } from "src/shared/payload/rich-text"; interface Props { content: RichTextContent; diff --git a/src/components/RichText/components/RTBlock/RTBlock.astro b/src/components/RichText/components/RTBlock/RTBlock.astro index a2a4620..6165273 100644 --- a/src/components/RichText/components/RTBlock/RTBlock.astro +++ b/src/components/RichText/components/RTBlock/RTBlock.astro @@ -2,14 +2,14 @@ import type { RichTextContext } from "src/utils/richText"; import RTSection from "./components/RTSection.astro"; import RTTranscript from "./components/RTTranscript.astro"; -import { - isBlockNodeBreakBlock, - isBlockNodeSectionBlock, - isBlockNodeTranscriptBlock, - type RichTextBlockNode, -} from "src/shared/payload/payload-sdk"; import ErrorMessage from "components/ErrorMessage.astro"; import RTBreak from "./components/RTBreak.astro"; +import { + type RichTextBlockNode, + isBlockNodeSectionBlock, + isBlockNodeTranscriptBlock, + isBlockNodeBreakBlock, +} from "src/shared/payload/rich-text"; interface Props { node: RichTextBlockNode; diff --git a/src/components/RichText/components/RTBlock/components/RTBreak.astro b/src/components/RichText/components/RTBlock/components/RTBreak.astro index 0db64c7..9b5c14f 100644 --- a/src/components/RichText/components/RTBlock/components/RTBreak.astro +++ b/src/components/RichText/components/RTBlock/components/RTBreak.astro @@ -1,7 +1,8 @@ --- import type { RichTextContext } from "src/utils/richText"; -import { BreakBlockType, type RichTextBreakBlock } from "src/shared/payload/payload-sdk"; import ErrorMessage from "components/ErrorMessage.astro"; +import { BreakBlockType } from "src/shared/payload/constants"; +import type { RichTextBreakBlock } from "src/shared/payload/rich-text"; interface Props { node: RichTextBreakBlock; diff --git a/src/components/RichText/components/RTBlock/components/RTSection.astro b/src/components/RichText/components/RTBlock/components/RTSection.astro index adf66a1..83626f0 100644 --- a/src/components/RichText/components/RTBlock/components/RTSection.astro +++ b/src/components/RichText/components/RTBlock/components/RTSection.astro @@ -1,7 +1,7 @@ --- import HeaderTitle from "components/HeaderTitle.astro"; import RichText from "components/RichText/RichText.astro"; -import type { RichTextSectionBlock } from "src/shared/payload/payload-sdk"; +import type { RichTextSectionBlock } from "src/shared/payload/rich-text"; import type { RichTextContext } from "src/utils/richText"; interface Props { diff --git a/src/components/RichText/components/RTBlock/components/RTTranscript.astro b/src/components/RichText/components/RTBlock/components/RTTranscript.astro index c89f8e1..04cbd2c 100644 --- a/src/components/RichText/components/RTBlock/components/RTTranscript.astro +++ b/src/components/RichText/components/RTBlock/components/RTTranscript.astro @@ -1,7 +1,7 @@ --- import type { RichTextContext } from "src/utils/richText"; -import type { RichTextTranscriptBlock } from "src/shared/payload/payload-sdk"; import Block from "components/Blocks/Block.astro"; +import type { RichTextTranscriptBlock } from "src/shared/payload/rich-text"; interface Props { node: RichTextTranscriptBlock; diff --git a/src/components/RichText/components/RTLinebreak.astro b/src/components/RichText/components/RTLinebreak.astro index cfdbed2..8338bef 100644 --- a/src/components/RichText/components/RTLinebreak.astro +++ b/src/components/RichText/components/RTLinebreak.astro @@ -1,6 +1,6 @@ --- +import type { RichTextLinebreakNode } from "src/shared/payload/rich-text"; import type { RichTextContext } from "src/utils/richText"; -import type { RichTextLinebreakNode } from "src/shared/payload/payload-sdk"; interface Props { node: RichTextLinebreakNode; diff --git a/src/components/RichText/components/RTLink/RTLink.astro b/src/components/RichText/components/RTLink/RTLink.astro index 2b7c1f0..b768f48 100644 --- a/src/components/RichText/components/RTLink/RTLink.astro +++ b/src/components/RichText/components/RTLink/RTLink.astro @@ -3,12 +3,12 @@ import type { RichTextContext } from "src/utils/richText"; import RTNode from "../RTNode.astro"; import RTCustomLink from "./components/RTCustomLink.astro"; import RTInternalLink from "./components/RTInternalLink.astro"; +import ErrorMessage from "components/ErrorMessage.astro"; import { isLinkNodeCustomLinkNode, isLinkNodeInternalLinkNode, type RichTextLinkNode, -} from "src/shared/payload/payload-sdk"; -import ErrorMessage from "components/ErrorMessage.astro"; +} from "src/shared/payload/rich-text"; interface Props { node: RichTextLinkNode; diff --git a/src/components/RichText/components/RTLink/components/RTInternalLink.astro b/src/components/RichText/components/RTLink/components/RTInternalLink.astro index 0ee8723..af0f461 100644 --- a/src/components/RichText/components/RTLink/components/RTInternalLink.astro +++ b/src/components/RichText/components/RTLink/components/RTInternalLink.astro @@ -1,7 +1,7 @@ --- import ErrorMessage from "components/ErrorMessage.astro"; import { getI18n } from "src/i18n/i18n"; -import { Collections } from "src/shared/payload/payload-sdk"; +import { Collections } from "src/shared/payload/constants"; interface Props { doc: { diff --git a/src/components/RichText/components/RTList/RTList.astro b/src/components/RichText/components/RTList/RTList.astro index 7fb133a..ab19627 100644 --- a/src/components/RichText/components/RTList/RTList.astro +++ b/src/components/RichText/components/RTList/RTList.astro @@ -2,13 +2,13 @@ import type { RichTextContext } from "src/utils/richText"; import RTBasicListItem from "./components/RTBasicListItem.astro"; import RTCheckListItem from "./components/RTCheckListItem.astro"; +import ErrorMessage from "components/ErrorMessage.astro"; import { + type RichTextListNode, + isListNodeNumberListNode, isListNodeBulletListNode, isListNodeCheckListNode, - isListNodeNumberListNode, - type RichTextListNode, -} from "src/shared/payload/payload-sdk"; -import ErrorMessage from "components/ErrorMessage.astro"; +} from "src/shared/payload/rich-text"; interface Props { node: RichTextListNode; diff --git a/src/components/RichText/components/RTNode.astro b/src/components/RichText/components/RTNode.astro index b79211c..4850655 100644 --- a/src/components/RichText/components/RTNode.astro +++ b/src/components/RichText/components/RTNode.astro @@ -5,21 +5,21 @@ import RTText from "./RTText/RTText.astro"; import RTLink from "./RTLink/RTLink.astro"; import RTBlock from "./RTBlock/RTBlock.astro"; import type { RichTextContext } from "src/utils/richText"; -import { - isNodeBlockNode, - isNodeLinebreakNode, - isNodeLinkNode, - isNodeListNode, - isNodeParagraphNode, - isNodeTabNode, - isNodeTextNode, - isNodeUploadNode, - type RichTextNode, -} from "src/shared/payload/payload-sdk"; import RTTab from "./RTTab.astro"; import ErrorMessage from "components/ErrorMessage.astro"; import RTLinebreak from "./RTLinebreak.astro"; import RTUpload from "./RTUpload/RTUpload.astro"; +import { + type RichTextNode, + isNodeParagraphNode, + isNodeListNode, + isNodeTextNode, + isNodeLinebreakNode, + isNodeLinkNode, + isNodeBlockNode, + isNodeTabNode, + isNodeUploadNode, +} from "src/shared/payload/rich-text"; interface Props { node: RichTextNode; diff --git a/src/components/RichText/components/RTParagraph.astro b/src/components/RichText/components/RTParagraph.astro index ce5706c..827a912 100644 --- a/src/components/RichText/components/RTParagraph.astro +++ b/src/components/RichText/components/RTParagraph.astro @@ -1,7 +1,7 @@ --- import type { RichTextContext } from "src/utils/richText"; import RTNode from "./RTNode.astro"; -import type { RichTextParagraphNode } from "src/shared/payload/payload-sdk"; +import type { RichTextParagraphNode } from "src/shared/payload/rich-text"; interface Props { node: RichTextParagraphNode; diff --git a/src/components/RichText/components/RTText/RTText.astro b/src/components/RichText/components/RTText/RTText.astro index 28a333b..c6aa148 100644 --- a/src/components/RichText/components/RTText/RTText.astro +++ b/src/components/RichText/components/RTText/RTText.astro @@ -8,7 +8,7 @@ import RTSubscript from "./components/RTSubscript.astro"; import RTSuperscript from "./components/RTSuperscript.astro"; import RTInlineCode from "./components/RTInlineCode.astro"; import type { RichTextContext } from "src/utils/richText"; -import type { RichTextTextNode } from "src/shared/payload/payload-sdk"; +import type { RichTextTextNode } from "src/shared/payload/rich-text"; interface Props { node: RichTextTextNode; diff --git a/src/components/RichText/components/RTUpload/RTUpload.astro b/src/components/RichText/components/RTUpload/RTUpload.astro index 3297da7..75b858f 100644 --- a/src/components/RichText/components/RTUpload/RTUpload.astro +++ b/src/components/RichText/components/RTUpload/RTUpload.astro @@ -1,15 +1,15 @@ --- -import { - isUploadNodeAudioNode, - isUploadNodeImageNode, - isUploadNodeVideoNode, - type RichTextUploadNode, -} from "src/shared/payload/payload-sdk"; import type { RichTextContext } from "src/utils/richText"; import RTImage from "./components/RTImage.astro"; import ErrorMessage from "components/ErrorMessage.astro"; import RTAudio from "./components/RTAudio.astro"; import RTVideo from "./components/RTVideo.astro"; +import { + type RichTextUploadNode, + isUploadNodeImageNode, + isUploadNodeAudioNode, + isUploadNodeVideoNode, +} from "src/shared/payload/rich-text"; interface Props { node: RichTextUploadNode; diff --git a/src/components/RichText/components/RTUpload/components/RTAudio.astro b/src/components/RichText/components/RTUpload/components/RTAudio.astro index 7c9fb53..6f8407b 100644 --- a/src/components/RichText/components/RTUpload/components/RTAudio.astro +++ b/src/components/RichText/components/RTUpload/components/RTAudio.astro @@ -1,11 +1,11 @@ --- -import { type RichTextUploadAudioNode } from "src/shared/payload/payload-sdk"; import type { RichTextContext } from "src/utils/richText"; import AudioPlayer from "components/AudioPlayer.astro"; import HeaderTitle from "components/HeaderTitle.astro"; import { Icon } from "astro-icon/components"; import { getI18n } from "src/i18n/i18n"; import OpenMediaPageButton from "./OpenMediaPageButton.astro"; +import type { RichTextUploadAudioNode } from "src/shared/payload/rich-text"; interface Props { node: RichTextUploadAudioNode; diff --git a/src/components/RichText/components/RTUpload/components/RTImage.astro b/src/components/RichText/components/RTUpload/components/RTImage.astro index 3af5f06..5f87a1b 100644 --- a/src/components/RichText/components/RTUpload/components/RTImage.astro +++ b/src/components/RichText/components/RTUpload/components/RTImage.astro @@ -1,11 +1,11 @@ --- -import { type RichTextUploadImageNode } from "src/shared/payload/payload-sdk"; import type { RichTextContext } from "src/utils/richText"; import OpenMediaPageButton from "./OpenMediaPageButton.astro"; import { getI18n } from "src/i18n/i18n"; import HeaderTitle from "components/HeaderTitle.astro"; import { Icon } from "astro-icon/components"; import { sizesToSrcset } from "src/utils/img"; +import type { RichTextUploadImageNode } from "src/shared/payload/rich-text"; interface Props { node: RichTextUploadImageNode; diff --git a/src/components/RichText/components/RTUpload/components/RTVideo.astro b/src/components/RichText/components/RTUpload/components/RTVideo.astro index 1fedd4d..0929a92 100644 --- a/src/components/RichText/components/RTUpload/components/RTVideo.astro +++ b/src/components/RichText/components/RTUpload/components/RTVideo.astro @@ -1,11 +1,11 @@ --- -import { type RichTextUploadVideoNode } from "src/shared/payload/payload-sdk"; import type { RichTextContext } from "src/utils/richText"; import VideoPlayer from "components/VideoPlayer.astro"; import OpenMediaPageButton from "./OpenMediaPageButton.astro"; import { getI18n } from "src/i18n/i18n"; import HeaderTitle from "components/HeaderTitle.astro"; import { Icon } from "astro-icon/components"; +import type { RichTextUploadVideoNode } from "src/shared/payload/rich-text"; interface Props { node: RichTextUploadVideoNode; diff --git a/src/components/SourceRow.astro b/src/components/SourceRow.astro index 1c3c440..322b5a3 100644 --- a/src/components/SourceRow.astro +++ b/src/components/SourceRow.astro @@ -1,6 +1,6 @@ --- import { getI18n } from "src/i18n/i18n"; -import type { EndpointSource } from "src/shared/payload/payload-sdk"; +import type { EndpointSource } from "src/shared/payload/endpoint-types"; interface Props { source: EndpointSource; diff --git a/src/components/TableOfContent/TableOfContent.astro b/src/components/TableOfContent/TableOfContent.astro index 2ce6a00..f454c0a 100644 --- a/src/components/TableOfContent/TableOfContent.astro +++ b/src/components/TableOfContent/TableOfContent.astro @@ -1,8 +1,8 @@ --- -import type { TableOfContentEntry } from "src/shared/payload/payload-sdk"; import TableOfContentItem from "./components/TableOfContentItem.astro"; import { getI18n } from "src/i18n/i18n"; import TitleIcon from "components/TitleIcon.astro"; +import type { TableOfContentEntry } from "src/shared/payload/endpoint-types"; interface Props { toc: TableOfContentEntry[]; diff --git a/src/components/TableOfContent/components/TableOfContentItem.astro b/src/components/TableOfContent/components/TableOfContentItem.astro index 87f897e..bcdfe40 100644 --- a/src/components/TableOfContent/components/TableOfContentItem.astro +++ b/src/components/TableOfContent/components/TableOfContentItem.astro @@ -1,6 +1,6 @@ --- import { getI18n } from "src/i18n/i18n"; -import type { TableOfContentEntry } from "src/shared/payload/payload-sdk"; +import type { TableOfContentEntry } from "src/shared/payload/endpoint-types"; interface Props { entry: TableOfContentEntry; diff --git a/src/components/VideoPlayer.astro b/src/components/VideoPlayer.astro index ab36b78..558d150 100644 --- a/src/components/VideoPlayer.astro +++ b/src/components/VideoPlayer.astro @@ -1,5 +1,5 @@ --- -import type { EndpointVideoPreview } from "src/shared/payload/payload-sdk"; +import type { EndpointVideoPreview } from "src/shared/payload/endpoint-types"; import { formatLocale } from "src/utils/format"; interface Props { diff --git a/src/i18n/i18n.ts b/src/i18n/i18n.ts index a601956..92169a2 100644 --- a/src/i18n/i18n.ts +++ b/src/i18n/i18n.ts @@ -1,7 +1,7 @@ import type { WordingKey } from "src/i18n/wordings-keys"; -import type { EndpointChronologyEvent, EndpointSource } from "src/shared/payload/payload-sdk"; import { contextCache } from "src/utils/payload"; import { capitalize, formatInlineTitle } from "src/utils/format"; +import type { EndpointChronologyEvent, EndpointSource } from "src/shared/payload/endpoint-types"; export const defaultLocale = "en"; diff --git a/src/middleware/actionsHandling.ts b/src/middleware/actionsHandling.ts index 8c9b00d..112f2eb 100644 --- a/src/middleware/actionsHandling.ts +++ b/src/middleware/actionsHandling.ts @@ -8,7 +8,7 @@ import { isValidTheme, redirect, } from "src/middleware/utils"; -import { trackEvent } from "src/shared/analytics/analytics"; +import { analytics } from "src/services"; const ninetyDaysInSeconds = 60 * 60 * 24 * 90; @@ -21,7 +21,7 @@ export const actionsHandlingMiddleware = defineMiddleware(async ({ url, cookies : url.pathname; url.pathname = getAbsoluteLocaleUrl(language, pathnameWithoutLocale); url.searchParams.delete("action-lang"); - trackEvent("action-lang"); + analytics.trackEvent("action-lang"); cookies.set(CookieKeys.Language, language, { maxAge: ninetyDaysInSeconds, path: "/", @@ -32,7 +32,7 @@ export const actionsHandlingMiddleware = defineMiddleware(async ({ url, cookies const currency = url.searchParams.get("action-currency"); if (isValidCurrency(currency)) { - trackEvent("action-currency"); + analytics.trackEvent("action-currency"); cookies.set(CookieKeys.Currency, currency, { maxAge: ninetyDaysInSeconds, path: "/", @@ -44,7 +44,7 @@ export const actionsHandlingMiddleware = defineMiddleware(async ({ url, cookies const theme = url.searchParams.get("action-theme"); if (isValidTheme(theme)) { - trackEvent("action-theme"); + analytics.trackEvent("action-theme"); cookies.set(CookieKeys.Theme, theme, { maxAge: theme === "auto" ? 0 : ninetyDaysInSeconds, path: "/", diff --git a/src/middleware/languageNegotiation.ts b/src/middleware/languageNegotiation.ts index c33d880..2b911d2 100644 --- a/src/middleware/languageNegotiation.ts +++ b/src/middleware/languageNegotiation.ts @@ -1,5 +1,4 @@ import { defineMiddleware } from "astro:middleware"; -import { trackEvent } from "src/shared/analytics/analytics"; import { defaultLocale } from "src/i18n/i18n"; import { getAbsoluteLocaleUrl, @@ -8,6 +7,7 @@ import { getCurrentLocale, redirect, } from "src/middleware/utils"; +import { analytics } from "src/services"; const localeAgnosticPaths = ["/api/"]; @@ -23,14 +23,14 @@ export const localeNegotiationMiddleware = defineMiddleware(({ cookies, url, req if (!currentLocale) { const redirectURL = getAbsoluteLocaleUrl(bestMatchingLocale, url.pathname); - trackEvent("locale-redirect"); + analytics.trackEvent("locale-redirect"); return redirect(redirectURL); } if (currentLocale !== bestMatchingLocale) { const pathnameWithoutLocale = url.pathname.substring(currentLocale.length + 1); const redirectURL = getAbsoluteLocaleUrl(bestMatchingLocale, pathnameWithoutLocale); - trackEvent("locale-redirect"); + analytics.trackEvent("locale-redirect"); return redirect(redirectURL); } diff --git a/src/middleware/requestTracking.ts b/src/middleware/requestTracking.ts index d51bece..e784da7 100644 --- a/src/middleware/requestTracking.ts +++ b/src/middleware/requestTracking.ts @@ -1,9 +1,13 @@ import { defineMiddleware } from "astro/middleware"; -import { trackRequest } from "src/shared/analytics/analytics"; +import { analytics } from "src/services"; export const requestTrackingMiddleware = defineMiddleware(async (context, next) => { - const { request, params, locals, clientAddress } = context; + const { request, locals, clientAddress } = context; const response = await next(); - trackRequest(request, { params, locals, clientAddress }); + analytics.trackRequest(request, { + clientAddress, + locale: locals.currentLocale, + responseStatus: response.status, + }); return response; }); diff --git a/src/pages/[locale]/_components/LibraryCard.astro b/src/pages/[locale]/_components/LibraryCard.astro index f3b127d..b5f0553 100644 --- a/src/pages/[locale]/_components/LibraryCard.astro +++ b/src/pages/[locale]/_components/LibraryCard.astro @@ -1,5 +1,5 @@ --- -import type { EndpointPayloadImage } from "src/shared/payload/payload-sdk"; +import type { EndpointPayloadImage } from "src/shared/payload/endpoint-types"; import { sizesForGridLayout, sizesToSrcset } from "src/utils/img"; interface Props { diff --git a/src/pages/[locale]/api/hooks/collection-operation.ts b/src/pages/[locale]/api/hooks/collection-operation.ts index 6de6c8b..b6ce780 100644 --- a/src/pages/[locale]/api/hooks/collection-operation.ts +++ b/src/pages/[locale]/api/hooks/collection-operation.ts @@ -1,6 +1,7 @@ import type { APIRoute } from "astro"; +import { Collections } from "src/shared/payload/constants"; +import type { AfterOperationWebHookMessage } from "src/shared/payload/webhooks"; import { contextCache, dataCache } from "src/utils/payload.ts"; -import { Collections, type AfterOperationWebHookMessage } from "src/shared/payload/payload-sdk"; export const POST: APIRoute = async ({ request }) => { const auth = request.headers.get("Authorization"); diff --git a/src/pages/[locale]/api/pages/_components/PageCredits.astro b/src/pages/[locale]/api/pages/_components/PageCredits.astro index 7797c33..575cff1 100644 --- a/src/pages/[locale]/api/pages/_components/PageCredits.astro +++ b/src/pages/[locale]/api/pages/_components/PageCredits.astro @@ -4,7 +4,7 @@ import Credits from "components/Credits.astro"; import InlineCredits from "components/InlineCredits.astro"; import MasoActor from "components/Maso/MasoActor.astro"; import { getI18n } from "src/i18n/i18n"; -import type { EndpointCredit, EndpointPage } from "src/shared/payload/payload-sdk"; +import type { EndpointCredit, EndpointPage } from "src/shared/payload/endpoint-types"; import { formatLocale } from "src/utils/format"; interface Props { diff --git a/src/pages/[locale]/api/pages/partial.astro b/src/pages/[locale]/api/pages/partial.astro index 127ff76..d61f207 100644 --- a/src/pages/[locale]/api/pages/partial.astro +++ b/src/pages/[locale]/api/pages/partial.astro @@ -1,6 +1,5 @@ --- import RichText from "components/RichText/RichText.astro"; -import type { EndpointPage } from "src/shared/payload/payload-sdk"; import AppLayoutTitle from "components/AppLayout/components/AppLayoutTitle.astro"; import MasoTarget from "components/Maso/MasoTarget.astro"; import TableOfContent from "components/TableOfContent/TableOfContent.astro"; @@ -11,6 +10,7 @@ import type { Attribute } from "src/utils/attributes"; import { payload } from "src/utils/payload"; import { sizesToSrcset } from "src/utils/img"; import PageCredits from "./_components/PageCredits.astro"; +import type { EndpointPage } from "src/shared/payload/endpoint-types"; export const partial = true; diff --git a/src/pages/[locale]/api/timeline/partial.astro b/src/pages/[locale]/api/timeline/partial.astro index 78a9566..4bf4019 100644 --- a/src/pages/[locale]/api/timeline/partial.astro +++ b/src/pages/[locale]/api/timeline/partial.astro @@ -6,7 +6,7 @@ import TimelineLanguageOverride from "pages/[locale]/timeline/_components/Timeli import TimelineNote from "pages/[locale]/timeline/_components/TimelineNote.astro"; import TimelineSourcesButton from "pages/[locale]/timeline/_components/TimelineSourcesButton.astro"; import { getI18n } from "src/i18n/i18n"; -import type { EndpointChronologyEvent } from "src/shared/payload/payload-sdk"; +import type { EndpointChronologyEvent } from "src/shared/payload/endpoint-types"; import { payload } from "src/utils/payload"; export const partial = true; diff --git a/src/pages/[locale]/collectibles/[slug]/_components/AvailabilityInfo.astro b/src/pages/[locale]/collectibles/[slug]/_components/AvailabilityInfo.astro index 24f6728..3dde696 100644 --- a/src/pages/[locale]/collectibles/[slug]/_components/AvailabilityInfo.astro +++ b/src/pages/[locale]/collectibles/[slug]/_components/AvailabilityInfo.astro @@ -1,7 +1,7 @@ --- import TitleIcon from "components/TitleIcon.astro"; import { getI18n } from "src/i18n/i18n"; -import type { EndpointCollectible } from "src/shared/payload/payload-sdk"; +import type { EndpointCollectible } from "src/shared/payload/endpoint-types"; interface Props { urls: EndpointCollectible["urls"]; diff --git a/src/pages/[locale]/collectibles/[slug]/_components/ContentsSection/ContentRow.astro b/src/pages/[locale]/collectibles/[slug]/_components/ContentsSection/ContentRow.astro index bbaef28..f4f9fd5 100644 --- a/src/pages/[locale]/collectibles/[slug]/_components/ContentsSection/ContentRow.astro +++ b/src/pages/[locale]/collectibles/[slug]/_components/ContentsSection/ContentRow.astro @@ -2,12 +2,13 @@ import ErrorMessage from "components/ErrorMessage.astro"; import RichText from "components/RichText/RichText.astro"; import { getI18n } from "src/i18n/i18n"; -import { Collections, type EndpointCollectible } from "src/shared/payload/payload-sdk"; import Card from "components/Card.astro"; import AudioPlayer from "components/AudioPlayer.astro"; import VideoPlayer from "components/VideoPlayer.astro"; import InlineAttributes from "components/InlineAttributes.astro"; import { formatInlineTitle } from "src/utils/format"; +import { Collections } from "src/shared/payload/constants"; +import type { EndpointCollectible } from "src/shared/payload/endpoint-types"; interface Props { content: EndpointCollectible["contents"][number]; diff --git a/src/pages/[locale]/collectibles/[slug]/_components/ContentsSection/ContentsSection.astro b/src/pages/[locale]/collectibles/[slug]/_components/ContentsSection/ContentsSection.astro index 094ce5f..43d3bbf 100644 --- a/src/pages/[locale]/collectibles/[slug]/_components/ContentsSection/ContentsSection.astro +++ b/src/pages/[locale]/collectibles/[slug]/_components/ContentsSection/ContentsSection.astro @@ -1,8 +1,8 @@ --- -import type { EndpointCollectible } from "src/shared/payload/payload-sdk"; import ContentRow from "./ContentRow.astro"; import { getI18n } from "src/i18n/i18n"; import TitleIcon from "components/TitleIcon.astro"; +import type { EndpointCollectible } from "src/shared/payload/endpoint-types"; interface Props { contents: EndpointCollectible["contents"]; diff --git a/src/pages/[locale]/collectibles/[slug]/_components/ImageTile.astro b/src/pages/[locale]/collectibles/[slug]/_components/ImageTile.astro index ff90b05..aa47ab1 100644 --- a/src/pages/[locale]/collectibles/[slug]/_components/ImageTile.astro +++ b/src/pages/[locale]/collectibles/[slug]/_components/ImageTile.astro @@ -1,9 +1,9 @@ --- import type { EndpointImage, - EndpointPayloadImage, EndpointScanImage, -} from "src/shared/payload/payload-sdk"; + EndpointPayloadImage, +} from "src/shared/payload/endpoint-types"; import { sizesToSrcset } from "src/utils/img"; interface Props { diff --git a/src/pages/[locale]/collectibles/[slug]/_components/PageInfo.astro b/src/pages/[locale]/collectibles/[slug]/_components/PageInfo.astro index 5f7b46d..8a323b3 100644 --- a/src/pages/[locale]/collectibles/[slug]/_components/PageInfo.astro +++ b/src/pages/[locale]/collectibles/[slug]/_components/PageInfo.astro @@ -1,11 +1,8 @@ --- import TitleIcon from "components/TitleIcon.astro"; import { getI18n } from "src/i18n/i18n"; -import { - CollectibleBindingTypes, - CollectiblePageOrders, - type EndpointCollectible, -} from "src/shared/payload/payload-sdk"; +import { CollectibleBindingTypes, CollectiblePageOrders } from "src/shared/payload/constants"; +import type { EndpointCollectible } from "src/shared/payload/endpoint-types"; interface Props { pageInfo: NonNullable; diff --git a/src/pages/[locale]/collectibles/[slug]/_components/SubFilesSection.astro b/src/pages/[locale]/collectibles/[slug]/_components/SubFilesSection.astro index 49bfb9e..843cde0 100644 --- a/src/pages/[locale]/collectibles/[slug]/_components/SubFilesSection.astro +++ b/src/pages/[locale]/collectibles/[slug]/_components/SubFilesSection.astro @@ -2,7 +2,7 @@ import FilePreview from "components/Previews/FilePreview.astro"; import TitleIcon from "components/TitleIcon.astro"; import { getI18n } from "src/i18n/i18n"; -import type { EndpointCollectible } from "src/shared/payload/payload-sdk"; +import type { EndpointCollectible } from "src/shared/payload/endpoint-types"; interface Props { files: EndpointCollectible["files"]; diff --git a/src/pages/[locale]/collectibles/[slug]/_components/SubitemSection.astro b/src/pages/[locale]/collectibles/[slug]/_components/SubitemSection.astro index 840ceac..4858f50 100644 --- a/src/pages/[locale]/collectibles/[slug]/_components/SubitemSection.astro +++ b/src/pages/[locale]/collectibles/[slug]/_components/SubitemSection.astro @@ -2,7 +2,7 @@ import CollectiblePreview from "components/Previews/CollectiblePreview.astro"; import TitleIcon from "components/TitleIcon.astro"; import { getI18n } from "src/i18n/i18n"; -import type { EndpointCollectible } from "src/shared/payload/payload-sdk"; +import type { EndpointCollectible } from "src/shared/payload/endpoint-types"; interface Props { subitems: EndpointCollectible["subitems"]; diff --git a/src/pages/[locale]/collectibles/[slug]/index.astro b/src/pages/[locale]/collectibles/[slug]/index.astro index f403c11..18a4ff8 100644 --- a/src/pages/[locale]/collectibles/[slug]/index.astro +++ b/src/pages/[locale]/collectibles/[slug]/index.astro @@ -2,7 +2,6 @@ import AppLayout from "components/AppLayout/AppLayout.astro"; import AppLayoutTitle from "components/AppLayout/components/AppLayoutTitle.astro"; import { getI18n } from "src/i18n/i18n"; -import { CollectibleNature } from "src/shared/payload/payload-sdk"; import { fetchOr404 } from "src/utils/responses"; import ImageTile from "./_components/ImageTile.astro"; import SizeInfo from "./_components/SizeInfo.astro"; @@ -20,6 +19,7 @@ import { sizesToSrcset } from "src/utils/img"; import RichText from "components/RichText/RichText.astro"; import SubFilesSection from "./_components/SubFilesSection.astro"; import PriceInfo from "./_components/PriceInfo.astro"; +import { CollectibleNature } from "src/shared/payload/constants"; const slug = Astro.params.slug!; const { getLocalizedMatch, getLocalizedUrl, t, formatDate } = await getI18n( diff --git a/src/pages/[locale]/collectibles/[slug]/scans/_components/ScanPreview.astro b/src/pages/[locale]/collectibles/[slug]/scans/_components/ScanPreview.astro index 1ebe706..add383b 100644 --- a/src/pages/[locale]/collectibles/[slug]/scans/_components/ScanPreview.astro +++ b/src/pages/[locale]/collectibles/[slug]/scans/_components/ScanPreview.astro @@ -1,6 +1,6 @@ --- import { getI18n } from "src/i18n/i18n"; -import type { EndpointScanImage } from "src/shared/payload/payload-sdk"; +import type { EndpointScanImage } from "src/shared/payload/endpoint-types"; import { sizesForGridLayout, sizesToSrcset } from "src/utils/img"; interface Props { diff --git a/src/pages/[locale]/folders/[slug].astro b/src/pages/[locale]/folders/[slug].astro index ff0e0e2..d12b7bd 100644 --- a/src/pages/[locale]/folders/[slug].astro +++ b/src/pages/[locale]/folders/[slug].astro @@ -1,5 +1,4 @@ --- -import { Collections } from "src/shared/payload/payload-sdk"; import FoldersSection from "./_components/FoldersSection.astro"; import { fetchOr404 } from "src/utils/responses"; import ErrorMessage from "components/ErrorMessage.astro"; @@ -15,6 +14,7 @@ import AppLayoutTitle from "components/AppLayout/components/AppLayoutTitle.astro import { payload } from "src/utils/payload"; import RichText from "components/RichText/RichText.astro"; import FilePreview from "components/Previews/FilePreview.astro"; +import { Collections } from "src/shared/payload/constants"; const slug = Astro.params.slug!; diff --git a/src/pages/[locale]/folders/_components/FoldersSection.astro b/src/pages/[locale]/folders/_components/FoldersSection.astro index 13a208e..21412a5 100644 --- a/src/pages/[locale]/folders/_components/FoldersSection.astro +++ b/src/pages/[locale]/folders/_components/FoldersSection.astro @@ -1,5 +1,5 @@ --- -import type { EndpointFolderPreview } from "src/shared/payload/payload-sdk"; +import type { EndpointFolderPreview } from "src/shared/payload/endpoint-types"; import FolderCard from "./FolderCard.astro"; import { getI18n } from "src/i18n/i18n"; diff --git a/src/pages/[locale]/search/index.astro b/src/pages/[locale]/search/index.astro index 733d8a1..2814bda 100644 --- a/src/pages/[locale]/search/index.astro +++ b/src/pages/[locale]/search/index.astro @@ -7,8 +7,6 @@ import ImagePreview from "components/Previews/ImagePreview.astro"; import PagePreview from "components/Previews/PagePreview.astro"; import VideoPreview from "components/Previews/VideoPreview.astro"; import { getI18n } from "src/i18n/i18n"; -import { Collections } from "src/shared/payload/payload-sdk"; -import { meilisearch } from "src/utils/meilisearch"; import CollectiblePreview from "components/Previews/CollectiblePreview.astro"; import Button from "components/Button.astro"; import Paginator from "./_components/Paginator.astro"; @@ -17,6 +15,8 @@ import HomeTitle from "../_components/HomeTitle.astro"; import RecorderPreview from "components/Previews/RecorderPreview.astro"; import FolderPreview from "components/Previews/FolderPreview.astro"; import ChronologyEventPreview from "components/Previews/ChronologyEventPreview.astro"; +import { Collections } from "src/shared/payload/constants"; +import { meilisearch } from "src/services"; type State = { q: string; diff --git a/src/pages/[locale]/timeline/_components/TimelineEvent.astro b/src/pages/[locale]/timeline/_components/TimelineEvent.astro index 7d48fe4..724db1c 100644 --- a/src/pages/[locale]/timeline/_components/TimelineEvent.astro +++ b/src/pages/[locale]/timeline/_components/TimelineEvent.astro @@ -1,8 +1,8 @@ --- import { getI18n } from "src/i18n/i18n"; -import type { EndpointChronologyEvent } from "src/shared/payload/payload-sdk"; import TimelineEventPartial from "../../api/timeline/partial.astro"; import { formatTimelineDateToId } from "src/utils/format"; +import type { EndpointChronologyEvent } from "src/shared/payload/endpoint-types"; interface Props { event: EndpointChronologyEvent; diff --git a/src/pages/[locale]/timeline/_components/TimelineLanguageOverride.astro b/src/pages/[locale]/timeline/_components/TimelineLanguageOverride.astro index 39f753d..67462b8 100644 --- a/src/pages/[locale]/timeline/_components/TimelineLanguageOverride.astro +++ b/src/pages/[locale]/timeline/_components/TimelineLanguageOverride.astro @@ -4,7 +4,7 @@ import InlineCredits from "components/InlineCredits.astro"; import MasoActor from "components/Maso/MasoActor.astro"; import Tooltip from "components/Tooltip.astro"; import { getI18n } from "src/i18n/i18n"; -import type { EndpointCredit } from "src/shared/payload/payload-sdk"; +import type { EndpointCredit } from "src/shared/payload/endpoint-types"; import { formatLocale } from "src/utils/format"; interface Props { diff --git a/src/pages/[locale]/timeline/_components/TimelineNote.astro b/src/pages/[locale]/timeline/_components/TimelineNote.astro index 6f03114..a8729a8 100644 --- a/src/pages/[locale]/timeline/_components/TimelineNote.astro +++ b/src/pages/[locale]/timeline/_components/TimelineNote.astro @@ -3,7 +3,7 @@ import { Icon } from "astro-icon/components"; import RichText from "components/RichText/RichText.astro"; import Tooltip from "components/Tooltip.astro"; import { getI18n } from "src/i18n/i18n"; -import type { RichTextContent } from "src/shared/payload/payload-sdk"; +import type { RichTextContent } from "src/shared/payload/rich-text"; interface Props { notes: RichTextContent; diff --git a/src/pages/[locale]/timeline/_components/TimelineSourcesButton.astro b/src/pages/[locale]/timeline/_components/TimelineSourcesButton.astro index 9896b77..7121d0b 100644 --- a/src/pages/[locale]/timeline/_components/TimelineSourcesButton.astro +++ b/src/pages/[locale]/timeline/_components/TimelineSourcesButton.astro @@ -3,7 +3,7 @@ import { Icon } from "astro-icon/components"; import SourceRow from "components/SourceRow.astro"; import Tooltip from "components/Tooltip.astro"; import { getI18n } from "src/i18n/i18n"; -import type { EndpointSource } from "src/shared/payload/payload-sdk"; +import type { EndpointSource } from "src/shared/payload/endpoint-types"; interface Props { sources: EndpointSource[]; diff --git a/src/pages/[locale]/timeline/_components/TimelineYear.astro b/src/pages/[locale]/timeline/_components/TimelineYear.astro index 49ae785..1d86fd3 100644 --- a/src/pages/[locale]/timeline/_components/TimelineYear.astro +++ b/src/pages/[locale]/timeline/_components/TimelineYear.astro @@ -1,7 +1,7 @@ --- -import type { EndpointChronologyEvent } from "src/shared/payload/payload-sdk"; import TimelineEvent from "./TimelineEvent.astro"; import { getI18n } from "src/i18n/i18n"; +import type { EndpointChronologyEvent } from "src/shared/payload/endpoint-types"; import { contextCache } from "src/utils/payload"; interface Props { diff --git a/src/services.ts b/src/services.ts new file mode 100644 index 0000000..7bd7248 --- /dev/null +++ b/src/services.ts @@ -0,0 +1,9 @@ +import { AnalyticsSDK } from "src/shared/analytics/sdk"; +import { MeilisearchSDK } from "src/shared/meilisearch/sdk"; + +export const meilisearch = new MeilisearchSDK( + import.meta.env.MEILISEARCH_URL, + import.meta.env.MEILISEARCH_MASTER_KEY +); + +export const analytics = new AnalyticsSDK(import.meta.env.ANALYTICS_URL); diff --git a/src/utils/format.ts b/src/utils/format.ts index 4a17dbe..b5aebc6 100644 --- a/src/utils/format.ts +++ b/src/utils/format.ts @@ -1,12 +1,12 @@ +import type { EndpointChronologyEvent } from "src/shared/payload/endpoint-types"; import { isNodeLinkNode, isNodeListNode, isNodeParagraphNode, isNodeTextNode, - type EndpointChronologyEvent, type RichTextContent, type RichTextNode, -} from "src/shared/payload/payload-sdk"; +} from "src/shared/payload/rich-text"; import { contextCache } from "src/utils/payload"; export const formatLocale = (code: string): string => diff --git a/src/utils/img.ts b/src/utils/img.ts index ae64a8f..b16ce6d 100644 --- a/src/utils/img.ts +++ b/src/utils/img.ts @@ -1,4 +1,4 @@ -import type { PayloadImage } from "src/shared/payload/payload-sdk"; +import type { PayloadImage } from "src/shared/payload/endpoint-types"; export const sizesToSrcset = (sizes: PayloadImage[]): string => sizes.map(({ url, width }) => `${encodeURI(url)} ${width}w`).join(", "); diff --git a/src/utils/meilisearch.ts b/src/utils/meilisearch.ts deleted file mode 100644 index 16d62d0..0000000 --- a/src/utils/meilisearch.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Meilisearch } from "src/shared/meilisearch/meilisearch-sdk"; - -export const meilisearch = new Meilisearch( - import.meta.env.MEILISEARCH_URL, - import.meta.env.MEILISEARCH_MASTER_KEY -); diff --git a/src/utils/payload.ts b/src/utils/payload.ts index 0e3aacf..ce36b8f 100644 --- a/src/utils/payload.ts +++ b/src/utils/payload.ts @@ -2,7 +2,7 @@ import { ContextCache } from "src/cache/contextCache"; import { DataCache } from "src/cache/dataCache"; import { PageCache } from "src/cache/pageCache"; import { TokenCache } from "src/cache/tokenCache"; -import { PayloadSDK } from "src/shared/payload/payload-sdk"; +import { PayloadSDK } from "src/shared/payload/sdk"; const tokenCache = new TokenCache();