// This file is auto-generated by @hey-api/openapi-ts import { type DefaultError, queryOptions, type UseMutationOptions } from "@tanstack/react-query"; import { client } from "../client.gen"; import { browseFilesystem, changePassword, createBackupSchedule, createRepository, createVolume, deleteBackupSchedule, deleteRepository, deleteVolume, doctorRepository, downloadResticPassword, getBackupSchedule, getBackupScheduleForVolume, getContainersUsingVolume, getMe, getRepository, getSnapshotDetails, getStatus, getSystemInfo, getVolume, healthCheckVolume, listBackupSchedules, listFiles, listRcloneRemotes, listRepositories, listSnapshotFiles, listSnapshots, listVolumes, login, logout, mountVolume, type Options, register, restoreSnapshot, runBackupNow, stopBackup, testConnection, unmountVolume, updateBackupSchedule, updateVolume, } from "../sdk.gen"; import type { BrowseFilesystemData, BrowseFilesystemResponse, ChangePasswordData, ChangePasswordResponse, CreateBackupScheduleData, CreateBackupScheduleResponse, CreateRepositoryData, CreateRepositoryResponse, CreateVolumeData, CreateVolumeResponse, DeleteBackupScheduleData, DeleteBackupScheduleResponse, DeleteRepositoryData, DeleteRepositoryResponse, DeleteVolumeData, DeleteVolumeResponse, DoctorRepositoryData, DoctorRepositoryResponse, DownloadResticPasswordData, DownloadResticPasswordResponse, GetBackupScheduleData, GetBackupScheduleForVolumeData, GetBackupScheduleForVolumeResponse, GetBackupScheduleResponse, GetContainersUsingVolumeData, GetContainersUsingVolumeResponse, GetMeData, GetMeResponse, GetRepositoryData, GetRepositoryResponse, GetSnapshotDetailsData, GetSnapshotDetailsResponse, GetStatusData, GetStatusResponse, GetSystemInfoData, GetSystemInfoResponse, GetVolumeData, GetVolumeResponse, HealthCheckVolumeData, HealthCheckVolumeResponse, ListBackupSchedulesData, ListBackupSchedulesResponse, ListFilesData, ListFilesResponse, ListRcloneRemotesData, ListRcloneRemotesResponse, ListRepositoriesData, ListRepositoriesResponse, ListSnapshotFilesData, ListSnapshotFilesResponse, ListSnapshotsData, ListSnapshotsResponse, ListVolumesData, ListVolumesResponse, LoginData, LoginResponse, LogoutData, LogoutResponse, MountVolumeData, MountVolumeResponse, RegisterData, RegisterResponse, RestoreSnapshotData, RestoreSnapshotResponse, RunBackupNowData, RunBackupNowResponse, StopBackupData, StopBackupResponse, TestConnectionData, TestConnectionResponse, UnmountVolumeData, UnmountVolumeResponse, UpdateBackupScheduleData, UpdateBackupScheduleResponse, UpdateVolumeData, UpdateVolumeResponse, } from "../types.gen"; /** * Register a new user */ export const registerMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await register({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; /** * Login with username and password */ export const loginMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await login({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; /** * Logout current user */ export const logoutMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await logout({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export type QueryKey = [ Pick & { _id: string; _infinite?: boolean; tags?: ReadonlyArray; }, ]; const createQueryKey = ( id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray, ): [QueryKey[0]] => { const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl, } as QueryKey[0]; if (infinite) { params._infinite = infinite; } if (tags) { params.tags = tags; } if (options?.body) { params.body = options.body; } if (options?.headers) { params.headers = options.headers; } if (options?.path) { params.path = options.path; } if (options?.query) { params.query = options.query; } return [params]; }; export const getMeQueryKey = (options?: Options) => createQueryKey("getMe", options); /** * Get current authenticated user */ export const getMeOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getMe({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: getMeQueryKey(options), }); export const getStatusQueryKey = (options?: Options) => createQueryKey("getStatus", options); /** * Get authentication system status */ export const getStatusOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getStatus({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: getStatusQueryKey(options), }); /** * Change current user password */ export const changePasswordMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await changePassword({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const listVolumesQueryKey = (options?: Options) => createQueryKey("listVolumes", options); /** * List all volumes */ export const listVolumesOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await listVolumes({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: listVolumesQueryKey(options), }); /** * Create a new volume */ export const createVolumeMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await createVolume({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; /** * Test connection to backend */ export const testConnectionMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await testConnection({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; /** * Delete a volume */ export const deleteVolumeMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await deleteVolume({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const getVolumeQueryKey = (options: Options) => createQueryKey("getVolume", options); /** * Get a volume by name */ export const getVolumeOptions = (options: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getVolume({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: getVolumeQueryKey(options), }); /** * Update a volume's configuration */ export const updateVolumeMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await updateVolume({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const getContainersUsingVolumeQueryKey = (options: Options) => createQueryKey("getContainersUsingVolume", options); /** * Get containers using a volume by name */ export const getContainersUsingVolumeOptions = (options: Options) => queryOptions< GetContainersUsingVolumeResponse, DefaultError, GetContainersUsingVolumeResponse, ReturnType >({ queryFn: async ({ queryKey, signal }) => { const { data } = await getContainersUsingVolume({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: getContainersUsingVolumeQueryKey(options), }); /** * Mount a volume */ export const mountVolumeMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await mountVolume({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; /** * Unmount a volume */ export const unmountVolumeMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await unmountVolume({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; /** * Perform a health check on a volume */ export const healthCheckVolumeMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await healthCheckVolume({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const listFilesQueryKey = (options: Options) => createQueryKey("listFiles", options); /** * List files in a volume directory */ export const listFilesOptions = (options: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await listFiles({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: listFilesQueryKey(options), }); export const browseFilesystemQueryKey = (options?: Options) => createQueryKey("browseFilesystem", options); /** * Browse directories on the host filesystem */ export const browseFilesystemOptions = (options?: Options) => queryOptions< BrowseFilesystemResponse, DefaultError, BrowseFilesystemResponse, ReturnType >({ queryFn: async ({ queryKey, signal }) => { const { data } = await browseFilesystem({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: browseFilesystemQueryKey(options), }); export const listRepositoriesQueryKey = (options?: Options) => createQueryKey("listRepositories", options); /** * List all repositories */ export const listRepositoriesOptions = (options?: Options) => queryOptions< ListRepositoriesResponse, DefaultError, ListRepositoriesResponse, ReturnType >({ queryFn: async ({ queryKey, signal }) => { const { data } = await listRepositories({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: listRepositoriesQueryKey(options), }); /** * Create a new restic repository */ export const createRepositoryMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await createRepository({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const listRcloneRemotesQueryKey = (options?: Options) => createQueryKey("listRcloneRemotes", options); /** * List all configured rclone remotes on the host system */ export const listRcloneRemotesOptions = (options?: Options) => queryOptions< ListRcloneRemotesResponse, DefaultError, ListRcloneRemotesResponse, ReturnType >({ queryFn: async ({ queryKey, signal }) => { const { data } = await listRcloneRemotes({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: listRcloneRemotesQueryKey(options), }); /** * Delete a repository */ export const deleteRepositoryMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await deleteRepository({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const getRepositoryQueryKey = (options: Options) => createQueryKey("getRepository", options); /** * Get a single repository by name */ export const getRepositoryOptions = (options: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getRepository({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: getRepositoryQueryKey(options), }); export const listSnapshotsQueryKey = (options: Options) => createQueryKey("listSnapshots", options); /** * List all snapshots in a repository */ export const listSnapshotsOptions = (options: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await listSnapshots({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: listSnapshotsQueryKey(options), }); export const getSnapshotDetailsQueryKey = (options: Options) => createQueryKey("getSnapshotDetails", options); /** * Get details of a specific snapshot */ export const getSnapshotDetailsOptions = (options: Options) => queryOptions< GetSnapshotDetailsResponse, DefaultError, GetSnapshotDetailsResponse, ReturnType >({ queryFn: async ({ queryKey, signal }) => { const { data } = await getSnapshotDetails({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: getSnapshotDetailsQueryKey(options), }); export const listSnapshotFilesQueryKey = (options: Options) => createQueryKey("listSnapshotFiles", options); /** * List files and directories in a snapshot */ export const listSnapshotFilesOptions = (options: Options) => queryOptions< ListSnapshotFilesResponse, DefaultError, ListSnapshotFilesResponse, ReturnType >({ queryFn: async ({ queryKey, signal }) => { const { data } = await listSnapshotFiles({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: listSnapshotFilesQueryKey(options), }); /** * Restore a snapshot to a target path on the filesystem */ export const restoreSnapshotMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await restoreSnapshot({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; /** * Run doctor operations on a repository to fix common issues (unlock, check, repair index). Use this when the repository is locked or has errors. */ export const doctorRepositoryMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await doctorRepository({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const listBackupSchedulesQueryKey = (options?: Options) => createQueryKey("listBackupSchedules", options); /** * List all backup schedules */ export const listBackupSchedulesOptions = (options?: Options) => queryOptions< ListBackupSchedulesResponse, DefaultError, ListBackupSchedulesResponse, ReturnType >({ queryFn: async ({ queryKey, signal }) => { const { data } = await listBackupSchedules({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: listBackupSchedulesQueryKey(options), }); /** * Create a new backup schedule for a volume */ export const createBackupScheduleMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions< CreateBackupScheduleResponse, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await createBackupSchedule({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; /** * Delete a backup schedule */ export const deleteBackupScheduleMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions< DeleteBackupScheduleResponse, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await deleteBackupSchedule({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const getBackupScheduleQueryKey = (options: Options) => createQueryKey("getBackupSchedule", options); /** * Get a backup schedule by ID */ export const getBackupScheduleOptions = (options: Options) => queryOptions< GetBackupScheduleResponse, DefaultError, GetBackupScheduleResponse, ReturnType >({ queryFn: async ({ queryKey, signal }) => { const { data } = await getBackupSchedule({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: getBackupScheduleQueryKey(options), }); /** * Update a backup schedule */ export const updateBackupScheduleMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions< UpdateBackupScheduleResponse, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await updateBackupSchedule({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const getBackupScheduleForVolumeQueryKey = (options: Options) => createQueryKey("getBackupScheduleForVolume", options); /** * Get a backup schedule for a specific volume */ export const getBackupScheduleForVolumeOptions = (options: Options) => queryOptions< GetBackupScheduleForVolumeResponse, DefaultError, GetBackupScheduleForVolumeResponse, ReturnType >({ queryFn: async ({ queryKey, signal }) => { const { data } = await getBackupScheduleForVolume({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: getBackupScheduleForVolumeQueryKey(options), }); /** * Trigger a backup immediately for a schedule */ export const runBackupNowMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await runBackupNow({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; /** * Stop a backup that is currently in progress */ export const stopBackupMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await stopBackup({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const getSystemInfoQueryKey = (options?: Options) => createQueryKey("getSystemInfo", options); /** * Get system information including available capabilities */ export const getSystemInfoOptions = (options?: Options) => queryOptions>({ queryFn: async ({ queryKey, signal }) => { const { data } = await getSystemInfo({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: getSystemInfoQueryKey(options), }); /** * Download the Restic password file for backup recovery. Requires password re-authentication. */ export const downloadResticPasswordMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions< DownloadResticPasswordResponse, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await downloadResticPassword({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; };