lixnet 1.2.5 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/client.d.ts +3 -1
- package/dist/lib/types.d.ts +4 -2
- package/package.json +1 -1
package/dist/lib/client.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { FunctionInput, LXN_ServerClient_EventType } from "./types";
|
|
2
|
+
type ExtractRPCResponse<T> = T extends (...args: any) => infer R ? Awaited<R> : never;
|
|
2
3
|
export default class LixnetClient<Events extends LXN_ServerClient_EventType> {
|
|
3
4
|
private rpcUrl;
|
|
4
5
|
constructor({ rpcUrl }: {
|
|
5
6
|
rpcUrl: string;
|
|
6
7
|
});
|
|
7
|
-
call<K extends keyof Events>(event: K, input: FunctionInput<Events[K]>, options?: RequestInit): Promise<
|
|
8
|
+
call<K extends keyof Events>(event: K, input: FunctionInput<Events[K]>, options?: RequestInit): Promise<ExtractRPCResponse<Events[K]>>;
|
|
8
9
|
}
|
|
10
|
+
export {};
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -2,9 +2,11 @@ export type DebugLogger = ({ error, message, }: {
|
|
|
2
2
|
error?: boolean;
|
|
3
3
|
message: string;
|
|
4
4
|
}) => void;
|
|
5
|
-
export type FunctionInput<T> = T extends (input: infer TInput) => any ? TInput :
|
|
5
|
+
export type FunctionInput<T> = T extends (input: infer TInput) => any ? TInput : {
|
|
6
|
+
_TYPE_ERROR_: "Event definition must be a function type";
|
|
7
|
+
};
|
|
6
8
|
export type LXNServerHandler<Input> = (input: Input) => Promise<any> | any;
|
|
7
|
-
export type LXN_ServerClient_EventType =
|
|
9
|
+
export type LXN_ServerClient_EventType = object;
|
|
8
10
|
export type LXN_ServerClient_Request = Request & {
|
|
9
11
|
setAdditionalInit: (init: ResponseInit) => void;
|
|
10
12
|
};
|