mirror of
https://github.com/home-assistant/frontend.git
synced 2026-09-28 07:58:45 +01:00
Compare the backup, onboarding and cloud data modules with the handlers that produce them, and fix the mismatches. Several backup calls declared the wrong result. Deleting a backup returns agent errors, generating one returns a job id rather than a backup id, and restoring one returns nothing. The backup list carries extended content, not the base type. Add the blocked manager state, which is the state the manager starts in and replays to new subscribers, along with the event reason fields and the core_restart restore state. Correct the onboarding installation type, which listed a value the backend never sends and omitted one it does, and narrow the cloud onboarding status to the single field that endpoint returns. Remove the cloud strict connection preference and its translations. No such preference exists in core, so the warning it gated could never render. Claude-Session: https://claude.ai/code/session_01YDqKNfAAvMV7zJJNodsHfK Co-authored-by: Claude <noreply@anthropic.com>
67 lines
1.6 KiB
TypeScript
67 lines
1.6 KiB
TypeScript
import { handleFetchPromise } from "../util/hass-call-api";
|
|
import type { BackupContentExtended } from "./backup";
|
|
import type {
|
|
BackupManagerState,
|
|
RestoreBackupStage,
|
|
RestoreBackupState,
|
|
} from "./backup_manager";
|
|
|
|
export interface BackupOnboardingInfo {
|
|
state: BackupManagerState;
|
|
last_action_event: {
|
|
manager_state: BackupManagerState;
|
|
stage: RestoreBackupStage | null;
|
|
state: RestoreBackupState;
|
|
reason: string | null;
|
|
} | null;
|
|
}
|
|
|
|
export interface BackupOnboardingConfig extends BackupOnboardingInfo {
|
|
backups: BackupContentExtended[];
|
|
}
|
|
|
|
export const fetchBackupOnboardingInfo = async () =>
|
|
handleFetchPromise<BackupOnboardingConfig>(
|
|
fetch(`${__HASS_URL__}/api/onboarding/backup/info`)
|
|
);
|
|
|
|
export interface RestoreOnboardingBackupParams {
|
|
backup_id: string;
|
|
agent_id: string;
|
|
password?: string;
|
|
restore_addons?: string[];
|
|
restore_database?: boolean;
|
|
restore_folders?: string[];
|
|
}
|
|
|
|
export const restoreOnboardingBackup = async (
|
|
params: RestoreOnboardingBackupParams
|
|
) =>
|
|
handleFetchPromise(
|
|
fetch(`${__HASS_URL__}/api/onboarding/backup/restore`, {
|
|
method: "POST",
|
|
body: JSON.stringify(params),
|
|
})
|
|
);
|
|
|
|
export const uploadOnboardingBackup = async (
|
|
file: File,
|
|
agentIds: string[]
|
|
): Promise<{ backup_id: string }> => {
|
|
const fd = new FormData();
|
|
fd.append("file", file);
|
|
|
|
const params = new URLSearchParams();
|
|
|
|
agentIds.forEach((agentId) => {
|
|
params.append("agent_id", agentId);
|
|
});
|
|
|
|
return handleFetchPromise(
|
|
fetch(`${__HASS_URL__}/api/onboarding/backup/upload?${params.toString()}`, {
|
|
method: "POST",
|
|
body: fd,
|
|
})
|
|
);
|
|
};
|