100 lines
2.7 KiB
TypeScript
100 lines
2.7 KiB
TypeScript
/**
|
|
* Generated by orval v7.16.0 🍺
|
|
* Do not edit manually.
|
|
* OpenAPI definition
|
|
* OpenAPI spec version: v0
|
|
*/
|
|
import {
|
|
useQuery
|
|
} from '@tanstack/vue-query';
|
|
import type {
|
|
DataTag,
|
|
QueryClient,
|
|
QueryFunction,
|
|
QueryKey,
|
|
UseQueryOptions,
|
|
UseQueryReturnType
|
|
} from '@tanstack/vue-query';
|
|
|
|
import {
|
|
computed,
|
|
unref
|
|
} from 'vue';
|
|
import type {
|
|
MaybeRef
|
|
} from 'vue';
|
|
|
|
import type {
|
|
StreamProgress200Item
|
|
} from '.././models';
|
|
|
|
import streamProgressMutator from '.././event-source';
|
|
|
|
|
|
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
|
|
|
|
|
|
|
export const streamProgress = (
|
|
playlistId: MaybeRef<number>,
|
|
options?: SecondParameter<typeof streamProgressMutator>,signal?: AbortSignal
|
|
) => {
|
|
playlistId = unref(playlistId);
|
|
|
|
return streamProgressMutator<StreamProgress200Item[]>(
|
|
{url: `/importing/stream/${playlistId}`, method: 'GET', signal
|
|
},
|
|
options);
|
|
}
|
|
|
|
|
|
|
|
|
|
export const getStreamProgressQueryKey = (playlistId?: MaybeRef<number>,) => {
|
|
return [
|
|
'importing','stream',playlistId
|
|
] as const;
|
|
}
|
|
|
|
|
|
export const getStreamProgressQueryOptions = <TData = Awaited<ReturnType<typeof streamProgress>>, TError = unknown>(playlistId: MaybeRef<number>, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof streamProgress>>, TError, TData>>, request?: SecondParameter<typeof streamProgressMutator>}
|
|
) => {
|
|
|
|
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
|
|
const queryKey = getStreamProgressQueryKey(playlistId);
|
|
|
|
|
|
|
|
const queryFn: QueryFunction<Awaited<ReturnType<typeof streamProgress>>> = ({ signal }) => streamProgress(playlistId, requestOptions, signal);
|
|
|
|
|
|
|
|
|
|
|
|
return { queryKey, queryFn, enabled: computed(() => !!(unref(playlistId))), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof streamProgress>>, TError, TData>
|
|
}
|
|
|
|
export type StreamProgressQueryResult = NonNullable<Awaited<ReturnType<typeof streamProgress>>>
|
|
export type StreamProgressQueryError = unknown
|
|
|
|
|
|
|
|
export function useStreamProgress<TData = Awaited<ReturnType<typeof streamProgress>>, TError = unknown>(
|
|
playlistId: MaybeRef<number>, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof streamProgress>>, TError, TData>>, request?: SecondParameter<typeof streamProgressMutator>}
|
|
, queryClient?: QueryClient
|
|
): UseQueryReturnType<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
|
|
|
|
const queryOptions = getStreamProgressQueryOptions(playlistId,options)
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryReturnType<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
|
|
query.queryKey = unref(queryOptions).queryKey as DataTag<QueryKey, TData, TError>;
|
|
|
|
return query;
|
|
}
|
|
|
|
|
|
|
|
|