Add shared library + changed imports

This commit is contained in:
DrMint 2024-07-13 13:56:16 +02:00
parent 0d33354b7f
commit c707733bbc
84 changed files with 157 additions and 162 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "src/shared"]
path = src/shared
url = https://github.com/Accords-Library/shared-library.git

View File

@ -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"
}

View File

@ -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",

View File

@ -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",
});
}

View File

@ -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`;

View File

@ -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[] = [];

View File

@ -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`;

View File

@ -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`;

View File

@ -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<typeof Html>["openGraph"];

View File

@ -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;

View File

@ -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?:

View File

@ -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;

View File

@ -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[];

View File

@ -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;

View File

@ -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)[];

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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";

View File

@ -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)[];

View File

@ -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[];

View File

@ -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;

View File

@ -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;

View File

@ -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 {

View File

@ -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";

View File

@ -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 {

View File

@ -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 {

View File

@ -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;

View File

@ -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;

View File

@ -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 {

View File

@ -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";

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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 {

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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: {

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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[];

View File

@ -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;

View File

@ -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 {

View File

@ -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";

View File

@ -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: "/",

View File

@ -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);
}

View File

@ -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;
});

View File

@ -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 {

View File

@ -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");

View File

@ -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 {

View File

@ -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;

View File

@ -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;

View File

@ -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"];

View File

@ -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];

View File

@ -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"];

View File

@ -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 {

View File

@ -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<EndpointCollectible["pageInfo"]>;

View File

@ -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"];

View File

@ -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"];

View File

@ -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(

View File

@ -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 {

View File

@ -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!;

View File

@ -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";

View File

@ -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;

View File

@ -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;

View File

@ -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 {

View File

@ -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;

View File

@ -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[];

View File

@ -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 {

9
src/services.ts Normal file
View File

@ -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);

View File

@ -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 =>

View File

@ -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(", ");

View File

@ -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
);

View File

@ -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();