Add abortable API signals for setup status and server health/log fetches, document hook cancellation patterns, and cover stale refresh cancellation with tests.
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
/**
|
|
* Setup wizard API functions.
|
|
*
|
|
* Wraps calls to GET /api/setup and POST /api/setup.
|
|
*/
|
|
|
|
import { api } from "./client";
|
|
import { ENDPOINTS } from "./endpoints";
|
|
import type {
|
|
SetupRequest,
|
|
SetupResponse,
|
|
SetupStatusResponse,
|
|
SetupTimezoneResponse,
|
|
} from "../types/setup";
|
|
|
|
/**
|
|
* Check whether the initial setup has been completed.
|
|
*
|
|
* @returns Setup status response with a `completed` boolean.
|
|
*/
|
|
export async function getSetupStatus(signal?: AbortSignal): Promise<SetupStatusResponse> {
|
|
return api.get<SetupStatusResponse>(ENDPOINTS.setup, signal);
|
|
}
|
|
|
|
/**
|
|
* Submit the initial setup configuration.
|
|
*
|
|
* @param data - Setup request payload.
|
|
* @returns Success message from the API.
|
|
*/
|
|
export async function submitSetup(data: SetupRequest): Promise<SetupResponse> {
|
|
return api.post<SetupResponse>(ENDPOINTS.setup, data);
|
|
}
|
|
|
|
/**
|
|
* Fetch the IANA timezone configured during setup.
|
|
*
|
|
* Used by the frontend to convert UTC timestamps to the local timezone
|
|
* chosen by the administrator.
|
|
*
|
|
* @returns The configured timezone identifier (e.g. `"Europe/Berlin"`).
|
|
*/
|
|
export async function fetchTimezone(signal?: AbortSignal): Promise<SetupTimezoneResponse> {
|
|
return api.get<SetupTimezoneResponse>(ENDPOINTS.setupTimezone, signal);
|
|
}
|