/** RPC wire types (server-side). Mirror in client/src/platform/rpc.ts */

export type RpcRequest = {
  id: string;          // client-generated correlation id
  method: 'call';      // только один тип запроса: вызов зарегистрированной процедуры
  name: string;        // core.saved.name
  params?: unknown;    // JSON-параметры → JSONB в процедуру
};

export type RpcSuccess = {
  id: string;
  ok: true;
  result: unknown;
};

export type RpcError = {
  id: string;
  ok: false;
  error: { code: string; message: string };
};

export type RpcResponse = RpcSuccess | RpcError;

export type PushChangelog = {
  type: 'changelog';
  id: number;
  table: string;
  op: 'I' | 'U' | 'D';
  rowId: string;
};

export type ServerPush = PushChangelog;
