feature(security): implement token refresh logic and handle session expiration
This commit is contained in:
parent
e23863d26a
commit
bac8847e40
109
src/api/api.ts
109
src/api/api.ts
@ -1,5 +1,6 @@
|
||||
import axios, { type AxiosRequestConfig, isAxiosError } from "axios";
|
||||
import { toast } from "sonner";
|
||||
import type { DefaultResponseDTOAuthenticationResponseDTO } from "@/api/generated/api.schemas.ts";
|
||||
import type { User } from "@/contexts/AuthContext.tsx";
|
||||
|
||||
export const Api = axios.create({
|
||||
@ -12,6 +13,10 @@ interface ErrorResponseDTO {
|
||||
message: string;
|
||||
}
|
||||
|
||||
interface CustomAxiosRequestConfig extends AxiosRequestConfig {
|
||||
_retry?: boolean;
|
||||
}
|
||||
|
||||
Api.interceptors.request.use(async (config) => {
|
||||
const jsonString = localStorage.getItem("userData");
|
||||
if (jsonString) {
|
||||
@ -22,19 +27,117 @@ Api.interceptors.request.use(async (config) => {
|
||||
return config;
|
||||
});
|
||||
|
||||
let isRefreshing = false;
|
||||
let failedQueue: Array<{
|
||||
resolve: (token: string) => void;
|
||||
reject: (error: unknown) => void;
|
||||
}> = [];
|
||||
|
||||
const processQueue = (error: unknown, token: string | null = null) => {
|
||||
failedQueue.forEach((promise) => {
|
||||
if (error) {
|
||||
promise.reject(error);
|
||||
} else if (token) {
|
||||
promise.resolve(token);
|
||||
}
|
||||
});
|
||||
|
||||
failedQueue = [];
|
||||
};
|
||||
|
||||
Api.interceptors.response.use(
|
||||
(response) => response,
|
||||
(error) => {
|
||||
async (error) => {
|
||||
if (!isAxiosError(error)) {
|
||||
console.log(error);
|
||||
return;
|
||||
return Promise.reject(error);
|
||||
}
|
||||
|
||||
const originalRequest = error.config as CustomAxiosRequestConfig;
|
||||
|
||||
if (error.response?.status === 401 && !originalRequest._retry) {
|
||||
const userDataStr = localStorage.getItem("userData");
|
||||
if (!userDataStr) {
|
||||
handleLogout();
|
||||
return Promise.reject(error);
|
||||
}
|
||||
|
||||
const userData: User = JSON.parse(userDataStr);
|
||||
|
||||
// Prevent multiple simultaneous refreshes
|
||||
if (isRefreshing) {
|
||||
return new Promise((resolve, reject) => {
|
||||
failedQueue.push({
|
||||
resolve: (token) => {
|
||||
originalRequest.headers = {
|
||||
...originalRequest.headers,
|
||||
Authorization: `Bearer ${token}`,
|
||||
};
|
||||
resolve(Api(originalRequest));
|
||||
},
|
||||
reject,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
originalRequest._retry = true;
|
||||
isRefreshing = true;
|
||||
|
||||
try {
|
||||
const response =
|
||||
await axios.post<DefaultResponseDTOAuthenticationResponseDTO>(
|
||||
`${import.meta.env.VITE_API_BASE_URL}/auth/refresh`,
|
||||
{ refreshToken: userData.refreshToken },
|
||||
);
|
||||
|
||||
const { accessToken, refreshToken } = response.data.data!;
|
||||
|
||||
const newUserData = {
|
||||
...userData,
|
||||
token: accessToken,
|
||||
refreshToken: refreshToken,
|
||||
};
|
||||
localStorage.setItem("userData", JSON.stringify(newUserData));
|
||||
|
||||
Api.defaults.headers.common.Authorization = `Bearer ${accessToken}`;
|
||||
|
||||
processQueue(null, accessToken);
|
||||
|
||||
originalRequest.headers = {
|
||||
...originalRequest.headers,
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
};
|
||||
|
||||
return Api(originalRequest);
|
||||
} catch (refreshError) {
|
||||
processQueue(refreshError, null);
|
||||
handleLogout("Session expired. Please log in again.");
|
||||
|
||||
return Promise.reject(refreshError);
|
||||
} finally {
|
||||
isRefreshing = false;
|
||||
}
|
||||
}
|
||||
|
||||
const errorDTO = error.response?.data as ErrorResponseDTO;
|
||||
toast.error(errorDTO.message);
|
||||
if (errorDTO?.message) {
|
||||
toast.error(errorDTO.message);
|
||||
}
|
||||
|
||||
return Promise.reject(errorDTO);
|
||||
},
|
||||
);
|
||||
|
||||
const handleLogout = (message?: string) => {
|
||||
localStorage.removeItem("userData");
|
||||
|
||||
if (message) {
|
||||
toast.error(message);
|
||||
}
|
||||
|
||||
window.location.href = "/";
|
||||
};
|
||||
|
||||
export const customInstance = <T>(
|
||||
config: AxiosRequestConfig,
|
||||
options?: AxiosRequestConfig,
|
||||
|
||||
@ -5,245 +5,251 @@
|
||||
* OpenAPI spec version: v0
|
||||
*/
|
||||
export interface UpdateMangaDataCommand {
|
||||
mangaId?: number;
|
||||
mangaId?: number;
|
||||
}
|
||||
|
||||
export interface DefaultResponseDTOVoid {
|
||||
timestamp?: string;
|
||||
data?: unknown;
|
||||
message?: string;
|
||||
timestamp?: string;
|
||||
data?: unknown;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
export interface ImportMangaDexRequestDTO {
|
||||
id: string;
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface DefaultResponseDTOImportMangaDexResponseDTO {
|
||||
timestamp?: string;
|
||||
data?: ImportMangaDexResponseDTO;
|
||||
message?: string;
|
||||
timestamp?: string;
|
||||
data?: ImportMangaDexResponseDTO;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
export interface ImportMangaDexResponseDTO {
|
||||
id: number;
|
||||
id: number;
|
||||
}
|
||||
|
||||
export interface RegistrationRequestDTO {
|
||||
name?: string;
|
||||
email?: string;
|
||||
password?: string;
|
||||
name?: string;
|
||||
email?: string;
|
||||
password?: string;
|
||||
}
|
||||
|
||||
export interface AuthenticationRequestDTO {
|
||||
email: string;
|
||||
password: string;
|
||||
export interface RefreshTokenRequestDTO {
|
||||
refreshToken: string;
|
||||
}
|
||||
|
||||
export type AuthenticationResponseDTORole =
|
||||
(typeof AuthenticationResponseDTORole)[keyof typeof AuthenticationResponseDTORole];
|
||||
export type AuthenticationResponseDTORole = typeof AuthenticationResponseDTORole[keyof typeof AuthenticationResponseDTORole];
|
||||
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
||||
export const AuthenticationResponseDTORole = {
|
||||
USER: "USER",
|
||||
USER: 'USER',
|
||||
} as const;
|
||||
|
||||
export interface AuthenticationResponseDTO {
|
||||
id: number;
|
||||
token: string;
|
||||
email: string;
|
||||
name: string;
|
||||
role: AuthenticationResponseDTORole;
|
||||
id: number;
|
||||
accessToken: string;
|
||||
refreshToken: string;
|
||||
email: string;
|
||||
name: string;
|
||||
role: AuthenticationResponseDTORole;
|
||||
}
|
||||
|
||||
export interface DefaultResponseDTOAuthenticationResponseDTO {
|
||||
timestamp?: string;
|
||||
data?: AuthenticationResponseDTO;
|
||||
message?: string;
|
||||
timestamp?: string;
|
||||
data?: AuthenticationResponseDTO;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
export interface AuthenticationRequestDTO {
|
||||
email: string;
|
||||
password: string;
|
||||
}
|
||||
|
||||
export interface DefaultResponseDTOPageMangaListDTO {
|
||||
timestamp?: string;
|
||||
data?: PageMangaListDTO;
|
||||
message?: string;
|
||||
timestamp?: string;
|
||||
data?: PageMangaListDTO;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
pageNumber?: number;
|
||||
pageSize?: number;
|
||||
paged?: boolean;
|
||||
sort?: SortObject;
|
||||
unpaged?: boolean;
|
||||
offset?: number;
|
||||
pageNumber?: number;
|
||||
pageSize?: number;
|
||||
paged?: boolean;
|
||||
sort?: SortObject;
|
||||
unpaged?: boolean;
|
||||
}
|
||||
|
||||
export interface SortObject {
|
||||
empty?: boolean;
|
||||
sorted?: boolean;
|
||||
unsorted?: boolean;
|
||||
empty?: boolean;
|
||||
sorted?: boolean;
|
||||
unsorted?: boolean;
|
||||
}
|
||||
|
||||
export interface DefaultResponseDTOListMangaChapterDTO {
|
||||
timestamp?: string;
|
||||
data?: MangaChapterDTO[];
|
||||
message?: string;
|
||||
timestamp?: string;
|
||||
data?: MangaChapterDTO[];
|
||||
message?: string;
|
||||
}
|
||||
|
||||
export interface MangaChapterDTO {
|
||||
id: number;
|
||||
/** @minLength 1 */
|
||||
title: string;
|
||||
downloaded: boolean;
|
||||
isRead: boolean;
|
||||
id: number;
|
||||
/** @minLength 1 */
|
||||
title: string;
|
||||
downloaded: boolean;
|
||||
isRead: boolean;
|
||||
}
|
||||
|
||||
export interface DefaultResponseDTOMangaDTO {
|
||||
timestamp?: string;
|
||||
data?: MangaDTO;
|
||||
message?: string;
|
||||
timestamp?: string;
|
||||
data?: MangaDTO;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
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[];
|
||||
chapterCount: number;
|
||||
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[];
|
||||
chapterCount: number;
|
||||
}
|
||||
|
||||
export interface MangaProviderDTO {
|
||||
id: number;
|
||||
/** @minLength 1 */
|
||||
providerName: string;
|
||||
chaptersAvailable: number;
|
||||
chaptersDownloaded: number;
|
||||
supportsChapterFetch: boolean;
|
||||
id: number;
|
||||
/** @minLength 1 */
|
||||
providerName: string;
|
||||
chaptersAvailable: number;
|
||||
chaptersDownloaded: number;
|
||||
supportsChapterFetch: boolean;
|
||||
}
|
||||
|
||||
export interface DefaultResponseDTOMangaChapterImagesDTO {
|
||||
timestamp?: string;
|
||||
data?: MangaChapterImagesDTO;
|
||||
message?: string;
|
||||
timestamp?: string;
|
||||
data?: MangaChapterImagesDTO;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
export interface MangaChapterImagesDTO {
|
||||
id: number;
|
||||
/** @minLength 1 */
|
||||
mangaTitle: string;
|
||||
chapterImageKeys: string[];
|
||||
id: number;
|
||||
/** @minLength 1 */
|
||||
mangaTitle: string;
|
||||
chapterImageKeys: string[];
|
||||
}
|
||||
|
||||
export interface DefaultResponseDTOListImportReviewDTO {
|
||||
timestamp?: string;
|
||||
data?: ImportReviewDTO[];
|
||||
message?: string;
|
||||
timestamp?: string;
|
||||
data?: ImportReviewDTO[];
|
||||
message?: string;
|
||||
}
|
||||
|
||||
export interface ImportReviewDTO {
|
||||
id: number;
|
||||
/** @minLength 1 */
|
||||
title: string;
|
||||
/** @minLength 1 */
|
||||
providerName: string;
|
||||
externalUrl?: string;
|
||||
/** @minLength 1 */
|
||||
reason: string;
|
||||
createdAt: string;
|
||||
id: number;
|
||||
/** @minLength 1 */
|
||||
title: string;
|
||||
/** @minLength 1 */
|
||||
providerName: string;
|
||||
externalUrl?: string;
|
||||
/** @minLength 1 */
|
||||
reason: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface DefaultResponseDTOListGenreDTO {
|
||||
timestamp?: string;
|
||||
data?: GenreDTO[];
|
||||
message?: string;
|
||||
timestamp?: string;
|
||||
data?: GenreDTO[];
|
||||
message?: string;
|
||||
}
|
||||
|
||||
export interface GenreDTO {
|
||||
id: number;
|
||||
/** @minLength 1 */
|
||||
name: string;
|
||||
id: number;
|
||||
/** @minLength 1 */
|
||||
name: string;
|
||||
}
|
||||
|
||||
export type DownloadChapterArchiveParams = {
|
||||
archiveFileType: DownloadChapterArchiveArchiveFileType;
|
||||
archiveFileType: DownloadChapterArchiveArchiveFileType;
|
||||
};
|
||||
|
||||
export type DownloadChapterArchiveArchiveFileType =
|
||||
(typeof DownloadChapterArchiveArchiveFileType)[keyof typeof DownloadChapterArchiveArchiveFileType];
|
||||
export type DownloadChapterArchiveArchiveFileType = typeof DownloadChapterArchiveArchiveFileType[keyof typeof DownloadChapterArchiveArchiveFileType];
|
||||
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
||||
export const DownloadChapterArchiveArchiveFileType = {
|
||||
CBZ: "CBZ",
|
||||
CBR: "CBR",
|
||||
CBZ: 'CBZ',
|
||||
CBR: 'CBR',
|
||||
} as const;
|
||||
|
||||
export type ImportMultipleFilesBody = {
|
||||
/** @minLength 1 */
|
||||
malId: string;
|
||||
/** List of files to upload */
|
||||
files: Blob[];
|
||||
/** @minLength 1 */
|
||||
malId: string;
|
||||
/** List of files to upload */
|
||||
files: Blob[];
|
||||
};
|
||||
|
||||
export type ResolveImportReviewParams = {
|
||||
importReviewId: number;
|
||||
malId: string;
|
||||
importReviewId: number;
|
||||
malId: string;
|
||||
};
|
||||
|
||||
export type GetMangasParams = {
|
||||
searchQuery?: string;
|
||||
genreIds?: number[];
|
||||
statuses?: string[];
|
||||
userFavorites?: boolean;
|
||||
score?: number;
|
||||
/**
|
||||
* 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[];
|
||||
searchQuery?: string;
|
||||
genreIds?: number[];
|
||||
statuses?: string[];
|
||||
userFavorites?: boolean;
|
||||
score?: number;
|
||||
/**
|
||||
* 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[];
|
||||
};
|
||||
|
||||
|
||||
@ -4,199 +4,224 @@
|
||||
* OpenAPI definition
|
||||
* OpenAPI spec version: v0
|
||||
*/
|
||||
import {
|
||||
useMutation
|
||||
} from '@tanstack/react-query';
|
||||
import type {
|
||||
MutationFunction,
|
||||
QueryClient,
|
||||
UseMutationOptions,
|
||||
UseMutationResult
|
||||
} from '@tanstack/react-query';
|
||||
|
||||
import type {
|
||||
MutationFunction,
|
||||
QueryClient,
|
||||
UseMutationOptions,
|
||||
UseMutationResult,
|
||||
} from "@tanstack/react-query";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { customInstance } from "../../api";
|
||||
import type {
|
||||
AuthenticationRequestDTO,
|
||||
DefaultResponseDTOAuthenticationResponseDTO,
|
||||
DefaultResponseDTOVoid,
|
||||
RegistrationRequestDTO,
|
||||
} from "../api.schemas";
|
||||
AuthenticationRequestDTO,
|
||||
DefaultResponseDTOAuthenticationResponseDTO,
|
||||
DefaultResponseDTOVoid,
|
||||
RefreshTokenRequestDTO,
|
||||
RegistrationRequestDTO
|
||||
} from '../api.schemas';
|
||||
|
||||
import { customInstance } from '../../api';
|
||||
|
||||
|
||||
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Register a new user.
|
||||
* @summary Register user
|
||||
*/
|
||||
export const registerUser = (
|
||||
registrationRequestDTO: RegistrationRequestDTO,
|
||||
options?: SecondParameter<typeof customInstance>,
|
||||
signal?: AbortSignal,
|
||||
registrationRequestDTO: RegistrationRequestDTO,
|
||||
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
||||
) => {
|
||||
return customInstance<DefaultResponseDTOVoid>(
|
||||
{
|
||||
url: `/auth/register`,
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
data: registrationRequestDTO,
|
||||
signal,
|
||||
},
|
||||
options,
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
return customInstance<DefaultResponseDTOVoid>(
|
||||
{url: `/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 ?? {};
|
||||
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> => {
|
||||
|
||||
return registerUser(data, requestOptions);
|
||||
};
|
||||
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};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
|
||||
export type RegisterUserMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof registerUser>>
|
||||
>;
|
||||
export type RegisterUserMutationBody = RegistrationRequestDTO;
|
||||
export type RegisterUserMutationError = unknown;
|
||||
|
||||
/**
|
||||
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);
|
||||
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
|
||||
> => {
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
const mutationOptions = getRegisterUserMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
}
|
||||
/**
|
||||
* Refresh the authentication token
|
||||
* @summary Refresh authentication token
|
||||
*/
|
||||
export const refreshAuthToken = (
|
||||
refreshTokenRequestDTO: RefreshTokenRequestDTO,
|
||||
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
||||
) => {
|
||||
|
||||
|
||||
return customInstance<DefaultResponseDTOAuthenticationResponseDTO>(
|
||||
{url: `/auth/refresh`, method: 'POST',
|
||||
headers: {'Content-Type': 'application/json', },
|
||||
data: refreshTokenRequestDTO, signal
|
||||
},
|
||||
options);
|
||||
}
|
||||
|
||||
|
||||
|
||||
export const getRefreshAuthTokenMutationOptions = <TError = unknown,
|
||||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof refreshAuthToken>>, TError,{data: RefreshTokenRequestDTO}, TContext>, request?: SecondParameter<typeof customInstance>}
|
||||
): UseMutationOptions<Awaited<ReturnType<typeof refreshAuthToken>>, TError,{data: RefreshTokenRequestDTO}, TContext> => {
|
||||
|
||||
const mutationKey = ['refreshAuthToken'];
|
||||
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 refreshAuthToken>>, {data: RefreshTokenRequestDTO}> = (props) => {
|
||||
const {data} = props ?? {};
|
||||
|
||||
return refreshAuthToken(data,requestOptions)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return { mutationFn, ...mutationOptions }}
|
||||
|
||||
export type RefreshAuthTokenMutationResult = NonNullable<Awaited<ReturnType<typeof refreshAuthToken>>>
|
||||
export type RefreshAuthTokenMutationBody = RefreshTokenRequestDTO
|
||||
export type RefreshAuthTokenMutationError = unknown
|
||||
|
||||
/**
|
||||
* @summary Refresh authentication token
|
||||
*/
|
||||
export const useRefreshAuthToken = <TError = unknown,
|
||||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof refreshAuthToken>>, TError,{data: RefreshTokenRequestDTO}, TContext>, request?: SecondParameter<typeof customInstance>}
|
||||
, queryClient?: QueryClient): UseMutationResult<
|
||||
Awaited<ReturnType<typeof refreshAuthToken>>,
|
||||
TError,
|
||||
{data: RefreshTokenRequestDTO},
|
||||
TContext
|
||||
> => {
|
||||
|
||||
const mutationOptions = getRefreshAuthTokenMutationOptions(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,
|
||||
authenticationRequestDTO: AuthenticationRequestDTO,
|
||||
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
||||
) => {
|
||||
return customInstance<DefaultResponseDTOAuthenticationResponseDTO>(
|
||||
{
|
||||
url: `/auth/login`,
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
data: authenticationRequestDTO,
|
||||
signal,
|
||||
},
|
||||
options,
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
return customInstance<DefaultResponseDTOAuthenticationResponseDTO>(
|
||||
{url: `/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 ?? {};
|
||||
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> => {
|
||||
|
||||
return authenticateUser(data, requestOptions);
|
||||
};
|
||||
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};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
|
||||
export type AuthenticateUserMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof authenticateUser>>
|
||||
>;
|
||||
export type AuthenticateUserMutationBody = AuthenticationRequestDTO;
|
||||
export type AuthenticateUserMutationError = unknown;
|
||||
|
||||
/**
|
||||
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);
|
||||
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
|
||||
> => {
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
const mutationOptions = getAuthenticateUserMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
}
|
||||
|
||||
@ -4,98 +4,83 @@
|
||||
* OpenAPI definition
|
||||
* OpenAPI spec version: v0
|
||||
*/
|
||||
import {
|
||||
useMutation
|
||||
} from '@tanstack/react-query';
|
||||
import type {
|
||||
MutationFunction,
|
||||
QueryClient,
|
||||
UseMutationOptions,
|
||||
UseMutationResult
|
||||
} from '@tanstack/react-query';
|
||||
|
||||
import type {
|
||||
MutationFunction,
|
||||
QueryClient,
|
||||
UseMutationOptions,
|
||||
UseMutationResult,
|
||||
} from "@tanstack/react-query";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { customInstance } from "../../api";
|
||||
import type { UpdateMangaDataCommand } from "../api.schemas";
|
||||
UpdateMangaDataCommand
|
||||
} from '../api.schemas';
|
||||
|
||||
import { customInstance } from '../../api';
|
||||
|
||||
|
||||
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
||||
|
||||
|
||||
|
||||
export const sendRecord = (
|
||||
updateMangaDataCommand: UpdateMangaDataCommand,
|
||||
options?: SecondParameter<typeof customInstance>,
|
||||
signal?: AbortSignal,
|
||||
updateMangaDataCommand: UpdateMangaDataCommand,
|
||||
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
||||
) => {
|
||||
return customInstance<string>(
|
||||
{
|
||||
url: `/records`,
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
data: updateMangaDataCommand,
|
||||
signal,
|
||||
},
|
||||
options,
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
return customInstance<string>(
|
||||
{url: `/records`, method: 'POST',
|
||||
headers: {'Content-Type': 'application/json', },
|
||||
data: updateMangaDataCommand, signal
|
||||
},
|
||||
options);
|
||||
}
|
||||
|
||||
|
||||
export const getSendRecordMutationOptions = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof sendRecord>>,
|
||||
TError,
|
||||
{ data: UpdateMangaDataCommand },
|
||||
TContext
|
||||
>;
|
||||
request?: SecondParameter<typeof customInstance>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof sendRecord>>,
|
||||
TError,
|
||||
{ data: UpdateMangaDataCommand },
|
||||
TContext
|
||||
> => {
|
||||
const mutationKey = ["sendRecord"];
|
||||
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 sendRecord>>,
|
||||
{ data: UpdateMangaDataCommand }
|
||||
> = (props) => {
|
||||
const { data } = props ?? {};
|
||||
export const getSendRecordMutationOptions = <TError = unknown,
|
||||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof sendRecord>>, TError,{data: UpdateMangaDataCommand}, TContext>, request?: SecondParameter<typeof customInstance>}
|
||||
): UseMutationOptions<Awaited<ReturnType<typeof sendRecord>>, TError,{data: UpdateMangaDataCommand}, TContext> => {
|
||||
|
||||
return sendRecord(data, requestOptions);
|
||||
};
|
||||
const mutationKey = ['sendRecord'];
|
||||
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};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
|
||||
export type SendRecordMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof sendRecord>>
|
||||
>;
|
||||
export type SendRecordMutationBody = UpdateMangaDataCommand;
|
||||
export type SendRecordMutationError = unknown;
|
||||
|
||||
export const useSendRecord = <TError = unknown, TContext = unknown>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof sendRecord>>,
|
||||
TError,
|
||||
{ data: UpdateMangaDataCommand },
|
||||
TContext
|
||||
>;
|
||||
request?: SecondParameter<typeof customInstance>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof sendRecord>>,
|
||||
TError,
|
||||
{ data: UpdateMangaDataCommand },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions = getSendRecordMutationOptions(options);
|
||||
const mutationFn: MutationFunction<Awaited<ReturnType<typeof sendRecord>>, {data: UpdateMangaDataCommand}> = (props) => {
|
||||
const {data} = props ?? {};
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
return sendRecord(data,requestOptions)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return { mutationFn, ...mutationOptions }}
|
||||
|
||||
export type SendRecordMutationResult = NonNullable<Awaited<ReturnType<typeof sendRecord>>>
|
||||
export type SendRecordMutationBody = UpdateMangaDataCommand
|
||||
export type SendRecordMutationError = unknown
|
||||
|
||||
export const useSendRecord = <TError = unknown,
|
||||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof sendRecord>>, TError,{data: UpdateMangaDataCommand}, TContext>, request?: SecondParameter<typeof customInstance>}
|
||||
, queryClient?: QueryClient): UseMutationResult<
|
||||
Awaited<ReturnType<typeof sendRecord>>,
|
||||
TError,
|
||||
{data: UpdateMangaDataCommand},
|
||||
TContext
|
||||
> => {
|
||||
|
||||
const mutationOptions = getSendRecordMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
}
|
||||
|
||||
@ -4,190 +4,151 @@
|
||||
* OpenAPI definition
|
||||
* OpenAPI spec version: v0
|
||||
*/
|
||||
import {
|
||||
useMutation
|
||||
} from '@tanstack/react-query';
|
||||
import type {
|
||||
MutationFunction,
|
||||
QueryClient,
|
||||
UseMutationOptions,
|
||||
UseMutationResult
|
||||
} from '@tanstack/react-query';
|
||||
|
||||
import type {
|
||||
MutationFunction,
|
||||
QueryClient,
|
||||
UseMutationOptions,
|
||||
UseMutationResult,
|
||||
} from "@tanstack/react-query";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { customInstance } from "../../api";
|
||||
import type { DefaultResponseDTOVoid } from "../api.schemas";
|
||||
DefaultResponseDTOVoid
|
||||
} from '../api.schemas';
|
||||
|
||||
import { customInstance } from '../../api';
|
||||
|
||||
|
||||
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Remove a manga from favorites for the logged user.
|
||||
* @summary Unfavorite a manga
|
||||
*/
|
||||
export const setUnfavorite = (
|
||||
id: number,
|
||||
options?: SecondParameter<typeof customInstance>,
|
||||
signal?: AbortSignal,
|
||||
id: number,
|
||||
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
||||
) => {
|
||||
return customInstance<DefaultResponseDTOVoid>(
|
||||
{
|
||||
url: `/mangas/${encodeURIComponent(String(id))}/unfavorite`,
|
||||
method: "POST",
|
||||
signal,
|
||||
},
|
||||
options,
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
return customInstance<DefaultResponseDTOVoid>(
|
||||
{url: `/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 ?? {};
|
||||
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> => {
|
||||
|
||||
return setUnfavorite(id, requestOptions);
|
||||
};
|
||||
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};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
|
||||
export type SetUnfavoriteMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof setUnfavorite>>
|
||||
>;
|
||||
|
||||
export type SetUnfavoriteMutationError = unknown;
|
||||
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);
|
||||
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
|
||||
> => {
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
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,
|
||||
id: number,
|
||||
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
||||
) => {
|
||||
return customInstance<DefaultResponseDTOVoid>(
|
||||
{
|
||||
url: `/mangas/${encodeURIComponent(String(id))}/favorite`,
|
||||
method: "POST",
|
||||
signal,
|
||||
},
|
||||
options,
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
return customInstance<DefaultResponseDTOVoid>(
|
||||
{url: `/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 ?? {};
|
||||
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> => {
|
||||
|
||||
return setFavorite(id, requestOptions);
|
||||
};
|
||||
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};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
|
||||
export type SetFavoriteMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof setFavorite>>
|
||||
>;
|
||||
|
||||
export type SetFavoriteMutationError = unknown;
|
||||
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);
|
||||
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
|
||||
> => {
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
const mutationOptions = getSetFavoriteMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
}
|
||||
|
||||
@ -4,155 +4,122 @@
|
||||
* OpenAPI definition
|
||||
* OpenAPI spec version: v0
|
||||
*/
|
||||
import {
|
||||
useQuery
|
||||
} from '@tanstack/react-query';
|
||||
import type {
|
||||
DataTag,
|
||||
DefinedInitialDataOptions,
|
||||
DefinedUseQueryResult,
|
||||
QueryClient,
|
||||
QueryFunction,
|
||||
QueryKey,
|
||||
UndefinedInitialDataOptions,
|
||||
UseQueryOptions,
|
||||
UseQueryResult
|
||||
} from '@tanstack/react-query';
|
||||
|
||||
import type {
|
||||
DataTag,
|
||||
DefinedInitialDataOptions,
|
||||
DefinedUseQueryResult,
|
||||
QueryClient,
|
||||
QueryFunction,
|
||||
QueryKey,
|
||||
UndefinedInitialDataOptions,
|
||||
UseQueryOptions,
|
||||
UseQueryResult,
|
||||
} from "@tanstack/react-query";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { customInstance } from "../../api";
|
||||
import type { DefaultResponseDTOListGenreDTO } from "../api.schemas";
|
||||
DefaultResponseDTOListGenreDTO
|
||||
} from '../api.schemas';
|
||||
|
||||
import { customInstance } from '../../api';
|
||||
|
||||
|
||||
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve a list of genres.
|
||||
* @summary Get a list of genres
|
||||
*/
|
||||
export const getGenres = (
|
||||
options?: SecondParameter<typeof customInstance>,
|
||||
signal?: AbortSignal,
|
||||
|
||||
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
||||
) => {
|
||||
return customInstance<DefaultResponseDTOListGenreDTO>(
|
||||
{ url: `/genres`, method: "GET", signal },
|
||||
options,
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
return customInstance<DefaultResponseDTOListGenreDTO>(
|
||||
{url: `/genres`, method: 'GET', signal
|
||||
},
|
||||
options);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
export const getGetGenresQueryKey = () => {
|
||||
return [`/genres`] as const;
|
||||
};
|
||||
return [
|
||||
`/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 ?? {};
|
||||
|
||||
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 queryKey = queryOptions?.queryKey ?? getGetGenresQueryKey();
|
||||
const {query: queryOptions, request: requestOptions} = options ?? {};
|
||||
|
||||
const queryFn: QueryFunction<Awaited<ReturnType<typeof getGenres>>> = ({
|
||||
signal,
|
||||
}) => getGenres(requestOptions, signal);
|
||||
const queryKey = queryOptions?.queryKey ?? getGetGenresQueryKey();
|
||||
|
||||
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;
|
||||
const queryFn: QueryFunction<Awaited<ReturnType<typeof getGenres>>> = ({ signal }) => getGenres(requestOptions, signal);
|
||||
|
||||
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>;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
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);
|
||||
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 query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
||||
TData,
|
||||
TError
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
const queryOptions = getGetGenresQueryOptions(options)
|
||||
|
||||
query.queryKey = queryOptions.queryKey;
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
return query;
|
||||
query.queryKey = queryOptions.queryKey ;
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -4,551 +4,383 @@
|
||||
* 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 type {
|
||||
DataTag,
|
||||
DefinedInitialDataOptions,
|
||||
DefinedUseQueryResult,
|
||||
MutationFunction,
|
||||
QueryClient,
|
||||
QueryFunction,
|
||||
QueryKey,
|
||||
UndefinedInitialDataOptions,
|
||||
UseMutationOptions,
|
||||
UseMutationResult,
|
||||
UseQueryOptions,
|
||||
UseQueryResult,
|
||||
} from "@tanstack/react-query";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { customInstance } from "../../api";
|
||||
import type {
|
||||
DefaultResponseDTOMangaChapterImagesDTO,
|
||||
DefaultResponseDTOVoid,
|
||||
DownloadChapterArchiveParams,
|
||||
} from "../api.schemas";
|
||||
DefaultResponseDTOMangaChapterImagesDTO,
|
||||
DefaultResponseDTOVoid,
|
||||
DownloadChapterArchiveParams
|
||||
} from '../api.schemas';
|
||||
|
||||
import { customInstance } from '../../api';
|
||||
|
||||
|
||||
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Fetch all not yet downloaded chapters from the provider
|
||||
* @summary Fetch all chapters
|
||||
*/
|
||||
export const fetchAllChapters = (
|
||||
mangaProviderId: number,
|
||||
options?: SecondParameter<typeof customInstance>,
|
||||
signal?: AbortSignal,
|
||||
mangaProviderId: number,
|
||||
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
||||
) => {
|
||||
return customInstance<DefaultResponseDTOVoid>(
|
||||
{
|
||||
url: `/mangas/${encodeURIComponent(String(mangaProviderId))}/fetch-all-chapters`,
|
||||
method: "POST",
|
||||
signal,
|
||||
},
|
||||
options,
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
return customInstance<DefaultResponseDTOVoid>(
|
||||
{url: `/mangas/${encodeURIComponent(String(mangaProviderId))}/fetch-all-chapters`, method: 'POST', signal
|
||||
},
|
||||
options);
|
||||
}
|
||||
|
||||
|
||||
export const getFetchAllChaptersMutationOptions = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof fetchAllChapters>>,
|
||||
TError,
|
||||
{ mangaProviderId: number },
|
||||
TContext
|
||||
>;
|
||||
request?: SecondParameter<typeof customInstance>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof fetchAllChapters>>,
|
||||
TError,
|
||||
{ mangaProviderId: number },
|
||||
TContext
|
||||
> => {
|
||||
const mutationKey = ["fetchAllChapters"];
|
||||
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 fetchAllChapters>>,
|
||||
{ mangaProviderId: number }
|
||||
> = (props) => {
|
||||
const { mangaProviderId } = props ?? {};
|
||||
export const getFetchAllChaptersMutationOptions = <TError = unknown,
|
||||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof fetchAllChapters>>, TError,{mangaProviderId: number}, TContext>, request?: SecondParameter<typeof customInstance>}
|
||||
): UseMutationOptions<Awaited<ReturnType<typeof fetchAllChapters>>, TError,{mangaProviderId: number}, TContext> => {
|
||||
|
||||
return fetchAllChapters(mangaProviderId, requestOptions);
|
||||
};
|
||||
const mutationKey = ['fetchAllChapters'];
|
||||
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};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
|
||||
export type FetchAllChaptersMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof fetchAllChapters>>
|
||||
>;
|
||||
|
||||
export type FetchAllChaptersMutationError = unknown;
|
||||
const mutationFn: MutationFunction<Awaited<ReturnType<typeof fetchAllChapters>>, {mangaProviderId: number}> = (props) => {
|
||||
const {mangaProviderId} = props ?? {};
|
||||
|
||||
/**
|
||||
return fetchAllChapters(mangaProviderId,requestOptions)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return { mutationFn, ...mutationOptions }}
|
||||
|
||||
export type FetchAllChaptersMutationResult = NonNullable<Awaited<ReturnType<typeof fetchAllChapters>>>
|
||||
|
||||
export type FetchAllChaptersMutationError = unknown
|
||||
|
||||
/**
|
||||
* @summary Fetch all chapters
|
||||
*/
|
||||
export const useFetchAllChapters = <TError = unknown, TContext = unknown>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof fetchAllChapters>>,
|
||||
TError,
|
||||
{ mangaProviderId: number },
|
||||
TContext
|
||||
>;
|
||||
request?: SecondParameter<typeof customInstance>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof fetchAllChapters>>,
|
||||
TError,
|
||||
{ mangaProviderId: number },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions = getFetchAllChaptersMutationOptions(options);
|
||||
export const useFetchAllChapters = <TError = unknown,
|
||||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof fetchAllChapters>>, TError,{mangaProviderId: number}, TContext>, request?: SecondParameter<typeof customInstance>}
|
||||
, queryClient?: QueryClient): UseMutationResult<
|
||||
Awaited<ReturnType<typeof fetchAllChapters>>,
|
||||
TError,
|
||||
{mangaProviderId: number},
|
||||
TContext
|
||||
> => {
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
const mutationOptions = getFetchAllChaptersMutationOptions(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,
|
||||
chapterId: number,
|
||||
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
||||
) => {
|
||||
return customInstance<DefaultResponseDTOVoid>(
|
||||
{
|
||||
url: `/mangas/chapters/${encodeURIComponent(String(chapterId))}/mark-as-read`,
|
||||
method: "POST",
|
||||
signal,
|
||||
},
|
||||
options,
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
return customInstance<DefaultResponseDTOVoid>(
|
||||
{url: `/mangas/chapters/${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 ?? {};
|
||||
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> => {
|
||||
|
||||
return markAsRead(chapterId, requestOptions);
|
||||
};
|
||||
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};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
|
||||
export type MarkAsReadMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof markAsRead>>
|
||||
>;
|
||||
|
||||
export type MarkAsReadMutationError = unknown;
|
||||
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);
|
||||
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
|
||||
> => {
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
const mutationOptions = getMarkAsReadMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
}
|
||||
/**
|
||||
* Fetch the chapter from the provider
|
||||
* @summary Fetch chapter
|
||||
*/
|
||||
export const fetchChapter = (
|
||||
chapterId: number,
|
||||
options?: SecondParameter<typeof customInstance>,
|
||||
signal?: AbortSignal,
|
||||
chapterId: number,
|
||||
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
||||
) => {
|
||||
return customInstance<DefaultResponseDTOVoid>(
|
||||
{
|
||||
url: `/mangas/chapters/${encodeURIComponent(String(chapterId))}/fetch`,
|
||||
method: "POST",
|
||||
signal,
|
||||
},
|
||||
options,
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
return customInstance<DefaultResponseDTOVoid>(
|
||||
{url: `/mangas/chapters/${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 ?? {};
|
||||
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> => {
|
||||
|
||||
return fetchChapter(chapterId, requestOptions);
|
||||
};
|
||||
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};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
|
||||
export type FetchChapterMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof fetchChapter>>
|
||||
>;
|
||||
|
||||
export type FetchChapterMutationError = unknown;
|
||||
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);
|
||||
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
|
||||
> => {
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
const mutationOptions = getFetchChapterMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
}
|
||||
/**
|
||||
* Download a chapter as a compressed file by its ID.
|
||||
* @summary Download chapter archive
|
||||
*/
|
||||
export const downloadChapterArchive = (
|
||||
chapterId: number,
|
||||
params: DownloadChapterArchiveParams,
|
||||
options?: SecondParameter<typeof customInstance>,
|
||||
signal?: AbortSignal,
|
||||
chapterId: number,
|
||||
params: DownloadChapterArchiveParams,
|
||||
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
||||
) => {
|
||||
return customInstance<Blob>(
|
||||
{
|
||||
url: `/mangas/chapters/${encodeURIComponent(String(chapterId))}/download`,
|
||||
method: "POST",
|
||||
params,
|
||||
responseType: "blob",
|
||||
signal,
|
||||
},
|
||||
options,
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
return customInstance<Blob>(
|
||||
{url: `/mangas/chapters/${encodeURIComponent(String(chapterId))}/download`, 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 ?? {};
|
||||
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> => {
|
||||
|
||||
return downloadChapterArchive(chapterId, params, requestOptions);
|
||||
};
|
||||
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};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
|
||||
export type DownloadChapterArchiveMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof downloadChapterArchive>>
|
||||
>;
|
||||
|
||||
export type DownloadChapterArchiveMutationError = unknown;
|
||||
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);
|
||||
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
|
||||
> => {
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
const mutationOptions = getDownloadChapterArchiveMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
}
|
||||
/**
|
||||
* Retrieve a list of manga chapter images for a specific manga/provider combination.
|
||||
* @summary Get the images for a specific manga/provider combination
|
||||
*/
|
||||
export const getMangaChapterImages = (
|
||||
chapterId: number,
|
||||
options?: SecondParameter<typeof customInstance>,
|
||||
signal?: AbortSignal,
|
||||
chapterId: number,
|
||||
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
||||
) => {
|
||||
return customInstance<DefaultResponseDTOMangaChapterImagesDTO>(
|
||||
{
|
||||
url: `/mangas/chapters/${encodeURIComponent(String(chapterId))}/images`,
|
||||
method: "GET",
|
||||
signal,
|
||||
},
|
||||
options,
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
return customInstance<DefaultResponseDTOMangaChapterImagesDTO>(
|
||||
{url: `/mangas/chapters/${encodeURIComponent(String(chapterId))}/images`, method: 'GET', signal
|
||||
},
|
||||
options);
|
||||
}
|
||||
|
||||
|
||||
export const getGetMangaChapterImagesQueryKey = (chapterId?: number) => {
|
||||
return [`/mangas/chapters/${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>;
|
||||
},
|
||||
|
||||
export const getGetMangaChapterImagesQueryKey = (chapterId?: number,) => {
|
||||
return [
|
||||
`/mangas/chapters/${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 {query: queryOptions, request: requestOptions} = options ?? {};
|
||||
|
||||
const queryFn: QueryFunction<
|
||||
Awaited<ReturnType<typeof getMangaChapterImages>>
|
||||
> = ({ signal }) => getMangaChapterImages(chapterId, requestOptions, signal);
|
||||
const queryKey = queryOptions?.queryKey ?? getGetMangaChapterImagesQueryKey(chapterId);
|
||||
|
||||
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;
|
||||
const queryFn: QueryFunction<Awaited<ReturnType<typeof getMangaChapterImages>>> = ({ signal }) => getMangaChapterImages(chapterId, requestOptions, signal);
|
||||
|
||||
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>;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
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 images 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);
|
||||
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 query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
||||
TData,
|
||||
TError
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
const queryOptions = getGetMangaChapterImagesQueryOptions(chapterId,options)
|
||||
|
||||
query.queryKey = queryOptions.queryKey;
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
return query;
|
||||
query.queryKey = queryOptions.queryKey ;
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -4,347 +4,255 @@
|
||||
* 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 type {
|
||||
DataTag,
|
||||
DefinedInitialDataOptions,
|
||||
DefinedUseQueryResult,
|
||||
MutationFunction,
|
||||
QueryClient,
|
||||
QueryFunction,
|
||||
QueryKey,
|
||||
UndefinedInitialDataOptions,
|
||||
UseMutationOptions,
|
||||
UseMutationResult,
|
||||
UseQueryOptions,
|
||||
UseQueryResult,
|
||||
} from "@tanstack/react-query";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { customInstance } from "../../api";
|
||||
import type {
|
||||
DefaultResponseDTOListImportReviewDTO,
|
||||
DefaultResponseDTOVoid,
|
||||
ResolveImportReviewParams,
|
||||
} from "../api.schemas";
|
||||
DefaultResponseDTOListImportReviewDTO,
|
||||
DefaultResponseDTOVoid,
|
||||
ResolveImportReviewParams
|
||||
} from '../api.schemas';
|
||||
|
||||
import { customInstance } from '../../api';
|
||||
|
||||
|
||||
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get list of pending import reviews.
|
||||
* @summary Get list of pending import reviews
|
||||
*/
|
||||
export const getImportReviews = (
|
||||
options?: SecondParameter<typeof customInstance>,
|
||||
signal?: AbortSignal,
|
||||
|
||||
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
||||
) => {
|
||||
return customInstance<DefaultResponseDTOListImportReviewDTO>(
|
||||
{ url: `/manga/import/review`, method: "GET", signal },
|
||||
options,
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
return customInstance<DefaultResponseDTOListImportReviewDTO>(
|
||||
{url: `/manga/import/review`, method: 'GET', signal
|
||||
},
|
||||
options);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
export const getGetImportReviewsQueryKey = () => {
|
||||
return [`/manga/import/review`] as const;
|
||||
};
|
||||
return [
|
||||
`/manga/import/review`
|
||||
] as const;
|
||||
}
|
||||
|
||||
export const getGetImportReviewsQueryOptions = <
|
||||
TData = Awaited<ReturnType<typeof getImportReviews>>,
|
||||
TError = unknown,
|
||||
>(options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<Awaited<ReturnType<typeof getImportReviews>>, TError, TData>
|
||||
>;
|
||||
request?: SecondParameter<typeof customInstance>;
|
||||
}) => {
|
||||
const { query: queryOptions, request: requestOptions } = options ?? {};
|
||||
|
||||
export const getGetImportReviewsQueryOptions = <TData = Awaited<ReturnType<typeof getImportReviews>>, TError = unknown>( options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getImportReviews>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
||||
) => {
|
||||
|
||||
const queryKey = queryOptions?.queryKey ?? getGetImportReviewsQueryKey();
|
||||
const {query: queryOptions, request: requestOptions} = options ?? {};
|
||||
|
||||
const queryFn: QueryFunction<
|
||||
Awaited<ReturnType<typeof getImportReviews>>
|
||||
> = ({ signal }) => getImportReviews(requestOptions, signal);
|
||||
const queryKey = queryOptions?.queryKey ?? getGetImportReviewsQueryKey();
|
||||
|
||||
return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof getImportReviews>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
};
|
||||
|
||||
|
||||
export type GetImportReviewsQueryResult = NonNullable<
|
||||
Awaited<ReturnType<typeof getImportReviews>>
|
||||
>;
|
||||
export type GetImportReviewsQueryError = unknown;
|
||||
const queryFn: QueryFunction<Awaited<ReturnType<typeof getImportReviews>>> = ({ signal }) => getImportReviews(requestOptions, signal);
|
||||
|
||||
export function useGetImportReviews<
|
||||
TData = Awaited<ReturnType<typeof getImportReviews>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
options: {
|
||||
query: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof getImportReviews>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
DefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof getImportReviews>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof getImportReviews>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
request?: SecondParameter<typeof customInstance>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): DefinedUseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useGetImportReviews<
|
||||
TData = Awaited<ReturnType<typeof getImportReviews>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof getImportReviews>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
> &
|
||||
Pick<
|
||||
UndefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof getImportReviews>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof getImportReviews>>
|
||||
>,
|
||||
"initialData"
|
||||
>;
|
||||
request?: SecondParameter<typeof customInstance>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
export function useGetImportReviews<
|
||||
TData = Awaited<ReturnType<typeof getImportReviews>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof getImportReviews>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
request?: SecondParameter<typeof customInstance>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getImportReviews>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
|
||||
}
|
||||
|
||||
export type GetImportReviewsQueryResult = NonNullable<Awaited<ReturnType<typeof getImportReviews>>>
|
||||
export type GetImportReviewsQueryError = unknown
|
||||
|
||||
|
||||
export function useGetImportReviews<TData = Awaited<ReturnType<typeof getImportReviews>>, TError = unknown>(
|
||||
options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getImportReviews>>, TError, TData>> & Pick<
|
||||
DefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof getImportReviews>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof getImportReviews>>
|
||||
> , 'initialData'
|
||||
>, request?: SecondParameter<typeof customInstance>}
|
||||
, queryClient?: QueryClient
|
||||
): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
||||
export function useGetImportReviews<TData = Awaited<ReturnType<typeof getImportReviews>>, TError = unknown>(
|
||||
options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getImportReviews>>, TError, TData>> & Pick<
|
||||
UndefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof getImportReviews>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof getImportReviews>>
|
||||
> , 'initialData'
|
||||
>, request?: SecondParameter<typeof customInstance>}
|
||||
, queryClient?: QueryClient
|
||||
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
||||
export function useGetImportReviews<TData = Awaited<ReturnType<typeof getImportReviews>>, TError = unknown>(
|
||||
options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getImportReviews>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
||||
, queryClient?: QueryClient
|
||||
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
||||
/**
|
||||
* @summary Get list of pending import reviews
|
||||
*/
|
||||
|
||||
export function useGetImportReviews<
|
||||
TData = Awaited<ReturnType<typeof getImportReviews>>,
|
||||
TError = unknown,
|
||||
>(
|
||||
options?: {
|
||||
query?: Partial<
|
||||
UseQueryOptions<
|
||||
Awaited<ReturnType<typeof getImportReviews>>,
|
||||
TError,
|
||||
TData
|
||||
>
|
||||
>;
|
||||
request?: SecondParameter<typeof customInstance>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseQueryResult<TData, TError> & {
|
||||
queryKey: DataTag<QueryKey, TData, TError>;
|
||||
} {
|
||||
const queryOptions = getGetImportReviewsQueryOptions(options);
|
||||
export function useGetImportReviews<TData = Awaited<ReturnType<typeof getImportReviews>>, TError = unknown>(
|
||||
options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getImportReviews>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
||||
, queryClient?: QueryClient
|
||||
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
|
||||
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
||||
TData,
|
||||
TError
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
const queryOptions = getGetImportReviewsQueryOptions(options)
|
||||
|
||||
query.queryKey = queryOptions.queryKey;
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
return query;
|
||||
query.queryKey = queryOptions.queryKey ;
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Resolve import review by ID.
|
||||
* @summary Resolve import review
|
||||
*/
|
||||
export const resolveImportReview = (
|
||||
params: ResolveImportReviewParams,
|
||||
options?: SecondParameter<typeof customInstance>,
|
||||
signal?: AbortSignal,
|
||||
params: ResolveImportReviewParams,
|
||||
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
||||
) => {
|
||||
return customInstance<DefaultResponseDTOVoid>(
|
||||
{ url: `/manga/import/review`, method: "POST", params, signal },
|
||||
options,
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
return customInstance<DefaultResponseDTOVoid>(
|
||||
{url: `/manga/import/review`, method: 'POST',
|
||||
params, signal
|
||||
},
|
||||
options);
|
||||
}
|
||||
|
||||
|
||||
export const getResolveImportReviewMutationOptions = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof resolveImportReview>>,
|
||||
TError,
|
||||
{ params: ResolveImportReviewParams },
|
||||
TContext
|
||||
>;
|
||||
request?: SecondParameter<typeof customInstance>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof resolveImportReview>>,
|
||||
TError,
|
||||
{ params: ResolveImportReviewParams },
|
||||
TContext
|
||||
> => {
|
||||
const mutationKey = ["resolveImportReview"];
|
||||
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 resolveImportReview>>,
|
||||
{ params: ResolveImportReviewParams }
|
||||
> = (props) => {
|
||||
const { params } = props ?? {};
|
||||
export const getResolveImportReviewMutationOptions = <TError = unknown,
|
||||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof resolveImportReview>>, TError,{params: ResolveImportReviewParams}, TContext>, request?: SecondParameter<typeof customInstance>}
|
||||
): UseMutationOptions<Awaited<ReturnType<typeof resolveImportReview>>, TError,{params: ResolveImportReviewParams}, TContext> => {
|
||||
|
||||
return resolveImportReview(params, requestOptions);
|
||||
};
|
||||
const mutationKey = ['resolveImportReview'];
|
||||
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};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
|
||||
export type ResolveImportReviewMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof resolveImportReview>>
|
||||
>;
|
||||
|
||||
export type ResolveImportReviewMutationError = unknown;
|
||||
const mutationFn: MutationFunction<Awaited<ReturnType<typeof resolveImportReview>>, {params: ResolveImportReviewParams}> = (props) => {
|
||||
const {params} = props ?? {};
|
||||
|
||||
/**
|
||||
return resolveImportReview(params,requestOptions)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return { mutationFn, ...mutationOptions }}
|
||||
|
||||
export type ResolveImportReviewMutationResult = NonNullable<Awaited<ReturnType<typeof resolveImportReview>>>
|
||||
|
||||
export type ResolveImportReviewMutationError = unknown
|
||||
|
||||
/**
|
||||
* @summary Resolve import review
|
||||
*/
|
||||
export const useResolveImportReview = <TError = unknown, TContext = unknown>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof resolveImportReview>>,
|
||||
TError,
|
||||
{ params: ResolveImportReviewParams },
|
||||
TContext
|
||||
>;
|
||||
request?: SecondParameter<typeof customInstance>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof resolveImportReview>>,
|
||||
TError,
|
||||
{ params: ResolveImportReviewParams },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions = getResolveImportReviewMutationOptions(options);
|
||||
export const useResolveImportReview = <TError = unknown,
|
||||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof resolveImportReview>>, TError,{params: ResolveImportReviewParams}, TContext>, request?: SecondParameter<typeof customInstance>}
|
||||
, queryClient?: QueryClient): UseMutationResult<
|
||||
Awaited<ReturnType<typeof resolveImportReview>>,
|
||||
TError,
|
||||
{params: ResolveImportReviewParams},
|
||||
TContext
|
||||
> => {
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
const mutationOptions = getResolveImportReviewMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
}
|
||||
/**
|
||||
* Delete pending import review by ID.
|
||||
* @summary Delete pending import review
|
||||
*/
|
||||
export const deleteImportReview = (
|
||||
id: number,
|
||||
options?: SecondParameter<typeof customInstance>,
|
||||
) => {
|
||||
return customInstance<DefaultResponseDTOVoid>(
|
||||
{
|
||||
url: `/manga/import/review/${encodeURIComponent(String(id))}`,
|
||||
method: "DELETE",
|
||||
},
|
||||
options,
|
||||
);
|
||||
};
|
||||
id: number,
|
||||
options?: SecondParameter<typeof customInstance>,) => {
|
||||
|
||||
|
||||
return customInstance<DefaultResponseDTOVoid>(
|
||||
{url: `/manga/import/review/${encodeURIComponent(String(id))}`, method: 'DELETE'
|
||||
},
|
||||
options);
|
||||
}
|
||||
|
||||
|
||||
export const getDeleteImportReviewMutationOptions = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof deleteImportReview>>,
|
||||
TError,
|
||||
{ id: number },
|
||||
TContext
|
||||
>;
|
||||
request?: SecondParameter<typeof customInstance>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof deleteImportReview>>,
|
||||
TError,
|
||||
{ id: number },
|
||||
TContext
|
||||
> => {
|
||||
const mutationKey = ["deleteImportReview"];
|
||||
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 deleteImportReview>>,
|
||||
{ id: number }
|
||||
> = (props) => {
|
||||
const { id } = props ?? {};
|
||||
export const getDeleteImportReviewMutationOptions = <TError = unknown,
|
||||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteImportReview>>, TError,{id: number}, TContext>, request?: SecondParameter<typeof customInstance>}
|
||||
): UseMutationOptions<Awaited<ReturnType<typeof deleteImportReview>>, TError,{id: number}, TContext> => {
|
||||
|
||||
return deleteImportReview(id, requestOptions);
|
||||
};
|
||||
const mutationKey = ['deleteImportReview'];
|
||||
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};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
|
||||
export type DeleteImportReviewMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof deleteImportReview>>
|
||||
>;
|
||||
|
||||
export type DeleteImportReviewMutationError = unknown;
|
||||
const mutationFn: MutationFunction<Awaited<ReturnType<typeof deleteImportReview>>, {id: number}> = (props) => {
|
||||
const {id} = props ?? {};
|
||||
|
||||
/**
|
||||
return deleteImportReview(id,requestOptions)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return { mutationFn, ...mutationOptions }}
|
||||
|
||||
export type DeleteImportReviewMutationResult = NonNullable<Awaited<ReturnType<typeof deleteImportReview>>>
|
||||
|
||||
export type DeleteImportReviewMutationError = unknown
|
||||
|
||||
/**
|
||||
* @summary Delete pending import review
|
||||
*/
|
||||
export const useDeleteImportReview = <TError = unknown, TContext = unknown>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof deleteImportReview>>,
|
||||
TError,
|
||||
{ id: number },
|
||||
TContext
|
||||
>;
|
||||
request?: SecondParameter<typeof customInstance>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof deleteImportReview>>,
|
||||
TError,
|
||||
{ id: number },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions = getDeleteImportReviewMutationOptions(options);
|
||||
export const useDeleteImportReview = <TError = unknown,
|
||||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteImportReview>>, TError,{id: number}, TContext>, request?: SecondParameter<typeof customInstance>}
|
||||
, queryClient?: QueryClient): UseMutationResult<
|
||||
Awaited<ReturnType<typeof deleteImportReview>>,
|
||||
TError,
|
||||
{id: number},
|
||||
TContext
|
||||
> => {
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
const mutationOptions = getDeleteImportReviewMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
}
|
||||
|
||||
@ -4,205 +4,161 @@
|
||||
* OpenAPI definition
|
||||
* OpenAPI spec version: v0
|
||||
*/
|
||||
import {
|
||||
useMutation
|
||||
} from '@tanstack/react-query';
|
||||
import type {
|
||||
MutationFunction,
|
||||
QueryClient,
|
||||
UseMutationOptions,
|
||||
UseMutationResult
|
||||
} from '@tanstack/react-query';
|
||||
|
||||
import type {
|
||||
MutationFunction,
|
||||
QueryClient,
|
||||
UseMutationOptions,
|
||||
UseMutationResult,
|
||||
} from "@tanstack/react-query";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { customInstance } from "../../api";
|
||||
import type {
|
||||
DefaultResponseDTOImportMangaDexResponseDTO,
|
||||
DefaultResponseDTOVoid,
|
||||
ImportMangaDexRequestDTO,
|
||||
ImportMultipleFilesBody,
|
||||
} from "../api.schemas";
|
||||
DefaultResponseDTOImportMangaDexResponseDTO,
|
||||
DefaultResponseDTOVoid,
|
||||
ImportMangaDexRequestDTO,
|
||||
ImportMultipleFilesBody
|
||||
} from '../api.schemas';
|
||||
|
||||
import { customInstance } from '../../api';
|
||||
|
||||
|
||||
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Accepts multiple files via multipart/form-data and processes them.
|
||||
* @summary Upload multiple files
|
||||
*/
|
||||
export const importMultipleFiles = (
|
||||
importMultipleFilesBody: ImportMultipleFilesBody,
|
||||
options?: SecondParameter<typeof customInstance>,
|
||||
signal?: AbortSignal,
|
||||
importMultipleFilesBody: ImportMultipleFilesBody,
|
||||
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
||||
) => {
|
||||
const formData = new FormData();
|
||||
formData.append(`malId`, importMultipleFilesBody.malId);
|
||||
importMultipleFilesBody.files.forEach((value) =>
|
||||
formData.append(`files`, value),
|
||||
);
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append(`malId`, importMultipleFilesBody.malId)
|
||||
importMultipleFilesBody.files.forEach(value => formData.append(`files`, value));
|
||||
|
||||
return customInstance<DefaultResponseDTOVoid>(
|
||||
{
|
||||
url: `/manga/import/upload`,
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "multipart/form-data" },
|
||||
data: formData,
|
||||
signal,
|
||||
},
|
||||
options,
|
||||
);
|
||||
};
|
||||
return customInstance<DefaultResponseDTOVoid>(
|
||||
{url: `/manga/import/upload`, method: 'POST',
|
||||
headers: {'Content-Type': 'multipart/form-data', },
|
||||
data: formData, signal
|
||||
},
|
||||
options);
|
||||
}
|
||||
|
||||
|
||||
export const getImportMultipleFilesMutationOptions = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof importMultipleFiles>>,
|
||||
TError,
|
||||
{ data: ImportMultipleFilesBody },
|
||||
TContext
|
||||
>;
|
||||
request?: SecondParameter<typeof customInstance>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof importMultipleFiles>>,
|
||||
TError,
|
||||
{ data: ImportMultipleFilesBody },
|
||||
TContext
|
||||
> => {
|
||||
const mutationKey = ["importMultipleFiles"];
|
||||
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 importMultipleFiles>>,
|
||||
{ data: ImportMultipleFilesBody }
|
||||
> = (props) => {
|
||||
const { data } = props ?? {};
|
||||
export const getImportMultipleFilesMutationOptions = <TError = unknown,
|
||||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof importMultipleFiles>>, TError,{data: ImportMultipleFilesBody}, TContext>, request?: SecondParameter<typeof customInstance>}
|
||||
): UseMutationOptions<Awaited<ReturnType<typeof importMultipleFiles>>, TError,{data: ImportMultipleFilesBody}, TContext> => {
|
||||
|
||||
return importMultipleFiles(data, requestOptions);
|
||||
};
|
||||
const mutationKey = ['importMultipleFiles'];
|
||||
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};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
|
||||
export type ImportMultipleFilesMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof importMultipleFiles>>
|
||||
>;
|
||||
export type ImportMultipleFilesMutationBody = ImportMultipleFilesBody;
|
||||
export type ImportMultipleFilesMutationError = unknown;
|
||||
|
||||
/**
|
||||
const mutationFn: MutationFunction<Awaited<ReturnType<typeof importMultipleFiles>>, {data: ImportMultipleFilesBody}> = (props) => {
|
||||
const {data} = props ?? {};
|
||||
|
||||
return importMultipleFiles(data,requestOptions)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return { mutationFn, ...mutationOptions }}
|
||||
|
||||
export type ImportMultipleFilesMutationResult = NonNullable<Awaited<ReturnType<typeof importMultipleFiles>>>
|
||||
export type ImportMultipleFilesMutationBody = ImportMultipleFilesBody
|
||||
export type ImportMultipleFilesMutationError = unknown
|
||||
|
||||
/**
|
||||
* @summary Upload multiple files
|
||||
*/
|
||||
export const useImportMultipleFiles = <TError = unknown, TContext = unknown>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof importMultipleFiles>>,
|
||||
TError,
|
||||
{ data: ImportMultipleFilesBody },
|
||||
TContext
|
||||
>;
|
||||
request?: SecondParameter<typeof customInstance>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof importMultipleFiles>>,
|
||||
TError,
|
||||
{ data: ImportMultipleFilesBody },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions = getImportMultipleFilesMutationOptions(options);
|
||||
export const useImportMultipleFiles = <TError = unknown,
|
||||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof importMultipleFiles>>, TError,{data: ImportMultipleFilesBody}, TContext>, request?: SecondParameter<typeof customInstance>}
|
||||
, queryClient?: QueryClient): UseMutationResult<
|
||||
Awaited<ReturnType<typeof importMultipleFiles>>,
|
||||
TError,
|
||||
{data: ImportMultipleFilesBody},
|
||||
TContext
|
||||
> => {
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
const mutationOptions = getImportMultipleFilesMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
}
|
||||
/**
|
||||
* Imports manga data from MangaDex into the local database.
|
||||
* @summary Import manga from MangaDex
|
||||
*/
|
||||
export const importFromMangaDex = (
|
||||
importMangaDexRequestDTO: ImportMangaDexRequestDTO,
|
||||
options?: SecondParameter<typeof customInstance>,
|
||||
signal?: AbortSignal,
|
||||
importMangaDexRequestDTO: ImportMangaDexRequestDTO,
|
||||
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
||||
) => {
|
||||
return customInstance<DefaultResponseDTOImportMangaDexResponseDTO>(
|
||||
{
|
||||
url: `/manga/import/manga-dex`,
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
data: importMangaDexRequestDTO,
|
||||
signal,
|
||||
},
|
||||
options,
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
return customInstance<DefaultResponseDTOImportMangaDexResponseDTO>(
|
||||
{url: `/manga/import/manga-dex`, method: 'POST',
|
||||
headers: {'Content-Type': 'application/json', },
|
||||
data: importMangaDexRequestDTO, signal
|
||||
},
|
||||
options);
|
||||
}
|
||||
|
||||
|
||||
export const getImportFromMangaDexMutationOptions = <
|
||||
TError = unknown,
|
||||
TContext = unknown,
|
||||
>(options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof importFromMangaDex>>,
|
||||
TError,
|
||||
{ data: ImportMangaDexRequestDTO },
|
||||
TContext
|
||||
>;
|
||||
request?: SecondParameter<typeof customInstance>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof importFromMangaDex>>,
|
||||
TError,
|
||||
{ data: ImportMangaDexRequestDTO },
|
||||
TContext
|
||||
> => {
|
||||
const mutationKey = ["importFromMangaDex"];
|
||||
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 importFromMangaDex>>,
|
||||
{ data: ImportMangaDexRequestDTO }
|
||||
> = (props) => {
|
||||
const { data } = props ?? {};
|
||||
export const getImportFromMangaDexMutationOptions = <TError = unknown,
|
||||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof importFromMangaDex>>, TError,{data: ImportMangaDexRequestDTO}, TContext>, request?: SecondParameter<typeof customInstance>}
|
||||
): UseMutationOptions<Awaited<ReturnType<typeof importFromMangaDex>>, TError,{data: ImportMangaDexRequestDTO}, TContext> => {
|
||||
|
||||
return importFromMangaDex(data, requestOptions);
|
||||
};
|
||||
const mutationKey = ['importFromMangaDex'];
|
||||
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};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
|
||||
export type ImportFromMangaDexMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof importFromMangaDex>>
|
||||
>;
|
||||
export type ImportFromMangaDexMutationBody = ImportMangaDexRequestDTO;
|
||||
export type ImportFromMangaDexMutationError = unknown;
|
||||
|
||||
/**
|
||||
const mutationFn: MutationFunction<Awaited<ReturnType<typeof importFromMangaDex>>, {data: ImportMangaDexRequestDTO}> = (props) => {
|
||||
const {data} = props ?? {};
|
||||
|
||||
return importFromMangaDex(data,requestOptions)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return { mutationFn, ...mutationOptions }}
|
||||
|
||||
export type ImportFromMangaDexMutationResult = NonNullable<Awaited<ReturnType<typeof importFromMangaDex>>>
|
||||
export type ImportFromMangaDexMutationBody = ImportMangaDexRequestDTO
|
||||
export type ImportFromMangaDexMutationError = unknown
|
||||
|
||||
/**
|
||||
* @summary Import manga from MangaDex
|
||||
*/
|
||||
export const useImportFromMangaDex = <TError = unknown, TContext = unknown>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof importFromMangaDex>>,
|
||||
TError,
|
||||
{ data: ImportMangaDexRequestDTO },
|
||||
TContext
|
||||
>;
|
||||
request?: SecondParameter<typeof customInstance>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof importFromMangaDex>>,
|
||||
TError,
|
||||
{ data: ImportMangaDexRequestDTO },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions = getImportFromMangaDexMutationOptions(options);
|
||||
export const useImportFromMangaDex = <TError = unknown,
|
||||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof importFromMangaDex>>, TError,{data: ImportMangaDexRequestDTO}, TContext>, request?: SecondParameter<typeof customInstance>}
|
||||
, queryClient?: QueryClient): UseMutationResult<
|
||||
Awaited<ReturnType<typeof importFromMangaDex>>,
|
||||
TError,
|
||||
{data: ImportMangaDexRequestDTO},
|
||||
TContext
|
||||
> => {
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
const mutationOptions = getImportFromMangaDexMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
}
|
||||
|
||||
@ -4,585 +4,380 @@
|
||||
* 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 type {
|
||||
DataTag,
|
||||
DefinedInitialDataOptions,
|
||||
DefinedUseQueryResult,
|
||||
MutationFunction,
|
||||
QueryClient,
|
||||
QueryFunction,
|
||||
QueryKey,
|
||||
UndefinedInitialDataOptions,
|
||||
UseMutationOptions,
|
||||
UseMutationResult,
|
||||
UseQueryOptions,
|
||||
UseQueryResult,
|
||||
} from "@tanstack/react-query";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { customInstance } from "../../api";
|
||||
import type {
|
||||
DefaultResponseDTOListMangaChapterDTO,
|
||||
DefaultResponseDTOMangaDTO,
|
||||
DefaultResponseDTOPageMangaListDTO,
|
||||
DefaultResponseDTOVoid,
|
||||
GetMangasParams,
|
||||
} from "../api.schemas";
|
||||
DefaultResponseDTOListMangaChapterDTO,
|
||||
DefaultResponseDTOMangaDTO,
|
||||
DefaultResponseDTOPageMangaListDTO,
|
||||
DefaultResponseDTOVoid,
|
||||
GetMangasParams
|
||||
} from '../api.schemas';
|
||||
|
||||
import { customInstance } from '../../api';
|
||||
|
||||
|
||||
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,
|
||||
mangaProviderId: number,
|
||||
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
||||
) => {
|
||||
return customInstance<DefaultResponseDTOVoid>(
|
||||
{
|
||||
url: `/mangas/${encodeURIComponent(String(mangaProviderId))}/fetch-chapters`,
|
||||
method: "POST",
|
||||
signal,
|
||||
},
|
||||
options,
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
return customInstance<DefaultResponseDTOVoid>(
|
||||
{url: `/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 ?? {};
|
||||
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> => {
|
||||
|
||||
return fetchMangaChapters(mangaProviderId, requestOptions);
|
||||
};
|
||||
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};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
|
||||
export type FetchMangaChaptersMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof fetchMangaChapters>>
|
||||
>;
|
||||
|
||||
export type FetchMangaChaptersMutationError = unknown;
|
||||
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);
|
||||
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
|
||||
> => {
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
const mutationOptions = getFetchMangaChaptersMutationOptions(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,
|
||||
params?: GetMangasParams,
|
||||
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
||||
) => {
|
||||
return customInstance<DefaultResponseDTOPageMangaListDTO>(
|
||||
{ url: `/mangas`, method: "GET", params, signal },
|
||||
options,
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
return customInstance<DefaultResponseDTOPageMangaListDTO>(
|
||||
{url: `/mangas`, method: 'GET',
|
||||
params, signal
|
||||
},
|
||||
options);
|
||||
}
|
||||
|
||||
|
||||
export const getGetMangasQueryKey = (params?: GetMangasParams) => {
|
||||
return [`/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>;
|
||||
},
|
||||
|
||||
export const getGetMangasQueryKey = (params?: GetMangasParams,) => {
|
||||
return [
|
||||
`/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 {query: queryOptions, request: requestOptions} = options ?? {};
|
||||
|
||||
const queryFn: QueryFunction<Awaited<ReturnType<typeof getMangas>>> = ({
|
||||
signal,
|
||||
}) => getMangas(params, requestOptions, signal);
|
||||
const queryKey = queryOptions?.queryKey ?? getGetMangasQueryKey(params);
|
||||
|
||||
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;
|
||||
const queryFn: QueryFunction<Awaited<ReturnType<typeof getMangas>>> = ({ signal }) => getMangas(params, requestOptions, signal);
|
||||
|
||||
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>;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
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);
|
||||
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 query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
||||
TData,
|
||||
TError
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
const queryOptions = getGetMangasQueryOptions(params,options)
|
||||
|
||||
query.queryKey = queryOptions.queryKey;
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
return query;
|
||||
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,
|
||||
mangaProviderId: number,
|
||||
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
||||
) => {
|
||||
return customInstance<DefaultResponseDTOListMangaChapterDTO>(
|
||||
{
|
||||
url: `/mangas/${encodeURIComponent(String(mangaProviderId))}/chapters`,
|
||||
method: "GET",
|
||||
signal,
|
||||
},
|
||||
options,
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
return customInstance<DefaultResponseDTOListMangaChapterDTO>(
|
||||
{url: `/mangas/${encodeURIComponent(String(mangaProviderId))}/chapters`, method: 'GET', signal
|
||||
},
|
||||
options);
|
||||
}
|
||||
|
||||
|
||||
export const getGetMangaChaptersQueryKey = (mangaProviderId?: number) => {
|
||||
return [`/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>;
|
||||
},
|
||||
|
||||
export const getGetMangaChaptersQueryKey = (mangaProviderId?: number,) => {
|
||||
return [
|
||||
`/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 {query: queryOptions, request: requestOptions} = options ?? {};
|
||||
|
||||
const queryFn: QueryFunction<
|
||||
Awaited<ReturnType<typeof getMangaChapters>>
|
||||
> = ({ signal }) => getMangaChapters(mangaProviderId, requestOptions, signal);
|
||||
const queryKey = queryOptions?.queryKey ?? getGetMangaChaptersQueryKey(mangaProviderId);
|
||||
|
||||
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;
|
||||
const queryFn: QueryFunction<Awaited<ReturnType<typeof getMangaChapters>>> = ({ signal }) => getMangaChapters(mangaProviderId, requestOptions, signal);
|
||||
|
||||
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>;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
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,
|
||||
);
|
||||
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 query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
||||
TData,
|
||||
TError
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
const queryOptions = getGetMangaChaptersQueryOptions(mangaProviderId,options)
|
||||
|
||||
query.queryKey = queryOptions.queryKey;
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
return query;
|
||||
query.queryKey = queryOptions.queryKey ;
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the details of a manga by its ID
|
||||
* @summary Get the details of a manga
|
||||
*/
|
||||
export const getManga = (
|
||||
mangaId: number,
|
||||
options?: SecondParameter<typeof customInstance>,
|
||||
signal?: AbortSignal,
|
||||
mangaId: number,
|
||||
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
||||
) => {
|
||||
return customInstance<DefaultResponseDTOMangaDTO>(
|
||||
{
|
||||
url: `/mangas/${encodeURIComponent(String(mangaId))}`,
|
||||
method: "GET",
|
||||
signal,
|
||||
},
|
||||
options,
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
return customInstance<DefaultResponseDTOMangaDTO>(
|
||||
{url: `/mangas/${encodeURIComponent(String(mangaId))}`, method: 'GET', signal
|
||||
},
|
||||
options);
|
||||
}
|
||||
|
||||
|
||||
export const getGetMangaQueryKey = (mangaId?: number) => {
|
||||
return [`/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>;
|
||||
},
|
||||
|
||||
export const getGetMangaQueryKey = (mangaId?: number,) => {
|
||||
return [
|
||||
`/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 {query: queryOptions, request: requestOptions} = options ?? {};
|
||||
|
||||
const queryFn: QueryFunction<Awaited<ReturnType<typeof getManga>>> = ({
|
||||
signal,
|
||||
}) => getManga(mangaId, requestOptions, signal);
|
||||
const queryKey = queryOptions?.queryKey ?? getGetMangaQueryKey(mangaId);
|
||||
|
||||
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;
|
||||
const queryFn: QueryFunction<Awaited<ReturnType<typeof getManga>>> = ({ signal }) => getManga(mangaId, requestOptions, signal);
|
||||
|
||||
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>;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
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);
|
||||
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 query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
||||
TData,
|
||||
TError
|
||||
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
const queryOptions = getGetMangaQueryOptions(mangaId,options)
|
||||
|
||||
query.queryKey = queryOptions.queryKey;
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
return query;
|
||||
query.queryKey = queryOptions.queryKey ;
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -22,6 +22,7 @@ export interface User {
|
||||
email: string;
|
||||
name: string;
|
||||
token: string;
|
||||
refreshToken: string;
|
||||
role: string;
|
||||
}
|
||||
|
||||
@ -65,7 +66,8 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
||||
id: response.data.id,
|
||||
email: response.data.email,
|
||||
name: response.data.name,
|
||||
token: response.data.token,
|
||||
token: response.data.accessToken,
|
||||
refreshToken: response.data.refreshToken,
|
||||
role: response.data.role,
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user