split anilist.ts
This commit is contained in:
parent
21e3060c68
commit
4a73d9460d
2721
src/anilist.ts
2721
src/anilist.ts
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,56 @@
|
|||
import { Fields, Fn, UpdateOperation } from "../types/Anilist.ts"
|
||||
import { User } from "./User.ts"
|
||||
|
||||
export const ActivityReply = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** The id of the reply */
|
||||
withId() {
|
||||
query[0] = query[0].set({ subField: "id", level })
|
||||
return this
|
||||
},
|
||||
/** The id of the replies creator */
|
||||
withUserId() {
|
||||
query[0] = query[0].set({ subField: "userId", level })
|
||||
return this
|
||||
},
|
||||
/** The id of the parent activity */
|
||||
withActivityId() {
|
||||
query[0] = query[0].set({ subField: "activityId", level })
|
||||
return this
|
||||
},
|
||||
/** The reply text */
|
||||
withText(args?: { asHtml: boolean }) {
|
||||
query[0] = query[0].set({ subField: "text", level, variables: args })
|
||||
return this
|
||||
},
|
||||
/** The amount of likes the reply has */
|
||||
withLikeCount() {
|
||||
query[0] = query[0].set({ subField: "likeCount", level })
|
||||
return this
|
||||
},
|
||||
/** If the currently authenticated user liked the reply */
|
||||
withIsLiked() {
|
||||
query[0] = query[0].set({ subField: "isLiked", level })
|
||||
return this
|
||||
},
|
||||
/** The time the reply was created at */
|
||||
withCreatedAt() {
|
||||
query[0] = query[0].set({ subField: "createdAt", level })
|
||||
return this
|
||||
},
|
||||
/** The user who created reply */
|
||||
withUser(fn: Fn<typeof User>) {
|
||||
query[0] = query[0].set({ subField: "user", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The users who liked the reply */
|
||||
withLikes(fn: Fn<typeof User>) {
|
||||
query[0] = query[0].set({ subField: "likes", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
})
|
|
@ -0,0 +1,79 @@
|
|||
import { PageInfo } from "../anilist.ts"
|
||||
import { Fields, Fn, UpdateOperation } from "../types/Anilist.ts"
|
||||
import { Media } from "./Media.ts"
|
||||
|
||||
const AiringScheduleEdge = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
withNode(fn: Fn<typeof AiringSchedule>) {
|
||||
query[0] = query[0].set({ subField: "node", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(AiringSchedule({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The id of the connection */
|
||||
withId() {
|
||||
query[0] = query[0].set({ subField: "id", level })
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
export const AiringScheduleConnection = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
withEdges(fn: Fn<typeof AiringScheduleEdge>) {
|
||||
query[0] = query[0].set({ subField: "edges", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(AiringScheduleEdge({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withNodes(fn: Fn<typeof AiringSchedule>) {
|
||||
query[0] = query[0].set({ subField: "nodes", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(AiringSchedule({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The pagination information */
|
||||
withPageInfo(fn: Fn<typeof PageInfo>) {
|
||||
query[0] = query[0].set({ subField: "pageInfo", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(PageInfo({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
export const AiringSchedule = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** The id of the airing schedule item */
|
||||
withId() {
|
||||
query[0] = query[0].set({ subField: "id", level })
|
||||
return this
|
||||
},
|
||||
/** The time the episode airs at */
|
||||
withAiringAt() {
|
||||
query[0] = query[0].set({ subField: "airingAt", level })
|
||||
return this
|
||||
},
|
||||
/** Seconds until episode starts airing */
|
||||
withTimeUntilAiring() {
|
||||
query[0] = query[0].set({ subField: "timeUntilAiring", level })
|
||||
return this
|
||||
},
|
||||
/** The airing episode number */
|
||||
withEpisode() {
|
||||
query[0] = query[0].set({ subField: "episode", level })
|
||||
return this
|
||||
},
|
||||
/** The associate media id of the airing episode */
|
||||
withMediaId() {
|
||||
query[0] = query[0].set({ subField: "mediaId", level })
|
||||
return this
|
||||
},
|
||||
/** The associate media of the airing episode */
|
||||
withMedia(fn: Fn<typeof Media>) {
|
||||
query[0] = query[0].set({ subField: "media", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
})
|
|
@ -0,0 +1,20 @@
|
|||
import { Fields, Fn, UpdateOperation } from "../types/Anilist.ts"
|
||||
import { User } from "./User.ts"
|
||||
|
||||
export const AniChartUser = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
withUser(fn: Fn<typeof User>) {
|
||||
query[0] = query[0].set({ subField: "user", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withSettings() {
|
||||
query[0] = query[0].set({ subField: "settings", level })
|
||||
return this
|
||||
},
|
||||
withHighlights() {
|
||||
query[0] = query[0].set({ subField: "highlights", level })
|
||||
return this
|
||||
},
|
||||
})
|
|
@ -0,0 +1,232 @@
|
|||
import {
|
||||
CharacterEdgeVoiceActorRolesArgs,
|
||||
CharacterEdgeVoiceActorsArgs,
|
||||
CharacterMediaArgs,
|
||||
} from "../types/generated/graphql.ts"
|
||||
import { Fields, Fn, UpdateOperation } from "../types/Anilist.ts"
|
||||
import { FuzzyDate, PageInfo } from "../anilist.ts"
|
||||
import { Media, MediaConnection } from "./Media.ts"
|
||||
import { Staff, StaffRoleType } from "./Staff.ts"
|
||||
|
||||
const CharacterName = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** The person's given name */
|
||||
withFirst() {
|
||||
query[0] = query[0].set({ subField: "first", level })
|
||||
return this
|
||||
},
|
||||
/** The person's middle name */
|
||||
withMiddle() {
|
||||
query[0] = query[0].set({ subField: "middle", level })
|
||||
return this
|
||||
},
|
||||
/** The person's surname */
|
||||
withLast() {
|
||||
query[0] = query[0].set({ subField: "last", level })
|
||||
return this
|
||||
},
|
||||
/** The person's first and last name */
|
||||
withFull() {
|
||||
query[0] = query[0].set({ subField: "full", level })
|
||||
return this
|
||||
},
|
||||
/** The person's full name in their native language */
|
||||
withNative() {
|
||||
query[0] = query[0].set({ subField: "native", level })
|
||||
return this
|
||||
},
|
||||
/** Other names the staff member might be referred to as (pen names) */
|
||||
withAlternative() {
|
||||
query[0] = query[0].set({ subField: "alternative", level })
|
||||
return this
|
||||
},
|
||||
/** The currently authenticated users preferred name language. Default romaji for non-authenticated */
|
||||
withUserPreferred() {
|
||||
query[0] = query[0].set({ subField: "userPreferred", level })
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
const CharacterImage = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** The person's image of media at its largest size */
|
||||
withLarge() {
|
||||
query[0] = query[0].set({ subField: "large", level })
|
||||
return this
|
||||
},
|
||||
/** The person's image of media at medium size */
|
||||
withMedium() {
|
||||
query[0] = query[0].set({ subField: "medium", level })
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
const CharacterEdge = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
withNode(fn: Fn<typeof Character>) {
|
||||
query[0] = query[0].set({ subField: "node", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(Character({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The id of the connection */
|
||||
withId() {
|
||||
query[0] = query[0].set({ subField: "id", level })
|
||||
return this
|
||||
},
|
||||
/** The characters role in the media */
|
||||
withRole() {
|
||||
query[0] = query[0].set({ subField: "role", level })
|
||||
return this
|
||||
},
|
||||
/** Media specific character name */
|
||||
withName() {
|
||||
query[0] = query[0].set({ subField: "name", level })
|
||||
return this
|
||||
},
|
||||
/** The voice actors of the character */
|
||||
withVoiceActors(args: CharacterEdgeVoiceActorsArgs | undefined, fn: Fn<typeof Staff>) {
|
||||
query[0] = query[0].set({ subField: "voiceActors", level, variables: args, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(Staff({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The voice actors of the character with role date */
|
||||
withVoiceActorRoles(
|
||||
args: CharacterEdgeVoiceActorRolesArgs | undefined,
|
||||
fn: Fn<typeof StaffRoleType>,
|
||||
) {
|
||||
query[0] = query[0].set({
|
||||
subField: "voiceActorRoles",
|
||||
level,
|
||||
variables: args,
|
||||
hasSubField: true,
|
||||
})
|
||||
let tmpQuery
|
||||
fn(StaffRoleType({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The media the character is in */
|
||||
withMedia(fn: Fn<typeof Media>) {
|
||||
query[0] = query[0].set({ subField: "media", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The order the character should be displayed from the users favourites */
|
||||
withFavouriteOrder() {
|
||||
query[0] = query[0].set({ subField: "favouriteOrder", level })
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
export const CharacterConnection = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
withEdges(fn: Fn<typeof CharacterEdge>) {
|
||||
query[0] = query[0].set({ subField: "edges", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(CharacterEdge({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withNodes(fn: Fn<typeof Character>) {
|
||||
query[0] = query[0].set({ subField: "nodes", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(Character({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The pagination information */
|
||||
withPageInfo(fn: Fn<typeof PageInfo>) {
|
||||
query[0] = query[0].set({ subField: "pageInfo", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(PageInfo({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
export const Character = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** The id of the character */
|
||||
withId() {
|
||||
query[0] = query[0].set({ subField: "id", level })
|
||||
return this
|
||||
},
|
||||
/** The names of the character */
|
||||
withName(fn: Fn<typeof CharacterName>) {
|
||||
query[0] = query[0].set({ subField: "name", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(CharacterName({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** Character images */
|
||||
withImage(fn: Fn<typeof CharacterImage>) {
|
||||
query[0] = query[0].set({ subField: "image", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(CharacterImage({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** A general description of the character */
|
||||
withDescription(args?: { asHtml: boolean }) {
|
||||
query[0] = query[0].set({ subField: "description", level, variables: args })
|
||||
return this
|
||||
},
|
||||
/** The character's gender. Usually Male, Female, or Non-binary but can be any string. */
|
||||
withGender() {
|
||||
query[0] = query[0].set({ subField: "gender", level })
|
||||
return this
|
||||
},
|
||||
/** The character's birth date */
|
||||
withDateOfBirth(fn: Fn<typeof FuzzyDate>) {
|
||||
query[0] = query[0].set({ subField: "dateOfBirth", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(FuzzyDate({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The character's age. Note this is a string, not an int, it may contain further text and additional ages. */
|
||||
withAge() {
|
||||
query[0] = query[0].set({ subField: "age", level })
|
||||
return this
|
||||
},
|
||||
/** The characters blood type */
|
||||
withBloodType() {
|
||||
query[0] = query[0].set({ subField: "bloodType", level })
|
||||
return this
|
||||
},
|
||||
/** If the character is marked as favourite by the currently authenticated user */
|
||||
withIsFavourite() {
|
||||
query[0] = query[0].set({ subField: "isFavourite", level })
|
||||
return this
|
||||
},
|
||||
/** If the character is blocked from being added to favourites */
|
||||
withIsFavouriteBlocked() {
|
||||
query[0] = query[0].set({ subField: "isFavouriteBlocked", level })
|
||||
return this
|
||||
},
|
||||
/** The url for the character page on the AniList website */
|
||||
withSiteUrl() {
|
||||
query[0] = query[0].set({ subField: "siteUrl", level })
|
||||
return this
|
||||
},
|
||||
/** Media that includes the character */
|
||||
withMedia(args: CharacterMediaArgs | undefined, fn: Fn<typeof MediaConnection>) {
|
||||
query[0] = query[0].set({ subField: "media", level, variables: args, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(MediaConnection({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The amount of user's who have favourited the character */
|
||||
withFavourites() {
|
||||
query[0] = query[0].set({ subField: "favourites", level })
|
||||
return this
|
||||
},
|
||||
/** Notes for site moderators */
|
||||
withModNotes() {
|
||||
query[0] = query[0].set({ subField: "modNotes", level })
|
||||
return this
|
||||
},
|
||||
})
|
|
@ -0,0 +1,50 @@
|
|||
import { Fields, UpdateOperation } from "../types/Anilist.ts"
|
||||
|
||||
export const ExternalLinkSourceCollection = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** The id of the external link */
|
||||
withId() {
|
||||
query[0] = query[0].set({ subField: "id", level })
|
||||
return this
|
||||
},
|
||||
/** The url of the external link or base url of link source */
|
||||
withUrl() {
|
||||
query[0] = query[0].set({ subField: "url", level })
|
||||
return this
|
||||
},
|
||||
/** The links website site name */
|
||||
withSite() {
|
||||
query[0] = query[0].set({ subField: "site", level })
|
||||
return this
|
||||
},
|
||||
/** The links website site id */
|
||||
withSiteId() {
|
||||
query[0] = query[0].set({ subField: "siteId", level })
|
||||
return this
|
||||
},
|
||||
withType() {
|
||||
query[0] = query[0].set({ subField: "type", level })
|
||||
return this
|
||||
},
|
||||
/** Language the site content is in. See Staff language field for values. */
|
||||
withLanguage() {
|
||||
query[0] = query[0].set({ subField: "language", level })
|
||||
return this
|
||||
},
|
||||
withColor() {
|
||||
query[0] = query[0].set({ subField: "color", level })
|
||||
return this
|
||||
},
|
||||
/** The icon image url of the site. Not available for all links. Transparent PNG 64x64 */
|
||||
withIcon() {
|
||||
query[0] = query[0].set({ subField: "icon", level })
|
||||
return this
|
||||
},
|
||||
withNotes() {
|
||||
query[0] = query[0].set({ subField: "notes", level })
|
||||
return this
|
||||
},
|
||||
withIsDisabled() {
|
||||
query[0] = query[0].set({ subField: "isDisabled", level })
|
||||
return this
|
||||
},
|
||||
})
|
|
@ -0,0 +1,9 @@
|
|||
import { Fields, UpdateOperation } from "../types/Anilist.ts"
|
||||
|
||||
export const Markdown = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** The parsed markdown as html */
|
||||
withHtml() {
|
||||
query[0] = query[0].set({ subField: "html", level })
|
||||
return this
|
||||
},
|
||||
})
|
|
@ -0,0 +1,760 @@
|
|||
import {
|
||||
MediaAiringScheduleArgs,
|
||||
MediaCharactersArgs,
|
||||
MediaDescriptionArgs,
|
||||
MediaEdgeRelationTypeArgs,
|
||||
MediaEdgeVoiceActorRolesArgs,
|
||||
MediaEdgeVoiceActorsArgs,
|
||||
MediaRecommendationsArgs,
|
||||
MediaReviewsArgs,
|
||||
MediaSourceArgs,
|
||||
MediaStaffArgs,
|
||||
MediaStatusArgs,
|
||||
MediaStudiosArgs,
|
||||
MediaTrendsArgs,
|
||||
} from "../types/generated/graphql.ts"
|
||||
import { Fields, Fn, UpdateOperation } from "../types/Anilist.ts"
|
||||
import type { AtLeastOne } from "../types/AtLeastOne.ts"
|
||||
import { FuzzyDate, PageInfo } from "../anilist.ts"
|
||||
import { MediaTag } from "./MediaTag.ts"
|
||||
import { MediaList } from "./MediaList.ts"
|
||||
import { AiringSchedule, AiringScheduleConnection } from "./AiringSchedule.ts"
|
||||
import { Character, CharacterConnection } from "./Character.ts"
|
||||
import { Staff, StaffConnection, StaffRoleType } from "./Staff.ts"
|
||||
import { MediaTrendConnection } from "./MediaTrend.ts"
|
||||
import { RecommendationConnection } from "./Recommendation.ts"
|
||||
import { ReviewConnection } from "./Review.ts"
|
||||
import { StudioConnection } from "./Studio.ts"
|
||||
|
||||
export const MediaListGroup = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** Media list entries */
|
||||
withEntries(fn: Fn<typeof MediaList>) {
|
||||
query[0] = query[0].set({ subField: "entries", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(MediaList({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withName() {
|
||||
query[0] = query[0].set({ subField: "name", level })
|
||||
return this
|
||||
},
|
||||
withIsCustomList() {
|
||||
query[0] = query[0].set({ subField: "isCustomList", level })
|
||||
return this
|
||||
},
|
||||
withIsSplitCompletedList() {
|
||||
query[0] = query[0].set({ subField: "isSplitCompletedList", level })
|
||||
return this
|
||||
},
|
||||
withStatus() {
|
||||
query[0] = query[0].set({ subField: "status", level })
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
const MediaTitle = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** The romanization of the native language title */
|
||||
romaji(args?: { stylised: boolean }) {
|
||||
query[0] = query[0].set({ subField: "romaji", level, variables: args })
|
||||
return this
|
||||
},
|
||||
/** The official english title */
|
||||
english(args?: { stylised: boolean }) {
|
||||
query[0] = query[0].set({ subField: "english", level, variables: args })
|
||||
return this
|
||||
},
|
||||
/** Official title in it's native language */
|
||||
native(args?: { stylised: boolean }) {
|
||||
query[0] = query[0].set({ subField: "native", level, variables: args })
|
||||
return this
|
||||
},
|
||||
/** The currently authenticated users preferred title language. Default romaji for non-authenticated */
|
||||
userPreferred() {
|
||||
query[0] = query[0].set({ subField: "userPreferred", level })
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
const MediaTrailer = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** The trailer video id */
|
||||
withId() {
|
||||
query[0] = query[0].set({ subField: "id", level })
|
||||
return this
|
||||
},
|
||||
/** The site the video is hosted by (Currently either youtube or dailymotion) */
|
||||
withSite() {
|
||||
query[0] = query[0].set({ subField: "site", level })
|
||||
return this
|
||||
},
|
||||
/** The url for the thumbnail image of the video */
|
||||
withThumbnail() {
|
||||
query[0] = query[0].set({ subField: "thumbnail", level })
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
const MediaCoverImage = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** The cover image url of the media at its largest size. If this size isn't available, large will be provided instead. */
|
||||
withExtraLarge() {
|
||||
query[0] = query[0].set({ subField: "extraLarge", level })
|
||||
return this
|
||||
},
|
||||
/** The cover image url of the media at a large size */
|
||||
withLarge() {
|
||||
query[0] = query[0].set({ subField: "large", level })
|
||||
return this
|
||||
},
|
||||
/** The cover image url of the media at medium size */
|
||||
withMedium() {
|
||||
query[0] = query[0].set({ subField: "medium", level })
|
||||
return this
|
||||
},
|
||||
/** Average #hex color of cover image */
|
||||
withColor() {
|
||||
query[0] = query[0].set({ subField: "color", level })
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
const MediaExternalLink = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** The id of the external link */
|
||||
withId() {
|
||||
query[0] = query[0].set({ subField: "id", level })
|
||||
return this
|
||||
},
|
||||
/** The url of the external link or base url of link source */
|
||||
withUrl() {
|
||||
query[0] = query[0].set({ subField: "url", level })
|
||||
return this
|
||||
},
|
||||
/** The links website site name */
|
||||
withSite() {
|
||||
query[0] = query[0].set({ subField: "site", level })
|
||||
return this
|
||||
},
|
||||
/** The links website site id */
|
||||
withSiteId() {
|
||||
query[0] = query[0].set({ subField: "siteId", level })
|
||||
return this
|
||||
},
|
||||
withType() {
|
||||
query[0] = query[0].set({ subField: "type", level })
|
||||
return this
|
||||
},
|
||||
/** Language the site content is in. See Staff language field for values. */
|
||||
withLanguage() {
|
||||
query[0] = query[0].set({ subField: "language", level })
|
||||
return this
|
||||
},
|
||||
withColor() {
|
||||
query[0] = query[0].set({ subField: "color", level })
|
||||
return this
|
||||
},
|
||||
/** The icon image url of the site. Not available for all links. Transparent PNG 64x64 */
|
||||
withIcon() {
|
||||
query[0] = query[0].set({ subField: "icon", level })
|
||||
return this
|
||||
},
|
||||
withNotes() {
|
||||
query[0] = query[0].set({ subField: "notes", level })
|
||||
return this
|
||||
},
|
||||
withIsDisabled() {
|
||||
query[0] = query[0].set({ subField: "isDisabled", level })
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
const MediaStreamingEpisode = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** Title of the episode */
|
||||
withTitle() {
|
||||
query[0] = query[0].set({ subField: "title", level })
|
||||
return this
|
||||
},
|
||||
/** Url of episode image thumbnail */
|
||||
withThumbnail() {
|
||||
query[0] = query[0].set({ subField: "thumbnail", level })
|
||||
return this
|
||||
},
|
||||
/** The url of the episode */
|
||||
withUrl() {
|
||||
query[0] = query[0].set({ subField: "url", level })
|
||||
return this
|
||||
},
|
||||
/** The site location of the streaming episodes */
|
||||
withSite() {
|
||||
query[0] = query[0].set({ subField: "site", level })
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
const MediaRank = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** The id of the rank */
|
||||
withId() {
|
||||
query[0] = query[0].set({ subField: "id", level })
|
||||
return this
|
||||
},
|
||||
/** The numerical rank of the media */
|
||||
withRank() {
|
||||
query[0] = query[0].set({ subField: "rank", level })
|
||||
return this
|
||||
},
|
||||
/** The type of ranking */
|
||||
withType() {
|
||||
query[0] = query[0].set({ subField: "type", level })
|
||||
return this
|
||||
},
|
||||
/** The format the media is ranked within */
|
||||
withFormat() {
|
||||
query[0] = query[0].set({ subField: "format", level })
|
||||
return this
|
||||
},
|
||||
/** The year the media is ranked within */
|
||||
withYear() {
|
||||
query[0] = query[0].set({ subField: "year", level })
|
||||
return this
|
||||
},
|
||||
/** The season the media is ranked within */
|
||||
withSeason() {
|
||||
query[0] = query[0].set({ subField: "season", level })
|
||||
return this
|
||||
},
|
||||
/** If the ranking is based on all time instead of a season/year */
|
||||
withAllTime() {
|
||||
query[0] = query[0].set({ subField: "allTime", level })
|
||||
return this
|
||||
},
|
||||
/** String that gives context to the ranking type and time span */
|
||||
withContext() {
|
||||
query[0] = query[0].set({ subField: "context", level })
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
const MediaStats = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
scoreDistribution(fn: Fn<typeof ScoreDistribution>) {
|
||||
query[0] = query[0].set({ subField: "scoreDistribution", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(ScoreDistribution({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
statusDistribution(fn: Fn<typeof StatusDistribution>) {
|
||||
query[0] = query[0].set({ subField: "statusDistribution", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(StatusDistribution({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
const StatusDistribution = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
withStatus() {
|
||||
query[0] = query[0].set({ subField: "status", level })
|
||||
return this
|
||||
},
|
||||
withAmount() {
|
||||
query[0] = query[0].set({ subField: "amount", level })
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
const ScoreDistribution = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
withScore() {
|
||||
query[0] = query[0].set({ subField: "score", level })
|
||||
return this
|
||||
},
|
||||
withAmount() {
|
||||
query[0] = query[0].set({ subField: "amount", level })
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
const MediaEdge = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
withNode(fn: Fn<typeof Media>) {
|
||||
query[0] = query[0].set({ subField: "node", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The id of the connection */
|
||||
withId() {
|
||||
query[0] = query[0].set({ subField: "id", level })
|
||||
return this
|
||||
},
|
||||
/** The type of relation to the parent model */
|
||||
withRelationType(args?: MediaEdgeRelationTypeArgs) {
|
||||
query[0] = query[0].set({ subField: "relationType", level, variables: args })
|
||||
return this
|
||||
},
|
||||
/** If the studio is the main animation studio of the media (For Studio->MediaConnection field only) */
|
||||
withIsMainStudio() {
|
||||
query[0] = query[0].set({ subField: "isMainStudio", level })
|
||||
return this
|
||||
},
|
||||
/** The characters in the media voiced by the parent actor */
|
||||
withCharacters(fn: Fn<typeof Character>) {
|
||||
query[0] = query[0].set({ subField: "characters", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(Character({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The characters role in the media */
|
||||
withCharacterRole() {
|
||||
query[0] = query[0].set({ subField: "characterRole", level })
|
||||
return this
|
||||
},
|
||||
/** Media specific character name */
|
||||
withCharacterName() {
|
||||
query[0] = query[0].set({ subField: "characterName", level })
|
||||
return this
|
||||
},
|
||||
/** Notes regarding the VA's role for the character */
|
||||
withRoleNotes() {
|
||||
query[0] = query[0].set({ subField: "roleNotes", level })
|
||||
return this
|
||||
},
|
||||
/** Used for grouping roles where multiple dubs exist for the same language. Either dubbing company name or language variant. */
|
||||
withDubGroup() {
|
||||
query[0] = query[0].set({ subField: "dubGroup", level })
|
||||
return this
|
||||
},
|
||||
/** The role of the staff member in the production of the media */
|
||||
withStaffRole() {
|
||||
query[0] = query[0].set({ subField: "staffRole", level })
|
||||
return this
|
||||
},
|
||||
/** The voice actors of the character */
|
||||
withVoiceActors(args: MediaEdgeVoiceActorsArgs | undefined, fn: Fn<typeof Staff>) {
|
||||
query[0] = query[0].set({ subField: "voiceActors", level, variables: args, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(Staff({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The voice actors of the character with role date */
|
||||
withVoiceActorRoles(
|
||||
args: MediaEdgeVoiceActorRolesArgs | undefined,
|
||||
fn: Fn<typeof StaffRoleType>,
|
||||
) {
|
||||
query[0] = query[0].set({
|
||||
subField: "voiceActorRoles",
|
||||
level,
|
||||
variables: args,
|
||||
hasSubField: true,
|
||||
})
|
||||
let tmpQuery
|
||||
fn(StaffRoleType({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The order the media should be displayed from the users favourites */
|
||||
withFavouriteOrder() {
|
||||
query[0] = query[0].set({ subField: "favouriteOrder", level })
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
export const MediaConnection = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
withEdges(fn: Fn<typeof MediaEdge>) {
|
||||
query[0] = query[0].set({ subField: "edges", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(MediaEdge({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withNodes(fn: Fn<typeof Media>) {
|
||||
query[0] = query[0].set({ subField: "nodes", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The pagination information */
|
||||
withPageInfo(fn: Fn<typeof PageInfo>) {
|
||||
query[0] = query[0].set({ subField: "pageInfo", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(PageInfo({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
export const Media = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** The id of the media */
|
||||
withId() {
|
||||
query[0] = query[0].set({ subField: "id", level })
|
||||
return this
|
||||
},
|
||||
/** The mal id of the media */
|
||||
withIdMal() {
|
||||
query[0] = query[0].set({ subField: "idMal", level })
|
||||
return this
|
||||
},
|
||||
/** The type of the media; anime or manga */
|
||||
withType() {
|
||||
query[0] = query[0].set({ subField: "type", level })
|
||||
return this
|
||||
},
|
||||
/** The format the media was released in */
|
||||
withFormat() {
|
||||
query[0] = query[0].set({ subField: "format", level })
|
||||
return this
|
||||
},
|
||||
/** The season the media was initially released in */
|
||||
withSeason() {
|
||||
query[0] = query[0].set({ subField: "season", level })
|
||||
return this
|
||||
},
|
||||
/** The season year the media was initially released in */
|
||||
withSeasonYear() {
|
||||
query[0] = query[0].set({ subField: "seasonYear", level })
|
||||
return this
|
||||
},
|
||||
/** The year & season the media was initially released in */
|
||||
withSeasonInt() {
|
||||
query[0] = query[0].set({ subField: "seasonInt", level })
|
||||
return this
|
||||
},
|
||||
/** The amount of episodes the anime has when complete */
|
||||
withEpisodes() {
|
||||
query[0] = query[0].set({ subField: "episodes", level })
|
||||
return this
|
||||
},
|
||||
/** The general length of each anime episode in minutes */
|
||||
withDuration() {
|
||||
query[0] = query[0].set({ subField: "duration", level })
|
||||
return this
|
||||
},
|
||||
/** The amount of chapters the manga has when complete */
|
||||
withChapters() {
|
||||
query[0] = query[0].set({ subField: "chapters", level })
|
||||
return this
|
||||
},
|
||||
/** The amount of volumes the manga has when complete */
|
||||
withVolumes() {
|
||||
query[0] = query[0].set({ subField: "volumes", level })
|
||||
return this
|
||||
},
|
||||
/** Where the media was created. (ISO 3166-1 alpha-2) */
|
||||
withCountryOfOrigin() {
|
||||
query[0] = query[0].set({ subField: "countryOfOrigin", level })
|
||||
return this
|
||||
},
|
||||
/** If the media is officially licensed or a self-published doujin release */
|
||||
withIsLicensed() {
|
||||
query[0] = query[0].set({ subField: "isLicensed", level })
|
||||
return this
|
||||
},
|
||||
/** Official Twitter hashtags for the media */
|
||||
withHashtag() {
|
||||
query[0] = query[0].set({ subField: "hashtag", level })
|
||||
return this
|
||||
},
|
||||
/** When the media's data was last updated */
|
||||
withUpdatedAt() {
|
||||
query[0] = query[0].set({ subField: "updatedAt", level })
|
||||
return this
|
||||
},
|
||||
/** The banner image of the media */
|
||||
withBannerImage() {
|
||||
query[0] = query[0].set({ subField: "bannerImage", level })
|
||||
return this
|
||||
},
|
||||
/** The genres of the media */
|
||||
withGenres() {
|
||||
query[0] = query[0].set({ subField: "genres", level })
|
||||
return this
|
||||
},
|
||||
/** Alternative titles of the media */
|
||||
withSynonyms() {
|
||||
query[0] = query[0].set({ subField: "synonyms", level })
|
||||
return this
|
||||
},
|
||||
/** A weighted average score of all the user's scores of the media */
|
||||
withAverageScore() {
|
||||
query[0] = query[0].set({ subField: "averageScore", level })
|
||||
return this
|
||||
},
|
||||
/** Mean score of all the user's scores of the media */
|
||||
withMeanScore() {
|
||||
query[0] = query[0].set({ subField: "meanScore", level })
|
||||
return this
|
||||
},
|
||||
/** The number of users with the media on their list */
|
||||
withPopularity() {
|
||||
query[0] = query[0].set({ subField: "popularity", level })
|
||||
return this
|
||||
},
|
||||
/** Locked media may not be added to lists our favorited. This may be due to the entry pending for deletion or other reasons. */
|
||||
withIsLocked() {
|
||||
query[0] = query[0].set({ subField: "isLocked", level })
|
||||
return this
|
||||
},
|
||||
/** The amount of related activity in the past hour */
|
||||
withTrending() {
|
||||
query[0] = query[0].set({ subField: "trending", level })
|
||||
return this
|
||||
},
|
||||
/** The amount of user's who have favourited the media */
|
||||
withFavourites() {
|
||||
query[0] = query[0].set({ subField: "favourites", level })
|
||||
return this
|
||||
},
|
||||
/** If the media is marked as favourite by the current authenticated user */
|
||||
withIsFavourite() {
|
||||
query[0] = query[0].set({ subField: "isFavourite", level })
|
||||
return this
|
||||
},
|
||||
/** If the media is blocked from being added to favourites */
|
||||
withIsFavouriteBlocked() {
|
||||
query[0] = query[0].set({ subField: "isFavouriteBlocked", level })
|
||||
return this
|
||||
},
|
||||
/** If the media is intended only for 18+ adult audiences */
|
||||
withIsAdult() {
|
||||
query[0] = query[0].set({ subField: "isAdult", level })
|
||||
return this
|
||||
},
|
||||
/** The media's next episode airing schedule */
|
||||
withNextAiringEpisode(fn: Fn<typeof AiringSchedule>) {
|
||||
query[0] = query[0].set({ subField: "nextAiringEpisode", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(AiringSchedule({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The url for the media page on the AniList website */
|
||||
withSiteUrl() {
|
||||
query[0] = query[0].set({ subField: "siteUrl", level })
|
||||
return this
|
||||
},
|
||||
/** If the media should have forum thread automatically created for it on airing episode release */
|
||||
withAutoCreateForumThread() {
|
||||
query[0] = query[0].set({ subField: "autoCreateForumThread", level })
|
||||
return this
|
||||
},
|
||||
/** If the media is blocked from being recommended to/from */
|
||||
withIsRecommendationBlocked() {
|
||||
query[0] = query[0].set({ subField: "isRecommendationBlocked", level })
|
||||
return this
|
||||
},
|
||||
/** If the media is blocked from being reviewed */
|
||||
withIsReviewBlocked() {
|
||||
query[0] = query[0].set({ subField: "isReviewBlocked", level })
|
||||
return this
|
||||
},
|
||||
/** Notes for site moderators */
|
||||
withModNotes() {
|
||||
query[0] = query[0].set({ subField: "modNotes", level })
|
||||
return this
|
||||
},
|
||||
/** The current releasing status of the media */
|
||||
withStatus(args?: MediaStatusArgs) {
|
||||
query[0] = query[0].set({ subField: "status", level, variables: args })
|
||||
return this
|
||||
},
|
||||
/** Short description of the media's story and characters */
|
||||
withDescription(args?: MediaDescriptionArgs) {
|
||||
query[0] = query[0].set({ subField: "description", level, variables: args })
|
||||
return this
|
||||
},
|
||||
/** Source type the media was adapted from. */
|
||||
withSource(args?: MediaSourceArgs) {
|
||||
query[0] = query[0].set({ subField: "source", level, variables: args })
|
||||
return this
|
||||
},
|
||||
/** The staff who produced the media */
|
||||
withStaff(
|
||||
args: MediaStaffArgs | undefined,
|
||||
fn: Fn<typeof StaffConnection>,
|
||||
) {
|
||||
query[0] = query[0].set({ subField: "staff", level, variables: args, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(StaffConnection({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** User recommendations for similar media */
|
||||
withRecommendations(
|
||||
args: MediaRecommendationsArgs | undefined,
|
||||
fn: Fn<typeof RecommendationConnection>,
|
||||
) {
|
||||
query[0] = query[0].set({
|
||||
subField: "recommendations",
|
||||
level,
|
||||
variables: args,
|
||||
hasSubField: true,
|
||||
})
|
||||
let tmpQuery
|
||||
fn(RecommendationConnection({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The characters in the media */
|
||||
withCharacters(
|
||||
args: AtLeastOne<MediaCharactersArgs> | undefined,
|
||||
fn: Fn<typeof CharacterConnection>,
|
||||
) {
|
||||
query[0] = query[0].set({ subField: "characters", level, variables: args, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(
|
||||
CharacterConnection({ query: tmpQuery = [query[0]], level: level + 1 }),
|
||||
)
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The companies who produced the media */
|
||||
withStudios(
|
||||
args: MediaStudiosArgs | undefined,
|
||||
fn: Fn<typeof StudioConnection>,
|
||||
) {
|
||||
query[0] = query[0].set({ subField: "studios", level, variables: args, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(StudioConnection({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The media's entire airing schedule */
|
||||
withAiringSchedule(
|
||||
args: MediaAiringScheduleArgs | undefined,
|
||||
fn: Fn<typeof AiringScheduleConnection>,
|
||||
) {
|
||||
query[0] = query[0].set({
|
||||
subField: "airingSchedule",
|
||||
level,
|
||||
variables: args,
|
||||
hasSubField: true,
|
||||
})
|
||||
let tmpQuery
|
||||
fn(AiringScheduleConnection({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The media's daily trend stats */
|
||||
withTrends(
|
||||
args: MediaTrendsArgs | undefined,
|
||||
fn: Fn<typeof MediaTrendConnection>,
|
||||
) {
|
||||
query[0] = query[0].set({ subField: "trends", level, variables: args, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(MediaTrendConnection({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** User reviews of the media */
|
||||
withReviews(
|
||||
args: MediaReviewsArgs | undefined,
|
||||
fn: Fn<typeof ReviewConnection>,
|
||||
) {
|
||||
query[0] = query[0].set({ subField: "reviews", level, variables: args, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(ReviewConnection({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The official titles of the media in various languages */
|
||||
withTitle(fn: Fn<typeof MediaTitle>) {
|
||||
query[0] = query[0].set({ subField: "title", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(MediaTitle({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The first official release date of the media */
|
||||
withStartDate(fn: Fn<typeof FuzzyDate>) {
|
||||
query[0] = query[0].set({ subField: "startDate", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(FuzzyDate({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The last official release date of the media */
|
||||
withEndDate(fn: Fn<typeof FuzzyDate>) {
|
||||
query[0] = query[0].set({ subField: "endDate", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(FuzzyDate({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** Media trailer or advertisement */
|
||||
withTrailer(fn: Fn<typeof MediaTrailer>) {
|
||||
query[0] = query[0].set({ subField: "trailer", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(MediaTrailer({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The cover images of the media */
|
||||
withCoverImage(fn: Fn<typeof MediaCoverImage>) {
|
||||
query[0] = query[0].set({ subField: "coverImage", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(MediaCoverImage({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** List of tags that describes elements and themes of the media */
|
||||
withTags(fn: Fn<typeof MediaTag>) {
|
||||
query[0] = query[0].set({ subField: "tags", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(MediaTag({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** Other media in the same or connecting franchise */
|
||||
withRelations(fn: Fn<typeof MediaConnection>) {
|
||||
query[0] = query[0].set({ subField: "relations", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(MediaConnection({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** External links to another site related to the media */
|
||||
withExternalLinks(
|
||||
fn: Fn<typeof MediaExternalLink>,
|
||||
) {
|
||||
query[0] = query[0].set({ subField: "externalLinks", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(MediaExternalLink({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** Data and links to legal streaming episodes on external sites */
|
||||
withStreamingEpisodes(
|
||||
fn: Fn<typeof MediaStreamingEpisode>,
|
||||
) {
|
||||
query[0] = query[0].set({ subField: "streamingEpisodes", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(MediaStreamingEpisode({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The ranking of the media in a particular time span and format compared to other media */
|
||||
withRankings(fn: Fn<typeof MediaRank>) {
|
||||
query[0] = query[0].set({ subField: "rankings", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(MediaRank({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The authenticated user's media list entry for the media */
|
||||
withMediaListEntry(
|
||||
fn: Fn<typeof MediaList>,
|
||||
) {
|
||||
query[0] = query[0].set({ subField: "mediaListEntry", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(MediaList({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withStats(fn: Fn<typeof MediaStats>) {
|
||||
query[0] = query[0].set({ subField: "stats", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(MediaStats({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
})
|
|
@ -0,0 +1,99 @@
|
|||
import { Fields, Fn, UpdateOperation } from "../types/Anilist.ts"
|
||||
import { Media } from "./Media.ts"
|
||||
import { FuzzyDate } from "../anilist.ts"
|
||||
import { User } from "./User.ts"
|
||||
|
||||
export const MediaList = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
withCompletedAt(fn: Fn<typeof FuzzyDate>) {
|
||||
query[0] = query[0].set({
|
||||
subField: "completedAt",
|
||||
level,
|
||||
hasSubField: true,
|
||||
})
|
||||
let tmpQuery
|
||||
fn(FuzzyDate({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withStartedAt(fn: Fn<typeof FuzzyDate>) {
|
||||
query[0] = query[0].set({
|
||||
subField: "startedAt",
|
||||
level,
|
||||
hasSubField: true,
|
||||
})
|
||||
let tmpQuery
|
||||
fn(FuzzyDate({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withId() {
|
||||
query[0] = query[0].set({ subField: "id", level })
|
||||
return this
|
||||
},
|
||||
withUserId() {
|
||||
query[0] = query[0].set({ subField: "userId", level })
|
||||
return this
|
||||
},
|
||||
withMediaId() {
|
||||
query[0] = query[0].set({ subField: "mediaId", level })
|
||||
return this
|
||||
},
|
||||
withStatus() {
|
||||
query[0] = query[0].set({ subField: "status", level })
|
||||
return this
|
||||
},
|
||||
withProgress() {
|
||||
query[0] = query[0].set({ subField: "progress", level })
|
||||
return this
|
||||
},
|
||||
withProgressVolumes() {
|
||||
query[0] = query[0].set({ subField: "progressVolumes", level })
|
||||
return this
|
||||
},
|
||||
withRepeat() {
|
||||
query[0] = query[0].set({ subField: "repeat", level })
|
||||
return this
|
||||
},
|
||||
withPriority() {
|
||||
query[0] = query[0].set({ subField: "priority", level })
|
||||
return this
|
||||
},
|
||||
withPrivate() {
|
||||
query[0] = query[0].set({ subField: "private", level })
|
||||
return this
|
||||
},
|
||||
withNotes() {
|
||||
query[0] = query[0].set({ subField: "notes", level })
|
||||
return this
|
||||
},
|
||||
withAdvancedScores() {
|
||||
query[0] = query[0].set({ subField: "advancedScores", level })
|
||||
return this
|
||||
},
|
||||
withHiddenFromStatusLists() {
|
||||
query[0] = query[0].set({ subField: "hiddenFromStatusLists", level })
|
||||
return this
|
||||
},
|
||||
withUpdatedAt() {
|
||||
query[0] = query[0].set({ subField: "updatedAt", level })
|
||||
return this
|
||||
},
|
||||
withCreatedAt() {
|
||||
query[0] = query[0].set({ subField: "createdAt", level })
|
||||
return this
|
||||
},
|
||||
withMedia(fn: Fn<typeof Media>) {
|
||||
query[0] = query[0].set({ subField: "media", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withUser(fn: Fn<typeof User>) {
|
||||
query[0] = query[0].set({ subField: "user", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
})
|
|
@ -0,0 +1,23 @@
|
|||
import { Fields, Fn, UpdateOperation } from "../types/Anilist.ts"
|
||||
import { MediaListGroup } from "./Media.ts"
|
||||
|
||||
export const MediaListCollection = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** Grouped media list entries */
|
||||
withLists(fn: Fn<typeof MediaListGroup>) {
|
||||
query[0] = query[0].set({ subField: "lists", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(MediaListGroup({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The owner of the list */
|
||||
withUser() {
|
||||
query[0] = query[0].set({ subField: "user", level })
|
||||
return this
|
||||
},
|
||||
/** If there is another chunk */
|
||||
withHasNextChunk() {
|
||||
query[0] = query[0].set({ subField: "hasNextChunk", level })
|
||||
return this
|
||||
},
|
||||
})
|
|
@ -0,0 +1,49 @@
|
|||
import { Fields, UpdateOperation } from "../types/Anilist.ts"
|
||||
|
||||
export const MediaTag = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** The id of the tag */
|
||||
withId() {
|
||||
query[0] = query[0].set({ subField: "id", level })
|
||||
return this
|
||||
},
|
||||
/** The name of the tag */
|
||||
withName() {
|
||||
query[0] = query[0].set({ subField: "name", level })
|
||||
return this
|
||||
},
|
||||
/** A general description of the tag */
|
||||
withDescription() {
|
||||
query[0] = query[0].set({ subField: "description", level })
|
||||
return this
|
||||
},
|
||||
/** The categories of tags this tag belongs to */
|
||||
withCategory() {
|
||||
query[0] = query[0].set({ subField: "category", level })
|
||||
return this
|
||||
},
|
||||
/** The relevance ranking of the tag out of the 100 for this media */
|
||||
withRank() {
|
||||
query[0] = query[0].set({ subField: "rank", level })
|
||||
return this
|
||||
},
|
||||
/** If the tag could be a spoiler for any media */
|
||||
withIsGeneralSpoiler() {
|
||||
query[0] = query[0].set({ subField: "isGeneralSpoiler", level })
|
||||
return this
|
||||
},
|
||||
/** If the tag is a spoiler for this media */
|
||||
withIsMediaSpoiler() {
|
||||
query[0] = query[0].set({ subField: "isMediaSpoiler", level })
|
||||
return this
|
||||
},
|
||||
/** If the tag is only for adult 18+ media */
|
||||
withIsAdult() {
|
||||
query[0] = query[0].set({ subField: "isAdult", level })
|
||||
return this
|
||||
},
|
||||
/** The user who submitted the tag */
|
||||
withUserId() {
|
||||
query[0] = query[0].set({ subField: "userId", level })
|
||||
return this
|
||||
},
|
||||
})
|
|
@ -0,0 +1,89 @@
|
|||
import { Fields, Fn, UpdateOperation } from "../types/Anilist.ts"
|
||||
import { Media } from "./Media.ts"
|
||||
import { PageInfo } from "../anilist.ts"
|
||||
|
||||
const MediaTrendEdge = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
withNode(fn: Fn<typeof MediaTrend>) {
|
||||
query[0] = query[0].set({ subField: "node", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(MediaTrend({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
export const MediaTrendConnection = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
withEdges(fn: Fn<typeof MediaTrendEdge>) {
|
||||
query[0] = query[0].set({ subField: "edges", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(MediaTrendEdge({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withNodes(fn: Fn<typeof MediaTrend>) {
|
||||
query[0] = query[0].set({ subField: "nodes", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(MediaTrend({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The pagination information */
|
||||
withPageInfo(fn: Fn<typeof PageInfo>) {
|
||||
query[0] = query[0].set({ subField: "pageInfo", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(PageInfo({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
export const MediaTrend = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** The id of the tag */
|
||||
withMediaId() {
|
||||
query[0] = query[0].set({ subField: "mediaId", level })
|
||||
return this
|
||||
},
|
||||
/** The day the data was recorded (timestamp) */
|
||||
withDate() {
|
||||
query[0] = query[0].set({ subField: "date", level })
|
||||
return this
|
||||
},
|
||||
/** The amount of media activity on the day */
|
||||
withTrending() {
|
||||
query[0] = query[0].set({ subField: "trending", level })
|
||||
return this
|
||||
},
|
||||
/** A weighted average score of all the user's scores of the media */
|
||||
withAverageScore() {
|
||||
query[0] = query[0].set({ subField: "averageScore", level })
|
||||
return this
|
||||
},
|
||||
/** The number of users with the media on their list */
|
||||
withPopularity() {
|
||||
query[0] = query[0].set({ subField: "popularity", level })
|
||||
return this
|
||||
},
|
||||
/** The number of users with watching/reading the media */
|
||||
withInProgress() {
|
||||
query[0] = query[0].set({ subField: "inProgress", level })
|
||||
return this
|
||||
},
|
||||
/** If the media was being released at this time */
|
||||
withReleasing() {
|
||||
query[0] = query[0].set({ subField: "releasing", level })
|
||||
return this
|
||||
},
|
||||
/** The episode number of the anime released on this day */
|
||||
withEpisode() {
|
||||
query[0] = query[0].set({ subField: "episode", level })
|
||||
return this
|
||||
},
|
||||
/** The related media */
|
||||
withMedia(fn: Fn<typeof Media>) {
|
||||
query[0] = query[0].set({ subField: "node", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
})
|
|
@ -0,0 +1,80 @@
|
|||
import { Fields, Fn, UpdateOperation } from "../types/Anilist.ts"
|
||||
import { Media } from "./Media.ts"
|
||||
import { User } from "./User.ts"
|
||||
import { PageInfo } from "../anilist.ts"
|
||||
|
||||
const RecommendationEdge = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
withNode(fn: Fn<typeof Recommendation>) {
|
||||
query[0] = query[0].set({ subField: "node", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(Recommendation({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
})
|
||||
export const RecommendationConnection = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
withEdges(fn: Fn<typeof RecommendationEdge>) {
|
||||
query[0] = query[0].set({ subField: "edges", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(RecommendationEdge({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withNodes(fn: Fn<typeof Recommendation>) {
|
||||
query[0] = query[0].set({ subField: "nodes", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(Recommendation({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The pagination information */
|
||||
withPageInfo(fn: Fn<typeof PageInfo>) {
|
||||
query[0] = query[0].set({ subField: "pageInfo", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(PageInfo({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
export const Recommendation = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** The id of the recommendation */
|
||||
withId() {
|
||||
query[0] = query[0].set({ subField: "id", level })
|
||||
return this
|
||||
},
|
||||
/** Users rating of the recommendation */
|
||||
withRating() {
|
||||
query[0] = query[0].set({ subField: "rating", level })
|
||||
return this
|
||||
},
|
||||
/** The rating of the recommendation by currently authenticated user */
|
||||
withUserRating() {
|
||||
query[0] = query[0].set({ subField: "userRating", level })
|
||||
return this
|
||||
},
|
||||
/** The media the recommendation is from */
|
||||
withMedia(fn: Fn<typeof Media>) {
|
||||
query[0] = query[0].set({ subField: "media", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The recommended media */
|
||||
withMediaRecommendation(fn: Fn<typeof Media>) {
|
||||
query[0] = query[0].set({ subField: "media", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The user that first created the recommendation */
|
||||
withUser(fn: Fn<typeof User>) {
|
||||
query[0] = query[0].set({ subField: "user", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
})
|
|
@ -0,0 +1,128 @@
|
|||
import { PageInfo } from "../anilist.ts"
|
||||
import { Fields, Fn, UpdateOperation } from "../types/Anilist.ts"
|
||||
import { Media } from "./Media.ts"
|
||||
import { User } from "./User.ts"
|
||||
|
||||
const ReviewEdge = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
withNode(fn: Fn<typeof Review>) {
|
||||
query[0] = query[0].set({ subField: "node", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(Review({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
export const ReviewConnection = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
withEdges(fn: Fn<typeof ReviewEdge>) {
|
||||
query[0] = query[0].set({ subField: "edges", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(ReviewEdge({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withNodes(fn: Fn<typeof Review>) {
|
||||
query[0] = query[0].set({ subField: "nodes", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(Review({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The pagination information */
|
||||
withPageInfo(fn: Fn<typeof PageInfo>) {
|
||||
query[0] = query[0].set({ subField: "pageInfo", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(PageInfo({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
export const Review = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** The id of the review */
|
||||
withId() {
|
||||
query[0] = query[0].set({ subField: "id", level })
|
||||
return this
|
||||
},
|
||||
/** The id of the review's creator */
|
||||
withUserId() {
|
||||
query[0] = query[0].set({ subField: "userid", level })
|
||||
return this
|
||||
},
|
||||
/** The id of the review's media */
|
||||
withMediaId() {
|
||||
query[0] = query[0].set({ subField: "mediaid", level })
|
||||
return this
|
||||
},
|
||||
/** For which type of media the review is for */
|
||||
withMediaType() {
|
||||
query[0] = query[0].set({ subField: "mediatype", level })
|
||||
return this
|
||||
},
|
||||
/** A short summary of the review */
|
||||
withSummary() {
|
||||
query[0] = query[0].set({ subField: "summary", level })
|
||||
return this
|
||||
},
|
||||
/** The main review body text */
|
||||
body(args?: { asHtml: boolean }) {
|
||||
query[0] = query[0].set({ subField: "(args", level, variables: args })
|
||||
return this
|
||||
},
|
||||
/** The total user rating of the review */
|
||||
withRating() {
|
||||
query[0] = query[0].set({ subField: "rating", level })
|
||||
return this
|
||||
},
|
||||
/** The amount of user ratings of the review */
|
||||
withRatingAmount() {
|
||||
query[0] = query[0].set({ subField: "ratingamount", level })
|
||||
return this
|
||||
},
|
||||
/** The rating of the review by currently authenticated user */
|
||||
withUserRating() {
|
||||
query[0] = query[0].set({ subField: "userrating", level })
|
||||
return this
|
||||
},
|
||||
/** The review score of the media */
|
||||
withScore() {
|
||||
query[0] = query[0].set({ subField: "score", level })
|
||||
return this
|
||||
},
|
||||
/** If the review is not yet publicly published and is only viewable by creator */
|
||||
withPrivate() {
|
||||
query[0] = query[0].set({ subField: "private", level })
|
||||
return this
|
||||
},
|
||||
/** The url for the review page on the AniList website */
|
||||
withSiteUrl() {
|
||||
query[0] = query[0].set({ subField: "siteurl", level })
|
||||
return this
|
||||
},
|
||||
/** The time of the thread creation */
|
||||
withCreatedAt() {
|
||||
query[0] = query[0].set({ subField: "createdat", level })
|
||||
return this
|
||||
},
|
||||
/** The time of the thread last update */
|
||||
withUpdatedAt() {
|
||||
query[0] = query[0].set({ subField: "updatedat", level })
|
||||
return this
|
||||
},
|
||||
/** The creator of the review */
|
||||
withUser(fn: Fn<typeof User>) {
|
||||
query[0] = query[0].set({ subField: "user", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The media the review is of */
|
||||
withMedia(fn: Fn<typeof Media>) {
|
||||
query[0] = query[0].set({ subField: "media", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
})
|
|
@ -0,0 +1,67 @@
|
|||
import {
|
||||
SiteStatisticsAnimeArgs,
|
||||
SiteStatisticsCharactersArgs,
|
||||
SiteStatisticsMangaArgs,
|
||||
SiteStatisticsReviewsArgs,
|
||||
SiteStatisticsStaffArgs,
|
||||
SiteStatisticsStudiosArgs,
|
||||
SiteStatisticsUsersArgs,
|
||||
} from "../types/generated/graphql.ts"
|
||||
import { Fields, Fn, UpdateOperation } from "../types/Anilist.ts"
|
||||
import type { AtLeastOne } from "../types/AtLeastOne.ts"
|
||||
import { SiteTrendConnection } from "./SiteTrend.ts"
|
||||
|
||||
export const SiteStatistics = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
withUsers(args: AtLeastOne<SiteStatisticsUsersArgs>, fn: Fn<typeof SiteTrendConnection>) {
|
||||
query[0] = query[0].set({ subField: "users", level, hasSubField: true, variables: args })
|
||||
let tmpQuery
|
||||
fn(SiteTrendConnection({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withAnime(args: AtLeastOne<SiteStatisticsAnimeArgs>, fn: Fn<typeof SiteTrendConnection>) {
|
||||
query[0] = query[0].set({ subField: "anime", level, hasSubField: true, variables: args })
|
||||
let tmpQuery
|
||||
fn(SiteTrendConnection({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withManga(args: AtLeastOne<SiteStatisticsMangaArgs>, fn: Fn<typeof SiteTrendConnection>) {
|
||||
query[0] = query[0].set({ subField: "manga", level, hasSubField: true, variables: args })
|
||||
let tmpQuery
|
||||
fn(SiteTrendConnection({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withCharacters(
|
||||
args: AtLeastOne<SiteStatisticsCharactersArgs>,
|
||||
fn: Fn<typeof SiteTrendConnection>,
|
||||
) {
|
||||
query[0] = query[0].set({ subField: "characters", level, hasSubField: true, variables: args })
|
||||
let tmpQuery
|
||||
fn(SiteTrendConnection({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withStaff(args: AtLeastOne<SiteStatisticsStaffArgs>, fn: Fn<typeof SiteTrendConnection>) {
|
||||
query[0] = query[0].set({ subField: "staff", level, hasSubField: true, variables: args })
|
||||
let tmpQuery
|
||||
fn(SiteTrendConnection({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withStudios(args: AtLeastOne<SiteStatisticsStudiosArgs>, fn: Fn<typeof SiteTrendConnection>) {
|
||||
query[0] = query[0].set({ subField: "studios", level, hasSubField: true, variables: args })
|
||||
let tmpQuery
|
||||
fn(SiteTrendConnection({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withReviews(args: AtLeastOne<SiteStatisticsReviewsArgs>, fn: Fn<typeof SiteTrendConnection>) {
|
||||
query[0] = query[0].set({ subField: "reviews", level, hasSubField: true, variables: args })
|
||||
let tmpQuery
|
||||
fn(SiteTrendConnection({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
})
|
|
@ -0,0 +1,55 @@
|
|||
import { Fields, Fn, UpdateOperation } from "../types/Anilist.ts"
|
||||
import { PageInfo } from "../anilist.ts"
|
||||
|
||||
const SiteTrend = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** The day the data was recorded (timestamp) */
|
||||
withDate() {
|
||||
query[0] = query[0].set({ subField: "date", level })
|
||||
return this
|
||||
},
|
||||
|
||||
withCount() {
|
||||
query[0] = query[0].set({ subField: "count", level })
|
||||
return this
|
||||
},
|
||||
/** The change from yesterday */
|
||||
withChange() {
|
||||
query[0] = query[0].set({ subField: "change", level })
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
const SiteTrendEdge = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
withNode(fn: Fn<typeof SiteTrend>) {
|
||||
query[0] = query[0].set({ subField: "node", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(SiteTrend({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
export const SiteTrendConnection = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
withEdges(fn: Fn<typeof SiteTrendEdge>) {
|
||||
query[0] = query[0].set({ subField: "edges", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(SiteTrendEdge({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withNodes(fn: Fn<typeof SiteTrend>) {
|
||||
query[0] = query[0].set({ subField: "nodes", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(SiteTrend({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The pagination information */
|
||||
withPageInfo(fn: Fn<typeof PageInfo>) {
|
||||
query[0] = query[0].set({ subField: "pageInfo", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(PageInfo({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
})
|
|
@ -0,0 +1,290 @@
|
|||
import {
|
||||
StaffCharacterMediaArgs,
|
||||
StaffCharactersArgs,
|
||||
StaffStaffMediaArgs,
|
||||
} from "../types/generated/graphql.ts"
|
||||
import { Fields, Fn, UpdateOperation } from "../types/Anilist.ts"
|
||||
import { FuzzyDate, PageInfo } from "../anilist.ts"
|
||||
import { User } from "./User.ts"
|
||||
import { CharacterConnection } from "./Character.ts"
|
||||
import { MediaConnection } from "./Media.ts"
|
||||
|
||||
export const StaffRoleType = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** The voice actors of the character */
|
||||
withVoiceActor(fn: Fn<typeof Staff>) {
|
||||
query[0] = query[0].set({ subField: "voiceActor", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(Staff({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** Notes regarding the VA's role for the character */
|
||||
withRoleNotes() {
|
||||
query[0] = query[0].set({ subField: "roleNotes", level })
|
||||
return this
|
||||
},
|
||||
/** Used for grouping roles where multiple dubs exist for the same language. Either dubbing company name or language variant. */
|
||||
withDubGroup() {
|
||||
query[0] = query[0].set({ subField: "dubGroup", level })
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
const StaffEdge = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
withNode(fn: Fn<typeof Staff>) {
|
||||
query[0] = query[0].set({ subField: "node", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(Staff({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The id of the connection */
|
||||
withId() {
|
||||
query[0] = query[0].set({ subField: "id", level })
|
||||
return this
|
||||
},
|
||||
/** The role of the staff member in the production of the media */
|
||||
withRole() {
|
||||
query[0] = query[0].set({ subField: "role", level })
|
||||
return this
|
||||
},
|
||||
/** The order the staff should be displayed from the users favourites */
|
||||
withFavouriteOrder() {
|
||||
query[0] = query[0].set({ subField: "favouriteOrder", level })
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
export const StaffConnection = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
withEdges(fn: Fn<typeof StaffEdge>) {
|
||||
query[0] = query[0].set({ subField: "edges", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(StaffEdge({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withNodes(fn: Fn<typeof Staff>) {
|
||||
query[0] = query[0].set({ subField: "nodes", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(Staff({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The pagination information */
|
||||
withPageInfo(fn: Fn<typeof PageInfo>) {
|
||||
query[0] = query[0].set({ subField: "pageInfo", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(PageInfo({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
const StaffName = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** The person's given name */
|
||||
withFirst() {
|
||||
query[0] = query[0].set({ subField: "first", level })
|
||||
return this
|
||||
},
|
||||
/** The person's middle name */
|
||||
withMiddle() {
|
||||
query[0] = query[0].set({ subField: "middle", level })
|
||||
return this
|
||||
},
|
||||
/** The person's surname */
|
||||
withLast() {
|
||||
query[0] = query[0].set({ subField: "last", level })
|
||||
return this
|
||||
},
|
||||
/** The person's first and last name */
|
||||
withFull() {
|
||||
query[0] = query[0].set({ subField: "full", level })
|
||||
return this
|
||||
},
|
||||
/** The person's full name in their native language */
|
||||
withNative() {
|
||||
query[0] = query[0].set({ subField: "native", level })
|
||||
return this
|
||||
},
|
||||
/** Other names the staff member might be referred to as (pen names) */
|
||||
withAlternative() {
|
||||
query[0] = query[0].set({ subField: "alternative", level })
|
||||
return this
|
||||
},
|
||||
/** The currently authenticated users preferred name language. Default romaji for non-authenticated */
|
||||
withUserPreferred() {
|
||||
query[0] = query[0].set({ subField: "userPreferred", level })
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
const StaffImage = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** The person's image of media at its largest size */
|
||||
withLarge() {
|
||||
query[0] = query[0].set({ subField: "large", level })
|
||||
return this
|
||||
},
|
||||
/** The person's image of media at medium size */
|
||||
withMedium() {
|
||||
query[0] = query[0].set({ subField: "medium", level })
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
export const Staff = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** The id of the staff member */
|
||||
withId() {
|
||||
query[0] = query[0].set({ subField: "id", level })
|
||||
return this
|
||||
},
|
||||
/** The names of the staff member */
|
||||
withName(fn: Fn<typeof StaffName>) {
|
||||
query[0] = query[0].set({ subField: "name", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(StaffName({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The primary language of the staff member. Current values: Japanese, English, Korean, Italian, Spanish, Portuguese, French, German, Hebrew, Hungarian, Chinese, Arabic, Filipino, Catalan, Finnish, Turkish, Dutch, Swedish, Thai, Tagalog, Malaysian, Indonesian, Vietnamese, Nepali, Hindi, Urdu */
|
||||
withLanguageV2() {
|
||||
query[0] = query[0].set({ subField: "languageV2", level })
|
||||
return this
|
||||
},
|
||||
/** The staff images */
|
||||
withImage(fn: Fn<typeof StaffImage>) {
|
||||
query[0] = query[0].set({ subField: "image", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(StaffImage({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** A general description of the staff member */
|
||||
withDescription(args?: { asHtml: boolean }) {
|
||||
query[0] = query[0].set({ subField: "description", level, variables: args })
|
||||
return this
|
||||
},
|
||||
/** The person's primary occupations */
|
||||
withPrimaryOccupations() {
|
||||
query[0] = query[0].set({ subField: "primaryOccupations", level })
|
||||
return this
|
||||
},
|
||||
/** The staff's gender. Usually Male, Female, or Non-binary but can be any string. */
|
||||
withGender() {
|
||||
query[0] = query[0].set({ subField: "gender", level })
|
||||
return this
|
||||
},
|
||||
withDateOfBirth(fn: Fn<typeof FuzzyDate>) {
|
||||
query[0] = query[0].set({ subField: "dateOfBirth", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(FuzzyDate({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withDateOfDeath(fn: Fn<typeof FuzzyDate>) {
|
||||
query[0] = query[0].set({ subField: "dateOfDeath", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(FuzzyDate({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The person's age in years */
|
||||
withAge() {
|
||||
query[0] = query[0].set({ subField: "age", level })
|
||||
return this
|
||||
},
|
||||
/** [startYear, endYear] (If the 2nd value is not present staff is still active) */
|
||||
withYearsActive() {
|
||||
query[0] = query[0].set({ subField: "yearsActive", level })
|
||||
return this
|
||||
},
|
||||
/** The persons birthplace or hometown */
|
||||
withHomeTown() {
|
||||
query[0] = query[0].set({ subField: "homeTown", level })
|
||||
return this
|
||||
},
|
||||
/** The persons blood type */
|
||||
withBloodType() {
|
||||
query[0] = query[0].set({ subField: "bloodType", level })
|
||||
return this
|
||||
},
|
||||
/** If the staff member is marked as favourite by the currently authenticated user */
|
||||
withIsFavourite() {
|
||||
query[0] = query[0].set({ subField: "isFavourite", level })
|
||||
return this
|
||||
},
|
||||
/** If the staff member is blocked from being added to favourites */
|
||||
withIsFavouriteBlocked() {
|
||||
query[0] = query[0].set({ subField: "isFavouriteBlocked", level })
|
||||
return this
|
||||
},
|
||||
/** The url for the staff page on the AniList website */
|
||||
withSiteUrl() {
|
||||
query[0] = query[0].set({ subField: "siteUrl", level })
|
||||
return this
|
||||
},
|
||||
/** Media where the staff member has a production role */
|
||||
withStaffMedia(args: StaffStaffMediaArgs | undefined, fn: Fn<typeof MediaConnection>) {
|
||||
query[0] = query[0].set({ subField: "staffMedia", level, variables: args, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(MediaConnection({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** Characters voiced by the actor */
|
||||
withCharacters(args: StaffCharactersArgs | undefined, fn: Fn<typeof CharacterConnection>) {
|
||||
query[0] = query[0].set({ subField: "characters", level, variables: args, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(CharacterConnection({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** Media the actor voiced characters in. (Same data as characters with media as node instead of characters) */
|
||||
withCharacterMedia(args: StaffCharacterMediaArgs | undefined, fn: Fn<typeof MediaConnection>) {
|
||||
query[0] = query[0].set({
|
||||
subField: "characterMedia",
|
||||
level,
|
||||
variables: args,
|
||||
hasSubField: true,
|
||||
})
|
||||
let tmpQuery
|
||||
fn(MediaConnection({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** Staff member that the submission is referencing */
|
||||
withStaff(fn: Fn<typeof Staff>) {
|
||||
query[0] = query[0].set({ subField: "staff", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(Staff({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** Submitter for the submission */
|
||||
withSubmitter(fn: Fn<typeof User>) {
|
||||
query[0] = query[0].set({ subField: "submitter", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** Status of the submission */
|
||||
withSubmissionStatus() {
|
||||
query[0] = query[0].set({ subField: "submissionStatus", level })
|
||||
return this
|
||||
},
|
||||
/** Inner details of submission status */
|
||||
withSubmissionNotes() {
|
||||
query[0] = query[0].set({ subField: "submissionNotes", level })
|
||||
return this
|
||||
},
|
||||
/** The amount of user's who have favourited the staff member */
|
||||
withFavourites() {
|
||||
query[0] = query[0].set({ subField: "favourites", level })
|
||||
return this
|
||||
},
|
||||
/** Notes for site moderators */
|
||||
withModNotes() {
|
||||
query[0] = query[0].set({ subField: "modNotes", level })
|
||||
return this
|
||||
},
|
||||
})
|
|
@ -0,0 +1,95 @@
|
|||
import { StudioMediaArgs } from "../types/generated/graphql.ts"
|
||||
import { Fields, Fn, UpdateOperation } from "../types/Anilist.ts"
|
||||
import { PageInfo } from "../anilist.ts"
|
||||
import { MediaConnection } from "./Media.ts"
|
||||
|
||||
const StudioEdge = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
withNode(fn: Fn<typeof Studio>) {
|
||||
query[0] = query[0].set({ subField: "node", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(Studio({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The id of the connection */
|
||||
withId() {
|
||||
query[0] = query[0].set({ subField: "id", level })
|
||||
return this
|
||||
},
|
||||
/** If the studio is the main animation studio of the anime */
|
||||
withIsMain() {
|
||||
query[0] = query[0].set({ subField: "isMain", level })
|
||||
return this
|
||||
},
|
||||
/** The order the character should be displayed from the users favourites */
|
||||
withFavouriteOrder() {
|
||||
query[0] = query[0].set({ subField: "favouriteOrder", level })
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
export const StudioConnection = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
withEdges(fn: Fn<typeof StudioEdge>) {
|
||||
query[0] = query[0].set({ subField: "edges", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(StudioEdge({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withNodes(fn: Fn<typeof Studio>) {
|
||||
query[0] = query[0].set({ subField: "nodes", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(Studio({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The pagination information */
|
||||
withPageInfo(fn: Fn<typeof PageInfo>) {
|
||||
query[0] = query[0].set({ subField: "pageInfo", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(PageInfo({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
export const Studio = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** The id of the studio */
|
||||
withId() {
|
||||
query[0] = query[0].set({ subField: "id", level })
|
||||
return this
|
||||
},
|
||||
/** The name of the studio */
|
||||
withName() {
|
||||
query[0] = query[0].set({ subField: "name", level })
|
||||
return this
|
||||
},
|
||||
/** If the studio is an animation studio or a different kind of company */
|
||||
withIsAnimationStudio() {
|
||||
query[0] = query[0].set({ subField: "isAnimationStudio", level })
|
||||
return this
|
||||
},
|
||||
/** The media the studio has worked on */
|
||||
withMedia(args: StudioMediaArgs | undefined, fn: Fn<typeof MediaConnection>) {
|
||||
query[0] = query[0].set({ subField: "media", level, variables: args, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(MediaConnection({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The url for the studio page on the AniList website */
|
||||
withSiteUrl() {
|
||||
query[0] = query[0].set({ subField: "siteUrl", level })
|
||||
return this
|
||||
},
|
||||
/** If the studio is marked as favourite by the currently authenticated user */
|
||||
withIsFavourite() {
|
||||
query[0] = query[0].set({ subField: "isFavourite", level })
|
||||
return this
|
||||
},
|
||||
/** The amount of user's who have favourited the studio */
|
||||
withFavourites() {
|
||||
query[0] = query[0].set({ subField: "favourites", level })
|
||||
return this
|
||||
},
|
||||
})
|
|
@ -0,0 +1,155 @@
|
|||
import { Fields, Fn, UpdateOperation } from "../types/Anilist.ts"
|
||||
import { Media } from "./Media.ts"
|
||||
import { User } from "./User.ts"
|
||||
|
||||
const ThreadCategory = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** The id of the category */
|
||||
withId() {
|
||||
query[0] = query[0].set({ subField: "id", level })
|
||||
return this
|
||||
},
|
||||
/** The name of the category */
|
||||
withName() {
|
||||
query[0] = query[0].set({ subField: "name", level })
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
export const Thread = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** The id of the thread */
|
||||
withId() {
|
||||
query[0] = query[0].set({ subField: "id", level })
|
||||
return this
|
||||
},
|
||||
/** The title of the thread */
|
||||
withTitle() {
|
||||
query[0] = query[0].set({ subField: "title", level })
|
||||
return this
|
||||
},
|
||||
/** The text body of the thread (Markdown) */
|
||||
withBody(args?: { asHtml: boolean }) {
|
||||
query[0] = query[0].set({ subField: "body", level, variables: args })
|
||||
return this
|
||||
},
|
||||
/** The id of the thread owner user */
|
||||
withUserId() {
|
||||
query[0] = query[0].set({ subField: "userId", level })
|
||||
return this
|
||||
},
|
||||
/** The id of the user who most recently commented on the thread */
|
||||
withReplyUserId() {
|
||||
query[0] = query[0].set({ subField: "replyUserId", level })
|
||||
return this
|
||||
},
|
||||
/** The id of the most recent comment on the thread */
|
||||
withReplyCommentId() {
|
||||
query[0] = query[0].set({ subField: "replyCommentId", level })
|
||||
return this
|
||||
},
|
||||
/** The number of comments on the thread */
|
||||
withReplyCount() {
|
||||
query[0] = query[0].set({ subField: "replyCount", level })
|
||||
return this
|
||||
},
|
||||
/** The number of times users have viewed the thread */
|
||||
withViewCount() {
|
||||
query[0] = query[0].set({ subField: "viewCount", level })
|
||||
return this
|
||||
},
|
||||
/** If the thread is locked and can receive comments */
|
||||
withIsLocked() {
|
||||
query[0] = query[0].set({ subField: "isLocked", level })
|
||||
return this
|
||||
},
|
||||
/** If the thread is stickied and should be displayed at the top of the page */
|
||||
withIsSticky() {
|
||||
query[0] = query[0].set({ subField: "isSticky", level })
|
||||
return this
|
||||
},
|
||||
/** If the currently authenticated user is subscribed to the thread */
|
||||
withIsSubscribed() {
|
||||
query[0] = query[0].set({ subField: "isSubscribed", level })
|
||||
return this
|
||||
},
|
||||
/** The amount of likes the thread has */
|
||||
withLikeCount() {
|
||||
query[0] = query[0].set({ subField: "likeCount", level })
|
||||
return this
|
||||
},
|
||||
/** If the currently authenticated user liked the thread */
|
||||
withIsLiked() {
|
||||
query[0] = query[0].set({ subField: "isLiked", level })
|
||||
return this
|
||||
},
|
||||
/** The time of the last reply */
|
||||
withRepliedAt() {
|
||||
query[0] = query[0].set({ subField: "repliedAt", level })
|
||||
return this
|
||||
},
|
||||
/** The time of the thread creation */
|
||||
withCreatedAt() {
|
||||
query[0] = query[0].set({ subField: "createdAt", level })
|
||||
return this
|
||||
},
|
||||
/** The time of the thread last update */
|
||||
withUpdatedAt() {
|
||||
query[0] = query[0].set({ subField: "updatedAt", level })
|
||||
return this
|
||||
},
|
||||
/** The owner of the thread */
|
||||
withUser(fn?: Fn<typeof User>) {
|
||||
query[0] = query[0].set({ subField: "user", level, hasSubField: true })
|
||||
if (!fn) query[0] = query[0].set({ subField: "id", level: level + 1 })
|
||||
else {
|
||||
let tmpQuery
|
||||
fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
}
|
||||
return this
|
||||
},
|
||||
/** The user to last reply to the thread */
|
||||
withReplyUser(fn?: Fn<typeof User>) {
|
||||
query[0] = query[0].set({ subField: "replayUser", level, hasSubField: true })
|
||||
if (!fn) query[0] = query[0].set({ subField: "id", level: level + 1 })
|
||||
else {
|
||||
let tmpQuery
|
||||
fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
}
|
||||
return this
|
||||
},
|
||||
/** The users who liked the thread */
|
||||
withLikes(fn?: Fn<typeof User>) {
|
||||
query[0] = query[0].set({ subField: "likes", level, hasSubField: true })
|
||||
if (!fn) query[0] = query[0].set({ subField: "id", level: level + 1 })
|
||||
else {
|
||||
let tmpQuery
|
||||
fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
}
|
||||
return this
|
||||
},
|
||||
/** The url for the thread page on the AniList website */
|
||||
withSiteUrl() {
|
||||
query[0] = query[0].set({ subField: "siteUrl", level })
|
||||
return this
|
||||
},
|
||||
/** The categories of the thread */
|
||||
withCategories(
|
||||
fn: Fn<typeof ThreadCategory>,
|
||||
) {
|
||||
query[0] = query[0].set({ subField: "categories", level })
|
||||
let tmpQuery
|
||||
fn(ThreadCategory({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/** The media categories of the thread */
|
||||
withMediaCategories(fn: Fn<typeof Media>) {
|
||||
query[0] = query[0].set({ subField: "mediaCategories", level, hasSubField: true })
|
||||
let tmpQuery
|
||||
fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
})
|
|
@ -0,0 +1,95 @@
|
|||
import { User } from "./User.ts"
|
||||
import { Thread } from "./Thread.ts"
|
||||
import { Fields, Fn, UpdateOperation } from "../types/Anilist.ts"
|
||||
|
||||
export const ThreadComment = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** The id of the comment */
|
||||
withId() {
|
||||
query[0] = query[0].set({ subField: "id", level })
|
||||
return this
|
||||
},
|
||||
/** The user id of the comment's owner */
|
||||
withUserId() {
|
||||
query[0] = query[0].set({ subField: "userId", level })
|
||||
return this
|
||||
},
|
||||
/** The id of thread the comment belongs to */
|
||||
withThreadId() {
|
||||
query[0] = query[0].set({ subField: "threadId", level })
|
||||
return this
|
||||
},
|
||||
/** The text content of the comment (Markdown) */
|
||||
withComment(args?: { asHtml: boolean }) {
|
||||
query[0] = query[0].set({ subField: "comment", level, variables: args })
|
||||
return this
|
||||
},
|
||||
/** The amount of likes the comment has */
|
||||
withLikeCount() {
|
||||
query[0] = query[0].set({ subField: "likeCount", level })
|
||||
return this
|
||||
},
|
||||
/** If the currently authenticated user liked the comment */
|
||||
withIsLiked() {
|
||||
query[0] = query[0].set({ subField: "isLiked", level })
|
||||
return this
|
||||
},
|
||||
/** The url for the comment page on the AniList website */
|
||||
withSiteUrl() {
|
||||
query[0] = query[0].set({ subField: "siteUrl", level })
|
||||
return this
|
||||
},
|
||||
/** The time of the comments creation */
|
||||
withCreatedAt() {
|
||||
query[0] = query[0].set({ subField: "createdAt", level })
|
||||
return this
|
||||
},
|
||||
/** The time of the comments last update */
|
||||
withUpdatedAt() {
|
||||
query[0] = query[0].set({ subField: "updatedAt", level })
|
||||
return this
|
||||
},
|
||||
/** The thread the comment belongs to */
|
||||
withThread(fn?: Fn<typeof Thread>) {
|
||||
query[0] = query[0].set({ subField: "thread", level, hasSubField: true })
|
||||
if (!fn) query[0] = query[0].set({ subField: "id", level: level + 1 })
|
||||
else {
|
||||
let tmpQuery
|
||||
fn(Thread({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
}
|
||||
|
||||
return this
|
||||
},
|
||||
/** The user who created the comment */
|
||||
withUser(fn?: Fn<typeof User>) {
|
||||
query[0] = query[0].set({ subField: "user", level, hasSubField: true })
|
||||
if (!fn) query[0] = query[0].set({ subField: "id", level: level + 1 })
|
||||
else {
|
||||
let tmpQuery
|
||||
fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
}
|
||||
return this
|
||||
},
|
||||
/** The users who liked the comment */
|
||||
withLikes(fn?: Fn<typeof User>) {
|
||||
query[0] = query[0].set({ subField: "likes", level, hasSubField: true })
|
||||
if (!fn) query[0] = query[0].set({ subField: "id", level: level + 1 })
|
||||
else {
|
||||
let tmpQuery
|
||||
fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
}
|
||||
return this
|
||||
},
|
||||
/** The comment's child reply comments */
|
||||
withChildComments() {
|
||||
query[0] = query[0].set({ subField: "childComments", level })
|
||||
return this
|
||||
},
|
||||
/** If the comment tree is locked and may not receive replies or edits */
|
||||
withIsLocked() {
|
||||
query[0] = query[0].set({ subField: "isLocked", level })
|
||||
return this
|
||||
},
|
||||
})
|
|
@ -0,0 +1,243 @@
|
|||
import { ListActivityOption, NotificationOption } from "../anilist.ts"
|
||||
import { Fields, Fn, UpdateOperation } from "../types/Anilist.ts"
|
||||
|
||||
export const UserPreviousName = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** A previous name of the user. */
|
||||
withName() {
|
||||
query[0] = query[0].set({ subField: "name", level })
|
||||
return this
|
||||
},
|
||||
/** When the user first changed from this name. */
|
||||
withCreatedAt() {
|
||||
query[0] = query[0].set({ subField: "createdAt", level })
|
||||
return this
|
||||
},
|
||||
/** When the user most recently changed from this name. */
|
||||
withUpdatedAt() {
|
||||
query[0] = query[0].set({ subField: "updatedAt", level })
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
export const UserOptions = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** The language the user wants to see media titles in */
|
||||
withTitleLanguage() {
|
||||
query[0] = query[0].set({ subField: "titleLanguage", level })
|
||||
return this
|
||||
},
|
||||
|
||||
/** Whether the user has enabled viewing of 18+ content */
|
||||
withDisplayAdultContent() {
|
||||
query[0] = query[0].set({ subField: "displayAdultContent", level })
|
||||
return this
|
||||
},
|
||||
|
||||
/** Whether the user receives notifications when a show they are watching aires */
|
||||
withAiringNotifications() {
|
||||
query[0] = query[0].set({ subField: "airingNotifications", level })
|
||||
return this
|
||||
},
|
||||
|
||||
/** Profile highlight color (blue, purple, pink, orange, red, green, gray) */
|
||||
withProfileColor() {
|
||||
query[0] = query[0].set({ subField: "profileColor", level })
|
||||
return this
|
||||
},
|
||||
|
||||
/** Notification options */
|
||||
withNotificationOptions(
|
||||
fn?: Fn<typeof NotificationOption>,
|
||||
) {
|
||||
query[0] = query[0].set({ subField: "notificationOptions", level })
|
||||
if (!fn) query[0] = query[0].set({ subField: "type", level: level + 1 })
|
||||
else {
|
||||
let tmpQuery
|
||||
fn(NotificationOption(tmpQuery = [query[0]], level + 1))
|
||||
query[0] = tmpQuery[0]
|
||||
}
|
||||
return this
|
||||
},
|
||||
|
||||
/** The user's timezone offset (Auth user only) */
|
||||
withTimezone() {
|
||||
query[0] = query[0].set({ subField: "timezone", level })
|
||||
return this
|
||||
},
|
||||
|
||||
/** Minutes between activity for them to be merged together. 0 is Never, Above 2 weeks (20160 mins) is Always. */
|
||||
withActivityMergeTime() {
|
||||
query[0] = query[0].set({ subField: "activityMergeTime", level })
|
||||
return this
|
||||
},
|
||||
|
||||
/** The language the user wants to see staff and character names in */
|
||||
withStaffNameLanguage() {
|
||||
query[0] = query[0].set({ subField: "staffNameLanguage", level })
|
||||
return this
|
||||
},
|
||||
|
||||
/** Whether the user only allow messages from users they follow */
|
||||
withRestrictMessagesToFollowing() {
|
||||
query[0] = query[0].set({ subField: "restrictMessagesToFollowing", level })
|
||||
return this
|
||||
},
|
||||
|
||||
/** The list activity types the user has disabled from being created from list updates */
|
||||
withDisabledListActivity(
|
||||
fn?: Fn<typeof ListActivityOption>,
|
||||
) {
|
||||
query[0] = query[0].set({
|
||||
subField: "disabledListActivity",
|
||||
level,
|
||||
hasSubField: true,
|
||||
})
|
||||
if (!fn) query[0] = query[0].set({ subField: "type", level: level + 1 })
|
||||
else {
|
||||
let tmpQuery
|
||||
fn(ListActivityOption(tmpQuery = [query[0]], level + 1))
|
||||
query[0] = tmpQuery[0]
|
||||
}
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
export const UserAvatar = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** The avatar of user at its largest size */
|
||||
withLarge() {
|
||||
query[0] = query[0].set({ subField: "large", level })
|
||||
return this
|
||||
},
|
||||
/** The avatar of user at medium size */
|
||||
withMedium() {
|
||||
query[0] = query[0].set({ subField: "medium", level })
|
||||
return this
|
||||
},
|
||||
})
|
||||
|
||||
export const User = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** The id of the user */
|
||||
withId() {
|
||||
query[0] = query[0].set({ subField: "id", level })
|
||||
return this
|
||||
},
|
||||
/** The name of the user */
|
||||
withName() {
|
||||
query[0] = query[0].set({ subField: "name", level })
|
||||
return this
|
||||
},
|
||||
/** The bio written by user (Markdown) */
|
||||
withAbout(args?: { asHtml: boolean }) {
|
||||
query[0] = query[0].set({ subField: "about", level, variables: args })
|
||||
return this
|
||||
},
|
||||
/** The user's avatar images */
|
||||
withAvatar(fn?: Fn<typeof UserAvatar>) {
|
||||
query[0] = query[0].set({ subField: "avatar", level, hasSubField: true })
|
||||
if (!fn) query[0] = query[0].set({ subField: "medium", level: level + 1 })
|
||||
else {
|
||||
let tmpQuery
|
||||
fn(UserAvatar({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
}
|
||||
return this
|
||||
},
|
||||
/** The user's banner images */
|
||||
withBannerImage() {
|
||||
query[0] = query[0].set({ subField: "bannerImage", level })
|
||||
return this
|
||||
},
|
||||
/** If the authenticated user if following this user */
|
||||
withIsFollowing() {
|
||||
query[0] = query[0].set({ subField: "isFollowing", level })
|
||||
return this
|
||||
},
|
||||
/** If this user if following the authenticated user */
|
||||
withIsFollower() {
|
||||
query[0] = query[0].set({ subField: "isFollower", level })
|
||||
return this
|
||||
},
|
||||
/** If the user is blocked by the authenticated user */
|
||||
withIsBlocked() {
|
||||
query[0] = query[0].set({ subField: "isBlocked", level })
|
||||
return this
|
||||
},
|
||||
withBans() {
|
||||
query[0] = query[0].set({ subField: "bans", level })
|
||||
return this
|
||||
},
|
||||
/* The user's general options */
|
||||
withOptions(fn: Fn<typeof UserOptions>) {
|
||||
query[0] = query[0].set({ subField: "options", level })
|
||||
let tmpQuery
|
||||
fn(UserOptions({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
/* The user's media list options */
|
||||
withMediaListOptions(_fn?: Fn<never>) {
|
||||
query[0] = query[0].set({ subField: "mediaListOptions", level })
|
||||
return this
|
||||
},
|
||||
/* The users favourites */
|
||||
withFavourites(args?: { page: number }, _fn?: Fn<never>) {
|
||||
query[0] = query[0].set({ subField: "favourites", level, variables: args })
|
||||
return this
|
||||
},
|
||||
/* The users anime & manga list statistics */
|
||||
withStatistics(_fn?: Fn<never>) {
|
||||
query[0] = query[0].set({ subField: "statistics", level })
|
||||
return this
|
||||
},
|
||||
/* The number of unread notifications the user has */
|
||||
withUnreadNotificationCount() {
|
||||
query[0] = query[0].set({ subField: "unreadNotificationCount", level })
|
||||
return this
|
||||
},
|
||||
/* The url for the user page on the AniList website */
|
||||
withSiteUrl() {
|
||||
query[0] = query[0].set({ subField: "siteUrl", level })
|
||||
return this
|
||||
},
|
||||
/* The donation tier of the user */
|
||||
withDonatorTier() {
|
||||
query[0] = query[0].set({ subField: "donatorTier", level })
|
||||
return this
|
||||
},
|
||||
/* Custom donation badge text */
|
||||
withDonatorBadge() {
|
||||
query[0] = query[0].set({ subField: "donatorBadge", level })
|
||||
return this
|
||||
},
|
||||
/* The user's moderator roles if they are a site moderator */
|
||||
withModeratorRoles() {
|
||||
query[0] = query[0].set({ subField: "moderatorRoles", level })
|
||||
return this
|
||||
},
|
||||
/* When the user's account was created. (Does not exist for accounts created before 2020) */
|
||||
withCreatedAt() {
|
||||
query[0] = query[0].set({ subField: "createdAt", level })
|
||||
return this
|
||||
},
|
||||
/* When the user's data was last updated */
|
||||
withUpdatedAt() {
|
||||
query[0] = query[0].set({ subField: "updatedAt", level })
|
||||
return this
|
||||
},
|
||||
/* The user's previously used names. */
|
||||
withPreviousNames(
|
||||
fn?: Fn<typeof UserPreviousName>,
|
||||
) {
|
||||
query[0] = query[0].set({
|
||||
subField: "previousNames",
|
||||
level,
|
||||
hasSubField: true,
|
||||
})
|
||||
if (!fn) query[0] = query[0].set({ subField: "name", level: level + 1 })
|
||||
else {
|
||||
let tmpQuery
|
||||
fn(UserPreviousName({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
}
|
||||
return this
|
||||
},
|
||||
})
|
Loading…
Reference in New Issue