normalize field arguments

This commit is contained in:
DrakeTDL 2023-10-19 10:53:27 -07:00
parent 69041caa68
commit 7feeb074f6
No known key found for this signature in database
22 changed files with 460 additions and 453 deletions

View File

@ -213,6 +213,7 @@ export const Deleted = ({ query, level }: Fields<typeof operationParser>) => ({
export const Client = function (auth?: { token: string }) {
let operation: ReturnType<typeof operationParser>
return {
get auth() {
return {
@ -664,69 +665,69 @@ export const Client = function (auth?: { token: string }) {
})
},
/** Update current user options */
UpdateUser(
UpdateUser(op:{
args: MutationUpdateUserArgs,
fn?: Fn<typeof User>,
fn?: Fn<typeof User>},
) {
operation = operation.set({
level: 1,
subField: "UpdateUser",
hasSubField: true,
variables: args,
variables: op.args,
})
if (!fn) operation = operation.set({ level: 2, subField: "id" })
if (!op.fn) operation = operation.set({ level: 2, subField: "id" })
else {
let tmpQuery
fn(User({ query: tmpQuery = [operation], level: 2 }))
op.fn(User({ query: tmpQuery = [operation], level: 2 }))
operation = tmpQuery[0]
}
return this
},
/** Create or update a media list entry */
SaveMediaListEntry(
SaveMediaListEntry(op:{
args: MutationSaveMediaListEntryArgs,
fn?: Fn<typeof MediaList>,
fn?: Fn<typeof MediaList>},
) {
operation = operation.set({
level: 1,
subField: "SaveMediaListEntry",
hasSubField: true,
variables: args,
variables: op.args,
})
if (!fn) operation = operation.set({ level: 2, subField: "id" })
if (!op.fn) operation = operation.set({ level: 2, subField: "id" })
else {
let tmpQuery
fn(MediaList({ query: tmpQuery = [operation], level: 2 }))
op.fn(MediaList({ query: tmpQuery = [operation], level: 2 }))
operation = tmpQuery[0]
}
return this
},
/** Update multiple media list entries to the same values */
UpdateMediaListEntries(
UpdateMediaListEntries(op:{
args: MutationUpdateMediaListEntriesArgs,
fn?: Fn<typeof MediaList>,
fn?: Fn<typeof MediaList>},
) {
operation = operation.set({
level: 1,
subField: "UpdateMediaListEntries",
hasSubField: true,
variables: args,
variables: op.args,
})
if (!fn) operation = operation.set({ level: 2, subField: "id" })
if (!op.fn) operation = operation.set({ level: 2, subField: "id" })
else {
let tmpQuery
fn(MediaList({ query: tmpQuery = [operation], level: 2 }))
op.fn(MediaList({ query: tmpQuery = [operation], level: 2 }))
operation = tmpQuery[0]
}
return this
},
/** Delete a media list entry */
DeleteMediaListEntry(args: MutationDeleteMediaListEntryArgs) {
DeleteMediaListEntry(op:{args: MutationDeleteMediaListEntryArgs}) {
operation = operation.set({
level: 1,
subField: "DeleteMediaListEntry",
hasSubField: true,
variables: args,
variables: op.args,
})
let tmpQuery
Deleted({ query: tmpQuery = [operation], level: 2 }).withDeleted()
@ -734,12 +735,12 @@ export const Client = function (auth?: { token: string }) {
return this
},
/** Delete a custom list and remove the list entries from it */
DeleteCustomList(args: MutationDeleteCustomListArgs) {
DeleteCustomList(op:{args: MutationDeleteCustomListArgs}) {
operation = operation.set({
level: 1,
subField: "DeleteCustomList",
hasSubField: true,
variables: args,
variables: op.args,
})
let tmpQuery
Deleted({ query: tmpQuery = [operation], level: 2 }).withDeleted()
@ -747,57 +748,57 @@ export const Client = function (auth?: { token: string }) {
return this
},
/** Create or update text activity for the currently authenticated user */
SaveTextActivity(args: MutationSaveTextActivityArgs, fn?: Fn<typeof TextActivity>) {
SaveTextActivity(op:{args: MutationSaveTextActivityArgs, fn?: Fn<typeof TextActivity>}) {
operation = operation.set({
level: 1,
subField: "TextActivity",
hasSubField: true,
variables: args,
variables: op.args,
})
let tmpQuery
if (!fn) TextActivity({ query: tmpQuery = [operation], level: 2 }).withId()
else fn(TextActivity({ query: tmpQuery = [operation], level: 2 }))
if (!op.fn) TextActivity({ query: tmpQuery = [operation], level: 2 }).withId()
else op.fn(TextActivity({ query: tmpQuery = [operation], level: 2 }))
operation = tmpQuery[0]
return this
},
/** Create or update message activity for the currently authenticated user */
SaveMessageActivity(
SaveMessageActivity(op:{
args: MutationSaveMessageActivityArgs,
fn?: Fn<typeof MessageActivity>,
fn?: Fn<typeof MessageActivity>},
) {
operation = operation.set({
level: 1,
subField: "MessageActivity",
hasSubField: true,
variables: args,
variables: op.args,
})
let tmpQuery
if (!fn) MessageActivity({ query: tmpQuery = [operation], level: 2 }).withId()
else fn(MessageActivity({ query: tmpQuery = [operation], level: 2 }))
if (!op.fn) MessageActivity({ query: tmpQuery = [operation], level: 2 }).withId()
else op.fn(MessageActivity({ query: tmpQuery = [operation], level: 2 }))
operation = tmpQuery[0]
return this
},
/** Update list activity (Mod Only) */
SaveListActivity(args: MutationSaveListActivityArgs, fn?: Fn<typeof ListActivity>) {
SaveListActivity(op:{args: MutationSaveListActivityArgs, fn?: Fn<typeof ListActivity>}) {
operation = operation.set({
level: 1,
subField: "ListActivity",
hasSubField: true,
variables: args,
variables: op.args,
})
let tmpQuery
if (!fn) ListActivity({ query: tmpQuery = [operation], level: 2 }).withId()
else fn(ListActivity({ query: tmpQuery = [operation], level: 2 }))
if (!op.fn) ListActivity({ query: tmpQuery = [operation], level: 2 }).withId()
else op.fn(ListActivity({ query: tmpQuery = [operation], level: 2 }))
operation = tmpQuery[0]
return this
},
/** Delete an activity item of the authenticated users */
DeleteActivity(args: MutationDeleteActivityArgs) {
DeleteActivity(op:{args: MutationDeleteActivityArgs}) {
operation = operation.set({
level: 1,
subField: "DeleteActivity",
hasSubField: true,
variables: args,
variables: op.args,
})
let tmpQuery
Deleted({ query: tmpQuery = [operation], level: 2 }).withDeleted()
@ -805,60 +806,60 @@ export const Client = function (auth?: { token: string }) {
return this
},
/** Toggle activity to be pinned to the top of the user's activity feed */
ToggleActivityPin(args: MutationToggleActivityPinArgs, fn: Fn<typeof ActivityUnion>) {
ToggleActivityPin(op:{args: MutationToggleActivityPinArgs, fn: Fn<typeof ActivityUnion>}) {
operation = operation.set({
level: 1,
subField: "ToggleActivityPin",
hasSubField: true,
variables: args,
variables: op.args,
})
let tmpQuery
fn(ActivityUnion({ query: tmpQuery = [operation], level: 2 }))
op.fn(ActivityUnion({ query: tmpQuery = [operation], level: 2 }))
operation = tmpQuery[0]
return this
},
/** Toggle the subscription of an activity item */
ToggleActivitySubscription(
ToggleActivitySubscription(op:{
args: MutationToggleActivitySubscriptionArgs,
fn: Fn<typeof ActivityUnion>,
fn: Fn<typeof ActivityUnion>},
) {
operation = operation.set({
level: 1,
subField: "ToggleActivitySubscription",
hasSubField: true,
variables: args,
variables: op.args,
})
let tmpQuery
fn(ActivityUnion({ query: tmpQuery = [operation], level: 2 }))
op.fn(ActivityUnion({ query: tmpQuery = [operation], level: 2 }))
operation = tmpQuery[0]
return this
},
/** Create or update an activity reply */
SaveActivityReply(
SaveActivityReply(op:{
args: MutationSaveActivityReplyArgs,
fn?: Fn<typeof ActivityReply>,
fn?: Fn<typeof ActivityReply>},
) {
operation = operation.set({
level: 1,
subField: "SaveActivityReply",
hasSubField: true,
variables: args,
variables: op.args,
})
if (!fn) operation = operation.set({ level: 2, subField: "id" })
if (!op.fn) operation = operation.set({ level: 2, subField: "id" })
else {
let tmpQuery
fn(ActivityReply({ query: tmpQuery = [operation], level: 2 }))
op.fn(ActivityReply({ query: tmpQuery = [operation], level: 2 }))
operation = tmpQuery[0]
}
return this
},
/** Delete an activity reply of the authenticated users */
DeleteActivityReply(args: MutationDeleteActivityReplyArgs) {
DeleteActivityReply(op:{args: MutationDeleteActivityReplyArgs}) {
operation = operation.set({
level: 1,
subField: "DeleteActivityReply",
hasSubField: true,
variables: args,
variables: op.args,
})
let tmpQuery
Deleted({ query: tmpQuery = [operation], level: 2 }).withDeleted()
@ -866,109 +867,109 @@ export const Client = function (auth?: { token: string }) {
return this
},
/** Add or remove a like from a likeable type. Returns all the users who liked the same model */
ToggleLike(
ToggleLike(op:{
args: MutationToggleLikeArgs,
fn?: Fn<typeof User>,
fn?: Fn<typeof User>},
) {
operation = operation.set({
level: 1,
subField: "ToggleLike",
hasSubField: true,
variables: args,
variables: op.args,
})
if (!fn) operation = operation.set({ level: 2, subField: "id" })
if (!op.fn) operation = operation.set({ level: 2, subField: "id" })
else {
let tmpQuery
fn(User({ query: tmpQuery = [operation], level: 2 }))
op.fn(User({ query: tmpQuery = [operation], level: 2 }))
operation = tmpQuery[0]
}
return this
},
/** Add or remove a like from a likeable type. */
ToggleLikeV2(args: MutationToggleLikeV2Args, fn: Fn<typeof LikeableUnion>) {
ToggleLikeV2(op:{args: MutationToggleLikeV2Args, fn: Fn<typeof LikeableUnion>}) {
operation = operation.set({
level: 1,
subField: "ToggleLikeV2",
hasSubField: true,
variables: args,
variables: op.args,
})
let tmpQuery
fn(LikeableUnion({ query: tmpQuery = [operation], level: 2 }))
op.fn(LikeableUnion({ query: tmpQuery = [operation], level: 2 }))
operation = tmpQuery[0]
return this
},
/** Toggle the un/following of a user */
ToggleFollow(
ToggleFollow(op:{
args: MutationToggleFollowArgs,
fn?: Fn<typeof User>,
fn?: Fn<typeof User>},
) {
operation = operation.set({
level: 1,
subField: "ToggleFollow",
hasSubField: true,
variables: args,
variables: op.args,
})
if (!fn) operation = operation.set({ level: 2, subField: "id" })
if (!op.fn) operation = operation.set({ level: 2, subField: "id" })
else {
let tmpQuery
fn(User({ query: tmpQuery = [operation], level: 2 }))
op.fn(User({ query: tmpQuery = [operation], level: 2 }))
operation = tmpQuery[0]
}
return this
},
/** Favourite or unfavourite an anime, manga, character, staff member, or studio */
ToggleFavourite(args: MutationToggleFavouriteArgs, fn: Fn<typeof Favourites>) {
ToggleFavourite(op:{args: MutationToggleFavouriteArgs, fn: Fn<typeof Favourites>}) {
operation = operation.set({
level: 1,
subField: "ToggleFavourite",
hasSubField: true,
variables: args,
variables: op.args,
})
let tmpQuery
fn(Favourites({ query: tmpQuery = [operation], level: 2 }))
op.fn(Favourites({ query: tmpQuery = [operation], level: 2 }))
operation = tmpQuery[0]
return this
},
/** Update the order favourites are displayed in */
UpdateFavouriteOrder(args: MutationUpdateFavouriteOrderArgs, fn: Fn<typeof Favourites>) {
UpdateFavouriteOrder(op:{args: MutationUpdateFavouriteOrderArgs, fn: Fn<typeof Favourites>}) {
operation = operation.set({
level: 1,
subField: "UpdateFavouriteOrder",
hasSubField: true,
variables: args,
variables: op.args,
})
let tmpQuery
fn(Favourites({ query: tmpQuery = [operation], level: 2 }))
op.fn(Favourites({ query: tmpQuery = [operation], level: 2 }))
operation = tmpQuery[0]
return this
},
/** Create or update a review */
SaveReview(
SaveReview(op:{
args: MutationSaveReviewArgs,
fn?: Fn<typeof Review>,
fn?: Fn<typeof Review>},
) {
operation = operation.set({
level: 1,
subField: "SaveReview",
hasSubField: true,
variables: args,
variables: op.args,
})
if (!fn) operation = operation.set({ level: 2, subField: "id" })
if (!op.fn) operation = operation.set({ level: 2, subField: "id" })
else {
let tmpQuery
fn(Review({ query: tmpQuery = [operation], level: 2 }))
op.fn(Review({ query: tmpQuery = [operation], level: 2 }))
operation = tmpQuery[0]
}
return this
},
/** Delete a review */
DeleteReview(args: MutationDeleteReviewArgs) {
DeleteReview(op:{args: MutationDeleteReviewArgs}) {
operation = operation.set({
level: 1,
subField: "DeleteReview",
hasSubField: true,
variables: args,
variables: op.args,
})
let tmpQuery
Deleted({ query: tmpQuery = [operation], level: 2 }).withDeleted()
@ -976,69 +977,69 @@ export const Client = function (auth?: { token: string }) {
return this
},
/** Rate a review */
RateReview(
RateReview(op:{
args: MutationRateReviewArgs,
fn?: Fn<typeof Review>,
fn?: Fn<typeof Review>},
) {
operation = operation.set({
level: 1,
subField: "RateReview",
hasSubField: true,
variables: args,
variables: op.args,
})
if (!fn) operation = operation.set({ level: 2, subField: "id" })
if (!op.fn) operation = operation.set({ level: 2, subField: "id" })
else {
let tmpQuery
fn(Review({ query: tmpQuery = [operation], level: 2 }))
op.fn(Review({ query: tmpQuery = [operation], level: 2 }))
operation = tmpQuery[0]
}
return this
},
/** Recommendation a media */
SaveRecommendation(
SaveRecommendation(op:{
args: MutationSaveRecommendationArgs,
fn?: Fn<typeof Recommendation>,
fn?: Fn<typeof Recommendation>},
) {
operation = operation.set({
level: 1,
subField: "SaveRecommendation",
hasSubField: true,
variables: args,
variables: op.args,
})
if (!fn) operation = operation.set({ level: 2, subField: "id" })
if (!op.fn) operation = operation.set({ level: 2, subField: "id" })
else {
let tmpQuery
fn(Recommendation({ query: tmpQuery = [operation], level: 2 }))
op.fn(Recommendation({ query: tmpQuery = [operation], level: 2 }))
operation = tmpQuery[0]
}
return this
},
/** Create or update a forum thread */
SaveThread(
SaveThread(op:{
args: MutationSaveThreadArgs,
fn?: Fn<typeof Thread>,
fn?: Fn<typeof Thread>},
) {
operation = operation.set({
level: 1,
subField: "SaveThread",
hasSubField: true,
variables: args,
variables: op.args,
})
if (!fn) operation = operation.set({ level: 2, subField: "id" })
if (!op.fn) operation = operation.set({ level: 2, subField: "id" })
else {
let tmpQuery
fn(Thread({ query: tmpQuery = [operation], level: 2 }))
op.fn(Thread({ query: tmpQuery = [operation], level: 2 }))
operation = tmpQuery[0]
}
return this
},
/** Delete a thread */
DeleteThread(args: MutationDeleteThreadArgs) {
DeleteThread(op:{args: MutationDeleteThreadArgs}) {
operation = operation.set({
level: 1,
subField: "DeleteThread",
hasSubField: true,
variables: args,
variables: op.args,
})
let tmpQuery
Deleted({ query: tmpQuery = [operation], level: 2 }).withDeleted()
@ -1046,50 +1047,50 @@ export const Client = function (auth?: { token: string }) {
return this
},
/** Toggle the subscription of a forum thread */
ToggleThreadSubscription(
ToggleThreadSubscription(op:{
args: MutationToggleThreadSubscriptionArgs,
fn?: Fn<typeof Thread>,
fn?: Fn<typeof Thread>},
) {
operation = operation.set({
level: 1,
subField: "ToggleThreadSubscription",
hasSubField: true,
variables: args,
variables: op.args,
})
if (!fn) operation = operation.set({ level: 2, subField: "id" })
if (!op.fn) operation = operation.set({ level: 2, subField: "id" })
else {
let tmpQuery
fn(Thread({ query: tmpQuery = [operation], level: 2 }))
op.fn(Thread({ query: tmpQuery = [operation], level: 2 }))
operation = tmpQuery[0]
}
return this
},
/** Create or update a thread comment */
SaveThreadComment(
SaveThreadComment(op:{
args: MutationSaveThreadCommentArgs,
fn?: Fn<typeof ThreadComment>,
fn?: Fn<typeof ThreadComment>},
) {
operation = operation.set({
level: 1,
subField: "SaveThreadComment",
hasSubField: true,
variables: args,
variables: op.args,
})
if (!fn) operation = operation.set({ level: 2, subField: "id" })
if (!op.fn) operation = operation.set({ level: 2, subField: "id" })
else {
let tmpQuery
fn(ThreadComment({ query: tmpQuery = [operation], level: 2 }))
op.fn(ThreadComment({ query: tmpQuery = [operation], level: 2 }))
operation = tmpQuery[0]
}
return this
},
/** Delete a thread comment */
DeleteThreadComment(args: MutationDeleteThreadCommentArgs) {
DeleteThreadComment(op:{args: MutationDeleteThreadCommentArgs}) {
operation = operation.set({
level: 1,
subField: "DeleteThreadComment",
hasSubField: true,
variables: args,
variables: op.args,
})
let tmpQuery
Deleted({ query: tmpQuery = [operation], level: 2 }).withDeleted()

View File

@ -1,4 +1,5 @@
import { Fields, Fn, OperationParser } from "../types/Anilist.ts"
import { ActivityReplyTextArgs } from "../types/generated/graphql.ts"
import { User } from "./User.ts"
export const ActivityReply = ({ query, level }: Fields<OperationParser>) => ({
@ -18,8 +19,8 @@ export const ActivityReply = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The reply text */
withText(args?: { asHtml: boolean }) {
query[0] = query[0].set({ subField: "text", level, variables: args })
withText(op?: { args?: ActivityReplyTextArgs }) {
query[0] = query[0].set({ subField: "text", level, variables: op?.args })
return this
},
/** The amount of likes the reply has */
@ -38,19 +39,19 @@ export const ActivityReply = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The user who created reply */
withUser(fn: Fn<typeof User>) {
withUser(op: { fn: Fn<typeof User> }) {
query[0] = query[0].set({ subField: "user", level, hasSubField: true })
let tmpQuery
if (fn) fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
else User({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
/** The users who liked the reply */
withLikes(fn?: Fn<typeof User>) {
withLikes(op?: { fn?: Fn<typeof User> }) {
query[0] = query[0].set({ subField: "likes", level, hasSubField: true })
let tmpQuery
if (fn) fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
else User({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this

View File

@ -1,4 +1,5 @@
import { Fields, Fn, OperationParser } from "../types/Anilist.ts"
import { MessageActivityMessageArgs, TextActivityTextArgs } from "../types/generated/graphql.ts"
import { ActivityReply } from "./ActivityReply.ts"
import { Media } from "./Media.ts"
import { User } from "./User.ts"
@ -25,8 +26,8 @@ export const TextActivity = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The status text (Markdown) */
withText(args?: { asHtml: boolean }) {
query[0] = query[0].set({ subField: "text", level, variables: args })
withText(op?: { args?: TextActivityTextArgs }) {
query[0] = query[0].set({ subField: "text", level, variables: op?.args })
return this
},
/** The url for the activity page on the AniList website */
@ -65,28 +66,28 @@ export const TextActivity = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The user who created the activity */
withUser(fn?: Fn<typeof User>) {
withUser(op?: { fn?: Fn<typeof User> }) {
query[0] = query[0].set({ subField: "user", level })
let tmpQuery
if (fn) fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
else User({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
/** The written replies to the activity */
withReplies(fn?: Fn<typeof ActivityReply>) {
withReplies(op?: { fn?: Fn<typeof ActivityReply> }) {
query[0] = query[0].set({ subField: "replies", level })
let tmpQuery
if (fn) fn(ActivityReply({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(ActivityReply({ query: tmpQuery = [query[0]], level: level + 1 }))
else ActivityReply({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
/** The users who liked the activity */
withLikes(fn?: Fn<typeof User>) {
withLikes(op?: { fn?: Fn<typeof User> }) {
query[0] = query[0].set({ subField: "likes", level })
let tmpQuery
if (fn) fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
else User({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
@ -160,37 +161,37 @@ export const ListActivity = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The owner of the activity */
withUser(fn?: Fn<typeof User>) {
withUser(op?: { fn?: Fn<typeof User> }) {
query[0] = query[0].set({ subField: "user", level })
let tmpQuery
if (fn) fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
else User({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
/** The associated media to the activity update */
withMedia(fn?: Fn<typeof Media>) {
withMedia(op?: { fn?: Fn<typeof Media> }) {
query[0] = query[0].set({ subField: "media", level })
let tmpQuery
if (fn) fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
else Media({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
/** The written replies to the activity */
withReplies(fn?: Fn<typeof ActivityReply>) {
withReplies(op?: { fn?: Fn<typeof ActivityReply> }) {
query[0] = query[0].set({ subField: "replies", level })
let tmpQuery
if (fn) fn(ActivityReply({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(ActivityReply({ query: tmpQuery = [query[0]], level: level + 1 }))
else ActivityReply({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
/** The users who liked the activity */
withLikes(fn?: Fn<typeof User>) {
withLikes(op?: { fn?: Fn<typeof User> }) {
query[0] = query[0].set({ subField: "likes", level })
let tmpQuery
if (fn) fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
else User({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
@ -224,8 +225,8 @@ export const MessageActivity = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The message text (Markdown) */
withMessage(args?: { asHtml: boolean }) {
query[0] = query[0].set({ subField: "message", level, variables: args })
withMessage(op?: { args?: MessageActivityMessageArgs }) {
query[0] = query[0].set({ subField: "message", level, variables: op?.args })
return this
},
/** If the activity is locked and can receive replies */
@ -264,37 +265,37 @@ export const MessageActivity = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The user who the activity message was sent to */
withRecipient(fn?: Fn<typeof User>) {
withRecipient(op?: { fn?: Fn<typeof User> }) {
query[0] = query[0].set({ subField: "recipient", level })
let tmpQuery
if (fn) fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
else User({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
/** The user who sent the activity message */
withMessenger(fn?: Fn<typeof User>) {
withMessenger(op?: { fn?: Fn<typeof User> }) {
query[0] = query[0].set({ subField: "messenger", level })
let tmpQuery
if (fn) fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
else User({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
/** The written replies to the activity */
withReplies(fn?: Fn<typeof ActivityReply>) {
withReplies(op?: { fn?: Fn<typeof ActivityReply> }) {
query[0] = query[0].set({ subField: "replies", level })
let tmpQuery
if (fn) fn(ActivityReply({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(ActivityReply({ query: tmpQuery = [query[0]], level: level + 1 }))
else ActivityReply({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
/** The users who liked the activity */
withLikes(fn?: Fn<typeof User>) {
withLikes(op?: { fn?: Fn<typeof User> }) {
query[0] = query[0].set({ subField: "likes", level })
let tmpQuery
if (fn) fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
else User({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
@ -302,23 +303,23 @@ export const MessageActivity = ({ query, level }: Fields<OperationParser>) => ({
})
export const ActivityUnion = ({ query, level }: Fields<OperationParser>) => ({
withTextActivity(fn?: Fn<typeof TextActivity>) {
withTextActivity(op?: { fn?: Fn<typeof TextActivity> }) {
query[0] = query[0].set({ subField: "TextActivity", level, hasSubField: true, isUnion: true })
let tmpQuery
if (fn) fn(TextActivity({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(TextActivity({ query: tmpQuery = [query[0]], level: level + 1 }))
else TextActivity({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
withListActivity(fn?: Fn<typeof ListActivity>) {
withListActivity(op?: { fn?: Fn<typeof ListActivity> }) {
query[0] = query[0].set({ subField: "ListActivity", level, hasSubField: true, isUnion: true })
let tmpQuery
if (fn) fn(ListActivity({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(ListActivity({ query: tmpQuery = [query[0]], level: level + 1 }))
else ListActivity({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
withMessageActivity(fn?: Fn<typeof MessageActivity>) {
withMessageActivity(op?: { fn?: Fn<typeof MessageActivity> }) {
query[0] = query[0].set({
subField: "MessageActivity",
level,
@ -326,7 +327,7 @@ export const ActivityUnion = ({ query, level }: Fields<OperationParser>) => ({
isUnion: true,
})
let tmpQuery
if (fn) fn(MessageActivity({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(MessageActivity({ query: tmpQuery = [query[0]], level: level + 1 }))
else MessageActivity({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this

View File

@ -3,10 +3,10 @@ import { Media } from "./Media.ts"
import { PageInfo } from "./Page.ts"
const AiringScheduleEdge = ({ query, level }: Fields<OperationParser>) => ({
withNode(fn: Fn<typeof AiringSchedule>) {
withNode(op: { 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 }))
op.fn(AiringSchedule({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
@ -18,25 +18,25 @@ const AiringScheduleEdge = ({ query, level }: Fields<OperationParser>) => ({
})
export const AiringScheduleConnection = ({ query, level }: Fields<OperationParser>) => ({
withEdges(fn: Fn<typeof AiringScheduleEdge>) {
withEdges(op: { 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 }))
op.fn(AiringScheduleEdge({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
withNodes(fn: Fn<typeof AiringSchedule>) {
withNodes(op: { 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 }))
op.fn(AiringSchedule({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
/** The pagination information */
withPageInfo(fn: Fn<typeof PageInfo>) {
withPageInfo(op: { 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 }))
op.fn(PageInfo({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
@ -69,10 +69,10 @@ export const AiringSchedule = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The associate media of the airing episode */
withMedia(fn?: Fn<typeof Media>) {
withMedia(op?: { fn?: Fn<typeof Media> }) {
query[0] = query[0].set({ subField: "media", level, hasSubField: true })
let tmpQuery
if (fn) fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
else Media({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this

View File

@ -2,10 +2,10 @@ import { Fields, Fn, OperationParser } from "../types/Anilist.ts"
import { User } from "./User.ts"
export const AniChartUser = ({ query, level }: Fields<OperationParser>) => ({
withUser(fn?: Fn<typeof User>) {
withUser(op?: { fn?: Fn<typeof User> }) {
query[0] = query[0].set({ subField: "user", level, hasSubField: true })
let tmpQuery
if (fn) fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
else User({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this

View File

@ -1,4 +1,5 @@
import {
CharacterDescriptionArgs,
CharacterEdgeVoiceActorRolesArgs,
CharacterEdgeVoiceActorsArgs,
CharacterMediaArgs,
@ -62,10 +63,10 @@ const CharacterImage = ({ query, level }: Fields<OperationParser>) => ({
})
const CharacterEdge = ({ query, level }: Fields<OperationParser>) => ({
withNode(fn: Fn<typeof Character>) {
withNode(op: { fn: Fn<typeof Character> }) {
query[0] = query[0].set({ subField: "node", level, hasSubField: true })
let tmpQuery
if (fn) fn(Character({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(Character({ query: tmpQuery = [query[0]], level: level + 1 }))
else Character({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
@ -115,10 +116,10 @@ const CharacterEdge = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The media the character is in */
withMedia(fn?: Fn<typeof Media>) {
withMedia(op?: { fn?: Fn<typeof Media> }) {
query[0] = query[0].set({ subField: "media", level, hasSubField: true })
let tmpQuery
if (fn) fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
else Media({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
@ -131,27 +132,27 @@ const CharacterEdge = ({ query, level }: Fields<OperationParser>) => ({
})
export const CharacterConnection = ({ query, level }: Fields<OperationParser>) => ({
withEdges(fn?: Fn<typeof CharacterEdge>) {
withEdges(op?: { fn?: Fn<typeof CharacterEdge> }) {
query[0] = query[0].set({ subField: "edges", level, hasSubField: true })
let tmpQuery
if (fn) fn(CharacterEdge({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(CharacterEdge({ query: tmpQuery = [query[0]], level: level + 1 }))
else CharacterEdge({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
withNodes(fn?: Fn<typeof Character>) {
withNodes(op?: { fn?: Fn<typeof Character> }) {
query[0] = query[0].set({ subField: "nodes", level, hasSubField: true })
let tmpQuery
if (fn) fn(Character({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(Character({ query: tmpQuery = [query[0]], level: level + 1 }))
else Character({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
/** The pagination information */
withPageInfo(fn: Fn<typeof PageInfo>) {
withPageInfo(op: { 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 }))
op.fn(PageInfo({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
@ -164,26 +165,26 @@ export const Character = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The names of the character */
withName(fn?: Fn<typeof CharacterName>) {
withName(op?: { fn?: Fn<typeof CharacterName> }) {
query[0] = query[0].set({ subField: "name", level, hasSubField: true })
let tmpQuery
if (fn) fn(CharacterName({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(CharacterName({ query: tmpQuery = [query[0]], level: level + 1 }))
else CharacterName({ query: tmpQuery = [query[0]], level: level + 1 }).withUserPreferred()
query[0] = tmpQuery[0]
return this
},
/** Character images */
withImage(fn?: Fn<typeof CharacterImage>) {
withImage(op?: { fn?: Fn<typeof CharacterImage> }) {
query[0] = query[0].set({ subField: "image", level, hasSubField: true })
let tmpQuery
if (fn) fn(CharacterImage({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(CharacterImage({ query: tmpQuery = [query[0]], level: level + 1 }))
else CharacterImage({ query: tmpQuery = [query[0]], level: level + 1 }).withMedium()
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 })
withDescription(op?: { args?: CharacterDescriptionArgs }) {
query[0] = query[0].set({ subField: "description", level, variables: op?.args })
return this
},
/** The character's gender. Usually Male, Female, or Non-binary but can be any string. */
@ -192,10 +193,10 @@ export const Character = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The character's birth date */
withDateOfBirth(fn?: Fn<typeof FuzzyDate>) {
withDateOfBirth(op?: { fn?: Fn<typeof FuzzyDate> }) {
query[0] = query[0].set({ subField: "dateOfBirth", level, hasSubField: true })
let tmpQuery
if (fn) fn(FuzzyDate({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(FuzzyDate({ query: tmpQuery = [query[0]], level: level + 1 }))
else {
FuzzyDate({ query: tmpQuery = [query[0]], level: level + 1 })
.withYear()

View File

@ -5,23 +5,23 @@ import { Thread } from "./Thread.ts"
import { ThreadComment } from "./ThreadComment.ts"
export const LikeableUnion = ({ query, level }: Fields<OperationParser>) => ({
withListActivity(fn?: Fn<typeof ListActivity>) {
withListActivity(op?: { fn?: Fn<typeof ListActivity> }) {
query[0] = query[0].set({ subField: "ListActivity", level, hasSubField: true, isUnion: true })
let tmpQuery
if (fn) fn(ListActivity({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(ListActivity({ query: tmpQuery = [query[0]], level: level + 1 }))
else ListActivity({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
withTextActivity(fn?: Fn<typeof TextActivity>) {
withTextActivity(op?: { fn?: Fn<typeof TextActivity> }) {
query[0] = query[0].set({ subField: "TextActivity", level, hasSubField: true, isUnion: true })
let tmpQuery
if (fn) fn(TextActivity({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(TextActivity({ query: tmpQuery = [query[0]], level: level + 1 }))
else TextActivity({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
withMessageActivity(fn?: Fn<typeof MessageActivity>) {
withMessageActivity(op?: { fn?: Fn<typeof MessageActivity> }) {
query[0] = query[0].set({
subField: "MessageActivity",
level,
@ -29,31 +29,31 @@ export const LikeableUnion = ({ query, level }: Fields<OperationParser>) => ({
isUnion: true,
})
let tmpQuery
if (fn) fn(MessageActivity({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(MessageActivity({ query: tmpQuery = [query[0]], level: level + 1 }))
else MessageActivity({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
withActivityReply(fn?: Fn<typeof ActivityReply>) {
withActivityReply(op?: { fn?: Fn<typeof ActivityReply> }) {
query[0] = query[0].set({ subField: "ActivityReply", level, hasSubField: true, isUnion: true })
let tmpQuery
if (fn) fn(ActivityReply({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(ActivityReply({ query: tmpQuery = [query[0]], level: level + 1 }))
else ActivityReply({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
withThread(fn?: Fn<typeof Thread>) {
withThread(op?: { fn?: Fn<typeof Thread> }) {
query[0] = query[0].set({ subField: "Thread", level, hasSubField: true, isUnion: true })
let tmpQuery
if (fn) fn(Thread({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(Thread({ query: tmpQuery = [query[0]], level: level + 1 }))
else Thread({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
withThreadComment(fn?: Fn<typeof ThreadComment>) {
withThreadComment(op?: { fn?: Fn<typeof ThreadComment> }) {
query[0] = query[0].set({ subField: "ThreadComment", level, hasSubField: true, isUnion: true })
let tmpQuery
if (fn) fn(ThreadComment({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(ThreadComment({ query: tmpQuery = [query[0]], level: level + 1 }))
else ThreadComment({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this

View File

@ -11,6 +11,9 @@ import {
MediaStaffArgs,
MediaStatusArgs,
MediaStudiosArgs,
MediaTitleEnglishArgs,
MediaTitleNativeArgs,
MediaTitleRomajiArgs,
MediaTrendsArgs,
} from "../types/generated/graphql.ts"
import { Fields, Fn, OperationParser } from "../types/Anilist.ts"
@ -29,10 +32,10 @@ import { StudioConnection } from "./Studio.ts"
export const MediaListGroup = ({ query, level }: Fields<OperationParser>) => ({
/** Media list entries */
withEntries(fn: Fn<typeof MediaList>) {
withEntries(op: { fn: Fn<typeof MediaList> }) {
query[0] = query[0].set({ subField: "entries", level, hasSubField: true })
let tmpQuery
fn(MediaList({ query: tmpQuery = [query[0]], level: level + 1 }))
op.fn(MediaList({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
@ -56,18 +59,18 @@ export const MediaListGroup = ({ query, level }: Fields<OperationParser>) => ({
const MediaTitle = ({ query, level }: Fields<OperationParser>) => ({
/** The romanization of the native language title */
romaji(args?: { stylised: boolean }) {
query[0] = query[0].set({ subField: "romaji", level, variables: args })
romaji(op?: { args?: MediaTitleRomajiArgs }) {
query[0] = query[0].set({ subField: "romaji", level, variables: op?.args })
return this
},
/** The official english title */
english(args?: { stylised: boolean }) {
query[0] = query[0].set({ subField: "english", level, variables: args })
english(op?: { args?: MediaTitleEnglishArgs }) {
query[0] = query[0].set({ subField: "english", level, variables: op?.args })
return this
},
/** Official title in it's native language */
native(args?: { stylised: boolean }) {
query[0] = query[0].set({ subField: "native", level, variables: args })
native(op?: { args?: MediaTitleNativeArgs }) {
query[0] = query[0].set({ subField: "native", level, variables: op?.args })
return this
},
/** The currently authenticated users preferred title language. Default romaji for non-authenticated */
@ -234,17 +237,17 @@ const MediaRank = ({ query, level }: Fields<OperationParser>) => ({
})
const MediaStats = ({ query, level }: Fields<OperationParser>) => ({
scoreDistribution(fn: Fn<typeof ScoreDistribution>) {
scoreDistribution(op: { 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 }))
op.fn(ScoreDistribution({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
statusDistribution(fn: Fn<typeof StatusDistribution>) {
statusDistribution(op: { 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 }))
op.fn(StatusDistribution({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
@ -273,10 +276,10 @@ const ScoreDistribution = ({ query, level }: Fields<OperationParser>) => ({
})
const MediaEdge = ({ query, level }: Fields<OperationParser>) => ({
withNode(fn?: Fn<typeof Media>) {
withNode(op?: { fn?: Fn<typeof Media> }) {
query[0] = query[0].set({ subField: "node", level, hasSubField: true })
let tmpQuery
if (fn) fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
else Media({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
@ -287,8 +290,8 @@ const MediaEdge = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The type of relation to the parent model */
withRelationType(args?: AtLeastOne<MediaEdgeRelationTypeArgs>) {
query[0] = query[0].set({ subField: "relationType", level, variables: args })
withRelationType(op?: { args?: AtLeastOne<MediaEdgeRelationTypeArgs> }) {
query[0] = query[0].set({ subField: "relationType", level, variables: op?.args })
return this
},
/** If the studio is the main animation studio of the media (For Studio->MediaConnection field only) */
@ -297,10 +300,10 @@ const MediaEdge = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The characters in the media voiced by the parent actor */
withCharacters(fn: Fn<typeof Character>) {
withCharacters(op: { 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 }))
op.fn(Character({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
@ -367,27 +370,27 @@ const MediaEdge = ({ query, level }: Fields<OperationParser>) => ({
})
export const MediaConnection = ({ query, level }: Fields<OperationParser>) => ({
withEdges(fn?: Fn<typeof MediaEdge>) {
withEdges(op?: { fn?: Fn<typeof MediaEdge> }) {
query[0] = query[0].set({ subField: "edges", level, hasSubField: true })
let tmpQuery
if (fn) fn(MediaEdge({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(MediaEdge({ query: tmpQuery = [query[0]], level: level + 1 }))
else MediaEdge({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
withNodes(fn?: Fn<typeof Media>) {
withNodes(op?: { fn?: Fn<typeof Media> }) {
query[0] = query[0].set({ subField: "nodes", level, hasSubField: true })
let tmpQuery
if (fn) fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
else Media({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
/** The pagination information */
withPageInfo(fn: Fn<typeof PageInfo>) {
withPageInfo(op: { 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 }))
op.fn(PageInfo({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
@ -530,10 +533,10 @@ export const Media = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The media's next episode airing schedule */
withNextAiringEpisode(fn?: Fn<typeof AiringSchedule>) {
withNextAiringEpisode(op?: { fn?: Fn<typeof AiringSchedule> }) {
query[0] = query[0].set({ subField: "nextAiringEpisode", level, hasSubField: true })
let tmpQuery
if (fn) fn(AiringSchedule({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(AiringSchedule({ query: tmpQuery = [query[0]], level: level + 1 }))
else AiringSchedule({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
@ -564,18 +567,18 @@ export const Media = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The current releasing status of the media */
withStatus(args?: AtLeastOne<MediaStatusArgs>) {
query[0] = query[0].set({ subField: "status", level, variables: args })
withStatus(op?: { args?: AtLeastOne<MediaStatusArgs> }) {
query[0] = query[0].set({ subField: "status", level, variables: op?.args })
return this
},
/** Short description of the media's story and characters */
withDescription(args?: AtLeastOne<MediaDescriptionArgs>) {
query[0] = query[0].set({ subField: "description", level, variables: args })
withDescription(op?: { args?: AtLeastOne<MediaDescriptionArgs> }) {
query[0] = query[0].set({ subField: "description", level, variables: op?.args })
return this
},
/** Source type the media was adapted from. */
withSource(args?: AtLeastOne<MediaSourceArgs>) {
query[0] = query[0].set({ subField: "source", level, variables: args })
withSource(op?: { args?: AtLeastOne<MediaSourceArgs> }) {
query[0] = query[0].set({ subField: "source", level, variables: op?.args })
return this
},
/** The staff who produced the media */
@ -661,18 +664,18 @@ export const Media = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The official titles of the media in various languages */
withTitle(fn: Fn<typeof MediaTitle>) {
withTitle(op: { fn: Fn<typeof MediaTitle> }) {
query[0] = query[0].set({ subField: "title", level, hasSubField: true })
let tmpQuery
fn(MediaTitle({ query: tmpQuery = [query[0]], level: level + 1 }))
op.fn(MediaTitle({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
/** The first official release date of the media */
withStartDate(fn?: Fn<typeof FuzzyDate>) {
withStartDate(op?: { fn?: Fn<typeof FuzzyDate> }) {
query[0] = query[0].set({ subField: "startDate", level, hasSubField: true })
let tmpQuery
if (fn) fn(FuzzyDate({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(FuzzyDate({ query: tmpQuery = [query[0]], level: level + 1 }))
else {
FuzzyDate({ query: tmpQuery = [query[0]], level: level + 1 })
.withYear()
@ -683,10 +686,10 @@ export const Media = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The last official release date of the media */
withEndDate(fn?: Fn<typeof FuzzyDate>) {
withEndDate(op?: { fn?: Fn<typeof FuzzyDate> }) {
query[0] = query[0].set({ subField: "endDate", level, hasSubField: true })
let tmpQuery
if (fn) fn(FuzzyDate({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(FuzzyDate({ query: tmpQuery = [query[0]], level: level + 1 }))
else {
FuzzyDate({ query: tmpQuery = [query[0]], level: level + 1 })
.withYear()
@ -697,79 +700,75 @@ export const Media = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** Media trailer or advertisement */
withTrailer(fn: Fn<typeof MediaTrailer>) {
withTrailer(op: { fn: Fn<typeof MediaTrailer> }) {
query[0] = query[0].set({ subField: "trailer", level, hasSubField: true })
let tmpQuery
fn(MediaTrailer({ query: tmpQuery = [query[0]], level: level + 1 }))
op.fn(MediaTrailer({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
/** The cover images of the media */
withCoverImage(fn?: Fn<typeof MediaCoverImage>) {
withCoverImage(op?: { fn?: Fn<typeof MediaCoverImage> }) {
query[0] = query[0].set({ subField: "coverImage", level, hasSubField: true })
let tmpQuery
if (fn) fn(MediaCoverImage({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(MediaCoverImage({ query: tmpQuery = [query[0]], level: level + 1 }))
else MediaCoverImage({ query: tmpQuery = [query[0]], level: level + 1 }).withMedium()
query[0] = tmpQuery[0]
return this
},
/** List of tags that describes elements and themes of the media */
withTags(fn: Fn<typeof MediaTag>) {
withTags(op: { fn: Fn<typeof MediaTag> }) {
query[0] = query[0].set({ subField: "tags", level, hasSubField: true })
let tmpQuery
fn(MediaTag({ query: tmpQuery = [query[0]], level: level + 1 }))
op.fn(MediaTag({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
/** Other media in the same or connecting franchise */
withRelations(fn: Fn<typeof MediaConnection>) {
withRelations(op: { fn: Fn<typeof MediaConnection> }) {
query[0] = query[0].set({ subField: "relations", level, hasSubField: true })
let tmpQuery
fn(MediaConnection({ query: tmpQuery = [query[0]], level: level + 1 }))
op.fn(MediaConnection({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
/** External links to another site related to the media */
withExternalLinks(
fn: Fn<typeof MediaExternalLink>,
) {
withExternalLinks(op: { fn: Fn<typeof MediaExternalLink> }) {
query[0] = query[0].set({ subField: "externalLinks", level, hasSubField: true })
let tmpQuery
fn(MediaExternalLink({ query: tmpQuery = [query[0]], level: level + 1 }))
op.fn(MediaExternalLink({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
/** Data and links to legal streaming episodes on external sites */
withStreamingEpisodes(
fn: Fn<typeof MediaStreamingEpisode>,
) {
withStreamingEpisodes(op: { fn: Fn<typeof MediaStreamingEpisode> }) {
query[0] = query[0].set({ subField: "streamingEpisodes", level, hasSubField: true })
let tmpQuery
fn(MediaStreamingEpisode({ query: tmpQuery = [query[0]], level: level + 1 }))
op.fn(MediaStreamingEpisode({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
/** The ranking of the media in a particular time span and format compared to other media */
withRankings(fn: Fn<typeof MediaRank>) {
withRankings(op: { fn: Fn<typeof MediaRank> }) {
query[0] = query[0].set({ subField: "rankings", level, hasSubField: true })
let tmpQuery
fn(MediaRank({ query: tmpQuery = [query[0]], level: level + 1 }))
op.fn(MediaRank({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
/** The authenticated user's media list entry for the media */
withMediaListEntry(fn?: Fn<typeof MediaList>) {
withMediaListEntry(op?: { fn?: Fn<typeof MediaList> }) {
query[0] = query[0].set({ subField: "mediaListEntry", level, hasSubField: true })
let tmpQuery
if (fn) fn(MediaList({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(MediaList({ query: tmpQuery = [query[0]], level: level + 1 }))
else MediaList({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
withStats(fn: Fn<typeof MediaStats>) {
withStats(op: { fn: Fn<typeof MediaStats> }) {
query[0] = query[0].set({ subField: "stats", level, hasSubField: true })
let tmpQuery
fn(MediaStats({ query: tmpQuery = [query[0]], level: level + 1 }))
op.fn(MediaStats({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},

View File

@ -43,43 +43,43 @@ export const MediaListOptions = ({ query, level }: Fields<OperationParser>) => (
return this
},
/** The user's anime list options */
withAnimeList(fn: Fn<typeof MediaListTypeOptions>) {
withAnimeList(op: { fn: Fn<typeof MediaListTypeOptions> }) {
query[0] = query[0].set({ subField: "animeList", level })
let tmpQuery
fn(MediaListTypeOptions({ query: tmpQuery = [query[0]], level: level + 1 }))
op.fn(MediaListTypeOptions({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
/** The user's manga list options */
withMangaList(fn: Fn<typeof MediaListTypeOptions>) {
withMangaList(op: { fn: Fn<typeof MediaListTypeOptions> }) {
query[0] = query[0].set({ subField: "mangaList", level })
let tmpQuery
fn(MediaListTypeOptions({ query: tmpQuery = [query[0]], level: level + 1 }))
op.fn(MediaListTypeOptions({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
})
export const MediaList = ({ query, level }: Fields<OperationParser>) => ({
withCompletedAt(fn: Fn<typeof FuzzyDate>) {
withCompletedAt(op: { fn: Fn<typeof FuzzyDate> }) {
query[0] = query[0].set({
subField: "completedAt",
level,
hasSubField: true,
})
let tmpQuery
fn(FuzzyDate({ query: tmpQuery = [query[0]], level: level + 1 }))
op.fn(FuzzyDate({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
withStartedAt(fn: Fn<typeof FuzzyDate>) {
withStartedAt(op: { fn: Fn<typeof FuzzyDate> }) {
query[0] = query[0].set({
subField: "startedAt",
level,
hasSubField: true,
})
let tmpQuery
fn(FuzzyDate({ query: tmpQuery = [query[0]], level: level + 1 }))
op.fn(FuzzyDate({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
@ -139,18 +139,18 @@ export const MediaList = ({ query, level }: Fields<OperationParser>) => ({
query[0] = query[0].set({ subField: "createdAt", level })
return this
},
withMedia(fn?: Fn<typeof Media>) {
withMedia(op?: { fn?: Fn<typeof Media> }) {
query[0] = query[0].set({ subField: "media", level, hasSubField: true })
let tmpQuery
if (fn) fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
else Media({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
withUser(fn?: Fn<typeof User>) {
withUser(op?: { fn?: Fn<typeof User> }) {
query[0] = query[0].set({ subField: "user", level, hasSubField: true })
let tmpQuery
if (fn) fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
else User({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this

View File

@ -4,18 +4,18 @@ import { User } from "./User.ts"
export const MediaListCollection = ({ query, level }: Fields<OperationParser>) => ({
/** Grouped media list entries */
withLists(fn: Fn<typeof MediaListGroup>) {
withLists(op: { fn: Fn<typeof MediaListGroup> }) {
query[0] = query[0].set({ subField: "lists", level, hasSubField: true })
let tmpQuery
fn(MediaListGroup({ query: tmpQuery = [query[0]], level: level + 1 }))
op.fn(MediaListGroup({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
/** The owner of the list */
withUser(fn?: Fn<typeof User>) {
withUser(op?: { fn?: Fn<typeof User> }) {
query[0] = query[0].set({ subField: "user", level, hasSubField: true })
let tmpQuery
if (fn) fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
else User({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this

View File

@ -3,10 +3,10 @@ import { Media } from "./Media.ts"
import { PageInfo } from "./Page.ts"
const MediaTrendEdge = ({ query, level }: Fields<OperationParser>) => ({
withNode(fn?: Fn<typeof MediaTrend>) {
withNode(op?: { fn?: Fn<typeof MediaTrend> }) {
query[0] = query[0].set({ subField: "node", level, hasSubField: true })
let tmpQuery
if (fn) fn(MediaTrend({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(MediaTrend({ query: tmpQuery = [query[0]], level: level + 1 }))
else MediaTrend({ query: tmpQuery = [query[0]], level: level + 1 }).withMediaId()
query[0] = tmpQuery[0]
return this
@ -14,27 +14,27 @@ const MediaTrendEdge = ({ query, level }: Fields<OperationParser>) => ({
})
export const MediaTrendConnection = ({ query, level }: Fields<OperationParser>) => ({
withEdges(fn?: Fn<typeof MediaTrendEdge>) {
withEdges(op?: { fn?: Fn<typeof MediaTrendEdge> }) {
query[0] = query[0].set({ subField: "edges", level, hasSubField: true })
let tmpQuery
if (fn) fn(MediaTrendEdge({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(MediaTrendEdge({ query: tmpQuery = [query[0]], level: level + 1 }))
else MediaTrendEdge({ query: tmpQuery = [query[0]], level: level + 1 }).withNode()
query[0] = tmpQuery[0]
return this
},
withNodes(fn?: Fn<typeof MediaTrend>) {
withNodes(op?: { fn?: Fn<typeof MediaTrend> }) {
query[0] = query[0].set({ subField: "nodes", level, hasSubField: true })
let tmpQuery
if (fn) fn(MediaTrend({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(MediaTrend({ query: tmpQuery = [query[0]], level: level + 1 }))
else MediaTrend({ query: tmpQuery = [query[0]], level: level + 1 }).withMediaId()
query[0] = tmpQuery[0]
return this
},
/** The pagination information */
withPageInfo(fn: Fn<typeof PageInfo>) {
withPageInfo(op: { 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 }))
op.fn(PageInfo({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
@ -82,10 +82,10 @@ export const MediaTrend = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The related media */
withMedia(fn?: Fn<typeof Media>) {
withMedia(op?: { fn?: Fn<typeof Media> }) {
query[0] = query[0].set({ subField: "node", level, hasSubField: true })
let tmpQuery
if (fn) fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
else Media({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this

View File

@ -37,10 +37,10 @@ const AiringNotification = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The associated media of the airing schedule */
withMedia(fn: Fn<typeof Media>) {
withMedia(op: { 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 }))
op.fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
@ -73,10 +73,10 @@ const FollowingNotification = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The liked activity */
withUser(fn?: Fn<typeof User>) {
withUser(op?: { fn?: Fn<typeof User> }) {
query[0] = query[0].set({ subField: "user", level, hasSubField: true })
let tmpQuery
if (fn) fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
else User({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
@ -115,19 +115,19 @@ const ActivityMessageNotification = ({ query, level }: Fields<OperationParser>)
return this
},
/** The message activity */
withMessage(fn?: Fn<typeof MessageActivity>) {
withMessage(op?: { fn?: Fn<typeof MessageActivity> }) {
query[0] = query[0].set({ subField: "message", level, hasSubField: true })
let tmpQuery
if (fn) fn(MessageActivity({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(MessageActivity({ query: tmpQuery = [query[0]], level: level + 1 }))
else MessageActivity({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
/** The user who sent the message */
withUser(fn?: Fn<typeof User>) {
withUser(op?: { fn?: Fn<typeof User> }) {
query[0] = query[0].set({ subField: "user", level, hasSubField: true })
let tmpQuery
if (fn) fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
else User({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
@ -166,10 +166,10 @@ const ActivityNotification = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The liked activity */
withActivity(fn?: Fn<typeof ActivityUnion>) {
withActivity(op?: { fn?: Fn<typeof ActivityUnion> }) {
query[0] = query[0].set({ subField: "activity", level, hasSubField: true })
let tmpQuery
if (fn) fn(ActivityUnion({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(ActivityUnion({ query: tmpQuery = [query[0]], level: level + 1 }))
else {
ActivityUnion({ query: tmpQuery = [query[0]], level: level + 1 })
.withListActivity()
@ -180,10 +180,10 @@ const ActivityNotification = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The user who mentioned the authenticated user */
withUser(fn?: Fn<typeof User>) {
withUser(op?: { fn?: Fn<typeof User> }) {
query[0] = query[0].set({ subField: "user", level, hasSubField: true })
let tmpQuery
if (fn) fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
else User({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
@ -222,28 +222,28 @@ const ThreadCommentNotification = ({ query, level }: Fields<OperationParser>) =>
return this
},
/** The thread that the relevant comment belongs to */
withThread(fn?: Fn<typeof Thread>) {
withThread(op?: { fn?: Fn<typeof Thread> }) {
query[0] = query[0].set({ subField: "thread", level, hasSubField: true })
let tmpQuery
if (fn) fn(Thread({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(Thread({ query: tmpQuery = [query[0]], level: level + 1 }))
else Thread({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
/** The thread comment that included the @ mention */
withComment(fn?: Fn<typeof ThreadComment>) {
withComment(op?: { fn?: Fn<typeof ThreadComment> }) {
query[0] = query[0].set({ subField: "comment", level, hasSubField: true })
let tmpQuery
if (fn) fn(ThreadComment({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(ThreadComment({ query: tmpQuery = [query[0]], level: level + 1 }))
else ThreadComment({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
/** The user who mentioned the authenticated user */
withUser(fn?: Fn<typeof User>) {
withUser(op?: { fn?: Fn<typeof User> }) {
query[0] = query[0].set({ subField: "user", level, hasSubField: true })
let tmpQuery
if (fn) fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
else User({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
@ -282,28 +282,28 @@ const ThreadLikeNotification = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The thread that the relevant comment belongs to */
withThread(fn?: Fn<typeof Thread>) {
withThread(op?: { fn?: Fn<typeof Thread> }) {
query[0] = query[0].set({ subField: "thread", level, hasSubField: true })
let tmpQuery
if (fn) fn(Thread({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(Thread({ query: tmpQuery = [query[0]], level: level + 1 }))
else Thread({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
/** The liked thread comment */
withComment(fn?: Fn<typeof ThreadComment>) {
withComment(op?: { fn?: Fn<typeof ThreadComment> }) {
query[0] = query[0].set({ subField: "comment", level, hasSubField: true })
let tmpQuery
if (fn) fn(ThreadComment({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(ThreadComment({ query: tmpQuery = [query[0]], level: level + 1 }))
else ThreadComment({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
/** The user who liked the activity */
withUser(fn?: Fn<typeof User>) {
withUser(op?: { fn?: Fn<typeof User> }) {
query[0] = query[0].set({ subField: "user", level, hasSubField: true })
let tmpQuery
if (fn) fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
else User({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
@ -337,10 +337,10 @@ const RelatedMediaAdditionNotification = ({ query, level }: Fields<OperationPars
return this
},
/** The associated media of the airing schedule */
withMedia(fn?: Fn<typeof Media>) {
withMedia(op?: { fn?: Fn<typeof Media> }) {
query[0] = query[0].set({ subField: "media", level, hasSubField: true })
let tmpQuery
if (fn) fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
else Media({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
@ -379,10 +379,10 @@ const MediaDataChangeNotification = ({ query, level }: Fields<OperationParser>)
return this
},
/** The media that received data changes */
withMedia(fn?: Fn<typeof Media>) {
withMedia(op?: { fn?: Fn<typeof Media> }) {
query[0] = query[0].set({ subField: "media", level, hasSubField: true })
let tmpQuery
if (fn) fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
else Media({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
@ -426,10 +426,10 @@ const MediaMergeNotification = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The media that was merged into */
withMedia(fn?: Fn<typeof Media>) {
withMedia(op?: { fn?: Fn<typeof Media> }) {
query[0] = query[0].set({ subField: "media", level, hasSubField: true })
let tmpQuery
if (fn) fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
else Media({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
@ -470,7 +470,7 @@ const MediaDeletionNotification = ({ query, level }: Fields<OperationParser>) =>
})
export const NotificationUnion = ({ query, level }: Fields<OperationParser>) => ({
AiringNotification(fn?: Fn<typeof AiringNotification>) {
AiringNotification(op?: { fn?: Fn<typeof AiringNotification> }) {
query[0] = query[0].set({
subField: "AiringNotification",
level,
@ -478,12 +478,12 @@ export const NotificationUnion = ({ query, level }: Fields<OperationParser>) =>
isUnion: true,
})
let tmpQuery
if (fn) fn(AiringNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(AiringNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
else AiringNotification({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
FollowingNotification(fn?: Fn<typeof FollowingNotification>) {
FollowingNotification(op?: { fn?: Fn<typeof FollowingNotification> }) {
query[0] = query[0].set({
subField: "FollowingNotification",
level,
@ -491,12 +491,12 @@ export const NotificationUnion = ({ query, level }: Fields<OperationParser>) =>
isUnion: true,
})
let tmpQuery
if (fn) fn(FollowingNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(FollowingNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
else FollowingNotification({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
ActivityMessageNotification(fn?: Fn<typeof ActivityMessageNotification>) {
ActivityMessageNotification(op?: { fn?: Fn<typeof ActivityMessageNotification> }) {
query[0] = query[0].set({
subField: "ActivityMessageNotification",
level,
@ -504,12 +504,13 @@ export const NotificationUnion = ({ query, level }: Fields<OperationParser>) =>
isUnion: true,
})
let tmpQuery
if (fn) fn(ActivityMessageNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
else ActivityMessageNotification({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
if (op?.fn) {
op.fn(ActivityMessageNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
} else ActivityMessageNotification({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
ActivityMentionNotification(fn?: Fn<typeof ActivityNotification>) {
ActivityMentionNotification(op?: { fn?: Fn<typeof ActivityNotification> }) {
query[0] = query[0].set({
subField: "ActivityMentionNotification",
level,
@ -517,12 +518,12 @@ export const NotificationUnion = ({ query, level }: Fields<OperationParser>) =>
isUnion: true,
})
let tmpQuery
if (fn) fn(ActivityNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(ActivityNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
else ActivityNotification({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
ActivityReplyNotification(fn?: Fn<typeof ActivityNotification>) {
ActivityReplyNotification(op?: { fn?: Fn<typeof ActivityNotification> }) {
query[0] = query[0].set({
subField: "ActivityReplyNotification",
level,
@ -530,12 +531,12 @@ export const NotificationUnion = ({ query, level }: Fields<OperationParser>) =>
isUnion: true,
})
let tmpQuery
if (fn) fn(ActivityNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(ActivityNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
else ActivityNotification({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
ActivityReplySubscribedNotification(fn?: Fn<typeof ActivityNotification>) {
ActivityReplySubscribedNotification(op?: { fn?: Fn<typeof ActivityNotification> }) {
query[0] = query[0].set({
subField: "ActivityReplySubscribedNotification",
level,
@ -543,12 +544,12 @@ export const NotificationUnion = ({ query, level }: Fields<OperationParser>) =>
isUnion: true,
})
let tmpQuery
if (fn) fn(ActivityNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(ActivityNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
else ActivityNotification({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
ActivityLikeNotification(fn?: Fn<typeof ActivityNotification>) {
ActivityLikeNotification(op?: { fn?: Fn<typeof ActivityNotification> }) {
query[0] = query[0].set({
subField: "ActivityLikeNotification",
level,
@ -556,12 +557,12 @@ export const NotificationUnion = ({ query, level }: Fields<OperationParser>) =>
isUnion: true,
})
let tmpQuery
if (fn) fn(ActivityNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(ActivityNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
else ActivityNotification({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
ActivityReplyLikeNotification(fn?: Fn<typeof ActivityNotification>) {
ActivityReplyLikeNotification(op?: { fn?: Fn<typeof ActivityNotification> }) {
query[0] = query[0].set({
subField: "ActivityReplyLikeNotification",
level,
@ -569,12 +570,12 @@ export const NotificationUnion = ({ query, level }: Fields<OperationParser>) =>
isUnion: true,
})
let tmpQuery
if (fn) fn(ActivityNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(ActivityNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
else ActivityNotification({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
ThreadCommentMentionNotification(fn?: Fn<typeof ThreadCommentNotification>) {
ThreadCommentMentionNotification(op?: { fn?: Fn<typeof ThreadCommentNotification> }) {
query[0] = query[0].set({
subField: "ThreadCommentMentionNotification",
level,
@ -582,12 +583,12 @@ export const NotificationUnion = ({ query, level }: Fields<OperationParser>) =>
isUnion: true,
})
let tmpQuery
if (fn) fn(ThreadCommentNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(ThreadCommentNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
else ThreadCommentNotification({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
ThreadCommentReplyNotification(fn?: Fn<typeof ThreadCommentNotification>) {
ThreadCommentReplyNotification(op?: { fn?: Fn<typeof ThreadCommentNotification> }) {
query[0] = query[0].set({
subField: "ThreadCommentReplyNotification",
level,
@ -595,12 +596,12 @@ export const NotificationUnion = ({ query, level }: Fields<OperationParser>) =>
isUnion: true,
})
let tmpQuery
if (fn) fn(ThreadCommentNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(ThreadCommentNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
else ThreadCommentNotification({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
ThreadCommentSubscribedNotification(fn?: Fn<typeof ThreadCommentNotification>) {
ThreadCommentSubscribedNotification(op?: { fn?: Fn<typeof ThreadCommentNotification> }) {
query[0] = query[0].set({
subField: "ThreadCommentSubscribedNotification",
level,
@ -608,12 +609,12 @@ export const NotificationUnion = ({ query, level }: Fields<OperationParser>) =>
isUnion: true,
})
let tmpQuery
if (fn) fn(ThreadCommentNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(ThreadCommentNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
else ThreadCommentNotification({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
ThreadCommentLikeNotification(fn?: Fn<typeof ThreadCommentNotification>) {
ThreadCommentLikeNotification(op?: { fn?: Fn<typeof ThreadCommentNotification> }) {
query[0] = query[0].set({
subField: "ThreadCommentLikeNotification",
level,
@ -621,12 +622,12 @@ export const NotificationUnion = ({ query, level }: Fields<OperationParser>) =>
isUnion: true,
})
let tmpQuery
if (fn) fn(ThreadCommentNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(ThreadCommentNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
else ThreadCommentNotification({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
ThreadLikeNotification(fn?: Fn<typeof ThreadLikeNotification>) {
ThreadLikeNotification(op?: { fn?: Fn<typeof ThreadLikeNotification> }) {
query[0] = query[0].set({
subField: "ThreadLikeNotification",
level,
@ -634,12 +635,12 @@ export const NotificationUnion = ({ query, level }: Fields<OperationParser>) =>
isUnion: true,
})
let tmpQuery
if (fn) fn(ThreadLikeNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(ThreadLikeNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
else ThreadLikeNotification({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
RelatedMediaAdditionNotification(fn?: Fn<typeof RelatedMediaAdditionNotification>) {
RelatedMediaAdditionNotification(op?: { fn?: Fn<typeof RelatedMediaAdditionNotification> }) {
query[0] = query[0].set({
subField: "RelatedMediaAdditionNotification",
level,
@ -647,13 +648,14 @@ export const NotificationUnion = ({ query, level }: Fields<OperationParser>) =>
isUnion: true,
})
let tmpQuery
if (fn) fn(RelatedMediaAdditionNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
else {RelatedMediaAdditionNotification({ query: tmpQuery = [query[0]], level: level + 1 })
if (op?.fn) {
op.fn(RelatedMediaAdditionNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
} else {RelatedMediaAdditionNotification({ query: tmpQuery = [query[0]], level: level + 1 })
.withId()}
query[0] = tmpQuery[0]
return this
},
MediaDataChangeNotification(fn?: Fn<typeof MediaDataChangeNotification>) {
MediaDataChangeNotification(op?: { fn?: Fn<typeof MediaDataChangeNotification> }) {
query[0] = query[0].set({
subField: "MediaDataChangeNotification",
level,
@ -661,12 +663,13 @@ export const NotificationUnion = ({ query, level }: Fields<OperationParser>) =>
isUnion: true,
})
let tmpQuery
if (fn) fn(MediaDataChangeNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
else MediaDataChangeNotification({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
if (op?.fn) {
op.fn(MediaDataChangeNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
} else MediaDataChangeNotification({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
MediaMergeNotification(fn?: Fn<typeof MediaMergeNotification>) {
MediaMergeNotification(op?: { fn?: Fn<typeof MediaMergeNotification> }) {
query[0] = query[0].set({
subField: "MediaMergeNotification",
level,
@ -674,12 +677,12 @@ export const NotificationUnion = ({ query, level }: Fields<OperationParser>) =>
isUnion: true,
})
let tmpQuery
if (fn) fn(MediaMergeNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(MediaMergeNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
else MediaMergeNotification({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
MediaDeletionNotification(fn?: Fn<typeof MediaDeletionNotification>) {
MediaDeletionNotification(op?: { fn?: Fn<typeof MediaDeletionNotification> }) {
query[0] = query[0].set({
subField: "MediaDeletionNotification",
level,
@ -687,7 +690,7 @@ export const NotificationUnion = ({ query, level }: Fields<OperationParser>) =>
isUnion: true,
})
let tmpQuery
if (fn) fn(MediaDeletionNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(MediaDeletionNotification({ query: tmpQuery = [query[0]], level: level + 1 }))
else MediaDeletionNotification({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this

View File

@ -67,10 +67,10 @@ export const PageInfo = ({ query, level }: Fields<OperationParser>) => ({
export const Page = ({ query, level }: Fields<OperationParser>) => ({
/** The pagination information */
withPageInfo(fn: Fn<typeof PageInfo>) {
withPageInfo(op: { 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 }))
op.fn(PageInfo({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},

View File

@ -4,37 +4,37 @@ import { User } from "./User.ts"
import { PageInfo } from "./Page.ts"
const RecommendationEdge = ({ query, level }: Fields<OperationParser>) => ({
withNode(fn?: Fn<typeof Recommendation>) {
withNode(op?: { fn?: Fn<typeof Recommendation> }) {
query[0] = query[0].set({ subField: "node", level, hasSubField: true })
let tmpQuery
if (fn) fn(Recommendation({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(Recommendation({ query: tmpQuery = [query[0]], level: level + 1 }))
else Recommendation({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
})
export const RecommendationConnection = ({ query, level }: Fields<OperationParser>) => ({
withEdges(fn?: Fn<typeof RecommendationEdge>) {
withEdges(op?: { fn?: Fn<typeof RecommendationEdge> }) {
query[0] = query[0].set({ subField: "edges", level, hasSubField: true })
let tmpQuery
if (fn) fn(RecommendationEdge({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(RecommendationEdge({ query: tmpQuery = [query[0]], level: level + 1 }))
else RecommendationEdge({ query: tmpQuery = [query[0]], level: level + 1 }).withNode()
query[0] = tmpQuery[0]
return this
},
withNodes(fn?: Fn<typeof Recommendation>) {
withNodes(op?: { fn?: Fn<typeof Recommendation> }) {
query[0] = query[0].set({ subField: "nodes", level, hasSubField: true })
let tmpQuery
if (fn) fn(Recommendation({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(Recommendation({ query: tmpQuery = [query[0]], level: level + 1 }))
else Recommendation({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
/** The pagination information */
withPageInfo(fn: Fn<typeof PageInfo>) {
withPageInfo(op: { 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 }))
op.fn(PageInfo({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
@ -57,28 +57,28 @@ export const Recommendation = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The media the recommendation is from */
withMedia(fn?: Fn<typeof Media>) {
withMedia(op?: { fn?: Fn<typeof Media> }) {
query[0] = query[0].set({ subField: "media", level, hasSubField: true })
let tmpQuery
if (fn) fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
else Media({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
/** The recommended media */
withMediaRecommendation(fn?: Fn<typeof Media>) {
withMediaRecommendation(op?: { fn?: Fn<typeof Media> }) {
query[0] = query[0].set({ subField: "media", level, hasSubField: true })
let tmpQuery
if (fn) fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
else Media({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
/** The user that first created the recommendation */
withUser(fn?: Fn<typeof User>) {
withUser(op?: { fn?: Fn<typeof User> }) {
query[0] = query[0].set({ subField: "user", level, hasSubField: true })
let tmpQuery
if (fn) fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
else User({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this

View File

@ -4,10 +4,10 @@ import { Media } from "./Media.ts"
import { User } from "./User.ts"
const ReviewEdge = ({ query, level }: Fields<OperationParser>) => ({
withNode(fn?: Fn<typeof Review>) {
withNode(op?: { fn?: Fn<typeof Review> }) {
query[0] = query[0].set({ subField: "node", level, hasSubField: true })
let tmpQuery
if (fn) fn(Review({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(Review({ query: tmpQuery = [query[0]], level: level + 1 }))
else Review({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
@ -15,27 +15,27 @@ const ReviewEdge = ({ query, level }: Fields<OperationParser>) => ({
})
export const ReviewConnection = ({ query, level }: Fields<OperationParser>) => ({
withEdges(fn?: Fn<typeof ReviewEdge>) {
withEdges(op?: { fn?: Fn<typeof ReviewEdge> }) {
query[0] = query[0].set({ subField: "edges", level, hasSubField: true })
let tmpQuery
if (fn) fn(ReviewEdge({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(ReviewEdge({ query: tmpQuery = [query[0]], level: level + 1 }))
else ReviewEdge({ query: tmpQuery = [query[0]], level: level + 1 }).withNode()
query[0] = tmpQuery[0]
return this
},
withNodes(fn?: Fn<typeof Review>) {
withNodes(op?: { fn?: Fn<typeof Review> }) {
query[0] = query[0].set({ subField: "nodes", level, hasSubField: true })
let tmpQuery
if (fn) fn(Review({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(Review({ query: tmpQuery = [query[0]], level: level + 1 }))
else Review({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
/** The pagination information */
withPageInfo(fn: Fn<typeof PageInfo>) {
withPageInfo(op: { 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 }))
op.fn(PageInfo({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
@ -68,8 +68,8 @@ export const Review = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The main review body text */
body(args?: { asHtml: boolean }) {
query[0] = query[0].set({ subField: "(args", level, variables: args })
withBody(op?: { args?: { asHtml: boolean } }) {
query[0] = query[0].set({ subField: "body", level, variables: op?.args })
return this
},
/** The total user rating of the review */
@ -113,19 +113,19 @@ export const Review = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The creator of the review */
withUser(fn?: Fn<typeof User>) {
withUser(op?: { fn?: Fn<typeof User> }) {
query[0] = query[0].set({ subField: "user", level, hasSubField: true })
let tmpQuery
if (fn) fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
else User({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
/** The media the review is of */
withMedia(fn?: Fn<typeof Media>) {
withMedia(op?: { fn?: Fn<typeof Media> }) {
query[0] = query[0].set({ subField: "media", level, hasSubField: true })
let tmpQuery
if (fn) fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
else Media({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this

View File

@ -20,35 +20,35 @@ const SiteTrend = ({ query, level }: Fields<OperationParser>) => ({
})
const SiteTrendEdge = ({ query, level }: Fields<OperationParser>) => ({
withNode(fn: Fn<typeof SiteTrend>) {
withNode(op: { 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 }))
op.fn(SiteTrend({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
})
export const SiteTrendConnection = ({ query, level }: Fields<OperationParser>) => ({
withEdges(fn: Fn<typeof SiteTrendEdge>) {
withEdges(op: { 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 }))
op.fn(SiteTrendEdge({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
withNodes(fn: Fn<typeof SiteTrend>) {
withNodes(op: { 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 }))
op.fn(SiteTrend({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
/** The pagination information */
withPageInfo(fn: Fn<typeof PageInfo>) {
withPageInfo(op: { 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 }))
op.fn(PageInfo({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},

View File

@ -13,10 +13,10 @@ import { AtLeastOne } from "../types/AtLeastOne.ts"
export const StaffRoleType = ({ query, level }: Fields<OperationParser>) => ({
/** The voice actors of the character */
withVoiceActor(fn: Fn<typeof Staff>) {
withVoiceActor(op: { 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 }))
op.fn(Staff({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
@ -33,10 +33,10 @@ export const StaffRoleType = ({ query, level }: Fields<OperationParser>) => ({
})
const StaffEdge = ({ query, level }: Fields<OperationParser>) => ({
withNode(fn?: Fn<typeof Staff>) {
withNode(op?: { fn?: Fn<typeof Staff> }) {
query[0] = query[0].set({ subField: "node", level, hasSubField: true })
let tmpQuery
if (fn) fn(Staff({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(Staff({ query: tmpQuery = [query[0]], level: level + 1 }))
else Staff({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
@ -59,27 +59,27 @@ const StaffEdge = ({ query, level }: Fields<OperationParser>) => ({
})
export const StaffConnection = ({ query, level }: Fields<OperationParser>) => ({
withEdges(fn?: Fn<typeof StaffEdge>) {
withEdges(op?: { fn?: Fn<typeof StaffEdge> }) {
query[0] = query[0].set({ subField: "edges", level, hasSubField: true })
let tmpQuery
if (fn) fn(StaffEdge({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(StaffEdge({ query: tmpQuery = [query[0]], level: level + 1 }))
else StaffEdge({ query: tmpQuery = [query[0]], level: level + 1 }).withNode()
query[0] = tmpQuery[0]
return this
},
withNodes(fn?: Fn<typeof Staff>) {
withNodes(op?: { fn?: Fn<typeof Staff> }) {
query[0] = query[0].set({ subField: "nodes", level, hasSubField: true })
let tmpQuery
if (fn) fn(Staff({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(Staff({ query: tmpQuery = [query[0]], level: level + 1 }))
else Staff({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
/** The pagination information */
withPageInfo(fn: Fn<typeof PageInfo>) {
withPageInfo(op: { 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 }))
op.fn(PageInfo({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
@ -143,10 +143,10 @@ export const Staff = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The names of the staff member */
withName(fn?: Fn<typeof StaffName>) {
withName(op?: { fn?: Fn<typeof StaffName> }) {
query[0] = query[0].set({ subField: "name", level, hasSubField: true })
let tmpQuery
if (fn) fn(StaffName({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(StaffName({ query: tmpQuery = [query[0]], level: level + 1 }))
else StaffName({ query: tmpQuery = [query[0]], level: level + 1 }).withUserPreferred()
query[0] = tmpQuery[0]
return this
@ -157,17 +157,17 @@ export const Staff = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The staff images */
withImage(fn?: Fn<typeof StaffImage>) {
withImage(op?: { fn?: Fn<typeof StaffImage> }) {
query[0] = query[0].set({ subField: "image", level, hasSubField: true })
let tmpQuery
if (fn) fn(StaffImage({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(StaffImage({ query: tmpQuery = [query[0]], level: level + 1 }))
else StaffImage({ query: tmpQuery = [query[0]], level: level + 1 }).withMedium()
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 })
withDescription(op?: { args?: { asHtml: boolean } }) {
query[0] = query[0].set({ subField: "description", level, variables: op?.args })
return this
},
/** The person's primary occupations */
@ -180,10 +180,10 @@ export const Staff = ({ query, level }: Fields<OperationParser>) => ({
query[0] = query[0].set({ subField: "gender", level })
return this
},
withDateOfBirth(fn?: Fn<typeof FuzzyDate>) {
withDateOfBirth(op?: { fn?: Fn<typeof FuzzyDate> }) {
query[0] = query[0].set({ subField: "dateOfBirth", level, hasSubField: true })
let tmpQuery
if (fn) fn(FuzzyDate({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(FuzzyDate({ query: tmpQuery = [query[0]], level: level + 1 }))
else {
FuzzyDate({ query: tmpQuery = [query[0]], level: level + 1 })
.withYear()
@ -193,10 +193,10 @@ export const Staff = ({ query, level }: Fields<OperationParser>) => ({
query[0] = tmpQuery[0]
return this
},
withDateOfDeath(fn?: Fn<typeof FuzzyDate>) {
withDateOfDeath(op?: { fn?: Fn<typeof FuzzyDate> }) {
query[0] = query[0].set({ subField: "dateOfDeath", level, hasSubField: true })
let tmpQuery
if (fn) fn(FuzzyDate({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(FuzzyDate({ query: tmpQuery = [query[0]], level: level + 1 }))
else {
FuzzyDate({ query: tmpQuery = [query[0]], level: level + 1 })
.withYear()
@ -287,19 +287,19 @@ export const Staff = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** Staff member that the submission is referencing */
withStaff(fn?: Fn<typeof Staff>) {
withStaff(op?: { fn?: Fn<typeof Staff> }) {
query[0] = query[0].set({ subField: "staff", level, hasSubField: true })
let tmpQuery
if (fn) fn(Staff({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(Staff({ query: tmpQuery = [query[0]], level: level + 1 }))
else Staff({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
/** Submitter for the submission */
withSubmitter(fn?: Fn<typeof User>) {
withSubmitter(op?: { fn?: Fn<typeof User> }) {
query[0] = query[0].set({ subField: "submitter", level, hasSubField: true })
let tmpQuery
if (fn) fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
else User({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this

View File

@ -5,10 +5,10 @@ import { MediaConnection } from "./Media.ts"
import { AtLeastOne } from "../types/AtLeastOne.ts"
const StudioEdge = ({ query, level }: Fields<OperationParser>) => ({
withNode(fn?: Fn<typeof Studio>) {
withNode(op?: { fn?: Fn<typeof Studio> }) {
query[0] = query[0].set({ subField: "node", level, hasSubField: true })
let tmpQuery
if (fn) fn(Studio({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(Studio({ query: tmpQuery = [query[0]], level: level + 1 }))
else Studio({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
@ -31,27 +31,27 @@ const StudioEdge = ({ query, level }: Fields<OperationParser>) => ({
})
export const StudioConnection = ({ query, level }: Fields<OperationParser>) => ({
withEdges(fn?: Fn<typeof StudioEdge>) {
withEdges(op?: { fn?: Fn<typeof StudioEdge> }) {
query[0] = query[0].set({ subField: "edges", level, hasSubField: true })
let tmpQuery
if (fn) fn(StudioEdge({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(StudioEdge({ query: tmpQuery = [query[0]], level: level + 1 }))
else StudioEdge({ query: tmpQuery = [query[0]], level: level + 1 }).withNode()
query[0] = tmpQuery[0]
return this
},
withNodes(fn?: Fn<typeof Studio>) {
withNodes(op?: { fn?: Fn<typeof Studio> }) {
query[0] = query[0].set({ subField: "nodes", level, hasSubField: true })
let tmpQuery
if (fn) fn(Studio({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(Studio({ query: tmpQuery = [query[0]], level: level + 1 }))
else Studio({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
/** The pagination information */
withPageInfo(fn: Fn<typeof PageInfo>) {
withPageInfo(op: { 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 }))
op.fn(PageInfo({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},

View File

@ -27,8 +27,8 @@ export const Thread = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The text body of the thread (Markdown) */
withBody(args?: { asHtml: boolean }) {
query[0] = query[0].set({ subField: "body", level, variables: args })
withBody(op?: { args?: { asHtml: boolean } }) {
query[0] = query[0].set({ subField: "body", level, variables: op?.args })
return this
},
/** The id of the thread owner user */
@ -97,28 +97,28 @@ export const Thread = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The owner of the thread */
withUser(fn?: Fn<typeof User>) {
withUser(op?: { fn?: Fn<typeof User> }) {
query[0] = query[0].set({ subField: "user", level, hasSubField: true })
let tmpQuery
if (fn) fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
else User({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
/** The user to last reply to the thread */
withReplyUser(fn?: Fn<typeof User>) {
withReplyUser(op?: { fn?: Fn<typeof User> }) {
query[0] = query[0].set({ subField: "replayUser", level, hasSubField: true })
let tmpQuery
if (fn) fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
else User({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
/** The users who liked the thread */
withLikes(fn?: Fn<typeof User>) {
withLikes(op?: { fn?: Fn<typeof User> }) {
query[0] = query[0].set({ subField: "likes", level, hasSubField: true })
let tmpQuery
if (fn) fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
else User({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
@ -129,18 +129,18 @@ export const Thread = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The categories of the thread */
withCategories(fn: Fn<typeof ThreadCategory>) {
withCategories(op: { fn: Fn<typeof ThreadCategory> }) {
query[0] = query[0].set({ subField: "categories", level })
let tmpQuery
fn(ThreadCategory({ query: tmpQuery = [query[0]], level: level + 1 }))
op.fn(ThreadCategory({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
/** The media categories of the thread */
withMediaCategories(fn?: Fn<typeof Media>) {
withMediaCategories(op?: { fn?: Fn<typeof Media> }) {
query[0] = query[0].set({ subField: "mediaCategories", level, hasSubField: true })
let tmpQuery
if (fn) fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(Media({ query: tmpQuery = [query[0]], level: level + 1 }))
else Media({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this

View File

@ -19,8 +19,8 @@ export const ThreadComment = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The text content of the comment (Markdown) */
withComment(args?: { asHtml: boolean }) {
query[0] = query[0].set({ subField: "comment", level, variables: args })
withComment(op?: { args?: { asHtml: boolean } }) {
query[0] = query[0].set({ subField: "comment", level, variables: op?.args })
return this
},
/** The amount of likes the comment has */
@ -49,28 +49,28 @@ export const ThreadComment = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The thread the comment belongs to */
withThread(fn?: Fn<typeof Thread>) {
withThread(op?: { fn?: Fn<typeof Thread> }) {
query[0] = query[0].set({ subField: "thread", level, hasSubField: true })
let tmpQuery
if (fn) fn(Thread({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(Thread({ query: tmpQuery = [query[0]], level: level + 1 }))
else Thread({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
/** The user who created the comment */
withUser(fn?: Fn<typeof User>) {
withUser(op?: { fn?: Fn<typeof User> }) {
query[0] = query[0].set({ subField: "user", level, hasSubField: true })
let tmpQuery
if (fn) fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
else User({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
},
/** The users who liked the comment */
withLikes(fn?: Fn<typeof User>) {
withLikes(op?: { fn?: Fn<typeof User> }) {
query[0] = query[0].set({ subField: "likes", level, hasSubField: true })
let tmpQuery
if (fn) fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(User({ query: tmpQuery = [query[0]], level: level + 1 }))
else User({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this

View File

@ -1,4 +1,5 @@
import { Fields, Fn, OperationParser } from "../types/Anilist.ts"
import { UserFavouritesArgs } from "../types/generated/graphql.ts"
import { Favourites } from "./Favourites.ts"
import { MediaListOptions } from "./MediaList.ts"
import { UserStatisticTypes } from "./UserStatistics.ts"
@ -69,10 +70,10 @@ export const UserOptions = ({ query, level }: Fields<OperationParser>) => ({
},
/** Notification options */
withNotificationOptions(fn: Fn<typeof NotificationOption>) {
withNotificationOptions(op: { fn: Fn<typeof NotificationOption> }) {
query[0] = query[0].set({ subField: "notificationOptions", level })
let tmpQuery
fn(NotificationOption({ query: tmpQuery = [query[0]], level: level + 1 }))
op.fn(NotificationOption({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
@ -102,14 +103,14 @@ export const UserOptions = ({ query, level }: Fields<OperationParser>) => ({
},
/** The list activity types the user has disabled from being created from list updates */
withDisabledListActivity(fn: Fn<typeof ListActivityOption>) {
withDisabledListActivity(op: { fn: Fn<typeof ListActivityOption> }) {
query[0] = query[0].set({
subField: "disabledListActivity",
level,
hasSubField: true,
})
let tmpQuery
fn(ListActivityOption({ query: tmpQuery = [query[0]], level: level + 1 }))
op.fn(ListActivityOption({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
@ -140,15 +141,15 @@ export const User = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/** The bio written by user (Markdown) */
withAbout(args?: { asHtml: boolean }) {
query[0] = query[0].set({ subField: "about", level, variables: args })
withAbout(op?: { args?: { asHtml: boolean } }) {
query[0] = query[0].set({ subField: "about", level, variables: op?.args })
return this
},
/** The user's avatar images */
withAvatar(fn?: Fn<typeof UserAvatar>) {
withAvatar(op?: { fn?: Fn<typeof UserAvatar> }) {
query[0] = query[0].set({ subField: "avatar", level, hasSubField: true })
let tmpQuery
if (fn) fn(UserAvatar({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(UserAvatar({ query: tmpQuery = [query[0]], level: level + 1 }))
else UserAvatar({ query: tmpQuery = [query[0]], level: level + 1 }).withMedium()
query[0] = tmpQuery[0]
return this
@ -178,23 +179,23 @@ export const User = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/* The user's general options */
withOptions(fn: Fn<typeof UserOptions>) {
withOptions(op: { fn: Fn<typeof UserOptions> }) {
query[0] = query[0].set({ subField: "options", level })
let tmpQuery
fn(UserOptions({ query: tmpQuery = [query[0]], level: level + 1 }))
op.fn(UserOptions({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
/* The user's media list options */
withMediaListOptions(fn: Fn<typeof MediaListOptions>) {
withMediaListOptions(op: { fn: Fn<typeof MediaListOptions> }) {
query[0] = query[0].set({ subField: "mediaListOptions", level })
let tmpQuery
fn(MediaListOptions({ query: tmpQuery = [query[0]], level: level + 1 }))
op.fn(MediaListOptions({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
/* The users favourites */
withFavourites(op: { args?: { page: number }; fn: Fn<typeof Favourites> }) {
withFavourites(op: { args?: UserFavouritesArgs; fn: Fn<typeof Favourites> }) {
query[0] = query[0].set({ subField: "favourites", level, variables: op?.args })
let tmpQuery
op.fn(Favourites({ query: tmpQuery = [query[0]], level: level + 1 }))
@ -202,10 +203,10 @@ export const User = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/* The users anime & manga list statistics */
withStatistics(fn: Fn<typeof UserStatisticTypes>) {
withStatistics(op: { fn: Fn<typeof UserStatisticTypes> }) {
query[0] = query[0].set({ subField: "statistics", level, hasSubField: true })
let tmpQuery
fn(UserStatisticTypes({ query: tmpQuery = [query[0]], level: level + 1 }))
op.fn(UserStatisticTypes({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
@ -245,14 +246,14 @@ export const User = ({ query, level }: Fields<OperationParser>) => ({
return this
},
/* The user's previously used names. */
withPreviousNames(fn?: Fn<typeof UserPreviousName>) {
withPreviousNames(op?: { fn?: Fn<typeof UserPreviousName> }) {
query[0] = query[0].set({
subField: "previousNames",
level,
hasSubField: true,
})
let tmpQuery
if (fn) fn(UserPreviousName({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(UserPreviousName({ query: tmpQuery = [query[0]], level: level + 1 }))
else UserPreviousName({ query: tmpQuery = [query[0]], level: level + 1 }).withName()
query[0] = tmpQuery[0]
return this

View File

@ -280,10 +280,10 @@ const UserVoiceActorStatistics = ({ query, level }: Fields<OperationParser>) =>
query[0] = query[0].set({ subField: "mediaIds", level })
return this
},
withVoiceActor(fn?: Fn<typeof Staff>) {
withVoiceActor(op?: { fn?: Fn<typeof Staff> }) {
query[0] = query[0].set({ subField: "voiceActor", level, hasSubField: true })
let tmpQuery
if (fn) fn(Staff({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(Staff({ query: tmpQuery = [query[0]], level: level + 1 }))
else Staff({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
@ -315,10 +315,10 @@ const UserStaffStatistics = ({ query, level }: Fields<OperationParser>) => ({
query[0] = query[0].set({ subField: "mediaIds", level })
return this
},
withStaff(fn?: Fn<typeof Staff>) {
withStaff(op?: { fn?: Fn<typeof Staff> }) {
query[0] = query[0].set({ subField: "staff", level, hasSubField: true })
let tmpQuery
if (fn) fn(Staff({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op?.fn(Staff({ query: tmpQuery = [query[0]], level: level + 1 }))
else Staff({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
@ -346,10 +346,10 @@ const UserStudioStatistics = ({ query, level }: Fields<OperationParser>) => ({
query[0] = query[0].set({ subField: "mediaIds", level })
return this
},
withStudio(fn?: Fn<typeof Studio>) {
withStudio(op?: { fn?: Fn<typeof Studio> }) {
query[0] = query[0].set({ subField: "studio", level, hasSubField: true })
let tmpQuery
if (fn) fn(Studio({ query: tmpQuery = [query[0]], level: level + 1 }))
if (op?.fn) op.fn(Studio({ query: tmpQuery = [query[0]], level: level + 1 }))
else Studio({ query: tmpQuery = [query[0]], level: level + 1 }).withId()
query[0] = tmpQuery[0]
return this
@ -480,17 +480,17 @@ export const UserStatistics = ({ query, level }: Fields<OperationParser>) => ({
})
export const UserStatisticTypes = ({ query, level }: Fields<OperationParser>) => ({
withAnime(fn: Fn<typeof UserStatistics>) {
withAnime(op: { fn: Fn<typeof UserStatistics> }) {
query[0] = query[0].set({ subField: "anime", level, hasSubField: true })
let tmpQuery
fn(UserStatistics({ query: tmpQuery = [query[0]], level: level + 1 }))
op.fn(UserStatistics({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},
withManga(fn: Fn<typeof UserStatistics>) {
withManga(op: { fn: Fn<typeof UserStatistics> }) {
query[0] = query[0].set({ subField: "manga", level, hasSubField: true })
let tmpQuery
fn(UserStatistics({ query: tmpQuery = [query[0]], level: level + 1 }))
op.fn(UserStatistics({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
return this
},