Skip to content

Commit cd11b66

Browse files
committed
add GetState and SetState
1 parent 4d114f2 commit cd11b66

File tree

4 files changed

+38
-6
lines changed

4 files changed

+38
-6
lines changed

dist/index.d.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,17 @@ interface SetTabTitleRequest extends BaseRequest {
5252
title: string;
5353
};
5454
}
55-
type PluginRequestData = GetTablesRequest | GetColumnsRequest | GetConnectionInfoRequest | GetAllTabsRequest | RunQueryRequest | ExpandTableResultRequest | SetTabTitleRequest;
55+
interface GetStateRequest extends BaseRequest {
56+
name: "getState";
57+
args: void;
58+
}
59+
interface SetStateRequest<T extends unknown> extends BaseRequest {
60+
name: "setState";
61+
args: {
62+
state: T;
63+
};
64+
}
65+
type PluginRequestData = GetTablesRequest | GetColumnsRequest | GetConnectionInfoRequest | GetAllTabsRequest | RunQueryRequest | ExpandTableResultRequest | SetTabTitleRequest | GetStateRequest | SetStateRequest<unknown>;
5666

5767
type TabType = string;
5868
type TableFilter = any;
@@ -82,9 +92,11 @@ type RunQueryResponse = {
8292
};
8393
type ExpandTableResultResponse = void;
8494
type SetTabTitleResponse = void;
95+
type GetStateResponse<T extends unknown> = T;
96+
type SetStateResponse = void;
8597
interface PluginResponseData {
8698
id: string;
87-
result: GetTablesResponse | GetColumnsResponse | GetConnectionInfoResponse | GetAllTabsResponse | RunQueryResponse | ExpandTableResultResponse | SetTabTitleResponse;
99+
result: GetTablesResponse | GetColumnsResponse | GetConnectionInfoResponse | GetAllTabsResponse | RunQueryResponse | ExpandTableResultResponse | SetTabTitleResponse | GetStateResponse<unknown> | SetStateResponse;
88100
error?: Error;
89101
}
90102
interface QueryTabResponse extends BaseTabResponse {
@@ -145,4 +157,4 @@ declare function notify(name: string, args: any): void;
145157
declare function addNotificationListener(name: string, handler: (args: any) => void): Promise<void>;
146158

147159
export { addNotificationListener, notify, request, setDebugComms };
148-
export type { ExpandTableResultRequest, ExpandTableResultResponse, GetAllTabsRequest, GetAllTabsResponse, GetColumnsRequest, GetColumnsResponse, GetConnectionInfoRequest, GetConnectionInfoResponse, GetTablesRequest, GetTablesResponse, PluginNotificationData, PluginRequestData, PluginResponseData, QueryResult, RunQueryRequest, RunQueryResponse, SetTabTitleRequest, SetTabTitleResponse, TabResponse, ThemeChangedNotification, ThemeType, WindowEventClass, WindowEventInits, WindowEventNotification };
160+
export type { ExpandTableResultRequest, ExpandTableResultResponse, GetAllTabsRequest, GetAllTabsResponse, GetColumnsRequest, GetColumnsResponse, GetConnectionInfoRequest, GetConnectionInfoResponse, GetStateRequest, GetStateResponse, GetTablesRequest, GetTablesResponse, PluginNotificationData, PluginRequestData, PluginResponseData, QueryResult, RunQueryRequest, RunQueryResponse, SetStateRequest, SetStateResponse, SetTabTitleRequest, SetTabTitleResponse, TabResponse, ThemeChangedNotification, ThemeType, WindowEventClass, WindowEventInits, WindowEventNotification };

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@beekeeperstudio/plugin",
3-
"version": "1.0.6",
3+
"version": "1.0.7",
44
"description": "A simple TypeScript wrapper to send messages from your Beekeeper Studio plugin to the main app.",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/requestTypes.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,25 @@ export interface SetTabTitleRequest extends BaseRequest {
5050
};
5151
}
5252

53+
export interface GetStateRequest extends BaseRequest {
54+
name: "getState";
55+
args: void;
56+
}
57+
58+
export interface SetStateRequest<T extends unknown> extends BaseRequest {
59+
name: "setState";
60+
args: {
61+
state: T;
62+
};
63+
}
64+
5365
export type PluginRequestData =
5466
| GetTablesRequest
5567
| GetColumnsRequest
5668
| GetConnectionInfoRequest
5769
| GetAllTabsRequest
5870
| RunQueryRequest
5971
| ExpandTableResultRequest
60-
| SetTabTitleRequest;
72+
| SetTabTitleRequest
73+
| GetStateRequest
74+
| SetStateRequest<unknown>;

src/responseTypes.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ export type ExpandTableResultResponse = void;
3636

3737
export type SetTabTitleResponse = void;
3838

39+
export type GetStateResponse<T extends unknown> = T;
40+
41+
export type SetStateResponse = void;
42+
3943
export interface PluginResponseData {
4044
id: string;
4145
result:
@@ -45,7 +49,9 @@ export interface PluginResponseData {
4549
| GetAllTabsResponse
4650
| RunQueryResponse
4751
| ExpandTableResultResponse
48-
| SetTabTitleResponse;
52+
| SetTabTitleResponse
53+
| GetStateResponse<unknown>
54+
| SetStateResponse;
4955
error?: Error;
5056
}
5157

0 commit comments

Comments
 (0)