Adapt to new payload sdk changes
This commit is contained in:
parent
4639935eb8
commit
1e7654e976
|
@ -7,7 +7,7 @@ const sdk = await fetch(`${import.meta.env.PAYLOAD_API_URL}/sdk`);
|
||||||
if (!sdk.ok) {
|
if (!sdk.ok) {
|
||||||
console.error("Failed to get the sdk", sdk.status, sdk.statusText);
|
console.error("Failed to get the sdk", sdk.status, sdk.statusText);
|
||||||
} else {
|
} else {
|
||||||
const sdkFile = await sdk.text();
|
const sdkFile = (await sdk.text()).replaceAll("process.env.", "import.meta.env.");
|
||||||
writeFileSync(`${PAYLOAD_FOLDER}/payload-sdk.ts`, sdkFile, {
|
writeFileSync(`${PAYLOAD_FOLDER}/payload-sdk.ts`, sdkFile, {
|
||||||
encoding: "utf-8",
|
encoding: "utf-8",
|
||||||
});
|
});
|
||||||
|
|
|
@ -48,9 +48,6 @@ export interface Config {
|
||||||
pages: Page;
|
pages: Page;
|
||||||
'chronology-items': ChronologyItem;
|
'chronology-items': ChronologyItem;
|
||||||
'chronology-eras': ChronologyEra;
|
'chronology-eras': ChronologyEra;
|
||||||
weapons: Weapon;
|
|
||||||
'weapons-groups': WeaponsGroup;
|
|
||||||
'weapons-thumbnails': WeaponsThumbnail;
|
|
||||||
'recorders-thumbnails': RecordersThumbnail;
|
'recorders-thumbnails': RecordersThumbnail;
|
||||||
notes: Note;
|
notes: Note;
|
||||||
videos: Video;
|
videos: Video;
|
||||||
|
@ -64,6 +61,7 @@ export interface Config {
|
||||||
wordings: Wording;
|
wordings: Wording;
|
||||||
collectibles: Collectible;
|
collectibles: Collectible;
|
||||||
'generic-contents': GenericContent;
|
'generic-contents': GenericContent;
|
||||||
|
'background-images': BackgroundImage;
|
||||||
'payload-preferences': PayloadPreference;
|
'payload-preferences': PayloadPreference;
|
||||||
'payload-migrations': PayloadMigration;
|
'payload-migrations': PayloadMigration;
|
||||||
};
|
};
|
||||||
|
@ -195,7 +193,7 @@ export interface Collectible {
|
||||||
} | null;
|
} | null;
|
||||||
id?: string | null;
|
id?: string | null;
|
||||||
}[];
|
}[];
|
||||||
backgroundImage?: string | Image | null;
|
backgroundImage?: string | BackgroundImage | null;
|
||||||
gallery?:
|
gallery?:
|
||||||
| {
|
| {
|
||||||
image: string | Image;
|
image: string | Image;
|
||||||
|
@ -413,6 +411,31 @@ export interface TagsGroup {
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* This interface was referenced by `Config`'s JSON-Schema
|
||||||
|
* via the `definition` "background-images".
|
||||||
|
*/
|
||||||
|
export interface BackgroundImage {
|
||||||
|
id: string;
|
||||||
|
updatedAt: string;
|
||||||
|
createdAt: string;
|
||||||
|
url?: string | null;
|
||||||
|
filename?: string | null;
|
||||||
|
mimeType?: string | null;
|
||||||
|
filesize?: number | null;
|
||||||
|
width?: number | null;
|
||||||
|
height?: number | null;
|
||||||
|
sizes?: {
|
||||||
|
thumb?: {
|
||||||
|
url?: string | null;
|
||||||
|
width?: number | null;
|
||||||
|
height?: number | null;
|
||||||
|
mimeType?: string | null;
|
||||||
|
filesize?: number | null;
|
||||||
|
filename?: string | null;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* This interface was referenced by `Config`'s JSON-Schema
|
* This interface was referenced by `Config`'s JSON-Schema
|
||||||
* via the `definition` "recorders".
|
* via the `definition` "recorders".
|
||||||
|
@ -484,7 +507,7 @@ export interface Page {
|
||||||
slug: string;
|
slug: string;
|
||||||
type: 'Content' | 'Post' | 'Generic';
|
type: 'Content' | 'Post' | 'Generic';
|
||||||
thumbnail?: string | Image | null;
|
thumbnail?: string | Image | null;
|
||||||
backgroundImage?: string | Image | null;
|
backgroundImage?: string | BackgroundImage | null;
|
||||||
tags?: (string | Tag)[] | null;
|
tags?: (string | Tag)[] | null;
|
||||||
authors?: (string | Recorder)[] | null;
|
authors?: (string | Recorder)[] | null;
|
||||||
translations: {
|
translations: {
|
||||||
|
@ -644,173 +667,6 @@ export interface ChronologyEra {
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* This interface was referenced by `Config`'s JSON-Schema
|
|
||||||
* via the `definition` "weapons".
|
|
||||||
*/
|
|
||||||
export interface Weapon {
|
|
||||||
id: string;
|
|
||||||
slug: string;
|
|
||||||
thumbnail?: string | WeaponsThumbnail | null;
|
|
||||||
group?: (string | null) | WeaponsGroup;
|
|
||||||
appearances: {
|
|
||||||
translations: {
|
|
||||||
language: string | Language;
|
|
||||||
sourceLanguage: string | Language;
|
|
||||||
name: string;
|
|
||||||
description?: {
|
|
||||||
root: {
|
|
||||||
children: {
|
|
||||||
type: string;
|
|
||||||
version: number;
|
|
||||||
[k: string]: unknown;
|
|
||||||
}[];
|
|
||||||
direction: ('ltr' | 'rtl') | null;
|
|
||||||
format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | '';
|
|
||||||
indent: number;
|
|
||||||
type: string;
|
|
||||||
version: number;
|
|
||||||
};
|
|
||||||
[k: string]: unknown;
|
|
||||||
} | null;
|
|
||||||
level1?: {
|
|
||||||
root: {
|
|
||||||
children: {
|
|
||||||
type: string;
|
|
||||||
version: number;
|
|
||||||
[k: string]: unknown;
|
|
||||||
}[];
|
|
||||||
direction: ('ltr' | 'rtl') | null;
|
|
||||||
format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | '';
|
|
||||||
indent: number;
|
|
||||||
type: string;
|
|
||||||
version: number;
|
|
||||||
};
|
|
||||||
[k: string]: unknown;
|
|
||||||
} | null;
|
|
||||||
level2?: {
|
|
||||||
root: {
|
|
||||||
children: {
|
|
||||||
type: string;
|
|
||||||
version: number;
|
|
||||||
[k: string]: unknown;
|
|
||||||
}[];
|
|
||||||
direction: ('ltr' | 'rtl') | null;
|
|
||||||
format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | '';
|
|
||||||
indent: number;
|
|
||||||
type: string;
|
|
||||||
version: number;
|
|
||||||
};
|
|
||||||
[k: string]: unknown;
|
|
||||||
} | null;
|
|
||||||
level3?: {
|
|
||||||
root: {
|
|
||||||
children: {
|
|
||||||
type: string;
|
|
||||||
version: number;
|
|
||||||
[k: string]: unknown;
|
|
||||||
}[];
|
|
||||||
direction: ('ltr' | 'rtl') | null;
|
|
||||||
format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | '';
|
|
||||||
indent: number;
|
|
||||||
type: string;
|
|
||||||
version: number;
|
|
||||||
};
|
|
||||||
[k: string]: unknown;
|
|
||||||
} | null;
|
|
||||||
level4?: {
|
|
||||||
root: {
|
|
||||||
children: {
|
|
||||||
type: string;
|
|
||||||
version: number;
|
|
||||||
[k: string]: unknown;
|
|
||||||
}[];
|
|
||||||
direction: ('ltr' | 'rtl') | null;
|
|
||||||
format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | '';
|
|
||||||
indent: number;
|
|
||||||
type: string;
|
|
||||||
version: number;
|
|
||||||
};
|
|
||||||
[k: string]: unknown;
|
|
||||||
} | null;
|
|
||||||
transcribers?: (string | Recorder)[] | null;
|
|
||||||
translators?: (string | Recorder)[] | null;
|
|
||||||
proofreaders?: (string | Recorder)[] | null;
|
|
||||||
id?: string | null;
|
|
||||||
}[];
|
|
||||||
id?: string | null;
|
|
||||||
}[];
|
|
||||||
updatedBy: string | Recorder;
|
|
||||||
updatedAt: string;
|
|
||||||
createdAt: string;
|
|
||||||
_status?: ('draft' | 'published') | null;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* This interface was referenced by `Config`'s JSON-Schema
|
|
||||||
* via the `definition` "weapons-thumbnails".
|
|
||||||
*/
|
|
||||||
export interface WeaponsThumbnail {
|
|
||||||
id: string;
|
|
||||||
weapon?: (string | null) | Weapon;
|
|
||||||
updatedAt: string;
|
|
||||||
createdAt: string;
|
|
||||||
url?: string | null;
|
|
||||||
filename?: string | null;
|
|
||||||
mimeType?: string | null;
|
|
||||||
filesize?: number | null;
|
|
||||||
width?: number | null;
|
|
||||||
height?: number | null;
|
|
||||||
sizes?: {
|
|
||||||
thumb?: {
|
|
||||||
url?: string | null;
|
|
||||||
width?: number | null;
|
|
||||||
height?: number | null;
|
|
||||||
mimeType?: string | null;
|
|
||||||
filesize?: number | null;
|
|
||||||
filename?: string | null;
|
|
||||||
};
|
|
||||||
og?: {
|
|
||||||
url?: string | null;
|
|
||||||
width?: number | null;
|
|
||||||
height?: number | null;
|
|
||||||
mimeType?: string | null;
|
|
||||||
filesize?: number | null;
|
|
||||||
filename?: string | null;
|
|
||||||
};
|
|
||||||
small?: {
|
|
||||||
url?: string | null;
|
|
||||||
width?: number | null;
|
|
||||||
height?: number | null;
|
|
||||||
mimeType?: string | null;
|
|
||||||
filesize?: number | null;
|
|
||||||
filename?: string | null;
|
|
||||||
};
|
|
||||||
medium?: {
|
|
||||||
url?: string | null;
|
|
||||||
width?: number | null;
|
|
||||||
height?: number | null;
|
|
||||||
mimeType?: string | null;
|
|
||||||
filesize?: number | null;
|
|
||||||
filename?: string | null;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* This interface was referenced by `Config`'s JSON-Schema
|
|
||||||
* via the `definition` "weapons-groups".
|
|
||||||
*/
|
|
||||||
export interface WeaponsGroup {
|
|
||||||
id: string;
|
|
||||||
slug: string;
|
|
||||||
translations?:
|
|
||||||
| {
|
|
||||||
language: string | Language;
|
|
||||||
name: string;
|
|
||||||
id?: string | null;
|
|
||||||
}[]
|
|
||||||
| null;
|
|
||||||
weapons?: (string | Weapon)[] | null;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* This interface was referenced by `Config`'s JSON-Schema
|
* This interface was referenced by `Config`'s JSON-Schema
|
||||||
* via the `definition` "notes".
|
* via the `definition` "notes".
|
||||||
|
@ -1011,9 +867,6 @@ export enum Collections {
|
||||||
RecordersThumbnails = "recorders-thumbnails",
|
RecordersThumbnails = "recorders-thumbnails",
|
||||||
VideosChannels = "videos-channels",
|
VideosChannels = "videos-channels",
|
||||||
Videos = "videos",
|
Videos = "videos",
|
||||||
Weapons = "weapons",
|
|
||||||
WeaponsGroups = "weapons-groups",
|
|
||||||
WeaponsThumbnails = "weapons-thumbnails",
|
|
||||||
Folders = "folders",
|
Folders = "folders",
|
||||||
FoldersThumbnails = "folders-thumbnails",
|
FoldersThumbnails = "folders-thumbnails",
|
||||||
Tags = "tags",
|
Tags = "tags",
|
||||||
|
@ -1142,6 +995,16 @@ export interface RichTextLinebreakNode extends RichTextNode {
|
||||||
type: "linebreak";
|
type: "linebreak";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface RichTextUploadNode extends RichTextNode {
|
||||||
|
type: "upload";
|
||||||
|
relationTo: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RichTextUploadImageNode extends RichTextUploadNode {
|
||||||
|
relationTo: "images" | "background-images";
|
||||||
|
value: Image;
|
||||||
|
}
|
||||||
|
|
||||||
export interface RichTextTextNode extends RichTextNode {
|
export interface RichTextTextNode extends RichTextNode {
|
||||||
type: "text";
|
type: "text";
|
||||||
format: number;
|
format: number;
|
||||||
|
@ -1201,6 +1064,12 @@ export interface RichTextSpacerBlock extends RichTextBlockNode {
|
||||||
export const isNodeParagraphNode = (node: RichTextNode): node is RichTextParagraphNode =>
|
export const isNodeParagraphNode = (node: RichTextNode): node is RichTextParagraphNode =>
|
||||||
node.type === "paragraph";
|
node.type === "paragraph";
|
||||||
|
|
||||||
|
export const isNodeUploadNode = (node: RichTextNode): node is RichTextUploadNode =>
|
||||||
|
node.type === "upload";
|
||||||
|
|
||||||
|
export const isUploadNodeImageNode = (node: RichTextUploadNode): node is RichTextUploadImageNode =>
|
||||||
|
node.relationTo === "images" || node.relationTo === "background-images";
|
||||||
|
|
||||||
export const isNodeListNode = (node: RichTextNode): node is RichTextListNode =>
|
export const isNodeListNode = (node: RichTextNode): node is RichTextListNode =>
|
||||||
node.type === "list";
|
node.type === "list";
|
||||||
|
|
||||||
|
@ -1248,11 +1117,15 @@ export const isBlockNodeSpacerBlock = (node: RichTextBlockNode): node is RichTex
|
||||||
|
|
||||||
/* TODO: TO BE REMOVED WHEN https://github.com/payloadcms/payload/issues/5216 is closed */
|
/* TODO: TO BE REMOVED WHEN https://github.com/payloadcms/payload/issues/5216 is closed */
|
||||||
export interface CueBlock {
|
export interface CueBlock {
|
||||||
|
content: RichTextContent;
|
||||||
|
blockType: 'cueBlock';
|
||||||
id?: string | null;
|
id?: string | null;
|
||||||
blockName?: string | null;
|
blockName?: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LineBlock {
|
export interface LineBlock {
|
||||||
|
content: RichTextContent;
|
||||||
|
blockType: 'lineBlock';
|
||||||
id?: string | null;
|
id?: string | null;
|
||||||
blockName?: string | null;
|
blockName?: string | null;
|
||||||
}
|
}
|
||||||
|
@ -1353,43 +1226,6 @@ const request = async (url: string, init?: RequestInit): Promise<Response> => {
|
||||||
|
|
||||||
// SDK and Types
|
// SDK and Types
|
||||||
|
|
||||||
export type EndpointWeapon = EndpointBasicWeapon & {
|
|
||||||
appearances: {
|
|
||||||
categories: string[];
|
|
||||||
translations: {
|
|
||||||
language: string;
|
|
||||||
sourceLanguage: string;
|
|
||||||
name: string;
|
|
||||||
description?: string;
|
|
||||||
level1?: string;
|
|
||||||
level2?: string;
|
|
||||||
level3?: string;
|
|
||||||
level4?: string;
|
|
||||||
transcribers: string[];
|
|
||||||
translators: string[];
|
|
||||||
proofreaders: string[];
|
|
||||||
}[];
|
|
||||||
}[];
|
|
||||||
group?: {
|
|
||||||
slug: string;
|
|
||||||
translations: { language: string; name: string }[];
|
|
||||||
weapons: EndpointBasicWeapon[];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export type EndpointBasicWeapon = {
|
|
||||||
slug: string;
|
|
||||||
type: string;
|
|
||||||
categories: string[];
|
|
||||||
translations: { language: string; name: string; aliases: string[] }[];
|
|
||||||
images?: {
|
|
||||||
previewCard: PayloadImage;
|
|
||||||
thumbnailHeader: PayloadImage;
|
|
||||||
lightBox: PayloadImage;
|
|
||||||
openGraph: PayloadImage;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export type EndpointEra = {
|
export type EndpointEra = {
|
||||||
slug: string;
|
slug: string;
|
||||||
startingYear: number;
|
startingYear: number;
|
||||||
|
@ -1397,7 +1233,7 @@ export type EndpointEra = {
|
||||||
translations: {
|
translations: {
|
||||||
language: string;
|
language: string;
|
||||||
title: string;
|
title: string;
|
||||||
description?: string;
|
description?: RichTextContent;
|
||||||
}[];
|
}[];
|
||||||
items: {
|
items: {
|
||||||
date: {
|
date: {
|
||||||
|
@ -1410,16 +1246,13 @@ export type EndpointEra = {
|
||||||
language: string;
|
language: string;
|
||||||
sourceLanguage: string;
|
sourceLanguage: string;
|
||||||
title?: string;
|
title?: string;
|
||||||
description?: string;
|
description?: RichTextContent;
|
||||||
notes?: string;
|
notes?: RichTextContent;
|
||||||
transcribers: string[];
|
transcribers: EndpointRecorder[];
|
||||||
translators: string[];
|
translators: EndpointRecorder[];
|
||||||
proofreaders: string[];
|
proofreaders: EndpointRecorder[];
|
||||||
}[];
|
}[];
|
||||||
}[];
|
}[];
|
||||||
createdAt: Date;
|
|
||||||
updatedAt: Date;
|
|
||||||
updatedBy: string;
|
|
||||||
}[];
|
}[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1621,8 +1454,6 @@ export type PayloadImage = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const payload = {
|
export const payload = {
|
||||||
getWeapon: async (slug: string): Promise<EndpointWeapon> =>
|
|
||||||
await (await request(payloadApiUrl(Collections.Weapons, `slug/${slug}`))).json(),
|
|
||||||
getEras: async (): Promise<EndpointEra[]> =>
|
getEras: async (): Promise<EndpointEra[]> =>
|
||||||
await (await request(payloadApiUrl(Collections.ChronologyEras, `all`))).json(),
|
await (await request(payloadApiUrl(Collections.ChronologyEras, `all`))).json(),
|
||||||
getRootFolders: async (): Promise<EndpointFolderPreview[]> =>
|
getRootFolders: async (): Promise<EndpointFolderPreview[]> =>
|
||||||
|
@ -1637,10 +1468,6 @@ export const payload = {
|
||||||
await (await request(payloadApiUrl(Collections.Wordings, `all`))).json(),
|
await (await request(payloadApiUrl(Collections.Wordings, `all`))).json(),
|
||||||
getRecorders: async (): Promise<EndpointRecorder[]> =>
|
getRecorders: async (): Promise<EndpointRecorder[]> =>
|
||||||
await (await request(payloadApiUrl(Collections.Recorders, `all`))).json(),
|
await (await request(payloadApiUrl(Collections.Recorders, `all`))).json(),
|
||||||
getTags: async (): Promise<EndpointTag[]> =>
|
|
||||||
await (await request(payloadApiUrl(Collections.Tags, `all`))).json(),
|
|
||||||
getTagsGroups: async (): Promise<EndpointTagsGroup[]> =>
|
|
||||||
await (await request(payloadApiUrl(Collections.TagsGroups, `all`))).json(),
|
|
||||||
getPage: async (slug: string): Promise<EndpointPage> =>
|
getPage: async (slug: string): Promise<EndpointPage> =>
|
||||||
await (await request(payloadApiUrl(Collections.Pages, `slug/${slug}`))).json(),
|
await (await request(payloadApiUrl(Collections.Pages, `slug/${slug}`))).json(),
|
||||||
getCollectible: async (slug: string): Promise<EndpointCollectible> =>
|
getCollectible: async (slug: string): Promise<EndpointCollectible> =>
|
||||||
|
|
Loading…
Reference in New Issue