Files
archon/archon-ui-main/src/features/settings/version/services/versionService.ts
Cole Medin 3ff3f7f2dc Migrations and version APIs (#718)
* Preparing migration folder for the migration alert implementation

* Migrations and version APIs initial

* Touching up update instructions in README and UI

* Unit tests for migrations and version APIs

* Splitting up the Ollama migration scripts

* Removing temporary PRPs

---------

Co-authored-by: Rasmus Widing <rasmus.widing@gmail.com>
2025-09-22 12:25:58 +03:00

50 lines
1.4 KiB
TypeScript

/**
* Service for version checking and update management
*/
import { callAPIWithETag } from "@/features/shared/apiWithEtag";
import type { CurrentVersionResponse, VersionCheckResponse } from "../types";
export const versionService = {
/**
* Check for available Archon updates
*/
async checkVersion(): Promise<VersionCheckResponse> {
try {
const response = await callAPIWithETag("/api/version/check");
return response as VersionCheckResponse;
} catch (error) {
console.error("Error checking version:", error);
throw error;
}
},
/**
* Get current Archon version without checking for updates
*/
async getCurrentVersion(): Promise<CurrentVersionResponse> {
try {
const response = await callAPIWithETag("/api/version/current");
return response as CurrentVersionResponse;
} catch (error) {
console.error("Error getting current version:", error);
throw error;
}
},
/**
* Clear version cache to force fresh check
*/
async clearCache(): Promise<{ message: string; success: boolean }> {
try {
const response = await callAPIWithETag("/api/version/clear-cache", {
method: "POST",
});
return response as { message: string; success: boolean };
} catch (error) {
console.error("Error clearing version cache:", error);
throw error;
}
},
};