3385 lines
108 KiB
TypeScript
3385 lines
108 KiB
TypeScript
import {
|
|
CharacterEdgeVoiceActorRolesArgs,
|
|
CharacterEdgeVoiceActorsArgs,
|
|
CharacterMediaArgs,
|
|
MediaAiringScheduleArgs,
|
|
MediaCharactersArgs,
|
|
MediaDescriptionArgs,
|
|
MediaEdgeRelationTypeArgs,
|
|
MediaEdgeVoiceActorRolesArgs,
|
|
MediaEdgeVoiceActorsArgs,
|
|
MediaRecommendationsArgs,
|
|
MediaReviewsArgs,
|
|
MediaSourceArgs,
|
|
MediaStaffArgs,
|
|
MediaStatusArgs,
|
|
MediaStudiosArgs,
|
|
MediaTrendsArgs,
|
|
QueryActivityReplyArgs,
|
|
QueryAiringScheduleArgs,
|
|
QueryCharacterArgs,
|
|
QueryExternalLinkSourceCollectionArgs,
|
|
QueryFollowerArgs,
|
|
QueryFollowingArgs,
|
|
QueryLikeArgs,
|
|
QueryMarkdownArgs,
|
|
QueryMediaArgs,
|
|
QueryMediaListArgs,
|
|
QueryMediaListCollectionArgs,
|
|
QueryMediaTagCollectionArgs,
|
|
QueryMediaTrendArgs,
|
|
QueryRecommendationArgs,
|
|
QueryReviewArgs,
|
|
QueryStaffArgs,
|
|
QueryStudioArgs,
|
|
QueryThreadArgs,
|
|
QueryThreadCommentArgs,
|
|
QueryUserArgs,
|
|
SiteStatisticsAnimeArgs,
|
|
SiteStatisticsCharactersArgs,
|
|
SiteStatisticsMangaArgs,
|
|
SiteStatisticsReviewsArgs,
|
|
SiteStatisticsStaffArgs,
|
|
SiteStatisticsStudiosArgs,
|
|
SiteStatisticsUsersArgs,
|
|
StaffCharacterMediaArgs,
|
|
StaffCharactersArgs,
|
|
StaffStaffMediaArgs,
|
|
StudioMediaArgs,
|
|
} from "./types/generated/graphql.ts"
|
|
import { Fetch, Fields, Fn, UpdateQuery } from "./types/Anilist.ts"
|
|
import type { AtLeastOne } from "./types/AtLeastOne.ts"
|
|
|
|
const rewriteVarValues = (
|
|
variable: PropertyKey | unknown | (PropertyKey | unknown)[],
|
|
) => {
|
|
switch (typeof variable) {
|
|
case "object":
|
|
return `[${variable}]`
|
|
case "string":
|
|
return variable === variable.toUpperCase() ? `${variable}` : `"${variable}"`
|
|
default:
|
|
return variable
|
|
}
|
|
}
|
|
const tab = (n: number) => new Array(n + 1).fill("").join("\t")
|
|
const t = tab
|
|
|
|
const updateOperation = (
|
|
{ query, variables, field, level, hasSubField }: UpdateQuery,
|
|
) => {
|
|
if (!query) query = `${field[level]} {\n\t%${field[level]}\n}`
|
|
const convertedType: [string[], string[]] = [[], []]
|
|
if (variables) {
|
|
const variable = Object.entries(variables)
|
|
for (let i = 0; i <= variable.length - 1; i++) {
|
|
convertedType[0].push(
|
|
`${variable[i][0]}: ${rewriteVarValues(variable[i][1])}`,
|
|
)
|
|
}
|
|
}
|
|
query = query
|
|
.replace(
|
|
`%${field[level - 1]}`,
|
|
`${field[level]}${variables ? ` (${convertedType[0].join(", ")})` : ""}${
|
|
hasSubField ? `${` {\n${t(level + 1)}%${field.at(-1)}\n${t(level)}}`}` : ""
|
|
}\n${t(level)}%${field[level - 1]}`,
|
|
)
|
|
|
|
return {
|
|
get() {
|
|
// return query
|
|
return query!.replace(/(\n|,)?(\t+| )%\w+\b/g, "")
|
|
},
|
|
set(
|
|
{ subField, variables, hasSubField, level }:
|
|
& Pick<UpdateQuery, "hasSubField" | "variables">
|
|
& { subField: string; level: number },
|
|
) {
|
|
// const f = [...field]
|
|
field.splice(level, 0, subField)
|
|
while (field.length - 1 > level) field.pop()
|
|
|
|
return updateOperation({ query, variables, level, field, hasSubField })
|
|
},
|
|
}
|
|
}
|
|
|
|
const fetch: Fetch = async (init) => {
|
|
let host:
|
|
| "https://graphql.anilist.co"
|
|
| "https://anilist.co/api/v2/oauth/token"
|
|
|
|
const body = {}
|
|
const headers = new Headers({
|
|
"Content-Type": "application/json",
|
|
"Accept": "application/json",
|
|
})
|
|
if ("code" in init) {
|
|
const {
|
|
client_id,
|
|
client_secret,
|
|
code,
|
|
redirect_uri,
|
|
grant_type = "authorization_code",
|
|
} = init
|
|
host = "https://anilist.co/api/v2/oauth/token"
|
|
Object.assign(body, {
|
|
grant_type,
|
|
client_id,
|
|
client_secret,
|
|
redirect_uri,
|
|
code,
|
|
})
|
|
} else {
|
|
host = "https://graphql.anilist.co"
|
|
const { query, token } = init
|
|
Object.assign(body, { query })
|
|
if (token) headers.set("Authorization", `Bearer ${token}`)
|
|
}
|
|
const res = await self.fetch(host, {
|
|
method: "POST",
|
|
headers,
|
|
body: JSON.stringify(body),
|
|
})
|
|
if (res.status !== 200) {
|
|
throw new Error("Something went wrong.", {
|
|
cause: JSON.stringify(await res.json()),
|
|
})
|
|
}
|
|
return await res.json()
|
|
}
|
|
|
|
const FuzzyDate = ({ query, level }: Fields<typeof updateOperation>) => ({
|
|
withDay() {
|
|
query[0] = query[0].set({ subField: "day", level })
|
|
return this
|
|
},
|
|
withMonth() {
|
|
query[0] = query[0].set({ subField: "month", level })
|
|
return this
|
|
},
|
|
withYear() {
|
|
query[0] = query[0].set({ subField: "year", level })
|
|
return this
|
|
},
|
|
})
|
|
const MediaList = ({ query, level }: Fields<typeof updateOperation>) => ({
|
|
withCompletedAt(fn: (fields: ReturnType<typeof FuzzyDate>) => void) {
|
|
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: (fields: ReturnType<typeof FuzzyDate>) => void) {
|
|
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: (fields: ReturnType<typeof User>) => void) {
|
|
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
|
|
},
|
|
})
|
|
|
|
const UserPreviousName = (query: ReturnType<typeof updateOperation>[], level: number) => ({
|
|
/** 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
|
|
},
|
|
})
|
|
const NotificationOption = (query: ReturnType<typeof updateOperation>[], level: number) => ({
|
|
withEnabled() {
|
|
query[0] = query[0].set({ subField: "enabled", level })
|
|
return this
|
|
},
|
|
withType() {
|
|
query[0] = query[0].set({ subField: "type", level })
|
|
return this
|
|
},
|
|
})
|
|
const ListActivityOption = (query: ReturnType<typeof updateOperation>[], level: number) => ({
|
|
withDisabled() {
|
|
query[0] = query[0].set({ subField: "disabled", level })
|
|
return this
|
|
},
|
|
withType() {
|
|
query[0] = query[0].set({ subField: "type", level })
|
|
return this
|
|
},
|
|
})
|
|
const UserOptions = (query: ReturnType<typeof updateOperation>[], level: number) => ({
|
|
/** 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?: (fields: ReturnType<typeof NotificationOption>) => void,
|
|
) {
|
|
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?: (fields: ReturnType<typeof ListActivityOption>) => void,
|
|
) {
|
|
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
|
|
},
|
|
})
|
|
const UserAvatar = (query: ReturnType<typeof updateOperation>[], level: number) => ({
|
|
/** 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
|
|
},
|
|
})
|
|
const Markdown = ({ query, level }: Fields<typeof updateOperation>) => ({
|
|
/** The parsed markdown as html */
|
|
withHtml() {
|
|
query[0] = query[0].set({ subField: "html", level })
|
|
return this
|
|
},
|
|
})
|
|
const AniChartUser = ({ query, level }: Fields<typeof updateOperation>) => ({
|
|
withUser(fn: Fn<typeof User>) {
|
|
query[0] = query[0].set({ subField: "user", level })
|
|
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
|
|
},
|
|
})
|
|
const SiteStatistics = ({ query, level }: Fields<typeof 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
|
|
},
|
|
})
|
|
const ExternalLinkSourceCollection = ({ query, level }: Fields<typeof 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 ActivityReply = ({ query, level }: Fields<typeof 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: (fields: ReturnType<typeof User>) => void) {
|
|
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: (fields: ReturnType<typeof User>) => void) {
|
|
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
|
|
},
|
|
})
|
|
const MediaListGroup = ({ query, level }: Fields<typeof updateOperation>) => ({
|
|
/** Media list entries */
|
|
withEntries(fn: (fields: ReturnType<typeof MediaList>) => void) {
|
|
query[0] = query[0].set({ subField: "entries", level })
|
|
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 MediaListCollection = ({ query, level }: Fields<typeof updateOperation>) => ({
|
|
/** Grouped media list entries */
|
|
withLists(fn: (fields: ReturnType<typeof MediaListGroup>) => void) {
|
|
query[0] = query[0].set({ subField: "lists", level })
|
|
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
|
|
},
|
|
})
|
|
const User = ({ query, level }: Fields<typeof 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?: (fields: ReturnType<typeof UserAvatar>) => void) {
|
|
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(tmpQuery = [query[0]], 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: (fields: ReturnType<typeof UserOptions>) => void) {
|
|
query[0] = query[0].set({ subField: "options", level })
|
|
let tmpQuery
|
|
fn(UserOptions(tmpQuery = [query[0]], level + 1))
|
|
query[0] = tmpQuery[0]
|
|
return this
|
|
},
|
|
/* The user's media list options */
|
|
withMediaListOptions(fn?: (fields: never) => void) {
|
|
query[0] = query[0].set({ subField: "mediaListOptions", level })
|
|
return this
|
|
},
|
|
/* The users favourites */
|
|
withFavourites(args?: { page: number }, fn?: (fields: never) => void) {
|
|
query[0] = query[0].set({ subField: "favourites", level, variables: args })
|
|
return this
|
|
},
|
|
/* The users anime & manga list statistics */
|
|
withStatistics(fn?: (fields: never) => void) {
|
|
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?: (fields: ReturnType<typeof UserPreviousName>) => void,
|
|
) {
|
|
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(tmpQuery = [query[0]], level + 1))
|
|
query[0] = tmpQuery[0]
|
|
}
|
|
return this
|
|
},
|
|
})
|
|
const Thread = ({ query, level }: Fields<typeof 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?: (fields: ReturnType<typeof User>) => void) {
|
|
query[0] = query[0].set({ subField: "user", level })
|
|
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?: (fields: ReturnType<typeof User>) => void) {
|
|
query[0] = query[0].set({ subField: "replayUser", level })
|
|
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?: (fields: ReturnType<typeof User>) => void) {
|
|
query[0] = query[0].set({ subField: "likes", level })
|
|
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: (fields: ReturnType<typeof ThreadCategory>) => void,
|
|
) {
|
|
query[0] = query[0].set({ subField: "categories", level })
|
|
let tmpQuery
|
|
fn(ThreadCategory(tmpQuery = [query[0]], level + 1))
|
|
query[0] = tmpQuery[0]
|
|
return this
|
|
},
|
|
/** The media categories of the thread */
|
|
withMediaCategories(fn: (fields: ReturnType<typeof Media>) => void) {
|
|
query[0] = query[0].set({ subField: "mediaCategories", level })
|
|
let tmpQuery
|
|
fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
|
|
query[0] = tmpQuery[0]
|
|
return this
|
|
},
|
|
})
|
|
|
|
const ThreadCategory = (query: ReturnType<typeof updateOperation>[], level: number) => ({
|
|
/** 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
|
|
},
|
|
})
|
|
|
|
const ThreadComment = (query: ReturnType<typeof updateOperation>[], level: number) => ({
|
|
/** 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?: (fields: ReturnType<typeof Thread>) => void) {
|
|
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?: (fields: ReturnType<typeof User>) => void) {
|
|
query[0] = query[0].set({ subField: "user", level })
|
|
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?: (fields: ReturnType<typeof User>) => void) {
|
|
query[0] = query[0].set({ subField: "likes", level })
|
|
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
|
|
},
|
|
})
|
|
|
|
const PageInfo = ({ query, level }: Fields<typeof updateOperation>) => ({
|
|
/** The total number of items. Note: This value is not guaranteed to be accurate, do not rely on this for logic */
|
|
withTotal() {
|
|
query[0] = query[0].set({ subField: "total", level })
|
|
return this
|
|
},
|
|
/** The count on a page */
|
|
withPerPage() {
|
|
query[0] = query[0].set({ subField: "perPage", level })
|
|
return this
|
|
},
|
|
/** The current page */
|
|
withCurrentPage() {
|
|
query[0] = query[0].set({ subField: "currentPage", level })
|
|
return this
|
|
},
|
|
/** The last page */
|
|
withLastPage() {
|
|
query[0] = query[0].set({ subField: "lastPage", level })
|
|
return this
|
|
},
|
|
/** If there is another page */
|
|
withHasNextPage() {
|
|
query[0] = query[0].set({ subField: "hasNextPage", level })
|
|
return this
|
|
},
|
|
})
|
|
|
|
const Media = ({ query, level }: Fields<typeof 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() {
|
|
query[0] = query[0].set({ subField: "nextAiringEpisode", level })
|
|
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: (fields: ReturnType<typeof StaffConnection>) => void,
|
|
) {
|
|
query[0] = query[0].set({ subField: "staff", level, variables: args })
|
|
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: (fields: ReturnType<typeof RecommendationConnection>) => void,
|
|
) {
|
|
query[0] = query[0].set({
|
|
subField: "recommendations",
|
|
level,
|
|
variables: args,
|
|
})
|
|
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: (fields: ReturnType<typeof CharacterConnection>) => void,
|
|
) {
|
|
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: (fields: ReturnType<typeof StudioConnection>) => void,
|
|
) {
|
|
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: (fields: ReturnType<typeof AiringScheduleConnection>) => void,
|
|
) {
|
|
query[0] = query[0].set({
|
|
subField: "airingSchedule",
|
|
level,
|
|
variables: args,
|
|
})
|
|
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: (fields: ReturnType<typeof MediaTrendConnection>) => void,
|
|
) {
|
|
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: (fields: ReturnType<typeof ReviewConnection>) => void,
|
|
) {
|
|
query[0] = query[0].set({ subField: "reviews", level, variables: args })
|
|
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: (fields: ReturnType<typeof MediaTitle>) => void) {
|
|
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: (fields: ReturnType<typeof FuzzyDate>) => void) {
|
|
query[0] = query[0].set({ subField: "startDate", level })
|
|
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: (fields: ReturnType<typeof FuzzyDate>) => void) {
|
|
query[0] = query[0].set({ subField: "endDate", level })
|
|
let tmpQuery
|
|
fn(FuzzyDate({ query: tmpQuery = [query[0]], level: level + 1 }))
|
|
query[0] = tmpQuery[0]
|
|
return this
|
|
},
|
|
/** Media trailer or advertisement */
|
|
withTrailer(fn: (fields: ReturnType<typeof MediaTrailer>) => void) {
|
|
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: (fields: ReturnType<typeof MediaCoverImage>) => void) {
|
|
query[0] = query[0].set({ subField: "coverImage", level })
|
|
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: (fields: ReturnType<typeof MediaTag>) => void) {
|
|
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: (fields: ReturnType<typeof MediaConnection>) => void) {
|
|
query[0] = query[0].set({ subField: "relations", level })
|
|
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: (fields: ReturnType<typeof MediaExternalLink>) => void,
|
|
) {
|
|
query[0] = query[0].set({ subField: "externalLinks", level })
|
|
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: (fields: ReturnType<typeof MediaStreamingEpisode>) => void,
|
|
) {
|
|
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: (fields: ReturnType<typeof MediaRank>) => void) {
|
|
query[0] = query[0].set({ subField: "rankings", level })
|
|
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: (fields: ReturnType<typeof MediaList>) => void,
|
|
) {
|
|
query[0] = query[0].set({ subField: "mediaListEntry", level })
|
|
let tmpQuery
|
|
fn(MediaList({ query: tmpQuery = [query[0]], level: level + 1 }))
|
|
query[0] = tmpQuery[0]
|
|
return this
|
|
},
|
|
withStats(fn: (fields: ReturnType<typeof MediaStats>) => void) {
|
|
query[0] = query[0].set({ subField: "stats", level })
|
|
let tmpQuery
|
|
fn(MediaStats({ query: tmpQuery = [query[0]], level: level + 1 }))
|
|
query[0] = tmpQuery[0]
|
|
return this
|
|
},
|
|
})
|
|
const MediaEdge = ({ query, level }: Fields<typeof 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
|
|
},
|
|
})
|
|
const MediaConnection = ({ query, level }: Fields<typeof 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
|
|
},
|
|
})
|
|
|
|
const StaffRoleType = ({ query, level }: Fields<typeof 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 CharacterName = ({ query, level }: Fields<typeof 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<typeof 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 StaffName = ({ query, level }: Fields<typeof 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<typeof 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 Staff = ({ query, level }: Fields<typeof 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
|
|
},
|
|
})
|
|
const StaffEdge = ({ query, level }: Fields<typeof updateOperation>) => ({
|
|
withNode(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
|
|
},
|
|
|
|
/** 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
|
|
},
|
|
})
|
|
const StaffConnection = ({ query, level }: Fields<typeof 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 Studio = ({ query, level }: Fields<typeof 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
|
|
},
|
|
})
|
|
const StudioEdge = ({ query, level }: Fields<typeof 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
|
|
},
|
|
})
|
|
const StudioConnection = ({ query, level }: Fields<typeof 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
|
|
},
|
|
})
|
|
|
|
const AiringSchedule = ({ query, level }: Fields<typeof 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
|
|
},
|
|
})
|
|
const AiringScheduleEdge = ({ query, level }: Fields<typeof 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
|
|
},
|
|
})
|
|
const AiringScheduleConnection = ({ query, level }: Fields<typeof 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
|
|
},
|
|
})
|
|
|
|
const MediaTrend = ({ query, level }: Fields<typeof 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
|
|
},
|
|
})
|
|
const MediaTrendEdge = ({ query, level }: Fields<typeof 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
|
|
},
|
|
})
|
|
const MediaTrendConnection = ({ query, level }: Fields<typeof 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
|
|
},
|
|
})
|
|
|
|
const Review = ({ query, level }: Fields<typeof 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
|
|
},
|
|
})
|
|
const ReviewEdge = ({ query, level }: Fields<typeof 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
|
|
},
|
|
})
|
|
const ReviewConnection = ({ query, level }: Fields<typeof 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
|
|
},
|
|
})
|
|
|
|
const Recommendation = ({ query, level }: Fields<typeof 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
|
|
},
|
|
})
|
|
const RecommendationEdge = ({ query, level }: Fields<typeof 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
|
|
},
|
|
})
|
|
const RecommendationConnection = ({ query, level }: Fields<typeof 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
|
|
},
|
|
})
|
|
|
|
const SiteTrend = ({ query, level }: Fields<typeof 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<typeof 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
|
|
},
|
|
})
|
|
const SiteTrendConnection = ({ query, level }: Fields<typeof 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
|
|
},
|
|
})
|
|
|
|
const Character = ({ query, level }: Fields<typeof 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
|
|
},
|
|
})
|
|
const CharacterEdge = ({ query, level }: Fields<typeof 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
|
|
},
|
|
})
|
|
|
|
const CharacterConnection = ({ query, level }: Fields<typeof 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
|
|
},
|
|
})
|
|
const MediaTitle = ({ query, level }: Fields<typeof 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<typeof 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<typeof 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 MediaTag = ({ query, level }: Fields<typeof 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
|
|
},
|
|
})
|
|
const MediaExternalLink = ({ query, level }: Fields<typeof 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<typeof 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<typeof 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<typeof 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<typeof 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<typeof updateOperation>) => ({
|
|
withScore() {
|
|
query[0] = query[0].set({ subField: "score", level })
|
|
return this
|
|
},
|
|
withAmount() {
|
|
query[0] = query[0].set({ subField: "amount", level })
|
|
return this
|
|
},
|
|
})
|
|
|
|
export const Client = function (auth?: { token: string }) {
|
|
let operation: ReturnType<typeof updateOperation>
|
|
return {
|
|
get auth() {
|
|
return {
|
|
getToken(init: {
|
|
code: string
|
|
client_id: string
|
|
client_secret: string
|
|
redirect_uri: string
|
|
}) {
|
|
return fetch(init)
|
|
},
|
|
}
|
|
},
|
|
get query() {
|
|
operation = updateOperation({
|
|
field: ["query"],
|
|
level: 0,
|
|
})
|
|
|
|
return {
|
|
get raw() {
|
|
return {
|
|
get() {
|
|
return operation.get()
|
|
},
|
|
}
|
|
},
|
|
fetch() {
|
|
return fetch({ query: this.raw.get()! })
|
|
},
|
|
Page() {
|
|
throw "To be Implemented"
|
|
},
|
|
/** Media query */
|
|
Media(
|
|
args: AtLeastOne<QueryMediaArgs>,
|
|
fn?: (fields: ReturnType<typeof Media>) => void,
|
|
) {
|
|
operation = operation.set({
|
|
subField: "Media",
|
|
variables: args,
|
|
hasSubField: true,
|
|
level: 1,
|
|
})
|
|
if (!fn) operation = operation.set({ subField: "id", level: 2 })
|
|
else {
|
|
let tmpQuery
|
|
fn(Media({ query: tmpQuery = [operation], level: 2 }))
|
|
operation = tmpQuery[0]
|
|
}
|
|
|
|
return this
|
|
},
|
|
/** Media Trend query */
|
|
MediaTrend(
|
|
args: QueryMediaTrendArgs,
|
|
fn?: (fields: ReturnType<typeof MediaTrend>) => void,
|
|
) {
|
|
operation = operation.set({
|
|
subField: "MediaTrend",
|
|
variables: args,
|
|
hasSubField: true,
|
|
level: 1,
|
|
})
|
|
if (!fn) operation = operation.set({ subField: "id", level: 2 })
|
|
else {
|
|
let tmpQuery
|
|
fn(MediaTrend({ query: tmpQuery = [operation], level: 2 }))
|
|
operation = tmpQuery[0]
|
|
}
|
|
return this
|
|
},
|
|
/** Airing schedule query */
|
|
AiringSchedule(
|
|
args: QueryAiringScheduleArgs,
|
|
fn?: (fields: ReturnType<typeof AiringSchedule>) => void,
|
|
) {
|
|
operation = operation.set({
|
|
subField: "AiringSchedule",
|
|
variables: args,
|
|
hasSubField: true,
|
|
level: 1,
|
|
})
|
|
if (!fn) operation = operation.set({ subField: "id", level: 2 })
|
|
else {
|
|
let tmpQuery
|
|
fn(AiringSchedule({ query: tmpQuery = [operation], level: 2 }))
|
|
operation = tmpQuery[0]
|
|
}
|
|
return this
|
|
},
|
|
/** Character query */
|
|
Character(
|
|
args: QueryCharacterArgs,
|
|
fn?: (fields: ReturnType<typeof Character>) => void,
|
|
) {
|
|
operation = operation.set({
|
|
subField: "Character",
|
|
variables: args,
|
|
hasSubField: true,
|
|
level: 1,
|
|
})
|
|
if (!fn) operation = operation.set({ subField: "id", level: 2 })
|
|
else {
|
|
let tmpQuery
|
|
fn(Character({ query: tmpQuery = [operation], level: 2 }))
|
|
operation = tmpQuery[0]
|
|
}
|
|
return this
|
|
},
|
|
/** Staff query */
|
|
Staff(
|
|
args: QueryStaffArgs,
|
|
fn?: (fields: ReturnType<typeof Staff>) => void,
|
|
) {
|
|
operation = operation.set({
|
|
subField: "Staff",
|
|
variables: args,
|
|
hasSubField: true,
|
|
level: 1,
|
|
})
|
|
if (!fn) operation = operation.set({ subField: "id", level: 2 })
|
|
else {
|
|
let tmpQuery
|
|
fn(Staff({ query: tmpQuery = [operation], level: 2 }))
|
|
operation = tmpQuery[0]
|
|
}
|
|
return this
|
|
},
|
|
/** Media list query */
|
|
MediaList(
|
|
args: QueryMediaListArgs,
|
|
fn?: (fields: ReturnType<typeof MediaList>) => void,
|
|
) {
|
|
operation = operation.set({
|
|
subField: "MediaList",
|
|
variables: args,
|
|
hasSubField: true,
|
|
level: 1,
|
|
})
|
|
if (!fn) operation = operation.set({ subField: "id", level: 2 })
|
|
else {
|
|
let tmpQuery
|
|
fn(MediaList({ query: tmpQuery = [operation], level: 2 }))
|
|
operation = tmpQuery[0]
|
|
}
|
|
return this
|
|
},
|
|
/** Media list collection query, provides list pre-grouped by status & custom lists. User ID and Media Type arguments required. */
|
|
MediaListCollection(
|
|
args: QueryMediaListCollectionArgs,
|
|
fn?: (fields: ReturnType<typeof MediaListCollection>) => void,
|
|
) {
|
|
operation = operation.set({
|
|
subField: "MediaListCollection",
|
|
variables: args,
|
|
hasSubField: true,
|
|
level: 1,
|
|
})
|
|
if (!fn) operation = operation.set({ subField: "id", level: 2 })
|
|
else {
|
|
let tmpQuery
|
|
fn(MediaListCollection({ query: tmpQuery = [operation], level: 2 }))
|
|
operation = tmpQuery[0]
|
|
}
|
|
return this
|
|
},
|
|
/** Collection of all the possible media genres */
|
|
GenreCollection() {
|
|
operation = operation.set({ subField: "GenreCollection", level: 1 })
|
|
return this
|
|
},
|
|
/** Collection of all the possible media tags */
|
|
MediaTagCollection(
|
|
args: QueryMediaTagCollectionArgs,
|
|
fn?: (fields: ReturnType<typeof MediaTag>) => void,
|
|
) {
|
|
operation = operation.set({
|
|
subField: "MediaTagCollection",
|
|
variables: args,
|
|
hasSubField: true,
|
|
level: 1,
|
|
})
|
|
if (!fn) operation = operation.set({ subField: "id", level: 2 })
|
|
else {
|
|
let tmpQuery
|
|
fn(MediaTag({ query: tmpQuery = [operation], level: 2 }))
|
|
operation = tmpQuery[0]
|
|
}
|
|
return this
|
|
},
|
|
/** User query */
|
|
User(
|
|
args: QueryUserArgs,
|
|
fn?: (fields: ReturnType<typeof User>) => void,
|
|
) {
|
|
operation = operation.set({
|
|
subField: "User",
|
|
variables: args,
|
|
hasSubField: true,
|
|
level: 1,
|
|
})
|
|
if (!fn) operation = operation.set({ subField: "id", level: 2 })
|
|
else {
|
|
let tmpQuery
|
|
fn(User({ query: tmpQuery = [operation], level: 2 }))
|
|
operation = tmpQuery[0]
|
|
}
|
|
return this
|
|
},
|
|
/** Get the currently authenticated user */
|
|
Viewer(
|
|
fn: (fields: ReturnType<typeof User>) => void,
|
|
) {
|
|
operation = operation.set({
|
|
subField: "Viewer",
|
|
hasSubField: true,
|
|
level: 1,
|
|
})
|
|
if (!fn) operation = operation.set({ subField: "id", level: 2 })
|
|
else {
|
|
let tmpQuery
|
|
fn(User({ query: tmpQuery = [operation], level: 2 }))
|
|
operation = tmpQuery[0]
|
|
}
|
|
return this
|
|
},
|
|
/** Notification query */
|
|
Notification() {
|
|
throw "To be Implemented"
|
|
},
|
|
/** Studio query */
|
|
Studio(
|
|
args: QueryStudioArgs,
|
|
fn?: (fields: ReturnType<typeof Studio>) => void,
|
|
) {
|
|
operation = operation.set({
|
|
subField: "Studio",
|
|
variables: args,
|
|
hasSubField: true,
|
|
level: 1,
|
|
})
|
|
if (!fn) operation = operation.set({ subField: "id", level: 2 })
|
|
else {
|
|
let tmpQuery
|
|
fn(Studio({ query: tmpQuery = [operation], level: 2 }))
|
|
operation = tmpQuery[0]
|
|
}
|
|
return this
|
|
},
|
|
/** Review query */
|
|
Review(
|
|
args: QueryReviewArgs,
|
|
fn?: (fields: ReturnType<typeof Review>) => void,
|
|
) {
|
|
operation = operation.set({
|
|
subField: "Review",
|
|
variables: args,
|
|
hasSubField: true,
|
|
level: 1,
|
|
})
|
|
if (!fn) operation = operation.set({ subField: "id", level: 2 })
|
|
else {
|
|
let tmpQuery
|
|
fn(Review({ query: tmpQuery = [operation], level: 2 }))
|
|
operation = tmpQuery[0]
|
|
}
|
|
return this
|
|
},
|
|
/** Activity query */
|
|
Activity() {
|
|
throw "To be Implemented"
|
|
},
|
|
/** Activity reply query */
|
|
ActivityReply(
|
|
args: QueryActivityReplyArgs,
|
|
fn?: (fields: ReturnType<typeof ActivityReply>) => void,
|
|
) {
|
|
operation = operation.set({
|
|
subField: "ActivityReply",
|
|
variables: args,
|
|
hasSubField: true,
|
|
level: 1,
|
|
})
|
|
if (!fn) operation = operation.set({ subField: "id", level: 2 })
|
|
else {
|
|
let tmpQuery
|
|
fn(ActivityReply({ query: tmpQuery = [operation], level: 2 }))
|
|
operation = tmpQuery[0]
|
|
}
|
|
return this
|
|
},
|
|
/** Follow query */
|
|
Following(
|
|
args: QueryFollowingArgs,
|
|
fn?: (fields: ReturnType<typeof User>) => void,
|
|
) {
|
|
operation = operation.set({
|
|
subField: "Following",
|
|
variables: args,
|
|
hasSubField: true,
|
|
level: 1,
|
|
})
|
|
if (!fn) operation = operation.set({ subField: "id", level: 2 })
|
|
else {
|
|
let tmpQuery
|
|
fn(User({ query: tmpQuery = [operation], level: 2 }))
|
|
operation = tmpQuery[0]
|
|
}
|
|
return this
|
|
},
|
|
/** Follow query */
|
|
Follower(
|
|
args: QueryFollowerArgs,
|
|
fn?: (fields: ReturnType<typeof User>) => void,
|
|
) {
|
|
operation = operation.set({
|
|
subField: "Follower",
|
|
variables: args,
|
|
hasSubField: true,
|
|
level: 1,
|
|
})
|
|
if (!fn) operation = operation.set({ subField: "id", level: 2 })
|
|
else {
|
|
let tmpQuery
|
|
fn(User({ query: tmpQuery = [operation], level: 2 }))
|
|
operation = tmpQuery[0]
|
|
}
|
|
return this
|
|
},
|
|
/** Thread query */
|
|
Thread(
|
|
args: QueryThreadArgs,
|
|
fn?: (fields: ReturnType<typeof Thread>) => void,
|
|
) {
|
|
operation = operation.set({
|
|
subField: "Thread",
|
|
variables: args,
|
|
hasSubField: true,
|
|
level: 1,
|
|
})
|
|
if (!fn) operation = operation.set({ subField: "id", level: 2 })
|
|
else {
|
|
let tmpQuery
|
|
fn(Thread({ query: tmpQuery = [operation], level: 2 }))
|
|
operation = tmpQuery[0]
|
|
}
|
|
return this
|
|
},
|
|
/** Comment query */
|
|
ThreadComment(
|
|
args: QueryThreadCommentArgs,
|
|
fn?: (fields: ReturnType<typeof ThreadComment>) => void,
|
|
) {
|
|
operation = operation.set({
|
|
level: 1,
|
|
subField: "ThreadComment",
|
|
hasSubField: true,
|
|
variables: args,
|
|
})
|
|
if (!fn) operation = operation.set({ level: 2, subField: "id" })
|
|
else {
|
|
let tmpQuery
|
|
fn(ThreadComment(tmpQuery = [operation], 2))
|
|
operation = tmpQuery[0]
|
|
}
|
|
return this
|
|
},
|
|
/** Recommendation query */
|
|
Recommendation(
|
|
args: QueryRecommendationArgs,
|
|
fn?: (fields: ReturnType<typeof Recommendation>) => void,
|
|
) {
|
|
operation = operation.set({
|
|
subField: "Recommendation",
|
|
variables: args,
|
|
hasSubField: true,
|
|
level: 1,
|
|
})
|
|
if (!fn) operation = operation.set({ subField: "id", level: 2 })
|
|
else {
|
|
let tmpQuery
|
|
fn(Recommendation({ query: tmpQuery = [operation], level: 2 }))
|
|
operation = tmpQuery[0]
|
|
}
|
|
return this
|
|
},
|
|
/** Like query */
|
|
Like(
|
|
args: QueryLikeArgs,
|
|
fn?: (fields: ReturnType<typeof User>) => void,
|
|
) {
|
|
operation = operation.set({
|
|
subField: "Like",
|
|
variables: args,
|
|
hasSubField: true,
|
|
level: 1,
|
|
})
|
|
if (!fn) operation = operation.set({ subField: "id", level: 2 })
|
|
else {
|
|
let tmpQuery
|
|
fn(User({ query: tmpQuery = [operation], level: 2 }))
|
|
operation = tmpQuery[0]
|
|
}
|
|
return this
|
|
},
|
|
/** Provide AniList markdown to be converted to html (Requires auth) */
|
|
Markdown(
|
|
args: QueryMarkdownArgs,
|
|
fn: (fields: ReturnType<typeof Markdown>) => void,
|
|
) {
|
|
operation = operation.set({
|
|
subField: "Markdown",
|
|
hasSubField: true,
|
|
variables: args,
|
|
level: 1,
|
|
})
|
|
let tmpQuery
|
|
fn(Markdown({ query: tmpQuery = [operation], level: 2 }))
|
|
operation = tmpQuery[0]
|
|
return this
|
|
},
|
|
AniChartUser(fn: (fields: ReturnType<typeof AniChartUser>) => void) {
|
|
operation = operation.set({ subField: "AniChartUser", hasSubField: true, level: 1 })
|
|
let tmpQuery
|
|
fn(AniChartUser({ query: tmpQuery = [operation], level: 2 }))
|
|
operation = tmpQuery[0]
|
|
|
|
return this
|
|
},
|
|
/** Site statistics query */
|
|
SiteStatistics(
|
|
fn?: (fields: ReturnType<typeof SiteStatistics>) => void,
|
|
) {
|
|
operation = operation.set({
|
|
subField: "SiteStatistics",
|
|
hasSubField: true,
|
|
level: 1,
|
|
})
|
|
if (!fn) operation = operation.set({ subField: "id", level: 2 })
|
|
else {
|
|
let tmpQuery
|
|
fn(SiteStatistics({ query: tmpQuery = [operation], level: 2 }))
|
|
operation = tmpQuery[0]
|
|
}
|
|
return this
|
|
},
|
|
/** ExternalLinkSource collection query */
|
|
ExternalLinkSourceCollection(
|
|
args: QueryExternalLinkSourceCollectionArgs,
|
|
fn?: (fields: ReturnType<typeof ExternalLinkSourceCollection>) => void,
|
|
) {
|
|
operation = operation.set({
|
|
subField: "ExternalLinkSourceCollection",
|
|
variables: args,
|
|
hasSubField: true,
|
|
level: 1,
|
|
})
|
|
if (!fn) operation = operation.set({ subField: "id", level: 2 })
|
|
else {
|
|
let tmpQuery
|
|
fn(ExternalLinkSourceCollection({ query: tmpQuery = [operation], level: 2 }))
|
|
operation = tmpQuery[0]
|
|
}
|
|
return this
|
|
},
|
|
}
|
|
},
|
|
get mutation() {
|
|
operation = updateOperation({
|
|
field: ["mutation"],
|
|
level: 0,
|
|
})
|
|
|
|
return {
|
|
get raw() {
|
|
return {
|
|
get() {
|
|
return operation.get()
|
|
},
|
|
}
|
|
},
|
|
fetch() {
|
|
return fetch({
|
|
query: this.raw.get()!,
|
|
token: auth?.token,
|
|
})
|
|
},
|
|
/** Update current user options */
|
|
UpdateUser() {
|
|
throw "To be Implemented"
|
|
},
|
|
/** Create or update a media list entry */
|
|
SaveMediaListEntry() {
|
|
throw "To be Implemented"
|
|
},
|
|
/** Update multiple media list entries to the same values */
|
|
UpdateMediaListEntries() {
|
|
throw "To be Implemented"
|
|
},
|
|
/** Delete a media list entry */
|
|
DeleteMediaListEntry() {
|
|
throw "To be Implemented"
|
|
},
|
|
/** Delete a custom list and remove the list entries from it */
|
|
DeleteCustomList() {
|
|
throw "To be Implemented"
|
|
},
|
|
/** Create or update text activity for the currently authenticated user */
|
|
SaveTextActivity() {
|
|
throw "To be Implemented"
|
|
},
|
|
/** Create or update message activity for the currently authenticated user */
|
|
SaveMessageActivity() {
|
|
throw "To be Implemented"
|
|
},
|
|
/** Update list activity (Mod Only) */
|
|
SaveListActivity() {
|
|
throw "To be Implemented"
|
|
},
|
|
/** Delete an activity item of the authenticated users */
|
|
DeleteActivity() {
|
|
throw "To be Implemented"
|
|
},
|
|
/** Toggle activity to be pinned to the top of the user's activity feed */
|
|
ToggleActivityPin() {
|
|
throw "To be Implemented"
|
|
},
|
|
/** Toggle the subscription of an activity item */
|
|
ToggleActivitySubscription() {
|
|
throw "To be Implemented"
|
|
},
|
|
/** Create or update an activity reply */
|
|
SaveActivityReply() {
|
|
throw "To be Implemented"
|
|
},
|
|
/** Delete an activity reply of the authenticated users */
|
|
DeleteActivityReply() {
|
|
throw "To be Implemented"
|
|
},
|
|
/** Add or remove a like from a likeable type. Returns all the users who liked the same model */
|
|
ToggleLike() {
|
|
throw "To be Implemented"
|
|
},
|
|
/** Add or remove a like from a likeable type. */
|
|
ToggleLikeV2() {
|
|
throw "To be Implemented"
|
|
},
|
|
/** Toggle the un/following of a user */
|
|
ToggleFollow() {
|
|
throw "To be Implemented"
|
|
},
|
|
/** Favourite or unfavourite an anime, manga, character, staff member, or studio */
|
|
ToggleFavourite() {
|
|
throw "To be Implemented"
|
|
},
|
|
/** Update the order favourites are displayed in */
|
|
UpdateFavouriteOrder() {
|
|
throw "To be Implemented"
|
|
},
|
|
/** Create or update a review */
|
|
SaveReview() {
|
|
throw "To be Implemented"
|
|
},
|
|
/** Delete a review */
|
|
DeleteReview() {
|
|
throw "To be Implemented"
|
|
},
|
|
/** Rate a review */
|
|
RateReview() {
|
|
throw "To be Implemented"
|
|
},
|
|
/** Recommendation a media */
|
|
SaveRecommendation() {
|
|
throw "To be Implemented"
|
|
},
|
|
/** Create or update a forum thread */
|
|
SaveThread() {
|
|
throw "To be Implemented"
|
|
},
|
|
/** Delete a thread */
|
|
DeleteThread() {
|
|
throw "To be Implemented"
|
|
},
|
|
/** Toggle the subscription of a forum thread */
|
|
ToggleThreadSubscription() {
|
|
throw "To be Implemented"
|
|
},
|
|
/** Create or update a thread comment */
|
|
SaveThreadComment(
|
|
args:
|
|
& ({
|
|
/** The comment id, required for updating */
|
|
id: number
|
|
} | {
|
|
/** The id of thread the comment belongs to */
|
|
threadId: number
|
|
} | {
|
|
/** The id of thread comment to reply to */
|
|
parentCommentId: number
|
|
})
|
|
& {
|
|
/** The comment markdown text */
|
|
comment: string
|
|
/** If the comment tree should be locked. (Mod Only) */
|
|
locked?: boolean
|
|
},
|
|
fn?: (fields: ReturnType<typeof ThreadComment>) => void,
|
|
) {
|
|
operation = operation.set({
|
|
level: 1,
|
|
subField: "SaveThreadComment",
|
|
hasSubField: true,
|
|
variables: args,
|
|
})
|
|
if (!fn) operation = operation.set({ level: 2, subField: "id" })
|
|
else {
|
|
let tmpQuery
|
|
fn(ThreadComment(tmpQuery = [operation], 2))
|
|
operation = tmpQuery[0]
|
|
}
|
|
return this
|
|
},
|
|
/** Delete a thread comment */
|
|
DeleteThreadComment() {
|
|
throw "To be Implemented"
|
|
},
|
|
UpdateAniChartSettings() {
|
|
throw "To be Implemented"
|
|
},
|
|
UpdateAniChartHighlights() {
|
|
throw "To be Implemented"
|
|
},
|
|
}
|
|
},
|
|
}
|
|
}
|