*Move code to types package

This commit is contained in:
Derrick Hammer 2022-08-28 22:35:07 -04:00
parent 744ab44af8
commit c347692490
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 0 additions and 48 deletions

View File

@ -1,27 +1,4 @@
import { JSONSchemaType } from "ajv";
import { PluginApiManager } from "./plugin.js";
import { RPCServer } from "./rpc/server.js";
export interface RPCRequest {
bypassCache?: boolean;
module: string;
method: string;
data: any;
}
export interface RPCResponse {
updated?: number;
data?: any;
error?: string;
}
export interface RPCMethod {
cacheable: boolean;
handler: (
request: RPCRequest,
sendStream: (stream: AsyncIterable<Uint8Array>) => void
) => Promise<RPCResponse | null>;
}
// @ts-ignore
export const RPC_REQUEST_SCHEMA: JSONSchemaType<RPCRequest> = {
@ -42,28 +19,3 @@ export const RPC_REQUEST_SCHEMA: JSONSchemaType<RPCRequest> = {
},
},
};
export interface StreamFileResponse {
data?: Uint8Array;
done: boolean;
}
export interface PluginAPI {
config: any;
registerMethod: (methodName: string, method: RPCMethod) => void;
loadPlugin: PluginApiManager["loadPlugin"];
getMethods: RPCServer["getMethods"];
}
export type PluginFunction = (api: PluginAPI) => Promise<void>;
export interface Plugin {
name: string;
plugin: PluginFunction;
exports?: any;
default?: Plugin;
}
export type RPCStreamHandler = (
stream: AsyncIterable<Uint8Array>
) => Promise<RPCResponse>;