/** * Client-side RPC helper for the dsh-connect web settings pane. * * The frontend talks to the host over the `/dsh-connect` channel; the channel * returns `{ ok, value }`/`{ ok:false, error }` envelopes (see `settings-rpc.js`). * This helper unwraps the envelope and throws a typed error on failure, so the * UI can catch it and render a message. Pure + dependency-free for easy testing. * * @module dsh-connect/settings/rpc-client */ import type { SettingsSnapshot } from "./settings-rpc.js"; /** The `ctx.connection.rpc.call` signature the settings pane uses. */ export type RpcCall = (endpoint: string, payload?: unknown, signal?: AbortSignal) => Promise<{ ok: boolean; value?: unknown; error?: { code: string; message: string; }; }>; /** A typed RPC failure, surfaced to the settings UI. */ export declare class RpcError extends Error { readonly code: string; constructor(code: string, message: string); } /** Invoke one endpoint and unwrap the envelope (throws `RpcError` on failure). */ export declare function callRpc(rpcCall: RpcCall, endpoint: string, payload?: unknown, signal?: AbortSignal): Promise; /** Load the current settings snapshot via `settings.get`. */ export declare function loadSettings(rpcCall: RpcCall): Promise; /** Persist the settings via `settings.save`. */ export declare function saveSettings(rpcCall: RpcCall, config: Record): Promise; /** Persist channel secrets to the credential store via `credentials.save`. */ export declare function saveCredentials(rpcCall: RpcCall, channel: string, values: Record): Promise; /** Ask the host for a fresh status snapshot via `settings.status`. */ export declare function loadStatus(rpcCall: RpcCall): Promise; //# sourceMappingURL=rpc-client.d.ts.map