Fixed some tsc errors
This commit is contained in:
parent
7842f7e35f
commit
6cb23eb82e
|
@ -35,8 +35,6 @@ export const getBySlugEndpoint = createGetByEndpoint(
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
switch (relationTo) {
|
switch (relationTo) {
|
||||||
case "contents":
|
|
||||||
return [{ relationTo, value }];
|
|
||||||
case "library-items":
|
case "library-items":
|
||||||
return [{ relationTo, value }];
|
return [{ relationTo, value }];
|
||||||
case "pages":
|
case "pages":
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import payload, { GeneratedTypes } from "payload";
|
import payload, { GeneratedTypes } from "payload";
|
||||||
import { Collections } from "../constants";
|
|
||||||
import { CollectionEndpoint } from "../types/payload";
|
import { CollectionEndpoint } from "../types/payload";
|
||||||
|
|
||||||
export const createGetByEndpoint = <C extends Collections, R>(
|
export const createGetByEndpoint = <C extends keyof GeneratedTypes["collections"], R>(
|
||||||
collection: C,
|
collection: C,
|
||||||
attribute: string,
|
attribute: string,
|
||||||
handler: (doc: GeneratedTypes["collections"][C]) => Promise<R> | R
|
handler: (doc: GeneratedTypes["collections"][C]) => Promise<R> | R
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import payload, { GeneratedTypes } from "payload";
|
import payload, { GeneratedTypes } from "payload";
|
||||||
import { BasePayload } from "payload/dist/payload";
|
import { BasePayload } from "payload/dist/payload";
|
||||||
import QueryString from "qs";
|
import QueryString from "qs";
|
||||||
import { Collections } from "../constants";
|
|
||||||
import { Recorder } from "../types/collections";
|
import { Recorder } from "../types/collections";
|
||||||
import { CollectionEndpoint } from "../types/payload";
|
import { CollectionEndpoint } from "../types/payload";
|
||||||
import { isDefined } from "../utils/asserts";
|
import { isDefined } from "../utils/asserts";
|
||||||
|
@ -39,7 +38,7 @@ type Params<S> = {
|
||||||
};
|
};
|
||||||
payload: {
|
payload: {
|
||||||
path?: string;
|
path?: string;
|
||||||
collection: Collections;
|
collection: keyof GeneratedTypes["collections"];
|
||||||
import?: (strapiObject: S, user: any) => Promise<void>;
|
import?: (strapiObject: S, user: any) => Promise<void>;
|
||||||
convert?: (
|
convert?: (
|
||||||
strapiObject: S,
|
strapiObject: S,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { BeforeDuplicate } from "payload/types";
|
import { BeforeDuplicate } from "payload/types";
|
||||||
|
|
||||||
export const beforeDuplicatePiping = (hooks: BeforeDuplicate[]): BeforeDuplicate => {
|
export const beforeDuplicatePiping = (hooks: BeforeDuplicate[]): BeforeDuplicate => {
|
||||||
return ({ data: initialData }) => hooks.reduce((data, hook) => hook({ data }), initialData);
|
return (initialArgs: Parameters<BeforeDuplicate>["0"]) =>
|
||||||
|
hooks.reduce((data, hook) => hook({ ...initialArgs, data }), initialArgs.data);
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,7 +20,7 @@ import {
|
||||||
UnderlineTextFeature,
|
UnderlineTextFeature,
|
||||||
UnorderedListFeature,
|
UnorderedListFeature,
|
||||||
UploadFeature,
|
UploadFeature,
|
||||||
lexicalEditor
|
lexicalEditor,
|
||||||
} from "@payloadcms/richtext-lexical";
|
} from "@payloadcms/richtext-lexical";
|
||||||
import { Block, RichTextAdapter } from "payload/types";
|
import { Block, RichTextAdapter } from "payload/types";
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ export const createEditor = ({
|
||||||
if (blocks.length > 0) enabledFeatures.push(BlocksFeature({ blocks }));
|
if (blocks.length > 0) enabledFeatures.push(BlocksFeature({ blocks }));
|
||||||
if (headings) enabledFeatures.push(ParagraphFeature(), HeadingFeature({}));
|
if (headings) enabledFeatures.push(ParagraphFeature(), HeadingFeature({}));
|
||||||
if (debugs) enabledFeatures.push(TreeViewFeature());
|
if (debugs) enabledFeatures.push(TreeViewFeature());
|
||||||
if (images) enabledFeatures.push(UploadFeature({ collections: [] }));
|
if (images) enabledFeatures.push(UploadFeature());
|
||||||
if (links) enabledFeatures.push(LinkFeature({}));
|
if (links) enabledFeatures.push(LinkFeature({}));
|
||||||
if (relations) enabledFeatures.push(RelationshipFeature());
|
if (relations) enabledFeatures.push(RelationshipFeature());
|
||||||
if (alignment) enabledFeatures.push(AlignFeature());
|
if (alignment) enabledFeatures.push(AlignFeature());
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import payload from "payload";
|
import payload, { GeneratedTypes } from "payload";
|
||||||
import { Collections, KeysTypes } from "../constants";
|
import { Collections, KeysTypes } from "../constants";
|
||||||
import { StrapiImage } from "../types/strapi";
|
import { StrapiImage } from "../types/strapi";
|
||||||
import { isDefined } from "./asserts";
|
import { isDefined } from "./asserts";
|
||||||
|
@ -35,7 +35,7 @@ export const findRecorder = async (name: string): Promise<string> => {
|
||||||
|
|
||||||
type UploadStrapiImage = {
|
type UploadStrapiImage = {
|
||||||
image: StrapiImage;
|
image: StrapiImage;
|
||||||
collection: Collections;
|
collection: keyof GeneratedTypes["collections"];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const uploadStrapiImage = async ({
|
export const uploadStrapiImage = async ({
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import tags from "language-tags";
|
import tags from "language-tags";
|
||||||
|
import { RichTextContent } from "../constants";
|
||||||
import { isUndefined } from "./asserts";
|
import { isUndefined } from "./asserts";
|
||||||
|
|
||||||
export const shortenEllipsis = (text: string, length: number): string =>
|
export const shortenEllipsis = (text: string, length: number): string =>
|
||||||
|
@ -24,9 +25,7 @@ export const formatToPascalCase = (name: string): string => capitalize(formatToC
|
||||||
|
|
||||||
export const plainTextToLexical = (
|
export const plainTextToLexical = (
|
||||||
text: string
|
text: string
|
||||||
): {
|
): RichTextContent => ({
|
||||||
[k: string]: unknown;
|
|
||||||
}[] => ({
|
|
||||||
root: {
|
root: {
|
||||||
type: "root",
|
type: "root",
|
||||||
format: "",
|
format: "",
|
||||||
|
|
Loading…
Reference in New Issue