From 0a2e0319a4ec1b3d0c381c0b4c86d6fe173318b8 Mon Sep 17 00:00:00 2001 From: RLAlpha49 <75044176+RLAlpha49@users.noreply.github.com> Date: Thu, 25 Apr 2024 22:34:39 -0500 Subject: [PATCH] Refactor Interfaces --- src/apis/anilist/interfaces/CoverImage.ts | 6 + src/apis/anilist/interfaces/ExternalLink.ts | 5 + src/apis/anilist/interfaces/FuzzyDate.ts | 5 + src/apis/anilist/interfaces/Image.ts | 4 + src/apis/anilist/interfaces/Media.ts | 59 +++++ src/apis/anilist/interfaces/MediaListEntry.ts | 4 + src/apis/anilist/interfaces/Name.ts | 6 + .../anilist/interfaces/NextAiringEpisode.ts | 5 + src/apis/anilist/interfaces/Ranking.ts | 10 + .../anilist/interfaces/ScoreDistribution.ts | 4 + src/apis/anilist/interfaces/Stats.ts | 7 + .../anilist/interfaces/StatusDistribution.ts | 4 + .../anilist/interfaces/StreamingEpisode.ts | 6 + src/apis/anilist/interfaces/Tag.ts | 9 + src/apis/anilist/interfaces/Title.ts | 6 + src/apis/anilist/interfaces/Trailer.ts | 5 + .../interfaces/responses/AiringSchedule.ts | 10 + .../anilist/interfaces/responses/Character.ts | 26 +++ .../anilist/interfaces/responses/Media.ts | 118 ++++++++++ .../anilist/interfaces/responses/MediaList.ts | 24 ++ .../interfaces/responses/MediaTrend.ts | 13 ++ .../anilist/interfaces/responses/Staff.ts | 53 +++++ src/apis/anilist/interfaces/responses/User.ts | 72 ++++++ src/apis/anilist/query/AiringSchedule.ts | 118 +--------- src/apis/anilist/query/Character.ts | 46 +--- src/apis/anilist/query/Media.ts | 206 +----------------- src/apis/anilist/query/MediaList.ts | 136 +----------- src/apis/anilist/query/MediaTrend.ts | 123 +---------- src/apis/anilist/query/Staff.ts | 86 +------- src/apis/anilist/query/User.ts | 75 +------ 30 files changed, 472 insertions(+), 779 deletions(-) create mode 100644 src/apis/anilist/interfaces/CoverImage.ts create mode 100644 src/apis/anilist/interfaces/ExternalLink.ts create mode 100644 src/apis/anilist/interfaces/FuzzyDate.ts create mode 100644 src/apis/anilist/interfaces/Image.ts create mode 100644 src/apis/anilist/interfaces/Media.ts create mode 100644 src/apis/anilist/interfaces/MediaListEntry.ts create mode 100644 src/apis/anilist/interfaces/Name.ts create mode 100644 src/apis/anilist/interfaces/NextAiringEpisode.ts create mode 100644 src/apis/anilist/interfaces/Ranking.ts create mode 100644 src/apis/anilist/interfaces/ScoreDistribution.ts create mode 100644 src/apis/anilist/interfaces/Stats.ts create mode 100644 src/apis/anilist/interfaces/StatusDistribution.ts create mode 100644 src/apis/anilist/interfaces/StreamingEpisode.ts create mode 100644 src/apis/anilist/interfaces/Tag.ts create mode 100644 src/apis/anilist/interfaces/Title.ts create mode 100644 src/apis/anilist/interfaces/Trailer.ts create mode 100644 src/apis/anilist/interfaces/responses/AiringSchedule.ts create mode 100644 src/apis/anilist/interfaces/responses/Character.ts create mode 100644 src/apis/anilist/interfaces/responses/Media.ts create mode 100644 src/apis/anilist/interfaces/responses/MediaList.ts create mode 100644 src/apis/anilist/interfaces/responses/MediaTrend.ts create mode 100644 src/apis/anilist/interfaces/responses/Staff.ts create mode 100644 src/apis/anilist/interfaces/responses/User.ts diff --git a/src/apis/anilist/interfaces/CoverImage.ts b/src/apis/anilist/interfaces/CoverImage.ts new file mode 100644 index 00000000..4d290beb --- /dev/null +++ b/src/apis/anilist/interfaces/CoverImage.ts @@ -0,0 +1,6 @@ +export interface CoverImage { + extraLarge: string + large: string + medium: string + color: string +} diff --git a/src/apis/anilist/interfaces/ExternalLink.ts b/src/apis/anilist/interfaces/ExternalLink.ts new file mode 100644 index 00000000..4a355317 --- /dev/null +++ b/src/apis/anilist/interfaces/ExternalLink.ts @@ -0,0 +1,5 @@ +export interface ExternalLink { + id: number + url: string + site: string +} diff --git a/src/apis/anilist/interfaces/FuzzyDate.ts b/src/apis/anilist/interfaces/FuzzyDate.ts new file mode 100644 index 00000000..a3d18128 --- /dev/null +++ b/src/apis/anilist/interfaces/FuzzyDate.ts @@ -0,0 +1,5 @@ +export interface FuzzyDate { + year: number + month: number + day: number +} diff --git a/src/apis/anilist/interfaces/Image.ts b/src/apis/anilist/interfaces/Image.ts new file mode 100644 index 00000000..cb278c77 --- /dev/null +++ b/src/apis/anilist/interfaces/Image.ts @@ -0,0 +1,4 @@ +export interface Image { + large: string + medium: string +} diff --git a/src/apis/anilist/interfaces/Media.ts b/src/apis/anilist/interfaces/Media.ts new file mode 100644 index 00000000..e01896a3 --- /dev/null +++ b/src/apis/anilist/interfaces/Media.ts @@ -0,0 +1,59 @@ +import { Title } from './Title' +import { FuzzyDate } from './FuzzyDate' +import { Trailer } from './Trailer' +import { CoverImage } from './CoverImage' +import { Tag } from './Tag' +import { NextAiringEpisode } from './NextAiringEpisode' +import { ExternalLink } from './ExternalLink' +import { StreamingEpisode } from './StreamingEpisode' +import { Ranking } from './Ranking' +import { Stats } from './Stats' +import { MediaListEntry } from './MediaListEntry' + +export interface Media { + id: number + idMal: number + title: Title + type: string + format: string + status: string + description: string + startDate: FuzzyDate + endDate: FuzzyDate + season: string + seasonYear: number + seasonInt: number + episodes?: number + duration?: number + chapters?: number + volumes?: number + countryOfOrigin: string + isLicensed: boolean + source: string + hashtag: string + trailer: Trailer + updatedAt: number + coverImage: CoverImage + bannerImage: string + genres: string[] + synonyms: string[] + averageScore: number + meanScore: number + popularity: number + isLocked: boolean + trending: number + favourites: number + tags: Tag[] + isFavourite: boolean + isAdult: boolean + nextAiringEpisode: NextAiringEpisode + externalLinks: ExternalLink[] + streamingEpisodes: StreamingEpisode[] + rankings: Ranking[] + mediaListEntry: MediaListEntry + stats: Stats + siteUrl: string + autoCreateForumThread: boolean + isRecommendationBlocked: boolean + modNotes: string +} diff --git a/src/apis/anilist/interfaces/MediaListEntry.ts b/src/apis/anilist/interfaces/MediaListEntry.ts new file mode 100644 index 00000000..d648c134 --- /dev/null +++ b/src/apis/anilist/interfaces/MediaListEntry.ts @@ -0,0 +1,4 @@ +export interface MediaListEntry { + id: number + status: string +} diff --git a/src/apis/anilist/interfaces/Name.ts b/src/apis/anilist/interfaces/Name.ts new file mode 100644 index 00000000..9bf61490 --- /dev/null +++ b/src/apis/anilist/interfaces/Name.ts @@ -0,0 +1,6 @@ +export interface Name { + first: string + last: string + full: string + native: string +} diff --git a/src/apis/anilist/interfaces/NextAiringEpisode.ts b/src/apis/anilist/interfaces/NextAiringEpisode.ts new file mode 100644 index 00000000..64971ae5 --- /dev/null +++ b/src/apis/anilist/interfaces/NextAiringEpisode.ts @@ -0,0 +1,5 @@ +export interface NextAiringEpisode { + airingAt: number + timeUntilAiring: number + episode: number +} diff --git a/src/apis/anilist/interfaces/Ranking.ts b/src/apis/anilist/interfaces/Ranking.ts new file mode 100644 index 00000000..97405175 --- /dev/null +++ b/src/apis/anilist/interfaces/Ranking.ts @@ -0,0 +1,10 @@ +export interface Ranking { + id: number + rank: number + type: string + format: string + year: number + season: string + allTime: boolean + context: string +} diff --git a/src/apis/anilist/interfaces/ScoreDistribution.ts b/src/apis/anilist/interfaces/ScoreDistribution.ts new file mode 100644 index 00000000..a8d7ba6e --- /dev/null +++ b/src/apis/anilist/interfaces/ScoreDistribution.ts @@ -0,0 +1,4 @@ +export interface ScoreDistribution { + score: number + amount: number +} diff --git a/src/apis/anilist/interfaces/Stats.ts b/src/apis/anilist/interfaces/Stats.ts new file mode 100644 index 00000000..86a5bfda --- /dev/null +++ b/src/apis/anilist/interfaces/Stats.ts @@ -0,0 +1,7 @@ +import { ScoreDistribution } from './ScoreDistribution' +import { StatusDistribution } from './StatusDistribution' + +export interface Stats { + scoreDistribution: ScoreDistribution[] + statusDistribution: StatusDistribution[] +} diff --git a/src/apis/anilist/interfaces/StatusDistribution.ts b/src/apis/anilist/interfaces/StatusDistribution.ts new file mode 100644 index 00000000..293c1693 --- /dev/null +++ b/src/apis/anilist/interfaces/StatusDistribution.ts @@ -0,0 +1,4 @@ +export interface StatusDistribution { + status: string + amount: number +} diff --git a/src/apis/anilist/interfaces/StreamingEpisode.ts b/src/apis/anilist/interfaces/StreamingEpisode.ts new file mode 100644 index 00000000..3f92b58c --- /dev/null +++ b/src/apis/anilist/interfaces/StreamingEpisode.ts @@ -0,0 +1,6 @@ +export interface StreamingEpisode { + title: string + thumbnail: string + url: string + site: string +} diff --git a/src/apis/anilist/interfaces/Tag.ts b/src/apis/anilist/interfaces/Tag.ts new file mode 100644 index 00000000..ab2cc70a --- /dev/null +++ b/src/apis/anilist/interfaces/Tag.ts @@ -0,0 +1,9 @@ +export interface Tag { + id: number + name: string + description: string + rank: number + isGeneralSpoiler: boolean + isMediaSpoiler: boolean + isAdult: boolean +} diff --git a/src/apis/anilist/interfaces/Title.ts b/src/apis/anilist/interfaces/Title.ts new file mode 100644 index 00000000..4660ecd5 --- /dev/null +++ b/src/apis/anilist/interfaces/Title.ts @@ -0,0 +1,6 @@ +export interface Title { + romaji: string + english: string + native: string + userPreferred: string +} diff --git a/src/apis/anilist/interfaces/Trailer.ts b/src/apis/anilist/interfaces/Trailer.ts new file mode 100644 index 00000000..c6a16df8 --- /dev/null +++ b/src/apis/anilist/interfaces/Trailer.ts @@ -0,0 +1,5 @@ +export interface Trailer { + id: string + site: string + thumbnail: string +} diff --git a/src/apis/anilist/interfaces/responses/AiringSchedule.ts b/src/apis/anilist/interfaces/responses/AiringSchedule.ts new file mode 100644 index 00000000..2ffdadd4 --- /dev/null +++ b/src/apis/anilist/interfaces/responses/AiringSchedule.ts @@ -0,0 +1,10 @@ +import { Media } from '../Media' + +export interface AiringScheduleResponse { + id: number + airingAt: number + timeUntilAiring: number + episode: number + mediaId: number + media: Media +} diff --git a/src/apis/anilist/interfaces/responses/Character.ts b/src/apis/anilist/interfaces/responses/Character.ts new file mode 100644 index 00000000..5c20dd5e --- /dev/null +++ b/src/apis/anilist/interfaces/responses/Character.ts @@ -0,0 +1,26 @@ +import { FuzzyDate } from '../FuzzyDate' +import { Name } from '../Name' +import { Image } from '../Image' +import { Title } from '../Title' + +export interface CharacterResponse { + id: number + name: Name + image: Image + description: string + gender: string + dateOfBirth: FuzzyDate + age: string + bloodType: string + isFavourite: boolean + isFavouriteBlocked: boolean + siteUrl: string + media: { + nodes: Array<{ + id: number + title: Title + }> + } + favourites: number + modNotes: string +} diff --git a/src/apis/anilist/interfaces/responses/Media.ts b/src/apis/anilist/interfaces/responses/Media.ts new file mode 100644 index 00000000..6b6de1ae --- /dev/null +++ b/src/apis/anilist/interfaces/responses/Media.ts @@ -0,0 +1,118 @@ +import { Title } from '../Title' +import { FuzzyDate } from '../FuzzyDate' +import { Trailer } from '../Trailer' +import { CoverImage } from '../CoverImage' +import { Tag } from '../Tag' +import { NextAiringEpisode } from '../NextAiringEpisode' +import { ExternalLink } from '../ExternalLink' +import { StreamingEpisode } from '../StreamingEpisode' +import { Ranking } from '../Ranking' +import { Stats } from '../Stats' +import { MediaListEntry } from '../MediaListEntry' +import { Name } from '../Name' +import { Image } from '../Image' + +export interface MediaResponse { + id: number + idMal: number + title: Title + type: string + format: string + status: string + description: string + startDate: FuzzyDate + endDate: FuzzyDate + season: string + seasonYear: number + seasonInt: number + episodes?: number + duration?: number + chapters?: number + volumes?: number + countryOfOrigin: string + isLicensed: boolean + source: string + hashtag: string + trailer: Trailer + updatedAt: number + coverImage: CoverImage + bannerImage: string + genres: string[] + synonyms: string[] + averageScore: number + meanScore: number + popularity: number + isLocked: boolean + trending: number + favourites: number + tags: Tag[] + relations: { + edges: Array<{ + relationType: string + node: { + id: number + title: Title + } + }> + } + characters: { + edges: Array<{ + id: number + role: string + name: string + voiceActors: Array<{ + id: number + name: Name + image: Image + }> + media: { + id: number + title: Title + coverImage: CoverImage + } + favouriteOrder: number + node: { + id: number + name: Name + image: Image + } + }> + } + staff: { + edges: Array<{ + id: number + role: string + favouriteOrder: number + node: { + id: number + name: Name + image: Image + } + }> + } + studios: { + edges: Array<{ + id: number + isMain: boolean + favouriteOrder: number + node: { + id: number + name: string + isAnimationStudio: boolean + siteUrl: string + } + }> + } + isFavourite: boolean + isAdult: boolean + nextAiringEpisode: NextAiringEpisode + externalLinks: ExternalLink[] + streamingEpisodes: StreamingEpisode[] + rankings: Ranking[] + mediaListEntry: MediaListEntry + stats: Stats + siteUrl: string + autoCreateForumThread: boolean + isRecommendationBlocked: boolean + modNotes: string +} diff --git a/src/apis/anilist/interfaces/responses/MediaList.ts b/src/apis/anilist/interfaces/responses/MediaList.ts new file mode 100644 index 00000000..ea5947c3 --- /dev/null +++ b/src/apis/anilist/interfaces/responses/MediaList.ts @@ -0,0 +1,24 @@ +import { Media } from '../Media' + +export interface MediaListResponse { + id: number + userId: number + mediaId: number + status: string + score: number + progress: number + progressVolumes: number + repeat: number + priority: number + private: boolean + notes: string + hiddenFromStatusLists: boolean + customLists: any + advancedScores: any + startedAt: any + completedAt: any + updatedAt: number + createdAt: number + media: Media + user: any +} diff --git a/src/apis/anilist/interfaces/responses/MediaTrend.ts b/src/apis/anilist/interfaces/responses/MediaTrend.ts new file mode 100644 index 00000000..5b9c78c8 --- /dev/null +++ b/src/apis/anilist/interfaces/responses/MediaTrend.ts @@ -0,0 +1,13 @@ +import { Media } from '../Media' + +export interface MediaTrendResponse { + mediaId: number + date: number + trending: number + averageScore: number + popularity: number + inProgress: number + releasing: boolean + episode: number + media: Media +} diff --git a/src/apis/anilist/interfaces/responses/Staff.ts b/src/apis/anilist/interfaces/responses/Staff.ts new file mode 100644 index 00000000..0e72f8ed --- /dev/null +++ b/src/apis/anilist/interfaces/responses/Staff.ts @@ -0,0 +1,53 @@ +import { Name } from '../Name' +import { Image } from '../Image' +import { FuzzyDate } from '../FuzzyDate' +import { Title } from '../Title' + +export interface StaffResponse { + id: number + name: Name + languageV2: string + image: Image + description: string + primaryOccupations: string[] + gender: string + dateOfBirth: FuzzyDate + dateOfDeath: FuzzyDate + age: number + yearsActive: number[] + homeTown: string + bloodType: string + isFavourite: boolean + isFavouriteBlocked: boolean + siteUrl: string + staffMedia: { + nodes: Array<{ + id: number + title: Title + }> + } + characters: { + nodes: Array<{ + id: number + name: Name + }> + } + characterMedia: { + nodes: Array<{ + id: number + title: Title + }> + } + staff: { + id: number + name: Name + } + submitter: { + id: number + name: string + } + submissionStatus: number + submissionNotes: string + favourites: number + modNotes: string +} diff --git a/src/apis/anilist/interfaces/responses/User.ts b/src/apis/anilist/interfaces/responses/User.ts new file mode 100644 index 00000000..a8c49b07 --- /dev/null +++ b/src/apis/anilist/interfaces/responses/User.ts @@ -0,0 +1,72 @@ +import { Image } from '../Image' + +export interface UserResponse { + id: number + name: string + about: string + avatar: Image + bannerImage: string + isFollowing: boolean + isFollower: boolean + isBlocked: boolean + bans: any[] + options: { + titleLanguage: string + displayAdultContent: boolean + airingNotifications: boolean + profileColor: string + notificationOptions: Array<{ + type: string + enabled: boolean + }> + timezone: string + activityMergeTime: number + staffNameLanguage: string + restrictMessagesToFollowing: boolean + disabledListActivity: Array<{ + disabled: boolean + type: string + }> + } + mediaListOptions: { + scoreFormat: string + rowOrder: string + animeList: { + sectionOrder: string[] + splitCompletedSectionByFormat: boolean + customLists: string[] + advancedScoring: string[] + advancedScoringEnabled: boolean + } + mangaList: { + sectionOrder: string[] + splitCompletedSectionByFormat: boolean + customLists: string[] + advancedScoring: string[] + advancedScoringEnabled: boolean + } + } + favourites: { + anime: any[] + manga: any[] + characters: any[] + staff: any[] + studios: any[] + } + statistics: { + anime: any + manga: any + } + unreadNotificationCount: number + siteUrl: string + donatorTier: number + donatorBadge: string + moderatorRoles: string[] + createdAt: number + updatedAt: number + previousNames: Array<{ + name: string + createdAt: number + updatedAt: number + }> +} diff --git a/src/apis/anilist/query/AiringSchedule.ts b/src/apis/anilist/query/AiringSchedule.ts index bc81a0ea..96a70d47 100644 --- a/src/apis/anilist/query/AiringSchedule.ts +++ b/src/apis/anilist/query/AiringSchedule.ts @@ -1,5 +1,6 @@ import { APIWrapper } from '../../../base/APIWrapper' import { sendRequest } from '../../../base/RequestHandler' +import { AiringScheduleResponse } from '../interfaces/responses/AiringSchedule' interface AiringScheduleVariables { id?: number @@ -23,123 +24,6 @@ interface AiringScheduleVariables { sort?: string[] } -interface AiringScheduleResponse { - id: number - airingAt: number - timeUntilAiring: number - episode: number - mediaId: number - media: { - id: number - idMal: number - title: { - romaji: string - english: string - native: string - userPreferred: string - } - type: string - format: string - status: string - description: string - startDate: { - year: number - month: number - day: number - } - endDate: { - year: number - month: number - day: number - } - season: string - seasonYear: number - seasonInt: number - episodes?: number - duration?: number - countryOfOrigin: string - isLicensed: boolean - source: string - hashtag: string - trailer: { - id: string - site: string - thumbnail: string - } - updatedAt: number - coverImage: { - extraLarge: string - large: string - medium: string - color: string - } - bannerImage: string - genres: string[] - synonyms: string[] - averageScore: number - meanScore: number - popularity: number - isLocked: boolean - trending: number - favourites: number - tags: Array<{ - id: number - name: string - description: string - rank: number - isGeneralSpoiler: boolean - isMediaSpoiler: boolean - isAdult: boolean - }> - isFavourite: boolean - isAdult: boolean - nextAiringEpisode: { - airingAt: number - timeUntilAiring: number - episode: number - } - externalLinks: Array<{ - id: number - url: string - site: string - }> - streamingEpisodes: Array<{ - title: string - thumbnail: string - url: string - site: string - }> - rankings: Array<{ - id: number - rank: number - type: string - format: string - year: number - season: string - allTime: boolean - context: string - }> - mediaListEntry: { - id: number - status: string - } - stats: { - scoreDistribution: Array<{ - score: number - amount: number - }> - statusDistribution: Array<{ - status: string - amount: number - }> - } - siteUrl: string - autoCreateForumThread: boolean - isRecommendationBlocked: boolean - modNotes: string - } -} - export class AiringScheduleQuery extends APIWrapper { constructor () { super('https://graphql.anilist.co') diff --git a/src/apis/anilist/query/Character.ts b/src/apis/anilist/query/Character.ts index 59cbd5c9..4d08f8f8 100644 --- a/src/apis/anilist/query/Character.ts +++ b/src/apis/anilist/query/Character.ts @@ -1,5 +1,6 @@ import { APIWrapper } from '../../../base/APIWrapper' import { sendRequest } from '../../../base/RequestHandler' +import { CharacterResponse } from '../interfaces/responses/Character' interface CharacterVariables { id?: number @@ -16,45 +17,6 @@ interface CharacterVariables { mediaPerPage?: number } -interface CharacterResponse { - id: number - name: { - first: string - last: string - full: string - native: string - } - image: { - large: string - medium: string - } - description: string - gender: string - dateOfBirth: { - year: number - month: number - day: number - } - age: string - bloodType: string - isFavourite: boolean - isFavouriteBlocked: boolean - siteUrl: string - media: { - nodes: Array<{ - id: number - title: { - romaji: string - english: string - native: string - userPreferred: string - } - }> - } - favourites: number - modNotes: string -} - export class CharacterQuery extends APIWrapper { constructor () { super('https://graphql.anilist.co') @@ -62,7 +24,7 @@ export class CharacterQuery extends APIWrapper { async character (variables?: CharacterVariables): Promise { const query = ` - query ($id: Int, $isBirthday: Boolean, $search: String, $id_not: Int, $id_in: [Int], $id_not_in: [Int], $sort: [CharacterSort]) { + query ($id: Int, $isBirthday: Boolean, $search: String, $id_not: Int, $id_in: [Int], $id_not_in: [Int], $sort: [CharacterSort], $asHtml: Boolean, $mediaSort: [MediaSort], $mediaOnList: Boolean, $mediaPage: Int, $mediaPerPage: Int) { Character (id: $id, isBirthday: $isBirthday, search: $search, id_not: $id_not, id_in: $id_in, id_not_in: $id_not_in, sort: $sort) { id name { @@ -75,7 +37,7 @@ export class CharacterQuery extends APIWrapper { large medium } - description(asHtml: true) + description(asHtml: $asHtml) gender dateOfBirth { year @@ -87,7 +49,7 @@ export class CharacterQuery extends APIWrapper { isFavourite isFavouriteBlocked siteUrl - media(sort: $sort, onList: $onList, page: $page, perPage: $perPage) { + media(sort: $mediaSort, onList: $mediaOnList, page: $mediaPage, perPage: $mediaPerPage) { nodes { id title { diff --git a/src/apis/anilist/query/Media.ts b/src/apis/anilist/query/Media.ts index 931b23a7..b41cf448 100644 --- a/src/apis/anilist/query/Media.ts +++ b/src/apis/anilist/query/Media.ts @@ -1,5 +1,6 @@ import { APIWrapper } from '../../../base/APIWrapper' import { sendRequest } from '../../../base/RequestHandler' +import { MediaResponse } from '../interfaces/responses/Media' interface MediaVariables { id?: number @@ -73,211 +74,6 @@ interface MediaVariables { sort?: string[] } -interface MediaResponse { - id: number - idMal: number - title: { - romaji: string - english: string - native: string - userPreferred: string - } - type: string - format: string - status: string - description: string - startDate: { - year: number - month: number - day: number - } - endDate: { - year: number - month: number - day: number - } - season: string - seasonYear: number - seasonInt: number - episodes: number - duration: number - chapters: number - volumes: number - countryOfOrigin: string - isLicensed: boolean - source: string - hashtag: string - trailer: { - id: string - site: string - thumbnail: string - } - updatedAt: number - coverImage: { - extraLarge: string - large: string - medium: string - color: string - } - bannerImage: string - genres: string[] - synonyms: string[] - averageScore: number - meanScore: number - popularity: number - isLocked: boolean - trending: number - favourites: number - tags: Array<{ - id: number - name: string - description: string - rank: number - isGeneralSpoiler: boolean - isMediaSpoiler: boolean - isAdult: boolean - }> - relations: { - edges: Array<{ - relationType: string - node: { - id: number - title: { - romaji: string - english: string - native: string - userPreferred: string - } - } - }> - } - characters: { - edges: Array<{ - id: number - role: string - name: string - voiceActors: Array<{ - id: number - name: { - first: string - last: string - full: string - native: string - } - image: { - large: string - } - }> - media: { - id: number - title: { - romaji: string - english: string - native: string - userPreferred: string - } - coverImage: { - extraLarge: string - large: string - medium: string - color: string - } - } - favouriteOrder: number - node: { - id: number - name: { - first: string - last: string - full: string - native: string - } - image: { - large: string - } - } - }> - } - staff: { - edges: Array<{ - id: number - role: string - favouriteOrder: number - node: { - id: number - name: { - first: string - last: string - full: string - native: string - } - image: { - large: string - } - } - }> - } - studios: { - edges: Array<{ - id: number - isMain: boolean - favouriteOrder: number - node: { - id: number - name: string - isAnimationStudio: boolean - siteUrl: string - } - }> - } - isFavourite: boolean - isAdult: boolean - nextAiringEpisode: { - airingAt: number - timeUntilAiring: number - episode: number - } - externalLinks: Array<{ - id: number - url: string - site: string - }> - streamingEpisodes: Array<{ - title: string - thumbnail: string - url: string - site: string - }> - rankings: Array<{ - id: number - rank: number - type: string - format: string - year: number - season: string - allTime: boolean - context: string - }> - mediaListEntry: { - id: number - status: string - } - stats: { - scoreDistribution: Array<{ - score: number - amount: number - }> - statusDistribution: Array<{ - status: string - amount: number - }> - } - siteUrl: string - autoCreateForumThread: boolean - isRecommendationBlocked: boolean - modNotes: string -} - export class MediaQuery extends APIWrapper { constructor () { super('https://graphql.anilist.co') diff --git a/src/apis/anilist/query/MediaList.ts b/src/apis/anilist/query/MediaList.ts index 38a71541..b6bab612 100644 --- a/src/apis/anilist/query/MediaList.ts +++ b/src/apis/anilist/query/MediaList.ts @@ -1,5 +1,6 @@ import { APIWrapper } from '../../../base/APIWrapper' import { sendRequest } from '../../../base/RequestHandler' +import { MediaListResponse } from '../interfaces/responses/MediaList' interface MediaListVariables { id?: number @@ -32,139 +33,6 @@ interface MediaListVariables { asHtml?: boolean } -interface MediaListResponse { - id: number - userId: number - mediaId: number - status: string - score: number - progress: number - progressVolumes: number - repeat: number - priority: number - private: boolean - notes: string - hiddenFromStatusLists: boolean - customLists: any - advancedScores: any - startedAt: any - completedAt: any - updatedAt: number - createdAt: number - media: { - id: number - idMal: number - title: { - romaji: string - english: string - native: string - userPreferred: string - } - type: string - format: string - status: string - description: string - startDate: { - year: number - month: number - day: number - } - endDate: { - year: number - month: number - day: number - } - season: string - seasonYear: number - seasonInt: number - episodes?: number - duration?: number - chapters?: number - volumes?: number - countryOfOrigin: string - isLicensed: boolean - source: string - hashtag: string - trailer: { - id: string - site: string - thumbnail: string - } - updatedAt: number - coverImage: { - extraLarge: string - large: string - medium: string - color: string - } - bannerImage: string - genres: string[] - synonyms: string[] - averageScore: number - meanScore: number - popularity: number - isLocked: boolean - trending: number - favourites: number - tags: Array<{ - id: number - name: string - description: string - rank: number - isGeneralSpoiler: boolean - isMediaSpoiler: boolean - isAdult: boolean - }> - isFavourite: boolean - isAdult: boolean - nextAiringEpisode: { - airingAt: number - timeUntilAiring: number - episode: number - } - externalLinks: Array<{ - id: number - url: string - site: string - }> - streamingEpisodes: Array<{ - title: string - thumbnail: string - url: string - site: string - }> - rankings: Array<{ - id: number - rank: number - type: string - format: string - year: number - season: string - allTime: boolean - context: string - }> - mediaListEntry: { - id: number - status: string - } - stats: { - scoreDistribution: Array<{ - score: number - amount: number - }> - statusDistribution: Array<{ - status: string - amount: number - }> - } - siteUrl: string - autoCreateForumThread: boolean - isRecommendationBlocked: boolean - modNotes: string - } - user: any -} - export class MediaListQuery extends APIWrapper { constructor () { super('https://graphql.anilist.co') @@ -318,4 +186,4 @@ export class MediaListQuery extends APIWrapper { const data = { query, variables } return await sendRequest(this.baseURL, 'POST', data) } -} \ No newline at end of file +} diff --git a/src/apis/anilist/query/MediaTrend.ts b/src/apis/anilist/query/MediaTrend.ts index a7403ec5..8a22935a 100644 --- a/src/apis/anilist/query/MediaTrend.ts +++ b/src/apis/anilist/query/MediaTrend.ts @@ -1,5 +1,6 @@ import { APIWrapper } from '../../../base/APIWrapper' import { sendRequest } from '../../../base/RequestHandler' +import { MediaTrendResponse } from '../interfaces/responses/MediaTrend' interface MediaTrendVariables { mediaId?: number @@ -30,128 +31,6 @@ interface MediaTrendVariables { type?: 'ANIME' | 'MANGA' } -interface MediaTrendResponse { - mediaId: number - date: number - trending: number - averageScore: number - popularity: number - inProgress: number - releasing: boolean - episode: number - media: { - id: number - idMal: number - title: { - romaji: string - english: string - native: string - userPreferred: string - } - type: string - format: string - status: string - description: string - startDate: { - year: number - month: number - day: number - } - endDate: { - year: number - month: number - day: number - } - season: string - seasonYear: number - seasonInt: number - episodes?: number - duration?: number - chapters?: number - volumes?: number - countryOfOrigin: string - isLicensed: boolean - source: string - hashtag: string - trailer: { - id: string - site: string - thumbnail: string - } - updatedAt: number - coverImage: { - extraLarge: string - large: string - medium: string - color: string - } - bannerImage: string - genres: string[] - synonyms: string[] - averageScore: number - meanScore: number - popularity: number - isLocked: boolean - trending: number - favourites: number - tags: Array<{ - id: number - name: string - description: string - rank: number - isGeneralSpoiler: boolean - isMediaSpoiler: boolean - isAdult: boolean - }> - isFavourite: boolean - isAdult: boolean - nextAiringEpisode: { - airingAt: number - timeUntilAiring: number - episode: number - } - externalLinks: Array<{ - id: number - url: string - site: string - }> - streamingEpisodes: Array<{ - title: string - thumbnail: string - url: string - site: string - }> - rankings: Array<{ - id: number - rank: number - type: string - format: string - year: number - season: string - allTime: boolean - context: string - }> - mediaListEntry: { - id: number - status: string - } - stats: { - scoreDistribution: Array<{ - score: number - amount: number - }> - statusDistribution: Array<{ - status: string - amount: number - }> - } - siteUrl: string - autoCreateForumThread: boolean - isRecommendationBlocked: boolean - modNotes: string - } -} - export class MediaTrendQuery extends APIWrapper { constructor () { super('https://graphql.anilist.co') diff --git a/src/apis/anilist/query/Staff.ts b/src/apis/anilist/query/Staff.ts index 0dcbbb14..271d4cfc 100644 --- a/src/apis/anilist/query/Staff.ts +++ b/src/apis/anilist/query/Staff.ts @@ -1,5 +1,6 @@ import { APIWrapper } from '../../../base/APIWrapper' import { sendRequest } from '../../../base/RequestHandler' +import { StaffResponse } from '../interfaces/responses/Staff' interface StaffVariables { id?: number @@ -24,91 +25,6 @@ interface StaffVariables { characterMediaPerPage?: number } -interface StaffResponse { - id: number - name: { - first: string - last: string - full: string - native: string - } - languageV2: string - image: { - large: string - medium: string - } - description: string - primaryOccupations: string[] - gender: string - dateOfBirth: { - year: number - month: number - day: number - } - dateOfDeath: { - year: number - month: number - day: number - } - age: number - yearsActive: number[] - homeTown: string - bloodType: string - isFavourite: boolean - isFavouriteBlocked: boolean - siteUrl: string - staffMedia: { - nodes: Array<{ - id: number - title: { - romaji: string - english: string - native: string - userPreferred: string - } - }> - } - characters: { - nodes: Array<{ - id: number - name: { - first: string - last: string - full: string - native: string - } - }> - } - characterMedia: { - nodes: Array<{ - id: number - title: { - romaji: string - english: string - native: string - userPreferred: string - } - }> - } - staff: { - id: number - name: { - first: string - last: string - full: string - native: string - } - } - submitter: { - id: number - name: string - } - submissionStatus: number - submissionNotes: string - favourites: number - modNotes: string -} - export class StaffQuery extends APIWrapper { constructor () { super('https://graphql.anilist.co') diff --git a/src/apis/anilist/query/User.ts b/src/apis/anilist/query/User.ts index b8e0e7d2..5f1f9d3a 100644 --- a/src/apis/anilist/query/User.ts +++ b/src/apis/anilist/query/User.ts @@ -1,5 +1,6 @@ import { APIWrapper } from '../../../base/APIWrapper' import { sendRequest } from '../../../base/RequestHandler' +import { UserResponse } from '../interfaces/responses/User' interface UserVariables { id?: number @@ -10,80 +11,6 @@ interface UserVariables { isHTML?: boolean } -interface UserResponse { - id: number - name: string - about: string - avatar: { - large: string - medium: string - } - bannerImage: string - isFollowing: boolean - isFollower: boolean - isBlocked: boolean - bans: any[] - options: { - titleLanguage: string - displayAdultContent: boolean - airingNotifications: boolean - profileColor: string - notificationOptions: Array<{ - type: string - enabled: boolean - }> - timezone: string - activityMergeTime: number - staffNameLanguage: string - restrictMessagesToFollowing: boolean - disabledListActivity: Array<{ - disabled: boolean - type: string - }> - } - mediaListOptions: { - scoreFormat: string - rowOrder: string - animeList: { - sectionOrder: string[] - splitCompletedSectionByFormat: boolean - customLists: string[] - advancedScoring: string[] - advancedScoringEnabled: boolean - } - mangaList: { - sectionOrder: string[] - splitCompletedSectionByFormat: boolean - customLists: string[] - advancedScoring: string[] - advancedScoringEnabled: boolean - } - } - favourites: { - anime: any[] - manga: any[] - characters: any[] - staff: any[] - studios: any[] - } - statistics: { - anime: any - manga: any - } - unreadNotificationCount: number - siteUrl: string - donatorTier: number - donatorBadge: string - moderatorRoles: string[] - createdAt: number - updatedAt: number - previousNames: Array<{ - name: string - createdAt: number - updatedAt: number - }> -} - export class UserQuery extends APIWrapper { constructor () { super('https://graphql.anilist.co')