File tree Expand file tree Collapse file tree 7 files changed +70
-31
lines changed
Expand file tree Collapse file tree 7 files changed +70
-31
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @beekeeperstudio/plugin" ,
3- "version" : " 1.4.0-beta.3 " ,
3+ "version" : " 1.4.0-beta.4 " ,
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" ,
Original file line number Diff line number Diff line change @@ -35,12 +35,29 @@ export type WindowEventInits =
3535
3636export type TableFilter = {
3737 field : string ;
38- type : "=" | "!=" | "like" | "not like" | "<" | "<=" | ">" | ">=" | "in" | "is" | "is not" ;
38+ type :
39+ | "="
40+ | "!="
41+ | "like"
42+ | "not like"
43+ | "<"
44+ | "<="
45+ | ">"
46+ | ">="
47+ | "in"
48+ | "is"
49+ | "is not" ;
3950 value ?: string | string [ ] ;
40- op ?: ' AND' | 'OR' ;
41- }
51+ op ?: " AND" | "OR" ;
52+ } ;
4253
43- export type JsonValue = string | number | boolean | null | JsonValue [ ] | { [ key : string ] : JsonValue } ;
54+ export type JsonValue =
55+ | string
56+ | number
57+ | boolean
58+ | null
59+ | JsonValue [ ]
60+ | { [ key : string ] : JsonValue } ;
4461
4562export type ActiveRange = {
4663 rows : number [ ] ;
@@ -93,4 +110,13 @@ export type CornerMenuParams = {
93110 activeRange : ActiveRange ;
94111} ;
95112
96- export type LoadViewParams = CornerMenuParams | RowMenuParams | ColumnMenuParams | CellMenuParams ;
113+ export type LoadViewParams =
114+ | CornerMenuParams
115+ | RowMenuParams
116+ | ColumnMenuParams
117+ | CellMenuParams ;
118+
119+ export type PluginViewContext = {
120+ command : string ;
121+ params ?: CellMenuParams | ColumnMenuParams | RowMenuParams | CornerMenuParams ;
122+ } ;
Original file line number Diff line number Diff line change 33 BroadcastNotification ,
44 PluginErrorNotification ,
55 ThemeChangedNotification ,
6- ViewLoadedNotification ,
76 WindowEventNotification ,
87} from "./notificationTypes" ;
98import type { PluginRequestPayload } from "./requestTypes" ;
@@ -123,10 +122,6 @@ export function addNotificationListener<Message extends JsonValue = JsonValue>(
123122 name : BroadcastNotification [ "name" ] ,
124123 handler : ( args : BroadcastNotification < Message > [ "args" ] ) => void ,
125124) : void ;
126- export function addNotificationListener (
127- name : ViewLoadedNotification [ "name" ] ,
128- handler : ( args : ViewLoadedNotification [ "args" ] ) => void ,
129- ) : void ;
130125export function addNotificationListener (
131126 name : ThemeChangedNotification [ "name" ] ,
132127 handler : ( args : ThemeChangedNotification [ "args" ] ) => void ,
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ import type {
3333 GetTableKeysResponse ,
3434 GetAppInfoResponse ,
3535 CheckForUpdateResponse ,
36+ GetViewContextResponse ,
3637} from "./responseTypes" ;
3738
3839/**
@@ -111,6 +112,20 @@ export async function setTabTitle(title: string): Promise<SetTabTitleResponse['r
111112 return await request ( { name : "setTabTitle" , args : { title } as SetTabTitleRequest [ 'args' ] } ) ;
112113}
113114
115+ /**
116+ * Get the current view context.
117+ *
118+ * A view context describes how this plugin view was opened and what data is
119+ * available for it. It always includes the static `command` from your
120+ * `manifest.json`, and may also include dynamic `params` depending on where
121+ * the menu was invoked.
122+ *
123+ * @since Beekeeper Studio 5.4.0
124+ **/
125+ export async function getViewContext ( ) : Promise < GetViewContextResponse [ 'result' ] > {
126+ return await request ( { name : "getViewContext" , args : void 0 } ) ;
127+ }
128+
114129/**
115130 * Get the current state of your view instance.
116131 *
Original file line number Diff line number Diff line change @@ -3,10 +3,6 @@ import {
33 WindowEventInits ,
44 WindowEventClass ,
55 JsonValue ,
6- CellMenuParams ,
7- CornerMenuParams ,
8- RowMenuParams ,
9- ColumnMenuParams ,
106} from "./commonTypes" ;
117
128export type AppTheme = {
@@ -45,21 +41,8 @@ export type BroadcastNotification<Message extends JsonValue = JsonValue> = {
4541 } ;
4642} ;
4743
48- export type ViewLoadedNotification = {
49- name : "viewLoaded" ;
50- args : {
51- command : string ;
52- params ?:
53- | CellMenuParams
54- | ColumnMenuParams
55- | RowMenuParams
56- | CornerMenuParams ;
57- } ;
58- } ;
59-
6044export type PluginNotificationData =
6145 | ThemeChangedNotification
6246 | WindowEventNotification
6347 | PluginErrorNotification
64- | ViewLoadedNotification
6548 | BroadcastNotification ;
Original file line number Diff line number Diff line change @@ -58,6 +58,11 @@ export interface SetTabTitleRequest extends BaseRequest {
5858 } ;
5959}
6060
61+ export type GetViewContextRequest = BaseRequest & {
62+ name : "getViewContext" ;
63+ args : void ;
64+ } ;
65+
6166export interface GetViewStateRequest extends BaseRequest {
6267 name : "getViewState" ;
6368 args : void ;
@@ -167,6 +172,7 @@ export type PluginRequestData =
167172 | RunQueryRequest
168173 | ExpandTableResultRequest
169174 | SetTabTitleRequest
175+ | GetViewContextRequest
170176 | GetViewStateRequest
171177 | SetViewStateRequest < unknown >
172178 | OpenExternalRequest
Original file line number Diff line number Diff line change 1- import { QueryResult , TableKey } from "./commonTypes" ;
1+ import {
2+ QueryResult ,
3+ TableKey ,
4+ CellMenuParams ,
5+ CornerMenuParams ,
6+ RowMenuParams ,
7+ ColumnMenuParams ,
8+ PluginViewContext ,
9+ } from "./commonTypes" ;
210import { AppTheme } from "./notificationTypes" ;
311
412type TabType = string ;
@@ -45,7 +53,7 @@ export type GetAppInfoResponse = BaseResponse & {
4553 version : string ;
4654 theme : AppTheme ;
4755 } ;
48- }
56+ } ;
4957
5058export interface RunQueryResponse extends BaseResponse {
5159 result : {
@@ -62,6 +70,10 @@ export interface SetTabTitleResponse extends BaseResponse {
6270 result : void ;
6371}
6472
73+ export type GetViewContextResponse = BaseResponse & {
74+ result : PluginViewContext ;
75+ } ;
76+
6577export interface GetViewStateResponse < T extends unknown > extends BaseResponse {
6678 result : T ;
6779}
@@ -82,7 +94,8 @@ export interface SetDataResponse extends BaseResponse {
8294 result : void ;
8395}
8496
85- export interface GetEncryptedDataResponse < T extends unknown > extends BaseResponse {
97+ export interface GetEncryptedDataResponse < T extends unknown >
98+ extends BaseResponse {
8699 result : T ;
87100}
88101
@@ -114,6 +127,7 @@ export type PluginResponseData =
114127 | RunQueryResponse
115128 | ExpandTableResultResponse
116129 | SetTabTitleResponse
130+ | GetViewContextResponse
117131 | GetViewStateResponse < unknown >
118132 | SetViewStateResponse
119133 | OpenExternalResponse
You can’t perform that action at this time.
0 commit comments