interface-relay/dist/index.d.ts

42 lines
1.1 KiB
TypeScript
Raw Normal View History

2022-08-29 02:02:11 +00:00
import type { JSONSchemaType } from "ajv";
export interface RPCRequest {
2022-08-29 02:11:57 +00:00
bypassCache?: boolean;
module: string;
method: string;
data: any;
2022-08-29 02:02:11 +00:00
}
export interface RPCResponse {
2022-08-29 02:11:57 +00:00
updated?: number;
data?: any;
error?: string;
2022-08-29 02:02:11 +00:00
}
export interface RPCMethod {
2022-08-29 02:11:57 +00:00
cacheable: boolean;
handler: (
request: RPCRequest,
sendStream: (stream: AsyncIterable<Uint8Array>) => void
) => Promise<RPCResponse | null>;
2022-08-29 02:02:11 +00:00
}
export declare const RPC_REQUEST_SCHEMA: JSONSchemaType<RPCRequest>;
export interface StreamFileResponse {
2022-08-29 02:11:57 +00:00
data?: Uint8Array;
done: boolean;
2022-08-29 02:02:11 +00:00
}
export interface PluginAPI {
2022-08-29 02:11:57 +00:00
config: any;
registerMethod: (methodName: string, method: RPCMethod) => void;
loadPlugin: (moduleName: string) => Promise<Plugin>;
getMethods: () => string[];
2022-08-29 02:02:11 +00:00
}
export declare type PluginFunction = (api: PluginAPI) => Promise<void>;
export interface Plugin {
2022-08-29 02:11:57 +00:00
name: string;
plugin: PluginFunction;
exports?: any;
default?: Plugin;
2022-08-29 02:02:11 +00:00
}
2022-08-29 02:11:57 +00:00
export declare type RPCStreamHandler = (
stream: AsyncIterable<Uint8Array>
) => Promise<RPCResponse>;
//# sourceMappingURL=index.d.ts.map