Use import type whenever possible

This commit is contained in:
DrMint 2024-07-13 13:05:20 +02:00
parent 04ce83b083
commit a5ca1ee9f2
8 changed files with 558 additions and 542 deletions

View File

@ -1,4 +1,4 @@
import { TrackRequestParams } from "./types"; import type { TrackRequestParams } from "./types";
type AnalyticsBody = Record<string, unknown> & { type AnalyticsBody = Record<string, unknown> & {
type: "event" | "request"; type: "event" | "request";

View File

@ -1,4 +1,4 @@
import { MeiliDocument, SearchRequest, SearchResponse } from "./types"; import type { MeiliDocument, SearchRequest, SearchResponse } from "./types";
export class MeilisearchSDK { export class MeilisearchSDK {
constructor( constructor(

View File

@ -1,5 +1,4 @@
import { Collections } from "../payload/constants"; import type {
import {
EndpointCollectible, EndpointCollectible,
EndpointPage, EndpointPage,
EndpointFolder, EndpointFolder,
@ -9,7 +8,8 @@ import {
EndpointFile, EndpointFile,
EndpointRecorder, EndpointRecorder,
EndpointChronologyEvent, EndpointChronologyEvent,
} from "../payload/endpoint-types"; } from "payload/endpoint-types";
import { Collections } from "../payload/constants";
export type MeiliDocument = { export type MeiliDocument = {
meilid: string; meilid: string;

View File

@ -1,4 +1,4 @@
import { RichTextContent } from "./rich-text"; import type { RichTextContent } from "./rich-text";
export interface TranscriptBlock extends GenericBlock { export interface TranscriptBlock extends GenericBlock {
lines: (LineBlock | CueBlock)[]; lines: (LineBlock | CueBlock)[];

View File

@ -1,5 +1,11 @@
import { AttributeTypes, CollectibleBindingTypes, CollectibleNature, CollectiblePageOrders, Collections } from "./constants"; import type {
import { RichTextContent } from "./rich-text"; Collections,
AttributeTypes,
CollectibleNature,
CollectibleBindingTypes,
CollectiblePageOrders,
} from "./constants";
import type { RichTextContent } from "./rich-text";
export interface EndpointCurrency { export interface EndpointCurrency {
id: string; id: string;
@ -19,9 +25,9 @@ export type EndpointFolderPreview = {
language: string; language: string;
title: string; title: string;
}[]; }[];
}; };
export type EndpointFolder = Omit<EndpointFolderPreview, "translations"> & { export type EndpointFolder = Omit<EndpointFolderPreview, "translations"> & {
translations: (EndpointFolderPreview["translations"][number] & { translations: (EndpointFolderPreview["translations"][number] & {
description?: RichTextContent; description?: RichTextContent;
})[]; })[];
@ -61,9 +67,9 @@ export type EndpointFolderPreview = {
} }
)[]; )[];
parentPages: EndpointSource[]; parentPages: EndpointSource[];
}; };
export type EndpointWebsiteConfig = { export type EndpointWebsiteConfig = {
home: { home: {
backgroundImage?: EndpointPayloadImage; backgroundImage?: EndpointPayloadImage;
folders: (EndpointFolderPreview & { folders: (EndpointFolderPreview & {
@ -82,31 +88,31 @@ export type EndpointFolderPreview = {
}[]; }[];
}; };
defaultOpenGraphImage?: EndpointPayloadImage; defaultOpenGraphImage?: EndpointPayloadImage;
}; };
export type EndpointRecorderPreview = { export type EndpointRecorderPreview = {
id: string; id: string;
username: string; username: string;
}; };
export type EndpointRecorder = EndpointRecorderPreview & { export type EndpointRecorder = EndpointRecorderPreview & {
avatar?: EndpointPayloadImage; avatar?: EndpointPayloadImage;
translations: { translations: {
language: string; language: string;
biography: RichTextContent; biography: RichTextContent;
}[]; }[];
languages: string[]; languages: string[];
}; };
export type EndpointWording = { export type EndpointWording = {
name: string; name: string;
translations: { translations: {
language: string; language: string;
name: string; name: string;
}[]; }[];
}; };
export type EndpointTag = { export type EndpointTag = {
id: string; id: string;
slug: string; slug: string;
page?: { slug: string }; page?: { slug: string };
@ -114,9 +120,9 @@ export type EndpointFolderPreview = {
language: string; language: string;
name: string; name: string;
}[]; }[];
}; };
export type EndpointGenericAttribute = { export type EndpointGenericAttribute = {
id: string; id: string;
slug: string; slug: string;
icon: string; icon: string;
@ -124,43 +130,43 @@ export type EndpointFolderPreview = {
language: string; language: string;
name: string; name: string;
}[]; }[];
}; };
export type EndpointNumberAttribute = EndpointGenericAttribute & { export type EndpointNumberAttribute = EndpointGenericAttribute & {
type: AttributeTypes.Number; type: AttributeTypes.Number;
value: number; value: number;
}; };
export type EndpointTextAttribute = EndpointGenericAttribute & { export type EndpointTextAttribute = EndpointGenericAttribute & {
type: AttributeTypes.Text; type: AttributeTypes.Text;
value: string; value: string;
}; };
export type EndpointTagsAttribute = EndpointGenericAttribute & { export type EndpointTagsAttribute = EndpointGenericAttribute & {
type: AttributeTypes.Tags; type: AttributeTypes.Tags;
value: EndpointTag[]; value: EndpointTag[];
}; };
export type EndpointAttribute = export type EndpointAttribute =
| EndpointNumberAttribute | EndpointNumberAttribute
| EndpointTextAttribute | EndpointTextAttribute
| EndpointTagsAttribute; | EndpointTagsAttribute;
export type EndpointRole = { export type EndpointRole = {
id: string; id: string;
icon: string; icon: string;
translations: { translations: {
language: string; language: string;
name: string; name: string;
}[]; }[];
}; };
export type EndpointCredit = { export type EndpointCredit = {
role: EndpointRole; role: EndpointRole;
recorders: EndpointRecorderPreview[]; recorders: EndpointRecorderPreview[];
}; };
export type EndpointPagePreview = { export type EndpointPagePreview = {
id: string; id: string;
slug: string; slug: string;
thumbnail?: EndpointPayloadImage; thumbnail?: EndpointPayloadImage;
@ -172,9 +178,9 @@ export type EndpointFolderPreview = {
subtitle?: string; subtitle?: string;
}[]; }[];
updatedAt: string; updatedAt: string;
}; };
export type EndpointPage = Omit<EndpointPagePreview, "translations"> & { export type EndpointPage = Omit<EndpointPagePreview, "translations"> & {
backgroundImage?: EndpointPayloadImage; backgroundImage?: EndpointPayloadImage;
translations: (EndpointPagePreview["translations"][number] & { translations: (EndpointPagePreview["translations"][number] & {
sourceLanguage: string; sourceLanguage: string;
@ -186,9 +192,9 @@ export type EndpointFolderPreview = {
createdAt: string; createdAt: string;
updatedBy?: EndpointRecorderPreview; updatedBy?: EndpointRecorderPreview;
parentPages: EndpointSource[]; parentPages: EndpointSource[];
}; };
export type EndpointCollectiblePreview = { export type EndpointCollectiblePreview = {
id: string; id: string;
slug: string; slug: string;
thumbnail?: EndpointPayloadImage; thumbnail?: EndpointPayloadImage;
@ -205,9 +211,12 @@ export type EndpointFolderPreview = {
amount: number; amount: number;
currency: string; currency: string;
}; };
}; };
export type EndpointCollectible = Omit<EndpointCollectiblePreview, "translations"> & { export type EndpointCollectible = Omit<
EndpointCollectiblePreview,
"translations"
> & {
translations: (EndpointCollectiblePreview["translations"][number] & { translations: (EndpointCollectiblePreview["translations"][number] & {
description?: RichTextContent; description?: RichTextContent;
})[]; })[];
@ -276,9 +285,9 @@ export type EndpointFolderPreview = {
updatedAt: string; updatedAt: string;
updatedBy?: EndpointRecorderPreview; updatedBy?: EndpointRecorderPreview;
parentPages: EndpointSource[]; parentPages: EndpointSource[];
}; };
export type EndpointCollectibleScans = { export type EndpointCollectibleScans = {
slug: string; slug: string;
thumbnail?: EndpointPayloadImage; thumbnail?: EndpointPayloadImage;
translations: { translations: {
@ -326,9 +335,9 @@ export type EndpointFolderPreview = {
}; };
pages: EndpointScanImage[]; pages: EndpointScanImage[];
parentPages: EndpointSource[]; parentPages: EndpointSource[];
}; };
export type EndpointCollectibleGallery = { export type EndpointCollectibleGallery = {
slug: string; slug: string;
thumbnail?: EndpointPayloadImage; thumbnail?: EndpointPayloadImage;
translations: { translations: {
@ -340,9 +349,9 @@ export type EndpointFolderPreview = {
}[]; }[];
images: EndpointPayloadImage[]; images: EndpointPayloadImage[];
parentPages: EndpointSource[]; parentPages: EndpointSource[];
}; };
export type EndpointCollectibleGalleryImage = { export type EndpointCollectibleGalleryImage = {
slug: string; slug: string;
translations: { translations: {
language: string; language: string;
@ -355,9 +364,9 @@ export type EndpointFolderPreview = {
previousIndex?: string; previousIndex?: string;
nextIndex?: string; nextIndex?: string;
parentPages: EndpointSource[]; parentPages: EndpointSource[];
}; };
export type EndpointCollectibleScanPage = { export type EndpointCollectibleScanPage = {
slug: string; slug: string;
translations: { translations: {
language: string; language: string;
@ -370,22 +379,22 @@ export type EndpointFolderPreview = {
previousIndex?: string; previousIndex?: string;
nextIndex?: string; nextIndex?: string;
parentPages: EndpointSource[]; parentPages: EndpointSource[];
}; };
export type EndpointScanImage = PayloadImage & { export type EndpointScanImage = PayloadImage & {
index: string; index: string;
sizes: PayloadImage[]; sizes: PayloadImage[];
}; };
export type TableOfContentEntry = { export type TableOfContentEntry = {
prefix: string; prefix: string;
title: string; title: string;
type: "sceneBreak" | "break" | "section"; type: "sceneBreak" | "break" | "section";
index: number; index: number;
children: TableOfContentEntry[]; children: TableOfContentEntry[];
}; };
export type EndpointChronologyEvent = { export type EndpointChronologyEvent = {
id: string; id: string;
date: { date: {
year: number; year: number;
@ -403,15 +412,20 @@ export type EndpointFolderPreview = {
credits: EndpointCredit[]; credits: EndpointCredit[];
}[]; }[];
}[]; }[];
}; };
export type EndpointSourcePreview = { export type EndpointSourcePreview = {
id: string; id: string;
slug: string; slug: string;
translations: { language: string; pretitle?: string; title: string; subtitle?: string }[]; translations: {
}; language: string;
pretitle?: string;
title: string;
subtitle?: string;
}[];
};
export type EndpointSource = export type EndpointSource =
| { type: "url"; url: string; label: string } | { type: "url"; url: string; label: string }
| { | {
type: "collectible"; type: "collectible";
@ -419,14 +433,17 @@ export type EndpointFolderPreview = {
range?: range?:
| { type: "page"; page: number } | { type: "page"; page: number }
| { type: "timestamp"; timestamp: string } | { type: "timestamp"; timestamp: string }
| { type: "custom"; translations: { language: string; note: string }[] }; | {
type: "custom";
translations: { language: string; note: string }[];
};
} }
| { type: "page"; page: EndpointSourcePreview } | { type: "page"; page: EndpointSourcePreview }
| { type: "folder"; folder: EndpointSourcePreview } | { type: "folder"; folder: EndpointSourcePreview }
| { type: "scans"; collectible: EndpointSourcePreview } | { type: "scans"; collectible: EndpointSourcePreview }
| { type: "gallery"; collectible: EndpointSourcePreview }; | { type: "gallery"; collectible: EndpointSourcePreview };
export type EndpointMediaPreview = { export type EndpointMediaPreview = {
id: string; id: string;
url: string; url: string;
filename: string; filename: string;
@ -438,9 +455,9 @@ export type EndpointFolderPreview = {
title: string; title: string;
subtitle?: string; subtitle?: string;
}[]; }[];
}; };
export type EndpointMedia = Omit<EndpointMediaPreview, "translations"> & { export type EndpointMedia = Omit<EndpointMediaPreview, "translations"> & {
filesize: number; filesize: number;
updatedAt: string; updatedAt: string;
createdAt: string; createdAt: string;
@ -448,42 +465,42 @@ export type EndpointFolderPreview = {
description?: RichTextContent; description?: RichTextContent;
})[]; })[];
credits: EndpointCredit[]; credits: EndpointCredit[];
}; };
export type EndpointImagePreview = EndpointMediaPreview & { export type EndpointImagePreview = EndpointMediaPreview & {
width: number; width: number;
height: number; height: number;
sizes: PayloadImage[]; sizes: PayloadImage[];
openGraph?: PayloadImage; openGraph?: PayloadImage;
}; };
export type EndpointImage = EndpointMedia & { export type EndpointImage = EndpointMedia & {
width: number; width: number;
height: number; height: number;
sizes: PayloadImage[]; sizes: PayloadImage[];
openGraph?: PayloadImage; openGraph?: PayloadImage;
}; };
export type EndpointAudioPreview = EndpointMediaPreview & { export type EndpointAudioPreview = EndpointMediaPreview & {
thumbnail?: EndpointPayloadImage; thumbnail?: EndpointPayloadImage;
duration: number; duration: number;
}; };
export type EndpointAudio = EndpointMedia & { export type EndpointAudio = EndpointMedia & {
thumbnail?: EndpointPayloadImage; thumbnail?: EndpointPayloadImage;
duration: number; duration: number;
}; };
export type EndpointVideoPreview = EndpointMediaPreview & { export type EndpointVideoPreview = EndpointMediaPreview & {
thumbnail?: EndpointPayloadImage; thumbnail?: EndpointPayloadImage;
subtitles: { subtitles: {
language: string; language: string;
url: string; url: string;
}[]; }[];
duration: number; duration: number;
}; };
export type EndpointVideo = EndpointMedia & { export type EndpointVideo = EndpointMedia & {
thumbnail?: EndpointPayloadImage; thumbnail?: EndpointPayloadImage;
subtitles: { subtitles: {
language: string; language: string;
@ -502,41 +519,41 @@ export type EndpointFolderPreview = {
publishedDate: string; publishedDate: string;
}; };
duration: number; duration: number;
}; };
export type EndpointFilePreview = EndpointMediaPreview & { export type EndpointFilePreview = EndpointMediaPreview & {
filesize: number; filesize: number;
thumbnail?: EndpointPayloadImage; thumbnail?: EndpointPayloadImage;
}; };
export type EndpointFile = EndpointMedia & { export type EndpointFile = EndpointMedia & {
filesize: number; filesize: number;
thumbnail?: EndpointPayloadImage; thumbnail?: EndpointPayloadImage;
}; };
export type EndpointPayloadImage = PayloadImage & { export type EndpointPayloadImage = PayloadImage & {
sizes: PayloadImage[]; sizes: PayloadImage[];
openGraph?: PayloadImage; openGraph?: PayloadImage;
}; };
export type PayloadMedia = { export type PayloadMedia = {
id: string; id: string;
url: string; url: string;
mimeType: string; mimeType: string;
filename: string; filename: string;
filesize: number; filesize: number;
}; };
export type PayloadImage = PayloadMedia & { export type PayloadImage = PayloadMedia & {
width: number; width: number;
height: number; height: number;
}; };
export type EndpointAllSDKUrls = { export type EndpointAllSDKUrls = {
urls: string[]; urls: string[];
}; };
export type EndpointAllIds = { export type EndpointAllIds = {
collectibles: { slugs: string[] }; collectibles: { slugs: string[] };
pages: { slugs: string[] }; pages: { slugs: string[] };
folders: { slugs: string[] }; folders: { slugs: string[] };
@ -546,5 +563,4 @@ export type EndpointFolderPreview = {
files: { ids: string[] }; files: { ids: string[] };
recorders: { ids: string[] }; recorders: { ids: string[] };
chronologyEvents: { ids: string[] }; chronologyEvents: { ids: string[] };
}; };

View File

@ -1,17 +1,17 @@
import { Collections } from "./constants";
import { import {
EndpointAudioPreview, type GenericBlock,
EndpointImagePreview, type SectionBlock,
EndpointVideoPreview, type TranscriptBlock,
} from "./endpoint-types"; type BreakBlock,
import {
GenericBlock,
SectionBlock,
TranscriptBlock,
BreakBlock,
isBlockTranscriptBlock, isBlockTranscriptBlock,
isBlockBreakBlock, isBlockBreakBlock,
} from "./blocks"; } from "./blocks";
import { Collections } from "./constants";
import type {
EndpointImagePreview,
EndpointVideoPreview,
EndpointAudioPreview,
} from "./endpoint-types";
export type RichTextContent = { export type RichTextContent = {
root: { root: {

View File

@ -1,24 +1,24 @@
import { Collections } from "./constants"; import { Collections } from "./constants";
import { import type {
EndpointAllIds, EndpointWebsiteConfig,
EndpointAllSDKUrls, EndpointFolder,
EndpointAudio, EndpointLanguage,
EndpointChronologyEvent, EndpointCurrency,
EndpointWording,
EndpointPage,
EndpointCollectible, EndpointCollectible,
EndpointCollectibleScans,
EndpointCollectibleScanPage,
EndpointCollectibleGallery, EndpointCollectibleGallery,
EndpointCollectibleGalleryImage, EndpointCollectibleGalleryImage,
EndpointCollectibleScanPage, EndpointChronologyEvent,
EndpointCollectibleScans,
EndpointCurrency,
EndpointFile,
EndpointFolder,
EndpointImage, EndpointImage,
EndpointLanguage, EndpointAudio,
EndpointPage,
EndpointRecorder,
EndpointVideo, EndpointVideo,
EndpointWebsiteConfig, EndpointFile,
EndpointWording, EndpointRecorder,
EndpointAllSDKUrls,
EndpointAllIds,
} from "./endpoint-types"; } from "./endpoint-types";
export const getSDKEndpoint = { export const getSDKEndpoint = {

View File

@ -1,4 +1,4 @@
import { Collections } from "./constants"; import type { Collections } from "./constants";
export type AfterOperationWebHookMessage = { export type AfterOperationWebHookMessage = {
collection: Collections; collection: Collections;