chore: gen api client
This commit is contained in:
parent
9475903ebb
commit
55d894c6f3
15 changed files with 325 additions and 946 deletions
|
|
@ -1,10 +1,6 @@
|
|||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
import {
|
||||
type DefaultError,
|
||||
queryOptions,
|
||||
type UseMutationOptions,
|
||||
} from "@tanstack/react-query";
|
||||
import { type DefaultError, queryOptions, type UseMutationOptions } from "@tanstack/react-query";
|
||||
|
||||
import { client } from "../client.gen";
|
||||
import {
|
||||
|
|
@ -179,8 +175,7 @@ const createQueryKey = <TOptions extends Options>(
|
|||
): [QueryKey<TOptions>[0]] => {
|
||||
const params: QueryKey<TOptions>[0] = {
|
||||
_id: id,
|
||||
baseUrl:
|
||||
options?.baseUrl || (options?.client ?? client).getConfig().baseUrl,
|
||||
baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl,
|
||||
} as QueryKey<TOptions>[0];
|
||||
if (infinite) {
|
||||
params._infinite = infinite;
|
||||
|
|
@ -203,19 +198,13 @@ const createQueryKey = <TOptions extends Options>(
|
|||
return [params];
|
||||
};
|
||||
|
||||
export const getStatusQueryKey = (options?: Options<GetStatusData>) =>
|
||||
createQueryKey("getStatus", options);
|
||||
export const getStatusQueryKey = (options?: Options<GetStatusData>) => createQueryKey("getStatus", options);
|
||||
|
||||
/**
|
||||
* Get authentication system status
|
||||
*/
|
||||
export const getStatusOptions = (options?: Options<GetStatusData>) =>
|
||||
queryOptions<
|
||||
GetStatusResponse,
|
||||
DefaultError,
|
||||
GetStatusResponse,
|
||||
ReturnType<typeof getStatusQueryKey>
|
||||
>({
|
||||
queryOptions<GetStatusResponse, DefaultError, GetStatusResponse, ReturnType<typeof getStatusQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await getStatus({
|
||||
...options,
|
||||
|
|
@ -228,19 +217,13 @@ export const getStatusOptions = (options?: Options<GetStatusData>) =>
|
|||
queryKey: getStatusQueryKey(options),
|
||||
});
|
||||
|
||||
export const listVolumesQueryKey = (options?: Options<ListVolumesData>) =>
|
||||
createQueryKey("listVolumes", options);
|
||||
export const listVolumesQueryKey = (options?: Options<ListVolumesData>) => createQueryKey("listVolumes", options);
|
||||
|
||||
/**
|
||||
* List all volumes
|
||||
*/
|
||||
export const listVolumesOptions = (options?: Options<ListVolumesData>) =>
|
||||
queryOptions<
|
||||
ListVolumesResponse,
|
||||
DefaultError,
|
||||
ListVolumesResponse,
|
||||
ReturnType<typeof listVolumesQueryKey>
|
||||
>({
|
||||
queryOptions<ListVolumesResponse, DefaultError, ListVolumesResponse, ReturnType<typeof listVolumesQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await listVolumes({
|
||||
...options,
|
||||
|
|
@ -258,16 +241,8 @@ export const listVolumesOptions = (options?: Options<ListVolumesData>) =>
|
|||
*/
|
||||
export const createVolumeMutation = (
|
||||
options?: Partial<Options<CreateVolumeData>>,
|
||||
): UseMutationOptions<
|
||||
CreateVolumeResponse,
|
||||
DefaultError,
|
||||
Options<CreateVolumeData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
CreateVolumeResponse,
|
||||
DefaultError,
|
||||
Options<CreateVolumeData>
|
||||
> = {
|
||||
): UseMutationOptions<CreateVolumeResponse, DefaultError, Options<CreateVolumeData>> => {
|
||||
const mutationOptions: UseMutationOptions<CreateVolumeResponse, DefaultError, Options<CreateVolumeData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await createVolume({
|
||||
...options,
|
||||
|
|
@ -285,16 +260,8 @@ export const createVolumeMutation = (
|
|||
*/
|
||||
export const testConnectionMutation = (
|
||||
options?: Partial<Options<TestConnectionData>>,
|
||||
): UseMutationOptions<
|
||||
TestConnectionResponse,
|
||||
DefaultError,
|
||||
Options<TestConnectionData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
TestConnectionResponse,
|
||||
DefaultError,
|
||||
Options<TestConnectionData>
|
||||
> = {
|
||||
): UseMutationOptions<TestConnectionResponse, DefaultError, Options<TestConnectionData>> => {
|
||||
const mutationOptions: UseMutationOptions<TestConnectionResponse, DefaultError, Options<TestConnectionData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await testConnection({
|
||||
...options,
|
||||
|
|
@ -312,16 +279,8 @@ export const testConnectionMutation = (
|
|||
*/
|
||||
export const deleteVolumeMutation = (
|
||||
options?: Partial<Options<DeleteVolumeData>>,
|
||||
): UseMutationOptions<
|
||||
DeleteVolumeResponse,
|
||||
DefaultError,
|
||||
Options<DeleteVolumeData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
DeleteVolumeResponse,
|
||||
DefaultError,
|
||||
Options<DeleteVolumeData>
|
||||
> = {
|
||||
): UseMutationOptions<DeleteVolumeResponse, DefaultError, Options<DeleteVolumeData>> => {
|
||||
const mutationOptions: UseMutationOptions<DeleteVolumeResponse, DefaultError, Options<DeleteVolumeData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await deleteVolume({
|
||||
...options,
|
||||
|
|
@ -334,19 +293,13 @@ export const deleteVolumeMutation = (
|
|||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const getVolumeQueryKey = (options: Options<GetVolumeData>) =>
|
||||
createQueryKey("getVolume", options);
|
||||
export const getVolumeQueryKey = (options: Options<GetVolumeData>) => createQueryKey("getVolume", options);
|
||||
|
||||
/**
|
||||
* Get a volume by name
|
||||
*/
|
||||
export const getVolumeOptions = (options: Options<GetVolumeData>) =>
|
||||
queryOptions<
|
||||
GetVolumeResponse,
|
||||
DefaultError,
|
||||
GetVolumeResponse,
|
||||
ReturnType<typeof getVolumeQueryKey>
|
||||
>({
|
||||
queryOptions<GetVolumeResponse, DefaultError, GetVolumeResponse, ReturnType<typeof getVolumeQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await getVolume({
|
||||
...options,
|
||||
|
|
@ -364,16 +317,8 @@ export const getVolumeOptions = (options: Options<GetVolumeData>) =>
|
|||
*/
|
||||
export const updateVolumeMutation = (
|
||||
options?: Partial<Options<UpdateVolumeData>>,
|
||||
): UseMutationOptions<
|
||||
UpdateVolumeResponse,
|
||||
DefaultError,
|
||||
Options<UpdateVolumeData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
UpdateVolumeResponse,
|
||||
DefaultError,
|
||||
Options<UpdateVolumeData>
|
||||
> = {
|
||||
): UseMutationOptions<UpdateVolumeResponse, DefaultError, Options<UpdateVolumeData>> => {
|
||||
const mutationOptions: UseMutationOptions<UpdateVolumeResponse, DefaultError, Options<UpdateVolumeData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await updateVolume({
|
||||
...options,
|
||||
|
|
@ -391,16 +336,8 @@ export const updateVolumeMutation = (
|
|||
*/
|
||||
export const mountVolumeMutation = (
|
||||
options?: Partial<Options<MountVolumeData>>,
|
||||
): UseMutationOptions<
|
||||
MountVolumeResponse,
|
||||
DefaultError,
|
||||
Options<MountVolumeData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
MountVolumeResponse,
|
||||
DefaultError,
|
||||
Options<MountVolumeData>
|
||||
> = {
|
||||
): UseMutationOptions<MountVolumeResponse, DefaultError, Options<MountVolumeData>> => {
|
||||
const mutationOptions: UseMutationOptions<MountVolumeResponse, DefaultError, Options<MountVolumeData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await mountVolume({
|
||||
...options,
|
||||
|
|
@ -418,16 +355,8 @@ export const mountVolumeMutation = (
|
|||
*/
|
||||
export const unmountVolumeMutation = (
|
||||
options?: Partial<Options<UnmountVolumeData>>,
|
||||
): UseMutationOptions<
|
||||
UnmountVolumeResponse,
|
||||
DefaultError,
|
||||
Options<UnmountVolumeData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
UnmountVolumeResponse,
|
||||
DefaultError,
|
||||
Options<UnmountVolumeData>
|
||||
> = {
|
||||
): UseMutationOptions<UnmountVolumeResponse, DefaultError, Options<UnmountVolumeData>> => {
|
||||
const mutationOptions: UseMutationOptions<UnmountVolumeResponse, DefaultError, Options<UnmountVolumeData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await unmountVolume({
|
||||
...options,
|
||||
|
|
@ -445,16 +374,8 @@ export const unmountVolumeMutation = (
|
|||
*/
|
||||
export const healthCheckVolumeMutation = (
|
||||
options?: Partial<Options<HealthCheckVolumeData>>,
|
||||
): UseMutationOptions<
|
||||
HealthCheckVolumeResponse,
|
||||
DefaultError,
|
||||
Options<HealthCheckVolumeData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
HealthCheckVolumeResponse,
|
||||
DefaultError,
|
||||
Options<HealthCheckVolumeData>
|
||||
> = {
|
||||
): UseMutationOptions<HealthCheckVolumeResponse, DefaultError, Options<HealthCheckVolumeData>> => {
|
||||
const mutationOptions: UseMutationOptions<HealthCheckVolumeResponse, DefaultError, Options<HealthCheckVolumeData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await healthCheckVolume({
|
||||
...options,
|
||||
|
|
@ -467,19 +388,13 @@ export const healthCheckVolumeMutation = (
|
|||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const listFilesQueryKey = (options: Options<ListFilesData>) =>
|
||||
createQueryKey("listFiles", options);
|
||||
export const listFilesQueryKey = (options: Options<ListFilesData>) => createQueryKey("listFiles", options);
|
||||
|
||||
/**
|
||||
* List files in a volume directory
|
||||
*/
|
||||
export const listFilesOptions = (options: Options<ListFilesData>) =>
|
||||
queryOptions<
|
||||
ListFilesResponse,
|
||||
DefaultError,
|
||||
ListFilesResponse,
|
||||
ReturnType<typeof listFilesQueryKey>
|
||||
>({
|
||||
queryOptions<ListFilesResponse, DefaultError, ListFilesResponse, ReturnType<typeof listFilesQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await listFiles({
|
||||
...options,
|
||||
|
|
@ -492,16 +407,13 @@ export const listFilesOptions = (options: Options<ListFilesData>) =>
|
|||
queryKey: listFilesQueryKey(options),
|
||||
});
|
||||
|
||||
export const browseFilesystemQueryKey = (
|
||||
options?: Options<BrowseFilesystemData>,
|
||||
) => createQueryKey("browseFilesystem", options);
|
||||
export const browseFilesystemQueryKey = (options?: Options<BrowseFilesystemData>) =>
|
||||
createQueryKey("browseFilesystem", options);
|
||||
|
||||
/**
|
||||
* Browse directories on the host filesystem
|
||||
*/
|
||||
export const browseFilesystemOptions = (
|
||||
options?: Options<BrowseFilesystemData>,
|
||||
) =>
|
||||
export const browseFilesystemOptions = (options?: Options<BrowseFilesystemData>) =>
|
||||
queryOptions<
|
||||
BrowseFilesystemResponse,
|
||||
DefaultError,
|
||||
|
|
@ -520,16 +432,13 @@ export const browseFilesystemOptions = (
|
|||
queryKey: browseFilesystemQueryKey(options),
|
||||
});
|
||||
|
||||
export const listRepositoriesQueryKey = (
|
||||
options?: Options<ListRepositoriesData>,
|
||||
) => createQueryKey("listRepositories", options);
|
||||
export const listRepositoriesQueryKey = (options?: Options<ListRepositoriesData>) =>
|
||||
createQueryKey("listRepositories", options);
|
||||
|
||||
/**
|
||||
* List all repositories
|
||||
*/
|
||||
export const listRepositoriesOptions = (
|
||||
options?: Options<ListRepositoriesData>,
|
||||
) =>
|
||||
export const listRepositoriesOptions = (options?: Options<ListRepositoriesData>) =>
|
||||
queryOptions<
|
||||
ListRepositoriesResponse,
|
||||
DefaultError,
|
||||
|
|
@ -553,16 +462,8 @@ export const listRepositoriesOptions = (
|
|||
*/
|
||||
export const createRepositoryMutation = (
|
||||
options?: Partial<Options<CreateRepositoryData>>,
|
||||
): UseMutationOptions<
|
||||
CreateRepositoryResponse,
|
||||
DefaultError,
|
||||
Options<CreateRepositoryData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
CreateRepositoryResponse,
|
||||
DefaultError,
|
||||
Options<CreateRepositoryData>
|
||||
> = {
|
||||
): UseMutationOptions<CreateRepositoryResponse, DefaultError, Options<CreateRepositoryData>> => {
|
||||
const mutationOptions: UseMutationOptions<CreateRepositoryResponse, DefaultError, Options<CreateRepositoryData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await createRepository({
|
||||
...options,
|
||||
|
|
@ -575,16 +476,13 @@ export const createRepositoryMutation = (
|
|||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const listRcloneRemotesQueryKey = (
|
||||
options?: Options<ListRcloneRemotesData>,
|
||||
) => createQueryKey("listRcloneRemotes", options);
|
||||
export const listRcloneRemotesQueryKey = (options?: Options<ListRcloneRemotesData>) =>
|
||||
createQueryKey("listRcloneRemotes", options);
|
||||
|
||||
/**
|
||||
* List all configured rclone remotes on the host system
|
||||
*/
|
||||
export const listRcloneRemotesOptions = (
|
||||
options?: Options<ListRcloneRemotesData>,
|
||||
) =>
|
||||
export const listRcloneRemotesOptions = (options?: Options<ListRcloneRemotesData>) =>
|
||||
queryOptions<
|
||||
ListRcloneRemotesResponse,
|
||||
DefaultError,
|
||||
|
|
@ -608,16 +506,8 @@ export const listRcloneRemotesOptions = (
|
|||
*/
|
||||
export const deleteRepositoryMutation = (
|
||||
options?: Partial<Options<DeleteRepositoryData>>,
|
||||
): UseMutationOptions<
|
||||
DeleteRepositoryResponse,
|
||||
DefaultError,
|
||||
Options<DeleteRepositoryData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
DeleteRepositoryResponse,
|
||||
DefaultError,
|
||||
Options<DeleteRepositoryData>
|
||||
> = {
|
||||
): UseMutationOptions<DeleteRepositoryResponse, DefaultError, Options<DeleteRepositoryData>> => {
|
||||
const mutationOptions: UseMutationOptions<DeleteRepositoryResponse, DefaultError, Options<DeleteRepositoryData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await deleteRepository({
|
||||
...options,
|
||||
|
|
@ -630,19 +520,13 @@ export const deleteRepositoryMutation = (
|
|||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const getRepositoryQueryKey = (options: Options<GetRepositoryData>) =>
|
||||
createQueryKey("getRepository", options);
|
||||
export const getRepositoryQueryKey = (options: Options<GetRepositoryData>) => createQueryKey("getRepository", options);
|
||||
|
||||
/**
|
||||
* Get a single repository by ID
|
||||
*/
|
||||
export const getRepositoryOptions = (options: Options<GetRepositoryData>) =>
|
||||
queryOptions<
|
||||
GetRepositoryResponse,
|
||||
DefaultError,
|
||||
GetRepositoryResponse,
|
||||
ReturnType<typeof getRepositoryQueryKey>
|
||||
>({
|
||||
queryOptions<GetRepositoryResponse, DefaultError, GetRepositoryResponse, ReturnType<typeof getRepositoryQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await getRepository({
|
||||
...options,
|
||||
|
|
@ -660,16 +544,8 @@ export const getRepositoryOptions = (options: Options<GetRepositoryData>) =>
|
|||
*/
|
||||
export const updateRepositoryMutation = (
|
||||
options?: Partial<Options<UpdateRepositoryData>>,
|
||||
): UseMutationOptions<
|
||||
UpdateRepositoryResponse,
|
||||
DefaultError,
|
||||
Options<UpdateRepositoryData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
UpdateRepositoryResponse,
|
||||
DefaultError,
|
||||
Options<UpdateRepositoryData>
|
||||
> = {
|
||||
): UseMutationOptions<UpdateRepositoryResponse, DefaultError, Options<UpdateRepositoryData>> => {
|
||||
const mutationOptions: UseMutationOptions<UpdateRepositoryResponse, DefaultError, Options<UpdateRepositoryData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await updateRepository({
|
||||
...options,
|
||||
|
|
@ -687,16 +563,8 @@ export const updateRepositoryMutation = (
|
|||
*/
|
||||
export const deleteSnapshotsMutation = (
|
||||
options?: Partial<Options<DeleteSnapshotsData>>,
|
||||
): UseMutationOptions<
|
||||
DeleteSnapshotsResponse,
|
||||
DefaultError,
|
||||
Options<DeleteSnapshotsData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
DeleteSnapshotsResponse,
|
||||
DefaultError,
|
||||
Options<DeleteSnapshotsData>
|
||||
> = {
|
||||
): UseMutationOptions<DeleteSnapshotsResponse, DefaultError, Options<DeleteSnapshotsData>> => {
|
||||
const mutationOptions: UseMutationOptions<DeleteSnapshotsResponse, DefaultError, Options<DeleteSnapshotsData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await deleteSnapshots({
|
||||
...options,
|
||||
|
|
@ -709,19 +577,13 @@ export const deleteSnapshotsMutation = (
|
|||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const listSnapshotsQueryKey = (options: Options<ListSnapshotsData>) =>
|
||||
createQueryKey("listSnapshots", options);
|
||||
export const listSnapshotsQueryKey = (options: Options<ListSnapshotsData>) => createQueryKey("listSnapshots", options);
|
||||
|
||||
/**
|
||||
* List all snapshots in a repository
|
||||
*/
|
||||
export const listSnapshotsOptions = (options: Options<ListSnapshotsData>) =>
|
||||
queryOptions<
|
||||
ListSnapshotsResponse,
|
||||
DefaultError,
|
||||
ListSnapshotsResponse,
|
||||
ReturnType<typeof listSnapshotsQueryKey>
|
||||
>({
|
||||
queryOptions<ListSnapshotsResponse, DefaultError, ListSnapshotsResponse, ReturnType<typeof listSnapshotsQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await listSnapshots({
|
||||
...options,
|
||||
|
|
@ -739,16 +601,8 @@ export const listSnapshotsOptions = (options: Options<ListSnapshotsData>) =>
|
|||
*/
|
||||
export const deleteSnapshotMutation = (
|
||||
options?: Partial<Options<DeleteSnapshotData>>,
|
||||
): UseMutationOptions<
|
||||
DeleteSnapshotResponse,
|
||||
DefaultError,
|
||||
Options<DeleteSnapshotData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
DeleteSnapshotResponse,
|
||||
DefaultError,
|
||||
Options<DeleteSnapshotData>
|
||||
> = {
|
||||
): UseMutationOptions<DeleteSnapshotResponse, DefaultError, Options<DeleteSnapshotData>> => {
|
||||
const mutationOptions: UseMutationOptions<DeleteSnapshotResponse, DefaultError, Options<DeleteSnapshotData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await deleteSnapshot({
|
||||
...options,
|
||||
|
|
@ -761,16 +615,13 @@ export const deleteSnapshotMutation = (
|
|||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const getSnapshotDetailsQueryKey = (
|
||||
options: Options<GetSnapshotDetailsData>,
|
||||
) => createQueryKey("getSnapshotDetails", options);
|
||||
export const getSnapshotDetailsQueryKey = (options: Options<GetSnapshotDetailsData>) =>
|
||||
createQueryKey("getSnapshotDetails", options);
|
||||
|
||||
/**
|
||||
* Get details of a specific snapshot
|
||||
*/
|
||||
export const getSnapshotDetailsOptions = (
|
||||
options: Options<GetSnapshotDetailsData>,
|
||||
) =>
|
||||
export const getSnapshotDetailsOptions = (options: Options<GetSnapshotDetailsData>) =>
|
||||
queryOptions<
|
||||
GetSnapshotDetailsResponse,
|
||||
DefaultError,
|
||||
|
|
@ -789,16 +640,13 @@ export const getSnapshotDetailsOptions = (
|
|||
queryKey: getSnapshotDetailsQueryKey(options),
|
||||
});
|
||||
|
||||
export const listSnapshotFilesQueryKey = (
|
||||
options: Options<ListSnapshotFilesData>,
|
||||
) => createQueryKey("listSnapshotFiles", options);
|
||||
export const listSnapshotFilesQueryKey = (options: Options<ListSnapshotFilesData>) =>
|
||||
createQueryKey("listSnapshotFiles", options);
|
||||
|
||||
/**
|
||||
* List files and directories in a snapshot
|
||||
*/
|
||||
export const listSnapshotFilesOptions = (
|
||||
options: Options<ListSnapshotFilesData>,
|
||||
) =>
|
||||
export const listSnapshotFilesOptions = (options: Options<ListSnapshotFilesData>) =>
|
||||
queryOptions<
|
||||
ListSnapshotFilesResponse,
|
||||
DefaultError,
|
||||
|
|
@ -822,16 +670,8 @@ export const listSnapshotFilesOptions = (
|
|||
*/
|
||||
export const restoreSnapshotMutation = (
|
||||
options?: Partial<Options<RestoreSnapshotData>>,
|
||||
): UseMutationOptions<
|
||||
RestoreSnapshotResponse,
|
||||
DefaultError,
|
||||
Options<RestoreSnapshotData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
RestoreSnapshotResponse,
|
||||
DefaultError,
|
||||
Options<RestoreSnapshotData>
|
||||
> = {
|
||||
): UseMutationOptions<RestoreSnapshotResponse, DefaultError, Options<RestoreSnapshotData>> => {
|
||||
const mutationOptions: UseMutationOptions<RestoreSnapshotResponse, DefaultError, Options<RestoreSnapshotData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await restoreSnapshot({
|
||||
...options,
|
||||
|
|
@ -849,16 +689,8 @@ export const restoreSnapshotMutation = (
|
|||
*/
|
||||
export const doctorRepositoryMutation = (
|
||||
options?: Partial<Options<DoctorRepositoryData>>,
|
||||
): UseMutationOptions<
|
||||
DoctorRepositoryResponse,
|
||||
DefaultError,
|
||||
Options<DoctorRepositoryData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
DoctorRepositoryResponse,
|
||||
DefaultError,
|
||||
Options<DoctorRepositoryData>
|
||||
> = {
|
||||
): UseMutationOptions<DoctorRepositoryResponse, DefaultError, Options<DoctorRepositoryData>> => {
|
||||
const mutationOptions: UseMutationOptions<DoctorRepositoryResponse, DefaultError, Options<DoctorRepositoryData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await doctorRepository({
|
||||
...options,
|
||||
|
|
@ -876,16 +708,8 @@ export const doctorRepositoryMutation = (
|
|||
*/
|
||||
export const tagSnapshotsMutation = (
|
||||
options?: Partial<Options<TagSnapshotsData>>,
|
||||
): UseMutationOptions<
|
||||
TagSnapshotsResponse,
|
||||
DefaultError,
|
||||
Options<TagSnapshotsData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
TagSnapshotsResponse,
|
||||
DefaultError,
|
||||
Options<TagSnapshotsData>
|
||||
> = {
|
||||
): UseMutationOptions<TagSnapshotsResponse, DefaultError, Options<TagSnapshotsData>> => {
|
||||
const mutationOptions: UseMutationOptions<TagSnapshotsResponse, DefaultError, Options<TagSnapshotsData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await tagSnapshots({
|
||||
...options,
|
||||
|
|
@ -898,16 +722,13 @@ export const tagSnapshotsMutation = (
|
|||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const listBackupSchedulesQueryKey = (
|
||||
options?: Options<ListBackupSchedulesData>,
|
||||
) => createQueryKey("listBackupSchedules", options);
|
||||
export const listBackupSchedulesQueryKey = (options?: Options<ListBackupSchedulesData>) =>
|
||||
createQueryKey("listBackupSchedules", options);
|
||||
|
||||
/**
|
||||
* List all backup schedules
|
||||
*/
|
||||
export const listBackupSchedulesOptions = (
|
||||
options?: Options<ListBackupSchedulesData>,
|
||||
) =>
|
||||
export const listBackupSchedulesOptions = (options?: Options<ListBackupSchedulesData>) =>
|
||||
queryOptions<
|
||||
ListBackupSchedulesResponse,
|
||||
DefaultError,
|
||||
|
|
@ -931,11 +752,7 @@ export const listBackupSchedulesOptions = (
|
|||
*/
|
||||
export const createBackupScheduleMutation = (
|
||||
options?: Partial<Options<CreateBackupScheduleData>>,
|
||||
): UseMutationOptions<
|
||||
CreateBackupScheduleResponse,
|
||||
DefaultError,
|
||||
Options<CreateBackupScheduleData>
|
||||
> => {
|
||||
): UseMutationOptions<CreateBackupScheduleResponse, DefaultError, Options<CreateBackupScheduleData>> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
CreateBackupScheduleResponse,
|
||||
DefaultError,
|
||||
|
|
@ -958,11 +775,7 @@ export const createBackupScheduleMutation = (
|
|||
*/
|
||||
export const deleteBackupScheduleMutation = (
|
||||
options?: Partial<Options<DeleteBackupScheduleData>>,
|
||||
): UseMutationOptions<
|
||||
DeleteBackupScheduleResponse,
|
||||
DefaultError,
|
||||
Options<DeleteBackupScheduleData>
|
||||
> => {
|
||||
): UseMutationOptions<DeleteBackupScheduleResponse, DefaultError, Options<DeleteBackupScheduleData>> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
DeleteBackupScheduleResponse,
|
||||
DefaultError,
|
||||
|
|
@ -980,16 +793,13 @@ export const deleteBackupScheduleMutation = (
|
|||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const getBackupScheduleQueryKey = (
|
||||
options: Options<GetBackupScheduleData>,
|
||||
) => createQueryKey("getBackupSchedule", options);
|
||||
export const getBackupScheduleQueryKey = (options: Options<GetBackupScheduleData>) =>
|
||||
createQueryKey("getBackupSchedule", options);
|
||||
|
||||
/**
|
||||
* Get a backup schedule by ID
|
||||
*/
|
||||
export const getBackupScheduleOptions = (
|
||||
options: Options<GetBackupScheduleData>,
|
||||
) =>
|
||||
export const getBackupScheduleOptions = (options: Options<GetBackupScheduleData>) =>
|
||||
queryOptions<
|
||||
GetBackupScheduleResponse,
|
||||
DefaultError,
|
||||
|
|
@ -1013,11 +823,7 @@ export const getBackupScheduleOptions = (
|
|||
*/
|
||||
export const updateBackupScheduleMutation = (
|
||||
options?: Partial<Options<UpdateBackupScheduleData>>,
|
||||
): UseMutationOptions<
|
||||
UpdateBackupScheduleResponse,
|
||||
DefaultError,
|
||||
Options<UpdateBackupScheduleData>
|
||||
> => {
|
||||
): UseMutationOptions<UpdateBackupScheduleResponse, DefaultError, Options<UpdateBackupScheduleData>> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
UpdateBackupScheduleResponse,
|
||||
DefaultError,
|
||||
|
|
@ -1035,16 +841,13 @@ export const updateBackupScheduleMutation = (
|
|||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const getBackupScheduleForVolumeQueryKey = (
|
||||
options: Options<GetBackupScheduleForVolumeData>,
|
||||
) => createQueryKey("getBackupScheduleForVolume", options);
|
||||
export const getBackupScheduleForVolumeQueryKey = (options: Options<GetBackupScheduleForVolumeData>) =>
|
||||
createQueryKey("getBackupScheduleForVolume", options);
|
||||
|
||||
/**
|
||||
* Get a backup schedule for a specific volume
|
||||
*/
|
||||
export const getBackupScheduleForVolumeOptions = (
|
||||
options: Options<GetBackupScheduleForVolumeData>,
|
||||
) =>
|
||||
export const getBackupScheduleForVolumeOptions = (options: Options<GetBackupScheduleForVolumeData>) =>
|
||||
queryOptions<
|
||||
GetBackupScheduleForVolumeResponse,
|
||||
DefaultError,
|
||||
|
|
@ -1068,16 +871,8 @@ export const getBackupScheduleForVolumeOptions = (
|
|||
*/
|
||||
export const runBackupNowMutation = (
|
||||
options?: Partial<Options<RunBackupNowData>>,
|
||||
): UseMutationOptions<
|
||||
RunBackupNowResponse,
|
||||
DefaultError,
|
||||
Options<RunBackupNowData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
RunBackupNowResponse,
|
||||
DefaultError,
|
||||
Options<RunBackupNowData>
|
||||
> = {
|
||||
): UseMutationOptions<RunBackupNowResponse, DefaultError, Options<RunBackupNowData>> => {
|
||||
const mutationOptions: UseMutationOptions<RunBackupNowResponse, DefaultError, Options<RunBackupNowData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await runBackupNow({
|
||||
...options,
|
||||
|
|
@ -1095,16 +890,8 @@ export const runBackupNowMutation = (
|
|||
*/
|
||||
export const stopBackupMutation = (
|
||||
options?: Partial<Options<StopBackupData>>,
|
||||
): UseMutationOptions<
|
||||
StopBackupResponse,
|
||||
DefaultError,
|
||||
Options<StopBackupData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
StopBackupResponse,
|
||||
DefaultError,
|
||||
Options<StopBackupData>
|
||||
> = {
|
||||
): UseMutationOptions<StopBackupResponse, DefaultError, Options<StopBackupData>> => {
|
||||
const mutationOptions: UseMutationOptions<StopBackupResponse, DefaultError, Options<StopBackupData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await stopBackup({
|
||||
...options,
|
||||
|
|
@ -1122,16 +909,8 @@ export const stopBackupMutation = (
|
|||
*/
|
||||
export const runForgetMutation = (
|
||||
options?: Partial<Options<RunForgetData>>,
|
||||
): UseMutationOptions<
|
||||
RunForgetResponse,
|
||||
DefaultError,
|
||||
Options<RunForgetData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
RunForgetResponse,
|
||||
DefaultError,
|
||||
Options<RunForgetData>
|
||||
> = {
|
||||
): UseMutationOptions<RunForgetResponse, DefaultError, Options<RunForgetData>> => {
|
||||
const mutationOptions: UseMutationOptions<RunForgetResponse, DefaultError, Options<RunForgetData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await runForget({
|
||||
...options,
|
||||
|
|
@ -1144,16 +923,13 @@ export const runForgetMutation = (
|
|||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const getScheduleNotificationsQueryKey = (
|
||||
options: Options<GetScheduleNotificationsData>,
|
||||
) => createQueryKey("getScheduleNotifications", options);
|
||||
export const getScheduleNotificationsQueryKey = (options: Options<GetScheduleNotificationsData>) =>
|
||||
createQueryKey("getScheduleNotifications", options);
|
||||
|
||||
/**
|
||||
* Get notification assignments for a backup schedule
|
||||
*/
|
||||
export const getScheduleNotificationsOptions = (
|
||||
options: Options<GetScheduleNotificationsData>,
|
||||
) =>
|
||||
export const getScheduleNotificationsOptions = (options: Options<GetScheduleNotificationsData>) =>
|
||||
queryOptions<
|
||||
GetScheduleNotificationsResponse,
|
||||
DefaultError,
|
||||
|
|
@ -1177,11 +953,7 @@ export const getScheduleNotificationsOptions = (
|
|||
*/
|
||||
export const updateScheduleNotificationsMutation = (
|
||||
options?: Partial<Options<UpdateScheduleNotificationsData>>,
|
||||
): UseMutationOptions<
|
||||
UpdateScheduleNotificationsResponse,
|
||||
DefaultError,
|
||||
Options<UpdateScheduleNotificationsData>
|
||||
> => {
|
||||
): UseMutationOptions<UpdateScheduleNotificationsResponse, DefaultError, Options<UpdateScheduleNotificationsData>> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
UpdateScheduleNotificationsResponse,
|
||||
DefaultError,
|
||||
|
|
@ -1199,16 +971,13 @@ export const updateScheduleNotificationsMutation = (
|
|||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const getScheduleMirrorsQueryKey = (
|
||||
options: Options<GetScheduleMirrorsData>,
|
||||
) => createQueryKey("getScheduleMirrors", options);
|
||||
export const getScheduleMirrorsQueryKey = (options: Options<GetScheduleMirrorsData>) =>
|
||||
createQueryKey("getScheduleMirrors", options);
|
||||
|
||||
/**
|
||||
* Get mirror repository assignments for a backup schedule
|
||||
*/
|
||||
export const getScheduleMirrorsOptions = (
|
||||
options: Options<GetScheduleMirrorsData>,
|
||||
) =>
|
||||
export const getScheduleMirrorsOptions = (options: Options<GetScheduleMirrorsData>) =>
|
||||
queryOptions<
|
||||
GetScheduleMirrorsResponse,
|
||||
DefaultError,
|
||||
|
|
@ -1232,11 +1001,7 @@ export const getScheduleMirrorsOptions = (
|
|||
*/
|
||||
export const updateScheduleMirrorsMutation = (
|
||||
options?: Partial<Options<UpdateScheduleMirrorsData>>,
|
||||
): UseMutationOptions<
|
||||
UpdateScheduleMirrorsResponse,
|
||||
DefaultError,
|
||||
Options<UpdateScheduleMirrorsData>
|
||||
> => {
|
||||
): UseMutationOptions<UpdateScheduleMirrorsResponse, DefaultError, Options<UpdateScheduleMirrorsData>> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
UpdateScheduleMirrorsResponse,
|
||||
DefaultError,
|
||||
|
|
@ -1254,16 +1019,13 @@ export const updateScheduleMirrorsMutation = (
|
|||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const getMirrorCompatibilityQueryKey = (
|
||||
options: Options<GetMirrorCompatibilityData>,
|
||||
) => createQueryKey("getMirrorCompatibility", options);
|
||||
export const getMirrorCompatibilityQueryKey = (options: Options<GetMirrorCompatibilityData>) =>
|
||||
createQueryKey("getMirrorCompatibility", options);
|
||||
|
||||
/**
|
||||
* Get mirror compatibility info for all repositories relative to a backup schedule's primary repository
|
||||
*/
|
||||
export const getMirrorCompatibilityOptions = (
|
||||
options: Options<GetMirrorCompatibilityData>,
|
||||
) =>
|
||||
export const getMirrorCompatibilityOptions = (options: Options<GetMirrorCompatibilityData>) =>
|
||||
queryOptions<
|
||||
GetMirrorCompatibilityResponse,
|
||||
DefaultError,
|
||||
|
|
@ -1287,11 +1049,7 @@ export const getMirrorCompatibilityOptions = (
|
|||
*/
|
||||
export const reorderBackupSchedulesMutation = (
|
||||
options?: Partial<Options<ReorderBackupSchedulesData>>,
|
||||
): UseMutationOptions<
|
||||
ReorderBackupSchedulesResponse,
|
||||
DefaultError,
|
||||
Options<ReorderBackupSchedulesData>
|
||||
> => {
|
||||
): UseMutationOptions<ReorderBackupSchedulesResponse, DefaultError, Options<ReorderBackupSchedulesData>> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
ReorderBackupSchedulesResponse,
|
||||
DefaultError,
|
||||
|
|
@ -1309,16 +1067,13 @@ export const reorderBackupSchedulesMutation = (
|
|||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const listNotificationDestinationsQueryKey = (
|
||||
options?: Options<ListNotificationDestinationsData>,
|
||||
) => createQueryKey("listNotificationDestinations", options);
|
||||
export const listNotificationDestinationsQueryKey = (options?: Options<ListNotificationDestinationsData>) =>
|
||||
createQueryKey("listNotificationDestinations", options);
|
||||
|
||||
/**
|
||||
* List all notification destinations
|
||||
*/
|
||||
export const listNotificationDestinationsOptions = (
|
||||
options?: Options<ListNotificationDestinationsData>,
|
||||
) =>
|
||||
export const listNotificationDestinationsOptions = (options?: Options<ListNotificationDestinationsData>) =>
|
||||
queryOptions<
|
||||
ListNotificationDestinationsResponse,
|
||||
DefaultError,
|
||||
|
|
@ -1391,16 +1146,13 @@ export const deleteNotificationDestinationMutation = (
|
|||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const getNotificationDestinationQueryKey = (
|
||||
options: Options<GetNotificationDestinationData>,
|
||||
) => createQueryKey("getNotificationDestination", options);
|
||||
export const getNotificationDestinationQueryKey = (options: Options<GetNotificationDestinationData>) =>
|
||||
createQueryKey("getNotificationDestination", options);
|
||||
|
||||
/**
|
||||
* Get a notification destination by ID
|
||||
*/
|
||||
export const getNotificationDestinationOptions = (
|
||||
options: Options<GetNotificationDestinationData>,
|
||||
) =>
|
||||
export const getNotificationDestinationOptions = (options: Options<GetNotificationDestinationData>) =>
|
||||
queryOptions<
|
||||
GetNotificationDestinationResponse,
|
||||
DefaultError,
|
||||
|
|
@ -1451,11 +1203,7 @@ export const updateNotificationDestinationMutation = (
|
|||
*/
|
||||
export const testNotificationDestinationMutation = (
|
||||
options?: Partial<Options<TestNotificationDestinationData>>,
|
||||
): UseMutationOptions<
|
||||
TestNotificationDestinationResponse,
|
||||
DefaultError,
|
||||
Options<TestNotificationDestinationData>
|
||||
> => {
|
||||
): UseMutationOptions<TestNotificationDestinationResponse, DefaultError, Options<TestNotificationDestinationData>> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
TestNotificationDestinationResponse,
|
||||
DefaultError,
|
||||
|
|
@ -1473,19 +1221,13 @@ export const testNotificationDestinationMutation = (
|
|||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const getSystemInfoQueryKey = (options?: Options<GetSystemInfoData>) =>
|
||||
createQueryKey("getSystemInfo", options);
|
||||
export const getSystemInfoQueryKey = (options?: Options<GetSystemInfoData>) => createQueryKey("getSystemInfo", options);
|
||||
|
||||
/**
|
||||
* Get system information including available capabilities
|
||||
*/
|
||||
export const getSystemInfoOptions = (options?: Options<GetSystemInfoData>) =>
|
||||
queryOptions<
|
||||
GetSystemInfoResponse,
|
||||
DefaultError,
|
||||
GetSystemInfoResponse,
|
||||
ReturnType<typeof getSystemInfoQueryKey>
|
||||
>({
|
||||
queryOptions<GetSystemInfoResponse, DefaultError, GetSystemInfoResponse, ReturnType<typeof getSystemInfoQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await getSystemInfo({
|
||||
...options,
|
||||
|
|
@ -1498,19 +1240,13 @@ export const getSystemInfoOptions = (options?: Options<GetSystemInfoData>) =>
|
|||
queryKey: getSystemInfoQueryKey(options),
|
||||
});
|
||||
|
||||
export const getUpdatesQueryKey = (options?: Options<GetUpdatesData>) =>
|
||||
createQueryKey("getUpdates", options);
|
||||
export const getUpdatesQueryKey = (options?: Options<GetUpdatesData>) => createQueryKey("getUpdates", options);
|
||||
|
||||
/**
|
||||
* Check for application updates from GitHub
|
||||
*/
|
||||
export const getUpdatesOptions = (options?: Options<GetUpdatesData>) =>
|
||||
queryOptions<
|
||||
GetUpdatesResponse,
|
||||
DefaultError,
|
||||
GetUpdatesResponse,
|
||||
ReturnType<typeof getUpdatesQueryKey>
|
||||
>({
|
||||
queryOptions<GetUpdatesResponse, DefaultError, GetUpdatesResponse, ReturnType<typeof getUpdatesQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await getUpdates({
|
||||
...options,
|
||||
|
|
@ -1528,11 +1264,7 @@ export const getUpdatesOptions = (options?: Options<GetUpdatesData>) =>
|
|||
*/
|
||||
export const downloadResticPasswordMutation = (
|
||||
options?: Partial<Options<DownloadResticPasswordData>>,
|
||||
): UseMutationOptions<
|
||||
DownloadResticPasswordResponse,
|
||||
DefaultError,
|
||||
Options<DownloadResticPasswordData>
|
||||
> => {
|
||||
): UseMutationOptions<DownloadResticPasswordResponse, DefaultError, Options<DownloadResticPasswordData>> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
DownloadResticPasswordResponse,
|
||||
DefaultError,
|
||||
|
|
|
|||
|
|
@ -1,11 +1,6 @@
|
|||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
import {
|
||||
type ClientOptions,
|
||||
type Config,
|
||||
createClient,
|
||||
createConfig,
|
||||
} from "./client";
|
||||
import { type ClientOptions, type Config, createClient, createConfig } from "./client";
|
||||
import type { ClientOptions as ClientOptions2 } from "./types.gen";
|
||||
|
||||
/**
|
||||
|
|
@ -20,6 +15,4 @@ export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (
|
|||
override?: Config<ClientOptions & T>,
|
||||
) => Config<Required<ClientOptions> & T>;
|
||||
|
||||
export const client = createClient(
|
||||
createConfig<ClientOptions2>({ baseUrl: "http://localhost:4096" }),
|
||||
);
|
||||
export const client = createClient(createConfig<ClientOptions2>({ baseUrl: "http://localhost:4096" }));
|
||||
|
|
|
|||
|
|
@ -2,11 +2,7 @@
|
|||
|
||||
export type { Auth } from "../core/auth.gen";
|
||||
export type { QuerySerializerOptions } from "../core/bodySerializer.gen";
|
||||
export {
|
||||
formDataBodySerializer,
|
||||
jsonBodySerializer,
|
||||
urlSearchParamsBodySerializer,
|
||||
} from "../core/bodySerializer.gen";
|
||||
export { formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer } from "../core/bodySerializer.gen";
|
||||
export { buildClientParams } from "../core/params.gen";
|
||||
export { serializeQueryKeyValue } from "../core/queryKeySerializer.gen";
|
||||
export { createClient } from "./client.gen";
|
||||
|
|
|
|||
|
|
@ -1,21 +1,14 @@
|
|||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
import type { Auth } from "../core/auth.gen";
|
||||
import type {
|
||||
ServerSentEventsOptions,
|
||||
ServerSentEventsResult,
|
||||
} from "../core/serverSentEvents.gen";
|
||||
import type {
|
||||
Client as CoreClient,
|
||||
Config as CoreConfig,
|
||||
} from "../core/types.gen";
|
||||
import type { ServerSentEventsOptions, ServerSentEventsResult } from "../core/serverSentEvents.gen";
|
||||
import type { Client as CoreClient, Config as CoreConfig } from "../core/types.gen";
|
||||
import type { Middleware } from "./utils.gen";
|
||||
|
||||
export type ResponseStyle = "data" | "fields";
|
||||
|
||||
export interface Config<T extends ClientOptions = ClientOptions>
|
||||
extends Omit<RequestInit, "body" | "headers" | "method">,
|
||||
CoreConfig {
|
||||
extends Omit<RequestInit, "body" | "headers" | "method">, CoreConfig {
|
||||
/**
|
||||
* Base URL for all requests made by this client.
|
||||
*/
|
||||
|
|
@ -42,14 +35,7 @@ export interface Config<T extends ClientOptions = ClientOptions>
|
|||
*
|
||||
* @default 'auto'
|
||||
*/
|
||||
parseAs?:
|
||||
| "arrayBuffer"
|
||||
| "auto"
|
||||
| "blob"
|
||||
| "formData"
|
||||
| "json"
|
||||
| "stream"
|
||||
| "text";
|
||||
parseAs?: "arrayBuffer" | "auto" | "blob" | "formData" | "json" | "stream" | "text";
|
||||
/**
|
||||
* Should we return only data or multiple fields (data, error, response, etc.)?
|
||||
*
|
||||
|
|
@ -69,17 +55,15 @@ export interface RequestOptions<
|
|||
TResponseStyle extends ResponseStyle = "fields",
|
||||
ThrowOnError extends boolean = boolean,
|
||||
Url extends string = string,
|
||||
> extends Config<{
|
||||
>
|
||||
extends
|
||||
Config<{
|
||||
responseStyle: TResponseStyle;
|
||||
throwOnError: ThrowOnError;
|
||||
}>,
|
||||
Pick<
|
||||
ServerSentEventsOptions<TData>,
|
||||
| "onSseError"
|
||||
| "onSseEvent"
|
||||
| "sseDefaultRetryDelay"
|
||||
| "sseMaxRetryAttempts"
|
||||
| "sseMaxRetryDelay"
|
||||
"onSseError" | "onSseEvent" | "sseDefaultRetryDelay" | "sseMaxRetryAttempts" | "sseMaxRetryDelay"
|
||||
> {
|
||||
/**
|
||||
* Any body that you want to add to your request.
|
||||
|
|
@ -116,32 +100,22 @@ export type RequestResult<
|
|||
? TData[keyof TData]
|
||||
: TData
|
||||
: {
|
||||
data: TData extends Record<string, unknown>
|
||||
? TData[keyof TData]
|
||||
: TData;
|
||||
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
|
||||
request: Request;
|
||||
response: Response;
|
||||
}
|
||||
>
|
||||
: Promise<
|
||||
TResponseStyle extends "data"
|
||||
?
|
||||
| (TData extends Record<string, unknown>
|
||||
? TData[keyof TData]
|
||||
: TData)
|
||||
| undefined
|
||||
? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined
|
||||
: (
|
||||
| {
|
||||
data: TData extends Record<string, unknown>
|
||||
? TData[keyof TData]
|
||||
: TData;
|
||||
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
|
||||
error: undefined;
|
||||
}
|
||||
| {
|
||||
data: undefined;
|
||||
error: TError extends Record<string, unknown>
|
||||
? TError[keyof TError]
|
||||
: TError;
|
||||
error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
|
||||
}
|
||||
) & {
|
||||
request: Request;
|
||||
|
|
@ -180,10 +154,7 @@ type RequestFn = <
|
|||
TResponseStyle extends ResponseStyle = "fields",
|
||||
>(
|
||||
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, "method"> &
|
||||
Pick<
|
||||
Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>,
|
||||
"method"
|
||||
>,
|
||||
Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, "method">,
|
||||
) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
|
||||
|
||||
type BuildUrlFn = <
|
||||
|
|
@ -197,13 +168,7 @@ type BuildUrlFn = <
|
|||
options: TData & Options<TData>,
|
||||
) => string;
|
||||
|
||||
export type Client = CoreClient<
|
||||
RequestFn,
|
||||
Config,
|
||||
MethodFn,
|
||||
BuildUrlFn,
|
||||
SseFn
|
||||
> & {
|
||||
export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
|
||||
interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
|
||||
};
|
||||
|
||||
|
|
@ -234,8 +199,5 @@ export type Options<
|
|||
ThrowOnError extends boolean = boolean,
|
||||
TResponse = unknown,
|
||||
TResponseStyle extends ResponseStyle = "fields",
|
||||
> = OmitKeys<
|
||||
RequestOptions<TResponse, TResponseStyle, ThrowOnError>,
|
||||
"body" | "path" | "query" | "url"
|
||||
> &
|
||||
> = OmitKeys<RequestOptions<TResponse, TResponseStyle, ThrowOnError>, "body" | "path" | "query" | "url"> &
|
||||
([TData] extends [never] ? unknown : Omit<TData, "url">);
|
||||
|
|
|
|||
|
|
@ -3,23 +3,11 @@
|
|||
import { getAuthToken } from "../core/auth.gen";
|
||||
import type { QuerySerializerOptions } from "../core/bodySerializer.gen";
|
||||
import { jsonBodySerializer } from "../core/bodySerializer.gen";
|
||||
import {
|
||||
serializeArrayParam,
|
||||
serializeObjectParam,
|
||||
serializePrimitiveParam,
|
||||
} from "../core/pathSerializer.gen";
|
||||
import { serializeArrayParam, serializeObjectParam, serializePrimitiveParam } from "../core/pathSerializer.gen";
|
||||
import { getUrl } from "../core/utils.gen";
|
||||
import type {
|
||||
Client,
|
||||
ClientOptions,
|
||||
Config,
|
||||
RequestOptions,
|
||||
} from "./types.gen";
|
||||
import type { Client, ClientOptions, Config, RequestOptions } from "./types.gen";
|
||||
|
||||
export const createQuerySerializer = <T = unknown>({
|
||||
parameters = {},
|
||||
...args
|
||||
}: QuerySerializerOptions = {}) => {
|
||||
export const createQuerySerializer = <T = unknown>({ parameters = {}, ...args }: QuerySerializerOptions = {}) => {
|
||||
const querySerializer = (queryParams: T) => {
|
||||
const search: string[] = [];
|
||||
if (queryParams && typeof queryParams === "object") {
|
||||
|
|
@ -70,9 +58,7 @@ export const createQuerySerializer = <T = unknown>({
|
|||
/**
|
||||
* Infers parseAs value from provided Content-Type header.
|
||||
*/
|
||||
export const getParseAs = (
|
||||
contentType: string | null,
|
||||
): Exclude<Config["parseAs"], "auto"> => {
|
||||
export const getParseAs = (contentType: string | null): Exclude<Config["parseAs"], "auto"> => {
|
||||
if (!contentType) {
|
||||
// If no Content-Type header is provided, the best we can do is return the raw response body,
|
||||
// which is effectively the same as the 'stream' option.
|
||||
|
|
@ -85,10 +71,7 @@ export const getParseAs = (
|
|||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
cleanContent.startsWith("application/json") ||
|
||||
cleanContent.endsWith("+json")
|
||||
) {
|
||||
if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
|
||||
return "json";
|
||||
}
|
||||
|
||||
|
|
@ -96,11 +79,7 @@ export const getParseAs = (
|
|||
return "formData";
|
||||
}
|
||||
|
||||
if (
|
||||
["application/", "audio/", "image/", "video/"].some((type) =>
|
||||
cleanContent.startsWith(type),
|
||||
)
|
||||
) {
|
||||
if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
|
||||
return "blob";
|
||||
}
|
||||
|
||||
|
|
@ -120,11 +99,7 @@ const checkForExistence = (
|
|||
if (!name) {
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
options.headers.has(name) ||
|
||||
options.query?.[name] ||
|
||||
options.headers.get("Cookie")?.includes(`${name}=`)
|
||||
) {
|
||||
if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -197,19 +172,14 @@ const headersEntries = (headers: Headers): Array<[string, string]> => {
|
|||
return entries;
|
||||
};
|
||||
|
||||
export const mergeHeaders = (
|
||||
...headers: Array<Required<Config>["headers"] | undefined>
|
||||
): Headers => {
|
||||
export const mergeHeaders = (...headers: Array<Required<Config>["headers"] | undefined>): Headers => {
|
||||
const mergedHeaders = new Headers();
|
||||
for (const header of headers) {
|
||||
if (!header) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const iterator =
|
||||
header instanceof Headers
|
||||
? headersEntries(header)
|
||||
: Object.entries(header);
|
||||
const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
|
||||
|
||||
for (const [key, value] of iterator) {
|
||||
if (value === null) {
|
||||
|
|
@ -221,10 +191,7 @@ export const mergeHeaders = (
|
|||
} else if (value !== undefined) {
|
||||
// assume object headers are meant to be JSON stringified, i.e. their
|
||||
// content value in OpenAPI specification is 'application/json'
|
||||
mergedHeaders.set(
|
||||
key,
|
||||
typeof value === "object" ? JSON.stringify(value) : (value as string),
|
||||
);
|
||||
mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : (value as string));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -238,16 +205,9 @@ type ErrInterceptor<Err, Res, Req, Options> = (
|
|||
options: Options,
|
||||
) => Err | Promise<Err>;
|
||||
|
||||
type ReqInterceptor<Req, Options> = (
|
||||
request: Req,
|
||||
options: Options,
|
||||
) => Req | Promise<Req>;
|
||||
type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>;
|
||||
|
||||
type ResInterceptor<Res, Req, Options> = (
|
||||
response: Res,
|
||||
request: Req,
|
||||
options: Options,
|
||||
) => Res | Promise<Res>;
|
||||
type ResInterceptor<Res, Req, Options> = (response: Res, request: Req, options: Options) => Res | Promise<Res>;
|
||||
|
||||
class Interceptors<Interceptor> {
|
||||
fns: Array<Interceptor | null> = [];
|
||||
|
|
@ -275,10 +235,7 @@ class Interceptors<Interceptor> {
|
|||
return this.fns.indexOf(id);
|
||||
}
|
||||
|
||||
update(
|
||||
id: number | Interceptor,
|
||||
fn: Interceptor,
|
||||
): number | Interceptor | false {
|
||||
update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false {
|
||||
const index = this.getInterceptorIndex(id);
|
||||
if (this.fns[index]) {
|
||||
this.fns[index] = fn;
|
||||
|
|
@ -299,12 +256,7 @@ export interface Middleware<Req, Res, Err, Options> {
|
|||
response: Interceptors<ResInterceptor<Res, Req, Options>>;
|
||||
}
|
||||
|
||||
export const createInterceptors = <Req, Res, Err, Options>(): Middleware<
|
||||
Req,
|
||||
Res,
|
||||
Err,
|
||||
Options
|
||||
> => ({
|
||||
export const createInterceptors = <Req, Res, Err, Options>(): Middleware<Req, Res, Err, Options> => ({
|
||||
error: new Interceptors<ErrInterceptor<Err, Res, Req, Options>>(),
|
||||
request: new Interceptors<ReqInterceptor<Req, Options>>(),
|
||||
response: new Interceptors<ResInterceptor<Res, Req, Options>>(),
|
||||
|
|
|
|||
|
|
@ -23,8 +23,7 @@ export const getAuthToken = async (
|
|||
auth: Auth,
|
||||
callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken,
|
||||
): Promise<string | undefined> => {
|
||||
const token =
|
||||
typeof callback === "function" ? await callback(auth) : callback;
|
||||
const token = typeof callback === "function" ? await callback(auth) : callback;
|
||||
|
||||
if (!token) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,6 @@
|
|||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
import type {
|
||||
ArrayStyle,
|
||||
ObjectStyle,
|
||||
SerializerOptions,
|
||||
} from "./pathSerializer.gen";
|
||||
import type { ArrayStyle, ObjectStyle, SerializerOptions } from "./pathSerializer.gen";
|
||||
|
||||
export type QuerySerializer = (query: Record<string, unknown>) => string;
|
||||
|
||||
|
|
@ -24,11 +20,7 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & {
|
|||
parameters?: Record<string, QuerySerializerOptionsObject>;
|
||||
};
|
||||
|
||||
const serializeFormDataPair = (
|
||||
data: FormData,
|
||||
key: string,
|
||||
value: unknown,
|
||||
): void => {
|
||||
const serializeFormDataPair = (data: FormData, key: string, value: unknown): void => {
|
||||
if (typeof value === "string" || value instanceof Blob) {
|
||||
data.append(key, value);
|
||||
} else if (value instanceof Date) {
|
||||
|
|
@ -38,11 +30,7 @@ const serializeFormDataPair = (
|
|||
}
|
||||
};
|
||||
|
||||
const serializeUrlSearchParamsPair = (
|
||||
data: URLSearchParams,
|
||||
key: string,
|
||||
value: unknown,
|
||||
): void => {
|
||||
const serializeUrlSearchParamsPair = (data: URLSearchParams, key: string, value: unknown): void => {
|
||||
if (typeof value === "string") {
|
||||
data.append(key, value);
|
||||
} else {
|
||||
|
|
@ -51,9 +39,7 @@ const serializeUrlSearchParamsPair = (
|
|||
};
|
||||
|
||||
export const formDataBodySerializer = {
|
||||
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(
|
||||
body: T,
|
||||
): FormData => {
|
||||
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T): FormData => {
|
||||
const data = new FormData();
|
||||
|
||||
Object.entries(body).forEach(([key, value]) => {
|
||||
|
|
@ -73,15 +59,11 @@ export const formDataBodySerializer = {
|
|||
|
||||
export const jsonBodySerializer = {
|
||||
bodySerializer: <T>(body: T): string =>
|
||||
JSON.stringify(body, (_key, value) =>
|
||||
typeof value === "bigint" ? value.toString() : value,
|
||||
),
|
||||
JSON.stringify(body, (_key, value) => (typeof value === "bigint" ? value.toString() : value)),
|
||||
};
|
||||
|
||||
export const urlSearchParamsBodySerializer = {
|
||||
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(
|
||||
body: T,
|
||||
): string => {
|
||||
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T): string => {
|
||||
const data = new URLSearchParams();
|
||||
|
||||
Object.entries(body).forEach(([key, value]) => {
|
||||
|
|
|
|||
|
|
@ -102,10 +102,7 @@ const stripEmptySlots = (params: Params) => {
|
|||
}
|
||||
};
|
||||
|
||||
export const buildClientParams = (
|
||||
args: ReadonlyArray<unknown>,
|
||||
fields: FieldsConfig,
|
||||
) => {
|
||||
export const buildClientParams = (args: ReadonlyArray<unknown>, fields: FieldsConfig) => {
|
||||
const params: Params = {
|
||||
body: {},
|
||||
headers: {},
|
||||
|
|
@ -148,15 +145,11 @@ export const buildClientParams = (
|
|||
params[field.map] = value;
|
||||
}
|
||||
} else {
|
||||
const extra = extraPrefixes.find(([prefix]) =>
|
||||
key.startsWith(prefix),
|
||||
);
|
||||
const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
|
||||
|
||||
if (extra) {
|
||||
const [prefix, slot] = extra;
|
||||
(params[slot] as Record<string, unknown>)[
|
||||
key.slice(prefix.length)
|
||||
] = value;
|
||||
(params[slot] as Record<string, unknown>)[key.slice(prefix.length)] = value;
|
||||
} else if ("allowExtra" in config && config.allowExtra) {
|
||||
for (const [slot, allowed] of Object.entries(config.allowExtra)) {
|
||||
if (allowed) {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
interface SerializeOptions<T>
|
||||
extends SerializePrimitiveOptions,
|
||||
SerializerOptions<T> {}
|
||||
interface SerializeOptions<T> extends SerializePrimitiveOptions, SerializerOptions<T> {}
|
||||
|
||||
interface SerializePrimitiveOptions {
|
||||
allowReserved?: boolean;
|
||||
|
|
@ -76,9 +74,9 @@ export const serializeArrayParam = ({
|
|||
value: unknown[];
|
||||
}) => {
|
||||
if (!explode) {
|
||||
const joinedValues = (
|
||||
allowReserved ? value : value.map((v) => encodeURIComponent(v as string))
|
||||
).join(separatorArrayNoExplode(style));
|
||||
const joinedValues = (allowReserved ? value : value.map((v) => encodeURIComponent(v as string))).join(
|
||||
separatorArrayNoExplode(style),
|
||||
);
|
||||
switch (style) {
|
||||
case "label":
|
||||
return `.${joinedValues}`;
|
||||
|
|
@ -105,16 +103,10 @@ export const serializeArrayParam = ({
|
|||
});
|
||||
})
|
||||
.join(separator);
|
||||
return style === "label" || style === "matrix"
|
||||
? separator + joinedValues
|
||||
: joinedValues;
|
||||
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
||||
};
|
||||
|
||||
export const serializePrimitiveParam = ({
|
||||
allowReserved,
|
||||
name,
|
||||
value,
|
||||
}: SerializePrimitiveParam) => {
|
||||
export const serializePrimitiveParam = ({ allowReserved, name, value }: SerializePrimitiveParam) => {
|
||||
if (value === undefined || value === null) {
|
||||
return "";
|
||||
}
|
||||
|
|
@ -146,11 +138,7 @@ export const serializeObjectParam = ({
|
|||
if (style !== "deepObject" && !explode) {
|
||||
let values: string[] = [];
|
||||
Object.entries(value).forEach(([key, v]) => {
|
||||
values = [
|
||||
...values,
|
||||
key,
|
||||
allowReserved ? (v as string) : encodeURIComponent(v as string),
|
||||
];
|
||||
values = [...values, key, allowReserved ? (v as string) : encodeURIComponent(v as string)];
|
||||
});
|
||||
const joinedValues = values.join(",");
|
||||
switch (style) {
|
||||
|
|
@ -175,7 +163,5 @@ export const serializeObjectParam = ({
|
|||
}),
|
||||
)
|
||||
.join(separator);
|
||||
return style === "label" || style === "matrix"
|
||||
? separator + joinedValues
|
||||
: joinedValues;
|
||||
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,23 +3,13 @@
|
|||
/**
|
||||
* JSON-friendly union that mirrors what Pinia Colada can hash.
|
||||
*/
|
||||
export type JsonValue =
|
||||
| null
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| JsonValue[]
|
||||
| { [key: string]: JsonValue };
|
||||
export type JsonValue = null | string | number | boolean | JsonValue[] | { [key: string]: JsonValue };
|
||||
|
||||
/**
|
||||
* Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
|
||||
*/
|
||||
export const queryKeyJsonReplacer = (_key: string, value: unknown) => {
|
||||
if (
|
||||
value === undefined ||
|
||||
typeof value === "function" ||
|
||||
typeof value === "symbol"
|
||||
) {
|
||||
if (value === undefined || typeof value === "function" || typeof value === "symbol") {
|
||||
return undefined;
|
||||
}
|
||||
if (typeof value === "bigint") {
|
||||
|
|
@ -61,9 +51,7 @@ const isPlainObject = (value: unknown): value is Record<string, unknown> => {
|
|||
* Turns URLSearchParams into a sorted JSON object for deterministic keys.
|
||||
*/
|
||||
const serializeSearchParams = (params: URLSearchParams): JsonValue => {
|
||||
const entries = Array.from(params.entries()).sort(([a], [b]) =>
|
||||
a.localeCompare(b),
|
||||
);
|
||||
const entries = Array.from(params.entries()).sort(([a], [b]) => a.localeCompare(b));
|
||||
const result: Record<string, JsonValue> = {};
|
||||
|
||||
for (const [key, value] of entries) {
|
||||
|
|
@ -86,26 +74,16 @@ const serializeSearchParams = (params: URLSearchParams): JsonValue => {
|
|||
/**
|
||||
* Normalizes any accepted value into a JSON-friendly shape for query keys.
|
||||
*/
|
||||
export const serializeQueryKeyValue = (
|
||||
value: unknown,
|
||||
): JsonValue | undefined => {
|
||||
export const serializeQueryKeyValue = (value: unknown): JsonValue | undefined => {
|
||||
if (value === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (
|
||||
typeof value === "string" ||
|
||||
typeof value === "number" ||
|
||||
typeof value === "boolean"
|
||||
) {
|
||||
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (
|
||||
value === undefined ||
|
||||
typeof value === "function" ||
|
||||
typeof value === "symbol"
|
||||
) {
|
||||
if (value === undefined || typeof value === "function" || typeof value === "symbol") {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
|
@ -121,10 +99,7 @@ export const serializeQueryKeyValue = (
|
|||
return stringifyToJsonValue(value);
|
||||
}
|
||||
|
||||
if (
|
||||
typeof URLSearchParams !== "undefined" &&
|
||||
value instanceof URLSearchParams
|
||||
) {
|
||||
if (typeof URLSearchParams !== "undefined" && value instanceof URLSearchParams) {
|
||||
return serializeSearchParams(value);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,7 @@
|
|||
|
||||
import type { Config } from "./types.gen";
|
||||
|
||||
export type ServerSentEventsOptions<TData = unknown> = Omit<
|
||||
RequestInit,
|
||||
"method"
|
||||
> &
|
||||
export type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, "method"> &
|
||||
Pick<Config, "method" | "responseTransformer" | "responseValidator"> & {
|
||||
/**
|
||||
* Fetch API implementation. You can use this option to provide a custom
|
||||
|
|
@ -74,16 +71,8 @@ export interface StreamEvent<TData = unknown> {
|
|||
retry?: number;
|
||||
}
|
||||
|
||||
export type ServerSentEventsResult<
|
||||
TData = unknown,
|
||||
TReturn = void,
|
||||
TNext = unknown,
|
||||
> = {
|
||||
stream: AsyncGenerator<
|
||||
TData extends Record<string, unknown> ? TData[keyof TData] : TData,
|
||||
TReturn,
|
||||
TNext
|
||||
>;
|
||||
export type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = {
|
||||
stream: AsyncGenerator<TData extends Record<string, unknown> ? TData[keyof TData] : TData, TReturn, TNext>;
|
||||
};
|
||||
|
||||
export const createSseClient = <TData = unknown>({
|
||||
|
|
@ -101,9 +90,7 @@ export const createSseClient = <TData = unknown>({
|
|||
}: ServerSentEventsOptions): ServerSentEventsResult<TData> => {
|
||||
let lastEventId: string | undefined;
|
||||
|
||||
const sleep =
|
||||
sseSleepFn ??
|
||||
((ms: number) => new Promise((resolve) => setTimeout(resolve, ms)));
|
||||
const sleep = sseSleepFn ?? ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms)));
|
||||
|
||||
const createStream = async function* () {
|
||||
let retryDelay: number = sseDefaultRetryDelay ?? 3000;
|
||||
|
|
@ -141,16 +128,11 @@ export const createSseClient = <TData = unknown>({
|
|||
const _fetch = options.fetch ?? globalThis.fetch;
|
||||
const response = await _fetch(request);
|
||||
|
||||
if (!response.ok)
|
||||
throw new Error(
|
||||
`SSE failed: ${response.status} ${response.statusText}`,
|
||||
);
|
||||
if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
|
||||
|
||||
if (!response.body) throw new Error("No body in SSE response");
|
||||
|
||||
const reader = response.body
|
||||
.pipeThrough(new TextDecoderStream())
|
||||
.getReader();
|
||||
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
|
||||
|
||||
let buffer = "";
|
||||
|
||||
|
|
@ -188,10 +170,7 @@ export const createSseClient = <TData = unknown>({
|
|||
} else if (line.startsWith("id:")) {
|
||||
lastEventId = line.replace(/^id:\s*/, "");
|
||||
} else if (line.startsWith("retry:")) {
|
||||
const parsed = Number.parseInt(
|
||||
line.replace(/^retry:\s*/, ""),
|
||||
10,
|
||||
);
|
||||
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
|
||||
if (!Number.isNaN(parsed)) {
|
||||
retryDelay = parsed;
|
||||
}
|
||||
|
|
@ -243,18 +222,12 @@ export const createSseClient = <TData = unknown>({
|
|||
// connection failed or aborted; retry after delay
|
||||
onSseError?.(error);
|
||||
|
||||
if (
|
||||
sseMaxRetryAttempts !== undefined &&
|
||||
attempt >= sseMaxRetryAttempts
|
||||
) {
|
||||
if (sseMaxRetryAttempts !== undefined && attempt >= sseMaxRetryAttempts) {
|
||||
break; // stop after firing error
|
||||
}
|
||||
|
||||
// exponential backoff: double retry each attempt, cap at 30s
|
||||
const backoff = Math.min(
|
||||
retryDelay * 2 ** (attempt - 1),
|
||||
sseMaxRetryDelay ?? 30000,
|
||||
);
|
||||
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 30000);
|
||||
await sleep(backoff);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,30 +1,11 @@
|
|||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
import type { Auth, AuthToken } from "./auth.gen";
|
||||
import type {
|
||||
BodySerializer,
|
||||
QuerySerializer,
|
||||
QuerySerializerOptions,
|
||||
} from "./bodySerializer.gen";
|
||||
import type { BodySerializer, QuerySerializer, QuerySerializerOptions } from "./bodySerializer.gen";
|
||||
|
||||
export type HttpMethod =
|
||||
| "connect"
|
||||
| "delete"
|
||||
| "get"
|
||||
| "head"
|
||||
| "options"
|
||||
| "patch"
|
||||
| "post"
|
||||
| "put"
|
||||
| "trace";
|
||||
export type HttpMethod = "connect" | "delete" | "get" | "head" | "options" | "patch" | "post" | "put" | "trace";
|
||||
|
||||
export type Client<
|
||||
RequestFn = never,
|
||||
Config = unknown,
|
||||
MethodFn = never,
|
||||
BuildUrlFn = never,
|
||||
SseFn = never,
|
||||
> = {
|
||||
export type Client<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never, SseFn = never> = {
|
||||
/**
|
||||
* Returns the final request URL.
|
||||
*/
|
||||
|
|
@ -34,9 +15,7 @@ export type Client<
|
|||
setConfig: (config: Config) => Config;
|
||||
} & {
|
||||
[K in HttpMethod]: MethodFn;
|
||||
} & ([SseFn] extends [never]
|
||||
? { sse?: never }
|
||||
: { sse: { [K in HttpMethod]: SseFn } });
|
||||
} & ([SseFn] extends [never] ? { sse?: never } : { sse: { [K in HttpMethod]: SseFn } });
|
||||
|
||||
export interface Config {
|
||||
/**
|
||||
|
|
@ -57,16 +36,7 @@ export interface Config {
|
|||
*/
|
||||
headers?:
|
||||
| RequestInit["headers"]
|
||||
| Record<
|
||||
string,
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| (string | number | boolean)[]
|
||||
| null
|
||||
| undefined
|
||||
| unknown
|
||||
>;
|
||||
| Record<string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown>;
|
||||
/**
|
||||
* The request method.
|
||||
*
|
||||
|
|
@ -112,7 +82,5 @@ type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never]
|
|||
: false;
|
||||
|
||||
export type OmitNever<T extends Record<string, unknown>> = {
|
||||
[K in keyof T as IsExactlyNeverOrNeverUndefined<T[K]> extends true
|
||||
? never
|
||||
: K]: T[K];
|
||||
[K in keyof T as IsExactlyNeverOrNeverUndefined<T[K]> extends true ? never : K]: T[K];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -44,10 +44,7 @@ export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
|
|||
}
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
url = url.replace(
|
||||
match,
|
||||
serializeArrayParam({ explode, name, style, value }),
|
||||
);
|
||||
url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -76,9 +73,7 @@ export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
|
|||
continue;
|
||||
}
|
||||
|
||||
const replaceValue = encodeURIComponent(
|
||||
style === "label" ? `.${value as string}` : (value as string),
|
||||
);
|
||||
const replaceValue = encodeURIComponent(style === "label" ? `.${value as string}` : (value as string));
|
||||
url = url.replace(match, replaceValue);
|
||||
}
|
||||
}
|
||||
|
|
@ -123,8 +118,7 @@ export function getValidRequestBody(options: {
|
|||
|
||||
if (isSerializedBody) {
|
||||
if ("serializedBody" in options) {
|
||||
const hasSerializedBody =
|
||||
options.serializedBody !== undefined && options.serializedBody !== "";
|
||||
const hasSerializedBody = options.serializedBody !== undefined && options.serializedBody !== "";
|
||||
|
||||
return hasSerializedBody ? options.serializedBody : null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,10 +114,10 @@ import type {
|
|||
UpdateVolumeResponses,
|
||||
} from "./types.gen";
|
||||
|
||||
export type Options<
|
||||
TData extends TDataShape = TDataShape,
|
||||
ThrowOnError extends boolean = boolean,
|
||||
> = Options2<TData, ThrowOnError> & {
|
||||
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<
|
||||
TData,
|
||||
ThrowOnError
|
||||
> & {
|
||||
/**
|
||||
* You can provide a client instance returned by `createClient()` instead of
|
||||
* individual options. This might be also useful if you want to implement a
|
||||
|
|
@ -134,9 +134,7 @@ export type Options<
|
|||
/**
|
||||
* Get authentication system status
|
||||
*/
|
||||
export const getStatus = <ThrowOnError extends boolean = false>(
|
||||
options?: Options<GetStatusData, ThrowOnError>,
|
||||
) =>
|
||||
export const getStatus = <ThrowOnError extends boolean = false>(options?: Options<GetStatusData, ThrowOnError>) =>
|
||||
(options?.client ?? client).get<GetStatusResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/auth/status",
|
||||
...options,
|
||||
|
|
@ -145,25 +143,14 @@ export const getStatus = <ThrowOnError extends boolean = false>(
|
|||
/**
|
||||
* List all volumes
|
||||
*/
|
||||
export const listVolumes = <ThrowOnError extends boolean = false>(
|
||||
options?: Options<ListVolumesData, ThrowOnError>,
|
||||
) =>
|
||||
(options?.client ?? client).get<ListVolumesResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/volumes",
|
||||
...options,
|
||||
});
|
||||
export const listVolumes = <ThrowOnError extends boolean = false>(options?: Options<ListVolumesData, ThrowOnError>) =>
|
||||
(options?.client ?? client).get<ListVolumesResponses, unknown, ThrowOnError>({ url: "/api/v1/volumes", ...options });
|
||||
|
||||
/**
|
||||
* Create a new volume
|
||||
*/
|
||||
export const createVolume = <ThrowOnError extends boolean = false>(
|
||||
options?: Options<CreateVolumeData, ThrowOnError>,
|
||||
) =>
|
||||
(options?.client ?? client).post<
|
||||
CreateVolumeResponses,
|
||||
unknown,
|
||||
ThrowOnError
|
||||
>({
|
||||
export const createVolume = <ThrowOnError extends boolean = false>(options?: Options<CreateVolumeData, ThrowOnError>) =>
|
||||
(options?.client ?? client).post<CreateVolumeResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/volumes",
|
||||
...options,
|
||||
headers: {
|
||||
|
|
@ -178,11 +165,7 @@ export const createVolume = <ThrowOnError extends boolean = false>(
|
|||
export const testConnection = <ThrowOnError extends boolean = false>(
|
||||
options?: Options<TestConnectionData, ThrowOnError>,
|
||||
) =>
|
||||
(options?.client ?? client).post<
|
||||
TestConnectionResponses,
|
||||
unknown,
|
||||
ThrowOnError
|
||||
>({
|
||||
(options?.client ?? client).post<TestConnectionResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/volumes/test-connection",
|
||||
...options,
|
||||
headers: {
|
||||
|
|
@ -194,38 +177,26 @@ export const testConnection = <ThrowOnError extends boolean = false>(
|
|||
/**
|
||||
* Delete a volume
|
||||
*/
|
||||
export const deleteVolume = <ThrowOnError extends boolean = false>(
|
||||
options: Options<DeleteVolumeData, ThrowOnError>,
|
||||
) =>
|
||||
(options.client ?? client).delete<
|
||||
DeleteVolumeResponses,
|
||||
unknown,
|
||||
ThrowOnError
|
||||
>({ url: "/api/v1/volumes/{name}", ...options });
|
||||
export const deleteVolume = <ThrowOnError extends boolean = false>(options: Options<DeleteVolumeData, ThrowOnError>) =>
|
||||
(options.client ?? client).delete<DeleteVolumeResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/volumes/{name}",
|
||||
...options,
|
||||
});
|
||||
|
||||
/**
|
||||
* Get a volume by name
|
||||
*/
|
||||
export const getVolume = <ThrowOnError extends boolean = false>(
|
||||
options: Options<GetVolumeData, ThrowOnError>,
|
||||
) =>
|
||||
(options.client ?? client).get<
|
||||
GetVolumeResponses,
|
||||
GetVolumeErrors,
|
||||
ThrowOnError
|
||||
>({ url: "/api/v1/volumes/{name}", ...options });
|
||||
export const getVolume = <ThrowOnError extends boolean = false>(options: Options<GetVolumeData, ThrowOnError>) =>
|
||||
(options.client ?? client).get<GetVolumeResponses, GetVolumeErrors, ThrowOnError>({
|
||||
url: "/api/v1/volumes/{name}",
|
||||
...options,
|
||||
});
|
||||
|
||||
/**
|
||||
* Update a volume's configuration
|
||||
*/
|
||||
export const updateVolume = <ThrowOnError extends boolean = false>(
|
||||
options: Options<UpdateVolumeData, ThrowOnError>,
|
||||
) =>
|
||||
(options.client ?? client).put<
|
||||
UpdateVolumeResponses,
|
||||
UpdateVolumeErrors,
|
||||
ThrowOnError
|
||||
>({
|
||||
export const updateVolume = <ThrowOnError extends boolean = false>(options: Options<UpdateVolumeData, ThrowOnError>) =>
|
||||
(options.client ?? client).put<UpdateVolumeResponses, UpdateVolumeErrors, ThrowOnError>({
|
||||
url: "/api/v1/volumes/{name}",
|
||||
...options,
|
||||
headers: {
|
||||
|
|
@ -237,9 +208,7 @@ export const updateVolume = <ThrowOnError extends boolean = false>(
|
|||
/**
|
||||
* Mount a volume
|
||||
*/
|
||||
export const mountVolume = <ThrowOnError extends boolean = false>(
|
||||
options: Options<MountVolumeData, ThrowOnError>,
|
||||
) =>
|
||||
export const mountVolume = <ThrowOnError extends boolean = false>(options: Options<MountVolumeData, ThrowOnError>) =>
|
||||
(options.client ?? client).post<MountVolumeResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/volumes/{name}/mount",
|
||||
...options,
|
||||
|
|
@ -251,11 +220,10 @@ export const mountVolume = <ThrowOnError extends boolean = false>(
|
|||
export const unmountVolume = <ThrowOnError extends boolean = false>(
|
||||
options: Options<UnmountVolumeData, ThrowOnError>,
|
||||
) =>
|
||||
(options.client ?? client).post<
|
||||
UnmountVolumeResponses,
|
||||
unknown,
|
||||
ThrowOnError
|
||||
>({ url: "/api/v1/volumes/{name}/unmount", ...options });
|
||||
(options.client ?? client).post<UnmountVolumeResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/volumes/{name}/unmount",
|
||||
...options,
|
||||
});
|
||||
|
||||
/**
|
||||
* Perform a health check on a volume
|
||||
|
|
@ -263,18 +231,15 @@ export const unmountVolume = <ThrowOnError extends boolean = false>(
|
|||
export const healthCheckVolume = <ThrowOnError extends boolean = false>(
|
||||
options: Options<HealthCheckVolumeData, ThrowOnError>,
|
||||
) =>
|
||||
(options.client ?? client).post<
|
||||
HealthCheckVolumeResponses,
|
||||
HealthCheckVolumeErrors,
|
||||
ThrowOnError
|
||||
>({ url: "/api/v1/volumes/{name}/health-check", ...options });
|
||||
(options.client ?? client).post<HealthCheckVolumeResponses, HealthCheckVolumeErrors, ThrowOnError>({
|
||||
url: "/api/v1/volumes/{name}/health-check",
|
||||
...options,
|
||||
});
|
||||
|
||||
/**
|
||||
* List files in a volume directory
|
||||
*/
|
||||
export const listFiles = <ThrowOnError extends boolean = false>(
|
||||
options: Options<ListFilesData, ThrowOnError>,
|
||||
) =>
|
||||
export const listFiles = <ThrowOnError extends boolean = false>(options: Options<ListFilesData, ThrowOnError>) =>
|
||||
(options.client ?? client).get<ListFilesResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/volumes/{name}/files",
|
||||
...options,
|
||||
|
|
@ -286,11 +251,10 @@ export const listFiles = <ThrowOnError extends boolean = false>(
|
|||
export const browseFilesystem = <ThrowOnError extends boolean = false>(
|
||||
options?: Options<BrowseFilesystemData, ThrowOnError>,
|
||||
) =>
|
||||
(options?.client ?? client).get<
|
||||
BrowseFilesystemResponses,
|
||||
unknown,
|
||||
ThrowOnError
|
||||
>({ url: "/api/v1/volumes/filesystem/browse", ...options });
|
||||
(options?.client ?? client).get<BrowseFilesystemResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/volumes/filesystem/browse",
|
||||
...options,
|
||||
});
|
||||
|
||||
/**
|
||||
* List all repositories
|
||||
|
|
@ -298,11 +262,10 @@ export const browseFilesystem = <ThrowOnError extends boolean = false>(
|
|||
export const listRepositories = <ThrowOnError extends boolean = false>(
|
||||
options?: Options<ListRepositoriesData, ThrowOnError>,
|
||||
) =>
|
||||
(options?.client ?? client).get<
|
||||
ListRepositoriesResponses,
|
||||
unknown,
|
||||
ThrowOnError
|
||||
>({ url: "/api/v1/repositories", ...options });
|
||||
(options?.client ?? client).get<ListRepositoriesResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/repositories",
|
||||
...options,
|
||||
});
|
||||
|
||||
/**
|
||||
* Create a new restic repository
|
||||
|
|
@ -310,11 +273,7 @@ export const listRepositories = <ThrowOnError extends boolean = false>(
|
|||
export const createRepository = <ThrowOnError extends boolean = false>(
|
||||
options?: Options<CreateRepositoryData, ThrowOnError>,
|
||||
) =>
|
||||
(options?.client ?? client).post<
|
||||
CreateRepositoryResponses,
|
||||
unknown,
|
||||
ThrowOnError
|
||||
>({
|
||||
(options?.client ?? client).post<CreateRepositoryResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/repositories",
|
||||
...options,
|
||||
headers: {
|
||||
|
|
@ -329,11 +288,10 @@ export const createRepository = <ThrowOnError extends boolean = false>(
|
|||
export const listRcloneRemotes = <ThrowOnError extends boolean = false>(
|
||||
options?: Options<ListRcloneRemotesData, ThrowOnError>,
|
||||
) =>
|
||||
(options?.client ?? client).get<
|
||||
ListRcloneRemotesResponses,
|
||||
unknown,
|
||||
ThrowOnError
|
||||
>({ url: "/api/v1/repositories/rclone-remotes", ...options });
|
||||
(options?.client ?? client).get<ListRcloneRemotesResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/repositories/rclone-remotes",
|
||||
...options,
|
||||
});
|
||||
|
||||
/**
|
||||
* Delete a repository
|
||||
|
|
@ -341,11 +299,10 @@ export const listRcloneRemotes = <ThrowOnError extends boolean = false>(
|
|||
export const deleteRepository = <ThrowOnError extends boolean = false>(
|
||||
options: Options<DeleteRepositoryData, ThrowOnError>,
|
||||
) =>
|
||||
(options.client ?? client).delete<
|
||||
DeleteRepositoryResponses,
|
||||
unknown,
|
||||
ThrowOnError
|
||||
>({ url: "/api/v1/repositories/{id}", ...options });
|
||||
(options.client ?? client).delete<DeleteRepositoryResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/repositories/{id}",
|
||||
...options,
|
||||
});
|
||||
|
||||
/**
|
||||
* Get a single repository by ID
|
||||
|
|
@ -353,9 +310,10 @@ export const deleteRepository = <ThrowOnError extends boolean = false>(
|
|||
export const getRepository = <ThrowOnError extends boolean = false>(
|
||||
options: Options<GetRepositoryData, ThrowOnError>,
|
||||
) =>
|
||||
(options.client ?? client).get<GetRepositoryResponses, unknown, ThrowOnError>(
|
||||
{ url: "/api/v1/repositories/{id}", ...options },
|
||||
);
|
||||
(options.client ?? client).get<GetRepositoryResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/repositories/{id}",
|
||||
...options,
|
||||
});
|
||||
|
||||
/**
|
||||
* Update a repository's name or settings
|
||||
|
|
@ -363,11 +321,7 @@ export const getRepository = <ThrowOnError extends boolean = false>(
|
|||
export const updateRepository = <ThrowOnError extends boolean = false>(
|
||||
options: Options<UpdateRepositoryData, ThrowOnError>,
|
||||
) =>
|
||||
(options.client ?? client).patch<
|
||||
UpdateRepositoryResponses,
|
||||
UpdateRepositoryErrors,
|
||||
ThrowOnError
|
||||
>({
|
||||
(options.client ?? client).patch<UpdateRepositoryResponses, UpdateRepositoryErrors, ThrowOnError>({
|
||||
url: "/api/v1/repositories/{id}",
|
||||
...options,
|
||||
headers: {
|
||||
|
|
@ -382,11 +336,7 @@ export const updateRepository = <ThrowOnError extends boolean = false>(
|
|||
export const deleteSnapshots = <ThrowOnError extends boolean = false>(
|
||||
options: Options<DeleteSnapshotsData, ThrowOnError>,
|
||||
) =>
|
||||
(options.client ?? client).delete<
|
||||
DeleteSnapshotsResponses,
|
||||
unknown,
|
||||
ThrowOnError
|
||||
>({
|
||||
(options.client ?? client).delete<DeleteSnapshotsResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/repositories/{id}/snapshots",
|
||||
...options,
|
||||
headers: {
|
||||
|
|
@ -401,9 +351,10 @@ export const deleteSnapshots = <ThrowOnError extends boolean = false>(
|
|||
export const listSnapshots = <ThrowOnError extends boolean = false>(
|
||||
options: Options<ListSnapshotsData, ThrowOnError>,
|
||||
) =>
|
||||
(options.client ?? client).get<ListSnapshotsResponses, unknown, ThrowOnError>(
|
||||
{ url: "/api/v1/repositories/{id}/snapshots", ...options },
|
||||
);
|
||||
(options.client ?? client).get<ListSnapshotsResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/repositories/{id}/snapshots",
|
||||
...options,
|
||||
});
|
||||
|
||||
/**
|
||||
* Delete a specific snapshot from a repository
|
||||
|
|
@ -411,11 +362,10 @@ export const listSnapshots = <ThrowOnError extends boolean = false>(
|
|||
export const deleteSnapshot = <ThrowOnError extends boolean = false>(
|
||||
options: Options<DeleteSnapshotData, ThrowOnError>,
|
||||
) =>
|
||||
(options.client ?? client).delete<
|
||||
DeleteSnapshotResponses,
|
||||
unknown,
|
||||
ThrowOnError
|
||||
>({ url: "/api/v1/repositories/{id}/snapshots/{snapshotId}", ...options });
|
||||
(options.client ?? client).delete<DeleteSnapshotResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/repositories/{id}/snapshots/{snapshotId}",
|
||||
...options,
|
||||
});
|
||||
|
||||
/**
|
||||
* Get details of a specific snapshot
|
||||
|
|
@ -423,11 +373,10 @@ export const deleteSnapshot = <ThrowOnError extends boolean = false>(
|
|||
export const getSnapshotDetails = <ThrowOnError extends boolean = false>(
|
||||
options: Options<GetSnapshotDetailsData, ThrowOnError>,
|
||||
) =>
|
||||
(options.client ?? client).get<
|
||||
GetSnapshotDetailsResponses,
|
||||
unknown,
|
||||
ThrowOnError
|
||||
>({ url: "/api/v1/repositories/{id}/snapshots/{snapshotId}", ...options });
|
||||
(options.client ?? client).get<GetSnapshotDetailsResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/repositories/{id}/snapshots/{snapshotId}",
|
||||
...options,
|
||||
});
|
||||
|
||||
/**
|
||||
* List files and directories in a snapshot
|
||||
|
|
@ -435,11 +384,7 @@ export const getSnapshotDetails = <ThrowOnError extends boolean = false>(
|
|||
export const listSnapshotFiles = <ThrowOnError extends boolean = false>(
|
||||
options: Options<ListSnapshotFilesData, ThrowOnError>,
|
||||
) =>
|
||||
(options.client ?? client).get<
|
||||
ListSnapshotFilesResponses,
|
||||
unknown,
|
||||
ThrowOnError
|
||||
>({
|
||||
(options.client ?? client).get<ListSnapshotFilesResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/repositories/{id}/snapshots/{snapshotId}/files",
|
||||
...options,
|
||||
});
|
||||
|
|
@ -450,11 +395,7 @@ export const listSnapshotFiles = <ThrowOnError extends boolean = false>(
|
|||
export const restoreSnapshot = <ThrowOnError extends boolean = false>(
|
||||
options: Options<RestoreSnapshotData, ThrowOnError>,
|
||||
) =>
|
||||
(options.client ?? client).post<
|
||||
RestoreSnapshotResponses,
|
||||
unknown,
|
||||
ThrowOnError
|
||||
>({
|
||||
(options.client ?? client).post<RestoreSnapshotResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/repositories/{id}/restore",
|
||||
...options,
|
||||
headers: {
|
||||
|
|
@ -469,28 +410,23 @@ export const restoreSnapshot = <ThrowOnError extends boolean = false>(
|
|||
export const doctorRepository = <ThrowOnError extends boolean = false>(
|
||||
options: Options<DoctorRepositoryData, ThrowOnError>,
|
||||
) =>
|
||||
(options.client ?? client).post<
|
||||
DoctorRepositoryResponses,
|
||||
unknown,
|
||||
ThrowOnError
|
||||
>({ url: "/api/v1/repositories/{id}/doctor", ...options });
|
||||
(options.client ?? client).post<DoctorRepositoryResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/repositories/{id}/doctor",
|
||||
...options,
|
||||
});
|
||||
|
||||
/**
|
||||
* Tag multiple snapshots in a repository
|
||||
*/
|
||||
export const tagSnapshots = <ThrowOnError extends boolean = false>(
|
||||
options: Options<TagSnapshotsData, ThrowOnError>,
|
||||
) =>
|
||||
(options.client ?? client).post<TagSnapshotsResponses, unknown, ThrowOnError>(
|
||||
{
|
||||
url: "/api/v1/repositories/{id}/snapshots/tag",
|
||||
...options,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
...options.headers,
|
||||
},
|
||||
export const tagSnapshots = <ThrowOnError extends boolean = false>(options: Options<TagSnapshotsData, ThrowOnError>) =>
|
||||
(options.client ?? client).post<TagSnapshotsResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/repositories/{id}/snapshots/tag",
|
||||
...options,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
...options.headers,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* List all backup schedules
|
||||
|
|
@ -498,11 +434,10 @@ export const tagSnapshots = <ThrowOnError extends boolean = false>(
|
|||
export const listBackupSchedules = <ThrowOnError extends boolean = false>(
|
||||
options?: Options<ListBackupSchedulesData, ThrowOnError>,
|
||||
) =>
|
||||
(options?.client ?? client).get<
|
||||
ListBackupSchedulesResponses,
|
||||
unknown,
|
||||
ThrowOnError
|
||||
>({ url: "/api/v1/backups", ...options });
|
||||
(options?.client ?? client).get<ListBackupSchedulesResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/backups",
|
||||
...options,
|
||||
});
|
||||
|
||||
/**
|
||||
* Create a new backup schedule for a volume
|
||||
|
|
@ -510,11 +445,7 @@ export const listBackupSchedules = <ThrowOnError extends boolean = false>(
|
|||
export const createBackupSchedule = <ThrowOnError extends boolean = false>(
|
||||
options?: Options<CreateBackupScheduleData, ThrowOnError>,
|
||||
) =>
|
||||
(options?.client ?? client).post<
|
||||
CreateBackupScheduleResponses,
|
||||
unknown,
|
||||
ThrowOnError
|
||||
>({
|
||||
(options?.client ?? client).post<CreateBackupScheduleResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/backups",
|
||||
...options,
|
||||
headers: {
|
||||
|
|
@ -529,11 +460,10 @@ export const createBackupSchedule = <ThrowOnError extends boolean = false>(
|
|||
export const deleteBackupSchedule = <ThrowOnError extends boolean = false>(
|
||||
options: Options<DeleteBackupScheduleData, ThrowOnError>,
|
||||
) =>
|
||||
(options.client ?? client).delete<
|
||||
DeleteBackupScheduleResponses,
|
||||
unknown,
|
||||
ThrowOnError
|
||||
>({ url: "/api/v1/backups/{scheduleId}", ...options });
|
||||
(options.client ?? client).delete<DeleteBackupScheduleResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/backups/{scheduleId}",
|
||||
...options,
|
||||
});
|
||||
|
||||
/**
|
||||
* Get a backup schedule by ID
|
||||
|
|
@ -541,11 +471,10 @@ export const deleteBackupSchedule = <ThrowOnError extends boolean = false>(
|
|||
export const getBackupSchedule = <ThrowOnError extends boolean = false>(
|
||||
options: Options<GetBackupScheduleData, ThrowOnError>,
|
||||
) =>
|
||||
(options.client ?? client).get<
|
||||
GetBackupScheduleResponses,
|
||||
unknown,
|
||||
ThrowOnError
|
||||
>({ url: "/api/v1/backups/{scheduleId}", ...options });
|
||||
(options.client ?? client).get<GetBackupScheduleResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/backups/{scheduleId}",
|
||||
...options,
|
||||
});
|
||||
|
||||
/**
|
||||
* Update a backup schedule
|
||||
|
|
@ -553,11 +482,7 @@ export const getBackupSchedule = <ThrowOnError extends boolean = false>(
|
|||
export const updateBackupSchedule = <ThrowOnError extends boolean = false>(
|
||||
options: Options<UpdateBackupScheduleData, ThrowOnError>,
|
||||
) =>
|
||||
(options.client ?? client).patch<
|
||||
UpdateBackupScheduleResponses,
|
||||
unknown,
|
||||
ThrowOnError
|
||||
>({
|
||||
(options.client ?? client).patch<UpdateBackupScheduleResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/backups/{scheduleId}",
|
||||
...options,
|
||||
headers: {
|
||||
|
|
@ -569,45 +494,36 @@ export const updateBackupSchedule = <ThrowOnError extends boolean = false>(
|
|||
/**
|
||||
* Get a backup schedule for a specific volume
|
||||
*/
|
||||
export const getBackupScheduleForVolume = <
|
||||
ThrowOnError extends boolean = false,
|
||||
>(
|
||||
export const getBackupScheduleForVolume = <ThrowOnError extends boolean = false>(
|
||||
options: Options<GetBackupScheduleForVolumeData, ThrowOnError>,
|
||||
) =>
|
||||
(options.client ?? client).get<
|
||||
GetBackupScheduleForVolumeResponses,
|
||||
unknown,
|
||||
ThrowOnError
|
||||
>({ url: "/api/v1/backups/volume/{volumeId}", ...options });
|
||||
(options.client ?? client).get<GetBackupScheduleForVolumeResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/backups/volume/{volumeId}",
|
||||
...options,
|
||||
});
|
||||
|
||||
/**
|
||||
* Trigger a backup immediately for a schedule
|
||||
*/
|
||||
export const runBackupNow = <ThrowOnError extends boolean = false>(
|
||||
options: Options<RunBackupNowData, ThrowOnError>,
|
||||
) =>
|
||||
(options.client ?? client).post<RunBackupNowResponses, unknown, ThrowOnError>(
|
||||
{ url: "/api/v1/backups/{scheduleId}/run", ...options },
|
||||
);
|
||||
export const runBackupNow = <ThrowOnError extends boolean = false>(options: Options<RunBackupNowData, ThrowOnError>) =>
|
||||
(options.client ?? client).post<RunBackupNowResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/backups/{scheduleId}/run",
|
||||
...options,
|
||||
});
|
||||
|
||||
/**
|
||||
* Stop a backup that is currently in progress
|
||||
*/
|
||||
export const stopBackup = <ThrowOnError extends boolean = false>(
|
||||
options: Options<StopBackupData, ThrowOnError>,
|
||||
) =>
|
||||
(options.client ?? client).post<
|
||||
StopBackupResponses,
|
||||
StopBackupErrors,
|
||||
ThrowOnError
|
||||
>({ url: "/api/v1/backups/{scheduleId}/stop", ...options });
|
||||
export const stopBackup = <ThrowOnError extends boolean = false>(options: Options<StopBackupData, ThrowOnError>) =>
|
||||
(options.client ?? client).post<StopBackupResponses, StopBackupErrors, ThrowOnError>({
|
||||
url: "/api/v1/backups/{scheduleId}/stop",
|
||||
...options,
|
||||
});
|
||||
|
||||
/**
|
||||
* Manually apply retention policy to clean up old snapshots
|
||||
*/
|
||||
export const runForget = <ThrowOnError extends boolean = false>(
|
||||
options: Options<RunForgetData, ThrowOnError>,
|
||||
) =>
|
||||
export const runForget = <ThrowOnError extends boolean = false>(options: Options<RunForgetData, ThrowOnError>) =>
|
||||
(options.client ?? client).post<RunForgetResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/backups/{scheduleId}/forget",
|
||||
...options,
|
||||
|
|
@ -619,25 +535,18 @@ export const runForget = <ThrowOnError extends boolean = false>(
|
|||
export const getScheduleNotifications = <ThrowOnError extends boolean = false>(
|
||||
options: Options<GetScheduleNotificationsData, ThrowOnError>,
|
||||
) =>
|
||||
(options.client ?? client).get<
|
||||
GetScheduleNotificationsResponses,
|
||||
unknown,
|
||||
ThrowOnError
|
||||
>({ url: "/api/v1/backups/{scheduleId}/notifications", ...options });
|
||||
(options.client ?? client).get<GetScheduleNotificationsResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/backups/{scheduleId}/notifications",
|
||||
...options,
|
||||
});
|
||||
|
||||
/**
|
||||
* Update notification assignments for a backup schedule
|
||||
*/
|
||||
export const updateScheduleNotifications = <
|
||||
ThrowOnError extends boolean = false,
|
||||
>(
|
||||
export const updateScheduleNotifications = <ThrowOnError extends boolean = false>(
|
||||
options: Options<UpdateScheduleNotificationsData, ThrowOnError>,
|
||||
) =>
|
||||
(options.client ?? client).put<
|
||||
UpdateScheduleNotificationsResponses,
|
||||
unknown,
|
||||
ThrowOnError
|
||||
>({
|
||||
(options.client ?? client).put<UpdateScheduleNotificationsResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/backups/{scheduleId}/notifications",
|
||||
...options,
|
||||
headers: {
|
||||
|
|
@ -652,11 +561,10 @@ export const updateScheduleNotifications = <
|
|||
export const getScheduleMirrors = <ThrowOnError extends boolean = false>(
|
||||
options: Options<GetScheduleMirrorsData, ThrowOnError>,
|
||||
) =>
|
||||
(options.client ?? client).get<
|
||||
GetScheduleMirrorsResponses,
|
||||
unknown,
|
||||
ThrowOnError
|
||||
>({ url: "/api/v1/backups/{scheduleId}/mirrors", ...options });
|
||||
(options.client ?? client).get<GetScheduleMirrorsResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/backups/{scheduleId}/mirrors",
|
||||
...options,
|
||||
});
|
||||
|
||||
/**
|
||||
* Update mirror repository assignments for a backup schedule
|
||||
|
|
@ -664,11 +572,7 @@ export const getScheduleMirrors = <ThrowOnError extends boolean = false>(
|
|||
export const updateScheduleMirrors = <ThrowOnError extends boolean = false>(
|
||||
options: Options<UpdateScheduleMirrorsData, ThrowOnError>,
|
||||
) =>
|
||||
(options.client ?? client).put<
|
||||
UpdateScheduleMirrorsResponses,
|
||||
unknown,
|
||||
ThrowOnError
|
||||
>({
|
||||
(options.client ?? client).put<UpdateScheduleMirrorsResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/backups/{scheduleId}/mirrors",
|
||||
...options,
|
||||
headers: {
|
||||
|
|
@ -683,11 +587,10 @@ export const updateScheduleMirrors = <ThrowOnError extends boolean = false>(
|
|||
export const getMirrorCompatibility = <ThrowOnError extends boolean = false>(
|
||||
options: Options<GetMirrorCompatibilityData, ThrowOnError>,
|
||||
) =>
|
||||
(options.client ?? client).get<
|
||||
GetMirrorCompatibilityResponses,
|
||||
unknown,
|
||||
ThrowOnError
|
||||
>({ url: "/api/v1/backups/{scheduleId}/mirrors/compatibility", ...options });
|
||||
(options.client ?? client).get<GetMirrorCompatibilityResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/backups/{scheduleId}/mirrors/compatibility",
|
||||
...options,
|
||||
});
|
||||
|
||||
/**
|
||||
* Reorder backup schedules by providing an array of schedule IDs in the desired order
|
||||
|
|
@ -695,11 +598,7 @@ export const getMirrorCompatibility = <ThrowOnError extends boolean = false>(
|
|||
export const reorderBackupSchedules = <ThrowOnError extends boolean = false>(
|
||||
options?: Options<ReorderBackupSchedulesData, ThrowOnError>,
|
||||
) =>
|
||||
(options?.client ?? client).post<
|
||||
ReorderBackupSchedulesResponses,
|
||||
unknown,
|
||||
ThrowOnError
|
||||
>({
|
||||
(options?.client ?? client).post<ReorderBackupSchedulesResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/backups/reorder",
|
||||
...options,
|
||||
headers: {
|
||||
|
|
@ -711,30 +610,21 @@ export const reorderBackupSchedules = <ThrowOnError extends boolean = false>(
|
|||
/**
|
||||
* List all notification destinations
|
||||
*/
|
||||
export const listNotificationDestinations = <
|
||||
ThrowOnError extends boolean = false,
|
||||
>(
|
||||
export const listNotificationDestinations = <ThrowOnError extends boolean = false>(
|
||||
options?: Options<ListNotificationDestinationsData, ThrowOnError>,
|
||||
) =>
|
||||
(options?.client ?? client).get<
|
||||
ListNotificationDestinationsResponses,
|
||||
unknown,
|
||||
ThrowOnError
|
||||
>({ url: "/api/v1/notifications/destinations", ...options });
|
||||
(options?.client ?? client).get<ListNotificationDestinationsResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/notifications/destinations",
|
||||
...options,
|
||||
});
|
||||
|
||||
/**
|
||||
* Create a new notification destination
|
||||
*/
|
||||
export const createNotificationDestination = <
|
||||
ThrowOnError extends boolean = false,
|
||||
>(
|
||||
export const createNotificationDestination = <ThrowOnError extends boolean = false>(
|
||||
options?: Options<CreateNotificationDestinationData, ThrowOnError>,
|
||||
) =>
|
||||
(options?.client ?? client).post<
|
||||
CreateNotificationDestinationResponses,
|
||||
unknown,
|
||||
ThrowOnError
|
||||
>({
|
||||
(options?.client ?? client).post<CreateNotificationDestinationResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/notifications/destinations",
|
||||
...options,
|
||||
headers: {
|
||||
|
|
@ -746,9 +636,7 @@ export const createNotificationDestination = <
|
|||
/**
|
||||
* Delete a notification destination
|
||||
*/
|
||||
export const deleteNotificationDestination = <
|
||||
ThrowOnError extends boolean = false,
|
||||
>(
|
||||
export const deleteNotificationDestination = <ThrowOnError extends boolean = false>(
|
||||
options: Options<DeleteNotificationDestinationData, ThrowOnError>,
|
||||
) =>
|
||||
(options.client ?? client).delete<
|
||||
|
|
@ -760,23 +648,18 @@ export const deleteNotificationDestination = <
|
|||
/**
|
||||
* Get a notification destination by ID
|
||||
*/
|
||||
export const getNotificationDestination = <
|
||||
ThrowOnError extends boolean = false,
|
||||
>(
|
||||
export const getNotificationDestination = <ThrowOnError extends boolean = false>(
|
||||
options: Options<GetNotificationDestinationData, ThrowOnError>,
|
||||
) =>
|
||||
(options.client ?? client).get<
|
||||
GetNotificationDestinationResponses,
|
||||
GetNotificationDestinationErrors,
|
||||
ThrowOnError
|
||||
>({ url: "/api/v1/notifications/destinations/{id}", ...options });
|
||||
(options.client ?? client).get<GetNotificationDestinationResponses, GetNotificationDestinationErrors, ThrowOnError>({
|
||||
url: "/api/v1/notifications/destinations/{id}",
|
||||
...options,
|
||||
});
|
||||
|
||||
/**
|
||||
* Update a notification destination
|
||||
*/
|
||||
export const updateNotificationDestination = <
|
||||
ThrowOnError extends boolean = false,
|
||||
>(
|
||||
export const updateNotificationDestination = <ThrowOnError extends boolean = false>(
|
||||
options: Options<UpdateNotificationDestinationData, ThrowOnError>,
|
||||
) =>
|
||||
(options.client ?? client).patch<
|
||||
|
|
@ -795,9 +678,7 @@ export const updateNotificationDestination = <
|
|||
/**
|
||||
* Test a notification destination by sending a test message
|
||||
*/
|
||||
export const testNotificationDestination = <
|
||||
ThrowOnError extends boolean = false,
|
||||
>(
|
||||
export const testNotificationDestination = <ThrowOnError extends boolean = false>(
|
||||
options: Options<TestNotificationDestinationData, ThrowOnError>,
|
||||
) =>
|
||||
(options.client ?? client).post<
|
||||
|
|
@ -812,18 +693,15 @@ export const testNotificationDestination = <
|
|||
export const getSystemInfo = <ThrowOnError extends boolean = false>(
|
||||
options?: Options<GetSystemInfoData, ThrowOnError>,
|
||||
) =>
|
||||
(options?.client ?? client).get<
|
||||
GetSystemInfoResponses,
|
||||
unknown,
|
||||
ThrowOnError
|
||||
>({ url: "/api/v1/system/info", ...options });
|
||||
(options?.client ?? client).get<GetSystemInfoResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/system/info",
|
||||
...options,
|
||||
});
|
||||
|
||||
/**
|
||||
* Check for application updates from GitHub
|
||||
*/
|
||||
export const getUpdates = <ThrowOnError extends boolean = false>(
|
||||
options?: Options<GetUpdatesData, ThrowOnError>,
|
||||
) =>
|
||||
export const getUpdates = <ThrowOnError extends boolean = false>(options?: Options<GetUpdatesData, ThrowOnError>) =>
|
||||
(options?.client ?? client).get<GetUpdatesResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/system/updates",
|
||||
...options,
|
||||
|
|
@ -835,11 +713,7 @@ export const getUpdates = <ThrowOnError extends boolean = false>(
|
|||
export const downloadResticPassword = <ThrowOnError extends boolean = false>(
|
||||
options?: Options<DownloadResticPasswordData, ThrowOnError>,
|
||||
) =>
|
||||
(options?.client ?? client).post<
|
||||
DownloadResticPasswordResponses,
|
||||
unknown,
|
||||
ThrowOnError
|
||||
>({
|
||||
(options?.client ?? client).post<DownloadResticPasswordResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/system/restic-password",
|
||||
...options,
|
||||
headers: {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ export default defineConfig({
|
|||
input: `http://${config.serverIp}:4096/api/v1/openapi.json`,
|
||||
output: {
|
||||
path: "./app/client/api-client",
|
||||
format: "biome",
|
||||
postProcess: ["oxfmt"],
|
||||
},
|
||||
plugins: [...defaultPlugins, "@tanstack/react-query", "@hey-api/client-fetch"],
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue