@caido/sdk-frontend 0.55.4-beta.7 → 0.55.4-beta.8
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/package.json +1 -1
- package/src/types/sdks/backend.d.ts +23 -11
package/package.json
CHANGED
|
@@ -1,19 +1,31 @@
|
|
|
1
1
|
import { type BackendEndpoints, type BackendEvents } from "../types/backend";
|
|
2
2
|
import type { PromisifiedReturnType } from "../types/utils";
|
|
3
|
+
|
|
4
|
+
type ResolvedAPI<T> = T extends { api: infer A } ? A : T;
|
|
5
|
+
type ResolvedEvents<T, Events> = T extends { events: infer A } ? A : Events;
|
|
6
|
+
|
|
3
7
|
/**
|
|
4
8
|
* Utilities to interact with the backend plugin.
|
|
5
9
|
* @category Backend
|
|
6
10
|
*/
|
|
7
|
-
export type BackendSDK<
|
|
8
|
-
|
|
11
|
+
export type BackendSDK<
|
|
12
|
+
T extends ResolvedAPI<BackendEndpoints>,
|
|
13
|
+
E extends BackendEvents,
|
|
14
|
+
> = {
|
|
15
|
+
[K in keyof ResolvedAPI<T>]: (
|
|
16
|
+
...args: Parameters<ResolvedAPI<T>[K]>
|
|
17
|
+
) => PromisifiedReturnType<ResolvedAPI<T>[K]>;
|
|
9
18
|
} & {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Subscribe to a backend event.
|
|
21
|
+
* @param event The event to subscribe to.
|
|
22
|
+
* @param callback The callback to call when the event is emitted.
|
|
23
|
+
* @returns An object with a `stop` method that can be called to stop listening to the event.
|
|
24
|
+
*/
|
|
25
|
+
onEvent: <K extends keyof ResolvedEvents<T, E>>(
|
|
26
|
+
event: K,
|
|
27
|
+
callback: ResolvedEvents<T, E>[K],
|
|
28
|
+
) => {
|
|
29
|
+
stop: () => void;
|
|
30
|
+
};
|
|
19
31
|
};
|