diff --git a/src/collections/Folders/endpoints/getBySlugEndpoint.ts b/src/collections/Folders/endpoints/getBySlugEndpoint.ts index 4186815..7af4eb8 100644 --- a/src/collections/Folders/endpoints/getBySlugEndpoint.ts +++ b/src/collections/Folders/endpoints/getBySlugEndpoint.ts @@ -35,8 +35,6 @@ export const getBySlugEndpoint = createGetByEndpoint( return []; } switch (relationTo) { - case "contents": - return [{ relationTo, value }]; case "library-items": return [{ relationTo, value }]; case "pages": diff --git a/src/endpoints/createGetByEndpoint.ts b/src/endpoints/createGetByEndpoint.ts index eba968b..3299881 100644 --- a/src/endpoints/createGetByEndpoint.ts +++ b/src/endpoints/createGetByEndpoint.ts @@ -1,8 +1,7 @@ import payload, { GeneratedTypes } from "payload"; -import { Collections } from "../constants"; import { CollectionEndpoint } from "../types/payload"; -export const createGetByEndpoint = ( +export const createGetByEndpoint = ( collection: C, attribute: string, handler: (doc: GeneratedTypes["collections"][C]) => Promise | R diff --git a/src/endpoints/createStrapiImportEndpoint.ts b/src/endpoints/createStrapiImportEndpoint.ts index 18313cc..5ee139b 100644 --- a/src/endpoints/createStrapiImportEndpoint.ts +++ b/src/endpoints/createStrapiImportEndpoint.ts @@ -1,7 +1,6 @@ import payload, { GeneratedTypes } from "payload"; import { BasePayload } from "payload/dist/payload"; import QueryString from "qs"; -import { Collections } from "../constants"; import { Recorder } from "../types/collections"; import { CollectionEndpoint } from "../types/payload"; import { isDefined } from "../utils/asserts"; @@ -39,7 +38,7 @@ type Params = { }; payload: { path?: string; - collection: Collections; + collection: keyof GeneratedTypes["collections"]; import?: (strapiObject: S, user: any) => Promise; convert?: ( strapiObject: S, diff --git a/src/hooks/beforeDuplicatePiping.ts b/src/hooks/beforeDuplicatePiping.ts index f59f888..b252de8 100644 --- a/src/hooks/beforeDuplicatePiping.ts +++ b/src/hooks/beforeDuplicatePiping.ts @@ -1,5 +1,6 @@ import { BeforeDuplicate } from "payload/types"; export const beforeDuplicatePiping = (hooks: BeforeDuplicate[]): BeforeDuplicate => { - return ({ data: initialData }) => hooks.reduce((data, hook) => hook({ data }), initialData); + return (initialArgs: Parameters["0"]) => + hooks.reduce((data, hook) => hook({ ...initialArgs, data }), initialArgs.data); }; diff --git a/src/utils/editor.ts b/src/utils/editor.ts index 1ba6ed9..fcdf858 100644 --- a/src/utils/editor.ts +++ b/src/utils/editor.ts @@ -20,7 +20,7 @@ import { UnderlineTextFeature, UnorderedListFeature, UploadFeature, - lexicalEditor + lexicalEditor, } from "@payloadcms/richtext-lexical"; import { Block, RichTextAdapter } from "payload/types"; @@ -53,7 +53,7 @@ export const createEditor = ({ if (blocks.length > 0) enabledFeatures.push(BlocksFeature({ blocks })); if (headings) enabledFeatures.push(ParagraphFeature(), HeadingFeature({})); if (debugs) enabledFeatures.push(TreeViewFeature()); - if (images) enabledFeatures.push(UploadFeature({ collections: [] })); + if (images) enabledFeatures.push(UploadFeature()); if (links) enabledFeatures.push(LinkFeature({})); if (relations) enabledFeatures.push(RelationshipFeature()); if (alignment) enabledFeatures.push(AlignFeature()); diff --git a/src/utils/localApi.ts b/src/utils/localApi.ts index 0c7a4bb..a00bdfe 100644 --- a/src/utils/localApi.ts +++ b/src/utils/localApi.ts @@ -1,4 +1,4 @@ -import payload from "payload"; +import payload, { GeneratedTypes } from "payload"; import { Collections, KeysTypes } from "../constants"; import { StrapiImage } from "../types/strapi"; import { isDefined } from "./asserts"; @@ -35,7 +35,7 @@ export const findRecorder = async (name: string): Promise => { type UploadStrapiImage = { image: StrapiImage; - collection: Collections; + collection: keyof GeneratedTypes["collections"]; }; export const uploadStrapiImage = async ({ diff --git a/src/utils/string.ts b/src/utils/string.ts index 0276e64..ad1c8b4 100644 --- a/src/utils/string.ts +++ b/src/utils/string.ts @@ -1,4 +1,5 @@ import tags from "language-tags"; +import { RichTextContent } from "../constants"; import { isUndefined } from "./asserts"; export const shortenEllipsis = (text: string, length: number): string => @@ -24,9 +25,7 @@ export const formatToPascalCase = (name: string): string => capitalize(formatToC export const plainTextToLexical = ( text: string -): { - [k: string]: unknown; -}[] => ({ +): RichTextContent => ({ root: { type: "root", format: "",