feat: system optional capabilities

This commit is contained in:
Nicolas Meienberger
2025-11-08 10:14:42 +01:00
parent 4dc239139f
commit 9ec765bd90
13 changed files with 316 additions and 43 deletions

View File

@@ -35,6 +35,7 @@ import {
updateBackupSchedule,
getBackupScheduleForVolume,
runBackupNow,
getSystemInfo,
} from "../sdk.gen";
import { queryOptions, type UseMutationOptions, type DefaultError } from "@tanstack/react-query";
import type {
@@ -90,6 +91,7 @@ import type {
GetBackupScheduleForVolumeData,
RunBackupNowData,
RunBackupNowResponse,
GetSystemInfoData,
} from "../types.gen";
import { client as _heyApiClient } from "../client.gen";
@@ -1078,3 +1080,23 @@ export const runBackupNowMutation = (
};
return mutationOptions;
};
export const getSystemInfoQueryKey = (options?: Options<GetSystemInfoData>) => createQueryKey("getSystemInfo", options);
/**
* Get system information including available capabilities
*/
export const getSystemInfoOptions = (options?: Options<GetSystemInfoData>) => {
return queryOptions({
queryFn: async ({ queryKey, signal }) => {
const { data } = await getSystemInfo({
...options,
...queryKey[0],
signal,
throwOnError: true,
});
return data;
},
queryKey: getSystemInfoQueryKey(options),
});
};

View File

@@ -72,6 +72,8 @@ import type {
GetBackupScheduleForVolumeResponses,
RunBackupNowData,
RunBackupNowResponses,
GetSystemInfoData,
GetSystemInfoResponses,
} from "./types.gen";
import { client as _heyApiClient } from "./client.gen";
@@ -513,3 +515,15 @@ export const runBackupNow = <ThrowOnError extends boolean = false>(
...options,
});
};
/**
* Get system information including available capabilities
*/
export const getSystemInfo = <ThrowOnError extends boolean = false>(
options?: Options<GetSystemInfoData, ThrowOnError>,
) => {
return (options?.client ?? _heyApiClient).get<GetSystemInfoResponses, unknown, ThrowOnError>({
url: "/api/v1/system/info",
...options,
});
};

View File

@@ -1418,6 +1418,26 @@ export type RunBackupNowResponses = {
export type RunBackupNowResponse = RunBackupNowResponses[keyof RunBackupNowResponses];
export type GetSystemInfoData = {
body?: never;
path?: never;
query?: never;
url: "/api/v1/system/info";
};
export type GetSystemInfoResponses = {
/**
* System information with enabled capabilities
*/
200: {
capabilities: {
docker: boolean;
};
};
};
export type GetSystemInfoResponse = GetSystemInfoResponses[keyof GetSystemInfoResponses];
export type ClientOptions = {
baseUrl: "http://192.168.2.42:4096" | (string & {});
};