Download ui/lib/api/default/default.ts from Jadewave/trans2: direct link, hf CLI and curl.
- Browser
- Download file 112 kB
-
https://huggingface.co/spaces/Jadewave/trans2/resolve/main/ui/lib/api/default/default.ts
- Command line
-
hf download hf://spaces/Jadewave/trans2/ui/lib/api/default/default.ts
-
curl -L -o default.ts https://huggingface.co/spaces/Jadewave/trans2/resolve/main/ui/lib/api/default/default.ts
112 kB
| /** | |
| * Generated by orval v8.8.1 🍺 | |
| * 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, | |
| CodexAuthStatus, | |
| CodexDeviceLogin, | |
| CodexImageGenerationOptions, | |
| CodexImageGenerationResponse, | |
| 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<T extends (...args: never) => unknown> = Parameters<T>[1] | |
| export const getStartCodexDeviceLoginUrl = () => { | |
| return `/api/v1/ai/codex/auth/device-code` | |
| } | |
| export const startCodexDeviceLogin = async (options?: RequestInit): Promise<CodexDeviceLogin> => { | |
| return fetchApi<CodexDeviceLogin>(getStartCodexDeviceLoginUrl(), { | |
| ...options, | |
| method: 'POST', | |
| }) | |
| } | |
| export const getStartCodexDeviceLoginMutationOptions = < | |
| TError = unknown, | |
| TContext = unknown, | |
| >(options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof startCodexDeviceLogin>>, | |
| TError, | |
| void, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }): UseMutationOptions< | |
| Awaited<ReturnType<typeof startCodexDeviceLogin>>, | |
| TError, | |
| void, | |
| TContext | |
| > => { | |
| const mutationKey = ['startCodexDeviceLogin'] | |
| 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 startCodexDeviceLogin>>, | |
| void | |
| > = () => { | |
| return startCodexDeviceLogin(requestOptions) | |
| } | |
| return { mutationFn, ...mutationOptions } | |
| } | |
| export type StartCodexDeviceLoginMutationResult = NonNullable< | |
| Awaited<ReturnType<typeof startCodexDeviceLogin>> | |
| > | |
| export type StartCodexDeviceLoginMutationError = unknown | |
| export const useStartCodexDeviceLogin = <TError = unknown, TContext = unknown>( | |
| options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof startCodexDeviceLogin>>, | |
| TError, | |
| void, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseMutationResult<Awaited<ReturnType<typeof startCodexDeviceLogin>>, TError, void, TContext> => { | |
| return useMutation(getStartCodexDeviceLoginMutationOptions(options), queryClient) | |
| } | |
| export const getDeleteCodexSessionUrl = () => { | |
| return `/api/v1/ai/codex/auth/session` | |
| } | |
| export const deleteCodexSession = async (options?: RequestInit): Promise<void> => { | |
| return fetchApi<void>(getDeleteCodexSessionUrl(), { | |
| ...options, | |
| method: 'DELETE', | |
| }) | |
| } | |
| export const getDeleteCodexSessionMutationOptions = < | |
| TError = unknown, | |
| TContext = unknown, | |
| >(options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof deleteCodexSession>>, | |
| TError, | |
| void, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }): UseMutationOptions<Awaited<ReturnType<typeof deleteCodexSession>>, TError, void, TContext> => { | |
| const mutationKey = ['deleteCodexSession'] | |
| 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 deleteCodexSession>>, void> = () => { | |
| return deleteCodexSession(requestOptions) | |
| } | |
| return { mutationFn, ...mutationOptions } | |
| } | |
| export type DeleteCodexSessionMutationResult = NonNullable< | |
| Awaited<ReturnType<typeof deleteCodexSession>> | |
| > | |
| export type DeleteCodexSessionMutationError = unknown | |
| export const useDeleteCodexSession = <TError = unknown, TContext = unknown>( | |
| options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof deleteCodexSession>>, | |
| TError, | |
| void, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseMutationResult<Awaited<ReturnType<typeof deleteCodexSession>>, TError, void, TContext> => { | |
| return useMutation(getDeleteCodexSessionMutationOptions(options), queryClient) | |
| } | |
| export const getGetCodexAuthStatusUrl = () => { | |
| return `/api/v1/ai/codex/auth/status` | |
| } | |
| export const getCodexAuthStatus = async (options?: RequestInit): Promise<CodexAuthStatus> => { | |
| return fetchApi<CodexAuthStatus>(getGetCodexAuthStatusUrl(), { | |
| ...options, | |
| method: 'GET', | |
| }) | |
| } | |
| export const getGetCodexAuthStatusQueryKey = () => { | |
| return [`/api/v1/ai/codex/auth/status`] as const | |
| } | |
| export const getGetCodexAuthStatusQueryOptions = < | |
| TData = Awaited<ReturnType<typeof getCodexAuthStatus>>, | |
| TError = unknown, | |
| >(options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getCodexAuthStatus>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }) => { | |
| const { query: queryOptions, request: requestOptions } = options ?? {} | |
| const queryKey = queryOptions?.queryKey ?? getGetCodexAuthStatusQueryKey() | |
| const queryFn: QueryFunction<Awaited<ReturnType<typeof getCodexAuthStatus>>> = ({ signal }) => | |
| getCodexAuthStatus({ signal, ...requestOptions }) | |
| return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< | |
| Awaited<ReturnType<typeof getCodexAuthStatus>>, | |
| TError, | |
| TData | |
| > & { queryKey: DataTag<QueryKey, TData, TError> } | |
| } | |
| export type GetCodexAuthStatusQueryResult = NonNullable< | |
| Awaited<ReturnType<typeof getCodexAuthStatus>> | |
| > | |
| export type GetCodexAuthStatusQueryError = unknown | |
| export function useGetCodexAuthStatus< | |
| TData = Awaited<ReturnType<typeof getCodexAuthStatus>>, | |
| TError = unknown, | |
| >( | |
| options: { | |
| query: Partial<UseQueryOptions<Awaited<ReturnType<typeof getCodexAuthStatus>>, TError, TData>> & | |
| Pick< | |
| DefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof getCodexAuthStatus>>, | |
| TError, | |
| Awaited<ReturnType<typeof getCodexAuthStatus>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetCodexAuthStatus< | |
| TData = Awaited<ReturnType<typeof getCodexAuthStatus>>, | |
| TError = unknown, | |
| >( | |
| options?: { | |
| query?: Partial< | |
| UseQueryOptions<Awaited<ReturnType<typeof getCodexAuthStatus>>, TError, TData> | |
| > & | |
| Pick< | |
| UndefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof getCodexAuthStatus>>, | |
| TError, | |
| Awaited<ReturnType<typeof getCodexAuthStatus>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetCodexAuthStatus< | |
| TData = Awaited<ReturnType<typeof getCodexAuthStatus>>, | |
| TError = unknown, | |
| >( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getCodexAuthStatus>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetCodexAuthStatus< | |
| TData = Awaited<ReturnType<typeof getCodexAuthStatus>>, | |
| TError = unknown, | |
| >( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getCodexAuthStatus>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } { | |
| const queryOptions = getGetCodexAuthStatusQueryOptions(options) | |
| const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { | |
| queryKey: DataTag<QueryKey, TData, TError> | |
| } | |
| return { ...query, queryKey: queryOptions.queryKey } | |
| } | |
| export const getStartCodexImageGenerationUrl = () => { | |
| return `/api/v1/ai/codex/images` | |
| } | |
| export const startCodexImageGeneration = async ( | |
| codexImageGenerationOptions: CodexImageGenerationOptions, | |
| options?: RequestInit, | |
| ): Promise<CodexImageGenerationResponse> => { | |
| return fetchApi<CodexImageGenerationResponse>(getStartCodexImageGenerationUrl(), { | |
| ...options, | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json', ...options?.headers }, | |
| body: JSON.stringify(codexImageGenerationOptions), | |
| }) | |
| } | |
| export const getStartCodexImageGenerationMutationOptions = < | |
| TError = unknown, | |
| TContext = unknown, | |
| >(options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof startCodexImageGeneration>>, | |
| TError, | |
| { data: CodexImageGenerationOptions }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }): UseMutationOptions< | |
| Awaited<ReturnType<typeof startCodexImageGeneration>>, | |
| TError, | |
| { data: CodexImageGenerationOptions }, | |
| TContext | |
| > => { | |
| const mutationKey = ['startCodexImageGeneration'] | |
| 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 startCodexImageGeneration>>, | |
| { data: CodexImageGenerationOptions } | |
| > = (props) => { | |
| const { data } = props ?? {} | |
| return startCodexImageGeneration(data, requestOptions) | |
| } | |
| return { mutationFn, ...mutationOptions } | |
| } | |
| export type StartCodexImageGenerationMutationResult = NonNullable< | |
| Awaited<ReturnType<typeof startCodexImageGeneration>> | |
| > | |
| export type StartCodexImageGenerationMutationBody = CodexImageGenerationOptions | |
| export type StartCodexImageGenerationMutationError = unknown | |
| export const useStartCodexImageGeneration = <TError = unknown, TContext = unknown>( | |
| options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof startCodexImageGeneration>>, | |
| TError, | |
| { data: CodexImageGenerationOptions }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseMutationResult< | |
| Awaited<ReturnType<typeof startCodexImageGeneration>>, | |
| TError, | |
| { data: CodexImageGenerationOptions }, | |
| TContext | |
| > => { | |
| return useMutation(getStartCodexImageGenerationMutationOptions(options), queryClient) | |
| } | |
| export const getGetBlobUrl = (hash: string) => { | |
| return `/api/v1/blobs/${hash}` | |
| } | |
| export const getBlob = async (hash: string, options?: RequestInit): Promise<Blob> => { | |
| return fetchApi<Blob>(getGetBlobUrl(hash), { | |
| ...options, | |
| method: 'GET', | |
| }) | |
| } | |
| export const getGetBlobQueryKey = (hash: string) => { | |
| return [`/api/v1/blobs/${hash}`] as const | |
| } | |
| export const getGetBlobQueryOptions = < | |
| TData = Awaited<ReturnType<typeof getBlob>>, | |
| TError = unknown, | |
| >( | |
| hash: string, | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getBlob>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| ) => { | |
| const { query: queryOptions, request: requestOptions } = options ?? {} | |
| const queryKey = queryOptions?.queryKey ?? getGetBlobQueryKey(hash) | |
| const queryFn: QueryFunction<Awaited<ReturnType<typeof getBlob>>> = ({ signal }) => | |
| getBlob(hash, { signal, ...requestOptions }) | |
| return { | |
| queryKey, | |
| queryFn, | |
| enabled: !!hash, | |
| gcTime: 300000, | |
| retry: 1, | |
| ...queryOptions, | |
| } as UseQueryOptions<Awaited<ReturnType<typeof getBlob>>, TError, TData> & { | |
| queryKey: DataTag<QueryKey, TData, TError> | |
| } | |
| } | |
| export type GetBlobQueryResult = NonNullable<Awaited<ReturnType<typeof getBlob>>> | |
| export type GetBlobQueryError = unknown | |
| export function useGetBlob<TData = Awaited<ReturnType<typeof getBlob>>, TError = unknown>( | |
| hash: string, | |
| options: { | |
| query: Partial<UseQueryOptions<Awaited<ReturnType<typeof getBlob>>, TError, TData>> & | |
| Pick< | |
| DefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof getBlob>>, | |
| TError, | |
| Awaited<ReturnType<typeof getBlob>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetBlob<TData = Awaited<ReturnType<typeof getBlob>>, TError = unknown>( | |
| hash: string, | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getBlob>>, TError, TData>> & | |
| Pick< | |
| UndefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof getBlob>>, | |
| TError, | |
| Awaited<ReturnType<typeof getBlob>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetBlob<TData = Awaited<ReturnType<typeof getBlob>>, TError = unknown>( | |
| hash: string, | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getBlob>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetBlob<TData = Awaited<ReturnType<typeof getBlob>>, TError = unknown>( | |
| hash: string, | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getBlob>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } { | |
| const queryOptions = getGetBlobQueryOptions(hash, options) | |
| const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { | |
| queryKey: DataTag<QueryKey, TData, TError> | |
| } | |
| return { ...query, queryKey: queryOptions.queryKey } | |
| } | |
| export const getGetConfigUrl = () => { | |
| return `/api/v1/config` | |
| } | |
| export const getConfig = async (options?: RequestInit): Promise<AppConfig> => { | |
| return fetchApi<AppConfig>(getGetConfigUrl(), { | |
| ...options, | |
| method: 'GET', | |
| }) | |
| } | |
| export const getGetConfigQueryKey = () => { | |
| return [`/api/v1/config`] as const | |
| } | |
| export const getGetConfigQueryOptions = < | |
| TData = Awaited<ReturnType<typeof getConfig>>, | |
| TError = unknown, | |
| >(options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getConfig>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }) => { | |
| const { query: queryOptions, request: requestOptions } = options ?? {} | |
| const queryKey = queryOptions?.queryKey ?? getGetConfigQueryKey() | |
| const queryFn: QueryFunction<Awaited<ReturnType<typeof getConfig>>> = ({ signal }) => | |
| getConfig({ signal, ...requestOptions }) | |
| return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< | |
| Awaited<ReturnType<typeof getConfig>>, | |
| TError, | |
| TData | |
| > & { queryKey: DataTag<QueryKey, TData, TError> } | |
| } | |
| export type GetConfigQueryResult = NonNullable<Awaited<ReturnType<typeof getConfig>>> | |
| export type GetConfigQueryError = unknown | |
| export function useGetConfig<TData = Awaited<ReturnType<typeof getConfig>>, TError = unknown>( | |
| options: { | |
| query: Partial<UseQueryOptions<Awaited<ReturnType<typeof getConfig>>, TError, TData>> & | |
| Pick< | |
| DefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof getConfig>>, | |
| TError, | |
| Awaited<ReturnType<typeof getConfig>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetConfig<TData = Awaited<ReturnType<typeof getConfig>>, TError = unknown>( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getConfig>>, TError, TData>> & | |
| Pick< | |
| UndefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof getConfig>>, | |
| TError, | |
| Awaited<ReturnType<typeof getConfig>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetConfig<TData = Awaited<ReturnType<typeof getConfig>>, TError = unknown>( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getConfig>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetConfig<TData = Awaited<ReturnType<typeof getConfig>>, TError = unknown>( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getConfig>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } { | |
| const queryOptions = getGetConfigQueryOptions(options) | |
| const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { | |
| queryKey: DataTag<QueryKey, TData, TError> | |
| } | |
| return { ...query, queryKey: queryOptions.queryKey } | |
| } | |
| export const getPatchConfigUrl = () => { | |
| return `/api/v1/config` | |
| } | |
| export const patchConfig = async ( | |
| configPatch: ConfigPatch, | |
| options?: RequestInit, | |
| ): Promise<AppConfig> => { | |
| return fetchApi<AppConfig>(getPatchConfigUrl(), { | |
| ...options, | |
| method: 'PATCH', | |
| headers: { 'Content-Type': 'application/json', ...options?.headers }, | |
| body: JSON.stringify(configPatch), | |
| }) | |
| } | |
| export const getPatchConfigMutationOptions = <TError = unknown, TContext = unknown>(options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof patchConfig>>, | |
| TError, | |
| { data: ConfigPatch }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }): UseMutationOptions< | |
| Awaited<ReturnType<typeof patchConfig>>, | |
| 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<ReturnType<typeof patchConfig>>, | |
| { data: ConfigPatch } | |
| > = (props) => { | |
| const { data } = props ?? {} | |
| return patchConfig(data, requestOptions) | |
| } | |
| return { mutationFn, ...mutationOptions } | |
| } | |
| export type PatchConfigMutationResult = NonNullable<Awaited<ReturnType<typeof patchConfig>>> | |
| export type PatchConfigMutationBody = ConfigPatch | |
| export type PatchConfigMutationError = unknown | |
| export const usePatchConfig = <TError = unknown, TContext = unknown>( | |
| options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof patchConfig>>, | |
| TError, | |
| { data: ConfigPatch }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseMutationResult< | |
| Awaited<ReturnType<typeof patchConfig>>, | |
| 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<void> => { | |
| return fetchApi<void>(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<ReturnType<typeof setProviderSecret>>, | |
| TError, | |
| { id: string; data: ProviderSecretRequest }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }): UseMutationOptions< | |
| Awaited<ReturnType<typeof setProviderSecret>>, | |
| 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<ReturnType<typeof setProviderSecret>>, | |
| { id: string; data: ProviderSecretRequest } | |
| > = (props) => { | |
| const { id, data } = props ?? {} | |
| return setProviderSecret(id, data, requestOptions) | |
| } | |
| return { mutationFn, ...mutationOptions } | |
| } | |
| export type SetProviderSecretMutationResult = NonNullable< | |
| Awaited<ReturnType<typeof setProviderSecret>> | |
| > | |
| 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 = <TError = unknown, TContext = unknown>( | |
| options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof setProviderSecret>>, | |
| TError, | |
| { id: string; data: ProviderSecretRequest }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseMutationResult< | |
| Awaited<ReturnType<typeof setProviderSecret>>, | |
| 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<void> => { | |
| return fetchApi<void>(getClearProviderSecretUrl(id), { | |
| ...options, | |
| method: 'DELETE', | |
| }) | |
| } | |
| export const getClearProviderSecretMutationOptions = < | |
| TError = unknown, | |
| TContext = unknown, | |
| >(options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof clearProviderSecret>>, | |
| TError, | |
| { id: string }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }): UseMutationOptions< | |
| Awaited<ReturnType<typeof clearProviderSecret>>, | |
| 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<ReturnType<typeof clearProviderSecret>>, | |
| { id: string } | |
| > = (props) => { | |
| const { id } = props ?? {} | |
| return clearProviderSecret(id, requestOptions) | |
| } | |
| return { mutationFn, ...mutationOptions } | |
| } | |
| export type ClearProviderSecretMutationResult = NonNullable< | |
| Awaited<ReturnType<typeof clearProviderSecret>> | |
| > | |
| export type ClearProviderSecretMutationError = unknown | |
| /** | |
| * @summary Clear a provider's keyring secret. The provider entry itself is kept. | |
| */ | |
| export const useClearProviderSecret = <TError = unknown, TContext = unknown>( | |
| options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof clearProviderSecret>>, | |
| TError, | |
| { id: string }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseMutationResult< | |
| Awaited<ReturnType<typeof clearProviderSecret>>, | |
| TError, | |
| { id: string }, | |
| TContext | |
| > => { | |
| return useMutation(getClearProviderSecretMutationOptions(options), queryClient) | |
| } | |
| export const getListDownloadsUrl = () => { | |
| return `/api/v1/downloads` | |
| } | |
| export const listDownloads = async (options?: RequestInit): Promise<ListDownloadsResponse> => { | |
| return fetchApi<ListDownloadsResponse>(getListDownloadsUrl(), { | |
| ...options, | |
| method: 'GET', | |
| }) | |
| } | |
| export const getListDownloadsQueryKey = () => { | |
| return [`/api/v1/downloads`] as const | |
| } | |
| export const getListDownloadsQueryOptions = < | |
| TData = Awaited<ReturnType<typeof listDownloads>>, | |
| TError = unknown, | |
| >(options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listDownloads>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }) => { | |
| const { query: queryOptions, request: requestOptions } = options ?? {} | |
| const queryKey = queryOptions?.queryKey ?? getListDownloadsQueryKey() | |
| const queryFn: QueryFunction<Awaited<ReturnType<typeof listDownloads>>> = ({ signal }) => | |
| listDownloads({ signal, ...requestOptions }) | |
| return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< | |
| Awaited<ReturnType<typeof listDownloads>>, | |
| TError, | |
| TData | |
| > & { queryKey: DataTag<QueryKey, TData, TError> } | |
| } | |
| export type ListDownloadsQueryResult = NonNullable<Awaited<ReturnType<typeof listDownloads>>> | |
| export type ListDownloadsQueryError = unknown | |
| export function useListDownloads< | |
| TData = Awaited<ReturnType<typeof listDownloads>>, | |
| TError = unknown, | |
| >( | |
| options: { | |
| query: Partial<UseQueryOptions<Awaited<ReturnType<typeof listDownloads>>, TError, TData>> & | |
| Pick< | |
| DefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof listDownloads>>, | |
| TError, | |
| Awaited<ReturnType<typeof listDownloads>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useListDownloads< | |
| TData = Awaited<ReturnType<typeof listDownloads>>, | |
| TError = unknown, | |
| >( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listDownloads>>, TError, TData>> & | |
| Pick< | |
| UndefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof listDownloads>>, | |
| TError, | |
| Awaited<ReturnType<typeof listDownloads>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useListDownloads< | |
| TData = Awaited<ReturnType<typeof listDownloads>>, | |
| TError = unknown, | |
| >( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listDownloads>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useListDownloads< | |
| TData = Awaited<ReturnType<typeof listDownloads>>, | |
| TError = unknown, | |
| >( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listDownloads>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } { | |
| const queryOptions = getListDownloadsQueryOptions(options) | |
| const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { | |
| queryKey: DataTag<QueryKey, TData, TError> | |
| } | |
| return { ...query, queryKey: queryOptions.queryKey } | |
| } | |
| export const getStartDownloadUrl = () => { | |
| return `/api/v1/downloads` | |
| } | |
| export const startDownload = async ( | |
| startDownloadRequest: StartDownloadRequest, | |
| options?: RequestInit, | |
| ): Promise<StartDownloadResponse> => { | |
| return fetchApi<StartDownloadResponse>(getStartDownloadUrl(), { | |
| ...options, | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json', ...options?.headers }, | |
| body: JSON.stringify(startDownloadRequest), | |
| }) | |
| } | |
| export const getStartDownloadMutationOptions = <TError = unknown, TContext = unknown>(options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof startDownload>>, | |
| TError, | |
| { data: StartDownloadRequest }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }): UseMutationOptions< | |
| Awaited<ReturnType<typeof startDownload>>, | |
| 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<ReturnType<typeof startDownload>>, | |
| { data: StartDownloadRequest } | |
| > = (props) => { | |
| const { data } = props ?? {} | |
| return startDownload(data, requestOptions) | |
| } | |
| return { mutationFn, ...mutationOptions } | |
| } | |
| export type StartDownloadMutationResult = NonNullable<Awaited<ReturnType<typeof startDownload>>> | |
| export type StartDownloadMutationBody = StartDownloadRequest | |
| export type StartDownloadMutationError = unknown | |
| export const useStartDownload = <TError = unknown, TContext = unknown>( | |
| options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof startDownload>>, | |
| TError, | |
| { data: StartDownloadRequest }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseMutationResult< | |
| Awaited<ReturnType<typeof startDownload>>, | |
| TError, | |
| { data: StartDownloadRequest }, | |
| TContext | |
| > => { | |
| return useMutation(getStartDownloadMutationOptions(options), queryClient) | |
| } | |
| export const getGetEngineCatalogUrl = () => { | |
| return `/api/v1/engines` | |
| } | |
| export const getEngineCatalog = async (options?: RequestInit): Promise<EngineCatalog> => { | |
| return fetchApi<EngineCatalog>(getGetEngineCatalogUrl(), { | |
| ...options, | |
| method: 'GET', | |
| }) | |
| } | |
| export const getGetEngineCatalogQueryKey = () => { | |
| return [`/api/v1/engines`] as const | |
| } | |
| export const getGetEngineCatalogQueryOptions = < | |
| TData = Awaited<ReturnType<typeof getEngineCatalog>>, | |
| TError = unknown, | |
| >(options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getEngineCatalog>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }) => { | |
| const { query: queryOptions, request: requestOptions } = options ?? {} | |
| const queryKey = queryOptions?.queryKey ?? getGetEngineCatalogQueryKey() | |
| const queryFn: QueryFunction<Awaited<ReturnType<typeof getEngineCatalog>>> = ({ signal }) => | |
| getEngineCatalog({ signal, ...requestOptions }) | |
| return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< | |
| Awaited<ReturnType<typeof getEngineCatalog>>, | |
| TError, | |
| TData | |
| > & { queryKey: DataTag<QueryKey, TData, TError> } | |
| } | |
| export type GetEngineCatalogQueryResult = NonNullable<Awaited<ReturnType<typeof getEngineCatalog>>> | |
| export type GetEngineCatalogQueryError = unknown | |
| export function useGetEngineCatalog< | |
| TData = Awaited<ReturnType<typeof getEngineCatalog>>, | |
| TError = unknown, | |
| >( | |
| options: { | |
| query: Partial<UseQueryOptions<Awaited<ReturnType<typeof getEngineCatalog>>, TError, TData>> & | |
| Pick< | |
| DefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof getEngineCatalog>>, | |
| TError, | |
| Awaited<ReturnType<typeof getEngineCatalog>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetEngineCatalog< | |
| TData = Awaited<ReturnType<typeof getEngineCatalog>>, | |
| TError = unknown, | |
| >( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getEngineCatalog>>, TError, TData>> & | |
| Pick< | |
| UndefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof getEngineCatalog>>, | |
| TError, | |
| Awaited<ReturnType<typeof getEngineCatalog>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetEngineCatalog< | |
| TData = Awaited<ReturnType<typeof getEngineCatalog>>, | |
| TError = unknown, | |
| >( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getEngineCatalog>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetEngineCatalog< | |
| TData = Awaited<ReturnType<typeof getEngineCatalog>>, | |
| TError = unknown, | |
| >( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getEngineCatalog>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } { | |
| const queryOptions = getGetEngineCatalogQueryOptions(options) | |
| const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { | |
| queryKey: DataTag<QueryKey, TData, TError> | |
| } | |
| return { ...query, queryKey: queryOptions.queryKey } | |
| } | |
| export const getEventsUrl = () => { | |
| return `/api/v1/events` | |
| } | |
| export const events = async (options?: RequestInit): Promise<AppEvent> => { | |
| return fetchApi<AppEvent>(getEventsUrl(), { | |
| ...options, | |
| method: 'GET', | |
| }) | |
| } | |
| export const getEventsQueryKey = () => { | |
| return [`/api/v1/events`] as const | |
| } | |
| export const getEventsQueryOptions = < | |
| TData = Awaited<ReturnType<typeof events>>, | |
| TError = unknown, | |
| >(options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof events>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }) => { | |
| const { query: queryOptions, request: requestOptions } = options ?? {} | |
| const queryKey = queryOptions?.queryKey ?? getEventsQueryKey() | |
| const queryFn: QueryFunction<Awaited<ReturnType<typeof events>>> = ({ signal }) => | |
| events({ signal, ...requestOptions }) | |
| return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< | |
| Awaited<ReturnType<typeof events>>, | |
| TError, | |
| TData | |
| > & { queryKey: DataTag<QueryKey, TData, TError> } | |
| } | |
| export type EventsQueryResult = NonNullable<Awaited<ReturnType<typeof events>>> | |
| export type EventsQueryError = unknown | |
| export function useEvents<TData = Awaited<ReturnType<typeof events>>, TError = unknown>( | |
| options: { | |
| query: Partial<UseQueryOptions<Awaited<ReturnType<typeof events>>, TError, TData>> & | |
| Pick< | |
| DefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof events>>, | |
| TError, | |
| Awaited<ReturnType<typeof events>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useEvents<TData = Awaited<ReturnType<typeof events>>, TError = unknown>( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof events>>, TError, TData>> & | |
| Pick< | |
| UndefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof events>>, | |
| TError, | |
| Awaited<ReturnType<typeof events>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useEvents<TData = Awaited<ReturnType<typeof events>>, TError = unknown>( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof events>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useEvents<TData = Awaited<ReturnType<typeof events>>, TError = unknown>( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof events>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } { | |
| const queryOptions = getEventsQueryOptions(options) | |
| const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { | |
| queryKey: DataTag<QueryKey, TData, TError> | |
| } | |
| return { ...query, queryKey: queryOptions.queryKey } | |
| } | |
| export const getListFontsUrl = () => { | |
| return `/api/v1/fonts` | |
| } | |
| export const listFonts = async (options?: RequestInit): Promise<FontFaceInfo[]> => { | |
| return fetchApi<FontFaceInfo[]>(getListFontsUrl(), { | |
| ...options, | |
| method: 'GET', | |
| }) | |
| } | |
| export const getListFontsQueryKey = () => { | |
| return [`/api/v1/fonts`] as const | |
| } | |
| export const getListFontsQueryOptions = < | |
| TData = Awaited<ReturnType<typeof listFonts>>, | |
| TError = unknown, | |
| >(options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listFonts>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }) => { | |
| const { query: queryOptions, request: requestOptions } = options ?? {} | |
| const queryKey = queryOptions?.queryKey ?? getListFontsQueryKey() | |
| const queryFn: QueryFunction<Awaited<ReturnType<typeof listFonts>>> = ({ signal }) => | |
| listFonts({ signal, ...requestOptions }) | |
| return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< | |
| Awaited<ReturnType<typeof listFonts>>, | |
| TError, | |
| TData | |
| > & { queryKey: DataTag<QueryKey, TData, TError> } | |
| } | |
| export type ListFontsQueryResult = NonNullable<Awaited<ReturnType<typeof listFonts>>> | |
| export type ListFontsQueryError = unknown | |
| export function useListFonts<TData = Awaited<ReturnType<typeof listFonts>>, TError = unknown>( | |
| options: { | |
| query: Partial<UseQueryOptions<Awaited<ReturnType<typeof listFonts>>, TError, TData>> & | |
| Pick< | |
| DefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof listFonts>>, | |
| TError, | |
| Awaited<ReturnType<typeof listFonts>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useListFonts<TData = Awaited<ReturnType<typeof listFonts>>, TError = unknown>( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listFonts>>, TError, TData>> & | |
| Pick< | |
| UndefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof listFonts>>, | |
| TError, | |
| Awaited<ReturnType<typeof listFonts>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useListFonts<TData = Awaited<ReturnType<typeof listFonts>>, TError = unknown>( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listFonts>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useListFonts<TData = Awaited<ReturnType<typeof listFonts>>, TError = unknown>( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listFonts>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } { | |
| const queryOptions = getListFontsQueryOptions(options) | |
| const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { | |
| queryKey: DataTag<QueryKey, TData, TError> | |
| } | |
| return { ...query, queryKey: queryOptions.queryKey } | |
| } | |
| export const getGetGoogleFontsCatalogUrl = () => { | |
| return `/api/v1/google-fonts` | |
| } | |
| export const getGoogleFontsCatalog = async (options?: RequestInit): Promise<GoogleFontCatalog> => { | |
| return fetchApi<GoogleFontCatalog>(getGetGoogleFontsCatalogUrl(), { | |
| ...options, | |
| method: 'GET', | |
| }) | |
| } | |
| export const getGetGoogleFontsCatalogQueryKey = () => { | |
| return [`/api/v1/google-fonts`] as const | |
| } | |
| export const getGetGoogleFontsCatalogQueryOptions = < | |
| TData = Awaited<ReturnType<typeof getGoogleFontsCatalog>>, | |
| TError = unknown, | |
| >(options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getGoogleFontsCatalog>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }) => { | |
| const { query: queryOptions, request: requestOptions } = options ?? {} | |
| const queryKey = queryOptions?.queryKey ?? getGetGoogleFontsCatalogQueryKey() | |
| const queryFn: QueryFunction<Awaited<ReturnType<typeof getGoogleFontsCatalog>>> = ({ signal }) => | |
| getGoogleFontsCatalog({ signal, ...requestOptions }) | |
| return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< | |
| Awaited<ReturnType<typeof getGoogleFontsCatalog>>, | |
| TError, | |
| TData | |
| > & { queryKey: DataTag<QueryKey, TData, TError> } | |
| } | |
| export type GetGoogleFontsCatalogQueryResult = NonNullable< | |
| Awaited<ReturnType<typeof getGoogleFontsCatalog>> | |
| > | |
| export type GetGoogleFontsCatalogQueryError = unknown | |
| export function useGetGoogleFontsCatalog< | |
| TData = Awaited<ReturnType<typeof getGoogleFontsCatalog>>, | |
| TError = unknown, | |
| >( | |
| options: { | |
| query: Partial< | |
| UseQueryOptions<Awaited<ReturnType<typeof getGoogleFontsCatalog>>, TError, TData> | |
| > & | |
| Pick< | |
| DefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof getGoogleFontsCatalog>>, | |
| TError, | |
| Awaited<ReturnType<typeof getGoogleFontsCatalog>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetGoogleFontsCatalog< | |
| TData = Awaited<ReturnType<typeof getGoogleFontsCatalog>>, | |
| TError = unknown, | |
| >( | |
| options?: { | |
| query?: Partial< | |
| UseQueryOptions<Awaited<ReturnType<typeof getGoogleFontsCatalog>>, TError, TData> | |
| > & | |
| Pick< | |
| UndefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof getGoogleFontsCatalog>>, | |
| TError, | |
| Awaited<ReturnType<typeof getGoogleFontsCatalog>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetGoogleFontsCatalog< | |
| TData = Awaited<ReturnType<typeof getGoogleFontsCatalog>>, | |
| TError = unknown, | |
| >( | |
| options?: { | |
| query?: Partial< | |
| UseQueryOptions<Awaited<ReturnType<typeof getGoogleFontsCatalog>>, TError, TData> | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetGoogleFontsCatalog< | |
| TData = Awaited<ReturnType<typeof getGoogleFontsCatalog>>, | |
| TError = unknown, | |
| >( | |
| options?: { | |
| query?: Partial< | |
| UseQueryOptions<Awaited<ReturnType<typeof getGoogleFontsCatalog>>, TError, TData> | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } { | |
| const queryOptions = getGetGoogleFontsCatalogQueryOptions(options) | |
| const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { | |
| queryKey: DataTag<QueryKey, TData, TError> | |
| } | |
| 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<void> => { | |
| return fetchApi<void>(getFetchGoogleFontUrl(family), { | |
| ...options, | |
| method: 'POST', | |
| }) | |
| } | |
| export const getFetchGoogleFontMutationOptions = <TError = unknown, TContext = unknown>(options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof fetchGoogleFont>>, | |
| TError, | |
| { family: string }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }): UseMutationOptions< | |
| Awaited<ReturnType<typeof fetchGoogleFont>>, | |
| 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<ReturnType<typeof fetchGoogleFont>>, | |
| { family: string } | |
| > = (props) => { | |
| const { family } = props ?? {} | |
| return fetchGoogleFont(family, requestOptions) | |
| } | |
| return { mutationFn, ...mutationOptions } | |
| } | |
| export type FetchGoogleFontMutationResult = NonNullable<Awaited<ReturnType<typeof fetchGoogleFont>>> | |
| export type FetchGoogleFontMutationError = unknown | |
| export const useFetchGoogleFont = <TError = unknown, TContext = unknown>( | |
| options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof fetchGoogleFont>>, | |
| TError, | |
| { family: string }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseMutationResult< | |
| Awaited<ReturnType<typeof fetchGoogleFont>>, | |
| 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<Blob> => { | |
| return fetchApi<Blob>(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<ReturnType<typeof getGoogleFontFile>>, | |
| TError = unknown, | |
| >( | |
| family: string, | |
| file: string, | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getGoogleFontFile>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| ) => { | |
| const { query: queryOptions, request: requestOptions } = options ?? {} | |
| const queryKey = queryOptions?.queryKey ?? getGetGoogleFontFileQueryKey(family, file) | |
| const queryFn: QueryFunction<Awaited<ReturnType<typeof getGoogleFontFile>>> = ({ signal }) => | |
| getGoogleFontFile(family, file, { signal, ...requestOptions }) | |
| return { | |
| queryKey, | |
| queryFn, | |
| enabled: !!(family && file), | |
| gcTime: 300000, | |
| retry: 1, | |
| ...queryOptions, | |
| } as UseQueryOptions<Awaited<ReturnType<typeof getGoogleFontFile>>, TError, TData> & { | |
| queryKey: DataTag<QueryKey, TData, TError> | |
| } | |
| } | |
| export type GetGoogleFontFileQueryResult = NonNullable< | |
| Awaited<ReturnType<typeof getGoogleFontFile>> | |
| > | |
| export type GetGoogleFontFileQueryError = unknown | |
| export function useGetGoogleFontFile< | |
| TData = Awaited<ReturnType<typeof getGoogleFontFile>>, | |
| TError = unknown, | |
| >( | |
| family: string, | |
| file: string, | |
| options: { | |
| query: Partial<UseQueryOptions<Awaited<ReturnType<typeof getGoogleFontFile>>, TError, TData>> & | |
| Pick< | |
| DefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof getGoogleFontFile>>, | |
| TError, | |
| Awaited<ReturnType<typeof getGoogleFontFile>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetGoogleFontFile< | |
| TData = Awaited<ReturnType<typeof getGoogleFontFile>>, | |
| TError = unknown, | |
| >( | |
| family: string, | |
| file: string, | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getGoogleFontFile>>, TError, TData>> & | |
| Pick< | |
| UndefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof getGoogleFontFile>>, | |
| TError, | |
| Awaited<ReturnType<typeof getGoogleFontFile>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetGoogleFontFile< | |
| TData = Awaited<ReturnType<typeof getGoogleFontFile>>, | |
| TError = unknown, | |
| >( | |
| family: string, | |
| file: string, | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getGoogleFontFile>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetGoogleFontFile< | |
| TData = Awaited<ReturnType<typeof getGoogleFontFile>>, | |
| TError = unknown, | |
| >( | |
| family: string, | |
| file: string, | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getGoogleFontFile>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } { | |
| const queryOptions = getGetGoogleFontFileQueryOptions(family, file, options) | |
| const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { | |
| queryKey: DataTag<QueryKey, TData, TError> | |
| } | |
| return { ...query, queryKey: queryOptions.queryKey } | |
| } | |
| export const getApplyCommandUrl = () => { | |
| return `/api/v1/history/apply` | |
| } | |
| export const applyCommand = async (op: Op, options?: RequestInit): Promise<HistoryResult> => { | |
| return fetchApi<HistoryResult>(getApplyCommandUrl(), { | |
| ...options, | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json', ...options?.headers }, | |
| body: JSON.stringify(op), | |
| }) | |
| } | |
| export const getApplyCommandMutationOptions = <TError = unknown, TContext = unknown>(options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof applyCommand>>, | |
| TError, | |
| { data: Op }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }): UseMutationOptions< | |
| Awaited<ReturnType<typeof applyCommand>>, | |
| 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<Awaited<ReturnType<typeof applyCommand>>, { data: Op }> = ( | |
| props, | |
| ) => { | |
| const { data } = props ?? {} | |
| return applyCommand(data, requestOptions) | |
| } | |
| return { mutationFn, ...mutationOptions } | |
| } | |
| export type ApplyCommandMutationResult = NonNullable<Awaited<ReturnType<typeof applyCommand>>> | |
| export type ApplyCommandMutationBody = Op | |
| export type ApplyCommandMutationError = unknown | |
| export const useApplyCommand = <TError = unknown, TContext = unknown>( | |
| options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof applyCommand>>, | |
| TError, | |
| { data: Op }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseMutationResult<Awaited<ReturnType<typeof applyCommand>>, TError, { data: Op }, TContext> => { | |
| return useMutation(getApplyCommandMutationOptions(options), queryClient) | |
| } | |
| export const getRedoUrl = () => { | |
| return `/api/v1/history/redo` | |
| } | |
| export const redo = async (options?: RequestInit): Promise<HistoryResult> => { | |
| return fetchApi<HistoryResult>(getRedoUrl(), { | |
| ...options, | |
| method: 'POST', | |
| }) | |
| } | |
| export const getRedoMutationOptions = <TError = unknown, TContext = unknown>(options?: { | |
| mutation?: UseMutationOptions<Awaited<ReturnType<typeof redo>>, TError, void, TContext> | |
| request?: SecondParameter<typeof fetchApi> | |
| }): UseMutationOptions<Awaited<ReturnType<typeof redo>>, 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<Awaited<ReturnType<typeof redo>>, void> = () => { | |
| return redo(requestOptions) | |
| } | |
| return { mutationFn, ...mutationOptions } | |
| } | |
| export type RedoMutationResult = NonNullable<Awaited<ReturnType<typeof redo>>> | |
| export type RedoMutationError = unknown | |
| export const useRedo = <TError = unknown, TContext = unknown>( | |
| options?: { | |
| mutation?: UseMutationOptions<Awaited<ReturnType<typeof redo>>, TError, void, TContext> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseMutationResult<Awaited<ReturnType<typeof redo>>, TError, void, TContext> => { | |
| return useMutation(getRedoMutationOptions(options), queryClient) | |
| } | |
| export const getUndoUrl = () => { | |
| return `/api/v1/history/undo` | |
| } | |
| export const undo = async (options?: RequestInit): Promise<HistoryResult> => { | |
| return fetchApi<HistoryResult>(getUndoUrl(), { | |
| ...options, | |
| method: 'POST', | |
| }) | |
| } | |
| export const getUndoMutationOptions = <TError = unknown, TContext = unknown>(options?: { | |
| mutation?: UseMutationOptions<Awaited<ReturnType<typeof undo>>, TError, void, TContext> | |
| request?: SecondParameter<typeof fetchApi> | |
| }): UseMutationOptions<Awaited<ReturnType<typeof undo>>, 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<Awaited<ReturnType<typeof undo>>, void> = () => { | |
| return undo(requestOptions) | |
| } | |
| return { mutationFn, ...mutationOptions } | |
| } | |
| export type UndoMutationResult = NonNullable<Awaited<ReturnType<typeof undo>>> | |
| export type UndoMutationError = unknown | |
| export const useUndo = <TError = unknown, TContext = unknown>( | |
| options?: { | |
| mutation?: UseMutationOptions<Awaited<ReturnType<typeof undo>>, TError, void, TContext> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseMutationResult<Awaited<ReturnType<typeof undo>>, TError, void, TContext> => { | |
| return useMutation(getUndoMutationOptions(options), queryClient) | |
| } | |
| export const getGetCatalogUrl = () => { | |
| return `/api/v1/llm/catalog` | |
| } | |
| export const getCatalog = async (options?: RequestInit): Promise<LlmCatalog> => { | |
| return fetchApi<LlmCatalog>(getGetCatalogUrl(), { | |
| ...options, | |
| method: 'GET', | |
| }) | |
| } | |
| export const getGetCatalogQueryKey = () => { | |
| return [`/api/v1/llm/catalog`] as const | |
| } | |
| export const getGetCatalogQueryOptions = < | |
| TData = Awaited<ReturnType<typeof getCatalog>>, | |
| TError = unknown, | |
| >(options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getCatalog>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }) => { | |
| const { query: queryOptions, request: requestOptions } = options ?? {} | |
| const queryKey = queryOptions?.queryKey ?? getGetCatalogQueryKey() | |
| const queryFn: QueryFunction<Awaited<ReturnType<typeof getCatalog>>> = ({ signal }) => | |
| getCatalog({ signal, ...requestOptions }) | |
| return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< | |
| Awaited<ReturnType<typeof getCatalog>>, | |
| TError, | |
| TData | |
| > & { queryKey: DataTag<QueryKey, TData, TError> } | |
| } | |
| export type GetCatalogQueryResult = NonNullable<Awaited<ReturnType<typeof getCatalog>>> | |
| export type GetCatalogQueryError = unknown | |
| export function useGetCatalog<TData = Awaited<ReturnType<typeof getCatalog>>, TError = unknown>( | |
| options: { | |
| query: Partial<UseQueryOptions<Awaited<ReturnType<typeof getCatalog>>, TError, TData>> & | |
| Pick< | |
| DefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof getCatalog>>, | |
| TError, | |
| Awaited<ReturnType<typeof getCatalog>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetCatalog<TData = Awaited<ReturnType<typeof getCatalog>>, TError = unknown>( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getCatalog>>, TError, TData>> & | |
| Pick< | |
| UndefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof getCatalog>>, | |
| TError, | |
| Awaited<ReturnType<typeof getCatalog>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetCatalog<TData = Awaited<ReturnType<typeof getCatalog>>, TError = unknown>( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getCatalog>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetCatalog<TData = Awaited<ReturnType<typeof getCatalog>>, TError = unknown>( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getCatalog>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } { | |
| const queryOptions = getGetCatalogQueryOptions(options) | |
| const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { | |
| queryKey: DataTag<QueryKey, TData, TError> | |
| } | |
| return { ...query, queryKey: queryOptions.queryKey } | |
| } | |
| export const getGetCurrentLlmUrl = () => { | |
| return `/api/v1/llm/current` | |
| } | |
| export const getCurrentLlm = async (options?: RequestInit): Promise<LlmState> => { | |
| return fetchApi<LlmState>(getGetCurrentLlmUrl(), { | |
| ...options, | |
| method: 'GET', | |
| }) | |
| } | |
| export const getGetCurrentLlmQueryKey = () => { | |
| return [`/api/v1/llm/current`] as const | |
| } | |
| export const getGetCurrentLlmQueryOptions = < | |
| TData = Awaited<ReturnType<typeof getCurrentLlm>>, | |
| TError = unknown, | |
| >(options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getCurrentLlm>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }) => { | |
| const { query: queryOptions, request: requestOptions } = options ?? {} | |
| const queryKey = queryOptions?.queryKey ?? getGetCurrentLlmQueryKey() | |
| const queryFn: QueryFunction<Awaited<ReturnType<typeof getCurrentLlm>>> = ({ signal }) => | |
| getCurrentLlm({ signal, ...requestOptions }) | |
| return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< | |
| Awaited<ReturnType<typeof getCurrentLlm>>, | |
| TError, | |
| TData | |
| > & { queryKey: DataTag<QueryKey, TData, TError> } | |
| } | |
| export type GetCurrentLlmQueryResult = NonNullable<Awaited<ReturnType<typeof getCurrentLlm>>> | |
| export type GetCurrentLlmQueryError = unknown | |
| export function useGetCurrentLlm< | |
| TData = Awaited<ReturnType<typeof getCurrentLlm>>, | |
| TError = unknown, | |
| >( | |
| options: { | |
| query: Partial<UseQueryOptions<Awaited<ReturnType<typeof getCurrentLlm>>, TError, TData>> & | |
| Pick< | |
| DefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof getCurrentLlm>>, | |
| TError, | |
| Awaited<ReturnType<typeof getCurrentLlm>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetCurrentLlm< | |
| TData = Awaited<ReturnType<typeof getCurrentLlm>>, | |
| TError = unknown, | |
| >( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getCurrentLlm>>, TError, TData>> & | |
| Pick< | |
| UndefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof getCurrentLlm>>, | |
| TError, | |
| Awaited<ReturnType<typeof getCurrentLlm>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetCurrentLlm< | |
| TData = Awaited<ReturnType<typeof getCurrentLlm>>, | |
| TError = unknown, | |
| >( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getCurrentLlm>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetCurrentLlm< | |
| TData = Awaited<ReturnType<typeof getCurrentLlm>>, | |
| TError = unknown, | |
| >( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getCurrentLlm>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } { | |
| const queryOptions = getGetCurrentLlmQueryOptions(options) | |
| const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { | |
| queryKey: DataTag<QueryKey, TData, TError> | |
| } | |
| return { ...query, queryKey: queryOptions.queryKey } | |
| } | |
| export const getPutCurrentLlmUrl = () => { | |
| return `/api/v1/llm/current` | |
| } | |
| export const putCurrentLlm = async ( | |
| llmLoadRequest: LlmLoadRequest, | |
| options?: RequestInit, | |
| ): Promise<void> => { | |
| return fetchApi<void>(getPutCurrentLlmUrl(), { | |
| ...options, | |
| method: 'PUT', | |
| headers: { 'Content-Type': 'application/json', ...options?.headers }, | |
| body: JSON.stringify(llmLoadRequest), | |
| }) | |
| } | |
| export const getPutCurrentLlmMutationOptions = <TError = unknown, TContext = unknown>(options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof putCurrentLlm>>, | |
| TError, | |
| { data: LlmLoadRequest }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }): UseMutationOptions< | |
| Awaited<ReturnType<typeof putCurrentLlm>>, | |
| 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<ReturnType<typeof putCurrentLlm>>, | |
| { data: LlmLoadRequest } | |
| > = (props) => { | |
| const { data } = props ?? {} | |
| return putCurrentLlm(data, requestOptions) | |
| } | |
| return { mutationFn, ...mutationOptions } | |
| } | |
| export type PutCurrentLlmMutationResult = NonNullable<Awaited<ReturnType<typeof putCurrentLlm>>> | |
| export type PutCurrentLlmMutationBody = LlmLoadRequest | |
| export type PutCurrentLlmMutationError = unknown | |
| export const usePutCurrentLlm = <TError = unknown, TContext = unknown>( | |
| options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof putCurrentLlm>>, | |
| TError, | |
| { data: LlmLoadRequest }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseMutationResult< | |
| Awaited<ReturnType<typeof putCurrentLlm>>, | |
| TError, | |
| { data: LlmLoadRequest }, | |
| TContext | |
| > => { | |
| return useMutation(getPutCurrentLlmMutationOptions(options), queryClient) | |
| } | |
| export const getDeleteCurrentLlmUrl = () => { | |
| return `/api/v1/llm/current` | |
| } | |
| export const deleteCurrentLlm = async (options?: RequestInit): Promise<void> => { | |
| return fetchApi<void>(getDeleteCurrentLlmUrl(), { | |
| ...options, | |
| method: 'DELETE', | |
| }) | |
| } | |
| export const getDeleteCurrentLlmMutationOptions = <TError = unknown, TContext = unknown>(options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof deleteCurrentLlm>>, | |
| TError, | |
| void, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }): UseMutationOptions<Awaited<ReturnType<typeof deleteCurrentLlm>>, 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<Awaited<ReturnType<typeof deleteCurrentLlm>>, void> = () => { | |
| return deleteCurrentLlm(requestOptions) | |
| } | |
| return { mutationFn, ...mutationOptions } | |
| } | |
| export type DeleteCurrentLlmMutationResult = NonNullable< | |
| Awaited<ReturnType<typeof deleteCurrentLlm>> | |
| > | |
| export type DeleteCurrentLlmMutationError = unknown | |
| export const useDeleteCurrentLlm = <TError = unknown, TContext = unknown>( | |
| options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof deleteCurrentLlm>>, | |
| TError, | |
| void, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseMutationResult<Awaited<ReturnType<typeof deleteCurrentLlm>>, TError, void, TContext> => { | |
| return useMutation(getDeleteCurrentLlmMutationOptions(options), queryClient) | |
| } | |
| export const getGetMetaUrl = () => { | |
| return `/api/v1/meta` | |
| } | |
| export const getMeta = async (options?: RequestInit): Promise<MetaInfo> => { | |
| return fetchApi<MetaInfo>(getGetMetaUrl(), { | |
| ...options, | |
| method: 'GET', | |
| }) | |
| } | |
| export const getGetMetaQueryKey = () => { | |
| return [`/api/v1/meta`] as const | |
| } | |
| export const getGetMetaQueryOptions = < | |
| TData = Awaited<ReturnType<typeof getMeta>>, | |
| TError = unknown, | |
| >(options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getMeta>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }) => { | |
| const { query: queryOptions, request: requestOptions } = options ?? {} | |
| const queryKey = queryOptions?.queryKey ?? getGetMetaQueryKey() | |
| const queryFn: QueryFunction<Awaited<ReturnType<typeof getMeta>>> = ({ signal }) => | |
| getMeta({ signal, ...requestOptions }) | |
| return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< | |
| Awaited<ReturnType<typeof getMeta>>, | |
| TError, | |
| TData | |
| > & { queryKey: DataTag<QueryKey, TData, TError> } | |
| } | |
| export type GetMetaQueryResult = NonNullable<Awaited<ReturnType<typeof getMeta>>> | |
| export type GetMetaQueryError = unknown | |
| export function useGetMeta<TData = Awaited<ReturnType<typeof getMeta>>, TError = unknown>( | |
| options: { | |
| query: Partial<UseQueryOptions<Awaited<ReturnType<typeof getMeta>>, TError, TData>> & | |
| Pick< | |
| DefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof getMeta>>, | |
| TError, | |
| Awaited<ReturnType<typeof getMeta>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetMeta<TData = Awaited<ReturnType<typeof getMeta>>, TError = unknown>( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getMeta>>, TError, TData>> & | |
| Pick< | |
| UndefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof getMeta>>, | |
| TError, | |
| Awaited<ReturnType<typeof getMeta>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetMeta<TData = Awaited<ReturnType<typeof getMeta>>, TError = unknown>( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getMeta>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetMeta<TData = Awaited<ReturnType<typeof getMeta>>, TError = unknown>( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getMeta>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } { | |
| const queryOptions = getGetMetaQueryOptions(options) | |
| const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { | |
| queryKey: DataTag<QueryKey, TData, TError> | |
| } | |
| return { ...query, queryKey: queryOptions.queryKey } | |
| } | |
| export const getListOperationsUrl = () => { | |
| return `/api/v1/operations` | |
| } | |
| export const listOperations = async (options?: RequestInit): Promise<ListOperationsResponse> => { | |
| return fetchApi<ListOperationsResponse>(getListOperationsUrl(), { | |
| ...options, | |
| method: 'GET', | |
| }) | |
| } | |
| export const getListOperationsQueryKey = () => { | |
| return [`/api/v1/operations`] as const | |
| } | |
| export const getListOperationsQueryOptions = < | |
| TData = Awaited<ReturnType<typeof listOperations>>, | |
| TError = unknown, | |
| >(options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listOperations>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }) => { | |
| const { query: queryOptions, request: requestOptions } = options ?? {} | |
| const queryKey = queryOptions?.queryKey ?? getListOperationsQueryKey() | |
| const queryFn: QueryFunction<Awaited<ReturnType<typeof listOperations>>> = ({ signal }) => | |
| listOperations({ signal, ...requestOptions }) | |
| return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< | |
| Awaited<ReturnType<typeof listOperations>>, | |
| TError, | |
| TData | |
| > & { queryKey: DataTag<QueryKey, TData, TError> } | |
| } | |
| export type ListOperationsQueryResult = NonNullable<Awaited<ReturnType<typeof listOperations>>> | |
| export type ListOperationsQueryError = unknown | |
| export function useListOperations< | |
| TData = Awaited<ReturnType<typeof listOperations>>, | |
| TError = unknown, | |
| >( | |
| options: { | |
| query: Partial<UseQueryOptions<Awaited<ReturnType<typeof listOperations>>, TError, TData>> & | |
| Pick< | |
| DefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof listOperations>>, | |
| TError, | |
| Awaited<ReturnType<typeof listOperations>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useListOperations< | |
| TData = Awaited<ReturnType<typeof listOperations>>, | |
| TError = unknown, | |
| >( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listOperations>>, TError, TData>> & | |
| Pick< | |
| UndefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof listOperations>>, | |
| TError, | |
| Awaited<ReturnType<typeof listOperations>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useListOperations< | |
| TData = Awaited<ReturnType<typeof listOperations>>, | |
| TError = unknown, | |
| >( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listOperations>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useListOperations< | |
| TData = Awaited<ReturnType<typeof listOperations>>, | |
| TError = unknown, | |
| >( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listOperations>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } { | |
| const queryOptions = getListOperationsQueryOptions(options) | |
| const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { | |
| queryKey: DataTag<QueryKey, TData, TError> | |
| } | |
| return { ...query, queryKey: queryOptions.queryKey } | |
| } | |
| export const getCancelOperationUrl = (id: string) => { | |
| return `/api/v1/operations/${id}` | |
| } | |
| export const cancelOperation = async (id: string, options?: RequestInit): Promise<void> => { | |
| return fetchApi<void>(getCancelOperationUrl(id), { | |
| ...options, | |
| method: 'DELETE', | |
| }) | |
| } | |
| export const getCancelOperationMutationOptions = <TError = unknown, TContext = unknown>(options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof cancelOperation>>, | |
| TError, | |
| { id: string }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }): UseMutationOptions< | |
| Awaited<ReturnType<typeof cancelOperation>>, | |
| 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<ReturnType<typeof cancelOperation>>, | |
| { id: string } | |
| > = (props) => { | |
| const { id } = props ?? {} | |
| return cancelOperation(id, requestOptions) | |
| } | |
| return { mutationFn, ...mutationOptions } | |
| } | |
| export type CancelOperationMutationResult = NonNullable<Awaited<ReturnType<typeof cancelOperation>>> | |
| export type CancelOperationMutationError = unknown | |
| export const useCancelOperation = <TError = unknown, TContext = unknown>( | |
| options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof cancelOperation>>, | |
| TError, | |
| { id: string }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseMutationResult< | |
| Awaited<ReturnType<typeof cancelOperation>>, | |
| TError, | |
| { id: string }, | |
| TContext | |
| > => { | |
| return useMutation(getCancelOperationMutationOptions(options), queryClient) | |
| } | |
| export const getCreatePagesUrl = () => { | |
| return `/api/v1/pages` | |
| } | |
| export const createPages = async (options?: RequestInit): Promise<CreatePagesResponse> => { | |
| return fetchApi<CreatePagesResponse>(getCreatePagesUrl(), { | |
| ...options, | |
| method: 'POST', | |
| }) | |
| } | |
| export const getCreatePagesMutationOptions = <TError = unknown, TContext = unknown>(options?: { | |
| mutation?: UseMutationOptions<Awaited<ReturnType<typeof createPages>>, TError, void, TContext> | |
| request?: SecondParameter<typeof fetchApi> | |
| }): UseMutationOptions<Awaited<ReturnType<typeof createPages>>, 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<Awaited<ReturnType<typeof createPages>>, void> = () => { | |
| return createPages(requestOptions) | |
| } | |
| return { mutationFn, ...mutationOptions } | |
| } | |
| export type CreatePagesMutationResult = NonNullable<Awaited<ReturnType<typeof createPages>>> | |
| export type CreatePagesMutationError = unknown | |
| export const useCreatePages = <TError = unknown, TContext = unknown>( | |
| options?: { | |
| mutation?: UseMutationOptions<Awaited<ReturnType<typeof createPages>>, TError, void, TContext> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseMutationResult<Awaited<ReturnType<typeof createPages>>, 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<CreatePagesResponse> => { | |
| return fetchApi<CreatePagesResponse>(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<ReturnType<typeof createPagesFromPaths>>, | |
| TError, | |
| { data: CreatePagesFromPathsRequest }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }): UseMutationOptions< | |
| Awaited<ReturnType<typeof createPagesFromPaths>>, | |
| 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<ReturnType<typeof createPagesFromPaths>>, | |
| { data: CreatePagesFromPathsRequest } | |
| > = (props) => { | |
| const { data } = props ?? {} | |
| return createPagesFromPaths(data, requestOptions) | |
| } | |
| return { mutationFn, ...mutationOptions } | |
| } | |
| export type CreatePagesFromPathsMutationResult = NonNullable< | |
| Awaited<ReturnType<typeof createPagesFromPaths>> | |
| > | |
| 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 = <TError = unknown, TContext = unknown>( | |
| options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof createPagesFromPaths>>, | |
| TError, | |
| { data: CreatePagesFromPathsRequest }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseMutationResult< | |
| Awaited<ReturnType<typeof createPagesFromPaths>>, | |
| 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<AddImageLayerResponse> => { | |
| return fetchApi<AddImageLayerResponse>(getAddImageLayerUrl(id), { | |
| ...options, | |
| method: 'POST', | |
| }) | |
| } | |
| export const getAddImageLayerMutationOptions = <TError = unknown, TContext = unknown>(options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof addImageLayer>>, | |
| TError, | |
| { id: PageId }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }): UseMutationOptions< | |
| Awaited<ReturnType<typeof addImageLayer>>, | |
| 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<Awaited<ReturnType<typeof addImageLayer>>, { id: PageId }> = ( | |
| props, | |
| ) => { | |
| const { id } = props ?? {} | |
| return addImageLayer(id, requestOptions) | |
| } | |
| return { mutationFn, ...mutationOptions } | |
| } | |
| export type AddImageLayerMutationResult = NonNullable<Awaited<ReturnType<typeof addImageLayer>>> | |
| export type AddImageLayerMutationError = unknown | |
| export const useAddImageLayer = <TError = unknown, TContext = unknown>( | |
| options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof addImageLayer>>, | |
| TError, | |
| { id: PageId }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseMutationResult< | |
| Awaited<ReturnType<typeof addImageLayer>>, | |
| 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<PutMaskResponse> => { | |
| return fetchApi<PutMaskResponse>(getPutMaskUrl(id, role), { | |
| ...options, | |
| method: 'PUT', | |
| headers: { 'Content-Type': 'image/png', ...options?.headers }, | |
| body: JSON.stringify(putMaskBody), | |
| }) | |
| } | |
| export const getPutMaskMutationOptions = <TError = unknown, TContext = unknown>(options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof putMask>>, | |
| TError, | |
| { id: PageId; role: MaskRole; data: Blob }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }): UseMutationOptions< | |
| Awaited<ReturnType<typeof putMask>>, | |
| 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<ReturnType<typeof putMask>>, | |
| { 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<Awaited<ReturnType<typeof putMask>>> | |
| 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 = <TError = unknown, TContext = unknown>( | |
| options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof putMask>>, | |
| TError, | |
| { id: PageId; role: MaskRole; data: Blob }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseMutationResult< | |
| Awaited<ReturnType<typeof putMask>>, | |
| 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<Blob> => { | |
| return fetchApi<Blob>(getGetPageThumbnailUrl(id), { | |
| ...options, | |
| method: 'GET', | |
| }) | |
| } | |
| export const getGetPageThumbnailQueryKey = (id: PageId) => { | |
| return [`/api/v1/pages/${id}/thumbnail`] as const | |
| } | |
| export const getGetPageThumbnailQueryOptions = < | |
| TData = Awaited<ReturnType<typeof getPageThumbnail>>, | |
| TError = unknown, | |
| >( | |
| id: PageId, | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getPageThumbnail>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| ) => { | |
| const { query: queryOptions, request: requestOptions } = options ?? {} | |
| const queryKey = queryOptions?.queryKey ?? getGetPageThumbnailQueryKey(id) | |
| const queryFn: QueryFunction<Awaited<ReturnType<typeof getPageThumbnail>>> = ({ signal }) => | |
| getPageThumbnail(id, { signal, ...requestOptions }) | |
| return { | |
| queryKey, | |
| queryFn, | |
| enabled: !!id, | |
| gcTime: 300000, | |
| retry: 1, | |
| ...queryOptions, | |
| } as UseQueryOptions<Awaited<ReturnType<typeof getPageThumbnail>>, TError, TData> & { | |
| queryKey: DataTag<QueryKey, TData, TError> | |
| } | |
| } | |
| export type GetPageThumbnailQueryResult = NonNullable<Awaited<ReturnType<typeof getPageThumbnail>>> | |
| export type GetPageThumbnailQueryError = unknown | |
| export function useGetPageThumbnail< | |
| TData = Awaited<ReturnType<typeof getPageThumbnail>>, | |
| TError = unknown, | |
| >( | |
| id: PageId, | |
| options: { | |
| query: Partial<UseQueryOptions<Awaited<ReturnType<typeof getPageThumbnail>>, TError, TData>> & | |
| Pick< | |
| DefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof getPageThumbnail>>, | |
| TError, | |
| Awaited<ReturnType<typeof getPageThumbnail>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetPageThumbnail< | |
| TData = Awaited<ReturnType<typeof getPageThumbnail>>, | |
| TError = unknown, | |
| >( | |
| id: PageId, | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getPageThumbnail>>, TError, TData>> & | |
| Pick< | |
| UndefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof getPageThumbnail>>, | |
| TError, | |
| Awaited<ReturnType<typeof getPageThumbnail>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetPageThumbnail< | |
| TData = Awaited<ReturnType<typeof getPageThumbnail>>, | |
| TError = unknown, | |
| >( | |
| id: PageId, | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getPageThumbnail>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetPageThumbnail< | |
| TData = Awaited<ReturnType<typeof getPageThumbnail>>, | |
| TError = unknown, | |
| >( | |
| id: PageId, | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getPageThumbnail>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } { | |
| const queryOptions = getGetPageThumbnailQueryOptions(id, options) | |
| const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { | |
| queryKey: DataTag<QueryKey, TData, TError> | |
| } | |
| return { ...query, queryKey: queryOptions.queryKey } | |
| } | |
| export const getStartPipelineUrl = () => { | |
| return `/api/v1/pipelines` | |
| } | |
| export const startPipeline = async ( | |
| startPipelineRequest: StartPipelineRequest, | |
| options?: RequestInit, | |
| ): Promise<StartPipelineResponse> => { | |
| return fetchApi<StartPipelineResponse>(getStartPipelineUrl(), { | |
| ...options, | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json', ...options?.headers }, | |
| body: JSON.stringify(startPipelineRequest), | |
| }) | |
| } | |
| export const getStartPipelineMutationOptions = <TError = unknown, TContext = unknown>(options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof startPipeline>>, | |
| TError, | |
| { data: StartPipelineRequest }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }): UseMutationOptions< | |
| Awaited<ReturnType<typeof startPipeline>>, | |
| 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<ReturnType<typeof startPipeline>>, | |
| { data: StartPipelineRequest } | |
| > = (props) => { | |
| const { data } = props ?? {} | |
| return startPipeline(data, requestOptions) | |
| } | |
| return { mutationFn, ...mutationOptions } | |
| } | |
| export type StartPipelineMutationResult = NonNullable<Awaited<ReturnType<typeof startPipeline>>> | |
| export type StartPipelineMutationBody = StartPipelineRequest | |
| export type StartPipelineMutationError = unknown | |
| export const useStartPipeline = <TError = unknown, TContext = unknown>( | |
| options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof startPipeline>>, | |
| TError, | |
| { data: StartPipelineRequest }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseMutationResult< | |
| Awaited<ReturnType<typeof startPipeline>>, | |
| TError, | |
| { data: StartPipelineRequest }, | |
| TContext | |
| > => { | |
| return useMutation(getStartPipelineMutationOptions(options), queryClient) | |
| } | |
| export const getListProjectsUrl = () => { | |
| return `/api/v1/projects` | |
| } | |
| export const listProjects = async (options?: RequestInit): Promise<ListProjectsResponse> => { | |
| return fetchApi<ListProjectsResponse>(getListProjectsUrl(), { | |
| ...options, | |
| method: 'GET', | |
| }) | |
| } | |
| export const getListProjectsQueryKey = () => { | |
| return [`/api/v1/projects`] as const | |
| } | |
| export const getListProjectsQueryOptions = < | |
| TData = Awaited<ReturnType<typeof listProjects>>, | |
| TError = unknown, | |
| >(options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listProjects>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }) => { | |
| const { query: queryOptions, request: requestOptions } = options ?? {} | |
| const queryKey = queryOptions?.queryKey ?? getListProjectsQueryKey() | |
| const queryFn: QueryFunction<Awaited<ReturnType<typeof listProjects>>> = ({ signal }) => | |
| listProjects({ signal, ...requestOptions }) | |
| return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< | |
| Awaited<ReturnType<typeof listProjects>>, | |
| TError, | |
| TData | |
| > & { queryKey: DataTag<QueryKey, TData, TError> } | |
| } | |
| export type ListProjectsQueryResult = NonNullable<Awaited<ReturnType<typeof listProjects>>> | |
| export type ListProjectsQueryError = unknown | |
| export function useListProjects<TData = Awaited<ReturnType<typeof listProjects>>, TError = unknown>( | |
| options: { | |
| query: Partial<UseQueryOptions<Awaited<ReturnType<typeof listProjects>>, TError, TData>> & | |
| Pick< | |
| DefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof listProjects>>, | |
| TError, | |
| Awaited<ReturnType<typeof listProjects>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useListProjects<TData = Awaited<ReturnType<typeof listProjects>>, TError = unknown>( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listProjects>>, TError, TData>> & | |
| Pick< | |
| UndefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof listProjects>>, | |
| TError, | |
| Awaited<ReturnType<typeof listProjects>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useListProjects<TData = Awaited<ReturnType<typeof listProjects>>, TError = unknown>( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listProjects>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useListProjects<TData = Awaited<ReturnType<typeof listProjects>>, TError = unknown>( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listProjects>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } { | |
| const queryOptions = getListProjectsQueryOptions(options) | |
| const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { | |
| queryKey: DataTag<QueryKey, TData, TError> | |
| } | |
| return { ...query, queryKey: queryOptions.queryKey } | |
| } | |
| export const getCreateProjectUrl = () => { | |
| return `/api/v1/projects` | |
| } | |
| export const createProject = async ( | |
| createProjectRequest: CreateProjectRequest, | |
| options?: RequestInit, | |
| ): Promise<ProjectSummary> => { | |
| return fetchApi<ProjectSummary>(getCreateProjectUrl(), { | |
| ...options, | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json', ...options?.headers }, | |
| body: JSON.stringify(createProjectRequest), | |
| }) | |
| } | |
| export const getCreateProjectMutationOptions = <TError = unknown, TContext = unknown>(options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof createProject>>, | |
| TError, | |
| { data: CreateProjectRequest }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }): UseMutationOptions< | |
| Awaited<ReturnType<typeof createProject>>, | |
| 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<ReturnType<typeof createProject>>, | |
| { data: CreateProjectRequest } | |
| > = (props) => { | |
| const { data } = props ?? {} | |
| return createProject(data, requestOptions) | |
| } | |
| return { mutationFn, ...mutationOptions } | |
| } | |
| export type CreateProjectMutationResult = NonNullable<Awaited<ReturnType<typeof createProject>>> | |
| export type CreateProjectMutationBody = CreateProjectRequest | |
| export type CreateProjectMutationError = unknown | |
| export const useCreateProject = <TError = unknown, TContext = unknown>( | |
| options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof createProject>>, | |
| TError, | |
| { data: CreateProjectRequest }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseMutationResult< | |
| Awaited<ReturnType<typeof createProject>>, | |
| 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<ProjectSummary> => { | |
| return fetchApi<ProjectSummary>(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<ReturnType<typeof putCurrentProject>>, | |
| TError, | |
| { data: OpenProjectRequest }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }): UseMutationOptions< | |
| Awaited<ReturnType<typeof putCurrentProject>>, | |
| 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<ReturnType<typeof putCurrentProject>>, | |
| { data: OpenProjectRequest } | |
| > = (props) => { | |
| const { data } = props ?? {} | |
| return putCurrentProject(data, requestOptions) | |
| } | |
| return { mutationFn, ...mutationOptions } | |
| } | |
| export type PutCurrentProjectMutationResult = NonNullable< | |
| Awaited<ReturnType<typeof putCurrentProject>> | |
| > | |
| export type PutCurrentProjectMutationBody = OpenProjectRequest | |
| export type PutCurrentProjectMutationError = unknown | |
| export const usePutCurrentProject = <TError = unknown, TContext = unknown>( | |
| options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof putCurrentProject>>, | |
| TError, | |
| { data: OpenProjectRequest }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseMutationResult< | |
| Awaited<ReturnType<typeof putCurrentProject>>, | |
| TError, | |
| { data: OpenProjectRequest }, | |
| TContext | |
| > => { | |
| return useMutation(getPutCurrentProjectMutationOptions(options), queryClient) | |
| } | |
| export const getDeleteCurrentProjectUrl = () => { | |
| return `/api/v1/projects/current` | |
| } | |
| export const deleteCurrentProject = async (options?: RequestInit): Promise<void> => { | |
| return fetchApi<void>(getDeleteCurrentProjectUrl(), { | |
| ...options, | |
| method: 'DELETE', | |
| }) | |
| } | |
| export const getDeleteCurrentProjectMutationOptions = < | |
| TError = unknown, | |
| TContext = unknown, | |
| >(options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof deleteCurrentProject>>, | |
| TError, | |
| void, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }): UseMutationOptions< | |
| Awaited<ReturnType<typeof deleteCurrentProject>>, | |
| 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<ReturnType<typeof deleteCurrentProject>>, | |
| void | |
| > = () => { | |
| return deleteCurrentProject(requestOptions) | |
| } | |
| return { mutationFn, ...mutationOptions } | |
| } | |
| export type DeleteCurrentProjectMutationResult = NonNullable< | |
| Awaited<ReturnType<typeof deleteCurrentProject>> | |
| > | |
| export type DeleteCurrentProjectMutationError = unknown | |
| export const useDeleteCurrentProject = <TError = unknown, TContext = unknown>( | |
| options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof deleteCurrentProject>>, | |
| TError, | |
| void, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseMutationResult<Awaited<ReturnType<typeof deleteCurrentProject>>, 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<Blob> => { | |
| return fetchApi<Blob>(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<ReturnType<typeof exportCurrentProject>>, | |
| TError, | |
| { data: ExportProjectRequest }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }): UseMutationOptions< | |
| Awaited<ReturnType<typeof exportCurrentProject>>, | |
| 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<ReturnType<typeof exportCurrentProject>>, | |
| { data: ExportProjectRequest } | |
| > = (props) => { | |
| const { data } = props ?? {} | |
| return exportCurrentProject(data, requestOptions) | |
| } | |
| return { mutationFn, ...mutationOptions } | |
| } | |
| export type ExportCurrentProjectMutationResult = NonNullable< | |
| Awaited<ReturnType<typeof exportCurrentProject>> | |
| > | |
| export type ExportCurrentProjectMutationBody = ExportProjectRequest | |
| export type ExportCurrentProjectMutationError = unknown | |
| export const useExportCurrentProject = <TError = unknown, TContext = unknown>( | |
| options?: { | |
| mutation?: UseMutationOptions< | |
| Awaited<ReturnType<typeof exportCurrentProject>>, | |
| TError, | |
| { data: ExportProjectRequest }, | |
| TContext | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseMutationResult< | |
| Awaited<ReturnType<typeof exportCurrentProject>>, | |
| TError, | |
| { data: ExportProjectRequest }, | |
| TContext | |
| > => { | |
| return useMutation(getExportCurrentProjectMutationOptions(options), queryClient) | |
| } | |
| export const getImportProjectUrl = () => { | |
| return `/api/v1/projects/import` | |
| } | |
| export const importProject = async (options?: RequestInit): Promise<ProjectSummary> => { | |
| return fetchApi<ProjectSummary>(getImportProjectUrl(), { | |
| ...options, | |
| method: 'POST', | |
| }) | |
| } | |
| export const getImportProjectMutationOptions = <TError = unknown, TContext = unknown>(options?: { | |
| mutation?: UseMutationOptions<Awaited<ReturnType<typeof importProject>>, TError, void, TContext> | |
| request?: SecondParameter<typeof fetchApi> | |
| }): UseMutationOptions<Awaited<ReturnType<typeof importProject>>, 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<Awaited<ReturnType<typeof importProject>>, void> = () => { | |
| return importProject(requestOptions) | |
| } | |
| return { mutationFn, ...mutationOptions } | |
| } | |
| export type ImportProjectMutationResult = NonNullable<Awaited<ReturnType<typeof importProject>>> | |
| export type ImportProjectMutationError = unknown | |
| export const useImportProject = <TError = unknown, TContext = unknown>( | |
| options?: { | |
| mutation?: UseMutationOptions<Awaited<ReturnType<typeof importProject>>, TError, void, TContext> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseMutationResult<Awaited<ReturnType<typeof importProject>>, TError, void, TContext> => { | |
| return useMutation(getImportProjectMutationOptions(options), queryClient) | |
| } | |
| export const getGetSceneBinUrl = () => { | |
| return `/api/v1/scene.bin` | |
| } | |
| export const getSceneBin = async (options?: RequestInit): Promise<Blob> => { | |
| return fetchApi<Blob>(getGetSceneBinUrl(), { | |
| ...options, | |
| method: 'GET', | |
| }) | |
| } | |
| export const getGetSceneBinQueryKey = () => { | |
| return [`/api/v1/scene.bin`] as const | |
| } | |
| export const getGetSceneBinQueryOptions = < | |
| TData = Awaited<ReturnType<typeof getSceneBin>>, | |
| TError = unknown, | |
| >(options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getSceneBin>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }) => { | |
| const { query: queryOptions, request: requestOptions } = options ?? {} | |
| const queryKey = queryOptions?.queryKey ?? getGetSceneBinQueryKey() | |
| const queryFn: QueryFunction<Awaited<ReturnType<typeof getSceneBin>>> = ({ signal }) => | |
| getSceneBin({ signal, ...requestOptions }) | |
| return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< | |
| Awaited<ReturnType<typeof getSceneBin>>, | |
| TError, | |
| TData | |
| > & { queryKey: DataTag<QueryKey, TData, TError> } | |
| } | |
| export type GetSceneBinQueryResult = NonNullable<Awaited<ReturnType<typeof getSceneBin>>> | |
| export type GetSceneBinQueryError = unknown | |
| export function useGetSceneBin<TData = Awaited<ReturnType<typeof getSceneBin>>, TError = unknown>( | |
| options: { | |
| query: Partial<UseQueryOptions<Awaited<ReturnType<typeof getSceneBin>>, TError, TData>> & | |
| Pick< | |
| DefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof getSceneBin>>, | |
| TError, | |
| Awaited<ReturnType<typeof getSceneBin>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetSceneBin<TData = Awaited<ReturnType<typeof getSceneBin>>, TError = unknown>( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getSceneBin>>, TError, TData>> & | |
| Pick< | |
| UndefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof getSceneBin>>, | |
| TError, | |
| Awaited<ReturnType<typeof getSceneBin>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetSceneBin<TData = Awaited<ReturnType<typeof getSceneBin>>, TError = unknown>( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getSceneBin>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetSceneBin<TData = Awaited<ReturnType<typeof getSceneBin>>, TError = unknown>( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getSceneBin>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } { | |
| const queryOptions = getGetSceneBinQueryOptions(options) | |
| const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { | |
| queryKey: DataTag<QueryKey, TData, TError> | |
| } | |
| return { ...query, queryKey: queryOptions.queryKey } | |
| } | |
| export const getGetSceneJsonUrl = () => { | |
| return `/api/v1/scene.json` | |
| } | |
| export const getSceneJson = async (options?: RequestInit): Promise<SceneSnapshot> => { | |
| return fetchApi<SceneSnapshot>(getGetSceneJsonUrl(), { | |
| ...options, | |
| method: 'GET', | |
| }) | |
| } | |
| export const getGetSceneJsonQueryKey = () => { | |
| return [`/api/v1/scene.json`] as const | |
| } | |
| export const getGetSceneJsonQueryOptions = < | |
| TData = Awaited<ReturnType<typeof getSceneJson>>, | |
| TError = unknown, | |
| >(options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getSceneJson>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }) => { | |
| const { query: queryOptions, request: requestOptions } = options ?? {} | |
| const queryKey = queryOptions?.queryKey ?? getGetSceneJsonQueryKey() | |
| const queryFn: QueryFunction<Awaited<ReturnType<typeof getSceneJson>>> = ({ signal }) => | |
| getSceneJson({ signal, ...requestOptions }) | |
| return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< | |
| Awaited<ReturnType<typeof getSceneJson>>, | |
| TError, | |
| TData | |
| > & { queryKey: DataTag<QueryKey, TData, TError> } | |
| } | |
| export type GetSceneJsonQueryResult = NonNullable<Awaited<ReturnType<typeof getSceneJson>>> | |
| export type GetSceneJsonQueryError = unknown | |
| export function useGetSceneJson<TData = Awaited<ReturnType<typeof getSceneJson>>, TError = unknown>( | |
| options: { | |
| query: Partial<UseQueryOptions<Awaited<ReturnType<typeof getSceneJson>>, TError, TData>> & | |
| Pick< | |
| DefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof getSceneJson>>, | |
| TError, | |
| Awaited<ReturnType<typeof getSceneJson>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetSceneJson<TData = Awaited<ReturnType<typeof getSceneJson>>, TError = unknown>( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getSceneJson>>, TError, TData>> & | |
| Pick< | |
| UndefinedInitialDataOptions< | |
| Awaited<ReturnType<typeof getSceneJson>>, | |
| TError, | |
| Awaited<ReturnType<typeof getSceneJson>> | |
| >, | |
| 'initialData' | |
| > | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetSceneJson<TData = Awaited<ReturnType<typeof getSceneJson>>, TError = unknown>( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getSceneJson>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } | |
| export function useGetSceneJson<TData = Awaited<ReturnType<typeof getSceneJson>>, TError = unknown>( | |
| options?: { | |
| query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getSceneJson>>, TError, TData>> | |
| request?: SecondParameter<typeof fetchApi> | |
| }, | |
| queryClient?: QueryClient, | |
| ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } { | |
| const queryOptions = getGetSceneJsonQueryOptions(options) | |
| const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { | |
| queryKey: DataTag<QueryKey, TData, TError> | |
| } | |
| return { ...query, queryKey: queryOptions.queryKey } | |
| } | |