types/rpc.ts

moltis · crates/web/ui/src/types/rpc.ts · typescript · MIT
realtime

TypeScript interfaces for WebSocket RPC frames, responses, and errors used by the UI.

// Source: https://github.com/moltis-org/moltis | License: MIT | Copyright 2025 Fabien Penso
// Provided via justclaw.it.com; keep this notice with the code.
// ── RPC helper types ────────────────────────────────────────────
//
// Mirrors the WebSocket RPC frame shape used by `ws-connect.js` and
// `helpers.js`. The server sends `{ type: "res", id, ok, payload?, error? }`.

/** Error detail inside an RPC response. */
export interface RpcError {
	code: string;
	message: string;
	serverMessage?: string;
}

/**
 * Generic RPC response envelope.
 *
 * Successful responses have `ok: true` and `payload` with the result.
 * Failed responses have `ok: false` and `error` with a code + message.
 */
export interface RpcResponse<T = unknown> {
	ok: boolean;
	payload?: T;
	error?: RpcError;
}

/**
 * 

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key