Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Refactor queries into smaller modules
Browse files Browse the repository at this point in the history
  • Loading branch information
RLAlpha49 committed Apr 27, 2024
1 parent 6c6b10e commit 3761ac6
Show file tree
Hide file tree
Showing 33 changed files with 917 additions and 1,875 deletions.
2 changes: 1 addition & 1 deletion __tests__/anilist.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ describe('Anilist API Query', () => {
type: 'ANIME',
status: 'COMPLETED',
chunk: 1,
perChunk: 10
perChunk: 10000
}))
console.log(response)
expect(response).toBeDefined()
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "anilink-api-wrapper",
"version": "1.0.0",
"version": "1.1.0",
"description": "Anilist API Wrapper",
"main": "dist/AniLink.js",
"scripts": {
Expand Down
9 changes: 9 additions & 0 deletions src/apis/anilist/interfaces/CoverImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,12 @@ export interface CoverImage {
medium: string
color: string
}

export const CoverImageSchema = `
coverImage {
extraLarge
large
medium
color
}
`
8 changes: 8 additions & 0 deletions src/apis/anilist/interfaces/ExternalLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@ export interface ExternalLink {
url: string
site: string
}

export const ExternalLinkSchema = `
externalLinks {
id
url
site
}
`
6 changes: 6 additions & 0 deletions src/apis/anilist/interfaces/FuzzyDate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ export interface FuzzyDate {
month: number
day: number
}

export const FuzzyDateSchema = `
year
month
day
`
7 changes: 7 additions & 0 deletions src/apis/anilist/interfaces/Image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@ export interface Image {
large: string
medium: string
}

export const ImageSchema = `
image {
large
medium
}
`
7 changes: 7 additions & 0 deletions src/apis/anilist/interfaces/MediaListEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@ export interface MediaListEntry {
id: number
status: string
}

export const MediaListEntrySchema = `
mediaListEntry {
id
status
}
`
9 changes: 9 additions & 0 deletions src/apis/anilist/interfaces/Name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,12 @@ export interface Name {
alternative: string
userPreferred: string
}

export const NameSchema = `
name {
first
last
full
native
}
`
8 changes: 8 additions & 0 deletions src/apis/anilist/interfaces/NextAiringEpisode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@ export interface NextAiringEpisode {
timeUntilAiring: number
episode: number
}

export const NextAiringEpisodeSchema = `
nextAiringEpisode {
airingAt
timeUntilAiring
episode
}
`
13 changes: 13 additions & 0 deletions src/apis/anilist/interfaces/Ranking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,16 @@ export interface Ranking {
allTime: boolean
context: string
}

export const RankingSchema = `
rankings {
id
rank
type
format
year
season
allTime
context
}
`
7 changes: 7 additions & 0 deletions src/apis/anilist/interfaces/ScoreDistribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@ export interface ScoreDistribution {
score: number
amount: number
}

export const ScoreDistributionSchema = `
scoreDistribution {
score
amount
}
`
7 changes: 7 additions & 0 deletions src/apis/anilist/interfaces/StatusDistribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@ export interface StatusDistribution {
status: string
amount: number
}

export const StatusDistributionSchema = `
statusDistribution {
status
amount
}
`
9 changes: 9 additions & 0 deletions src/apis/anilist/interfaces/StreamingEpisode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,12 @@ export interface StreamingEpisode {
url: string
site: string
}

export const StreamingEpisodeSchema = `
streamingEpisodes {
title
thumbnail
url
site
}
`
10 changes: 10 additions & 0 deletions src/apis/anilist/interfaces/Tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,13 @@ export interface Tag {
isMediaSpoiler: boolean
isAdult: boolean
}

export const TagSchema = `
id
name
description
rank
isGeneralSpoiler
isMediaSpoiler
isAdult
`
9 changes: 9 additions & 0 deletions src/apis/anilist/interfaces/Title.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,12 @@ export interface Title {
native: string
userPreferred: string
}

export const TitleSchema = `
title {
romaji
english
native
userPreferred
}
`
8 changes: 8 additions & 0 deletions src/apis/anilist/interfaces/Trailer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@ export interface Trailer {
site: string
thumbnail: string
}

export const TrailerSchema = `
trailer {
id
site
thumbnail
}
`
14 changes: 14 additions & 0 deletions src/apis/anilist/interfaces/UserStats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,17 @@ export interface UserStats {
favouredYears: Favoured[]
favouredFormats: Favoured[]
}

export const UserAnimeStatsSchema = `
count
meanScore
minutesWatched
mediaIds
`

export const UserMangaStatsSchema = `
count
meanScore
chaptersRead
mediaIds
`
12 changes: 12 additions & 0 deletions src/apis/anilist/interfaces/responses/AiringSchedule.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Media } from '../Media'
import { MediaSchema } from './Media'

export interface AiringScheduleResponse {
id: number
Expand All @@ -8,3 +9,14 @@ export interface AiringScheduleResponse {
mediaId: number
media: Media
}

export const AiringScheduleSchema = `
id
airingAt
timeUntilAiring
episode
mediaId
media {
${MediaSchema}
}
`
32 changes: 28 additions & 4 deletions src/apis/anilist/interfaces/responses/Character.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FuzzyDate } from '../FuzzyDate'
import { Name } from '../Name'
import { Image } from '../Image'
import { Title } from '../Title'
import { FuzzyDate, FuzzyDateSchema } from '../FuzzyDate'
import { Name, NameSchema } from '../Name'
import { Image, ImageSchema } from '../Image'
import { Title, TitleSchema } from '../Title'

export interface CharacterResponse {
id: number
Expand All @@ -24,3 +24,27 @@ export interface CharacterResponse {
favourites: number
modNotes: string
}

export const CharacterSchema = `
id
${NameSchema}
${ImageSchema}
description(asHtml: $asHtml)
gender
dateOfBirth {
${FuzzyDateSchema}
}
age
bloodType
isFavourite
isFavouriteBlocked
siteUrl
media(sort: $mediaSort, onList: $mediaOnList, page: $mediaPage, perPage: $mediaPerPage) {
nodes {
id
${TitleSchema}
}
}
favourites
modNotes
`
Loading

0 comments on commit 3761ac6

Please sign in to comment.