refactor: changed models dir to types

This commit is contained in:
Ritesh Ghosh
2024-01-19 19:56:39 +05:30
parent c4318e7361
commit 255e4823c9
25 changed files with 0 additions and 0 deletions
+113
View File
@@ -0,0 +1,113 @@
export interface Anime {
id: string | null;
name: string | null;
poster: string | null;
duration: string | null;
type: string | null;
rating: string | null;
episodes: {
sub: number | null;
dub: number | null;
};
}
type CommonAnimeProps = "id" | "name" | "poster";
export interface Top10Anime extends Pick<Anime, CommonAnimeProps | "episodes"> {
rank: number | null;
}
export type Top10AnimeTimePeriod = "day" | "week" | "month";
export interface MostPopularAnime
extends Pick<Anime, CommonAnimeProps | "episodes" | "type"> {
jname: string | null;
}
export interface SpotlightAnime
extends MostPopularAnime,
Pick<Top10Anime, "rank"> {
description: string | null;
}
export interface TrendingAnime
extends Pick<Anime, CommonAnimeProps>,
Pick<Top10Anime, "rank"> {}
export interface LatestEpisodeAnime extends Anime {}
export interface TopUpcomingAnime extends Anime {}
export interface TopAiringAnime extends MostPopularAnime {}
export interface AnimeGeneralAboutInfo
extends Pick<Anime, CommonAnimeProps>,
Pick<SpotlightAnime, "description"> {
stats: {
quality: string | null;
} & Pick<Anime, "duration" | "episodes" | "rating" | "type">;
}
export interface RecommendedAnime extends Anime {}
export interface RelatedAnime extends MostPopularAnime {}
export interface Season extends Pick<Anime, CommonAnimeProps> {
isCurrent: boolean;
title: string | null;
}
export interface AnimeSearchSuggestion
extends Omit<MostPopularAnime, "episodes" | "type"> {
moreInfo: Array<string>;
}
export interface AnimeEpisode extends Pick<Season, "title"> {
episodeId: string | null;
number: number;
isFiller: boolean;
}
export interface SubEpisode {
serverName: string;
serverId: number | null;
}
export interface DubEpisode extends SubEpisode {}
export type AnimeCategories =
| "most-favorite"
| "most-popular"
| "subbed-anime"
| "dubbed-anime"
| "recently-updated"
| "recently-added"
| "top-upcoming"
| "top-airing"
| "movie"
| "special"
| "ova"
| "ona"
| "tv"
| "completed";
export type AnimeServers =
| "vidstreaming"
| "megacloud"
| "streamsb"
| "streamtape"
| "vidcloud";
export enum Servers {
VidStreaming = "vidstreaming",
MegaCloud = "megacloud",
StreamSB = "streamsb",
StreamTape = "streamtape",
VidCloud = "vidcloud",
AsianLoad = "asianload",
GogoCDN = "gogocdn",
MixDrop = "mixdrop",
UpCloud = "upcloud",
VizCloud = "vizcloud",
MyCloud = "mycloud",
Filemoon = "filemoon",
}
+3
View File
@@ -0,0 +1,3 @@
export type AnimeAboutInfoQueryParams = {
id?: string;
};
+7
View File
@@ -0,0 +1,7 @@
export type CategoryAnimePathParams = {
category?: string;
};
export type CategoryAnimeQueryParams = {
page?: string;
};
@@ -0,0 +1,7 @@
import { type AnimeServers } from "../anime.js";
export type AnimeEpisodeSrcsQueryParams = {
id?: string;
server?: AnimeServers;
category?: "sub" | "dub";
};
+3
View File
@@ -0,0 +1,3 @@
export type AnimeEpisodePathParams = {
animeId?: string;
};
+7
View File
@@ -0,0 +1,7 @@
export type GenreAnimePathParams = {
name?: string;
};
export type GenreAnimeQueryParams = {
page?: string;
};
+7
View File
@@ -0,0 +1,7 @@
export type AnimeProducerPathParams = {
name?: string;
};
export type AnimeProducerQueryParams = {
page?: string;
};
+4
View File
@@ -0,0 +1,4 @@
export type AnimeSearchQueryParams = {
q?: string;
page?: string;
};
@@ -0,0 +1,3 @@
export type AnimeSearchSuggestQueryParams = {
q?: string;
};
+3
View File
@@ -0,0 +1,3 @@
export type EpisodeServersQueryParams = {
episodeId?: string;
};
@@ -0,0 +1,3 @@
export type EstimatedScheduleQueryParams = {
date?: string;
};
+35
View File
@@ -0,0 +1,35 @@
import type {
GenreAnimePathParams,
GenreAnimeQueryParams,
} from "./animeGenre.js";
import type {
CategoryAnimePathParams,
CategoryAnimeQueryParams,
} from "./animeCategory.js";
import type {
AnimeProducerPathParams,
AnimeProducerQueryParams,
} from "./animeProducer.js";
import type { AnimeSearchQueryParams } from "./animeSearch.js";
import type { AnimeEpisodePathParams } from "./animeEpisodes.js";
import type { EpisodeServersQueryParams } from "./episodeServers.js";
import type { AnimeAboutInfoQueryParams } from "./animeAboutInfo.js";
import type { AnimeEpisodeSrcsQueryParams } from "./animeEpisodeSrcs.js";
import type { EstimatedScheduleQueryParams } from "./estimatedSchedule.js";
import type { AnimeSearchSuggestQueryParams } from "./animeSearchSuggestion.js";
export type {
GenreAnimePathParams,
GenreAnimeQueryParams,
AnimeSearchQueryParams,
AnimeEpisodePathParams,
AnimeProducerPathParams,
CategoryAnimePathParams,
AnimeProducerQueryParams,
CategoryAnimeQueryParams,
AnimeAboutInfoQueryParams,
EpisodeServersQueryParams,
AnimeEpisodeSrcsQueryParams,
EstimatedScheduleQueryParams,
AnimeSearchSuggestQueryParams,
};
+18
View File
@@ -0,0 +1,18 @@
export interface Video {
url: string;
quality?: string;
isM3U8?: boolean;
size?: number;
[x: string]: unknown;
}
export interface Subtitle {
id?: string;
url: string;
lang: string;
}
export interface Intro {
start: number;
end: number;
}
+19
View File
@@ -0,0 +1,19 @@
import type {
Season,
RelatedAnime,
RecommendedAnime,
AnimeGeneralAboutInfo,
} from "../anime.js";
import { type HttpError } from "http-errors";
import { type ScrapedAnimeSearchResult } from "./animeSearch.js";
export interface ScrapedAnimeAboutInfo
extends Pick<ScrapedAnimeSearchResult, "mostPopularAnimes"> {
anime: {
info: AnimeGeneralAboutInfo;
moreInfo: Record<string, string | string[]>;
};
seasons: Array<Season>;
relatedAnimes: Array<RelatedAnime> | HttpError;
recommendedAnimes: Array<RecommendedAnime> | HttpError;
}
+22
View File
@@ -0,0 +1,22 @@
import type { HttpError } from "http-errors";
import type { Anime, Top10Anime } from "../anime.js";
export interface ScrapedAnimeCategory {
animes: Array<Anime> | HttpError;
genres: Array<string>;
top10Animes: {
today: Array<Top10Anime> | HttpError;
week: Array<Top10Anime> | HttpError;
month: Array<Top10Anime> | HttpError;
};
category: string;
totalPages: number;
currentPage: number;
hasNextPage: boolean;
}
export type CommonAnimeScrapeTypes =
| "animes"
| "totalPages"
| "hasNextPage"
| "currentPage";
+12
View File
@@ -0,0 +1,12 @@
import type { Intro, Subtitle, Video } from "../extractor.js";
export interface ScrapedAnimeEpisodesSources {
headers?: {
[k: string]: string;
};
intro?: Intro;
subtitles?: Subtitle[];
sources: Video[];
download?: string;
embedURL?: string;
}
+6
View File
@@ -0,0 +1,6 @@
import { type AnimeEpisode } from "../anime.js";
export interface ScrapedAnimeEpisodes {
totalEpisodes: number;
episodes: Array<AnimeEpisode>;
}
+11
View File
@@ -0,0 +1,11 @@
import type {
ScrapedAnimeCategory,
CommonAnimeScrapeTypes,
} from "./animeCategory.js";
import { type ScrapedHomePage } from "./homePage.js";
export interface ScrapedGenreAnime
extends Pick<ScrapedAnimeCategory, CommonAnimeScrapeTypes | "genres">,
Pick<ScrapedHomePage, "topAiringAnimes"> {
genreName: string;
}
+8
View File
@@ -0,0 +1,8 @@
import type { ScrapedHomePage } from "./homePage.js";
import type { ScrapedAnimeCategory } from "./animeCategory.js";
export interface ScrapedProducerAnime
extends Omit<ScrapedAnimeCategory, "genres" | "category">,
Pick<ScrapedHomePage, "topAiringAnimes"> {
producerName: string;
}
+11
View File
@@ -0,0 +1,11 @@
import type {
ScrapedAnimeCategory,
CommonAnimeScrapeTypes,
} from "./animeCategory.js";
import type { HttpError } from "http-errors";
import type { MostPopularAnime } from "../anime.js";
export interface ScrapedAnimeSearchResult
extends Pick<ScrapedAnimeCategory, CommonAnimeScrapeTypes> {
mostPopularAnimes: Array<MostPopularAnime> | HttpError;
}
@@ -0,0 +1,6 @@
import type { HttpError } from "http-errors";
import type { AnimeSearchSuggestion } from "../anime.js";
export interface ScrapedAnimeSearchSuggestion {
suggestions: Array<AnimeSearchSuggestion> | HttpError;
}
+8
View File
@@ -0,0 +1,8 @@
import type { SubEpisode, DubEpisode } from "../anime.js";
export interface ScrapedEpisodeServers {
sub: SubEpisode[];
dub: DubEpisode[];
episodeNo: number;
episodeId: string;
}
+10
View File
@@ -0,0 +1,10 @@
type EstimatedSchedule = {
id: string | null;
time: string | null;
name: string | null;
jname: string | null;
};
export type ScrapedEstimatedSchedule = {
scheduledAnimes: Array<EstimatedSchedule>;
};
+18
View File
@@ -0,0 +1,18 @@
import type {
TrendingAnime,
SpotlightAnime,
TopAiringAnime,
TopUpcomingAnime,
LatestEpisodeAnime,
} from "../anime.js";
import type { HttpError } from "http-errors";
import type { ScrapedAnimeCategory } from "./animeCategory.js";
export interface ScrapedHomePage
extends Pick<ScrapedAnimeCategory, "genres" | "top10Animes"> {
spotlightAnimes: Array<SpotlightAnime> | HttpError;
trendingAnimes: Array<TrendingAnime> | HttpError;
latestEpisodeAnimes: Array<LatestEpisodeAnime> | HttpError;
topUpcomingAnimes: Array<TopUpcomingAnime> | HttpError;
topAiringAnimes: Array<TopAiringAnime> | HttpError;
}
+25
View File
@@ -0,0 +1,25 @@
import type { ScrapedHomePage } from "./homePage.js";
import type { ScrapedGenreAnime } from "./animeGenre.js";
import type { ScrapedAnimeEpisodes } from "./animeEpisodes.js";
import type { ScrapedAnimeCategory } from "./animeCategory.js";
import type { ScrapedProducerAnime } from "./animeProducer.js";
import type { ScrapedEpisodeServers } from "./episodeServers.js";
import type { ScrapedAnimeAboutInfo } from "./animeAboutInfo.js";
import type { ScrapedAnimeSearchResult } from "./animeSearch.js";
import type { ScrapedEstimatedSchedule } from "./estimatedSchedule.js";
import type { ScrapedAnimeEpisodesSources } from "./animeEpisodeSrcs.js";
import type { ScrapedAnimeSearchSuggestion } from "./animeSearchSuggestion.js";
export type {
ScrapedHomePage,
ScrapedGenreAnime,
ScrapedAnimeEpisodes,
ScrapedProducerAnime,
ScrapedAnimeCategory,
ScrapedEpisodeServers,
ScrapedAnimeAboutInfo,
ScrapedAnimeSearchResult,
ScrapedEstimatedSchedule,
ScrapedAnimeEpisodesSources,
ScrapedAnimeSearchSuggestion,
};