496 lines
17 KiB
TypeScript
496 lines
17 KiB
TypeScript
import { Fields, Fn, OperationParser } from "../types/Anilist.ts"
|
|
import {
|
|
UserStatisticsCountriesArgs,
|
|
UserStatisticsFormatsArgs,
|
|
UserStatisticsGenresArgs,
|
|
UserStatisticsLengthsArgs,
|
|
UserStatisticsReleaseYearsArgs,
|
|
UserStatisticsScoresArgs,
|
|
UserStatisticsStaffArgs,
|
|
UserStatisticsStartYearsArgs,
|
|
UserStatisticsStatusesArgs,
|
|
UserStatisticsStudiosArgs,
|
|
UserStatisticsTagsArgs,
|
|
UserStatisticsVoiceActorsArgs,
|
|
} from "../../graphql-codegen/generated/graphql.ts"
|
|
import { Staff } from "./Staff.ts"
|
|
import { Studio } from "./Studio.ts"
|
|
|
|
const UserFormatStatistics = ({ operation, level }: Fields<OperationParser>) => ({
|
|
withCount(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "count", level })
|
|
return this
|
|
},
|
|
withMeanScore(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "meanScore", level })
|
|
return this
|
|
},
|
|
withMinutesWatched(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "minutesWatched", level })
|
|
return this
|
|
},
|
|
withChaptersRead(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "chaptersRead", level })
|
|
return this
|
|
},
|
|
withMediaIds(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "mediaIds", level })
|
|
return this
|
|
},
|
|
withFormat(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "format", level })
|
|
return this
|
|
},
|
|
})
|
|
|
|
const UserStatusStatistics = ({ operation, level }: Fields<OperationParser>) => ({
|
|
withCount(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "count", level })
|
|
return this
|
|
},
|
|
withMeanScore(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "meanScore", level })
|
|
return this
|
|
},
|
|
withMinutesWatched(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "minutesWatched", level })
|
|
return this
|
|
},
|
|
withChaptersRead(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "chaptersRead", level })
|
|
return this
|
|
},
|
|
withMediaIds(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "mediaIds", level })
|
|
return this
|
|
},
|
|
status(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "status", level })
|
|
return this
|
|
},
|
|
})
|
|
|
|
const UserScoreStatistics = ({ operation, level }: Fields<OperationParser>) => ({
|
|
withCount(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "count", level })
|
|
return this
|
|
},
|
|
withMeanScore(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "meanScore", level })
|
|
return this
|
|
},
|
|
withMinutesWatched(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "minutesWatched", level })
|
|
return this
|
|
},
|
|
withChaptersRead(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "chaptersRead", level })
|
|
return this
|
|
},
|
|
withMediaIds(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "mediaIds", level })
|
|
return this
|
|
},
|
|
score(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "score", level })
|
|
return this
|
|
},
|
|
})
|
|
|
|
const UserLengthStatistics = ({ operation, level }: Fields<OperationParser>) => ({
|
|
withCount(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "count", level })
|
|
return this
|
|
},
|
|
withMeanScore(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "meanScore", level })
|
|
return this
|
|
},
|
|
withMinutesWatched(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "minutesWatched", level })
|
|
return this
|
|
},
|
|
withChaptersRead(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "chaptersRead", level })
|
|
return this
|
|
},
|
|
withMediaIds(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "mediaIds", level })
|
|
return this
|
|
},
|
|
length(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "length", level })
|
|
return this
|
|
},
|
|
})
|
|
|
|
const UserReleaseYearStatistics = ({ operation, level }: Fields<OperationParser>) => ({
|
|
withCount(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "count", level })
|
|
return this
|
|
},
|
|
withMeanScore(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "meanScore", level })
|
|
return this
|
|
},
|
|
withMinutesWatched(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "minutesWatched", level })
|
|
return this
|
|
},
|
|
withChaptersRead(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "chaptersRead", level })
|
|
return this
|
|
},
|
|
withMediaIds(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "mediaIds", level })
|
|
return this
|
|
},
|
|
releaseYear(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "releaseYear", level })
|
|
return this
|
|
},
|
|
})
|
|
|
|
const UserStartYearStatistics = ({ operation, level }: Fields<OperationParser>) => ({
|
|
withCount(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "count", level })
|
|
return this
|
|
},
|
|
withMeanScore(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "meanScore", level })
|
|
return this
|
|
},
|
|
withMinutesWatched(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "minutesWatched", level })
|
|
return this
|
|
},
|
|
withChaptersRead(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "chaptersRead", level })
|
|
return this
|
|
},
|
|
withMediaIds(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "mediaIds", level })
|
|
return this
|
|
},
|
|
startYear(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "startYear", level })
|
|
return this
|
|
},
|
|
})
|
|
|
|
const UserGenreStatistics = ({ operation, level }: Fields<OperationParser>) => ({
|
|
withCount(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "count", level })
|
|
return this
|
|
},
|
|
withMeanScore(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "meanScore", level })
|
|
return this
|
|
},
|
|
withMinutesWatched(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "minutesWatched", level })
|
|
return this
|
|
},
|
|
withChaptersRead(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "chaptersRead", level })
|
|
return this
|
|
},
|
|
withMediaIds(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "mediaIds", level })
|
|
return this
|
|
},
|
|
genre(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "genre", level })
|
|
return this
|
|
},
|
|
})
|
|
|
|
const UserTagStatistics = ({ operation, level }: Fields<OperationParser>) => ({
|
|
withCount(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "count", level })
|
|
return this
|
|
},
|
|
withMeanScore(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "meanScore", level })
|
|
return this
|
|
},
|
|
withMinutesWatched(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "minutesWatched", level })
|
|
return this
|
|
},
|
|
withChaptersRead(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "chaptersRead", level })
|
|
return this
|
|
},
|
|
withMediaIds(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "mediaIds", level })
|
|
return this
|
|
},
|
|
tag(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "tag", level })
|
|
return this
|
|
},
|
|
})
|
|
|
|
const UserCountryStatistics = ({ operation, level }: Fields<OperationParser>) => ({
|
|
withCount(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "count", level })
|
|
return this
|
|
},
|
|
withMeanScore(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "meanScore", level })
|
|
return this
|
|
},
|
|
withMinutesWatched(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "minutesWatched", level })
|
|
return this
|
|
},
|
|
withChaptersRead(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "chaptersRead", level })
|
|
return this
|
|
},
|
|
withMediaIds(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "mediaIds", level })
|
|
return this
|
|
},
|
|
country(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "country", level })
|
|
return this
|
|
},
|
|
})
|
|
|
|
const UserVoiceActorStatistics = ({ operation, level }: Fields<OperationParser>) => ({
|
|
withCount(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "count", level })
|
|
return this
|
|
},
|
|
withMeanScore(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "meanScore", level })
|
|
return this
|
|
},
|
|
withMinutesWatched(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "minutesWatched", level })
|
|
return this
|
|
},
|
|
withChaptersRead(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "chaptersRead", level })
|
|
return this
|
|
},
|
|
withMediaIds(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "mediaIds", level })
|
|
return this
|
|
},
|
|
withVoiceActor(op?: { alias?: string; fn?: Fn<typeof Staff> }) {
|
|
operation.set({ alias: op?.alias, subField: "voiceActor", level, hasSubField: true })
|
|
if (op?.fn) op.fn(Staff({ operation, level: level + 1 }))
|
|
else Staff({ operation, level: level + 1 }).withId()
|
|
return this
|
|
},
|
|
withCharacterIds(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "characterIds", level })
|
|
return this
|
|
},
|
|
})
|
|
|
|
const UserStaffStatistics = ({ operation, level }: Fields<OperationParser>) => ({
|
|
withCount(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "count", level })
|
|
return this
|
|
},
|
|
withMeanScore(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "meanScore", level })
|
|
return this
|
|
},
|
|
withMinutesWatched(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "minutesWatched", level })
|
|
return this
|
|
},
|
|
withChaptersRead(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "chaptersRead", level })
|
|
return this
|
|
},
|
|
withMediaIds(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "mediaIds", level })
|
|
return this
|
|
},
|
|
withStaff(op?: { alias?: string; fn?: Fn<typeof Staff> }) {
|
|
operation.set({ alias: op?.alias, subField: "staff", level, hasSubField: true })
|
|
if (op?.fn) op?.fn(Staff({ operation, level: level + 1 }))
|
|
else Staff({ operation, level: level + 1 }).withId()
|
|
return this
|
|
},
|
|
})
|
|
|
|
const UserStudioStatistics = ({ operation, level }: Fields<OperationParser>) => ({
|
|
withCount(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "count", level })
|
|
return this
|
|
},
|
|
withMeanScore(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "meanScore", level })
|
|
return this
|
|
},
|
|
withMinutesWatched(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "minutesWatched", level })
|
|
return this
|
|
},
|
|
withChaptersRead(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "chaptersRead", level })
|
|
return this
|
|
},
|
|
withMediaIds(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "mediaIds", level })
|
|
return this
|
|
},
|
|
withStudio(op?: { alias?: string; fn?: Fn<typeof Studio> }) {
|
|
operation.set({ alias: op?.alias, subField: "studio", level, hasSubField: true })
|
|
if (op?.fn) op.fn(Studio({ operation, level: level + 1 }))
|
|
else Studio({ operation, level: level + 1 }).withId()
|
|
return this
|
|
},
|
|
})
|
|
|
|
export const UserStatistics = ({ operation, level }: Fields<OperationParser>) => ({
|
|
withCount(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "count", level })
|
|
return this
|
|
},
|
|
withMeanScore(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "meanScore", level })
|
|
return this
|
|
},
|
|
withStandardDeviation(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "standardDeviation", level })
|
|
return this
|
|
},
|
|
withMinutesWatched(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "minutesWatched", level })
|
|
return this
|
|
},
|
|
withEpisodesWatched(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "episodesWatched", level })
|
|
return this
|
|
},
|
|
withChaptersRead(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "chaptersRead", level })
|
|
return this
|
|
},
|
|
withVolumesRead(op?: { alias?: string }) {
|
|
operation.set({ alias: op?.alias, subField: "volumesRead", level })
|
|
return this
|
|
},
|
|
withFormats(
|
|
op: { alias?: string; args?: UserStatisticsFormatsArgs; fn: Fn<typeof UserFormatStatistics> },
|
|
) {
|
|
operation.set({ alias: op.alias, subField: "formats", level, hasSubField: true })
|
|
op.fn(UserFormatStatistics({ operation, level: level + 1 }))
|
|
return this
|
|
},
|
|
withStatuses(
|
|
op: { alias?: string; args?: UserStatisticsStatusesArgs; fn: Fn<typeof UserStatusStatistics> },
|
|
) {
|
|
operation.set({ alias: op.alias, subField: "statuses", level, hasSubField: true })
|
|
op.fn(UserStatusStatistics({ operation, level: level + 1 }))
|
|
return this
|
|
},
|
|
withScores(
|
|
op: { alias?: string; args?: UserStatisticsScoresArgs; fn: Fn<typeof UserScoreStatistics> },
|
|
) {
|
|
operation.set({ alias: op.alias, subField: "scores", level, hasSubField: true })
|
|
op.fn(UserScoreStatistics({ operation, level: level + 1 }))
|
|
return this
|
|
},
|
|
withLengths(
|
|
op: { alias?: string; args?: UserStatisticsLengthsArgs; fn: Fn<typeof UserLengthStatistics> },
|
|
) {
|
|
operation.set({ alias: op.alias, subField: "lengths", level, hasSubField: true })
|
|
op.fn(UserLengthStatistics({ operation, level: level + 1 }))
|
|
return this
|
|
},
|
|
withReleaseYears(
|
|
op: {
|
|
alias?: string
|
|
args?: UserStatisticsReleaseYearsArgs
|
|
fn: Fn<typeof UserReleaseYearStatistics>
|
|
},
|
|
) {
|
|
operation.set({ alias: op.alias, subField: "releaseYears", level, hasSubField: true })
|
|
op.fn(UserReleaseYearStatistics({ operation, level: level + 1 }))
|
|
return this
|
|
},
|
|
withStartYears(
|
|
op: {
|
|
alias?: string
|
|
args?: UserStatisticsStartYearsArgs
|
|
fn: Fn<typeof UserStartYearStatistics>
|
|
},
|
|
) {
|
|
operation.set({ alias: op.alias, subField: "startYears", level, hasSubField: true })
|
|
op.fn(UserStartYearStatistics({ operation, level: level + 1 }))
|
|
return this
|
|
},
|
|
withGenres(
|
|
op: { alias?: string; args?: UserStatisticsGenresArgs; fn: Fn<typeof UserGenreStatistics> },
|
|
) {
|
|
operation.set({ alias: op.alias, subField: "genres", level, hasSubField: true })
|
|
op.fn(UserGenreStatistics({ operation, level: level + 1 }))
|
|
return this
|
|
},
|
|
withTags(
|
|
op: { alias?: string; args?: UserStatisticsTagsArgs; fn: Fn<typeof UserTagStatistics> },
|
|
) {
|
|
operation.set({ alias: op.alias, subField: "tags", level, hasSubField: true })
|
|
op.fn(UserTagStatistics({ operation, level: level + 1 }))
|
|
return this
|
|
},
|
|
withCountries(
|
|
op: {
|
|
alias?: string
|
|
args?: UserStatisticsCountriesArgs
|
|
fn: Fn<typeof UserCountryStatistics>
|
|
},
|
|
) {
|
|
operation.set({ alias: op.alias, subField: "countries", level, hasSubField: true })
|
|
op.fn(UserCountryStatistics({ operation, level: level + 1 }))
|
|
return this
|
|
},
|
|
withVoiceActors(
|
|
op: {
|
|
alias?: string
|
|
args?: UserStatisticsVoiceActorsArgs
|
|
fn: Fn<typeof UserVoiceActorStatistics>
|
|
},
|
|
) {
|
|
operation.set({ alias: op.alias, subField: "voiceActors", level, hasSubField: true })
|
|
op.fn(UserVoiceActorStatistics({ operation, level: level + 1 }))
|
|
return this
|
|
},
|
|
withStaff(
|
|
op: { alias?: string; args?: UserStatisticsStaffArgs; fn: Fn<typeof UserStaffStatistics> },
|
|
) {
|
|
operation.set({ alias: op.alias, subField: "staff", level, hasSubField: true })
|
|
op.fn(UserStaffStatistics({ operation, level: level + 1 }))
|
|
return this
|
|
},
|
|
withStudios(
|
|
op: { alias?: string; args?: UserStatisticsStudiosArgs; fn: Fn<typeof UserStudioStatistics> },
|
|
) {
|
|
operation.set({ alias: op.alias, subField: "studios", level, hasSubField: true })
|
|
op.fn(UserStudioStatistics({ operation, level: level + 1 }))
|
|
return this
|
|
},
|
|
})
|
|
|
|
export const UserStatisticTypes = ({ operation, level }: Fields<OperationParser>) => ({
|
|
withAnime(op: { alias?: string; fn: Fn<typeof UserStatistics> }) {
|
|
operation.set({ alias: op.alias, subField: "anime", level, hasSubField: true })
|
|
op.fn(UserStatistics({ operation, level: level + 1 }))
|
|
return this
|
|
},
|
|
withManga(op: { alias?: string; fn: Fn<typeof UserStatistics> }) {
|
|
operation.set({ alias: op.alias, subField: "manga", level, hasSubField: true })
|
|
op.fn(UserStatistics({ operation, level: level + 1 }))
|
|
return this
|
|
},
|
|
})
|