diff --git "a/ui/lib/api/default/default.ts" "b/ui/lib/api/default/default.ts" new file mode 100644--- /dev/null +++ "b/ui/lib/api/default/default.ts" @@ -0,0 +1,3095 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +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 { fetchApi } from '.././fetch' +import type { + AddImageLayerResponse, + AppConfig, + AppEvent, + ConfigPatch, + CreatePagesFromPathsRequest, + CreatePagesResponse, + CreateProjectRequest, + EngineCatalog, + ExportProjectRequest, + FontFaceInfo, + GoogleFontCatalog, + HistoryResult, + ListDownloadsResponse, + ListOperationsResponse, + ListProjectsResponse, + LlmCatalog, + LlmLoadRequest, + LlmState, + MaskRole, + MetaInfo, + Op, + OpenProjectRequest, + PageId, + ProjectSummary, + ProviderSecretRequest, + PutMaskResponse, + SceneSnapshot, + StartDownloadRequest, + StartDownloadResponse, + StartPipelineRequest, + StartPipelineResponse, +} from '../schemas' + +type SecondParameter unknown> = Parameters[1] + +export const getGetBlobUrl = (hash: string) => { + return `/api/v1/blobs/${hash}` +} + +export const getBlob = async (hash: string, options?: RequestInit): Promise => { + return fetchApi(getGetBlobUrl(hash), { + ...options, + method: 'GET', + }) +} + +export const getGetBlobQueryKey = (hash: string) => { + return [`/api/v1/blobs/${hash}`] as const +} + +export const getGetBlobQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + hash: string, + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getGetBlobQueryKey(hash) + + const queryFn: QueryFunction>> = ({ signal }) => + getBlob(hash, { signal, ...requestOptions }) + + return { + queryKey, + queryFn, + enabled: !!hash, + gcTime: 300000, + retry: 1, + ...queryOptions, + } as UseQueryOptions>, TError, TData> & { + queryKey: DataTag + } +} + +export type GetBlobQueryResult = NonNullable>> +export type GetBlobQueryError = unknown + +export function useGetBlob>, TError = unknown>( + hash: string, + options: { + query: Partial>, TError, TData>> & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useGetBlob>, TError = unknown>( + hash: string, + options?: { + query?: Partial>, TError, TData>> & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useGetBlob>, TError = unknown>( + hash: string, + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useGetBlob>, TError = unknown>( + hash: string, + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getGetBlobQueryOptions(hash, options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +} + +export const getGetConfigUrl = () => { + return `/api/v1/config` +} + +export const getConfig = async (options?: RequestInit): Promise => { + return fetchApi(getGetConfigUrl(), { + ...options, + method: 'GET', + }) +} + +export const getGetConfigQueryKey = () => { + return [`/api/v1/config`] as const +} + +export const getGetConfigQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getGetConfigQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + getConfig({ signal, ...requestOptions }) + + return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag } +} + +export type GetConfigQueryResult = NonNullable>> +export type GetConfigQueryError = unknown + +export function useGetConfig>, TError = unknown>( + options: { + query: Partial>, TError, TData>> & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useGetConfig>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useGetConfig>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useGetConfig>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getGetConfigQueryOptions(options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +} + +export const getPatchConfigUrl = () => { + return `/api/v1/config` +} + +export const patchConfig = async ( + configPatch: ConfigPatch, + options?: RequestInit, +): Promise => { + return fetchApi(getPatchConfigUrl(), { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(configPatch), + }) +} + +export const getPatchConfigMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ConfigPatch }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: ConfigPatch }, + TContext +> => { + const mutationKey = ['patchConfig'] + 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>, + { data: ConfigPatch } + > = (props) => { + const { data } = props ?? {} + + return patchConfig(data, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type PatchConfigMutationResult = NonNullable>> +export type PatchConfigMutationBody = ConfigPatch +export type PatchConfigMutationError = unknown + +export const usePatchConfig = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ConfigPatch }, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { data: ConfigPatch }, + TContext +> => { + return useMutation(getPatchConfigMutationOptions(options), queryClient) +} +/** + * @summary Save (or overwrite) the keyring secret for a provider. Creates the +provider entry in `config.providers` if it didn't exist. `PUT` because +setting the secret is idempotent for the same body. + */ +export const getSetProviderSecretUrl = (id: string) => { + return `/api/v1/config/providers/${id}/secret` +} + +export const setProviderSecret = async ( + id: string, + providerSecretRequest: ProviderSecretRequest, + options?: RequestInit, +): Promise => { + return fetchApi(getSetProviderSecretUrl(id), { + ...options, + method: 'PUT', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(providerSecretRequest), + }) +} + +export const getSetProviderSecretMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: string; data: ProviderSecretRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { id: string; data: ProviderSecretRequest }, + TContext +> => { + const mutationKey = ['setProviderSecret'] + 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>, + { id: string; data: ProviderSecretRequest } + > = (props) => { + const { id, data } = props ?? {} + + return setProviderSecret(id, data, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type SetProviderSecretMutationResult = NonNullable< + Awaited> +> +export type SetProviderSecretMutationBody = ProviderSecretRequest +export type SetProviderSecretMutationError = unknown + +/** + * @summary Save (or overwrite) the keyring secret for a provider. Creates the +provider entry in `config.providers` if it didn't exist. `PUT` because +setting the secret is idempotent for the same body. + */ +export const useSetProviderSecret = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: string; data: ProviderSecretRequest }, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { id: string; data: ProviderSecretRequest }, + TContext +> => { + return useMutation(getSetProviderSecretMutationOptions(options), queryClient) +} +/** + * @summary Clear a provider's keyring secret. The provider entry itself is kept. + */ +export const getClearProviderSecretUrl = (id: string) => { + return `/api/v1/config/providers/${id}/secret` +} + +export const clearProviderSecret = async (id: string, options?: RequestInit): Promise => { + return fetchApi(getClearProviderSecretUrl(id), { + ...options, + method: 'DELETE', + }) +} + +export const getClearProviderSecretMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: string }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { id: string }, + TContext +> => { + const mutationKey = ['clearProviderSecret'] + 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>, + { id: string } + > = (props) => { + const { id } = props ?? {} + + return clearProviderSecret(id, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type ClearProviderSecretMutationResult = NonNullable< + Awaited> +> + +export type ClearProviderSecretMutationError = unknown + +/** + * @summary Clear a provider's keyring secret. The provider entry itself is kept. + */ +export const useClearProviderSecret = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: string }, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { id: string }, + TContext +> => { + return useMutation(getClearProviderSecretMutationOptions(options), queryClient) +} +export const getListDownloadsUrl = () => { + return `/api/v1/downloads` +} + +export const listDownloads = async (options?: RequestInit): Promise => { + return fetchApi(getListDownloadsUrl(), { + ...options, + method: 'GET', + }) +} + +export const getListDownloadsQueryKey = () => { + return [`/api/v1/downloads`] as const +} + +export const getListDownloadsQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getListDownloadsQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + listDownloads({ signal, ...requestOptions }) + + return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag } +} + +export type ListDownloadsQueryResult = NonNullable>> +export type ListDownloadsQueryError = unknown + +export function useListDownloads< + TData = Awaited>, + TError = unknown, +>( + options: { + query: Partial>, TError, TData>> & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useListDownloads< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial>, TError, TData>> & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useListDownloads< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useListDownloads< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getListDownloadsQueryOptions(options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +} + +export const getStartDownloadUrl = () => { + return `/api/v1/downloads` +} + +export const startDownload = async ( + startDownloadRequest: StartDownloadRequest, + options?: RequestInit, +): Promise => { + return fetchApi(getStartDownloadUrl(), { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(startDownloadRequest), + }) +} + +export const getStartDownloadMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: StartDownloadRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: StartDownloadRequest }, + TContext +> => { + const mutationKey = ['startDownload'] + 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>, + { data: StartDownloadRequest } + > = (props) => { + const { data } = props ?? {} + + return startDownload(data, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type StartDownloadMutationResult = NonNullable>> +export type StartDownloadMutationBody = StartDownloadRequest +export type StartDownloadMutationError = unknown + +export const useStartDownload = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: StartDownloadRequest }, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { data: StartDownloadRequest }, + TContext +> => { + return useMutation(getStartDownloadMutationOptions(options), queryClient) +} +export const getGetEngineCatalogUrl = () => { + return `/api/v1/engines` +} + +export const getEngineCatalog = async (options?: RequestInit): Promise => { + return fetchApi(getGetEngineCatalogUrl(), { + ...options, + method: 'GET', + }) +} + +export const getGetEngineCatalogQueryKey = () => { + return [`/api/v1/engines`] as const +} + +export const getGetEngineCatalogQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getGetEngineCatalogQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + getEngineCatalog({ signal, ...requestOptions }) + + return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag } +} + +export type GetEngineCatalogQueryResult = NonNullable>> +export type GetEngineCatalogQueryError = unknown + +export function useGetEngineCatalog< + TData = Awaited>, + TError = unknown, +>( + options: { + query: Partial>, TError, TData>> & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useGetEngineCatalog< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial>, TError, TData>> & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useGetEngineCatalog< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useGetEngineCatalog< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getGetEngineCatalogQueryOptions(options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +} + +export const getEventsUrl = () => { + return `/api/v1/events` +} + +export const events = async (options?: RequestInit): Promise => { + return fetchApi(getEventsUrl(), { + ...options, + method: 'GET', + }) +} + +export const getEventsQueryKey = () => { + return [`/api/v1/events`] as const +} + +export const getEventsQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getEventsQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + events({ signal, ...requestOptions }) + + return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag } +} + +export type EventsQueryResult = NonNullable>> +export type EventsQueryError = unknown + +export function useEvents>, TError = unknown>( + options: { + query: Partial>, TError, TData>> & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useEvents>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useEvents>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useEvents>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getEventsQueryOptions(options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +} + +export const getListFontsUrl = () => { + return `/api/v1/fonts` +} + +export const listFonts = async (options?: RequestInit): Promise => { + return fetchApi(getListFontsUrl(), { + ...options, + method: 'GET', + }) +} + +export const getListFontsQueryKey = () => { + return [`/api/v1/fonts`] as const +} + +export const getListFontsQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getListFontsQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + listFonts({ signal, ...requestOptions }) + + return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag } +} + +export type ListFontsQueryResult = NonNullable>> +export type ListFontsQueryError = unknown + +export function useListFonts>, TError = unknown>( + options: { + query: Partial>, TError, TData>> & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useListFonts>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useListFonts>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useListFonts>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getListFontsQueryOptions(options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +} + +export const getGetGoogleFontsCatalogUrl = () => { + return `/api/v1/google-fonts` +} + +export const getGoogleFontsCatalog = async (options?: RequestInit): Promise => { + return fetchApi(getGetGoogleFontsCatalogUrl(), { + ...options, + method: 'GET', + }) +} + +export const getGetGoogleFontsCatalogQueryKey = () => { + return [`/api/v1/google-fonts`] as const +} + +export const getGetGoogleFontsCatalogQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getGetGoogleFontsCatalogQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + getGoogleFontsCatalog({ signal, ...requestOptions }) + + return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag } +} + +export type GetGoogleFontsCatalogQueryResult = NonNullable< + Awaited> +> +export type GetGoogleFontsCatalogQueryError = unknown + +export function useGetGoogleFontsCatalog< + TData = Awaited>, + TError = unknown, +>( + options: { + query: Partial< + UseQueryOptions>, TError, TData> + > & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useGetGoogleFontsCatalog< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial< + UseQueryOptions>, TError, TData> + > & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useGetGoogleFontsCatalog< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial< + UseQueryOptions>, TError, TData> + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useGetGoogleFontsCatalog< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial< + UseQueryOptions>, TError, TData> + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getGetGoogleFontsCatalogQueryOptions(options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +} + +export const getFetchGoogleFontUrl = (family: string) => { + return `/api/v1/google-fonts/${family}/fetch` +} + +export const fetchGoogleFont = async (family: string, options?: RequestInit): Promise => { + return fetchApi(getFetchGoogleFontUrl(family), { + ...options, + method: 'POST', + }) +} + +export const getFetchGoogleFontMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { family: string }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { family: string }, + TContext +> => { + const mutationKey = ['fetchGoogleFont'] + 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>, + { family: string } + > = (props) => { + const { family } = props ?? {} + + return fetchGoogleFont(family, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type FetchGoogleFontMutationResult = NonNullable>> + +export type FetchGoogleFontMutationError = unknown + +export const useFetchGoogleFont = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { family: string }, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { family: string }, + TContext +> => { + return useMutation(getFetchGoogleFontMutationOptions(options), queryClient) +} +export const getGetGoogleFontFileUrl = (family: string, file: string) => { + return `/api/v1/google-fonts/${family}/${file}` +} + +export const getGoogleFontFile = async ( + family: string, + file: string, + options?: RequestInit, +): Promise => { + return fetchApi(getGetGoogleFontFileUrl(family, file), { + ...options, + method: 'GET', + }) +} + +export const getGetGoogleFontFileQueryKey = (family: string, file: string) => { + return [`/api/v1/google-fonts/${family}/${file}`] as const +} + +export const getGetGoogleFontFileQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + family: string, + file: string, + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getGetGoogleFontFileQueryKey(family, file) + + const queryFn: QueryFunction>> = ({ signal }) => + getGoogleFontFile(family, file, { signal, ...requestOptions }) + + return { + queryKey, + queryFn, + enabled: !!(family && file), + gcTime: 300000, + retry: 1, + ...queryOptions, + } as UseQueryOptions>, TError, TData> & { + queryKey: DataTag + } +} + +export type GetGoogleFontFileQueryResult = NonNullable< + Awaited> +> +export type GetGoogleFontFileQueryError = unknown + +export function useGetGoogleFontFile< + TData = Awaited>, + TError = unknown, +>( + family: string, + file: string, + options: { + query: Partial>, TError, TData>> & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useGetGoogleFontFile< + TData = Awaited>, + TError = unknown, +>( + family: string, + file: string, + options?: { + query?: Partial>, TError, TData>> & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useGetGoogleFontFile< + TData = Awaited>, + TError = unknown, +>( + family: string, + file: string, + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useGetGoogleFontFile< + TData = Awaited>, + TError = unknown, +>( + family: string, + file: string, + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getGetGoogleFontFileQueryOptions(family, file, options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +} + +export const getApplyCommandUrl = () => { + return `/api/v1/history/apply` +} + +export const applyCommand = async (op: Op, options?: RequestInit): Promise => { + return fetchApi(getApplyCommandUrl(), { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(op), + }) +} + +export const getApplyCommandMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: Op }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: Op }, + TContext +> => { + const mutationKey = ['applyCommand'] + 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>, { data: Op }> = ( + props, + ) => { + const { data } = props ?? {} + + return applyCommand(data, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type ApplyCommandMutationResult = NonNullable>> +export type ApplyCommandMutationBody = Op +export type ApplyCommandMutationError = unknown + +export const useApplyCommand = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: Op }, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult>, TError, { data: Op }, TContext> => { + return useMutation(getApplyCommandMutationOptions(options), queryClient) +} +export const getRedoUrl = () => { + return `/api/v1/history/redo` +} + +export const redo = async (options?: RequestInit): Promise => { + return fetchApi(getRedoUrl(), { + ...options, + method: 'POST', + }) +} + +export const getRedoMutationOptions = (options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter +}): UseMutationOptions>, TError, void, TContext> => { + const mutationKey = ['redo'] + 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>, void> = () => { + return redo(requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type RedoMutationResult = NonNullable>> + +export type RedoMutationError = unknown + +export const useRedo = ( + options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult>, TError, void, TContext> => { + return useMutation(getRedoMutationOptions(options), queryClient) +} +export const getUndoUrl = () => { + return `/api/v1/history/undo` +} + +export const undo = async (options?: RequestInit): Promise => { + return fetchApi(getUndoUrl(), { + ...options, + method: 'POST', + }) +} + +export const getUndoMutationOptions = (options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter +}): UseMutationOptions>, TError, void, TContext> => { + const mutationKey = ['undo'] + 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>, void> = () => { + return undo(requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type UndoMutationResult = NonNullable>> + +export type UndoMutationError = unknown + +export const useUndo = ( + options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult>, TError, void, TContext> => { + return useMutation(getUndoMutationOptions(options), queryClient) +} +export const getGetCatalogUrl = () => { + return `/api/v1/llm/catalog` +} + +export const getCatalog = async (options?: RequestInit): Promise => { + return fetchApi(getGetCatalogUrl(), { + ...options, + method: 'GET', + }) +} + +export const getGetCatalogQueryKey = () => { + return [`/api/v1/llm/catalog`] as const +} + +export const getGetCatalogQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getGetCatalogQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + getCatalog({ signal, ...requestOptions }) + + return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag } +} + +export type GetCatalogQueryResult = NonNullable>> +export type GetCatalogQueryError = unknown + +export function useGetCatalog>, TError = unknown>( + options: { + query: Partial>, TError, TData>> & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useGetCatalog>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useGetCatalog>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useGetCatalog>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getGetCatalogQueryOptions(options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +} + +export const getGetCurrentLlmUrl = () => { + return `/api/v1/llm/current` +} + +export const getCurrentLlm = async (options?: RequestInit): Promise => { + return fetchApi(getGetCurrentLlmUrl(), { + ...options, + method: 'GET', + }) +} + +export const getGetCurrentLlmQueryKey = () => { + return [`/api/v1/llm/current`] as const +} + +export const getGetCurrentLlmQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getGetCurrentLlmQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + getCurrentLlm({ signal, ...requestOptions }) + + return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag } +} + +export type GetCurrentLlmQueryResult = NonNullable>> +export type GetCurrentLlmQueryError = unknown + +export function useGetCurrentLlm< + TData = Awaited>, + TError = unknown, +>( + options: { + query: Partial>, TError, TData>> & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useGetCurrentLlm< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial>, TError, TData>> & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useGetCurrentLlm< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useGetCurrentLlm< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getGetCurrentLlmQueryOptions(options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +} + +export const getPutCurrentLlmUrl = () => { + return `/api/v1/llm/current` +} + +export const putCurrentLlm = async ( + llmLoadRequest: LlmLoadRequest, + options?: RequestInit, +): Promise => { + return fetchApi(getPutCurrentLlmUrl(), { + ...options, + method: 'PUT', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(llmLoadRequest), + }) +} + +export const getPutCurrentLlmMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: LlmLoadRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: LlmLoadRequest }, + TContext +> => { + const mutationKey = ['putCurrentLlm'] + 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>, + { data: LlmLoadRequest } + > = (props) => { + const { data } = props ?? {} + + return putCurrentLlm(data, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type PutCurrentLlmMutationResult = NonNullable>> +export type PutCurrentLlmMutationBody = LlmLoadRequest +export type PutCurrentLlmMutationError = unknown + +export const usePutCurrentLlm = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: LlmLoadRequest }, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { data: LlmLoadRequest }, + TContext +> => { + return useMutation(getPutCurrentLlmMutationOptions(options), queryClient) +} +export const getDeleteCurrentLlmUrl = () => { + return `/api/v1/llm/current` +} + +export const deleteCurrentLlm = async (options?: RequestInit): Promise => { + return fetchApi(getDeleteCurrentLlmUrl(), { + ...options, + method: 'DELETE', + }) +} + +export const getDeleteCurrentLlmMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + void, + TContext + > + request?: SecondParameter +}): UseMutationOptions>, TError, void, TContext> => { + const mutationKey = ['deleteCurrentLlm'] + 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>, void> = () => { + return deleteCurrentLlm(requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type DeleteCurrentLlmMutationResult = NonNullable< + Awaited> +> + +export type DeleteCurrentLlmMutationError = unknown + +export const useDeleteCurrentLlm = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + void, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult>, TError, void, TContext> => { + return useMutation(getDeleteCurrentLlmMutationOptions(options), queryClient) +} +export const getGetMetaUrl = () => { + return `/api/v1/meta` +} + +export const getMeta = async (options?: RequestInit): Promise => { + return fetchApi(getGetMetaUrl(), { + ...options, + method: 'GET', + }) +} + +export const getGetMetaQueryKey = () => { + return [`/api/v1/meta`] as const +} + +export const getGetMetaQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getGetMetaQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + getMeta({ signal, ...requestOptions }) + + return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag } +} + +export type GetMetaQueryResult = NonNullable>> +export type GetMetaQueryError = unknown + +export function useGetMeta>, TError = unknown>( + options: { + query: Partial>, TError, TData>> & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useGetMeta>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useGetMeta>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useGetMeta>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getGetMetaQueryOptions(options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +} + +export const getListOperationsUrl = () => { + return `/api/v1/operations` +} + +export const listOperations = async (options?: RequestInit): Promise => { + return fetchApi(getListOperationsUrl(), { + ...options, + method: 'GET', + }) +} + +export const getListOperationsQueryKey = () => { + return [`/api/v1/operations`] as const +} + +export const getListOperationsQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getListOperationsQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + listOperations({ signal, ...requestOptions }) + + return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag } +} + +export type ListOperationsQueryResult = NonNullable>> +export type ListOperationsQueryError = unknown + +export function useListOperations< + TData = Awaited>, + TError = unknown, +>( + options: { + query: Partial>, TError, TData>> & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useListOperations< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial>, TError, TData>> & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useListOperations< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useListOperations< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getListOperationsQueryOptions(options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +} + +export const getCancelOperationUrl = (id: string) => { + return `/api/v1/operations/${id}` +} + +export const cancelOperation = async (id: string, options?: RequestInit): Promise => { + return fetchApi(getCancelOperationUrl(id), { + ...options, + method: 'DELETE', + }) +} + +export const getCancelOperationMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: string }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { id: string }, + TContext +> => { + const mutationKey = ['cancelOperation'] + 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>, + { id: string } + > = (props) => { + const { id } = props ?? {} + + return cancelOperation(id, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type CancelOperationMutationResult = NonNullable>> + +export type CancelOperationMutationError = unknown + +export const useCancelOperation = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: string }, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { id: string }, + TContext +> => { + return useMutation(getCancelOperationMutationOptions(options), queryClient) +} +export const getCreatePagesUrl = () => { + return `/api/v1/pages` +} + +export const createPages = async (options?: RequestInit): Promise => { + return fetchApi(getCreatePagesUrl(), { + ...options, + method: 'POST', + }) +} + +export const getCreatePagesMutationOptions = (options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter +}): UseMutationOptions>, TError, void, TContext> => { + const mutationKey = ['createPages'] + 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>, void> = () => { + return createPages(requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type CreatePagesMutationResult = NonNullable>> + +export type CreatePagesMutationError = unknown + +export const useCreatePages = ( + options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult>, TError, void, TContext> => { + return useMutation(getCreatePagesMutationOptions(options), queryClient) +} +/** + * Web clients should keep using `POST /pages` with multipart. + * @summary Create pages by reading image files from absolute paths on the server's +filesystem. This is the Tauri desktop import path — the webview picker +returns paths, and the backend reads + decodes + hashes them in parallel +without a round-trip through JS memory or a multipart upload body. + */ +export const getCreatePagesFromPathsUrl = () => { + return `/api/v1/pages/from-paths` +} + +export const createPagesFromPaths = async ( + createPagesFromPathsRequest: CreatePagesFromPathsRequest, + options?: RequestInit, +): Promise => { + return fetchApi(getCreatePagesFromPathsUrl(), { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(createPagesFromPathsRequest), + }) +} + +export const getCreatePagesFromPathsMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: CreatePagesFromPathsRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: CreatePagesFromPathsRequest }, + TContext +> => { + const mutationKey = ['createPagesFromPaths'] + 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>, + { data: CreatePagesFromPathsRequest } + > = (props) => { + const { data } = props ?? {} + + return createPagesFromPaths(data, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type CreatePagesFromPathsMutationResult = NonNullable< + Awaited> +> +export type CreatePagesFromPathsMutationBody = CreatePagesFromPathsRequest +export type CreatePagesFromPathsMutationError = unknown + +/** + * @summary Create pages by reading image files from absolute paths on the server's +filesystem. This is the Tauri desktop import path — the webview picker +returns paths, and the backend reads + decodes + hashes them in parallel +without a round-trip through JS memory or a multipart upload body. + */ +export const useCreatePagesFromPaths = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: CreatePagesFromPathsRequest }, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { data: CreatePagesFromPathsRequest }, + TContext +> => { + return useMutation(getCreatePagesFromPathsMutationOptions(options), queryClient) +} +export const getAddImageLayerUrl = (id: PageId) => { + return `/api/v1/pages/${id}/image-layers` +} + +export const addImageLayer = async ( + id: PageId, + options?: RequestInit, +): Promise => { + return fetchApi(getAddImageLayerUrl(id), { + ...options, + method: 'POST', + }) +} + +export const getAddImageLayerMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: PageId }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { id: PageId }, + TContext +> => { + const mutationKey = ['addImageLayer'] + 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>, { id: PageId }> = ( + props, + ) => { + const { id } = props ?? {} + + return addImageLayer(id, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type AddImageLayerMutationResult = NonNullable>> + +export type AddImageLayerMutationError = unknown + +export const useAddImageLayer = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: PageId }, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { id: PageId }, + TContext +> => { + return useMutation(getAddImageLayerMutationOptions(options), queryClient) +} +/** + * @summary Upsert the `Mask { role }` node on a page with the raw image bytes in +the body. Emits `Op::UpdateNode` if a mask of that role exists, else +`Op::AddNode`. Used by the repair-brush / segment-edit flow; the +follow-up localized inpaint is a separate `POST /pipelines` call. + */ +export const getPutMaskUrl = (id: PageId, role: MaskRole) => { + return `/api/v1/pages/${id}/masks/${role}` +} + +export const putMask = async ( + id: PageId, + role: MaskRole, + putMaskBody: Blob, + options?: RequestInit, +): Promise => { + return fetchApi(getPutMaskUrl(id, role), { + ...options, + method: 'PUT', + headers: { 'Content-Type': 'image/png', ...options?.headers }, + body: JSON.stringify(putMaskBody), + }) +} + +export const getPutMaskMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: PageId; role: MaskRole; data: Blob }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { id: PageId; role: MaskRole; data: Blob }, + TContext +> => { + const mutationKey = ['putMask'] + 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>, + { id: PageId; role: MaskRole; data: Blob } + > = (props) => { + const { id, role, data } = props ?? {} + + return putMask(id, role, data, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type PutMaskMutationResult = NonNullable>> +export type PutMaskMutationBody = Blob +export type PutMaskMutationError = unknown + +/** + * @summary Upsert the `Mask { role }` node on a page with the raw image bytes in +the body. Emits `Op::UpdateNode` if a mask of that role exists, else +`Op::AddNode`. Used by the repair-brush / segment-edit flow; the +follow-up localized inpaint is a separate `POST /pipelines` call. + */ +export const usePutMask = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: PageId; role: MaskRole; data: Blob }, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { id: PageId; role: MaskRole; data: Blob }, + TContext +> => { + return useMutation(getPutMaskMutationOptions(options), queryClient) +} +export const getGetPageThumbnailUrl = (id: PageId) => { + return `/api/v1/pages/${id}/thumbnail` +} + +export const getPageThumbnail = async (id: PageId, options?: RequestInit): Promise => { + return fetchApi(getGetPageThumbnailUrl(id), { + ...options, + method: 'GET', + }) +} + +export const getGetPageThumbnailQueryKey = (id: PageId) => { + return [`/api/v1/pages/${id}/thumbnail`] as const +} + +export const getGetPageThumbnailQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + id: PageId, + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getGetPageThumbnailQueryKey(id) + + const queryFn: QueryFunction>> = ({ signal }) => + getPageThumbnail(id, { signal, ...requestOptions }) + + return { + queryKey, + queryFn, + enabled: !!id, + gcTime: 300000, + retry: 1, + ...queryOptions, + } as UseQueryOptions>, TError, TData> & { + queryKey: DataTag + } +} + +export type GetPageThumbnailQueryResult = NonNullable>> +export type GetPageThumbnailQueryError = unknown + +export function useGetPageThumbnail< + TData = Awaited>, + TError = unknown, +>( + id: PageId, + options: { + query: Partial>, TError, TData>> & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useGetPageThumbnail< + TData = Awaited>, + TError = unknown, +>( + id: PageId, + options?: { + query?: Partial>, TError, TData>> & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useGetPageThumbnail< + TData = Awaited>, + TError = unknown, +>( + id: PageId, + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useGetPageThumbnail< + TData = Awaited>, + TError = unknown, +>( + id: PageId, + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getGetPageThumbnailQueryOptions(id, options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +} + +export const getStartPipelineUrl = () => { + return `/api/v1/pipelines` +} + +export const startPipeline = async ( + startPipelineRequest: StartPipelineRequest, + options?: RequestInit, +): Promise => { + return fetchApi(getStartPipelineUrl(), { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(startPipelineRequest), + }) +} + +export const getStartPipelineMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: StartPipelineRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: StartPipelineRequest }, + TContext +> => { + const mutationKey = ['startPipeline'] + 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>, + { data: StartPipelineRequest } + > = (props) => { + const { data } = props ?? {} + + return startPipeline(data, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type StartPipelineMutationResult = NonNullable>> +export type StartPipelineMutationBody = StartPipelineRequest +export type StartPipelineMutationError = unknown + +export const useStartPipeline = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: StartPipelineRequest }, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { data: StartPipelineRequest }, + TContext +> => { + return useMutation(getStartPipelineMutationOptions(options), queryClient) +} +export const getListProjectsUrl = () => { + return `/api/v1/projects` +} + +export const listProjects = async (options?: RequestInit): Promise => { + return fetchApi(getListProjectsUrl(), { + ...options, + method: 'GET', + }) +} + +export const getListProjectsQueryKey = () => { + return [`/api/v1/projects`] as const +} + +export const getListProjectsQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getListProjectsQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + listProjects({ signal, ...requestOptions }) + + return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag } +} + +export type ListProjectsQueryResult = NonNullable>> +export type ListProjectsQueryError = unknown + +export function useListProjects>, TError = unknown>( + options: { + query: Partial>, TError, TData>> & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useListProjects>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useListProjects>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useListProjects>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getListProjectsQueryOptions(options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +} + +export const getCreateProjectUrl = () => { + return `/api/v1/projects` +} + +export const createProject = async ( + createProjectRequest: CreateProjectRequest, + options?: RequestInit, +): Promise => { + return fetchApi(getCreateProjectUrl(), { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(createProjectRequest), + }) +} + +export const getCreateProjectMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: CreateProjectRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: CreateProjectRequest }, + TContext +> => { + const mutationKey = ['createProject'] + 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>, + { data: CreateProjectRequest } + > = (props) => { + const { data } = props ?? {} + + return createProject(data, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type CreateProjectMutationResult = NonNullable>> +export type CreateProjectMutationBody = CreateProjectRequest +export type CreateProjectMutationError = unknown + +export const useCreateProject = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: CreateProjectRequest }, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { data: CreateProjectRequest }, + TContext +> => { + return useMutation(getCreateProjectMutationOptions(options), queryClient) +} +export const getPutCurrentProjectUrl = () => { + return `/api/v1/projects/current` +} + +export const putCurrentProject = async ( + openProjectRequest: OpenProjectRequest, + options?: RequestInit, +): Promise => { + return fetchApi(getPutCurrentProjectUrl(), { + ...options, + method: 'PUT', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(openProjectRequest), + }) +} + +export const getPutCurrentProjectMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: OpenProjectRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: OpenProjectRequest }, + TContext +> => { + const mutationKey = ['putCurrentProject'] + 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>, + { data: OpenProjectRequest } + > = (props) => { + const { data } = props ?? {} + + return putCurrentProject(data, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type PutCurrentProjectMutationResult = NonNullable< + Awaited> +> +export type PutCurrentProjectMutationBody = OpenProjectRequest +export type PutCurrentProjectMutationError = unknown + +export const usePutCurrentProject = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: OpenProjectRequest }, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { data: OpenProjectRequest }, + TContext +> => { + return useMutation(getPutCurrentProjectMutationOptions(options), queryClient) +} +export const getDeleteCurrentProjectUrl = () => { + return `/api/v1/projects/current` +} + +export const deleteCurrentProject = async (options?: RequestInit): Promise => { + return fetchApi(getDeleteCurrentProjectUrl(), { + ...options, + method: 'DELETE', + }) +} + +export const getDeleteCurrentProjectMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + void, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + void, + TContext +> => { + const mutationKey = ['deleteCurrentProject'] + 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>, + void + > = () => { + return deleteCurrentProject(requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type DeleteCurrentProjectMutationResult = NonNullable< + Awaited> +> + +export type DeleteCurrentProjectMutationError = unknown + +export const useDeleteCurrentProject = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + void, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult>, TError, void, TContext> => { + return useMutation(getDeleteCurrentProjectMutationOptions(options), queryClient) +} +export const getExportCurrentProjectUrl = () => { + return `/api/v1/projects/current/export` +} + +export const exportCurrentProject = async ( + exportProjectRequest: ExportProjectRequest, + options?: RequestInit, +): Promise => { + return fetchApi(getExportCurrentProjectUrl(), { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(exportProjectRequest), + }) +} + +export const getExportCurrentProjectMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ExportProjectRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: ExportProjectRequest }, + TContext +> => { + const mutationKey = ['exportCurrentProject'] + 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>, + { data: ExportProjectRequest } + > = (props) => { + const { data } = props ?? {} + + return exportCurrentProject(data, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type ExportCurrentProjectMutationResult = NonNullable< + Awaited> +> +export type ExportCurrentProjectMutationBody = ExportProjectRequest +export type ExportCurrentProjectMutationError = unknown + +export const useExportCurrentProject = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ExportProjectRequest }, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { data: ExportProjectRequest }, + TContext +> => { + return useMutation(getExportCurrentProjectMutationOptions(options), queryClient) +} +export const getImportProjectUrl = () => { + return `/api/v1/projects/import` +} + +export const importProject = async (options?: RequestInit): Promise => { + return fetchApi(getImportProjectUrl(), { + ...options, + method: 'POST', + }) +} + +export const getImportProjectMutationOptions = (options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter +}): UseMutationOptions>, TError, void, TContext> => { + const mutationKey = ['importProject'] + 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>, void> = () => { + return importProject(requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type ImportProjectMutationResult = NonNullable>> + +export type ImportProjectMutationError = unknown + +export const useImportProject = ( + options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult>, TError, void, TContext> => { + return useMutation(getImportProjectMutationOptions(options), queryClient) +} +export const getGetSceneBinUrl = () => { + return `/api/v1/scene.bin` +} + +export const getSceneBin = async (options?: RequestInit): Promise => { + return fetchApi(getGetSceneBinUrl(), { + ...options, + method: 'GET', + }) +} + +export const getGetSceneBinQueryKey = () => { + return [`/api/v1/scene.bin`] as const +} + +export const getGetSceneBinQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getGetSceneBinQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + getSceneBin({ signal, ...requestOptions }) + + return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag } +} + +export type GetSceneBinQueryResult = NonNullable>> +export type GetSceneBinQueryError = unknown + +export function useGetSceneBin>, TError = unknown>( + options: { + query: Partial>, TError, TData>> & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useGetSceneBin>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useGetSceneBin>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useGetSceneBin>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getGetSceneBinQueryOptions(options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +} + +export const getGetSceneJsonUrl = () => { + return `/api/v1/scene.json` +} + +export const getSceneJson = async (options?: RequestInit): Promise => { + return fetchApi(getGetSceneJsonUrl(), { + ...options, + method: 'GET', + }) +} + +export const getGetSceneJsonQueryKey = () => { + return [`/api/v1/scene.json`] as const +} + +export const getGetSceneJsonQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getGetSceneJsonQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + getSceneJson({ signal, ...requestOptions }) + + return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag } +} + +export type GetSceneJsonQueryResult = NonNullable>> +export type GetSceneJsonQueryError = unknown + +export function useGetSceneJson>, TError = unknown>( + options: { + query: Partial>, TError, TData>> & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useGetSceneJson>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useGetSceneJson>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useGetSceneJson>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getGetSceneJsonQueryOptions(options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +}