Skip to content

Commit dd6fc90

Browse files
committed
new methods
1 parent ffa990a commit dd6fc90

File tree

4 files changed

+54
-3
lines changed

4 files changed

+54
-3
lines changed

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.3.1",
3+
"version": "1.4.0-beta.1",
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/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import type {
99
OpenExternalRequest,
1010
SetDataRequest,
1111
SetEncryptedDataRequest,
12+
OpenTabRequest,
13+
OpenQueryTabRequest,
14+
OpenTableTableTabRequest,
15+
OpenTableStructureTabRequest,
1216
} from "./requestTypes";
1317
import type {
1418
GetTablesResponse,
@@ -25,6 +29,7 @@ import type {
2529
SetDataResponse,
2630
GetEncryptedDataResponse,
2731
SetEncryptedDataResponse,
32+
OpenTabResponse,
2833
} from "./responseTypes";
2934

3035
export async function getTables(schema?: string): Promise<GetTablesResponse['result']> {
@@ -115,6 +120,13 @@ export async function setEncryptedData<T>(keyOrValue: string | T, value?: T): Pr
115120
}
116121
}
117122

123+
export async function openTab(type: "query", args: Omit<OpenQueryTabRequest['args'], 'type'>): Promise<OpenTabResponse>;
124+
export async function openTab(type: "tableTable", args: Omit<OpenTableTableTabRequest['args'], 'type'>): Promise<OpenTabResponse>;
125+
export async function openTab(type: "tableStructure", args: Omit<OpenTableStructureTabRequest['args'], 'type'>): Promise<OpenTabResponse>;
126+
export async function openTab(type: OpenTabRequest['args']['type'], args: Omit<OpenTabRequest['args'], 'type'>): Promise<OpenTabResponse> {
127+
return await request({ name: "openTab", args: { type, ...args } });
128+
}
129+
118130
/** Clipboard interface. */
119131
export const clipboard = {
120132
/** Write text to the Electron clipboard. */

src/requestTypes.ts

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,37 @@ export interface ClipboardReadTextRequest extends BaseRequest {
111111
args: void;
112112
}
113113

114+
export type OpenQueryTabRequest = BaseRequest & {
115+
name: "openTab";
116+
args: {
117+
type: "query";
118+
query: string;
119+
};
120+
}
121+
122+
export type OpenTableTableTabRequest = BaseRequest & {
123+
name: "openTab";
124+
args: {
125+
type: "tableTable";
126+
table: string;
127+
schema?: string;
128+
};
129+
}
130+
131+
export type OpenTableStructureTabRequest = BaseRequest & {
132+
name: "openTab";
133+
args: {
134+
type: "tableStructure";
135+
table: string;
136+
schema?: string;
137+
};
138+
}
139+
140+
export type OpenTabRequest =
141+
| OpenQueryTabRequest
142+
| OpenTableTableTabRequest
143+
| OpenTableStructureTabRequest;
144+
114145
export type PluginRequestData =
115146
| GetTablesRequest
116147
| GetColumnsRequest
@@ -127,6 +158,9 @@ export type PluginRequestData =
127158
| GetEncryptedDataRequest
128159
| SetEncryptedDataRequest<unknown>
129160
| ClipboardWriteTextRequest
130-
| ClipboardReadTextRequest;
161+
| ClipboardReadTextRequest
162+
| OpenQueryTabRequest
163+
| OpenTableTableTabRequest
164+
| OpenTableStructureTabRequest;
131165

132166
export type PluginRequestPayload = PluginRequestData;

src/responseTypes.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ export interface ClipboardReadTextResponse extends BaseResponse {
8787
result: string;
8888
}
8989

90+
export interface OpenTabResponse extends BaseResponse {
91+
result: void;
92+
}
93+
9094
export type PluginResponseData =
9195
| GetTablesResponse
9296
| GetColumnsResponse
@@ -103,7 +107,8 @@ export type PluginResponseData =
103107
| GetEncryptedDataResponse<unknown>
104108
| SetEncryptedDataResponse
105109
| ClipboardWriteTextResponse
106-
| ClipboardReadTextResponse;
110+
| ClipboardReadTextResponse
111+
| OpenTabResponse;
107112

108113
export type PluginResponsePayload = PluginResponseData;
109114

0 commit comments

Comments
 (0)