File size: 1,522 Bytes
cdc337a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | import { apiRequest } from "@/shared/api/client";
import { createObjectDecoder, isBoolean, isOneOf, isString, type ValueValidator } from "@/shared/api/decoder";
export type SystemInfoDTO = {
publicApiBaseURL: string;
};
const decodeSystemInfo = createObjectDecoder<SystemInfoDTO>("system info", { publicApiBaseURL: isString });
export function getSystemInfo(): Promise<SystemInfoDTO> {
return apiRequest("/api/admin/v1/system", {}, decodeSystemInfo);
}
export type UpdateStatus = "unchecked" | "up_to_date" | "update_available" | "check_failed";
export type VersionInfoDTO = {
currentVersion: string;
latestVersion: string;
updateAvailable: boolean;
status: UpdateStatus;
checkedAt: string | null;
releaseUrl: string;
releaseNotes: string;
error: string;
};
const isNullableString: ValueValidator = (value) => value === null || isString(value);
const decodeVersionInfo = createObjectDecoder<VersionInfoDTO>("version info", {
currentVersion: isString,
latestVersion: isString,
updateAvailable: isBoolean,
status: isOneOf("unchecked", "up_to_date", "update_available", "check_failed"),
checkedAt: isNullableString,
releaseUrl: isString,
releaseNotes: isString,
error: isString,
});
export function getVersionInfo(): Promise<VersionInfoDTO> {
return apiRequest("/api/admin/v1/system/version", {}, decodeVersionInfo);
}
export function checkForUpdates(): Promise<VersionInfoDTO> {
return apiRequest("/api/admin/v1/system/update/check", { method: "POST" }, decodeVersionInfo);
}
|