Merge pull request 'feature(security): implement token refresh logic and handle session expiration' (#6) from feature/security into main
All checks were successful
ci/woodpecker/push/pipeline Pipeline was successful

Reviewed-on: #6
This commit is contained in:
rov 2025-10-31 13:54:50 -03:00
commit 850a9f95e9
11 changed files with 1619 additions and 2079 deletions

View File

@ -1,5 +1,6 @@
import axios, { type AxiosRequestConfig, isAxiosError } from "axios"; import axios, { type AxiosRequestConfig, isAxiosError } from "axios";
import { toast } from "sonner"; import { toast } from "sonner";
import type { DefaultResponseDTOAuthenticationResponseDTO } from "@/api/generated/api.schemas.ts";
import type { User } from "@/contexts/AuthContext.tsx"; import type { User } from "@/contexts/AuthContext.tsx";
export const Api = axios.create({ export const Api = axios.create({
@ -12,6 +13,10 @@ interface ErrorResponseDTO {
message: string; message: string;
} }
interface CustomAxiosRequestConfig extends AxiosRequestConfig {
_retry?: boolean;
}
Api.interceptors.request.use(async (config) => { Api.interceptors.request.use(async (config) => {
const jsonString = localStorage.getItem("userData"); const jsonString = localStorage.getItem("userData");
if (jsonString) { if (jsonString) {
@ -22,19 +27,117 @@ Api.interceptors.request.use(async (config) => {
return 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( Api.interceptors.response.use(
(response) => response, (response) => response,
(error) => { async (error) => {
if (!isAxiosError(error)) { if (!isAxiosError(error)) {
console.log(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; 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>( export const customInstance = <T>(
config: AxiosRequestConfig, config: AxiosRequestConfig,
options?: AxiosRequestConfig, options?: AxiosRequestConfig,

View File

@ -5,245 +5,251 @@
* OpenAPI spec version: v0 * OpenAPI spec version: v0
*/ */
export interface UpdateMangaDataCommand { export interface UpdateMangaDataCommand {
mangaId?: number; mangaId?: number;
} }
export interface DefaultResponseDTOVoid { export interface DefaultResponseDTOVoid {
timestamp?: string; timestamp?: string;
data?: unknown; data?: unknown;
message?: string; message?: string;
} }
export interface ImportMangaDexRequestDTO { export interface ImportMangaDexRequestDTO {
id: string; id: string;
} }
export interface DefaultResponseDTOImportMangaDexResponseDTO { export interface DefaultResponseDTOImportMangaDexResponseDTO {
timestamp?: string; timestamp?: string;
data?: ImportMangaDexResponseDTO; data?: ImportMangaDexResponseDTO;
message?: string; message?: string;
} }
export interface ImportMangaDexResponseDTO { export interface ImportMangaDexResponseDTO {
id: number; id: number;
} }
export interface RegistrationRequestDTO { export interface RegistrationRequestDTO {
name?: string; name?: string;
email?: string; email?: string;
password?: string; password?: string;
} }
export interface AuthenticationRequestDTO { export interface RefreshTokenRequestDTO {
email: string; refreshToken: string;
password: string;
} }
export type AuthenticationResponseDTORole = export type AuthenticationResponseDTORole = typeof AuthenticationResponseDTORole[keyof typeof AuthenticationResponseDTORole];
(typeof AuthenticationResponseDTORole)[keyof typeof AuthenticationResponseDTORole];
// eslint-disable-next-line @typescript-eslint/no-redeclare // eslint-disable-next-line @typescript-eslint/no-redeclare
export const AuthenticationResponseDTORole = { export const AuthenticationResponseDTORole = {
USER: "USER", USER: 'USER',
} as const; } as const;
export interface AuthenticationResponseDTO { export interface AuthenticationResponseDTO {
id: number; id: number;
token: string; accessToken: string;
email: string; refreshToken: string;
name: string; email: string;
role: AuthenticationResponseDTORole; name: string;
role: AuthenticationResponseDTORole;
} }
export interface DefaultResponseDTOAuthenticationResponseDTO { export interface DefaultResponseDTOAuthenticationResponseDTO {
timestamp?: string; timestamp?: string;
data?: AuthenticationResponseDTO; data?: AuthenticationResponseDTO;
message?: string; message?: string;
}
export interface AuthenticationRequestDTO {
email: string;
password: string;
} }
export interface DefaultResponseDTOPageMangaListDTO { export interface DefaultResponseDTOPageMangaListDTO {
timestamp?: string; timestamp?: string;
data?: PageMangaListDTO; data?: PageMangaListDTO;
message?: string; message?: string;
} }
export interface MangaListDTO { export interface MangaListDTO {
id: number; id: number;
/** @minLength 1 */ /** @minLength 1 */
title: string; title: string;
coverImageKey?: string; coverImageKey?: string;
status?: string; status?: string;
publishedFrom?: string; publishedFrom?: string;
publishedTo?: string; publishedTo?: string;
providerCount?: number; providerCount?: number;
genres: string[]; genres: string[];
authors: string[]; authors: string[];
score: number; score: number;
favorite: boolean; favorite: boolean;
} }
export interface PageMangaListDTO { export interface PageMangaListDTO {
totalPages?: number; totalPages?: number;
totalElements?: number; totalElements?: number;
size?: number; size?: number;
content?: MangaListDTO[]; content?: MangaListDTO[];
number?: number; number?: number;
pageable?: PageableObject; pageable?: PageableObject;
first?: boolean; first?: boolean;
last?: boolean; last?: boolean;
sort?: SortObject; sort?: SortObject;
numberOfElements?: number; numberOfElements?: number;
empty?: boolean; empty?: boolean;
} }
export interface PageableObject { export interface PageableObject {
offset?: number; offset?: number;
pageNumber?: number; pageNumber?: number;
pageSize?: number; pageSize?: number;
paged?: boolean; paged?: boolean;
sort?: SortObject; sort?: SortObject;
unpaged?: boolean; unpaged?: boolean;
} }
export interface SortObject { export interface SortObject {
empty?: boolean; empty?: boolean;
sorted?: boolean; sorted?: boolean;
unsorted?: boolean; unsorted?: boolean;
} }
export interface DefaultResponseDTOListMangaChapterDTO { export interface DefaultResponseDTOListMangaChapterDTO {
timestamp?: string; timestamp?: string;
data?: MangaChapterDTO[]; data?: MangaChapterDTO[];
message?: string; message?: string;
} }
export interface MangaChapterDTO { export interface MangaChapterDTO {
id: number; id: number;
/** @minLength 1 */ /** @minLength 1 */
title: string; title: string;
downloaded: boolean; downloaded: boolean;
isRead: boolean; isRead: boolean;
} }
export interface DefaultResponseDTOMangaDTO { export interface DefaultResponseDTOMangaDTO {
timestamp?: string; timestamp?: string;
data?: MangaDTO; data?: MangaDTO;
message?: string; message?: string;
} }
export interface MangaDTO { export interface MangaDTO {
id: number; id: number;
/** @minLength 1 */ /** @minLength 1 */
title: string; title: string;
coverImageKey?: string; coverImageKey?: string;
status?: string; status?: string;
publishedFrom?: string; publishedFrom?: string;
publishedTo?: string; publishedTo?: string;
synopsis?: string; synopsis?: string;
providerCount?: number; providerCount?: number;
alternativeTitles: string[]; alternativeTitles: string[];
genres: string[]; genres: string[];
authors: string[]; authors: string[];
score: number; score: number;
providers: MangaProviderDTO[]; providers: MangaProviderDTO[];
chapterCount: number; chapterCount: number;
} }
export interface MangaProviderDTO { export interface MangaProviderDTO {
id: number; id: number;
/** @minLength 1 */ /** @minLength 1 */
providerName: string; providerName: string;
chaptersAvailable: number; chaptersAvailable: number;
chaptersDownloaded: number; chaptersDownloaded: number;
supportsChapterFetch: boolean; supportsChapterFetch: boolean;
} }
export interface DefaultResponseDTOMangaChapterImagesDTO { export interface DefaultResponseDTOMangaChapterImagesDTO {
timestamp?: string; timestamp?: string;
data?: MangaChapterImagesDTO; data?: MangaChapterImagesDTO;
message?: string; message?: string;
} }
export interface MangaChapterImagesDTO { export interface MangaChapterImagesDTO {
id: number; id: number;
/** @minLength 1 */ /** @minLength 1 */
mangaTitle: string; mangaTitle: string;
chapterImageKeys: string[]; chapterImageKeys: string[];
} }
export interface DefaultResponseDTOListImportReviewDTO { export interface DefaultResponseDTOListImportReviewDTO {
timestamp?: string; timestamp?: string;
data?: ImportReviewDTO[]; data?: ImportReviewDTO[];
message?: string; message?: string;
} }
export interface ImportReviewDTO { export interface ImportReviewDTO {
id: number; id: number;
/** @minLength 1 */ /** @minLength 1 */
title: string; title: string;
/** @minLength 1 */ /** @minLength 1 */
providerName: string; providerName: string;
externalUrl?: string; externalUrl?: string;
/** @minLength 1 */ /** @minLength 1 */
reason: string; reason: string;
createdAt: string; createdAt: string;
} }
export interface DefaultResponseDTOListGenreDTO { export interface DefaultResponseDTOListGenreDTO {
timestamp?: string; timestamp?: string;
data?: GenreDTO[]; data?: GenreDTO[];
message?: string; message?: string;
} }
export interface GenreDTO { export interface GenreDTO {
id: number; id: number;
/** @minLength 1 */ /** @minLength 1 */
name: string; name: string;
} }
export type DownloadChapterArchiveParams = { export type DownloadChapterArchiveParams = {
archiveFileType: DownloadChapterArchiveArchiveFileType; archiveFileType: DownloadChapterArchiveArchiveFileType;
}; };
export type DownloadChapterArchiveArchiveFileType = export type DownloadChapterArchiveArchiveFileType = typeof DownloadChapterArchiveArchiveFileType[keyof typeof DownloadChapterArchiveArchiveFileType];
(typeof DownloadChapterArchiveArchiveFileType)[keyof typeof DownloadChapterArchiveArchiveFileType];
// eslint-disable-next-line @typescript-eslint/no-redeclare // eslint-disable-next-line @typescript-eslint/no-redeclare
export const DownloadChapterArchiveArchiveFileType = { export const DownloadChapterArchiveArchiveFileType = {
CBZ: "CBZ", CBZ: 'CBZ',
CBR: "CBR", CBR: 'CBR',
} as const; } as const;
export type ImportMultipleFilesBody = { export type ImportMultipleFilesBody = {
/** @minLength 1 */ /** @minLength 1 */
malId: string; malId: string;
/** List of files to upload */ /** List of files to upload */
files: Blob[]; files: Blob[];
}; };
export type ResolveImportReviewParams = { export type ResolveImportReviewParams = {
importReviewId: number; importReviewId: number;
malId: string; malId: string;
}; };
export type GetMangasParams = { export type GetMangasParams = {
searchQuery?: string; searchQuery?: string;
genreIds?: number[]; genreIds?: number[];
statuses?: string[]; statuses?: string[];
userFavorites?: boolean; userFavorites?: boolean;
score?: number; score?: number;
/** /**
* Zero-based page index (0..N) * Zero-based page index (0..N)
* @minimum 0 * @minimum 0
*/ */
page?: number; page?: number;
/** /**
* The size of the page to be returned * The size of the page to be returned
* @minimum 1 * @minimum 1
*/ */
size?: number; size?: number;
/** /**
* Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported. * Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.
*/ */
sort?: string[]; sort?: string[];
}; };

View File

@ -4,199 +4,224 @@
* OpenAPI definition * OpenAPI definition
* OpenAPI spec version: v0 * OpenAPI spec version: v0
*/ */
import {
useMutation
} from '@tanstack/react-query';
import type {
MutationFunction,
QueryClient,
UseMutationOptions,
UseMutationResult
} from '@tanstack/react-query';
import type { import type {
MutationFunction, AuthenticationRequestDTO,
QueryClient, DefaultResponseDTOAuthenticationResponseDTO,
UseMutationOptions, DefaultResponseDTOVoid,
UseMutationResult, RefreshTokenRequestDTO,
} from "@tanstack/react-query"; RegistrationRequestDTO
import { useMutation } from "@tanstack/react-query"; } from '../api.schemas';
import { customInstance } from "../../api";
import type { import { customInstance } from '../../api';
AuthenticationRequestDTO,
DefaultResponseDTOAuthenticationResponseDTO,
DefaultResponseDTOVoid,
RegistrationRequestDTO,
} from "../api.schemas";
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1]; type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
/** /**
* Register a new user. * Register a new user.
* @summary Register user * @summary Register user
*/ */
export const registerUser = ( export const registerUser = (
registrationRequestDTO: RegistrationRequestDTO, registrationRequestDTO: RegistrationRequestDTO,
options?: SecondParameter<typeof customInstance>, options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
signal?: AbortSignal,
) => { ) => {
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< return customInstance<DefaultResponseDTOVoid>(
Awaited<ReturnType<typeof registerUser>>, {url: `/auth/register`, method: 'POST',
{ data: RegistrationRequestDTO } headers: {'Content-Type': 'application/json', },
> = (props) => { data: registrationRequestDTO, signal
const { data } = props ?? {}; },
options);
}
return registerUser(data, requestOptions);
};
return { mutationFn, ...mutationOptions };
};
export type RegisterUserMutationResult = NonNullable< export const getRegisterUserMutationOptions = <TError = unknown,
Awaited<ReturnType<typeof registerUser>> 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> => {
export type RegisterUserMutationBody = RegistrationRequestDTO;
export type RegisterUserMutationError = unknown;
/** const mutationKey = ['registerUser'];
const {mutation: mutationOptions, request: requestOptions} = options ?
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
options
: {...options, mutation: {...options.mutation, mutationKey}}
: {mutation: { mutationKey, }, request: undefined};
const mutationFn: MutationFunction<Awaited<ReturnType<typeof registerUser>>, {data: RegistrationRequestDTO}> = (props) => {
const {data} = props ?? {};
return registerUser(data,requestOptions)
}
return { mutationFn, ...mutationOptions }}
export type RegisterUserMutationResult = NonNullable<Awaited<ReturnType<typeof registerUser>>>
export type RegisterUserMutationBody = RegistrationRequestDTO
export type RegisterUserMutationError = unknown
/**
* @summary Register user * @summary Register user
*/ */
export const useRegisterUser = <TError = unknown, TContext = unknown>( export const useRegisterUser = <TError = unknown,
options?: { TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof registerUser>>, TError,{data: RegistrationRequestDTO}, TContext>, request?: SecondParameter<typeof customInstance>}
mutation?: UseMutationOptions< , queryClient?: QueryClient): UseMutationResult<
Awaited<ReturnType<typeof registerUser>>, Awaited<ReturnType<typeof registerUser>>,
TError, TError,
{ data: RegistrationRequestDTO }, {data: RegistrationRequestDTO},
TContext TContext
>; > => {
request?: SecondParameter<typeof customInstance>;
},
queryClient?: QueryClient,
): UseMutationResult<
Awaited<ReturnType<typeof registerUser>>,
TError,
{ data: RegistrationRequestDTO },
TContext
> => {
const mutationOptions = getRegisterUserMutationOptions(options);
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. * Authenticate user with email and password.
* @summary Authenticate user * @summary Authenticate user
*/ */
export const authenticateUser = ( export const authenticateUser = (
authenticationRequestDTO: AuthenticationRequestDTO, authenticationRequestDTO: AuthenticationRequestDTO,
options?: SecondParameter<typeof customInstance>, options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
signal?: AbortSignal,
) => { ) => {
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< return customInstance<DefaultResponseDTOAuthenticationResponseDTO>(
Awaited<ReturnType<typeof authenticateUser>>, {url: `/auth/login`, method: 'POST',
{ data: AuthenticationRequestDTO } headers: {'Content-Type': 'application/json', },
> = (props) => { data: authenticationRequestDTO, signal
const { data } = props ?? {}; },
options);
}
return authenticateUser(data, requestOptions);
};
return { mutationFn, ...mutationOptions };
};
export type AuthenticateUserMutationResult = NonNullable< export const getAuthenticateUserMutationOptions = <TError = unknown,
Awaited<ReturnType<typeof authenticateUser>> 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> => {
export type AuthenticateUserMutationBody = AuthenticationRequestDTO;
export type AuthenticateUserMutationError = unknown;
/** const mutationKey = ['authenticateUser'];
const {mutation: mutationOptions, request: requestOptions} = options ?
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
options
: {...options, mutation: {...options.mutation, mutationKey}}
: {mutation: { mutationKey, }, request: undefined};
const mutationFn: MutationFunction<Awaited<ReturnType<typeof authenticateUser>>, {data: AuthenticationRequestDTO}> = (props) => {
const {data} = props ?? {};
return authenticateUser(data,requestOptions)
}
return { mutationFn, ...mutationOptions }}
export type AuthenticateUserMutationResult = NonNullable<Awaited<ReturnType<typeof authenticateUser>>>
export type AuthenticateUserMutationBody = AuthenticationRequestDTO
export type AuthenticateUserMutationError = unknown
/**
* @summary Authenticate user * @summary Authenticate user
*/ */
export const useAuthenticateUser = <TError = unknown, TContext = unknown>( export const useAuthenticateUser = <TError = unknown,
options?: { TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof authenticateUser>>, TError,{data: AuthenticationRequestDTO}, TContext>, request?: SecondParameter<typeof customInstance>}
mutation?: UseMutationOptions< , queryClient?: QueryClient): UseMutationResult<
Awaited<ReturnType<typeof authenticateUser>>, Awaited<ReturnType<typeof authenticateUser>>,
TError, TError,
{ data: AuthenticationRequestDTO }, {data: AuthenticationRequestDTO},
TContext TContext
>; > => {
request?: SecondParameter<typeof customInstance>;
}, const mutationOptions = getAuthenticateUserMutationOptions(options);
queryClient?: QueryClient,
): UseMutationResult< return useMutation(mutationOptions, queryClient);
Awaited<ReturnType<typeof authenticateUser>>, }
TError,
{ data: AuthenticationRequestDTO },
TContext
> => {
const mutationOptions = getAuthenticateUserMutationOptions(options);
return useMutation(mutationOptions, queryClient);
};

View File

@ -4,98 +4,83 @@
* OpenAPI definition * OpenAPI definition
* OpenAPI spec version: v0 * OpenAPI spec version: v0
*/ */
import {
useMutation
} from '@tanstack/react-query';
import type {
MutationFunction,
QueryClient,
UseMutationOptions,
UseMutationResult
} from '@tanstack/react-query';
import type { import type {
MutationFunction, UpdateMangaDataCommand
QueryClient, } from '../api.schemas';
UseMutationOptions,
UseMutationResult, import { customInstance } from '../../api';
} from "@tanstack/react-query";
import { useMutation } from "@tanstack/react-query";
import { customInstance } from "../../api";
import type { UpdateMangaDataCommand } from "../api.schemas";
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1]; type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
export const sendRecord = ( export const sendRecord = (
updateMangaDataCommand: UpdateMangaDataCommand, updateMangaDataCommand: UpdateMangaDataCommand,
options?: SecondParameter<typeof customInstance>, options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
signal?: AbortSignal,
) => { ) => {
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< return customInstance<string>(
Awaited<ReturnType<typeof sendRecord>>, {url: `/records`, method: 'POST',
{ data: UpdateMangaDataCommand } headers: {'Content-Type': 'application/json', },
> = (props) => { data: updateMangaDataCommand, signal
const { data } = props ?? {}; },
options);
}
return sendRecord(data, requestOptions);
};
return { mutationFn, ...mutationOptions };
};
export type SendRecordMutationResult = NonNullable< export const getSendRecordMutationOptions = <TError = unknown,
Awaited<ReturnType<typeof sendRecord>> 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> => {
export type SendRecordMutationBody = UpdateMangaDataCommand;
export type SendRecordMutationError = unknown;
export const useSendRecord = <TError = unknown, TContext = unknown>( const mutationKey = ['sendRecord'];
options?: { const {mutation: mutationOptions, request: requestOptions} = options ?
mutation?: UseMutationOptions< options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
Awaited<ReturnType<typeof sendRecord>>, options
TError, : {...options, mutation: {...options.mutation, mutationKey}}
{ data: UpdateMangaDataCommand }, : {mutation: { mutationKey, }, request: undefined};
TContext
>;
request?: SecondParameter<typeof customInstance>;
},
queryClient?: QueryClient, const mutationFn: MutationFunction<Awaited<ReturnType<typeof sendRecord>>, {data: UpdateMangaDataCommand}> = (props) => {
): UseMutationResult< const {data} = props ?? {};
Awaited<ReturnType<typeof sendRecord>>,
TError, return sendRecord(data,requestOptions)
{ data: UpdateMangaDataCommand }, }
TContext
> => {
const mutationOptions = getSendRecordMutationOptions(options);
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);
}
return useMutation(mutationOptions, queryClient);
};

View File

@ -4,190 +4,151 @@
* OpenAPI definition * OpenAPI definition
* OpenAPI spec version: v0 * OpenAPI spec version: v0
*/ */
import {
useMutation
} from '@tanstack/react-query';
import type {
MutationFunction,
QueryClient,
UseMutationOptions,
UseMutationResult
} from '@tanstack/react-query';
import type { import type {
MutationFunction, DefaultResponseDTOVoid
QueryClient, } from '../api.schemas';
UseMutationOptions,
UseMutationResult, import { customInstance } from '../../api';
} from "@tanstack/react-query";
import { useMutation } from "@tanstack/react-query";
import { customInstance } from "../../api";
import type { DefaultResponseDTOVoid } from "../api.schemas";
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1]; type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
/** /**
* Remove a manga from favorites for the logged user. * Remove a manga from favorites for the logged user.
* @summary Unfavorite a manga * @summary Unfavorite a manga
*/ */
export const setUnfavorite = ( export const setUnfavorite = (
id: number, id: number,
options?: SecondParameter<typeof customInstance>, options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
signal?: AbortSignal,
) => { ) => {
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< return customInstance<DefaultResponseDTOVoid>(
Awaited<ReturnType<typeof setUnfavorite>>, {url: `/mangas/${encodeURIComponent(String(id))}/unfavorite`, method: 'POST', signal
{ id: number } },
> = (props) => { options);
const { id } = props ?? {}; }
return setUnfavorite(id, requestOptions);
};
return { mutationFn, ...mutationOptions };
};
export type SetUnfavoriteMutationResult = NonNullable< export const getSetUnfavoriteMutationOptions = <TError = unknown,
Awaited<ReturnType<typeof setUnfavorite>> 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> => {
export type SetUnfavoriteMutationError = unknown; const mutationKey = ['setUnfavorite'];
const {mutation: mutationOptions, request: requestOptions} = options ?
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
options
: {...options, mutation: {...options.mutation, mutationKey}}
: {mutation: { mutationKey, }, request: undefined};
/**
const mutationFn: MutationFunction<Awaited<ReturnType<typeof setUnfavorite>>, {id: number}> = (props) => {
const {id} = props ?? {};
return setUnfavorite(id,requestOptions)
}
return { mutationFn, ...mutationOptions }}
export type SetUnfavoriteMutationResult = NonNullable<Awaited<ReturnType<typeof setUnfavorite>>>
export type SetUnfavoriteMutationError = unknown
/**
* @summary Unfavorite a manga * @summary Unfavorite a manga
*/ */
export const useSetUnfavorite = <TError = unknown, TContext = unknown>( export const useSetUnfavorite = <TError = unknown,
options?: { TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof setUnfavorite>>, TError,{id: number}, TContext>, request?: SecondParameter<typeof customInstance>}
mutation?: UseMutationOptions< , queryClient?: QueryClient): UseMutationResult<
Awaited<ReturnType<typeof setUnfavorite>>, Awaited<ReturnType<typeof setUnfavorite>>,
TError, TError,
{ id: number }, {id: number},
TContext TContext
>; > => {
request?: SecondParameter<typeof customInstance>;
},
queryClient?: QueryClient,
): UseMutationResult<
Awaited<ReturnType<typeof setUnfavorite>>,
TError,
{ id: number },
TContext
> => {
const mutationOptions = getSetUnfavoriteMutationOptions(options);
return useMutation(mutationOptions, queryClient); const mutationOptions = getSetUnfavoriteMutationOptions(options);
};
/** return useMutation(mutationOptions, queryClient);
}
/**
* Set a manga as favorite for the logged user. * Set a manga as favorite for the logged user.
* @summary Favorite a manga * @summary Favorite a manga
*/ */
export const setFavorite = ( export const setFavorite = (
id: number, id: number,
options?: SecondParameter<typeof customInstance>, options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
signal?: AbortSignal,
) => { ) => {
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< return customInstance<DefaultResponseDTOVoid>(
Awaited<ReturnType<typeof setFavorite>>, {url: `/mangas/${encodeURIComponent(String(id))}/favorite`, method: 'POST', signal
{ id: number } },
> = (props) => { options);
const { id } = props ?? {}; }
return setFavorite(id, requestOptions);
};
return { mutationFn, ...mutationOptions };
};
export type SetFavoriteMutationResult = NonNullable< export const getSetFavoriteMutationOptions = <TError = unknown,
Awaited<ReturnType<typeof setFavorite>> 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> => {
export type SetFavoriteMutationError = unknown; const mutationKey = ['setFavorite'];
const {mutation: mutationOptions, request: requestOptions} = options ?
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
options
: {...options, mutation: {...options.mutation, mutationKey}}
: {mutation: { mutationKey, }, request: undefined};
/**
const mutationFn: MutationFunction<Awaited<ReturnType<typeof setFavorite>>, {id: number}> = (props) => {
const {id} = props ?? {};
return setFavorite(id,requestOptions)
}
return { mutationFn, ...mutationOptions }}
export type SetFavoriteMutationResult = NonNullable<Awaited<ReturnType<typeof setFavorite>>>
export type SetFavoriteMutationError = unknown
/**
* @summary Favorite a manga * @summary Favorite a manga
*/ */
export const useSetFavorite = <TError = unknown, TContext = unknown>( export const useSetFavorite = <TError = unknown,
options?: { TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof setFavorite>>, TError,{id: number}, TContext>, request?: SecondParameter<typeof customInstance>}
mutation?: UseMutationOptions< , queryClient?: QueryClient): UseMutationResult<
Awaited<ReturnType<typeof setFavorite>>, Awaited<ReturnType<typeof setFavorite>>,
TError, TError,
{ id: number }, {id: number},
TContext TContext
>; > => {
request?: SecondParameter<typeof customInstance>;
}, const mutationOptions = getSetFavoriteMutationOptions(options);
queryClient?: QueryClient,
): UseMutationResult< return useMutation(mutationOptions, queryClient);
Awaited<ReturnType<typeof setFavorite>>, }
TError,
{ id: number },
TContext
> => {
const mutationOptions = getSetFavoriteMutationOptions(options);
return useMutation(mutationOptions, queryClient);
};

View File

@ -4,155 +4,122 @@
* OpenAPI definition * OpenAPI definition
* OpenAPI spec version: v0 * 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 { import type {
DataTag, DefaultResponseDTOListGenreDTO
DefinedInitialDataOptions, } from '../api.schemas';
DefinedUseQueryResult,
QueryClient, import { customInstance } from '../../api';
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";
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1]; type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
/** /**
* Retrieve a list of genres. * Retrieve a list of genres.
* @summary Get a list of genres * @summary Get a list of genres
*/ */
export const getGenres = ( 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 = () => { 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 ?? {};
const queryKey = queryOptions?.queryKey ?? getGetGenresQueryKey(); 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 queryFn: QueryFunction<Awaited<ReturnType<typeof getGenres>>> = ({ const {query: queryOptions, request: requestOptions} = options ?? {};
signal,
}) => getGenres(requestOptions, signal);
return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< const queryKey = queryOptions?.queryKey ?? getGetGenresQueryKey();
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>>, const queryFn: QueryFunction<Awaited<ReturnType<typeof getGenres>>> = ({ signal }) => getGenres(requestOptions, signal);
TError = unknown,
>(
options: {
query: Partial<
UseQueryOptions<Awaited<ReturnType<typeof getGenres>>, TError, TData>
> & return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getGenres>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
Pick< }
DefinedInitialDataOptions<
Awaited<ReturnType<typeof getGenres>>, export type GetGenresQueryResult = NonNullable<Awaited<ReturnType<typeof getGenres>>>
TError, export type GetGenresQueryError = unknown
Awaited<ReturnType<typeof getGenres>>
>,
"initialData" export function useGetGenres<TData = Awaited<ReturnType<typeof getGenres>>, TError = unknown>(
>; options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getGenres>>, TError, TData>> & Pick<
request?: SecondParameter<typeof customInstance>; DefinedInitialDataOptions<
}, Awaited<ReturnType<typeof getGenres>>,
queryClient?: QueryClient, TError,
): DefinedUseQueryResult<TData, TError> & { Awaited<ReturnType<typeof getGenres>>
queryKey: DataTag<QueryKey, TData, TError>; > , 'initialData'
}; >, request?: SecondParameter<typeof customInstance>}
export function useGetGenres< , queryClient?: QueryClient
TData = Awaited<ReturnType<typeof getGenres>>, ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
TError = unknown, export function useGetGenres<TData = Awaited<ReturnType<typeof getGenres>>, TError = unknown>(
>( options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getGenres>>, TError, TData>> & Pick<
options?: { UndefinedInitialDataOptions<
query?: Partial< Awaited<ReturnType<typeof getGenres>>,
UseQueryOptions<Awaited<ReturnType<typeof getGenres>>, TError, TData> TError,
> & Awaited<ReturnType<typeof getGenres>>
Pick< > , 'initialData'
UndefinedInitialDataOptions< >, request?: SecondParameter<typeof customInstance>}
Awaited<ReturnType<typeof getGenres>>, , queryClient?: QueryClient
TError, ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
Awaited<ReturnType<typeof getGenres>> export function useGetGenres<TData = Awaited<ReturnType<typeof getGenres>>, TError = unknown>(
>, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getGenres>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
"initialData" , queryClient?: QueryClient
>; ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
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 * @summary Get a list of genres
*/ */
export function useGetGenres< export function useGetGenres<TData = Awaited<ReturnType<typeof getGenres>>, TError = unknown>(
TData = Awaited<ReturnType<typeof getGenres>>, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getGenres>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
TError = unknown, , queryClient?: QueryClient
>( ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
options?: {
query?: Partial<
UseQueryOptions<Awaited<ReturnType<typeof getGenres>>, TError, TData>
>;
request?: SecondParameter<typeof customInstance>;
},
queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
queryKey: DataTag<QueryKey, TData, TError>;
} {
const queryOptions = getGetGenresQueryOptions(options);
const query = useQuery(queryOptions, queryClient) as UseQueryResult< const queryOptions = getGetGenresQueryOptions(options)
TData,
TError
> & { queryKey: DataTag<QueryKey, TData, TError> };
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;
} }

View File

@ -4,551 +4,383 @@
* OpenAPI definition * OpenAPI definition
* OpenAPI spec version: v0 * 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 { import type {
DataTag, DefaultResponseDTOMangaChapterImagesDTO,
DefinedInitialDataOptions, DefaultResponseDTOVoid,
DefinedUseQueryResult, DownloadChapterArchiveParams
MutationFunction, } from '../api.schemas';
QueryClient,
QueryFunction, import { customInstance } from '../../api';
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";
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1]; type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
/** /**
* Fetch all not yet downloaded chapters from the provider * Fetch all not yet downloaded chapters from the provider
* @summary Fetch all chapters * @summary Fetch all chapters
*/ */
export const fetchAllChapters = ( export const fetchAllChapters = (
mangaProviderId: number, mangaProviderId: number,
options?: SecondParameter<typeof customInstance>, options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
signal?: AbortSignal,
) => { ) => {
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< return customInstance<DefaultResponseDTOVoid>(
Awaited<ReturnType<typeof fetchAllChapters>>, {url: `/mangas/${encodeURIComponent(String(mangaProviderId))}/fetch-all-chapters`, method: 'POST', signal
{ mangaProviderId: number } },
> = (props) => { options);
const { mangaProviderId } = props ?? {}; }
return fetchAllChapters(mangaProviderId, requestOptions);
};
return { mutationFn, ...mutationOptions };
};
export type FetchAllChaptersMutationResult = NonNullable< export const getFetchAllChaptersMutationOptions = <TError = unknown,
Awaited<ReturnType<typeof fetchAllChapters>> 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> => {
export type FetchAllChaptersMutationError = unknown; 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 ?? {};
return fetchAllChapters(mangaProviderId,requestOptions)
}
return { mutationFn, ...mutationOptions }}
export type FetchAllChaptersMutationResult = NonNullable<Awaited<ReturnType<typeof fetchAllChapters>>>
export type FetchAllChaptersMutationError = unknown
/**
* @summary Fetch all chapters * @summary Fetch all chapters
*/ */
export const useFetchAllChapters = <TError = unknown, TContext = unknown>( export const useFetchAllChapters = <TError = unknown,
options?: { TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof fetchAllChapters>>, TError,{mangaProviderId: number}, TContext>, request?: SecondParameter<typeof customInstance>}
mutation?: UseMutationOptions< , queryClient?: QueryClient): UseMutationResult<
Awaited<ReturnType<typeof fetchAllChapters>>, Awaited<ReturnType<typeof fetchAllChapters>>,
TError, TError,
{ mangaProviderId: number }, {mangaProviderId: number},
TContext TContext
>; > => {
request?: SecondParameter<typeof customInstance>;
},
queryClient?: QueryClient,
): UseMutationResult<
Awaited<ReturnType<typeof fetchAllChapters>>,
TError,
{ mangaProviderId: number },
TContext
> => {
const mutationOptions = getFetchAllChaptersMutationOptions(options);
return useMutation(mutationOptions, queryClient); const mutationOptions = getFetchAllChaptersMutationOptions(options);
};
/** return useMutation(mutationOptions, queryClient);
}
/**
* Mark a chapter as read by its ID. * Mark a chapter as read by its ID.
* @summary Mark a chapter as read * @summary Mark a chapter as read
*/ */
export const markAsRead = ( export const markAsRead = (
chapterId: number, chapterId: number,
options?: SecondParameter<typeof customInstance>, options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
signal?: AbortSignal,
) => { ) => {
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< return customInstance<DefaultResponseDTOVoid>(
Awaited<ReturnType<typeof markAsRead>>, {url: `/mangas/chapters/${encodeURIComponent(String(chapterId))}/mark-as-read`, method: 'POST', signal
{ chapterId: number } },
> = (props) => { options);
const { chapterId } = props ?? {}; }
return markAsRead(chapterId, requestOptions);
};
return { mutationFn, ...mutationOptions };
};
export type MarkAsReadMutationResult = NonNullable< export const getMarkAsReadMutationOptions = <TError = unknown,
Awaited<ReturnType<typeof markAsRead>> 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> => {
export type MarkAsReadMutationError = unknown; const mutationKey = ['markAsRead'];
const {mutation: mutationOptions, request: requestOptions} = options ?
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
options
: {...options, mutation: {...options.mutation, mutationKey}}
: {mutation: { mutationKey, }, request: undefined};
/**
const mutationFn: MutationFunction<Awaited<ReturnType<typeof markAsRead>>, {chapterId: number}> = (props) => {
const {chapterId} = props ?? {};
return markAsRead(chapterId,requestOptions)
}
return { mutationFn, ...mutationOptions }}
export type MarkAsReadMutationResult = NonNullable<Awaited<ReturnType<typeof markAsRead>>>
export type MarkAsReadMutationError = unknown
/**
* @summary Mark a chapter as read * @summary Mark a chapter as read
*/ */
export const useMarkAsRead = <TError = unknown, TContext = unknown>( export const useMarkAsRead = <TError = unknown,
options?: { TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof markAsRead>>, TError,{chapterId: number}, TContext>, request?: SecondParameter<typeof customInstance>}
mutation?: UseMutationOptions< , queryClient?: QueryClient): UseMutationResult<
Awaited<ReturnType<typeof markAsRead>>, Awaited<ReturnType<typeof markAsRead>>,
TError, TError,
{ chapterId: number }, {chapterId: number},
TContext TContext
>; > => {
request?: SecondParameter<typeof customInstance>;
},
queryClient?: QueryClient,
): UseMutationResult<
Awaited<ReturnType<typeof markAsRead>>,
TError,
{ chapterId: number },
TContext
> => {
const mutationOptions = getMarkAsReadMutationOptions(options);
return useMutation(mutationOptions, queryClient); const mutationOptions = getMarkAsReadMutationOptions(options);
};
/** return useMutation(mutationOptions, queryClient);
}
/**
* Fetch the chapter from the provider * Fetch the chapter from the provider
* @summary Fetch chapter * @summary Fetch chapter
*/ */
export const fetchChapter = ( export const fetchChapter = (
chapterId: number, chapterId: number,
options?: SecondParameter<typeof customInstance>, options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
signal?: AbortSignal,
) => { ) => {
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< return customInstance<DefaultResponseDTOVoid>(
Awaited<ReturnType<typeof fetchChapter>>, {url: `/mangas/chapters/${encodeURIComponent(String(chapterId))}/fetch`, method: 'POST', signal
{ chapterId: number } },
> = (props) => { options);
const { chapterId } = props ?? {}; }
return fetchChapter(chapterId, requestOptions);
};
return { mutationFn, ...mutationOptions };
};
export type FetchChapterMutationResult = NonNullable< export const getFetchChapterMutationOptions = <TError = unknown,
Awaited<ReturnType<typeof fetchChapter>> 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> => {
export type FetchChapterMutationError = unknown; const mutationKey = ['fetchChapter'];
const {mutation: mutationOptions, request: requestOptions} = options ?
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
options
: {...options, mutation: {...options.mutation, mutationKey}}
: {mutation: { mutationKey, }, request: undefined};
/**
const mutationFn: MutationFunction<Awaited<ReturnType<typeof fetchChapter>>, {chapterId: number}> = (props) => {
const {chapterId} = props ?? {};
return fetchChapter(chapterId,requestOptions)
}
return { mutationFn, ...mutationOptions }}
export type FetchChapterMutationResult = NonNullable<Awaited<ReturnType<typeof fetchChapter>>>
export type FetchChapterMutationError = unknown
/**
* @summary Fetch chapter * @summary Fetch chapter
*/ */
export const useFetchChapter = <TError = unknown, TContext = unknown>( export const useFetchChapter = <TError = unknown,
options?: { TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof fetchChapter>>, TError,{chapterId: number}, TContext>, request?: SecondParameter<typeof customInstance>}
mutation?: UseMutationOptions< , queryClient?: QueryClient): UseMutationResult<
Awaited<ReturnType<typeof fetchChapter>>, Awaited<ReturnType<typeof fetchChapter>>,
TError, TError,
{ chapterId: number }, {chapterId: number},
TContext TContext
>; > => {
request?: SecondParameter<typeof customInstance>;
},
queryClient?: QueryClient,
): UseMutationResult<
Awaited<ReturnType<typeof fetchChapter>>,
TError,
{ chapterId: number },
TContext
> => {
const mutationOptions = getFetchChapterMutationOptions(options);
return useMutation(mutationOptions, queryClient); const mutationOptions = getFetchChapterMutationOptions(options);
};
/** return useMutation(mutationOptions, queryClient);
}
/**
* Download a chapter as a compressed file by its ID. * Download a chapter as a compressed file by its ID.
* @summary Download chapter archive * @summary Download chapter archive
*/ */
export const downloadChapterArchive = ( export const downloadChapterArchive = (
chapterId: number, chapterId: number,
params: DownloadChapterArchiveParams, params: DownloadChapterArchiveParams,
options?: SecondParameter<typeof customInstance>, options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
signal?: AbortSignal,
) => { ) => {
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< return customInstance<Blob>(
Awaited<ReturnType<typeof downloadChapterArchive>>, {url: `/mangas/chapters/${encodeURIComponent(String(chapterId))}/download`, method: 'POST',
{ chapterId: number; params: DownloadChapterArchiveParams } params,
> = (props) => { responseType: 'blob', signal
const { chapterId, params } = props ?? {}; },
options);
}
return downloadChapterArchive(chapterId, params, requestOptions);
};
return { mutationFn, ...mutationOptions };
};
export type DownloadChapterArchiveMutationResult = NonNullable< export const getDownloadChapterArchiveMutationOptions = <TError = unknown,
Awaited<ReturnType<typeof downloadChapterArchive>> 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> => {
export type DownloadChapterArchiveMutationError = unknown; const mutationKey = ['downloadChapterArchive'];
const {mutation: mutationOptions, request: requestOptions} = options ?
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
options
: {...options, mutation: {...options.mutation, mutationKey}}
: {mutation: { mutationKey, }, request: undefined};
/**
const mutationFn: MutationFunction<Awaited<ReturnType<typeof downloadChapterArchive>>, {chapterId: number;params: DownloadChapterArchiveParams}> = (props) => {
const {chapterId,params} = props ?? {};
return downloadChapterArchive(chapterId,params,requestOptions)
}
return { mutationFn, ...mutationOptions }}
export type DownloadChapterArchiveMutationResult = NonNullable<Awaited<ReturnType<typeof downloadChapterArchive>>>
export type DownloadChapterArchiveMutationError = unknown
/**
* @summary Download chapter archive * @summary Download chapter archive
*/ */
export const useDownloadChapterArchive = <TError = unknown, TContext = unknown>( export const useDownloadChapterArchive = <TError = unknown,
options?: { TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof downloadChapterArchive>>, TError,{chapterId: number;params: DownloadChapterArchiveParams}, TContext>, request?: SecondParameter<typeof customInstance>}
mutation?: UseMutationOptions< , queryClient?: QueryClient): UseMutationResult<
Awaited<ReturnType<typeof downloadChapterArchive>>, Awaited<ReturnType<typeof downloadChapterArchive>>,
TError, TError,
{ chapterId: number; params: DownloadChapterArchiveParams }, {chapterId: number;params: DownloadChapterArchiveParams},
TContext TContext
>; > => {
request?: SecondParameter<typeof customInstance>;
},
queryClient?: QueryClient,
): UseMutationResult<
Awaited<ReturnType<typeof downloadChapterArchive>>,
TError,
{ chapterId: number; params: DownloadChapterArchiveParams },
TContext
> => {
const mutationOptions = getDownloadChapterArchiveMutationOptions(options);
return useMutation(mutationOptions, queryClient); const mutationOptions = getDownloadChapterArchiveMutationOptions(options);
};
/** return useMutation(mutationOptions, queryClient);
}
/**
* Retrieve a list of manga chapter images for a specific manga/provider combination. * Retrieve a list of manga chapter images for a specific manga/provider combination.
* @summary Get the images for a specific manga/provider combination * @summary Get the images for a specific manga/provider combination
*/ */
export const getMangaChapterImages = ( export const getMangaChapterImages = (
chapterId: number, chapterId: number,
options?: SecondParameter<typeof customInstance>, options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
signal?: AbortSignal,
) => { ) => {
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 = < return customInstance<DefaultResponseDTOMangaChapterImagesDTO>(
TData = Awaited<ReturnType<typeof getMangaChapterImages>>, {url: `/mangas/chapters/${encodeURIComponent(String(chapterId))}/images`, method: 'GET', signal
TError = unknown, },
>( options);
chapterId: number, }
options?: {
query?: Partial<
UseQueryOptions<
Awaited<ReturnType<typeof getMangaChapterImages>>,
TError, export const getGetMangaChapterImagesQueryKey = (chapterId?: number,) => {
TData return [
> `/mangas/chapters/${chapterId}/images`
>; ] as const;
request?: SecondParameter<typeof customInstance>; }
},
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 = const {query: queryOptions, request: requestOptions} = options ?? {};
queryOptions?.queryKey ?? getGetMangaChapterImagesQueryKey(chapterId);
const queryFn: QueryFunction< const queryKey = queryOptions?.queryKey ?? getGetMangaChapterImagesQueryKey(chapterId);
Awaited<ReturnType<typeof getMangaChapterImages>>
> = ({ signal }) => getMangaChapterImages(chapterId, requestOptions, signal);
return {
queryKey,
queryFn,
enabled: !!chapterId,
...queryOptions,
} as UseQueryOptions<
Awaited<ReturnType<typeof getMangaChapterImages>>,
TError,
TData
> & { queryKey: DataTag<QueryKey, TData, TError> };
};
export type GetMangaChapterImagesQueryResult = NonNullable<
Awaited<ReturnType<typeof getMangaChapterImages>>
>;
export type GetMangaChapterImagesQueryError = unknown;
export function useGetMangaChapterImages< const queryFn: QueryFunction<Awaited<ReturnType<typeof getMangaChapterImages>>> = ({ signal }) => getMangaChapterImages(chapterId, requestOptions, signal);
TData = Awaited<ReturnType<typeof getMangaChapterImages>>,
TError = unknown,
>(
chapterId: number,
options: {
query: Partial< return { queryKey, queryFn, enabled: !!(chapterId), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getMangaChapterImages>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
UseQueryOptions< }
Awaited<ReturnType<typeof getMangaChapterImages>>,
TError, export type GetMangaChapterImagesQueryResult = NonNullable<Awaited<ReturnType<typeof getMangaChapterImages>>>
TData export type GetMangaChapterImagesQueryError = unknown
>
> &
Pick< export function useGetMangaChapterImages<TData = Awaited<ReturnType<typeof getMangaChapterImages>>, TError = unknown>(
DefinedInitialDataOptions< chapterId: number, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMangaChapterImages>>, TError, TData>> & Pick<
Awaited<ReturnType<typeof getMangaChapterImages>>, DefinedInitialDataOptions<
TError, Awaited<ReturnType<typeof getMangaChapterImages>>,
Awaited<ReturnType<typeof getMangaChapterImages>> TError,
>, Awaited<ReturnType<typeof getMangaChapterImages>>
"initialData" > , 'initialData'
>; >, request?: SecondParameter<typeof customInstance>}
request?: SecondParameter<typeof customInstance>; , queryClient?: QueryClient
}, ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
queryClient?: QueryClient, export function useGetMangaChapterImages<TData = Awaited<ReturnType<typeof getMangaChapterImages>>, TError = unknown>(
): DefinedUseQueryResult<TData, TError> & { chapterId: number, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMangaChapterImages>>, TError, TData>> & Pick<
queryKey: DataTag<QueryKey, TData, TError>; UndefinedInitialDataOptions<
}; Awaited<ReturnType<typeof getMangaChapterImages>>,
export function useGetMangaChapterImages< TError,
TData = Awaited<ReturnType<typeof getMangaChapterImages>>, Awaited<ReturnType<typeof getMangaChapterImages>>
TError = unknown, > , 'initialData'
>( >, request?: SecondParameter<typeof customInstance>}
chapterId: number, , queryClient?: QueryClient
options?: { ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
query?: Partial< export function useGetMangaChapterImages<TData = Awaited<ReturnType<typeof getMangaChapterImages>>, TError = unknown>(
UseQueryOptions< chapterId: number, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMangaChapterImages>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
Awaited<ReturnType<typeof getMangaChapterImages>>, , queryClient?: QueryClient
TError, ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, 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 * @summary Get the images for a specific manga/provider combination
*/ */
export function useGetMangaChapterImages< export function useGetMangaChapterImages<TData = Awaited<ReturnType<typeof getMangaChapterImages>>, TError = unknown>(
TData = Awaited<ReturnType<typeof getMangaChapterImages>>, chapterId: number, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMangaChapterImages>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
TError = unknown, , queryClient?: QueryClient
>( ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
chapterId: number,
options?: {
query?: Partial<
UseQueryOptions<
Awaited<ReturnType<typeof getMangaChapterImages>>,
TError,
TData
>
>;
request?: SecondParameter<typeof customInstance>;
},
queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
queryKey: DataTag<QueryKey, TData, TError>;
} {
const queryOptions = getGetMangaChapterImagesQueryOptions(chapterId, options);
const query = useQuery(queryOptions, queryClient) as UseQueryResult< const queryOptions = getGetMangaChapterImagesQueryOptions(chapterId,options)
TData,
TError
> & { queryKey: DataTag<QueryKey, TData, TError> };
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;
} }

View File

@ -4,347 +4,255 @@
* OpenAPI definition * OpenAPI definition
* OpenAPI spec version: v0 * 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 { import type {
DataTag, DefaultResponseDTOListImportReviewDTO,
DefinedInitialDataOptions, DefaultResponseDTOVoid,
DefinedUseQueryResult, ResolveImportReviewParams
MutationFunction, } from '../api.schemas';
QueryClient,
QueryFunction, import { customInstance } from '../../api';
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";
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1]; type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
/** /**
* Get list of pending import reviews. * Get list of pending import reviews.
* @summary Get list of pending import reviews * @summary Get list of pending import reviews
*/ */
export const getImportReviews = ( 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 = () => { 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 ?? {};
const queryKey = queryOptions?.queryKey ?? getGetImportReviewsQueryKey(); 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 queryFn: QueryFunction< const {query: queryOptions, request: requestOptions} = options ?? {};
Awaited<ReturnType<typeof getImportReviews>>
> = ({ signal }) => getImportReviews(requestOptions, signal);
return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< const queryKey = queryOptions?.queryKey ?? getGetImportReviewsQueryKey();
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>>, const queryFn: QueryFunction<Awaited<ReturnType<typeof getImportReviews>>> = ({ signal }) => getImportReviews(requestOptions, signal);
TError = unknown,
>(
options: {
query: Partial<
UseQueryOptions<
Awaited<ReturnType<typeof getImportReviews>>, return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getImportReviews>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
TError, }
TData
> export type GetImportReviewsQueryResult = NonNullable<Awaited<ReturnType<typeof getImportReviews>>>
> & export type GetImportReviewsQueryError = unknown
Pick<
DefinedInitialDataOptions<
Awaited<ReturnType<typeof getImportReviews>>, export function useGetImportReviews<TData = Awaited<ReturnType<typeof getImportReviews>>, TError = unknown>(
TError, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getImportReviews>>, TError, TData>> & Pick<
Awaited<ReturnType<typeof getImportReviews>> DefinedInitialDataOptions<
>, Awaited<ReturnType<typeof getImportReviews>>,
"initialData" TError,
>; Awaited<ReturnType<typeof getImportReviews>>
request?: SecondParameter<typeof customInstance>; > , 'initialData'
}, >, request?: SecondParameter<typeof customInstance>}
queryClient?: QueryClient, , queryClient?: QueryClient
): DefinedUseQueryResult<TData, TError> & { ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, 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<
export function useGetImportReviews< UndefinedInitialDataOptions<
TData = Awaited<ReturnType<typeof getImportReviews>>, Awaited<ReturnType<typeof getImportReviews>>,
TError = unknown, TError,
>( Awaited<ReturnType<typeof getImportReviews>>
options?: { > , 'initialData'
query?: Partial< >, request?: SecondParameter<typeof customInstance>}
UseQueryOptions< , queryClient?: QueryClient
Awaited<ReturnType<typeof getImportReviews>>, ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
TError, export function useGetImportReviews<TData = Awaited<ReturnType<typeof getImportReviews>>, TError = unknown>(
TData options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getImportReviews>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
> , queryClient?: QueryClient
> & ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
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 * @summary Get list of pending import reviews
*/ */
export function useGetImportReviews< export function useGetImportReviews<TData = Awaited<ReturnType<typeof getImportReviews>>, TError = unknown>(
TData = Awaited<ReturnType<typeof getImportReviews>>, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getImportReviews>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
TError = unknown, , queryClient?: QueryClient
>( ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
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);
const query = useQuery(queryOptions, queryClient) as UseQueryResult< const queryOptions = getGetImportReviewsQueryOptions(options)
TData,
TError
> & { queryKey: DataTag<QueryKey, TData, TError> };
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. * Resolve import review by ID.
* @summary Resolve import review * @summary Resolve import review
*/ */
export const resolveImportReview = ( export const resolveImportReview = (
params: ResolveImportReviewParams, params: ResolveImportReviewParams,
options?: SecondParameter<typeof customInstance>, options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
signal?: AbortSignal,
) => { ) => {
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< return customInstance<DefaultResponseDTOVoid>(
Awaited<ReturnType<typeof resolveImportReview>>, {url: `/manga/import/review`, method: 'POST',
{ params: ResolveImportReviewParams } params, signal
> = (props) => { },
const { params } = props ?? {}; options);
}
return resolveImportReview(params, requestOptions);
};
return { mutationFn, ...mutationOptions };
};
export type ResolveImportReviewMutationResult = NonNullable< export const getResolveImportReviewMutationOptions = <TError = unknown,
Awaited<ReturnType<typeof resolveImportReview>> 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> => {
export type ResolveImportReviewMutationError = unknown; 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 ?? {};
return resolveImportReview(params,requestOptions)
}
return { mutationFn, ...mutationOptions }}
export type ResolveImportReviewMutationResult = NonNullable<Awaited<ReturnType<typeof resolveImportReview>>>
export type ResolveImportReviewMutationError = unknown
/**
* @summary Resolve import review * @summary Resolve import review
*/ */
export const useResolveImportReview = <TError = unknown, TContext = unknown>( export const useResolveImportReview = <TError = unknown,
options?: { TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof resolveImportReview>>, TError,{params: ResolveImportReviewParams}, TContext>, request?: SecondParameter<typeof customInstance>}
mutation?: UseMutationOptions< , queryClient?: QueryClient): UseMutationResult<
Awaited<ReturnType<typeof resolveImportReview>>, Awaited<ReturnType<typeof resolveImportReview>>,
TError, TError,
{ params: ResolveImportReviewParams }, {params: ResolveImportReviewParams},
TContext TContext
>; > => {
request?: SecondParameter<typeof customInstance>;
},
queryClient?: QueryClient,
): UseMutationResult<
Awaited<ReturnType<typeof resolveImportReview>>,
TError,
{ params: ResolveImportReviewParams },
TContext
> => {
const mutationOptions = getResolveImportReviewMutationOptions(options);
return useMutation(mutationOptions, queryClient); const mutationOptions = getResolveImportReviewMutationOptions(options);
};
/** return useMutation(mutationOptions, queryClient);
}
/**
* Delete pending import review by ID. * Delete pending import review by ID.
* @summary Delete pending import review * @summary Delete pending import review
*/ */
export const deleteImportReview = ( export const deleteImportReview = (
id: number, id: number,
options?: SecondParameter<typeof customInstance>, 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< return customInstance<DefaultResponseDTOVoid>(
Awaited<ReturnType<typeof deleteImportReview>>, {url: `/manga/import/review/${encodeURIComponent(String(id))}`, method: 'DELETE'
{ id: number } },
> = (props) => { options);
const { id } = props ?? {}; }
return deleteImportReview(id, requestOptions);
};
return { mutationFn, ...mutationOptions };
};
export type DeleteImportReviewMutationResult = NonNullable< export const getDeleteImportReviewMutationOptions = <TError = unknown,
Awaited<ReturnType<typeof deleteImportReview>> 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> => {
export type DeleteImportReviewMutationError = unknown; 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 ?? {};
return deleteImportReview(id,requestOptions)
}
return { mutationFn, ...mutationOptions }}
export type DeleteImportReviewMutationResult = NonNullable<Awaited<ReturnType<typeof deleteImportReview>>>
export type DeleteImportReviewMutationError = unknown
/**
* @summary Delete pending import review * @summary Delete pending import review
*/ */
export const useDeleteImportReview = <TError = unknown, TContext = unknown>( export const useDeleteImportReview = <TError = unknown,
options?: { TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteImportReview>>, TError,{id: number}, TContext>, request?: SecondParameter<typeof customInstance>}
mutation?: UseMutationOptions< , queryClient?: QueryClient): UseMutationResult<
Awaited<ReturnType<typeof deleteImportReview>>, Awaited<ReturnType<typeof deleteImportReview>>,
TError, TError,
{ id: number }, {id: number},
TContext TContext
>; > => {
request?: SecondParameter<typeof customInstance>;
}, const mutationOptions = getDeleteImportReviewMutationOptions(options);
queryClient?: QueryClient,
): UseMutationResult< return useMutation(mutationOptions, queryClient);
Awaited<ReturnType<typeof deleteImportReview>>, }
TError,
{ id: number },
TContext
> => {
const mutationOptions = getDeleteImportReviewMutationOptions(options);
return useMutation(mutationOptions, queryClient);
};

View File

@ -4,205 +4,161 @@
* OpenAPI definition * OpenAPI definition
* OpenAPI spec version: v0 * OpenAPI spec version: v0
*/ */
import {
useMutation
} from '@tanstack/react-query';
import type {
MutationFunction,
QueryClient,
UseMutationOptions,
UseMutationResult
} from '@tanstack/react-query';
import type { import type {
MutationFunction, DefaultResponseDTOImportMangaDexResponseDTO,
QueryClient, DefaultResponseDTOVoid,
UseMutationOptions, ImportMangaDexRequestDTO,
UseMutationResult, ImportMultipleFilesBody
} from "@tanstack/react-query"; } from '../api.schemas';
import { useMutation } from "@tanstack/react-query";
import { customInstance } from "../../api"; import { customInstance } from '../../api';
import type {
DefaultResponseDTOImportMangaDexResponseDTO,
DefaultResponseDTOVoid,
ImportMangaDexRequestDTO,
ImportMultipleFilesBody,
} from "../api.schemas";
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1]; type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
/** /**
* Accepts multiple files via multipart/form-data and processes them. * Accepts multiple files via multipart/form-data and processes them.
* @summary Upload multiple files * @summary Upload multiple files
*/ */
export const importMultipleFiles = ( export const importMultipleFiles = (
importMultipleFilesBody: ImportMultipleFilesBody, importMultipleFilesBody: ImportMultipleFilesBody,
options?: SecondParameter<typeof customInstance>, options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
signal?: AbortSignal,
) => { ) => {
const formData = new FormData();
formData.append(`malId`, importMultipleFilesBody.malId);
importMultipleFilesBody.files.forEach((value) =>
formData.append(`files`, value),
);
return customInstance<DefaultResponseDTOVoid>( const formData = new FormData();
{ formData.append(`malId`, importMultipleFilesBody.malId)
url: `/manga/import/upload`, importMultipleFilesBody.files.forEach(value => formData.append(`files`, value));
method: "POST",
headers: { "Content-Type": "multipart/form-data" },
data: formData,
signal,
},
options,
);
};
export const getImportMultipleFilesMutationOptions = < return customInstance<DefaultResponseDTOVoid>(
TError = unknown, {url: `/manga/import/upload`, method: 'POST',
TContext = unknown, headers: {'Content-Type': 'multipart/form-data', },
>(options?: { data: formData, signal
mutation?: UseMutationOptions< },
Awaited<ReturnType<typeof importMultipleFiles>>, options);
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 ?? {};
return importMultipleFiles(data, requestOptions);
};
return { mutationFn, ...mutationOptions }; 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> => {
export type ImportMultipleFilesMutationResult = NonNullable< const mutationKey = ['importMultipleFiles'];
Awaited<ReturnType<typeof importMultipleFiles>> const {mutation: mutationOptions, request: requestOptions} = options ?
>; options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
export type ImportMultipleFilesMutationBody = ImportMultipleFilesBody; options
export type ImportMultipleFilesMutationError = unknown; : {...options, mutation: {...options.mutation, mutationKey}}
: {mutation: { mutationKey, }, request: undefined};
/**
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 * @summary Upload multiple files
*/ */
export const useImportMultipleFiles = <TError = unknown, TContext = unknown>( export const useImportMultipleFiles = <TError = unknown,
options?: { TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof importMultipleFiles>>, TError,{data: ImportMultipleFilesBody}, TContext>, request?: SecondParameter<typeof customInstance>}
mutation?: UseMutationOptions< , queryClient?: QueryClient): UseMutationResult<
Awaited<ReturnType<typeof importMultipleFiles>>, Awaited<ReturnType<typeof importMultipleFiles>>,
TError, TError,
{ data: ImportMultipleFilesBody }, {data: ImportMultipleFilesBody},
TContext TContext
>; > => {
request?: SecondParameter<typeof customInstance>;
},
queryClient?: QueryClient,
): UseMutationResult<
Awaited<ReturnType<typeof importMultipleFiles>>,
TError,
{ data: ImportMultipleFilesBody },
TContext
> => {
const mutationOptions = getImportMultipleFilesMutationOptions(options);
return useMutation(mutationOptions, queryClient); const mutationOptions = getImportMultipleFilesMutationOptions(options);
};
/** return useMutation(mutationOptions, queryClient);
}
/**
* Imports manga data from MangaDex into the local database. * Imports manga data from MangaDex into the local database.
* @summary Import manga from MangaDex * @summary Import manga from MangaDex
*/ */
export const importFromMangaDex = ( export const importFromMangaDex = (
importMangaDexRequestDTO: ImportMangaDexRequestDTO, importMangaDexRequestDTO: ImportMangaDexRequestDTO,
options?: SecondParameter<typeof customInstance>, options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
signal?: AbortSignal,
) => { ) => {
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< return customInstance<DefaultResponseDTOImportMangaDexResponseDTO>(
Awaited<ReturnType<typeof importFromMangaDex>>, {url: `/manga/import/manga-dex`, method: 'POST',
{ data: ImportMangaDexRequestDTO } headers: {'Content-Type': 'application/json', },
> = (props) => { data: importMangaDexRequestDTO, signal
const { data } = props ?? {}; },
options);
}
return importFromMangaDex(data, requestOptions);
};
return { mutationFn, ...mutationOptions };
};
export type ImportFromMangaDexMutationResult = NonNullable< export const getImportFromMangaDexMutationOptions = <TError = unknown,
Awaited<ReturnType<typeof importFromMangaDex>> 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> => {
export type ImportFromMangaDexMutationBody = ImportMangaDexRequestDTO;
export type ImportFromMangaDexMutationError = unknown;
/** 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 ?? {};
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 * @summary Import manga from MangaDex
*/ */
export const useImportFromMangaDex = <TError = unknown, TContext = unknown>( export const useImportFromMangaDex = <TError = unknown,
options?: { TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof importFromMangaDex>>, TError,{data: ImportMangaDexRequestDTO}, TContext>, request?: SecondParameter<typeof customInstance>}
mutation?: UseMutationOptions< , queryClient?: QueryClient): UseMutationResult<
Awaited<ReturnType<typeof importFromMangaDex>>, Awaited<ReturnType<typeof importFromMangaDex>>,
TError, TError,
{ data: ImportMangaDexRequestDTO }, {data: ImportMangaDexRequestDTO},
TContext TContext
>; > => {
request?: SecondParameter<typeof customInstance>;
}, const mutationOptions = getImportFromMangaDexMutationOptions(options);
queryClient?: QueryClient,
): UseMutationResult< return useMutation(mutationOptions, queryClient);
Awaited<ReturnType<typeof importFromMangaDex>>, }
TError,
{ data: ImportMangaDexRequestDTO },
TContext
> => {
const mutationOptions = getImportFromMangaDexMutationOptions(options);
return useMutation(mutationOptions, queryClient);
};

View File

@ -4,585 +4,380 @@
* OpenAPI definition * OpenAPI definition
* OpenAPI spec version: v0 * 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 { import type {
DataTag, DefaultResponseDTOListMangaChapterDTO,
DefinedInitialDataOptions, DefaultResponseDTOMangaDTO,
DefinedUseQueryResult, DefaultResponseDTOPageMangaListDTO,
MutationFunction, DefaultResponseDTOVoid,
QueryClient, GetMangasParams
QueryFunction, } from '../api.schemas';
QueryKey,
UndefinedInitialDataOptions, import { customInstance } from '../../api';
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";
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1]; type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
/** /**
* Fetch a list of manga chapters for a specific manga/provider combination. * Fetch a list of manga chapters for a specific manga/provider combination.
* @summary Fetch the available chapters for a specific manga/provider combination * @summary Fetch the available chapters for a specific manga/provider combination
*/ */
export const fetchMangaChapters = ( export const fetchMangaChapters = (
mangaProviderId: number, mangaProviderId: number,
options?: SecondParameter<typeof customInstance>, options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
signal?: AbortSignal,
) => { ) => {
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< return customInstance<DefaultResponseDTOVoid>(
Awaited<ReturnType<typeof fetchMangaChapters>>, {url: `/mangas/${encodeURIComponent(String(mangaProviderId))}/fetch-chapters`, method: 'POST', signal
{ mangaProviderId: number } },
> = (props) => { options);
const { mangaProviderId } = props ?? {}; }
return fetchMangaChapters(mangaProviderId, requestOptions);
};
return { mutationFn, ...mutationOptions };
};
export type FetchMangaChaptersMutationResult = NonNullable< export const getFetchMangaChaptersMutationOptions = <TError = unknown,
Awaited<ReturnType<typeof fetchMangaChapters>> 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> => {
export type FetchMangaChaptersMutationError = unknown; const mutationKey = ['fetchMangaChapters'];
const {mutation: mutationOptions, request: requestOptions} = options ?
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
options
: {...options, mutation: {...options.mutation, mutationKey}}
: {mutation: { mutationKey, }, request: undefined};
/**
const mutationFn: MutationFunction<Awaited<ReturnType<typeof fetchMangaChapters>>, {mangaProviderId: number}> = (props) => {
const {mangaProviderId} = props ?? {};
return fetchMangaChapters(mangaProviderId,requestOptions)
}
return { mutationFn, ...mutationOptions }}
export type FetchMangaChaptersMutationResult = NonNullable<Awaited<ReturnType<typeof fetchMangaChapters>>>
export type FetchMangaChaptersMutationError = unknown
/**
* @summary Fetch the available chapters for a specific manga/provider combination * @summary Fetch the available chapters for a specific manga/provider combination
*/ */
export const useFetchMangaChapters = <TError = unknown, TContext = unknown>( export const useFetchMangaChapters = <TError = unknown,
options?: { TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof fetchMangaChapters>>, TError,{mangaProviderId: number}, TContext>, request?: SecondParameter<typeof customInstance>}
mutation?: UseMutationOptions< , queryClient?: QueryClient): UseMutationResult<
Awaited<ReturnType<typeof fetchMangaChapters>>, Awaited<ReturnType<typeof fetchMangaChapters>>,
TError, TError,
{ mangaProviderId: number }, {mangaProviderId: number},
TContext TContext
>; > => {
request?: SecondParameter<typeof customInstance>;
},
queryClient?: QueryClient,
): UseMutationResult<
Awaited<ReturnType<typeof fetchMangaChapters>>,
TError,
{ mangaProviderId: number },
TContext
> => {
const mutationOptions = getFetchMangaChaptersMutationOptions(options);
return useMutation(mutationOptions, queryClient); const mutationOptions = getFetchMangaChaptersMutationOptions(options);
};
/** return useMutation(mutationOptions, queryClient);
}
/**
* Retrieve a list of mangas with their details. * Retrieve a list of mangas with their details.
* @summary Get a list of mangas * @summary Get a list of mangas
*/ */
export const getMangas = ( export const getMangas = (
params?: GetMangasParams, params?: GetMangasParams,
options?: SecondParameter<typeof customInstance>, options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
signal?: AbortSignal,
) => { ) => {
return customInstance<DefaultResponseDTOPageMangaListDTO>(
{ url: `/mangas`, method: "GET", params, signal },
options,
);
};
export const getGetMangasQueryKey = (params?: GetMangasParams) => {
return [`/mangas`, ...(params ? [params] : [])] as const;
};
export const getGetMangasQueryOptions = < return customInstance<DefaultResponseDTOPageMangaListDTO>(
TData = Awaited<ReturnType<typeof getMangas>>, {url: `/mangas`, method: 'GET',
TError = unknown, params, signal
>( },
params?: GetMangasParams, options);
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>>> = ({ const queryKey = queryOptions?.queryKey ?? getGetMangasQueryKey(params);
signal,
}) => getMangas(params, requestOptions, signal);
return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
Awaited<ReturnType<typeof getMangas>>,
TError,
TData
> & { queryKey: DataTag<QueryKey, TData, TError> };
};
export type GetMangasQueryResult = NonNullable<
Awaited<ReturnType<typeof getMangas>>
>;
export type GetMangasQueryError = unknown;
export function useGetMangas< const queryFn: QueryFunction<Awaited<ReturnType<typeof getMangas>>> = ({ signal }) => getMangas(params, requestOptions, signal);
TData = Awaited<ReturnType<typeof getMangas>>,
TError = unknown,
>(
params: undefined | GetMangasParams,
options: {
query: Partial< return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getMangas>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
UseQueryOptions<Awaited<ReturnType<typeof getMangas>>, TError, TData> }
> &
Pick< export type GetMangasQueryResult = NonNullable<Awaited<ReturnType<typeof getMangas>>>
DefinedInitialDataOptions< export type GetMangasQueryError = unknown
Awaited<ReturnType<typeof getMangas>>,
TError,
Awaited<ReturnType<typeof getMangas>> export function useGetMangas<TData = Awaited<ReturnType<typeof getMangas>>, TError = unknown>(
>, params: undefined | GetMangasParams, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMangas>>, TError, TData>> & Pick<
"initialData" DefinedInitialDataOptions<
>; Awaited<ReturnType<typeof getMangas>>,
request?: SecondParameter<typeof customInstance>; TError,
}, Awaited<ReturnType<typeof getMangas>>
queryClient?: QueryClient, > , 'initialData'
): DefinedUseQueryResult<TData, TError> & { >, request?: SecondParameter<typeof customInstance>}
queryKey: DataTag<QueryKey, TData, TError>; , queryClient?: QueryClient
}; ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetMangas< export function useGetMangas<TData = Awaited<ReturnType<typeof getMangas>>, TError = unknown>(
TData = Awaited<ReturnType<typeof getMangas>>, params?: GetMangasParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMangas>>, TError, TData>> & Pick<
TError = unknown, UndefinedInitialDataOptions<
>( Awaited<ReturnType<typeof getMangas>>,
params?: GetMangasParams, TError,
options?: { Awaited<ReturnType<typeof getMangas>>
query?: Partial< > , 'initialData'
UseQueryOptions<Awaited<ReturnType<typeof getMangas>>, TError, TData> >, request?: SecondParameter<typeof customInstance>}
> & , queryClient?: QueryClient
Pick< ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
UndefinedInitialDataOptions< export function useGetMangas<TData = Awaited<ReturnType<typeof getMangas>>, TError = unknown>(
Awaited<ReturnType<typeof getMangas>>, params?: GetMangasParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMangas>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
TError, , queryClient?: QueryClient
Awaited<ReturnType<typeof getMangas>> ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
>,
"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 * @summary Get a list of mangas
*/ */
export function useGetMangas< export function useGetMangas<TData = Awaited<ReturnType<typeof getMangas>>, TError = unknown>(
TData = Awaited<ReturnType<typeof getMangas>>, params?: GetMangasParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMangas>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
TError = unknown, , queryClient?: QueryClient
>( ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
params?: GetMangasParams,
options?: {
query?: Partial<
UseQueryOptions<Awaited<ReturnType<typeof getMangas>>, TError, TData>
>;
request?: SecondParameter<typeof customInstance>;
},
queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
queryKey: DataTag<QueryKey, TData, TError>;
} {
const queryOptions = getGetMangasQueryOptions(params, options);
const query = useQuery(queryOptions, queryClient) as UseQueryResult< const queryOptions = getGetMangasQueryOptions(params,options)
TData,
TError
> & { queryKey: DataTag<QueryKey, TData, TError> };
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. * Retrieve a list of manga chapters for a specific manga/provider combination.
* @summary Get the available chapters for a specific manga/provider combination * @summary Get the available chapters for a specific manga/provider combination
*/ */
export const getMangaChapters = ( export const getMangaChapters = (
mangaProviderId: number, mangaProviderId: number,
options?: SecondParameter<typeof customInstance>, options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
signal?: AbortSignal,
) => { ) => {
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 = < return customInstance<DefaultResponseDTOListMangaChapterDTO>(
TData = Awaited<ReturnType<typeof getMangaChapters>>, {url: `/mangas/${encodeURIComponent(String(mangaProviderId))}/chapters`, method: 'GET', signal
TError = unknown, },
>( options);
mangaProviderId: number, }
options?: {
query?: Partial<
UseQueryOptions<
Awaited<ReturnType<typeof getMangaChapters>>,
TError, export const getGetMangaChaptersQueryKey = (mangaProviderId?: number,) => {
TData return [
> `/mangas/${mangaProviderId}/chapters`
>; ] as const;
request?: SecondParameter<typeof customInstance>; }
},
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 = const {query: queryOptions, request: requestOptions} = options ?? {};
queryOptions?.queryKey ?? getGetMangaChaptersQueryKey(mangaProviderId);
const queryFn: QueryFunction< const queryKey = queryOptions?.queryKey ?? getGetMangaChaptersQueryKey(mangaProviderId);
Awaited<ReturnType<typeof getMangaChapters>>
> = ({ signal }) => getMangaChapters(mangaProviderId, requestOptions, signal);
return {
queryKey,
queryFn,
enabled: !!mangaProviderId,
...queryOptions,
} as UseQueryOptions<
Awaited<ReturnType<typeof getMangaChapters>>,
TError,
TData
> & { queryKey: DataTag<QueryKey, TData, TError> };
};
export type GetMangaChaptersQueryResult = NonNullable<
Awaited<ReturnType<typeof getMangaChapters>>
>;
export type GetMangaChaptersQueryError = unknown;
export function useGetMangaChapters< const queryFn: QueryFunction<Awaited<ReturnType<typeof getMangaChapters>>> = ({ signal }) => getMangaChapters(mangaProviderId, requestOptions, signal);
TData = Awaited<ReturnType<typeof getMangaChapters>>,
TError = unknown,
>(
mangaProviderId: number,
options: {
query: Partial< return { queryKey, queryFn, enabled: !!(mangaProviderId), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getMangaChapters>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
UseQueryOptions< }
Awaited<ReturnType<typeof getMangaChapters>>,
TError, export type GetMangaChaptersQueryResult = NonNullable<Awaited<ReturnType<typeof getMangaChapters>>>
TData export type GetMangaChaptersQueryError = unknown
>
> &
Pick< export function useGetMangaChapters<TData = Awaited<ReturnType<typeof getMangaChapters>>, TError = unknown>(
DefinedInitialDataOptions< mangaProviderId: number, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMangaChapters>>, TError, TData>> & Pick<
Awaited<ReturnType<typeof getMangaChapters>>, DefinedInitialDataOptions<
TError, Awaited<ReturnType<typeof getMangaChapters>>,
Awaited<ReturnType<typeof getMangaChapters>> TError,
>, Awaited<ReturnType<typeof getMangaChapters>>
"initialData" > , 'initialData'
>; >, request?: SecondParameter<typeof customInstance>}
request?: SecondParameter<typeof customInstance>; , queryClient?: QueryClient
}, ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
queryClient?: QueryClient, export function useGetMangaChapters<TData = Awaited<ReturnType<typeof getMangaChapters>>, TError = unknown>(
): DefinedUseQueryResult<TData, TError> & { mangaProviderId: number, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMangaChapters>>, TError, TData>> & Pick<
queryKey: DataTag<QueryKey, TData, TError>; UndefinedInitialDataOptions<
}; Awaited<ReturnType<typeof getMangaChapters>>,
export function useGetMangaChapters< TError,
TData = Awaited<ReturnType<typeof getMangaChapters>>, Awaited<ReturnType<typeof getMangaChapters>>
TError = unknown, > , 'initialData'
>( >, request?: SecondParameter<typeof customInstance>}
mangaProviderId: number, , queryClient?: QueryClient
options?: { ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
query?: Partial< export function useGetMangaChapters<TData = Awaited<ReturnType<typeof getMangaChapters>>, TError = unknown>(
UseQueryOptions< mangaProviderId: number, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMangaChapters>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
Awaited<ReturnType<typeof getMangaChapters>>, , queryClient?: QueryClient
TError, ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, 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 * @summary Get the available chapters for a specific manga/provider combination
*/ */
export function useGetMangaChapters< export function useGetMangaChapters<TData = Awaited<ReturnType<typeof getMangaChapters>>, TError = unknown>(
TData = Awaited<ReturnType<typeof getMangaChapters>>, mangaProviderId: number, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMangaChapters>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
TError = unknown, , queryClient?: QueryClient
>( ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
mangaProviderId: number,
options?: {
query?: Partial<
UseQueryOptions<
Awaited<ReturnType<typeof getMangaChapters>>,
TError,
TData
>
>;
request?: SecondParameter<typeof customInstance>;
},
queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
queryKey: DataTag<QueryKey, TData, TError>;
} {
const queryOptions = getGetMangaChaptersQueryOptions(
mangaProviderId,
options,
);
const query = useQuery(queryOptions, queryClient) as UseQueryResult< const queryOptions = getGetMangaChaptersQueryOptions(mangaProviderId,options)
TData,
TError
> & { queryKey: DataTag<QueryKey, TData, TError> };
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 * Get the details of a manga by its ID
* @summary Get the details of a manga * @summary Get the details of a manga
*/ */
export const getManga = ( export const getManga = (
mangaId: number, mangaId: number,
options?: SecondParameter<typeof customInstance>, options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
signal?: AbortSignal,
) => { ) => {
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 = < return customInstance<DefaultResponseDTOMangaDTO>(
TData = Awaited<ReturnType<typeof getManga>>, {url: `/mangas/${encodeURIComponent(String(mangaId))}`, method: 'GET', signal
TError = unknown, },
>( options);
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>>> = ({ const queryKey = queryOptions?.queryKey ?? getGetMangaQueryKey(mangaId);
signal,
}) => getManga(mangaId, requestOptions, signal);
return {
queryKey,
queryFn,
enabled: !!mangaId,
...queryOptions,
} as UseQueryOptions<Awaited<ReturnType<typeof getManga>>, TError, TData> & {
queryKey: DataTag<QueryKey, TData, TError>;
};
};
export type GetMangaQueryResult = NonNullable<
Awaited<ReturnType<typeof getManga>>
>;
export type GetMangaQueryError = unknown;
export function useGetManga< const queryFn: QueryFunction<Awaited<ReturnType<typeof getManga>>> = ({ signal }) => getManga(mangaId, requestOptions, signal);
TData = Awaited<ReturnType<typeof getManga>>,
TError = unknown,
>(
mangaId: number,
options: {
query: Partial< return { queryKey, queryFn, enabled: !!(mangaId), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getManga>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
UseQueryOptions<Awaited<ReturnType<typeof getManga>>, TError, TData> }
> &
Pick< export type GetMangaQueryResult = NonNullable<Awaited<ReturnType<typeof getManga>>>
DefinedInitialDataOptions< export type GetMangaQueryError = unknown
Awaited<ReturnType<typeof getManga>>,
TError,
Awaited<ReturnType<typeof getManga>> export function useGetManga<TData = Awaited<ReturnType<typeof getManga>>, TError = unknown>(
>, mangaId: number, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getManga>>, TError, TData>> & Pick<
"initialData" DefinedInitialDataOptions<
>; Awaited<ReturnType<typeof getManga>>,
request?: SecondParameter<typeof customInstance>; TError,
}, Awaited<ReturnType<typeof getManga>>
queryClient?: QueryClient, > , 'initialData'
): DefinedUseQueryResult<TData, TError> & { >, request?: SecondParameter<typeof customInstance>}
queryKey: DataTag<QueryKey, TData, TError>; , queryClient?: QueryClient
}; ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetManga< export function useGetManga<TData = Awaited<ReturnType<typeof getManga>>, TError = unknown>(
TData = Awaited<ReturnType<typeof getManga>>, mangaId: number, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getManga>>, TError, TData>> & Pick<
TError = unknown, UndefinedInitialDataOptions<
>( Awaited<ReturnType<typeof getManga>>,
mangaId: number, TError,
options?: { Awaited<ReturnType<typeof getManga>>
query?: Partial< > , 'initialData'
UseQueryOptions<Awaited<ReturnType<typeof getManga>>, TError, TData> >, request?: SecondParameter<typeof customInstance>}
> & , queryClient?: QueryClient
Pick< ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
UndefinedInitialDataOptions< export function useGetManga<TData = Awaited<ReturnType<typeof getManga>>, TError = unknown>(
Awaited<ReturnType<typeof getManga>>, mangaId: number, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getManga>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
TError, , queryClient?: QueryClient
Awaited<ReturnType<typeof getManga>> ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
>,
"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 * @summary Get the details of a manga
*/ */
export function useGetManga< export function useGetManga<TData = Awaited<ReturnType<typeof getManga>>, TError = unknown>(
TData = Awaited<ReturnType<typeof getManga>>, mangaId: number, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getManga>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
TError = unknown, , queryClient?: QueryClient
>( ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
mangaId: number,
options?: {
query?: Partial<
UseQueryOptions<Awaited<ReturnType<typeof getManga>>, TError, TData>
>;
request?: SecondParameter<typeof customInstance>;
},
queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
queryKey: DataTag<QueryKey, TData, TError>;
} {
const queryOptions = getGetMangaQueryOptions(mangaId, options);
const query = useQuery(queryOptions, queryClient) as UseQueryResult< const queryOptions = getGetMangaQueryOptions(mangaId,options)
TData,
TError
> & { queryKey: DataTag<QueryKey, TData, TError> };
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;
} }

View File

@ -22,6 +22,7 @@ export interface User {
email: string; email: string;
name: string; name: string;
token: string; token: string;
refreshToken: string;
role: string; role: string;
} }
@ -65,7 +66,8 @@ export function AuthProvider({ children }: { children: ReactNode }) {
id: response.data.id, id: response.data.id,
email: response.data.email, email: response.data.email,
name: response.data.name, name: response.data.name,
token: response.data.token, token: response.data.accessToken,
refreshToken: response.data.refreshToken,
role: response.data.role, role: response.data.role,
}; };