Inclui console handoff Desk↔Console (Spec 019), melhorias DNS Viewer (037), OpenPanel/Nextcloud/VM116 deploy notes, contracts stack e sidebar actualizado. Co-authored-by: Cursor <cursoragent@cursor.com>
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
/**
|
|
* VM112 onboarding API client — Fase B/C
|
|
*/
|
|
export type Vm112Config = { baseUrl: string; sessionId: string };
|
|
|
|
export async function vm112Post(
|
|
cfg: Vm112Config,
|
|
path: string,
|
|
body: Record<string, unknown>,
|
|
): Promise<Record<string, unknown>> {
|
|
const res = await fetch(`${cfg.baseUrl}${path}`, {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
"X-Onboarding-Session": cfg.sessionId,
|
|
},
|
|
body: JSON.stringify(body),
|
|
});
|
|
const data = (await res.json().catch(() => ({}))) as Record<string, unknown>;
|
|
if (!res.ok) {
|
|
const msg = (data.detail as string) || (data.message as string) || res.statusText;
|
|
throw new Error(typeof msg === "string" ? msg : JSON.stringify(msg));
|
|
}
|
|
return data;
|
|
}
|
|
|
|
export async function vm112Get(
|
|
cfg: Vm112Config,
|
|
path: string,
|
|
): Promise<Record<string, unknown>> {
|
|
const res = await fetch(`${cfg.baseUrl}${path}`, {
|
|
headers: { "X-Onboarding-Session": cfg.sessionId },
|
|
});
|
|
const data = (await res.json().catch(() => ({}))) as Record<string, unknown>;
|
|
if (!res.ok) throw new Error(res.statusText);
|
|
return data;
|
|
}
|