All checks were successful
ci/woodpecker/pr/pipeline Pipeline was successful
510 lines
19 KiB
TypeScript
510 lines
19 KiB
TypeScript
/**
|
|
* Generated by orval v7.15.0 🍺
|
|
* Do not edit manually.
|
|
* OpenAPI definition
|
|
* OpenAPI spec version: v0
|
|
*/
|
|
import {
|
|
useMutation,
|
|
useQuery
|
|
} from '@tanstack/react-query';
|
|
import type {
|
|
DataTag,
|
|
DefinedInitialDataOptions,
|
|
DefinedUseQueryResult,
|
|
MutationFunction,
|
|
QueryClient,
|
|
QueryFunction,
|
|
QueryKey,
|
|
UndefinedInitialDataOptions,
|
|
UseMutationOptions,
|
|
UseMutationResult,
|
|
UseQueryOptions,
|
|
UseQueryResult
|
|
} from '@tanstack/react-query';
|
|
|
|
import type {
|
|
DefaultResponseDTOListMangaChapterDTO,
|
|
DefaultResponseDTOMangaDTO,
|
|
DefaultResponseDTOPageMangaListDTO,
|
|
DefaultResponseDTOVoid,
|
|
GetMangasParams
|
|
} from '../api.schemas';
|
|
|
|
import { customInstance } from '../../api';
|
|
|
|
|
|
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
|
|
|
|
|
|
|
/**
|
|
* Fetch a list of manga chapters for a specific manga/provider combination.
|
|
* @summary Fetch the available chapters for a specific manga/provider combination
|
|
*/
|
|
export const fetchMangaChapters = (
|
|
mangaProviderId: number,
|
|
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
) => {
|
|
|
|
|
|
return customInstance<DefaultResponseDTOVoid>(
|
|
{url: `/mangas/${encodeURIComponent(String(mangaProviderId))}/fetch-chapters`, method: 'POST', signal
|
|
},
|
|
options);
|
|
}
|
|
|
|
|
|
|
|
export const getFetchMangaChaptersMutationOptions = <TError = unknown,
|
|
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof fetchMangaChapters>>, TError,{mangaProviderId: number}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
): UseMutationOptions<Awaited<ReturnType<typeof fetchMangaChapters>>, TError,{mangaProviderId: number}, TContext> => {
|
|
|
|
const mutationKey = ['fetchMangaChapters'];
|
|
const {mutation: mutationOptions, request: requestOptions} = options ?
|
|
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
|
|
options
|
|
: {...options, mutation: {...options.mutation, mutationKey}}
|
|
: {mutation: { mutationKey, }, request: undefined};
|
|
|
|
|
|
|
|
|
|
const mutationFn: MutationFunction<Awaited<ReturnType<typeof fetchMangaChapters>>, {mangaProviderId: number}> = (props) => {
|
|
const {mangaProviderId} = props ?? {};
|
|
|
|
return fetchMangaChapters(mangaProviderId,requestOptions)
|
|
}
|
|
|
|
|
|
|
|
|
|
return { mutationFn, ...mutationOptions }}
|
|
|
|
export type FetchMangaChaptersMutationResult = NonNullable<Awaited<ReturnType<typeof fetchMangaChapters>>>
|
|
|
|
export type FetchMangaChaptersMutationError = unknown
|
|
|
|
/**
|
|
* @summary Fetch the available chapters for a specific manga/provider combination
|
|
*/
|
|
export const useFetchMangaChapters = <TError = unknown,
|
|
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof fetchMangaChapters>>, TError,{mangaProviderId: number}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
, queryClient?: QueryClient): UseMutationResult<
|
|
Awaited<ReturnType<typeof fetchMangaChapters>>,
|
|
TError,
|
|
{mangaProviderId: number},
|
|
TContext
|
|
> => {
|
|
|
|
const mutationOptions = getFetchMangaChaptersMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
}
|
|
/**
|
|
* Unfollow the manga specified by its ID.
|
|
* @summary Unfollow the manga specified by its ID
|
|
*/
|
|
export const unfollowManga = (
|
|
mangaId: number,
|
|
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
) => {
|
|
|
|
|
|
return customInstance<DefaultResponseDTOVoid>(
|
|
{url: `/mangas/${encodeURIComponent(String(mangaId))}/unfollowManga`, method: 'POST', signal
|
|
},
|
|
options);
|
|
}
|
|
|
|
|
|
|
|
export const getUnfollowMangaMutationOptions = <TError = unknown,
|
|
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof unfollowManga>>, TError,{mangaId: number}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
): UseMutationOptions<Awaited<ReturnType<typeof unfollowManga>>, TError,{mangaId: number}, TContext> => {
|
|
|
|
const mutationKey = ['unfollowManga'];
|
|
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 unfollowManga>>, {mangaId: number}> = (props) => {
|
|
const {mangaId} = props ?? {};
|
|
|
|
return unfollowManga(mangaId,requestOptions)
|
|
}
|
|
|
|
|
|
|
|
|
|
return { mutationFn, ...mutationOptions }}
|
|
|
|
export type UnfollowMangaMutationResult = NonNullable<Awaited<ReturnType<typeof unfollowManga>>>
|
|
|
|
export type UnfollowMangaMutationError = unknown
|
|
|
|
/**
|
|
* @summary Unfollow the manga specified by its ID
|
|
*/
|
|
export const useUnfollowManga = <TError = unknown,
|
|
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof unfollowManga>>, TError,{mangaId: number}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
, queryClient?: QueryClient): UseMutationResult<
|
|
Awaited<ReturnType<typeof unfollowManga>>,
|
|
TError,
|
|
{mangaId: number},
|
|
TContext
|
|
> => {
|
|
|
|
const mutationOptions = getUnfollowMangaMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
}
|
|
/**
|
|
* Follow the manga specified by its ID.
|
|
* @summary Follow the manga specified by its ID
|
|
*/
|
|
export const followManga = (
|
|
mangaId: number,
|
|
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
) => {
|
|
|
|
|
|
return customInstance<DefaultResponseDTOVoid>(
|
|
{url: `/mangas/${encodeURIComponent(String(mangaId))}/followManga`, method: 'POST', signal
|
|
},
|
|
options);
|
|
}
|
|
|
|
|
|
|
|
export const getFollowMangaMutationOptions = <TError = unknown,
|
|
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof followManga>>, TError,{mangaId: number}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
): UseMutationOptions<Awaited<ReturnType<typeof followManga>>, TError,{mangaId: number}, TContext> => {
|
|
|
|
const mutationKey = ['followManga'];
|
|
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 followManga>>, {mangaId: number}> = (props) => {
|
|
const {mangaId} = props ?? {};
|
|
|
|
return followManga(mangaId,requestOptions)
|
|
}
|
|
|
|
|
|
|
|
|
|
return { mutationFn, ...mutationOptions }}
|
|
|
|
export type FollowMangaMutationResult = NonNullable<Awaited<ReturnType<typeof followManga>>>
|
|
|
|
export type FollowMangaMutationError = unknown
|
|
|
|
/**
|
|
* @summary Follow the manga specified by its ID
|
|
*/
|
|
export const useFollowManga = <TError = unknown,
|
|
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof followManga>>, TError,{mangaId: number}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
, queryClient?: QueryClient): UseMutationResult<
|
|
Awaited<ReturnType<typeof followManga>>,
|
|
TError,
|
|
{mangaId: number},
|
|
TContext
|
|
> => {
|
|
|
|
const mutationOptions = getFollowMangaMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
}
|
|
/**
|
|
* Retrieve a list of mangas with their details.
|
|
* @summary Get a list of mangas
|
|
*/
|
|
export const getMangas = (
|
|
params?: GetMangasParams,
|
|
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
) => {
|
|
|
|
|
|
return customInstance<DefaultResponseDTOPageMangaListDTO>(
|
|
{url: `/mangas`, method: 'GET',
|
|
params, signal
|
|
},
|
|
options);
|
|
}
|
|
|
|
|
|
|
|
|
|
export const getGetMangasQueryKey = (params?: GetMangasParams,) => {
|
|
return [
|
|
`/mangas`, ...(params ? [params]: [])
|
|
] as const;
|
|
}
|
|
|
|
|
|
export const getGetMangasQueryOptions = <TData = Awaited<ReturnType<typeof getMangas>>, TError = unknown>(params?: GetMangasParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMangas>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
) => {
|
|
|
|
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
|
|
const queryKey = queryOptions?.queryKey ?? getGetMangasQueryKey(params);
|
|
|
|
|
|
|
|
const queryFn: QueryFunction<Awaited<ReturnType<typeof getMangas>>> = ({ signal }) => getMangas(params, requestOptions, signal);
|
|
|
|
|
|
|
|
|
|
|
|
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getMangas>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
}
|
|
|
|
export type GetMangasQueryResult = NonNullable<Awaited<ReturnType<typeof getMangas>>>
|
|
export type GetMangasQueryError = unknown
|
|
|
|
|
|
export function useGetMangas<TData = Awaited<ReturnType<typeof getMangas>>, TError = unknown>(
|
|
params: undefined | GetMangasParams, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMangas>>, TError, TData>> & Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getMangas>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getMangas>>
|
|
> , 'initialData'
|
|
>, request?: SecondParameter<typeof customInstance>}
|
|
, queryClient?: QueryClient
|
|
): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
export function useGetMangas<TData = Awaited<ReturnType<typeof getMangas>>, TError = unknown>(
|
|
params?: GetMangasParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMangas>>, TError, TData>> & Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getMangas>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getMangas>>
|
|
> , 'initialData'
|
|
>, request?: SecondParameter<typeof customInstance>}
|
|
, queryClient?: QueryClient
|
|
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
export function useGetMangas<TData = Awaited<ReturnType<typeof getMangas>>, TError = unknown>(
|
|
params?: GetMangasParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMangas>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
, queryClient?: QueryClient
|
|
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
/**
|
|
* @summary Get a list of mangas
|
|
*/
|
|
|
|
export function useGetMangas<TData = Awaited<ReturnType<typeof getMangas>>, TError = unknown>(
|
|
params?: GetMangasParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMangas>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
, queryClient?: QueryClient
|
|
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
|
|
|
|
const queryOptions = getGetMangasQueryOptions(params,options)
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
|
|
query.queryKey = queryOptions.queryKey ;
|
|
|
|
return query;
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
* Retrieve a list of manga chapters for a specific manga/provider combination.
|
|
* @summary Get the available chapters for a specific manga/provider combination
|
|
*/
|
|
export const getMangaChapters = (
|
|
mangaProviderId: number,
|
|
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
) => {
|
|
|
|
|
|
return customInstance<DefaultResponseDTOListMangaChapterDTO>(
|
|
{url: `/mangas/${encodeURIComponent(String(mangaProviderId))}/chapters`, method: 'GET', signal
|
|
},
|
|
options);
|
|
}
|
|
|
|
|
|
|
|
|
|
export const getGetMangaChaptersQueryKey = (mangaProviderId?: number,) => {
|
|
return [
|
|
`/mangas/${mangaProviderId}/chapters`
|
|
] as const;
|
|
}
|
|
|
|
|
|
export const getGetMangaChaptersQueryOptions = <TData = Awaited<ReturnType<typeof getMangaChapters>>, TError = unknown>(mangaProviderId: number, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMangaChapters>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
) => {
|
|
|
|
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
|
|
const queryKey = queryOptions?.queryKey ?? getGetMangaChaptersQueryKey(mangaProviderId);
|
|
|
|
|
|
|
|
const queryFn: QueryFunction<Awaited<ReturnType<typeof getMangaChapters>>> = ({ signal }) => getMangaChapters(mangaProviderId, requestOptions, signal);
|
|
|
|
|
|
|
|
|
|
|
|
return { queryKey, queryFn, enabled: !!(mangaProviderId), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getMangaChapters>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
}
|
|
|
|
export type GetMangaChaptersQueryResult = NonNullable<Awaited<ReturnType<typeof getMangaChapters>>>
|
|
export type GetMangaChaptersQueryError = unknown
|
|
|
|
|
|
export function useGetMangaChapters<TData = Awaited<ReturnType<typeof getMangaChapters>>, TError = unknown>(
|
|
mangaProviderId: number, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMangaChapters>>, TError, TData>> & Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getMangaChapters>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getMangaChapters>>
|
|
> , 'initialData'
|
|
>, request?: SecondParameter<typeof customInstance>}
|
|
, queryClient?: QueryClient
|
|
): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
export function useGetMangaChapters<TData = Awaited<ReturnType<typeof getMangaChapters>>, TError = unknown>(
|
|
mangaProviderId: number, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMangaChapters>>, TError, TData>> & Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getMangaChapters>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getMangaChapters>>
|
|
> , 'initialData'
|
|
>, request?: SecondParameter<typeof customInstance>}
|
|
, queryClient?: QueryClient
|
|
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
export function useGetMangaChapters<TData = Awaited<ReturnType<typeof getMangaChapters>>, TError = unknown>(
|
|
mangaProviderId: number, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMangaChapters>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
, queryClient?: QueryClient
|
|
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
/**
|
|
* @summary Get the available chapters for a specific manga/provider combination
|
|
*/
|
|
|
|
export function useGetMangaChapters<TData = Awaited<ReturnType<typeof getMangaChapters>>, TError = unknown>(
|
|
mangaProviderId: number, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMangaChapters>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
, queryClient?: QueryClient
|
|
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
|
|
|
|
const queryOptions = getGetMangaChaptersQueryOptions(mangaProviderId,options)
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
|
|
query.queryKey = queryOptions.queryKey ;
|
|
|
|
return query;
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
* Get the details of a manga by its ID
|
|
* @summary Get the details of a manga
|
|
*/
|
|
export const getManga = (
|
|
mangaId: number,
|
|
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
) => {
|
|
|
|
|
|
return customInstance<DefaultResponseDTOMangaDTO>(
|
|
{url: `/mangas/${encodeURIComponent(String(mangaId))}`, method: 'GET', signal
|
|
},
|
|
options);
|
|
}
|
|
|
|
|
|
|
|
|
|
export const getGetMangaQueryKey = (mangaId?: number,) => {
|
|
return [
|
|
`/mangas/${mangaId}`
|
|
] as const;
|
|
}
|
|
|
|
|
|
export const getGetMangaQueryOptions = <TData = Awaited<ReturnType<typeof getManga>>, TError = unknown>(mangaId: number, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getManga>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
) => {
|
|
|
|
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
|
|
const queryKey = queryOptions?.queryKey ?? getGetMangaQueryKey(mangaId);
|
|
|
|
|
|
|
|
const queryFn: QueryFunction<Awaited<ReturnType<typeof getManga>>> = ({ signal }) => getManga(mangaId, requestOptions, signal);
|
|
|
|
|
|
|
|
|
|
|
|
return { queryKey, queryFn, enabled: !!(mangaId), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getManga>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
}
|
|
|
|
export type GetMangaQueryResult = NonNullable<Awaited<ReturnType<typeof getManga>>>
|
|
export type GetMangaQueryError = unknown
|
|
|
|
|
|
export function useGetManga<TData = Awaited<ReturnType<typeof getManga>>, TError = unknown>(
|
|
mangaId: number, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getManga>>, TError, TData>> & Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getManga>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getManga>>
|
|
> , 'initialData'
|
|
>, request?: SecondParameter<typeof customInstance>}
|
|
, queryClient?: QueryClient
|
|
): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
export function useGetManga<TData = Awaited<ReturnType<typeof getManga>>, TError = unknown>(
|
|
mangaId: number, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getManga>>, TError, TData>> & Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getManga>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getManga>>
|
|
> , 'initialData'
|
|
>, request?: SecondParameter<typeof customInstance>}
|
|
, queryClient?: QueryClient
|
|
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
export function useGetManga<TData = Awaited<ReturnType<typeof getManga>>, TError = unknown>(
|
|
mangaId: number, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getManga>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
, queryClient?: QueryClient
|
|
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
/**
|
|
* @summary Get the details of a manga
|
|
*/
|
|
|
|
export function useGetManga<TData = Awaited<ReturnType<typeof getManga>>, TError = unknown>(
|
|
mangaId: number, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getManga>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
, queryClient?: QueryClient
|
|
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
|
|
|
|
const queryOptions = getGetMangaQueryOptions(mangaId,options)
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
|
|
query.queryKey = queryOptions.queryKey ;
|
|
|
|
return query;
|
|
}
|
|
|
|
|
|
|
|
|