/** * JSON-RPC 2.0 Utility Functions * * Utility class for JSON-RPC message handling, validation, and creation. * Extracted from schemas/jsonrpc.ts for independent use. */ import { JSONRPCErrorCode, type JSONRPCParams, type JSONRPCId, type JSONRPCRequest, type JSONRPCNotification, type JSONRPCSuccessResponse, type JSONRPCErrorResponse, type JSONRPCError, type JSONRPCResponse, type JSONRPCMessage, type JSONRPCValidationResult } from "./schemas/jsonrpc.js"; /** * Utility functions for JSON-RPC message handling */ export declare class JSONRPCUtils { /** * Validate a JSON-RPC message (supports batch requests) */ static validateBatchMessage(message: any): JSONRPCValidationResult; /** * Validate a single JSON-RPC message */ static validateSingleMessage(message: any): JSONRPCValidationResult; /** * Create a JSON-RPC request */ static createRequest(method: string, params?: JSONRPCParams, options?: { customId?: JSONRPCId; }): JSONRPCRequest; /** * Create a JSON-RPC notification */ static createNotification(method: string, params?: JSONRPCParams): JSONRPCNotification; /** * Create a JSON-RPC success response */ static createSuccessResponse(result: any, id: JSONRPCId): JSONRPCSuccessResponse; /** * Create a JSON-RPC error response */ static createErrorResponse(error: JSONRPCError, id: JSONRPCId): JSONRPCErrorResponse; /** * Create a standard JSON-RPC error */ static createError(code: JSONRPCErrorCode | number, message: string, data?: any): JSONRPCError; /** * Generate a unique ID for requests */ static generateId(): string; /** * Check if a message is a JSON-RPC request */ static isRequest(message: any): message is JSONRPCRequest; /** * Check if a message is a JSON-RPC notification */ static isNotification(message: any): message is JSONRPCNotification; /** * Check if a message is a JSON-RPC response */ static isResponse(message: any): message is JSONRPCResponse; /** * Check if a response is a success response */ static isSuccessResponse(response: JSONRPCResponse): response is JSONRPCSuccessResponse; /** * Check if a response is an error response */ static isErrorResponse(response: JSONRPCResponse): response is JSONRPCErrorResponse; /** * Serialize a JSON-RPC message to string */ static serialize(message: JSONRPCMessage): string; /** * Deserialize a JSON-RPC message from string */ static deserialize(data: string | Buffer | Record): JSONRPCMessage | null; }