1840 lines
46 KiB
TypeScript
1840 lines
46 KiB
TypeScript
/**
|
|
* Generated by orval v7.14.0 🍺
|
|
* Do not edit manually.
|
|
* OpenAPI definition
|
|
* OpenAPI spec version: v0
|
|
*/
|
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
import type {
|
|
DataTag,
|
|
DefinedInitialDataOptions,
|
|
DefinedUseQueryResult,
|
|
MutationFunction,
|
|
QueryClient,
|
|
QueryFunction,
|
|
QueryKey,
|
|
UndefinedInitialDataOptions,
|
|
UseMutationOptions,
|
|
UseMutationResult,
|
|
UseQueryOptions,
|
|
UseQueryResult,
|
|
} from "@tanstack/react-query";
|
|
|
|
import { customInstance } from "./api";
|
|
export interface RegistrationRequestDTO {
|
|
name?: string;
|
|
email?: string;
|
|
password?: string;
|
|
}
|
|
|
|
export interface AuthenticationRequestDTO {
|
|
email: string;
|
|
password: string;
|
|
}
|
|
|
|
export type AuthenticationResponseDTORole =
|
|
(typeof AuthenticationResponseDTORole)[keyof typeof AuthenticationResponseDTORole];
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
export const AuthenticationResponseDTORole = {
|
|
USER: "USER",
|
|
} as const;
|
|
|
|
export interface AuthenticationResponseDTO {
|
|
id: number;
|
|
token: string;
|
|
email: string;
|
|
name: string;
|
|
role: AuthenticationResponseDTORole;
|
|
}
|
|
|
|
export interface MangaListDTO {
|
|
id: number;
|
|
/** @minLength 1 */
|
|
title: string;
|
|
coverImageKey?: string;
|
|
status?: string;
|
|
publishedFrom?: string;
|
|
publishedTo?: string;
|
|
providerCount?: number;
|
|
genres: string[];
|
|
authors: string[];
|
|
score: number;
|
|
favorite: boolean;
|
|
}
|
|
|
|
export interface PageMangaListDTO {
|
|
totalPages?: number;
|
|
totalElements?: number;
|
|
size?: number;
|
|
content?: MangaListDTO[];
|
|
number?: number;
|
|
pageable?: PageableObject;
|
|
first?: boolean;
|
|
last?: boolean;
|
|
sort?: SortObject;
|
|
numberOfElements?: number;
|
|
empty?: boolean;
|
|
}
|
|
|
|
export interface PageableObject {
|
|
offset?: number;
|
|
paged?: boolean;
|
|
pageNumber?: number;
|
|
pageSize?: number;
|
|
sort?: SortObject;
|
|
unpaged?: boolean;
|
|
}
|
|
|
|
export interface SortObject {
|
|
empty?: boolean;
|
|
sorted?: boolean;
|
|
unsorted?: boolean;
|
|
}
|
|
|
|
export interface MangaChapterDTO {
|
|
id: number;
|
|
/** @minLength 1 */
|
|
title: string;
|
|
downloaded: boolean;
|
|
isRead: boolean;
|
|
}
|
|
|
|
export interface MangaDTO {
|
|
id: number;
|
|
/** @minLength 1 */
|
|
title: string;
|
|
coverImageKey?: string;
|
|
status?: string;
|
|
publishedFrom?: string;
|
|
publishedTo?: string;
|
|
synopsis?: string;
|
|
providerCount?: number;
|
|
alternativeTitles: string[];
|
|
genres: string[];
|
|
authors: string[];
|
|
score: number;
|
|
providers: MangaProviderDTO[];
|
|
}
|
|
|
|
export interface MangaProviderDTO {
|
|
id: number;
|
|
/** @minLength 1 */
|
|
providerName: string;
|
|
chaptersAvailable: number;
|
|
chaptersDownloaded: number;
|
|
}
|
|
|
|
export interface MangaChapterImagesDTO {
|
|
id: number;
|
|
/** @minLength 1 */
|
|
mangaTitle: string;
|
|
chapterImageKeys: string[];
|
|
}
|
|
|
|
export interface GenreDTO {
|
|
id: number;
|
|
/** @minLength 1 */
|
|
name: string;
|
|
}
|
|
|
|
export type DownloadChapterArchiveParams = {
|
|
archiveFileType: DownloadChapterArchiveArchiveFileType;
|
|
};
|
|
|
|
export type DownloadChapterArchiveArchiveFileType =
|
|
(typeof DownloadChapterArchiveArchiveFileType)[keyof typeof DownloadChapterArchiveArchiveFileType];
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
export const DownloadChapterArchiveArchiveFileType = {
|
|
CBZ: "CBZ",
|
|
CBR: "CBR",
|
|
} as const;
|
|
|
|
export type GetMangasParams = {
|
|
searchQuery?: string;
|
|
genreIds?: number[];
|
|
statuses?: string[];
|
|
userFavorites?: boolean;
|
|
/**
|
|
* Zero-based page index (0..N)
|
|
* @minimum 0
|
|
*/
|
|
page?: number;
|
|
/**
|
|
* The size of the page to be returned
|
|
* @minimum 1
|
|
*/
|
|
size?: number;
|
|
/**
|
|
* Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.
|
|
*/
|
|
sort?: string[];
|
|
};
|
|
|
|
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
|
|
|
/**
|
|
* Fetch a list of manga chapters for a specific manga/provider combination.
|
|
* @summary Fetch the available chapters for a specific manga/provider combination
|
|
*/
|
|
export const fetchMangaChapters = (
|
|
mangaProviderId: number,
|
|
options?: SecondParameter<typeof customInstance>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customInstance<void>(
|
|
{
|
|
url: `http://192.168.1.142:8080/mangas/${encodeURIComponent(String(mangaProviderId))}/fetch-chapters`,
|
|
method: "POST",
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getFetchMangaChaptersMutationOptions = <
|
|
TError = unknown,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof fetchMangaChapters>>,
|
|
TError,
|
|
{ mangaProviderId: number },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof fetchMangaChapters>>,
|
|
TError,
|
|
{ mangaProviderId: number },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["fetchMangaChapters"];
|
|
const { mutation: mutationOptions, request: requestOptions } = options
|
|
? options.mutation &&
|
|
"mutationKey" in options.mutation &&
|
|
options.mutation.mutationKey
|
|
? options
|
|
: { ...options, mutation: { ...options.mutation, mutationKey } }
|
|
: { mutation: { mutationKey }, request: undefined };
|
|
|
|
const mutationFn: MutationFunction<
|
|
Awaited<ReturnType<typeof fetchMangaChapters>>,
|
|
{ mangaProviderId: number }
|
|
> = (props) => {
|
|
const { mangaProviderId } = props ?? {};
|
|
|
|
return fetchMangaChapters(mangaProviderId, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type FetchMangaChaptersMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof fetchMangaChapters>>
|
|
>;
|
|
|
|
export type FetchMangaChaptersMutationError = unknown;
|
|
|
|
/**
|
|
* @summary Fetch the available chapters for a specific manga/provider combination
|
|
*/
|
|
export const useFetchMangaChapters = <TError = unknown, TContext = unknown>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof fetchMangaChapters>>,
|
|
TError,
|
|
{ mangaProviderId: number },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof fetchMangaChapters>>,
|
|
TError,
|
|
{ mangaProviderId: number },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getFetchMangaChaptersMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
|
|
/**
|
|
* Remove a manga from favorites for the logged user.
|
|
* @summary Unfavorite a manga
|
|
*/
|
|
export const setUnfavorite = (
|
|
id: number,
|
|
options?: SecondParameter<typeof customInstance>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customInstance<void>(
|
|
{
|
|
url: `http://192.168.1.142:8080/mangas/${encodeURIComponent(String(id))}/unfavorite`,
|
|
method: "POST",
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getSetUnfavoriteMutationOptions = <
|
|
TError = unknown,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof setUnfavorite>>,
|
|
TError,
|
|
{ id: number },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof setUnfavorite>>,
|
|
TError,
|
|
{ id: number },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["setUnfavorite"];
|
|
const { mutation: mutationOptions, request: requestOptions } = options
|
|
? options.mutation &&
|
|
"mutationKey" in options.mutation &&
|
|
options.mutation.mutationKey
|
|
? options
|
|
: { ...options, mutation: { ...options.mutation, mutationKey } }
|
|
: { mutation: { mutationKey }, request: undefined };
|
|
|
|
const mutationFn: MutationFunction<
|
|
Awaited<ReturnType<typeof setUnfavorite>>,
|
|
{ id: number }
|
|
> = (props) => {
|
|
const { id } = props ?? {};
|
|
|
|
return setUnfavorite(id, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type SetUnfavoriteMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof setUnfavorite>>
|
|
>;
|
|
|
|
export type SetUnfavoriteMutationError = unknown;
|
|
|
|
/**
|
|
* @summary Unfavorite a manga
|
|
*/
|
|
export const useSetUnfavorite = <TError = unknown, TContext = unknown>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof setUnfavorite>>,
|
|
TError,
|
|
{ id: number },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof setUnfavorite>>,
|
|
TError,
|
|
{ id: number },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getSetUnfavoriteMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
|
|
/**
|
|
* Set a manga as favorite for the logged user.
|
|
* @summary Favorite a manga
|
|
*/
|
|
export const setFavorite = (
|
|
id: number,
|
|
options?: SecondParameter<typeof customInstance>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customInstance<void>(
|
|
{
|
|
url: `http://192.168.1.142:8080/mangas/${encodeURIComponent(String(id))}/favorite`,
|
|
method: "POST",
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getSetFavoriteMutationOptions = <
|
|
TError = unknown,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof setFavorite>>,
|
|
TError,
|
|
{ id: number },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof setFavorite>>,
|
|
TError,
|
|
{ id: number },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["setFavorite"];
|
|
const { mutation: mutationOptions, request: requestOptions } = options
|
|
? options.mutation &&
|
|
"mutationKey" in options.mutation &&
|
|
options.mutation.mutationKey
|
|
? options
|
|
: { ...options, mutation: { ...options.mutation, mutationKey } }
|
|
: { mutation: { mutationKey }, request: undefined };
|
|
|
|
const mutationFn: MutationFunction<
|
|
Awaited<ReturnType<typeof setFavorite>>,
|
|
{ id: number }
|
|
> = (props) => {
|
|
const { id } = props ?? {};
|
|
|
|
return setFavorite(id, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type SetFavoriteMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof setFavorite>>
|
|
>;
|
|
|
|
export type SetFavoriteMutationError = unknown;
|
|
|
|
/**
|
|
* @summary Favorite a manga
|
|
*/
|
|
export const useSetFavorite = <TError = unknown, TContext = unknown>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof setFavorite>>,
|
|
TError,
|
|
{ id: number },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof setFavorite>>,
|
|
TError,
|
|
{ id: number },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getSetFavoriteMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
|
|
/**
|
|
* Mark a chapter as read by its ID.
|
|
* @summary Mark a chapter as read
|
|
*/
|
|
export const markAsRead = (
|
|
chapterId: number,
|
|
options?: SecondParameter<typeof customInstance>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customInstance<void>(
|
|
{
|
|
url: `http://192.168.1.142:8080/mangas/${encodeURIComponent(String(chapterId))}/mark-as-read`,
|
|
method: "POST",
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getMarkAsReadMutationOptions = <
|
|
TError = unknown,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof markAsRead>>,
|
|
TError,
|
|
{ chapterId: number },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof markAsRead>>,
|
|
TError,
|
|
{ chapterId: number },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["markAsRead"];
|
|
const { mutation: mutationOptions, request: requestOptions } = options
|
|
? options.mutation &&
|
|
"mutationKey" in options.mutation &&
|
|
options.mutation.mutationKey
|
|
? options
|
|
: { ...options, mutation: { ...options.mutation, mutationKey } }
|
|
: { mutation: { mutationKey }, request: undefined };
|
|
|
|
const mutationFn: MutationFunction<
|
|
Awaited<ReturnType<typeof markAsRead>>,
|
|
{ chapterId: number }
|
|
> = (props) => {
|
|
const { chapterId } = props ?? {};
|
|
|
|
return markAsRead(chapterId, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type MarkAsReadMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof markAsRead>>
|
|
>;
|
|
|
|
export type MarkAsReadMutationError = unknown;
|
|
|
|
/**
|
|
* @summary Mark a chapter as read
|
|
*/
|
|
export const useMarkAsRead = <TError = unknown, TContext = unknown>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof markAsRead>>,
|
|
TError,
|
|
{ chapterId: number },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof markAsRead>>,
|
|
TError,
|
|
{ chapterId: number },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getMarkAsReadMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
|
|
/**
|
|
* @summary Update manga info
|
|
*/
|
|
export const updateMangaInfo = (
|
|
mangaId: number,
|
|
options?: SecondParameter<typeof customInstance>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customInstance<void>(
|
|
{
|
|
url: `http://192.168.1.142:8080/mangas/manga/${encodeURIComponent(String(mangaId))}/info`,
|
|
method: "POST",
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getUpdateMangaInfoMutationOptions = <
|
|
TError = unknown,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof updateMangaInfo>>,
|
|
TError,
|
|
{ mangaId: number },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof updateMangaInfo>>,
|
|
TError,
|
|
{ mangaId: number },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["updateMangaInfo"];
|
|
const { mutation: mutationOptions, request: requestOptions } = options
|
|
? options.mutation &&
|
|
"mutationKey" in options.mutation &&
|
|
options.mutation.mutationKey
|
|
? options
|
|
: { ...options, mutation: { ...options.mutation, mutationKey } }
|
|
: { mutation: { mutationKey }, request: undefined };
|
|
|
|
const mutationFn: MutationFunction<
|
|
Awaited<ReturnType<typeof updateMangaInfo>>,
|
|
{ mangaId: number }
|
|
> = (props) => {
|
|
const { mangaId } = props ?? {};
|
|
|
|
return updateMangaInfo(mangaId, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type UpdateMangaInfoMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof updateMangaInfo>>
|
|
>;
|
|
|
|
export type UpdateMangaInfoMutationError = unknown;
|
|
|
|
/**
|
|
* @summary Update manga info
|
|
*/
|
|
export const useUpdateMangaInfo = <TError = unknown, TContext = unknown>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof updateMangaInfo>>,
|
|
TError,
|
|
{ mangaId: number },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof updateMangaInfo>>,
|
|
TError,
|
|
{ mangaId: number },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getUpdateMangaInfoMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
|
|
/**
|
|
* @summary Download all chapters for a manga provider
|
|
*/
|
|
export const downloadAllChapters = (
|
|
mangaProviderId: number,
|
|
options?: SecondParameter<typeof customInstance>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customInstance<void>(
|
|
{
|
|
url: `http://192.168.1.142:8080/mangas/chapter/${encodeURIComponent(String(mangaProviderId))}/download-all`,
|
|
method: "POST",
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getDownloadAllChaptersMutationOptions = <
|
|
TError = unknown,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof downloadAllChapters>>,
|
|
TError,
|
|
{ mangaProviderId: number },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof downloadAllChapters>>,
|
|
TError,
|
|
{ mangaProviderId: number },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["downloadAllChapters"];
|
|
const { mutation: mutationOptions, request: requestOptions } = options
|
|
? options.mutation &&
|
|
"mutationKey" in options.mutation &&
|
|
options.mutation.mutationKey
|
|
? options
|
|
: { ...options, mutation: { ...options.mutation, mutationKey } }
|
|
: { mutation: { mutationKey }, request: undefined };
|
|
|
|
const mutationFn: MutationFunction<
|
|
Awaited<ReturnType<typeof downloadAllChapters>>,
|
|
{ mangaProviderId: number }
|
|
> = (props) => {
|
|
const { mangaProviderId } = props ?? {};
|
|
|
|
return downloadAllChapters(mangaProviderId, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type DownloadAllChaptersMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof downloadAllChapters>>
|
|
>;
|
|
|
|
export type DownloadAllChaptersMutationError = unknown;
|
|
|
|
/**
|
|
* @summary Download all chapters for a manga provider
|
|
*/
|
|
export const useDownloadAllChapters = <TError = unknown, TContext = unknown>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof downloadAllChapters>>,
|
|
TError,
|
|
{ mangaProviderId: number },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof downloadAllChapters>>,
|
|
TError,
|
|
{ mangaProviderId: number },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getDownloadAllChaptersMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
|
|
/**
|
|
* @summary Fetch chapter
|
|
*/
|
|
export const fetchChapter = (
|
|
chapterId: number,
|
|
options?: SecondParameter<typeof customInstance>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customInstance<void>(
|
|
{
|
|
url: `http://192.168.1.142:8080/mangas/chapter/${encodeURIComponent(String(chapterId))}/fetch`,
|
|
method: "POST",
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getFetchChapterMutationOptions = <
|
|
TError = unknown,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof fetchChapter>>,
|
|
TError,
|
|
{ chapterId: number },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof fetchChapter>>,
|
|
TError,
|
|
{ chapterId: number },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["fetchChapter"];
|
|
const { mutation: mutationOptions, request: requestOptions } = options
|
|
? options.mutation &&
|
|
"mutationKey" in options.mutation &&
|
|
options.mutation.mutationKey
|
|
? options
|
|
: { ...options, mutation: { ...options.mutation, mutationKey } }
|
|
: { mutation: { mutationKey }, request: undefined };
|
|
|
|
const mutationFn: MutationFunction<
|
|
Awaited<ReturnType<typeof fetchChapter>>,
|
|
{ chapterId: number }
|
|
> = (props) => {
|
|
const { chapterId } = props ?? {};
|
|
|
|
return fetchChapter(chapterId, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type FetchChapterMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof fetchChapter>>
|
|
>;
|
|
|
|
export type FetchChapterMutationError = unknown;
|
|
|
|
/**
|
|
* @summary Fetch chapter
|
|
*/
|
|
export const useFetchChapter = <TError = unknown, TContext = unknown>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof fetchChapter>>,
|
|
TError,
|
|
{ chapterId: number },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof fetchChapter>>,
|
|
TError,
|
|
{ chapterId: number },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getFetchChapterMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
|
|
/**
|
|
* @summary Download chapter archive
|
|
*/
|
|
export const downloadChapterArchive = (
|
|
chapterId: number,
|
|
params: DownloadChapterArchiveParams,
|
|
options?: SecondParameter<typeof customInstance>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customInstance<Blob>(
|
|
{
|
|
url: `http://192.168.1.142:8080/mangas/chapter/${encodeURIComponent(String(chapterId))}/download-archive`,
|
|
method: "POST",
|
|
params,
|
|
responseType: "blob",
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getDownloadChapterArchiveMutationOptions = <
|
|
TError = unknown,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof downloadChapterArchive>>,
|
|
TError,
|
|
{ chapterId: number; params: DownloadChapterArchiveParams },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof downloadChapterArchive>>,
|
|
TError,
|
|
{ chapterId: number; params: DownloadChapterArchiveParams },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["downloadChapterArchive"];
|
|
const { mutation: mutationOptions, request: requestOptions } = options
|
|
? options.mutation &&
|
|
"mutationKey" in options.mutation &&
|
|
options.mutation.mutationKey
|
|
? options
|
|
: { ...options, mutation: { ...options.mutation, mutationKey } }
|
|
: { mutation: { mutationKey }, request: undefined };
|
|
|
|
const mutationFn: MutationFunction<
|
|
Awaited<ReturnType<typeof downloadChapterArchive>>,
|
|
{ chapterId: number; params: DownloadChapterArchiveParams }
|
|
> = (props) => {
|
|
const { chapterId, params } = props ?? {};
|
|
|
|
return downloadChapterArchive(chapterId, params, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type DownloadChapterArchiveMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof downloadChapterArchive>>
|
|
>;
|
|
|
|
export type DownloadChapterArchiveMutationError = unknown;
|
|
|
|
/**
|
|
* @summary Download chapter archive
|
|
*/
|
|
export const useDownloadChapterArchive = <TError = unknown, TContext = unknown>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof downloadChapterArchive>>,
|
|
TError,
|
|
{ chapterId: number; params: DownloadChapterArchiveParams },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof downloadChapterArchive>>,
|
|
TError,
|
|
{ chapterId: number; params: DownloadChapterArchiveParams },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getDownloadChapterArchiveMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
|
|
/**
|
|
* Register a new user.
|
|
* @summary Register user
|
|
*/
|
|
export const registerUser = (
|
|
registrationRequestDTO: RegistrationRequestDTO,
|
|
options?: SecondParameter<typeof customInstance>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customInstance<void>(
|
|
{
|
|
url: `http://192.168.1.142:8080/auth/register`,
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
data: registrationRequestDTO,
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getRegisterUserMutationOptions = <
|
|
TError = unknown,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof registerUser>>,
|
|
TError,
|
|
{ data: RegistrationRequestDTO },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof registerUser>>,
|
|
TError,
|
|
{ data: RegistrationRequestDTO },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["registerUser"];
|
|
const { mutation: mutationOptions, request: requestOptions } = options
|
|
? options.mutation &&
|
|
"mutationKey" in options.mutation &&
|
|
options.mutation.mutationKey
|
|
? options
|
|
: { ...options, mutation: { ...options.mutation, mutationKey } }
|
|
: { mutation: { mutationKey }, request: undefined };
|
|
|
|
const mutationFn: MutationFunction<
|
|
Awaited<ReturnType<typeof registerUser>>,
|
|
{ data: RegistrationRequestDTO }
|
|
> = (props) => {
|
|
const { data } = props ?? {};
|
|
|
|
return registerUser(data, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type RegisterUserMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof registerUser>>
|
|
>;
|
|
export type RegisterUserMutationBody = RegistrationRequestDTO;
|
|
export type RegisterUserMutationError = unknown;
|
|
|
|
/**
|
|
* @summary Register user
|
|
*/
|
|
export const useRegisterUser = <TError = unknown, TContext = unknown>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof registerUser>>,
|
|
TError,
|
|
{ data: RegistrationRequestDTO },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof registerUser>>,
|
|
TError,
|
|
{ data: RegistrationRequestDTO },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getRegisterUserMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
|
|
/**
|
|
* Authenticate user with email and password.
|
|
* @summary Authenticate user
|
|
*/
|
|
export const authenticateUser = (
|
|
authenticationRequestDTO: AuthenticationRequestDTO,
|
|
options?: SecondParameter<typeof customInstance>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customInstance<AuthenticationResponseDTO>(
|
|
{
|
|
url: `http://192.168.1.142:8080/auth/login`,
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
data: authenticationRequestDTO,
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getAuthenticateUserMutationOptions = <
|
|
TError = unknown,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof authenticateUser>>,
|
|
TError,
|
|
{ data: AuthenticationRequestDTO },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof authenticateUser>>,
|
|
TError,
|
|
{ data: AuthenticationRequestDTO },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["authenticateUser"];
|
|
const { mutation: mutationOptions, request: requestOptions } = options
|
|
? options.mutation &&
|
|
"mutationKey" in options.mutation &&
|
|
options.mutation.mutationKey
|
|
? options
|
|
: { ...options, mutation: { ...options.mutation, mutationKey } }
|
|
: { mutation: { mutationKey }, request: undefined };
|
|
|
|
const mutationFn: MutationFunction<
|
|
Awaited<ReturnType<typeof authenticateUser>>,
|
|
{ data: AuthenticationRequestDTO }
|
|
> = (props) => {
|
|
const { data } = props ?? {};
|
|
|
|
return authenticateUser(data, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type AuthenticateUserMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof authenticateUser>>
|
|
>;
|
|
export type AuthenticateUserMutationBody = AuthenticationRequestDTO;
|
|
export type AuthenticateUserMutationError = unknown;
|
|
|
|
/**
|
|
* @summary Authenticate user
|
|
*/
|
|
export const useAuthenticateUser = <TError = unknown, TContext = unknown>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof authenticateUser>>,
|
|
TError,
|
|
{ data: AuthenticationRequestDTO },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof authenticateUser>>,
|
|
TError,
|
|
{ data: AuthenticationRequestDTO },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getAuthenticateUserMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
|
|
/**
|
|
* Retrieve a list of mangas with their details.
|
|
* @summary Get a list of mangas
|
|
*/
|
|
export const getMangas = (
|
|
params?: GetMangasParams,
|
|
options?: SecondParameter<typeof customInstance>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customInstance<PageMangaListDTO>(
|
|
{ url: `http://192.168.1.142:8080/mangas`, method: "GET", params, signal },
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getGetMangasQueryKey = (params?: GetMangasParams) => {
|
|
return [
|
|
`http://192.168.1.142:8080/mangas`,
|
|
...(params ? [params] : []),
|
|
] as const;
|
|
};
|
|
|
|
export const getGetMangasQueryOptions = <
|
|
TData = Awaited<ReturnType<typeof getMangas>>,
|
|
TError = unknown,
|
|
>(
|
|
params?: GetMangasParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getMangas>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
) => {
|
|
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
|
|
const queryKey = queryOptions?.queryKey ?? getGetMangasQueryKey(params);
|
|
|
|
const queryFn: QueryFunction<Awaited<ReturnType<typeof getMangas>>> = ({
|
|
signal,
|
|
}) => getMangas(params, requestOptions, signal);
|
|
|
|
return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
|
|
Awaited<ReturnType<typeof getMangas>>,
|
|
TError,
|
|
TData
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
};
|
|
|
|
export type GetMangasQueryResult = NonNullable<
|
|
Awaited<ReturnType<typeof getMangas>>
|
|
>;
|
|
export type GetMangasQueryError = unknown;
|
|
|
|
export function useGetMangas<
|
|
TData = Awaited<ReturnType<typeof getMangas>>,
|
|
TError = unknown,
|
|
>(
|
|
params: undefined | GetMangasParams,
|
|
options: {
|
|
query: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getMangas>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getMangas>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getMangas>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): DefinedUseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useGetMangas<
|
|
TData = Awaited<ReturnType<typeof getMangas>>,
|
|
TError = unknown,
|
|
>(
|
|
params?: GetMangasParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getMangas>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getMangas>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getMangas>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useGetMangas<
|
|
TData = Awaited<ReturnType<typeof getMangas>>,
|
|
TError = unknown,
|
|
>(
|
|
params?: GetMangasParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getMangas>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
/**
|
|
* @summary Get a list of mangas
|
|
*/
|
|
|
|
export function useGetMangas<
|
|
TData = Awaited<ReturnType<typeof getMangas>>,
|
|
TError = unknown,
|
|
>(
|
|
params?: GetMangasParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getMangas>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
} {
|
|
const queryOptions = getGetMangasQueryOptions(params, options);
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
|
TData,
|
|
TError
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
|
|
query.queryKey = queryOptions.queryKey;
|
|
|
|
return query;
|
|
}
|
|
|
|
/**
|
|
* Retrieve a list of manga chapters for a specific manga/provider combination.
|
|
* @summary Get the available chapters for a specific manga/provider combination
|
|
*/
|
|
export const getMangaChapters = (
|
|
mangaProviderId: number,
|
|
options?: SecondParameter<typeof customInstance>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customInstance<MangaChapterDTO[]>(
|
|
{
|
|
url: `http://192.168.1.142:8080/mangas/${encodeURIComponent(String(mangaProviderId))}/chapters`,
|
|
method: "GET",
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getGetMangaChaptersQueryKey = (mangaProviderId?: number) => {
|
|
return [
|
|
`http://192.168.1.142:8080/mangas/${mangaProviderId}/chapters`,
|
|
] as const;
|
|
};
|
|
|
|
export const getGetMangaChaptersQueryOptions = <
|
|
TData = Awaited<ReturnType<typeof getMangaChapters>>,
|
|
TError = unknown,
|
|
>(
|
|
mangaProviderId: number,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<
|
|
Awaited<ReturnType<typeof getMangaChapters>>,
|
|
TError,
|
|
TData
|
|
>
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
) => {
|
|
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
|
|
const queryKey =
|
|
queryOptions?.queryKey ?? getGetMangaChaptersQueryKey(mangaProviderId);
|
|
|
|
const queryFn: QueryFunction<
|
|
Awaited<ReturnType<typeof getMangaChapters>>
|
|
> = ({ signal }) => getMangaChapters(mangaProviderId, requestOptions, signal);
|
|
|
|
return {
|
|
queryKey,
|
|
queryFn,
|
|
enabled: !!mangaProviderId,
|
|
...queryOptions,
|
|
} as UseQueryOptions<
|
|
Awaited<ReturnType<typeof getMangaChapters>>,
|
|
TError,
|
|
TData
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
};
|
|
|
|
export type GetMangaChaptersQueryResult = NonNullable<
|
|
Awaited<ReturnType<typeof getMangaChapters>>
|
|
>;
|
|
export type GetMangaChaptersQueryError = unknown;
|
|
|
|
export function useGetMangaChapters<
|
|
TData = Awaited<ReturnType<typeof getMangaChapters>>,
|
|
TError = unknown,
|
|
>(
|
|
mangaProviderId: number,
|
|
options: {
|
|
query: Partial<
|
|
UseQueryOptions<
|
|
Awaited<ReturnType<typeof getMangaChapters>>,
|
|
TError,
|
|
TData
|
|
>
|
|
> &
|
|
Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getMangaChapters>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getMangaChapters>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): DefinedUseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useGetMangaChapters<
|
|
TData = Awaited<ReturnType<typeof getMangaChapters>>,
|
|
TError = unknown,
|
|
>(
|
|
mangaProviderId: number,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<
|
|
Awaited<ReturnType<typeof getMangaChapters>>,
|
|
TError,
|
|
TData
|
|
>
|
|
> &
|
|
Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getMangaChapters>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getMangaChapters>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useGetMangaChapters<
|
|
TData = Awaited<ReturnType<typeof getMangaChapters>>,
|
|
TError = unknown,
|
|
>(
|
|
mangaProviderId: number,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<
|
|
Awaited<ReturnType<typeof getMangaChapters>>,
|
|
TError,
|
|
TData
|
|
>
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
/**
|
|
* @summary Get the available chapters for a specific manga/provider combination
|
|
*/
|
|
|
|
export function useGetMangaChapters<
|
|
TData = Awaited<ReturnType<typeof getMangaChapters>>,
|
|
TError = unknown,
|
|
>(
|
|
mangaProviderId: number,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<
|
|
Awaited<ReturnType<typeof getMangaChapters>>,
|
|
TError,
|
|
TData
|
|
>
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
} {
|
|
const queryOptions = getGetMangaChaptersQueryOptions(
|
|
mangaProviderId,
|
|
options,
|
|
);
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
|
TData,
|
|
TError
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
|
|
query.queryKey = queryOptions.queryKey;
|
|
|
|
return query;
|
|
}
|
|
|
|
/**
|
|
* @summary Get the details of a manga
|
|
*/
|
|
export const getManga = (
|
|
mangaId: number,
|
|
options?: SecondParameter<typeof customInstance>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customInstance<MangaDTO>(
|
|
{
|
|
url: `http://192.168.1.142:8080/mangas/${encodeURIComponent(String(mangaId))}`,
|
|
method: "GET",
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getGetMangaQueryKey = (mangaId?: number) => {
|
|
return [`http://192.168.1.142:8080/mangas/${mangaId}`] as const;
|
|
};
|
|
|
|
export const getGetMangaQueryOptions = <
|
|
TData = Awaited<ReturnType<typeof getManga>>,
|
|
TError = unknown,
|
|
>(
|
|
mangaId: number,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getManga>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
) => {
|
|
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
|
|
const queryKey = queryOptions?.queryKey ?? getGetMangaQueryKey(mangaId);
|
|
|
|
const queryFn: QueryFunction<Awaited<ReturnType<typeof getManga>>> = ({
|
|
signal,
|
|
}) => getManga(mangaId, requestOptions, signal);
|
|
|
|
return {
|
|
queryKey,
|
|
queryFn,
|
|
enabled: !!mangaId,
|
|
...queryOptions,
|
|
} as UseQueryOptions<Awaited<ReturnType<typeof getManga>>, TError, TData> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
};
|
|
|
|
export type GetMangaQueryResult = NonNullable<
|
|
Awaited<ReturnType<typeof getManga>>
|
|
>;
|
|
export type GetMangaQueryError = unknown;
|
|
|
|
export function useGetManga<
|
|
TData = Awaited<ReturnType<typeof getManga>>,
|
|
TError = unknown,
|
|
>(
|
|
mangaId: number,
|
|
options: {
|
|
query: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getManga>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getManga>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getManga>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): DefinedUseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useGetManga<
|
|
TData = Awaited<ReturnType<typeof getManga>>,
|
|
TError = unknown,
|
|
>(
|
|
mangaId: number,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getManga>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getManga>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getManga>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useGetManga<
|
|
TData = Awaited<ReturnType<typeof getManga>>,
|
|
TError = unknown,
|
|
>(
|
|
mangaId: number,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getManga>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
/**
|
|
* @summary Get the details of a manga
|
|
*/
|
|
|
|
export function useGetManga<
|
|
TData = Awaited<ReturnType<typeof getManga>>,
|
|
TError = unknown,
|
|
>(
|
|
mangaId: number,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getManga>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
} {
|
|
const queryOptions = getGetMangaQueryOptions(mangaId, options);
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
|
TData,
|
|
TError
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
|
|
query.queryKey = queryOptions.queryKey;
|
|
|
|
return query;
|
|
}
|
|
|
|
/**
|
|
* Retrieve a list of manga chapters for a specific manga/provider combination.
|
|
* @summary Get the available chapters for a specific manga/provider combination
|
|
*/
|
|
export const getMangaChapterImages = (
|
|
chapterId: number,
|
|
options?: SecondParameter<typeof customInstance>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customInstance<MangaChapterImagesDTO>(
|
|
{
|
|
url: `http://192.168.1.142:8080/mangas/${encodeURIComponent(String(chapterId))}/images`,
|
|
method: "GET",
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getGetMangaChapterImagesQueryKey = (chapterId?: number) => {
|
|
return [`http://192.168.1.142:8080/mangas/${chapterId}/images`] as const;
|
|
};
|
|
|
|
export const getGetMangaChapterImagesQueryOptions = <
|
|
TData = Awaited<ReturnType<typeof getMangaChapterImages>>,
|
|
TError = unknown,
|
|
>(
|
|
chapterId: number,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<
|
|
Awaited<ReturnType<typeof getMangaChapterImages>>,
|
|
TError,
|
|
TData
|
|
>
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
) => {
|
|
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
|
|
const queryKey =
|
|
queryOptions?.queryKey ?? getGetMangaChapterImagesQueryKey(chapterId);
|
|
|
|
const queryFn: QueryFunction<
|
|
Awaited<ReturnType<typeof getMangaChapterImages>>
|
|
> = ({ signal }) => getMangaChapterImages(chapterId, requestOptions, signal);
|
|
|
|
return {
|
|
queryKey,
|
|
queryFn,
|
|
enabled: !!chapterId,
|
|
...queryOptions,
|
|
} as UseQueryOptions<
|
|
Awaited<ReturnType<typeof getMangaChapterImages>>,
|
|
TError,
|
|
TData
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
};
|
|
|
|
export type GetMangaChapterImagesQueryResult = NonNullable<
|
|
Awaited<ReturnType<typeof getMangaChapterImages>>
|
|
>;
|
|
export type GetMangaChapterImagesQueryError = unknown;
|
|
|
|
export function useGetMangaChapterImages<
|
|
TData = Awaited<ReturnType<typeof getMangaChapterImages>>,
|
|
TError = unknown,
|
|
>(
|
|
chapterId: number,
|
|
options: {
|
|
query: Partial<
|
|
UseQueryOptions<
|
|
Awaited<ReturnType<typeof getMangaChapterImages>>,
|
|
TError,
|
|
TData
|
|
>
|
|
> &
|
|
Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getMangaChapterImages>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getMangaChapterImages>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): DefinedUseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useGetMangaChapterImages<
|
|
TData = Awaited<ReturnType<typeof getMangaChapterImages>>,
|
|
TError = unknown,
|
|
>(
|
|
chapterId: number,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<
|
|
Awaited<ReturnType<typeof getMangaChapterImages>>,
|
|
TError,
|
|
TData
|
|
>
|
|
> &
|
|
Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getMangaChapterImages>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getMangaChapterImages>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useGetMangaChapterImages<
|
|
TData = Awaited<ReturnType<typeof getMangaChapterImages>>,
|
|
TError = unknown,
|
|
>(
|
|
chapterId: number,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<
|
|
Awaited<ReturnType<typeof getMangaChapterImages>>,
|
|
TError,
|
|
TData
|
|
>
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
/**
|
|
* @summary Get the available chapters for a specific manga/provider combination
|
|
*/
|
|
|
|
export function useGetMangaChapterImages<
|
|
TData = Awaited<ReturnType<typeof getMangaChapterImages>>,
|
|
TError = unknown,
|
|
>(
|
|
chapterId: number,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<
|
|
Awaited<ReturnType<typeof getMangaChapterImages>>,
|
|
TError,
|
|
TData
|
|
>
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
} {
|
|
const queryOptions = getGetMangaChapterImagesQueryOptions(chapterId, options);
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
|
TData,
|
|
TError
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
|
|
query.queryKey = queryOptions.queryKey;
|
|
|
|
return query;
|
|
}
|
|
|
|
/**
|
|
* Retrieve a list of genres.
|
|
* @summary Get a list of genres
|
|
*/
|
|
export const getGenres = (
|
|
options?: SecondParameter<typeof customInstance>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customInstance<GenreDTO[]>(
|
|
{ url: `http://192.168.1.142:8080/genres`, method: "GET", signal },
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getGetGenresQueryKey = () => {
|
|
return [`http://192.168.1.142:8080/genres`] as const;
|
|
};
|
|
|
|
export const getGetGenresQueryOptions = <
|
|
TData = Awaited<ReturnType<typeof getGenres>>,
|
|
TError = unknown,
|
|
>(options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getGenres>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
}) => {
|
|
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
|
|
const queryKey = queryOptions?.queryKey ?? getGetGenresQueryKey();
|
|
|
|
const queryFn: QueryFunction<Awaited<ReturnType<typeof getGenres>>> = ({
|
|
signal,
|
|
}) => getGenres(requestOptions, signal);
|
|
|
|
return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
|
|
Awaited<ReturnType<typeof getGenres>>,
|
|
TError,
|
|
TData
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
};
|
|
|
|
export type GetGenresQueryResult = NonNullable<
|
|
Awaited<ReturnType<typeof getGenres>>
|
|
>;
|
|
export type GetGenresQueryError = unknown;
|
|
|
|
export function useGetGenres<
|
|
TData = Awaited<ReturnType<typeof getGenres>>,
|
|
TError = unknown,
|
|
>(
|
|
options: {
|
|
query: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getGenres>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getGenres>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getGenres>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): DefinedUseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useGetGenres<
|
|
TData = Awaited<ReturnType<typeof getGenres>>,
|
|
TError = unknown,
|
|
>(
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getGenres>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getGenres>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getGenres>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useGetGenres<
|
|
TData = Awaited<ReturnType<typeof getGenres>>,
|
|
TError = unknown,
|
|
>(
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getGenres>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
/**
|
|
* @summary Get a list of genres
|
|
*/
|
|
|
|
export function useGetGenres<
|
|
TData = Awaited<ReturnType<typeof getGenres>>,
|
|
TError = unknown,
|
|
>(
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getGenres>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customInstance>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
} {
|
|
const queryOptions = getGetGenresQueryOptions(options);
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
|
TData,
|
|
TError
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
|
|
query.queryKey = queryOptions.queryKey;
|
|
|
|
return query;
|
|
}
|