diff --git a/src/collections/Collectibles/Collectibles.ts b/src/collections/Collectibles/Collectibles.ts index 838831f..fc1194c 100644 --- a/src/collections/Collectibles/Collectibles.ts +++ b/src/collections/Collectibles/Collectibles.ts @@ -695,8 +695,10 @@ export const Collectibles = buildVersionedCollectionConfig({ labels: { singular: "Other", plural: "Others" }, fields: [ translatedFields({ - admin: { className: "no-label" }, name: "translations", + admin: { className: "no-label" }, + required: true, + minRows: 1, fields: [ { name: "note", diff --git a/src/collections/Recorders/Recorders.ts b/src/collections/Recorders/Recorders.ts index a45c5d9..274ea20 100644 --- a/src/collections/Recorders/Recorders.ts +++ b/src/collections/Recorders/Recorders.ts @@ -5,9 +5,7 @@ import { QuickFilters } from "../../components/QuickFilters"; import { CollectionGroups, Collections, RecordersRoles } from "../../constants"; import { imageField } from "../../fields/imageField/imageField"; import { rowField } from "../../fields/rowField/rowField"; -import { translatedFields } from "../../fields/translatedFields/translatedFields"; import { buildCollectionConfig } from "../../utils/collectionConfig"; -import { createEditor } from "../../utils/editor"; import { getAllEndpoint } from "./endpoints/getAllEndpoint"; import { importFromStrapi } from "./endpoints/importFromStrapi"; import { beforeLoginMustHaveAtLeastOneRole } from "./hooks/beforeLoginMustHaveAtLeastOneRole"; @@ -102,23 +100,6 @@ export const Recorders = buildCollectionConfig({ description: "List of language(s) that this recorder is familiar with", }, }, - translatedFields({ - name: fields.biographies, - interfaceName: "RecorderBiographies", - admin: { - // TODO: Reenable when we can use rich text as titles useAsTitle: fields.biography, - description: - "A short personal description about you or your involvement with this project or the franchise", - }, - fields: [ - { - name: fields.biography, - required: true, - type: "richText", - editor: createEditor({ inlines: true, lists: true, links: true }), - }, - ], - }), { name: fields.role, type: "select", diff --git a/src/collections/Recorders/endpoints/getAllEndpoint.ts b/src/collections/Recorders/endpoints/getAllEndpoint.ts index f13a852..9ec7dc5 100644 --- a/src/collections/Recorders/endpoints/getAllEndpoint.ts +++ b/src/collections/Recorders/endpoints/getAllEndpoint.ts @@ -2,7 +2,7 @@ import payload from "payload"; import { Collections } from "../../../constants"; import { EndpointRecorder } from "../../../sdk"; import { CollectionEndpoint } from "../../../types/payload"; -import { isPayloadArrayType, isPayloadType, isValidPayloadImage } from "../../../utils/asserts"; +import { isPayloadArrayType, isValidPayloadImage } from "../../../utils/asserts"; export const getAllEndpoint: CollectionEndpoint = { method: "get", @@ -27,16 +27,11 @@ export const getAllEndpoint: CollectionEndpoint = { ).docs; const result: EndpointRecorder[] = recorders.map( - ({ anonymize, id, username, avatar, biographies, languages }) => ({ + ({ anonymize, id, username, avatar, languages }) => ({ id, username: anonymize ? `Recorder#${id.substring(0, 5)}` : username, ...(isValidPayloadImage(avatar) ? { avatar } : {}), languages: isPayloadArrayType(languages) ? languages.map(({ id }) => id) : [], - biographies: - biographies?.map(({ biography, language }) => ({ - language: isPayloadType(language) ? language.id : language, - biography, - })) ?? [], }) ); diff --git a/src/collections/Recorders/endpoints/importFromStrapi.ts b/src/collections/Recorders/endpoints/importFromStrapi.ts index b895bed..7b9ef85 100644 --- a/src/collections/Recorders/endpoints/importFromStrapi.ts +++ b/src/collections/Recorders/endpoints/importFromStrapi.ts @@ -3,9 +3,8 @@ import { Collections } from "../../../constants"; import { createStrapiImportEndpoint } from "../../../endpoints/createStrapiImportEndpoint"; import { Recorder } from "../../../types/collections"; import { StrapiImage, StrapiLanguage } from "../../../types/strapi"; -import { isDefined, isUndefined } from "../../../utils/asserts"; +import { isDefined } from "../../../utils/asserts"; import { uploadStrapiImage } from "../../../utils/localApi"; -import { plainTextToLexical } from "../../../utils/string"; type StrapiRecorder = { username: string; @@ -25,7 +24,7 @@ export const importFromStrapi = createStrapiImportEndpoint({ }, payload: { collection: Collections.Recorders, - import: async ({ username, anonymize, anonymous_code, languages, avatar, bio: bios }, user) => { + import: async ({ username, anonymize, anonymous_code, languages, avatar }, user) => { const avatarId = await uploadStrapiImage({ collection: Collections.Images, image: avatar, @@ -58,15 +57,6 @@ export const importFromStrapi = createStrapiImportEndpoint({ anonymize, languages: languages.data?.map((language) => language.attributes.code), avatar: avatarId, - biographies: bios?.map(({ language, bio }) => { - if (isUndefined(language.data)) - throw new Error("A language is required for a Recorder biography"); - if (isUndefined(bio)) throw new Error("A bio is required for a Recorder biography"); - return { - language: language.data.attributes.code, - biography: plainTextToLexical(bio), - }; - }), email: `${anonymous_code}@accords-library.com`, password: process.env.RECORDER_DEFAULT_PASSWORD, }, diff --git a/src/fields/slugField/slugField.ts b/src/fields/slugField/slugField.ts index be7f7b6..252ed45 100644 --- a/src/fields/slugField/slugField.ts +++ b/src/fields/slugField/slugField.ts @@ -14,6 +14,7 @@ export const slugField = ({ admin, ...otherProps }: Props): TextField => ({ type: "text", required: true, unique: true, + index: true, validate: validateSlug, admin: { description: diff --git a/src/payload.config.ts b/src/payload.config.ts index 9ad591a..9caaa30 100644 --- a/src/payload.config.ts +++ b/src/payload.config.ts @@ -17,6 +17,8 @@ import { Recorders } from "./collections/Recorders/Recorders"; import { Tags } from "./collections/Tags/Tags"; import { TagsGroups } from "./collections/TagsGroups/TagsGroups"; import { Videos } from "./collections/Videos/Videos"; +import { VideosChannels } from "./collections/VideosChannels/VideosChannels"; +import { VideosSubtitles } from "./collections/VideosSubtitles/VideosSubtitles"; import { Wordings } from "./collections/Wordings/Wordings"; import { Icon } from "./components/Icon"; import { Logo } from "./components/Logo"; @@ -24,13 +26,6 @@ import { Collections } from "./constants"; import { ftpAdapter } from "./plugins/ftpAdapter"; import { createEditor } from "./utils/editor"; -if (!process.env.PAYLOAD_URI) throw new Error("Missing PAYLOAD_URI in .env"); -if (!process.env.MONGODB_URI) throw new Error("Missing MONGODB_URI in .env"); -if (!process.env.FTP_HOST) throw new Error("Missing FTP_HOST in .env"); -if (!process.env.FTP_USER) throw new Error("Missing FTP_USER in .env"); -if (!process.env.FTP_PASSWORD) throw new Error("Missing FTP_PASSWORD in .env"); -if (!process.env.FTP_BASE_URL) throw new Error("Missing FTP_BASE_URL in .env"); - export default buildConfig({ serverURL: process.env.PAYLOAD_URI, admin: { @@ -54,6 +49,8 @@ export default buildConfig({ Images, Videos, + VideosSubtitles, + VideosChannels, Tags, TagsGroups, @@ -64,7 +61,7 @@ export default buildConfig({ GenericContents, ], db: mongooseAdapter({ - url: process.env.MONGODB_URI, + url: process.env.MONGODB_URI ?? "", }), globals: [HomeFolders], telemetry: false, @@ -79,11 +76,11 @@ export default buildConfig({ collections: { [Collections.Videos]: { adapter: ftpAdapter({ - host: process.env.FTP_HOST, - user: process.env.FTP_USER, - password: process.env.FTP_PASSWORD, + host: process.env.FTP_HOST ?? "", + user: process.env.FTP_USER ?? "", + password: process.env.FTP_PASSWORD ?? "", secure: false, - endpoint: process.env.FTP_BASE_URL, + endpoint: process.env.FTP_BASE_URL ?? "", }), disableLocalStorage: true, disablePayloadAccessControl: true, diff --git a/src/sdk.ts b/src/sdk.ts index 65ec94c..882245d 100644 --- a/src/sdk.ts +++ b/src/sdk.ts @@ -139,10 +139,6 @@ export type EndpointRecorder = { username: string; avatar?: PayloadImage; languages: string[]; - biographies: { - language: string; - biography: RichTextContent; - }[]; }; export type EndpointWording = { diff --git a/src/types/collections.ts b/src/types/collections.ts index 2f38cfc..7ba0b59 100644 --- a/src/types/collections.ts +++ b/src/types/collections.ts @@ -6,31 +6,6 @@ * and re-run `payload generate:types` to regenerate this file. */ -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "RecorderBiographies". - */ -export type RecorderBiographies = - | { - language: string | Language; - biography: { - root: { - type: string; - children: { - type: string; - version: number; - [k: string]: unknown; - }[]; - direction: ("ltr" | "rtl") | null; - format: "left" | "start" | "center" | "right" | "end" | "justify" | ""; - indent: number; - version: number; - }; - [k: string]: unknown; - }; - id?: string | null; - }[] - | null; /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "CategoryTranslations". @@ -207,7 +182,6 @@ export interface Recorder { username: string; avatar?: string | Image | null; languages?: (string | Language)[] | null; - biographies?: RecorderBiographies; role?: ("Admin" | "Recorder" | "Api")[] | null; anonymize: boolean; email: string; @@ -426,8 +400,7 @@ export interface Collectible { blockType: "timeRange"; } | { - translations?: - | { + translations: { language: string | Language; note: { root: { @@ -445,8 +418,7 @@ export interface Collectible { [k: string]: unknown; }; id?: string | null; - }[] - | null; + }[]; id?: string | null; blockName?: string | null; blockType: "other"; diff --git a/src/utils/endpoints.ts b/src/utils/endpoints.ts index c785821..13b44ad 100644 --- a/src/utils/endpoints.ts +++ b/src/utils/endpoints.ts @@ -76,18 +76,12 @@ export const handleParentPages = ({ export const handleRecorder = ({ id, - biographies, languages, username, avatar, anonymize, }: Recorder): EndpointRecorder => ({ id, - biographies: - biographies?.map(({ biography, language }) => ({ - biography, - language: isPayloadType(language) ? language.id : language, - })) ?? [], languages: languages?.map((language) => (isPayloadType(language) ? language.id : language)) ?? [], username: anonymize ? `Recorder#${id.substring(0, 5)}` : username, ...(isValidPayloadImage(avatar) ? { avatar } : {}),