*Dont put api methods in an api namespace
This commit is contained in:
parent
b91fd5d8b5
commit
ba20b1f36e
|
@ -50,12 +50,10 @@ export class PluginAPI {
|
||||||
private getPluginAPI(pluginName: string): RelayPluginAPI {
|
private getPluginAPI(pluginName: string): RelayPluginAPI {
|
||||||
return {
|
return {
|
||||||
config,
|
config,
|
||||||
api: {
|
registerMethod: (methodName: string, method: RPCMethod): void => {
|
||||||
registerMethod: (methodName: string, method: RPCMethod): void => {
|
getRpcServer().registerMethod(pluginName, methodName, method);
|
||||||
getRpcServer().registerMethod(pluginName, methodName, method);
|
|
||||||
},
|
|
||||||
loadPlugin: getPluginAPI().loadPlugin,
|
|
||||||
},
|
},
|
||||||
|
loadPlugin: getPluginAPI().loadPlugin,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
10
src/types.ts
10
src/types.ts
|
@ -21,6 +21,7 @@ export interface RPCMethod {
|
||||||
sendStream: (stream: AsyncIterable<Uint8Array>) => void
|
sendStream: (stream: AsyncIterable<Uint8Array>) => void
|
||||||
) => RPCResponse | null;
|
) => RPCResponse | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const RPC_REQUEST_SCHEMA: JSONSchemaType<RPCRequest> = {
|
export const RPC_REQUEST_SCHEMA: JSONSchemaType<RPCRequest> = {
|
||||||
anyOf: [],
|
anyOf: [],
|
||||||
oneOf: [],
|
oneOf: [],
|
||||||
|
@ -48,19 +49,20 @@ export const RPC_REQUEST_SCHEMA: JSONSchemaType<RPCRequest> = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface StreamFileResponse {
|
export interface StreamFileResponse {
|
||||||
data?: Uint8Array;
|
data?: Uint8Array;
|
||||||
done: boolean;
|
done: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RelayPluginAPI {
|
export interface RelayPluginAPI {
|
||||||
config: any;
|
config: any;
|
||||||
api: {
|
registerMethod: (methodName: string, method: RPCMethod) => void;
|
||||||
registerMethod: (methodName: string, method: RPCMethod) => void;
|
loadPlugin: PluginAPI["loadPlugin"];
|
||||||
loadPlugin: PluginAPI["loadPlugin"];
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type PluginFunction = (api: RelayPluginAPI) => Promise<void>;
|
export type PluginFunction = (api: RelayPluginAPI) => Promise<void>;
|
||||||
|
|
||||||
export interface Plugin {
|
export interface Plugin {
|
||||||
name: string;
|
name: string;
|
||||||
plugin: PluginFunction;
|
plugin: PluginFunction;
|
||||||
|
|
Loading…
Reference in New Issue