Removed unused exports

This commit is contained in:
DrMint 2024-03-20 13:31:33 +01:00
parent 4fd59464ba
commit 1a9d4f2dd0
10 changed files with 127 additions and 136 deletions

View File

@ -26,7 +26,7 @@ const generateRecursiveSectionBlock = (depth = 1, maxDepth = 5): Block => ({
blocks: [ blocks: [
...(depth < maxDepth ? [generateRecursiveSectionBlock(depth + 1, maxDepth)] : []), ...(depth < maxDepth ? [generateRecursiveSectionBlock(depth + 1, maxDepth)] : []),
transcriptBlock, transcriptBlock,
breakBlock breakBlock,
], ],
}), }),
}, },

View File

@ -28,7 +28,14 @@ export const Folders = buildCollectionConfig({
admin: { admin: {
useAsTitle: fields.slug, useAsTitle: fields.slug,
group: CollectionGroups.Collections, group: CollectionGroups.Collections,
defaultColumns: [fields.slug, fields.translations, fields.parentFolders, fields.sections, fields.files, fields.icon], defaultColumns: [
fields.slug,
fields.translations,
fields.parentFolders,
fields.sections,
fields.files,
fields.icon,
],
description: description:
"Folders provide a way to structure our content. A folder can contain subfolders and/or files.", "Folders provide a way to structure our content. A folder can contain subfolders and/or files.",
preview: ({ slug }) => `https://v3.accords-library.com/en/folders/${slug}`, preview: ({ slug }) => `https://v3.accords-library.com/en/folders/${slug}`,

View File

@ -19,8 +19,7 @@ export const getBySlugEndpoint = createGetByEndpoint(
? { ? {
type: "single", type: "single",
subfolders: subfolders:
sections[0]?.subfolders?.filter(isPayloadType).map(convertFolderToPreview) ?? sections[0]?.subfolders?.filter(isPayloadType).map(convertFolderToPreview) ?? [],
[],
} }
: { : {
type: "multiple", type: "multiple",

View File

@ -5,7 +5,7 @@ export const createGetByEndpoint = <C extends keyof GeneratedTypes["collections"
collection: C, collection: C,
attribute: string, attribute: string,
handler: (doc: GeneratedTypes["collections"][C]) => Promise<R> | R, handler: (doc: GeneratedTypes["collections"][C]) => Promise<R> | R,
depth?: number, depth?: number
): CollectionEndpoint => ({ ): CollectionEndpoint => ({
path: `/${attribute}/:${attribute}`, path: `/${attribute}/:${attribute}`,
method: "get", method: "get",

View File

@ -4,10 +4,7 @@ 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";
export const getAllStrapiEntries = async ( const getAllStrapiEntries = async (collectionSlug: string, params: Object): Promise<any[]> => {
collectionSlug: string,
params: Object
): Promise<any[]> => {
let page = 1; let page = 1;
let totalPage = 1; let totalPage = 1;
const result: any[] = []; const result: any[] = [];
@ -39,14 +36,11 @@ type Params<S> = {
path?: string; path?: string;
collection: keyof GeneratedTypes["collections"]; collection: keyof GeneratedTypes["collections"];
import?: (strapiObject: S, user: any) => Promise<void>; import?: (strapiObject: S, user: any) => Promise<void>;
convert?: ( convert?: (strapiObject: S, user: any) => any;
strapiObject: S,
user: any
) => any;
}; };
}; };
export const importStrapiEntries = async <S>({ const importStrapiEntries = async <S>({
strapi: strapiParams, strapi: strapiParams,
payload: payloadParams, payload: payloadParams,
user, user,

View File

@ -20,8 +20,8 @@ export type RecorderBiographies =
version: number; version: number;
[k: string]: unknown; [k: string]: unknown;
}[]; }[];
direction: ('ltr' | 'rtl') | null; direction: ("ltr" | "rtl") | null;
format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; format: "left" | "start" | "center" | "right" | "end" | "justify" | "";
indent: number; indent: number;
type: string; type: string;
version: number; version: number;
@ -46,26 +46,25 @@ export interface Config {
pages: Page; pages: Page;
collectibles: Collectible; collectibles: Collectible;
folders: Folder; folders: Folder;
'chronology-items': ChronologyItem; "chronology-events": ChronologyEvent;
'chronology-eras': ChronologyEra;
notes: Note; notes: Note;
images: Image; images: Image;
'background-images': BackgroundImage; "background-images": BackgroundImage;
'recorders-thumbnails': RecordersThumbnail; "recorders-thumbnails": RecordersThumbnail;
videos: Video; videos: Video;
'videos-channels': VideosChannel; "videos-channels": VideosChannel;
tags: Tag; tags: Tag;
'tags-groups': TagsGroup; "tags-groups": TagsGroup;
recorders: Recorder; recorders: Recorder;
languages: Language; languages: Language;
currencies: Currency; currencies: Currency;
wordings: Wording; wordings: Wording;
'generic-contents': GenericContent; "generic-contents": GenericContent;
'payload-preferences': PayloadPreference; "payload-preferences": PayloadPreference;
'payload-migrations': PayloadMigration; "payload-migrations": PayloadMigration;
}; };
globals: { globals: {
'home-folders': HomeFolder; "home-folders": HomeFolder;
}; };
} }
/** /**
@ -75,7 +74,7 @@ export interface Config {
export interface Page { export interface Page {
id: string; id: string;
slug: string; slug: string;
type: 'Content' | 'Post' | 'Generic'; type: "Content" | "Post" | "Generic";
thumbnail?: string | Image | null; thumbnail?: string | Image | null;
backgroundImage?: string | BackgroundImage | null; backgroundImage?: string | BackgroundImage | null;
tags?: (string | Tag)[] | null; tags?: (string | Tag)[] | null;
@ -93,8 +92,8 @@ export interface Page {
version: number; version: number;
[k: string]: unknown; [k: string]: unknown;
}[]; }[];
direction: ('ltr' | 'rtl') | null; direction: ("ltr" | "rtl") | null;
format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; format: "left" | "start" | "center" | "right" | "end" | "justify" | "";
indent: number; indent: number;
type: string; type: string;
version: number; version: number;
@ -108,8 +107,8 @@ export interface Page {
version: number; version: number;
[k: string]: unknown; [k: string]: unknown;
}[]; }[];
direction: ('ltr' | 'rtl') | null; direction: ("ltr" | "rtl") | null;
format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; format: "left" | "start" | "center" | "right" | "end" | "justify" | "";
indent: number; indent: number;
type: string; type: string;
version: number; version: number;
@ -126,7 +125,7 @@ export interface Page {
updatedBy: string | Recorder; updatedBy: string | Recorder;
updatedAt: string; updatedAt: string;
createdAt: string; createdAt: string;
_status?: ('draft' | 'published') | null; _status?: ("draft" | "published") | null;
} }
/** /**
* This interface was referenced by `Config`'s JSON-Schema * This interface was referenced by `Config`'s JSON-Schema
@ -237,7 +236,7 @@ export interface Recorder {
avatar?: string | RecordersThumbnail | null; avatar?: string | RecordersThumbnail | null;
languages?: (string | Language)[] | null; languages?: (string | Language)[] | null;
biographies?: RecorderBiographies; biographies?: RecorderBiographies;
role?: ('Admin' | 'Recorder' | 'Api')[] | null; role?: ("Admin" | "Recorder" | "Api")[] | null;
anonymize: boolean; anonymize: boolean;
email: string; email: string;
resetPasswordToken?: string | null; resetPasswordToken?: string | null;
@ -301,8 +300,8 @@ export interface Folder {
version: number; version: number;
[k: string]: unknown; [k: string]: unknown;
}[]; }[];
direction: ('ltr' | 'rtl') | null; direction: ("ltr" | "rtl") | null;
format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; format: "left" | "start" | "center" | "right" | "end" | "justify" | "";
indent: number; indent: number;
type: string; type: string;
version: number; version: number;
@ -327,11 +326,11 @@ export interface Folder {
files?: files?:
| ( | (
| { | {
relationTo: 'collectibles'; relationTo: "collectibles";
value: string | Collectible; value: string | Collectible;
} }
| { | {
relationTo: 'pages'; relationTo: "pages";
value: string | Page; value: string | Page;
} }
)[] )[]
@ -347,7 +346,7 @@ export interface Collectible {
id: string; id: string;
slug: string; slug: string;
thumbnail?: string | Image | null; thumbnail?: string | Image | null;
nature: 'Physical' | 'Digital'; nature: "Physical" | "Digital";
languages?: (string | Language)[] | null; languages?: (string | Language)[] | null;
tags?: (string | Tag)[] | null; tags?: (string | Tag)[] | null;
translations: { translations: {
@ -362,8 +361,8 @@ export interface Collectible {
version: number; version: number;
[k: string]: unknown; [k: string]: unknown;
}[]; }[];
direction: ('ltr' | 'rtl') | null; direction: ("ltr" | "rtl") | null;
format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; format: "left" | "start" | "center" | "right" | "end" | "justify" | "";
indent: number; indent: number;
type: string; type: string;
version: number; version: number;
@ -455,8 +454,8 @@ export interface Collectible {
pageInfoEnabled?: boolean | null; pageInfoEnabled?: boolean | null;
pageInfo?: { pageInfo?: {
pageCount: number; pageCount: number;
bindingType?: ('Paperback' | 'Hardcover') | null; bindingType?: ("Paperback" | "Hardcover") | null;
pageOrder?: ('Left to right' | 'Right to left') | null; pageOrder?: ("Left to right" | "Right to left") | null;
}; };
folders?: (string | Folder)[] | null; folders?: (string | Folder)[] | null;
parentItems?: (string | Collectible)[] | null; parentItems?: (string | Collectible)[] | null;
@ -465,11 +464,11 @@ export interface Collectible {
| { | {
content: content:
| { | {
relationTo: 'pages'; relationTo: "pages";
value: string | Page; value: string | Page;
} }
| { | {
relationTo: 'generic-contents'; relationTo: "generic-contents";
value: string | GenericContent; value: string | GenericContent;
}; };
range?: range?:
@ -479,14 +478,14 @@ export interface Collectible {
end: number; end: number;
id?: string | null; id?: string | null;
blockName?: string | null; blockName?: string | null;
blockType: 'pageRange'; blockType: "pageRange";
} }
| { | {
start: string; start: string;
end: string; end: string;
id?: string | null; id?: string | null;
blockName?: string | null; blockName?: string | null;
blockType: 'timeRange'; blockType: "timeRange";
} }
| { | {
translations?: translations?:
@ -499,8 +498,8 @@ export interface Collectible {
version: number; version: number;
[k: string]: unknown; [k: string]: unknown;
}[]; }[];
direction: ('ltr' | 'rtl') | null; direction: ("ltr" | "rtl") | null;
format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; format: "left" | "start" | "center" | "right" | "end" | "justify" | "";
indent: number; indent: number;
type: string; type: string;
version: number; version: number;
@ -512,7 +511,7 @@ export interface Collectible {
| null; | null;
id?: string | null; id?: string | null;
blockName?: string | null; blockName?: string | null;
blockType: 'other'; blockType: "other";
} }
)[] )[]
| null; | null;
@ -522,7 +521,7 @@ export interface Collectible {
updatedBy: string | Recorder; updatedBy: string | Recorder;
updatedAt: string; updatedAt: string;
createdAt: string; createdAt: string;
_status?: ('draft' | 'published') | null; _status?: ("draft" | "published") | null;
} }
/** /**
* This interface was referenced by `Config`'s JSON-Schema * This interface was referenced by `Config`'s JSON-Schema
@ -548,9 +547,9 @@ export interface GenericContent {
} }
/** /**
* This interface was referenced by `Config`'s JSON-Schema * This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "chronology-items". * via the `definition` "chronology-events".
*/ */
export interface ChronologyItem { export interface ChronologyEvent {
id: string; id: string;
name?: string | null; name?: string | null;
date: { date: {
@ -559,6 +558,7 @@ export interface ChronologyItem {
day?: number | null; day?: number | null;
}; };
events: { events: {
sources?: (UrlBlock | CollectibleBlock | PageBlock)[] | null;
translations: { translations: {
language: string | Language; language: string | Language;
sourceLanguage: string | Language; sourceLanguage: string | Language;
@ -570,8 +570,8 @@ export interface ChronologyItem {
version: number; version: number;
[k: string]: unknown; [k: string]: unknown;
}[]; }[];
direction: ('ltr' | 'rtl') | null; direction: ("ltr" | "rtl") | null;
format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; format: "left" | "start" | "center" | "right" | "end" | "justify" | "";
indent: number; indent: number;
type: string; type: string;
version: number; version: number;
@ -585,8 +585,8 @@ export interface ChronologyItem {
version: number; version: number;
[k: string]: unknown; [k: string]: unknown;
}[]; }[];
direction: ('ltr' | 'rtl') | null; direction: ("ltr" | "rtl") | null;
format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; format: "left" | "start" | "center" | "right" | "end" | "justify" | "";
indent: number; indent: number;
type: string; type: string;
version: number; version: number;
@ -603,42 +603,63 @@ export interface ChronologyItem {
updatedBy: string | Recorder; updatedBy: string | Recorder;
updatedAt: string; updatedAt: string;
createdAt: string; createdAt: string;
_status?: ('draft' | 'published') | null; _status?: ("draft" | "published") | null;
} }
/** /**
* This interface was referenced by `Config`'s JSON-Schema * This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "chronology-eras". * via the `definition` "UrlBlock".
*/ */
export interface ChronologyEra { export interface UrlBlock {
id: string; url: string;
slug: string; id?: string | null;
startingYear: number; blockName?: string | null;
endingYear: number; blockType: "urlBlock";
translations?: }
| { /**
language: string | Language; * This interface was referenced by `Config`'s JSON-Schema
title: string; * via the `definition` "CollectibleBlock".
description?: { */
root: { export interface CollectibleBlock {
children: { collectible: string | Collectible;
type: string; range?:
version: number; | (
[k: string]: unknown; | {
page: number;
id?: string | null;
blockName?: string | null;
blockType: "page";
}
| {
timestamp: string;
id?: string | null;
blockName?: string | null;
blockType: "timestamp";
}
| {
translations: {
language: string | Language;
note: string;
id?: string | null;
}[]; }[];
direction: ('ltr' | 'rtl') | null; id?: string | null;
format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; blockName?: string | null;
indent: number; blockType: "other";
type: string; }
version: number; )[]
};
[k: string]: unknown;
} | null;
id?: string | null;
}[]
| null; | null;
events?: (string | ChronologyItem)[] | null; id?: string | null;
updatedAt: string; blockName?: string | null;
createdAt: string; blockType: "collectibleBlock";
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "PageBlock".
*/
export interface PageBlock {
page: string | Page;
id?: string | null;
blockName?: string | null;
blockType: "pageBlock";
} }
/** /**
* This interface was referenced by `Config`'s JSON-Schema * This interface was referenced by `Config`'s JSON-Schema
@ -653,8 +674,8 @@ export interface Note {
version: number; version: number;
[k: string]: unknown; [k: string]: unknown;
}[]; }[];
direction: ('ltr' | 'rtl') | null; direction: ("ltr" | "rtl") | null;
format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; format: "left" | "start" | "center" | "right" | "end" | "justify" | "";
indent: number; indent: number;
type: string; type: string;
version: number; version: number;
@ -672,7 +693,7 @@ export interface Video {
id: string; id: string;
uid: string; uid: string;
gone: boolean; gone: boolean;
source: 'YouTube' | 'NicoNico' | 'Tumblr'; source: "YouTube" | "NicoNico" | "Tumblr";
title: string; title: string;
description?: string | null; description?: string | null;
likes?: number | null; likes?: number | null;
@ -708,7 +729,7 @@ export interface Wording {
export interface PayloadPreference { export interface PayloadPreference {
id: string; id: string;
user: { user: {
relationTo: 'recorders'; relationTo: "recorders";
value: string | Recorder; value: string | Recorder;
}; };
key?: string | null; key?: string | null;
@ -764,15 +785,15 @@ export interface LineBlock {
version: number; version: number;
[k: string]: unknown; [k: string]: unknown;
}[]; }[];
direction: ('ltr' | 'rtl') | null; direction: ("ltr" | "rtl") | null;
format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; format: "left" | "start" | "center" | "right" | "end" | "justify" | "";
indent: number; indent: number;
type: string; type: string;
version: number; version: number;
}; };
[k: string]: unknown; [k: string]: unknown;
}; };
blockType: 'lineBlock'; blockType: "lineBlock";
} }
/** /**
* This interface was referenced by `Config`'s JSON-Schema * This interface was referenced by `Config`'s JSON-Schema
@ -786,15 +807,15 @@ export interface CueBlock {
version: number; version: number;
[k: string]: unknown; [k: string]: unknown;
}[]; }[];
direction: ('ltr' | 'rtl') | null; direction: ("ltr" | "rtl") | null;
format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; format: "left" | "start" | "center" | "right" | "end" | "justify" | "";
indent: number; indent: number;
type: string; type: string;
version: number; version: number;
}; };
[k: string]: unknown; [k: string]: unknown;
}; };
blockType: 'cueBlock'; blockType: "cueBlock";
} }
/** /**
* This interface was referenced by `Config`'s JSON-Schema * This interface was referenced by `Config`'s JSON-Schema
@ -804,17 +825,17 @@ export interface TranscriptBlock {
lines: (LineBlock | CueBlock)[]; lines: (LineBlock | CueBlock)[];
id?: string | null; id?: string | null;
blockName?: string | null; blockName?: string | null;
blockType: 'transcriptBlock'; blockType: "transcriptBlock";
} }
/** /**
* This interface was referenced by `Config`'s JSON-Schema * This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "BreakBlock". * via the `definition` "BreakBlock".
*/ */
export interface BreakBlock { export interface BreakBlock {
type: 'Scene break' | 'Empty space' | 'Solid line' | 'Dotted line'; type: "Scene break" | "Empty space" | "Solid line" | "Dotted line";
id?: string | null; id?: string | null;
blockName?: string | null; blockName?: string | null;
blockType: 'breakBlock'; blockType: "breakBlock";
} }
/** /**
* This interface was referenced by `Config`'s JSON-Schema * This interface was referenced by `Config`'s JSON-Schema
@ -828,8 +849,8 @@ export interface SectionBlock {
version: number; version: number;
[k: string]: unknown; [k: string]: unknown;
}[]; }[];
direction: ('ltr' | 'rtl') | null; direction: ("ltr" | "rtl") | null;
format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; format: "left" | "start" | "center" | "right" | "end" | "justify" | "";
indent: number; indent: number;
type: string; type: string;
version: number; version: number;
@ -838,10 +859,9 @@ export interface SectionBlock {
}; };
id?: string | null; id?: string | null;
blockName?: string | null; blockName?: string | null;
blockType: 'sectionBlock'; blockType: "sectionBlock";
} }
declare module "payload" {
declare module 'payload' {
export interface GeneratedTypes extends Config {} export interface GeneratedTypes extends Config {}
} }

View File

@ -2,10 +2,6 @@ export type StrapiLanguage = {
data?: { attributes: { code: string } }; data?: { attributes: { code: string } };
}; };
export type StrapiRecorders = {
data?: { attributes: { username: string } }[];
};
export type StrapiImage = { export type StrapiImage = {
data?: { data?: {
attributes: { attributes: {

View File

@ -12,15 +12,6 @@ export const isNotEmpty = (value: string | null | undefined): value is string =>
export const isEmpty = (value: string | null | undefined): value is string => export const isEmpty = (value: string | null | undefined): value is string =>
isUndefined(value) || value.trim().length === 0; isUndefined(value) || value.trim().length === 0;
type Span = [number, number];
const hasNoIntersection = (a: Span, b: Span): boolean => {
const [aStart, aEnd] = a;
const [bStart, bEnd] = b;
return aEnd < bStart || aStart > bEnd;
};
export const hasIntersection = (a: Span, b: Span): boolean => !hasNoIntersection(a, b);
export const hasDuplicates = <T>(list: T[]): boolean => list.length !== new Set(list).size; export const hasDuplicates = <T>(list: T[]): boolean => list.length !== new Set(list).size;
export const isValidPayloadImage = ( export const isValidPayloadImage = (
@ -46,9 +37,6 @@ export const isValidPayloadImage = (
return true; return true;
}; };
export const isString = <T extends Object>(value: string | T): value is string =>
typeof value === "string";
export const isPayloadType = <T extends Object>(value: string | T): value is T => export const isPayloadType = <T extends Object>(value: string | T): value is T =>
typeof value === "object"; typeof value === "object";

View File

@ -1,18 +1,7 @@
import payload, { GeneratedTypes } from "payload"; import payload, { GeneratedTypes } from "payload";
import { Collections } from "../constants";
import { StrapiImage } from "../types/strapi"; import { StrapiImage } from "../types/strapi";
import { isDefined } from "./asserts"; import { isDefined } from "./asserts";
export const findRecorder = async (name: string): Promise<string> => {
const recorder = await payload.find({
collection: Collections.Recorders,
where: { username: { equals: name } },
depth: 0,
});
if (!recorder.docs[0]) throw new Error(`Recorder ${name} wasn't found`);
return recorder.docs[0].id;
};
type UploadStrapiImage = { type UploadStrapiImage = {
image: StrapiImage; image: StrapiImage;
collection: keyof GeneratedTypes["collections"]; collection: keyof GeneratedTypes["collections"];

View File

@ -14,7 +14,7 @@ export const capitalize = (string: string): string => {
return [firstLetter.toUpperCase(), ...otherLetters].join(""); return [firstLetter.toUpperCase(), ...otherLetters].join("");
}; };
export const formatToCamelCase = (name: string): string => const formatToCamelCase = (name: string): string =>
name name
.toLowerCase() .toLowerCase()
.split(/[ \_-]/g) .split(/[ \_-]/g)
@ -23,9 +23,7 @@ export const formatToCamelCase = (name: string): string =>
export const formatToPascalCase = (name: string): string => capitalize(formatToCamelCase(name)); export const formatToPascalCase = (name: string): string => capitalize(formatToCamelCase(name));
export const plainTextToLexical = ( export const plainTextToLexical = (text: string): RichTextContent => ({
text: string
): RichTextContent => ({
root: { root: {
type: "root", type: "root",
format: "", format: "",