@@ -13,12 +13,12 @@ import type {
1313 OpenQueryTabRequest ,
1414 OpenTableTableTabRequest ,
1515 OpenTableStructureTabRequest ,
16+ GetTableKeysRequest ,
1617} from "./requestTypes" ;
1718import type {
1819 GetTablesResponse ,
1920 GetColumnsResponse ,
2021 GetConnectionInfoResponse ,
21- GetAllTabsResponse ,
2222 RunQueryResponse ,
2323 ExpandTableResultResponse ,
2424 SetTabTitleResponse ,
@@ -30,48 +30,113 @@ import type {
3030 GetEncryptedDataResponse ,
3131 SetEncryptedDataResponse ,
3232 OpenTabResponse ,
33+ GetTableKeysResponse ,
34+ GetAppInfoResponse ,
35+ CheckForUpdateResponse ,
3336} from "./responseTypes" ;
3437
38+ /**
39+ * Get a list of tables from the current database.
40+ * @since Beekeeper Studio 5.3.0
41+ **/
3542export async function getTables ( schema ?: string ) : Promise < GetTablesResponse [ 'result' ] > {
3643 return await request ( { name : "getTables" , args : { schema } as GetTablesRequest [ 'args' ] } ) ;
3744}
3845
46+ /**
47+ * Get a list of columns from a table.
48+ *
49+ * @since Beekeeper Studio 5.3.0
50+ **/
3951export async function getColumns ( table : string , schema ?: string ) : Promise < GetColumnsResponse [ 'result' ] > {
4052 return await request ( { name : "getColumns" , args : { table, schema } as GetColumnsRequest [ 'args' ] } ) ;
4153}
4254
55+ /** @since Beekeeper Studio 5.4.0 */
56+ export async function getTableKeys ( table : string , schema ?: string ) : Promise < GetTableKeysResponse [ 'result' ] > {
57+ return await request ( { name : "getTableKeys" , args : { table, schema } as GetTableKeysRequest [ 'args' ] } ) ;
58+ }
59+
60+ /**
61+ * Get information about the current database connection.
62+ *
63+ * @since Beekeeper Studio 5.3.0
64+ **/
4365export async function getConnectionInfo ( ) : Promise < GetConnectionInfoResponse [ 'result' ] > {
4466 return await request ( { name : "getConnectionInfo" , args : void 0 } ) ;
4567}
4668
47- export async function getAllTabs ( ) : Promise < GetAllTabsResponse [ 'result' ] > {
48- return await request ( { name : "getAllTabs" , args : void 0 } ) ;
69+ /** @since Beekeeper Studio 5.4.0 */
70+ export async function getAppInfo ( ) : Promise < GetAppInfoResponse [ 'result' ] > {
71+ return await request ( { name : "getAppInfo" , args : void 0 } ) ;
4972}
5073
74+ /**
75+ * Check if plugin's update is available.
76+ *
77+ * @since Beekeeper Studio 5.4.0
78+ **/
79+ export async function checkForUpdate ( ) : Promise < CheckForUpdateResponse [ 'result' ] > {
80+ return await request ( { name : "checkForUpdate" , args : void 0 } ) ;
81+ }
82+
83+ /**
84+ * Execute a SQL query against the current database.
85+ *
86+ * WARNING: The query will be executed exactly as provided with no modification
87+ * or sanitization. Always validate and sanitize user input before including it
88+ * in queries to prevent unwanted actions.
89+ *
90+ * @since Beekeeper Studio 5.3.0
91+ **/
5192export async function runQuery ( query : string ) : Promise < RunQueryResponse [ 'result' ] > {
5293 return await request ( { name : "runQuery" , args : { query } as RunQueryRequest [ 'args' ] } ) ;
5394}
5495
96+ /**
97+ * Display query results in the bottom table panel (shell-type tabs only).
98+ *
99+ * @since Beekeeper Studio 5.3.0
100+ **/
55101export async function expandTableResult ( results : any [ ] ) : Promise < ExpandTableResultResponse [ 'result' ] > {
56102 return await request ( { name : "expandTableResult" , args : { results } as ExpandTableResultRequest [ 'args' ] } ) ;
57103}
58104
105+ /**
106+ * Set the title of the current plugin tab.
107+ *
108+ * @since Beekeeper Studio 5.3.0
109+ **/
59110export async function setTabTitle ( title : string ) : Promise < SetTabTitleResponse [ 'result' ] > {
60111 return await request ( { name : "setTabTitle" , args : { title } as SetTabTitleRequest [ 'args' ] } ) ;
61112}
62113
114+ /**
115+ * Get the current state of your view instance.
116+ *
117+ * @see {@link https://docs.beekeeperstudio.io/plugin_development/plugin-views/#view-state|View State }
118+ * @since Beekeeper Studio 5.3.0
119+ **/
63120export async function getViewState < T > ( ) : Promise < GetViewStateResponse < T > [ 'result' ] > {
64121 return await request ( { name : "getViewState" , args : void 0 } ) ;
65122}
66123
124+ /**
125+ * Set the state of your view instance.
126+ *
127+ * @see {@link https://docs.beekeeperstudio.io/plugin_development/plugin-views/#view-state|View State }
128+ * @since Beekeeper Studio 5.3.0
129+ **/
67130export async function setViewState < T > ( state : T ) : Promise < SetViewStateResponse [ 'result' ] > {
68131 return await request ( { name : "setViewState" , args : { state } as SetViewStateRequest < T > [ 'args' ] } ) ;
69132}
70133
134+ /** @since Beekeeper Studio 5.3.0 */
71135export async function openExternal ( link : string ) : Promise < OpenExternalResponse [ 'result' ] > {
72136 return await request ( { name : "openExternal" , args : { link } as OpenExternalRequest [ 'args' ] } ) ;
73137}
74138
139+ /** @since Beekeeper Studio 5.3.0 */
75140export async function getData < T > ( key : string = "default" ) : Promise < GetDataResponse < T > [ 'result' ] > {
76141 return await request ( { name : "getData" , args : { key } } ) ;
77142}
@@ -85,6 +150,8 @@ export async function getData<T>(key: string = "default"): Promise<GetDataRespon
85150 *
86151 * // Store with default key (equivalent to setData("default", value))
87152 * await setData({ name: "John" });
153+ *
154+ * @since Beekeeper Studio 5.3.0
88155 */
89156export async function setData < T > ( key : string , value : T ) : Promise < SetDataResponse [ 'result' ] > ;
90157export async function setData < T > ( value : T ) : Promise < SetDataResponse [ 'result' ] > ;
@@ -96,6 +163,7 @@ export async function setData<T>(keyOrValue: string | T, value?: T): Promise<Set
96163 }
97164}
98165
166+ /** @since Beekeeper Studio 5.3.0 */
99167export async function getEncryptedData < T > ( key : string ) : Promise < GetEncryptedDataResponse < T > [ 'result' ] > {
100168 return await request ( { name : "getEncryptedData" , args : { key } } ) ;
101169}
@@ -109,6 +177,8 @@ export async function getEncryptedData<T>(key: string): Promise<GetEncryptedData
109177 *
110178 * // Store with default key (equivalent to setEncryptedData("default", value))
111179 * await setEncryptedData({ token: "abc123" });
180+ *
181+ * @since Beekeeper Studio 5.3.0
112182 */
113183export async function setEncryptedData < T > ( key : string , value : T ) : Promise < SetEncryptedDataResponse [ 'result' ] > ;
114184export async function setEncryptedData < T > ( value : T ) : Promise < SetEncryptedDataResponse [ 'result' ] > ;
@@ -120,6 +190,7 @@ export async function setEncryptedData<T>(keyOrValue: string | T, value?: T): Pr
120190 }
121191}
122192
193+ /** @since Beekeeper Studio 5.4.0 */
123194export async function openTab ( type : "query" , args ?: Omit < OpenQueryTabRequest [ 'args' ] , 'type' > ) : Promise < OpenTabResponse > ;
124195export async function openTab ( type : "tableTable" , args : Omit < OpenTableTableTabRequest [ 'args' ] , 'type' > ) : Promise < OpenTabResponse > ;
125196export async function openTab ( type : "tableStructure" , args : Omit < OpenTableStructureTabRequest [ 'args' ] , 'type' > ) : Promise < OpenTabResponse > ;
0 commit comments