Mini Kabibi Habibi
/**
* This file is used to give data back to the Export package
* Export should NOT ever depend on State package because that will bloat deps on cai/uxp-export-as repo
*/
import type { CAIAPI } from '@cai/types';
import { RpcBase, IJsonRpcRequest, IUXPCallable, ErrorCode } from '@cai/rpc';
export interface IHandlerParams extends IUXPCallable {
documentID: number;
}
export interface CallCAIParams extends IUXPCallable {
args: any[];
method: keyof CAIAPI;
}
interface IServerHandlers {
[key: string]: Function;
}
export interface IServerOptions {
handlers?: IServerHandlers;
}
declare type GetCAIMethod = () => CAIAPI;
/**
* RpcServer that listens and replies to plugin commands using JSON RPC.
*
* This should only be used by the main CAI plugin (@cai/panel).
*/
export declare class RpcServer extends RpcBase {
protected static instance: RpcServer;
protected targetPlugins: any;
protected options?: IServerOptions;
private handlers;
protected constructor(getState: GetCAIMethod, options?: IServerOptions);
/**
* Singleton provider
* @returns RpcServer
*/
static getInstance(getState: GetCAIMethod, options?: IServerOptions): RpcServer;
/**
* Pushes commands sent to this plugin via `invokeCommand` to the internal stream
* so they can be processed.
* @param command
*/
protected handleCommand(rpcCmd: IJsonRpcRequest<IHandlerParams>): Promise<void>;
/**
* Takes actions and sends messages back based on the RPC method.
*/
private initStreamHandlers;
/**
* Send a reply notification to the plugin that sent the original JSON RPC command/request
* @param originalCommand The original JSON RPC request that triggered this reply
* @param params Data to send back to the consuming plugin's RpcClient
*/
protected reply(originalCommand: IJsonRpcRequest<IHandlerParams>, params: any, error?: ErrorCode): void;
}
export {};