// 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, createBackupSchedule, createNotificationDestination, createRepository, createVolume, deleteBackupSchedule, deleteNotificationDestination, deleteRepository, deleteSnapshot, deleteSnapshots, deleteVolume, doctorRepository, downloadResticPassword, getBackupSchedule, getBackupScheduleForVolume, getMirrorCompatibility, getNotificationDestination, getRepository, getScheduleMirrors, getScheduleNotifications, getSnapshotDetails, getStatus, getSystemInfo, getUpdates, getVolume, healthCheckVolume, listBackupSchedules, listFiles, listNotificationDestinations, listRcloneRemotes, listRepositories, listSnapshotFiles, listSnapshots, listVolumes, mountVolume, type Options, reorderBackupSchedules, restoreSnapshot, runBackupNow, runForget, stopBackup, tagSnapshots, testConnection, testNotificationDestination, unmountVolume, updateBackupSchedule, updateNotificationDestination, updateRepository, updateScheduleMirrors, updateScheduleNotifications, updateVolume, } from "../sdk.gen"; import type { BrowseFilesystemData, BrowseFilesystemResponse, CreateBackupScheduleData, CreateBackupScheduleResponse, CreateNotificationDestinationData, CreateNotificationDestinationResponse, CreateRepositoryData, CreateRepositoryResponse, CreateVolumeData, CreateVolumeResponse, DeleteBackupScheduleData, DeleteBackupScheduleResponse, DeleteNotificationDestinationData, DeleteNotificationDestinationResponse, DeleteRepositoryData, DeleteRepositoryResponse, DeleteSnapshotData, DeleteSnapshotResponse, DeleteSnapshotsData, DeleteSnapshotsResponse, DeleteVolumeData, DeleteVolumeResponse, DoctorRepositoryData, DoctorRepositoryResponse, DownloadResticPasswordData, DownloadResticPasswordResponse, GetBackupScheduleData, GetBackupScheduleForVolumeData, GetBackupScheduleForVolumeResponse, GetBackupScheduleResponse, GetMirrorCompatibilityData, GetMirrorCompatibilityResponse, GetNotificationDestinationData, GetNotificationDestinationResponse, GetRepositoryData, GetRepositoryResponse, GetScheduleMirrorsData, GetScheduleMirrorsResponse, GetScheduleNotificationsData, GetScheduleNotificationsResponse, GetSnapshotDetailsData, GetSnapshotDetailsResponse, GetStatusData, GetStatusResponse, GetSystemInfoData, GetSystemInfoResponse, GetUpdatesData, GetUpdatesResponse, GetVolumeData, GetVolumeResponse, HealthCheckVolumeData, HealthCheckVolumeResponse, ListBackupSchedulesData, ListBackupSchedulesResponse, ListFilesData, ListFilesResponse, ListNotificationDestinationsData, ListNotificationDestinationsResponse, ListRcloneRemotesData, ListRcloneRemotesResponse, ListRepositoriesData, ListRepositoriesResponse, ListSnapshotFilesData, ListSnapshotFilesResponse, ListSnapshotsData, ListSnapshotsResponse, ListVolumesData, ListVolumesResponse, MountVolumeData, MountVolumeResponse, ReorderBackupSchedulesData, ReorderBackupSchedulesResponse, RestoreSnapshotData, RestoreSnapshotResponse, RunBackupNowData, RunBackupNowResponse, RunForgetData, RunForgetResponse, StopBackupData, StopBackupResponse, TagSnapshotsData, TagSnapshotsResponse, TestConnectionData, TestConnectionResponse, TestNotificationDestinationData, TestNotificationDestinationResponse, UnmountVolumeData, UnmountVolumeResponse, UpdateBackupScheduleData, UpdateBackupScheduleResponse, UpdateNotificationDestinationData, UpdateNotificationDestinationResponse, UpdateRepositoryData, UpdateRepositoryResponse, UpdateScheduleMirrorsData, UpdateScheduleMirrorsResponse, UpdateScheduleNotificationsData, UpdateScheduleNotificationsResponse, UpdateVolumeData, UpdateVolumeResponse, } from "../types.gen"; 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 getStatusQueryKey = (options?: Options) => createQueryKey("getStatus", options); /** * Get authentication system status */ export const getStatusOptions = (options?: Options) => queryOptions< GetStatusResponse, DefaultError, GetStatusResponse, ReturnType >({ queryFn: async ({ queryKey, signal }) => { const { data } = await getStatus({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: getStatusQueryKey(options), }); export const listVolumesQueryKey = (options?: Options) => createQueryKey("listVolumes", options); /** * List all volumes */ export const listVolumesOptions = (options?: Options) => queryOptions< ListVolumesResponse, DefaultError, ListVolumesResponse, ReturnType >({ 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< CreateVolumeResponse, DefaultError, Options > => { const mutationOptions: UseMutationOptions< CreateVolumeResponse, DefaultError, Options > = { 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< TestConnectionResponse, DefaultError, Options > => { const mutationOptions: UseMutationOptions< TestConnectionResponse, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await testConnection({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; /** * Delete a volume */ export const deleteVolumeMutation = ( options?: Partial>, ): UseMutationOptions< DeleteVolumeResponse, DefaultError, Options > => { const mutationOptions: UseMutationOptions< DeleteVolumeResponse, DefaultError, Options > = { 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< GetVolumeResponse, DefaultError, GetVolumeResponse, ReturnType >({ 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< UpdateVolumeResponse, DefaultError, Options > => { const mutationOptions: UseMutationOptions< UpdateVolumeResponse, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await updateVolume({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; /** * Mount a volume */ export const mountVolumeMutation = ( options?: Partial>, ): UseMutationOptions< MountVolumeResponse, DefaultError, Options > => { const mutationOptions: UseMutationOptions< MountVolumeResponse, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await mountVolume({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; /** * Unmount a volume */ export const unmountVolumeMutation = ( options?: Partial>, ): UseMutationOptions< UnmountVolumeResponse, DefaultError, Options > => { const mutationOptions: UseMutationOptions< UnmountVolumeResponse, DefaultError, Options > = { 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< HealthCheckVolumeResponse, DefaultError, Options > => { const mutationOptions: UseMutationOptions< HealthCheckVolumeResponse, DefaultError, Options > = { 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< ListFilesResponse, DefaultError, ListFilesResponse, ReturnType >({ 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< CreateRepositoryResponse, DefaultError, Options > => { const mutationOptions: UseMutationOptions< CreateRepositoryResponse, DefaultError, Options > = { 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< DeleteRepositoryResponse, DefaultError, Options > => { const mutationOptions: UseMutationOptions< DeleteRepositoryResponse, DefaultError, Options > = { 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 ID */ export const getRepositoryOptions = (options: Options) => queryOptions< GetRepositoryResponse, DefaultError, GetRepositoryResponse, ReturnType >({ queryFn: async ({ queryKey, signal }) => { const { data } = await getRepository({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: getRepositoryQueryKey(options), }); /** * Update a repository's name or settings */ export const updateRepositoryMutation = ( options?: Partial>, ): UseMutationOptions< UpdateRepositoryResponse, DefaultError, Options > => { const mutationOptions: UseMutationOptions< UpdateRepositoryResponse, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await updateRepository({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; /** * Delete multiple snapshots from a repository */ export const deleteSnapshotsMutation = ( options?: Partial>, ): UseMutationOptions< DeleteSnapshotsResponse, DefaultError, Options > => { const mutationOptions: UseMutationOptions< DeleteSnapshotsResponse, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await deleteSnapshots({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const listSnapshotsQueryKey = (options: Options) => createQueryKey("listSnapshots", options); /** * List all snapshots in a repository */ export const listSnapshotsOptions = (options: Options) => queryOptions< ListSnapshotsResponse, DefaultError, ListSnapshotsResponse, ReturnType >({ queryFn: async ({ queryKey, signal }) => { const { data } = await listSnapshots({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: listSnapshotsQueryKey(options), }); /** * Delete a specific snapshot from a repository */ export const deleteSnapshotMutation = ( options?: Partial>, ): UseMutationOptions< DeleteSnapshotResponse, DefaultError, Options > => { const mutationOptions: UseMutationOptions< DeleteSnapshotResponse, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await deleteSnapshot({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; 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< RestoreSnapshotResponse, DefaultError, Options > => { const mutationOptions: UseMutationOptions< RestoreSnapshotResponse, DefaultError, Options > = { 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< DoctorRepositoryResponse, DefaultError, Options > => { const mutationOptions: UseMutationOptions< DoctorRepositoryResponse, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await doctorRepository({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; /** * Tag multiple snapshots in a repository */ export const tagSnapshotsMutation = ( options?: Partial>, ): UseMutationOptions< TagSnapshotsResponse, DefaultError, Options > => { const mutationOptions: UseMutationOptions< TagSnapshotsResponse, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await tagSnapshots({ ...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< CreateBackupScheduleResponse, DefaultError, Options > => { 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< DeleteBackupScheduleResponse, DefaultError, Options > => { 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< UpdateBackupScheduleResponse, DefaultError, Options > => { 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< RunBackupNowResponse, DefaultError, Options > => { const mutationOptions: UseMutationOptions< RunBackupNowResponse, DefaultError, Options > = { 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< StopBackupResponse, DefaultError, Options > => { const mutationOptions: UseMutationOptions< StopBackupResponse, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await stopBackup({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; /** * Manually apply retention policy to clean up old snapshots */ export const runForgetMutation = ( options?: Partial>, ): UseMutationOptions< RunForgetResponse, DefaultError, Options > => { const mutationOptions: UseMutationOptions< RunForgetResponse, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await runForget({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const getScheduleNotificationsQueryKey = ( options: Options, ) => createQueryKey("getScheduleNotifications", options); /** * Get notification assignments for a backup schedule */ export const getScheduleNotificationsOptions = ( options: Options, ) => queryOptions< GetScheduleNotificationsResponse, DefaultError, GetScheduleNotificationsResponse, ReturnType >({ queryFn: async ({ queryKey, signal }) => { const { data } = await getScheduleNotifications({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: getScheduleNotificationsQueryKey(options), }); /** * Update notification assignments for a backup schedule */ export const updateScheduleNotificationsMutation = ( options?: Partial>, ): UseMutationOptions< UpdateScheduleNotificationsResponse, DefaultError, Options > => { const mutationOptions: UseMutationOptions< UpdateScheduleNotificationsResponse, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await updateScheduleNotifications({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const getScheduleMirrorsQueryKey = ( options: Options, ) => createQueryKey("getScheduleMirrors", options); /** * Get mirror repository assignments for a backup schedule */ export const getScheduleMirrorsOptions = ( options: Options, ) => queryOptions< GetScheduleMirrorsResponse, DefaultError, GetScheduleMirrorsResponse, ReturnType >({ queryFn: async ({ queryKey, signal }) => { const { data } = await getScheduleMirrors({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: getScheduleMirrorsQueryKey(options), }); /** * Update mirror repository assignments for a backup schedule */ export const updateScheduleMirrorsMutation = ( options?: Partial>, ): UseMutationOptions< UpdateScheduleMirrorsResponse, DefaultError, Options > => { const mutationOptions: UseMutationOptions< UpdateScheduleMirrorsResponse, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await updateScheduleMirrors({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const getMirrorCompatibilityQueryKey = ( options: Options, ) => createQueryKey("getMirrorCompatibility", options); /** * Get mirror compatibility info for all repositories relative to a backup schedule's primary repository */ export const getMirrorCompatibilityOptions = ( options: Options, ) => queryOptions< GetMirrorCompatibilityResponse, DefaultError, GetMirrorCompatibilityResponse, ReturnType >({ queryFn: async ({ queryKey, signal }) => { const { data } = await getMirrorCompatibility({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: getMirrorCompatibilityQueryKey(options), }); /** * Reorder backup schedules by providing an array of schedule IDs in the desired order */ export const reorderBackupSchedulesMutation = ( options?: Partial>, ): UseMutationOptions< ReorderBackupSchedulesResponse, DefaultError, Options > => { const mutationOptions: UseMutationOptions< ReorderBackupSchedulesResponse, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await reorderBackupSchedules({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const listNotificationDestinationsQueryKey = ( options?: Options, ) => createQueryKey("listNotificationDestinations", options); /** * List all notification destinations */ export const listNotificationDestinationsOptions = ( options?: Options, ) => queryOptions< ListNotificationDestinationsResponse, DefaultError, ListNotificationDestinationsResponse, ReturnType >({ queryFn: async ({ queryKey, signal }) => { const { data } = await listNotificationDestinations({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: listNotificationDestinationsQueryKey(options), }); /** * Create a new notification destination */ export const createNotificationDestinationMutation = ( options?: Partial>, ): UseMutationOptions< CreateNotificationDestinationResponse, DefaultError, Options > => { const mutationOptions: UseMutationOptions< CreateNotificationDestinationResponse, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await createNotificationDestination({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; /** * Delete a notification destination */ export const deleteNotificationDestinationMutation = ( options?: Partial>, ): UseMutationOptions< DeleteNotificationDestinationResponse, DefaultError, Options > => { const mutationOptions: UseMutationOptions< DeleteNotificationDestinationResponse, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await deleteNotificationDestination({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const getNotificationDestinationQueryKey = ( options: Options, ) => createQueryKey("getNotificationDestination", options); /** * Get a notification destination by ID */ export const getNotificationDestinationOptions = ( options: Options, ) => queryOptions< GetNotificationDestinationResponse, DefaultError, GetNotificationDestinationResponse, ReturnType >({ queryFn: async ({ queryKey, signal }) => { const { data } = await getNotificationDestination({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: getNotificationDestinationQueryKey(options), }); /** * Update a notification destination */ export const updateNotificationDestinationMutation = ( options?: Partial>, ): UseMutationOptions< UpdateNotificationDestinationResponse, DefaultError, Options > => { const mutationOptions: UseMutationOptions< UpdateNotificationDestinationResponse, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await updateNotificationDestination({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; /** * Test a notification destination by sending a test message */ export const testNotificationDestinationMutation = ( options?: Partial>, ): UseMutationOptions< TestNotificationDestinationResponse, DefaultError, Options > => { const mutationOptions: UseMutationOptions< TestNotificationDestinationResponse, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await testNotificationDestination({ ...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< GetSystemInfoResponse, DefaultError, GetSystemInfoResponse, ReturnType >({ queryFn: async ({ queryKey, signal }) => { const { data } = await getSystemInfo({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: getSystemInfoQueryKey(options), }); export const getUpdatesQueryKey = (options?: Options) => createQueryKey("getUpdates", options); /** * Check for application updates from GitHub */ export const getUpdatesOptions = (options?: Options) => queryOptions< GetUpdatesResponse, DefaultError, GetUpdatesResponse, ReturnType >({ queryFn: async ({ queryKey, signal }) => { const { data } = await getUpdates({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: getUpdatesQueryKey(options), }); /** * Download the Restic password file for backup recovery. Requires password re-authentication. */ export const downloadResticPasswordMutation = ( options?: Partial>, ): UseMutationOptions< DownloadResticPasswordResponse, DefaultError, Options > => { const mutationOptions: UseMutationOptions< DownloadResticPasswordResponse, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await downloadResticPassword({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; };