parent
ed7d209ea9
commit
e396f024a5
|
@ -41,6 +41,7 @@ import {
|
|||
QueryMediaTagCollectionArgs,
|
||||
QueryMediaTrendArgs,
|
||||
QueryNotificationArgs,
|
||||
QueryPageArgs,
|
||||
QueryRecommendationArgs,
|
||||
QueryReviewArgs,
|
||||
QueryStaffArgs,
|
||||
|
@ -81,6 +82,7 @@ import {
|
|||
} from "./queries/ActivityUnion.ts"
|
||||
import { LikeableUnion } from "./queries/LikeableUnion.ts"
|
||||
import { NotificationUnion } from "./queries/NotificationUnion.ts"
|
||||
import { Page } from "./queries/Page.ts"
|
||||
|
||||
const rewriteVarValues = (
|
||||
variable: PropertyKey | unknown | (PropertyKey | unknown)[],
|
||||
|
@ -200,34 +202,6 @@ export const FuzzyDate = ({ query, level }: Fields<typeof updateOperation>) => (
|
|||
},
|
||||
})
|
||||
|
||||
export 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
|
||||
},
|
||||
})
|
||||
|
||||
export const Deleted = ({ query, level }: Fields<typeof updateOperation>) => ({
|
||||
/** If an item has been successfully deleted */
|
||||
withDeleted() {
|
||||
|
@ -269,8 +243,18 @@ export const Client = function (auth?: { token: string }) {
|
|||
fetch() {
|
||||
return fetch({ query: this.raw.get()! })
|
||||
},
|
||||
Page() {
|
||||
throw "To be Implemented"
|
||||
Page(args: AtLeastOne<QueryPageArgs>, fn: Fn<typeof Page>) {
|
||||
operation = operation.set({
|
||||
subField: "Page",
|
||||
variables: args,
|
||||
hasSubField: true,
|
||||
level: 1,
|
||||
})
|
||||
let tmpQuery
|
||||
fn(Page({ query: tmpQuery = [operation], level: 2 }))
|
||||
operation = tmpQuery[0]
|
||||
|
||||
return this
|
||||
},
|
||||
/** Media query */
|
||||
Media(args: AtLeastOne<QueryMediaArgs>, fn?: Fn<typeof Media>) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { PageInfo } from "../anilist.ts"
|
||||
import { Fields, Fn, UpdateOperation } from "../types/Anilist.ts"
|
||||
import { Media } from "./Media.ts"
|
||||
import { PageInfo } from "./Page.ts"
|
||||
|
||||
const AiringScheduleEdge = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
withNode(fn: Fn<typeof AiringSchedule>) {
|
||||
|
|
|
@ -4,7 +4,8 @@ import {
|
|||
CharacterMediaArgs,
|
||||
} from "../types/generated/graphql.ts"
|
||||
import { Fields, Fn, UpdateOperation } from "../types/Anilist.ts"
|
||||
import { FuzzyDate, PageInfo } from "../anilist.ts"
|
||||
import { PageInfo } from "./Page.ts"
|
||||
import { FuzzyDate } from "../anilist.ts"
|
||||
import { Media, MediaConnection } from "./Media.ts"
|
||||
import { Staff, StaffRoleType } from "./Staff.ts"
|
||||
|
||||
|
|
|
@ -15,7 +15,8 @@ import {
|
|||
} from "../types/generated/graphql.ts"
|
||||
import { Fields, Fn, UpdateOperation } from "../types/Anilist.ts"
|
||||
import type { AtLeastOne } from "../types/AtLeastOne.ts"
|
||||
import { FuzzyDate, PageInfo } from "../anilist.ts"
|
||||
import { PageInfo } from "./Page.ts"
|
||||
import { FuzzyDate } from "../anilist.ts"
|
||||
import { MediaTag } from "./MediaTag.ts"
|
||||
import { MediaList } from "./MediaList.ts"
|
||||
import { AiringSchedule, AiringScheduleConnection } from "./AiringSchedule.ts"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Fields, Fn, UpdateOperation } from "../types/Anilist.ts"
|
||||
import { Media } from "./Media.ts"
|
||||
import { PageInfo } from "../anilist.ts"
|
||||
import { PageInfo } from "./Page.ts"
|
||||
|
||||
const MediaTrendEdge = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
withNode(fn: Fn<typeof MediaTrend>) {
|
||||
|
|
|
@ -0,0 +1,227 @@
|
|||
import { Fields, Fn, UpdateOperation } from "../types/Anilist.ts"
|
||||
import {
|
||||
PageActivitiesArgs,
|
||||
PageActivityRepliesArgs,
|
||||
PageAiringSchedulesArgs,
|
||||
PageCharactersArgs,
|
||||
PageFollowersArgs,
|
||||
PageFollowingArgs,
|
||||
// PageInfo,
|
||||
PageLikesArgs,
|
||||
PageMediaArgs,
|
||||
PageMediaListArgs,
|
||||
PageMediaTrendsArgs,
|
||||
PageNotificationsArgs,
|
||||
PageRecommendationsArgs,
|
||||
PageReviewsArgs,
|
||||
PageStaffArgs,
|
||||
PageStudiosArgs,
|
||||
PageThreadCommentsArgs,
|
||||
PageThreadsArgs,
|
||||
PageUsersArgs,
|
||||
} from "../types/generated/graphql.ts"
|
||||
import { ActivityReply } from "./ActivityReply.ts"
|
||||
import { ActivityUnion } from "./ActivityUnion.ts"
|
||||
import { AiringSchedule } from "./AiringSchedule.ts"
|
||||
import { Character } from "./Character.ts"
|
||||
import { Media } from "./Media.ts"
|
||||
import { MediaList } from "./MediaList.ts"
|
||||
import { MediaTrend } from "./MediaTrend.ts"
|
||||
import { NotificationUnion } from "./NotificationUnion.ts"
|
||||
import { Recommendation } from "./Recommendation.ts"
|
||||
import { Review } from "./Review.ts"
|
||||
import { Staff } from "./Staff.ts"
|
||||
import { Studio } from "./Studio.ts"
|
||||
import { Thread } from "./Thread.ts"
|
||||
import { ThreadComment } from "./ThreadComment.ts"
|
||||
import { User } from "./User.ts"
|
||||
|
||||
export const PageInfo = ({ query, level }: Fields<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
|
||||
},
|
||||
})
|
||||
|
||||
export const Page = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** 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
|
||||
},
|
||||
withUsers(args: PageUsersArgs, fn: Fn<typeof User>) {
|
||||
query[0] = query[0].set({ subField: "users", level, hasSubField: true, variables: args })
|
||||
let tmpQuery
|
||||
fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withMedia(args: PageMediaArgs, fn: Fn<typeof Media>) {
|
||||
query[0] = query[0].set({ subField: "media", level, hasSubField: true, variables: args })
|
||||
let tmpQuery
|
||||
fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withCharacters(args: PageCharactersArgs, fn: Fn<typeof Character>) {
|
||||
query[0] = query[0].set({ subField: "characters", level, hasSubField: true, variables: args })
|
||||
let tmpQuery
|
||||
fn(Character({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withStaff(args: PageStaffArgs, fn: Fn<typeof Staff>) {
|
||||
query[0] = query[0].set({ subField: "staff", level, hasSubField: true, variables: args })
|
||||
let tmpQuery
|
||||
fn(Staff({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withStudios(args: PageStudiosArgs, fn: Fn<typeof Studio>) {
|
||||
query[0] = query[0].set({ subField: "studios", level, hasSubField: true, variables: args })
|
||||
let tmpQuery
|
||||
fn(Studio({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withMediaList(args: PageMediaListArgs, fn: Fn<typeof MediaList>) {
|
||||
query[0] = query[0].set({ subField: "mediaList", level, hasSubField: true, variables: args })
|
||||
let tmpQuery
|
||||
fn(MediaList({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withAiringSchedules(args: PageAiringSchedulesArgs, fn: Fn<typeof AiringSchedule>) {
|
||||
query[0] = query[0].set({
|
||||
subField: "airingSchedules",
|
||||
level,
|
||||
hasSubField: true,
|
||||
variables: args,
|
||||
})
|
||||
let tmpQuery
|
||||
fn(AiringSchedule({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withMediaTrends(args: PageMediaTrendsArgs, fn: Fn<typeof MediaTrend>) {
|
||||
query[0] = query[0].set({ subField: "mediaTrends", level, hasSubField: true, variables: args })
|
||||
let tmpQuery
|
||||
fn(MediaTrend({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withNotifications(args: PageNotificationsArgs, fn: Fn<typeof NotificationUnion>) {
|
||||
query[0] = query[0].set({
|
||||
subField: "notifications",
|
||||
level,
|
||||
hasSubField: true,
|
||||
variables: args,
|
||||
})
|
||||
let tmpQuery
|
||||
fn(NotificationUnion({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withFollowers(args: PageFollowersArgs, fn: Fn<typeof User>) {
|
||||
query[0] = query[0].set({ subField: "followers", level, hasSubField: true, variables: args })
|
||||
let tmpQuery
|
||||
fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withFollowing(args: PageFollowingArgs, fn: Fn<typeof User>) {
|
||||
query[0] = query[0].set({ subField: "following", level, hasSubField: true, variables: args })
|
||||
let tmpQuery
|
||||
fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withActivities(args: PageActivitiesArgs, fn: Fn<typeof ActivityUnion>) {
|
||||
query[0] = query[0].set({ subField: "activities", level, hasSubField: true, variables: args })
|
||||
let tmpQuery
|
||||
fn(ActivityUnion({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withActivityReplies(args: PageActivityRepliesArgs, fn: Fn<typeof ActivityReply>) {
|
||||
query[0] = query[0].set({
|
||||
subField: "activityReplies",
|
||||
level,
|
||||
hasSubField: true,
|
||||
variables: args,
|
||||
})
|
||||
let tmpQuery
|
||||
fn(ActivityReply({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withThreads(args: PageThreadsArgs, fn: Fn<typeof Thread>) {
|
||||
query[0] = query[0].set({ subField: "threads", level, hasSubField: true, variables: args })
|
||||
let tmpQuery
|
||||
fn(Thread({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withThreadComments(args: PageThreadCommentsArgs, fn: Fn<typeof ThreadComment>) {
|
||||
query[0] = query[0].set({
|
||||
subField: "threadComments",
|
||||
level,
|
||||
hasSubField: true,
|
||||
variables: args,
|
||||
})
|
||||
let tmpQuery
|
||||
fn(ThreadComment({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withReviews(args: PageReviewsArgs, fn: Fn<typeof Review>) {
|
||||
query[0] = query[0].set({ subField: "reviews", level, hasSubField: true, variables: args })
|
||||
let tmpQuery
|
||||
fn(Review({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withRecommendations(args: PageRecommendationsArgs, fn: Fn<typeof Recommendation>) {
|
||||
query[0] = query[0].set({
|
||||
subField: "recommendations",
|
||||
level,
|
||||
hasSubField: true,
|
||||
variables: args,
|
||||
})
|
||||
let tmpQuery
|
||||
fn(Recommendation({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
withLikes(args: PageLikesArgs, fn: Fn<typeof User>) {
|
||||
query[0] = query[0].set({ subField: "likes", level, hasSubField: true, variables: args })
|
||||
let tmpQuery
|
||||
fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
|
||||
query[0] = tmpQuery[0]
|
||||
return this
|
||||
},
|
||||
})
|
|
@ -1,7 +1,7 @@
|
|||
import { Fields, Fn, UpdateOperation } from "../types/Anilist.ts"
|
||||
import { Media } from "./Media.ts"
|
||||
import { User } from "./User.ts"
|
||||
import { PageInfo } from "../anilist.ts"
|
||||
import { PageInfo } from "./Page.ts"
|
||||
|
||||
const RecommendationEdge = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
withNode(fn: Fn<typeof Recommendation>) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { PageInfo } from "../anilist.ts"
|
||||
import { PageInfo } from "./Page.ts"
|
||||
import { Fields, Fn, UpdateOperation } from "../types/Anilist.ts"
|
||||
import { Media } from "./Media.ts"
|
||||
import { User } from "./User.ts"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Fields, Fn, UpdateOperation } from "../types/Anilist.ts"
|
||||
import { PageInfo } from "../anilist.ts"
|
||||
import { PageInfo } from "./Page.ts"
|
||||
|
||||
const SiteTrend = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
/** The day the data was recorded (timestamp) */
|
||||
|
|
|
@ -4,7 +4,8 @@ import {
|
|||
StaffStaffMediaArgs,
|
||||
} from "../types/generated/graphql.ts"
|
||||
import { Fields, Fn, UpdateOperation } from "../types/Anilist.ts"
|
||||
import { FuzzyDate, PageInfo } from "../anilist.ts"
|
||||
import { FuzzyDate } from "../anilist.ts"
|
||||
import { PageInfo } from "./Page.ts"
|
||||
import { User } from "./User.ts"
|
||||
import { CharacterConnection } from "./Character.ts"
|
||||
import { MediaConnection } from "./Media.ts"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { StudioMediaArgs } from "../types/generated/graphql.ts"
|
||||
import { Fields, Fn, UpdateOperation } from "../types/Anilist.ts"
|
||||
import { PageInfo } from "../anilist.ts"
|
||||
import { PageInfo } from "./Page.ts"
|
||||
import { MediaConnection } from "./Media.ts"
|
||||
|
||||
const StudioEdge = ({ query, level }: Fields<UpdateOperation>) => ({
|
||||
|
|
Loading…
Reference in New Issue