diff --git a/src/plugin.ts b/src/plugin.ts index af493c7..99ace98 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -50,12 +50,10 @@ export class PluginAPI { private getPluginAPI(pluginName: string): RelayPluginAPI { return { config, - api: { - registerMethod: (methodName: string, method: RPCMethod): void => { - getRpcServer().registerMethod(pluginName, methodName, method); - }, - loadPlugin: getPluginAPI().loadPlugin, + registerMethod: (methodName: string, method: RPCMethod): void => { + getRpcServer().registerMethod(pluginName, methodName, method); }, + loadPlugin: getPluginAPI().loadPlugin, }; } } diff --git a/src/types.ts b/src/types.ts index 13f9918..d39c93e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -21,6 +21,7 @@ export interface RPCMethod { sendStream: (stream: AsyncIterable) => void ) => RPCResponse | null; } + export const RPC_REQUEST_SCHEMA: JSONSchemaType = { anyOf: [], oneOf: [], @@ -48,19 +49,20 @@ export const RPC_REQUEST_SCHEMA: JSONSchemaType = { }, }, }; + export interface StreamFileResponse { data?: Uint8Array; done: boolean; } + export interface RelayPluginAPI { config: any; - api: { - registerMethod: (methodName: string, method: RPCMethod) => void; - loadPlugin: PluginAPI["loadPlugin"]; - }; + registerMethod: (methodName: string, method: RPCMethod) => void; + loadPlugin: PluginAPI["loadPlugin"]; } export type PluginFunction = (api: RelayPluginAPI) => Promise; + export interface Plugin { name: string; plugin: PluginFunction;