@beekeeperstudio/plugin 1.3.1 → 1.4.0-beta.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"eventForwarder.js","sources":["../src/comms.ts","../src/eventForwarder.ts"],"sourcesContent":["import type { PluginRequestPayload } from \"./requestTypes\";\nimport { generateUUID } from \"./utils\";\n\n// Define a custom import.meta interface for TypeScript\ndeclare global {\n interface ImportMeta {\n env: {\n MODE: string;\n };\n }\n}\n\nconst pendingRequests = new Map<\n string,\n {\n // The whole payload is kept just in case for debugging\n payload: PluginRequestPayload;\n resolve: (value: any) => void;\n reject: (reason?: any) => void;\n }\n>();\n\nlet debugComms = false;\n\nexport function setDebugComms(value: boolean) {\n debugComms = value;\n}\n\nwindow.addEventListener(\"message\", (event) => {\n const { id, name, args, result, error } = event.data || {};\n\n if (name) {\n if (debugComms) {\n const time = new Date().toLocaleTimeString(\"en-GB\");\n console.groupCollapsed(`${time} [NOTIFICATION] ${name}`);\n console.log(\"Args:\", args);\n console.groupEnd();\n }\n\n const handlers = notificationListeners.get(name);\n if (handlers) {\n handlers.forEach((handler) => handler(args));\n }\n }\n\n if (id && pendingRequests.has(id)) {\n const { resolve, reject, payload } = pendingRequests.get(id)!;\n pendingRequests.delete(id);\n\n if (debugComms) {\n const time = new Date().toLocaleTimeString(\"en-GB\");\n console.groupCollapsed(`${time} [RESPONSE] ${payload.name}`);\n console.log(\"Result:\", result);\n if (error) console.error(\"Error:\", error);\n console.groupEnd();\n }\n\n if (error) {\n reject(error);\n } else {\n resolve(result);\n }\n }\n});\n\nexport async function request(raw: any): Promise<any> {\n const payload = { id: generateUUID(), ...raw } as PluginRequestPayload;\n\n if (debugComms) {\n const time = new Date().toLocaleTimeString(\"en-GB\");\n console.groupCollapsed(`${time} [REQUEST] ${payload.name}`);\n console.log(\"id:\", payload.id);\n console.log(\"args:\", payload.args);\n console.log(\"payload:\", payload);\n console.groupEnd();\n }\n\n return new Promise<any>((resolve, reject) => {\n try {\n pendingRequests.set(payload.id, { payload: payload, resolve, reject });\n window.parent.postMessage(payload, \"*\");\n } catch (e) {\n reject(e);\n }\n });\n}\n\nexport function notify(name: string, args: any) {\n const payload = { name, args }\n if (debugComms) {\n const time = new Date().toLocaleTimeString(\"en-GB\");\n console.groupCollapsed(`${time} [NOTIFICATION] ${name}`);\n console.log(\"args:\", args);\n console.log(\"payload:\", payload);\n console.groupEnd();\n }\n window.parent.postMessage(payload, \"*\");\n}\n\nconst notificationListeners = new Map<string, ((args: any) => void)[]>();\n\nexport async function addNotificationListener(\n name: string,\n handler: (args: any) => void,\n) {\n if (!notificationListeners.get(name)) {\n notificationListeners.set(name, []);\n }\n notificationListeners.get(name)!.push(handler);\n}\n","/** Any events that need to be forwarded to parent/plugin system\n * must go here */\n\n/** FIXME this file must be injected from the plugin system automatically */\n\nimport { notify } from \"./comms\";\nimport { WindowEventInits, WindowEventClass } from \"./commonTypes\";\n\nfunction createEventInit<T>(event: T): {\n eventClass: WindowEventClass;\n eventInitOptions: WindowEventInits;\n} {\n if (event instanceof MouseEvent) {\n const eventInitOptions: MouseEventInit = {\n clientX: event.clientX,\n clientY: event.clientY,\n screenX: event.screenX,\n screenY: event.screenY,\n button: event.button,\n buttons: event.buttons,\n altKey: event.altKey,\n ctrlKey: event.ctrlKey,\n shiftKey: event.shiftKey,\n metaKey: event.metaKey,\n movementX: event.movementX,\n movementY: event.movementY,\n detail: event.detail,\n };\n return {\n eventClass: \"MouseEvent\",\n eventInitOptions,\n };\n }\n\n if (event instanceof PointerEvent) {\n const eventInitOptions: PointerEventInit = {\n clientX: event.clientX,\n clientY: event.clientY,\n screenX: event.screenX,\n screenY: event.screenY,\n button: event.button,\n buttons: event.buttons,\n altKey: event.altKey,\n ctrlKey: event.ctrlKey,\n shiftKey: event.shiftKey,\n metaKey: event.metaKey,\n movementX: event.movementX,\n movementY: event.movementY,\n detail: event.detail,\n pointerId: event.pointerId,\n pointerType: event.pointerType,\n isPrimary: event.isPrimary,\n };\n return {\n eventClass: \"PointerEvent\",\n eventInitOptions,\n };\n }\n\n if (event instanceof KeyboardEvent) {\n const isPasswordField =\n (event.target as HTMLInputElement)?.type === \"password\";\n\n if (isPasswordField) {\n // Avoid logging keystrokes from password fields\n return {\n eventClass: \"KeyboardEvent\",\n eventInitOptions: {},\n };\n }\n\n const eventInitOptions: KeyboardEventInit = {\n key: event.key,\n code: event.code,\n keyCode: event.keyCode,\n location: event.location,\n altKey: event.altKey,\n ctrlKey: event.ctrlKey,\n shiftKey: event.shiftKey,\n metaKey: event.metaKey,\n repeat: event.repeat,\n isComposing: event.isComposing,\n };\n\n return {\n eventClass: \"KeyboardEvent\",\n eventInitOptions,\n };\n }\n\n return {\n eventClass: \"Event\",\n eventInitOptions: {},\n };\n}\n\nconst forwardedEvents = [\n \"contextmenu\",\n \"click\",\n \"dblclick\",\n \"pointercancel\",\n \"pointerdown\",\n \"pointerenter\",\n \"pointerleave\",\n \"pointermove\",\n \"pointerout\",\n \"pointerover\",\n \"pointerup\",\n \"mousedown\",\n \"mouseenter\",\n \"mouseleave\",\n \"mousemove\",\n \"mouseout\",\n \"mouseover\",\n \"mouseup\",\n \"keydown\",\n \"keypress\",\n \"keyup\",\n] as const;\n\nforwardedEvents.forEach((eventType) => {\n document.addEventListener(eventType, (event) => {\n const eventInit = createEventInit(event);\n notify(\"windowEvent\", {\n eventType,\n eventClass: eventInit.eventClass,\n eventInitOptions: eventInit.eventInitOptions,\n });\n });\n});\n"],"names":[],"mappings":"AAYA,MAAM,eAAe,GAAG,IAAI,GAAG,EAQ5B;AAQH,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,KAAK,KAAI;AAC3C,IAAA,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC,IAAI,IAAI,EAAE;IAE1D,IAAI,IAAI,EAAE;QAQR,MAAM,QAAQ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AAO,EAAE,KAAK,CAAC,OAAO;YACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,WAAW,EAAE,KAAK,CAAC,WAAW;SAC/B;QAED,OAAO;AACL,YAAA,UAAU,EAAE,eAAe;YAC3B,gBAAgB;SACjB;;IAGH,OAAO;AACL,QAAA,UAAU,EAAE,OAAO;AACnB,QAAA,gBAAgB,EAAE,EAAE;KACrB;AACH;AAEA,MAAM,eAAe,GAAG;IACtB,aAAa;IACb,OAAO;IACP,UAAU;IACV,eAAe;IACf,aAAa;IACb,cAAc;IACd,cAAc;IACd,aAAa;IACb,YAAY;IACZ,aAAa;IACb,WAAW;IACX,WAAW;IACX,YAAY;IACZ,YAAY;IACZ,WAAW;IACX,UAAU;IACV,WAAW;IACX,SAAS;IACT,SAAS;IACT,UAAU;IACV,OAAO;CACC;AAEV,eAAe,CAAC,OAAO,CAAC,CAAC,SAAS,KAAI;IACpC,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,KAAK,KAAI;AAC7C,QAAA,MAAM,SAAS,GAAG,eAAe,CAAC,KAAK,CAAC;QACxC,MAAM,CAAC,aAAa,EAAE;YACpB,SAAS;YACT,UAAU,EAAE,SAAS,CAAC,UAAU;YAChC,gBAAgB,EAAE,SAAS,CAAC,gBAAgB;AAC7C,SAAA,CAAC;AACJ,KAAC,CAAC;AACJ,CAAC,CAAC"}
1
+ {"version":3,"file":"eventForwarder.js","sources":["../src/comms.ts","../src/eventForwarder.ts"],"sourcesContent":["import { JsonValue } from \"./commonTypes\";\nimport {\n BroadcastNotification,\n PluginErrorNotification,\n ThemeChangedNotification,\n ViewLoadedNotification,\n WindowEventNotification,\n} from \"./notificationTypes\";\nimport type { PluginRequestPayload } from \"./requestTypes\";\nimport { generateUUID } from \"./utils\";\n\n// Define a custom import.meta interface for TypeScript\ndeclare global {\n interface ImportMeta {\n env: {\n MODE: string;\n };\n }\n}\n\nconst pendingRequests = new Map<\n string,\n {\n // The whole payload is kept just in case for debugging\n payload: PluginRequestPayload;\n resolve: (value: any) => void;\n reject: (reason?: any) => void;\n }\n>();\n\nlet debugComms = false;\n\nexport function setDebugComms(value: boolean) {\n debugComms = value;\n}\n\nwindow.addEventListener(\"message\", (event) => {\n const { id, name, args, result, error } = event.data || {};\n\n if (name) {\n if (debugComms) {\n const time = new Date().toLocaleTimeString(\"en-GB\");\n console.groupCollapsed(`${time} [NOTIFICATION] ${name}`);\n console.log(\"Args:\", args);\n console.groupEnd();\n }\n\n const handlers = notificationListeners.get(name);\n if (handlers) {\n handlers.forEach((handler) => handler(args));\n }\n }\n\n if (id && pendingRequests.has(id)) {\n const { resolve, reject, payload } = pendingRequests.get(id)!;\n pendingRequests.delete(id);\n\n if (debugComms) {\n const time = new Date().toLocaleTimeString(\"en-GB\");\n console.groupCollapsed(`${time} [RESPONSE] ${payload.name}`);\n console.log(\"Result:\", result);\n if (error) console.error(\"Error:\", error);\n console.groupEnd();\n }\n\n if (error) {\n reject(error);\n } else {\n resolve(result);\n }\n }\n});\n\nexport async function request(raw: any): Promise<any> {\n const payload = { id: generateUUID(), ...raw } as PluginRequestPayload;\n\n if (debugComms) {\n const time = new Date().toLocaleTimeString(\"en-GB\");\n console.groupCollapsed(`${time} [REQUEST] ${payload.name}`);\n console.log(\"id:\", payload.id);\n console.log(\"args:\", payload.args);\n console.log(\"payload:\", payload);\n console.groupEnd();\n }\n\n return new Promise<any>((resolve, reject) => {\n try {\n pendingRequests.set(payload.id, { payload: payload, resolve, reject });\n window.parent.postMessage(payload, \"*\");\n } catch (e) {\n reject(e);\n }\n });\n}\n\nexport function notify<Message extends JsonValue = JsonValue>(\n name: BroadcastNotification[\"name\"],\n args: BroadcastNotification<Message>[\"args\"],\n): void;\nexport function notify(\n name: PluginErrorNotification[\"name\"],\n args: PluginErrorNotification[\"args\"],\n): void;\nexport function notify(\n name: WindowEventNotification[\"name\"],\n args: WindowEventNotification[\"args\"],\n): void;\nexport function notify(name: string, args: any) {\n const payload = { name, args };\n if (debugComms) {\n const time = new Date().toLocaleTimeString(\"en-GB\");\n console.groupCollapsed(`${time} [NOTIFICATION] ${name}`);\n console.log(\"args:\", args);\n console.log(\"payload:\", payload);\n console.groupEnd();\n }\n window.parent.postMessage(payload, \"*\");\n}\n\nconst notificationListeners = new Map<string, ((args: any) => void)[]>();\n\nexport function addNotificationListener<Message extends JsonValue = JsonValue>(\n name: BroadcastNotification[\"name\"],\n handler: (args: BroadcastNotification<Message>[\"args\"]) => void,\n): void;\nexport function addNotificationListener(\n name: ViewLoadedNotification[\"name\"],\n handler: (args: ViewLoadedNotification[\"args\"]) => void,\n): void;\nexport function addNotificationListener(\n name: ThemeChangedNotification[\"name\"],\n handler: (args: ThemeChangedNotification[\"args\"]) => void,\n): void;\nexport function addNotificationListener(\n name: string,\n handler: (args: any) => void,\n) {\n if (!notificationListeners.get(name)) {\n notificationListeners.set(name, []);\n }\n notificationListeners.get(name)!.push(handler);\n}\n\nexport function removeNotificationListener(\n name: string,\n handler: (args: any) => void,\n) {\n const handlers = notificationListeners.get(name);\n if (handlers) {\n const index = handlers.indexOf(handler);\n if (index > -1) {\n handlers.splice(index, 1);\n }\n }\n}\n","/** Any events that need to be forwarded to parent/plugin system\n * must go here */\n\n/** FIXME this file must be injected from the plugin system automatically */\n\nimport { notify } from \"./comms\";\nimport { WindowEventInits, WindowEventClass } from \"./commonTypes\";\n\nfunction createEventInit<T>(event: T): {\n eventClass: WindowEventClass;\n eventInitOptions: WindowEventInits;\n} {\n if (event instanceof MouseEvent) {\n const eventInitOptions: MouseEventInit = {\n clientX: event.clientX,\n clientY: event.clientY,\n screenX: event.screenX,\n screenY: event.screenY,\n button: event.button,\n buttons: event.buttons,\n altKey: event.altKey,\n ctrlKey: event.ctrlKey,\n shiftKey: event.shiftKey,\n metaKey: event.metaKey,\n movementX: event.movementX,\n movementY: event.movementY,\n detail: event.detail,\n };\n return {\n eventClass: \"MouseEvent\",\n eventInitOptions,\n };\n }\n\n if (event instanceof PointerEvent) {\n const eventInitOptions: PointerEventInit = {\n clientX: event.clientX,\n clientY: event.clientY,\n screenX: event.screenX,\n screenY: event.screenY,\n button: event.button,\n buttons: event.buttons,\n altKey: event.altKey,\n ctrlKey: event.ctrlKey,\n shiftKey: event.shiftKey,\n metaKey: event.metaKey,\n movementX: event.movementX,\n movementY: event.movementY,\n detail: event.detail,\n pointerId: event.pointerId,\n pointerType: event.pointerType,\n isPrimary: event.isPrimary,\n };\n return {\n eventClass: \"PointerEvent\",\n eventInitOptions,\n };\n }\n\n if (event instanceof KeyboardEvent) {\n const isPasswordField =\n (event.target as HTMLInputElement)?.type === \"password\";\n\n if (isPasswordField) {\n // Avoid logging keystrokes from password fields\n return {\n eventClass: \"KeyboardEvent\",\n eventInitOptions: {},\n };\n }\n\n const eventInitOptions: KeyboardEventInit = {\n key: event.key,\n code: event.code,\n keyCode: event.keyCode,\n location: event.location,\n altKey: event.altKey,\n ctrlKey: event.ctrlKey,\n shiftKey: event.shiftKey,\n metaKey: event.metaKey,\n repeat: event.repeat,\n isComposing: event.isComposing,\n };\n\n return {\n eventClass: \"KeyboardEvent\",\n eventInitOptions,\n };\n }\n\n return {\n eventClass: \"Event\",\n eventInitOptions: {},\n };\n}\n\nconst forwardedEvents = [\n \"contextmenu\",\n \"click\",\n \"dblclick\",\n \"pointercancel\",\n \"pointerdown\",\n \"pointerenter\",\n \"pointerleave\",\n \"pointermove\",\n \"pointerout\",\n \"pointerover\",\n \"pointerup\",\n \"mousedown\",\n \"mouseenter\",\n \"mouseleave\",\n \"mousemove\",\n \"mouseout\",\n \"mouseover\",\n \"mouseup\",\n \"keydown\",\n \"keypress\",\n \"keyup\",\n] as const;\n\nforwardedEvents.forEach((eventType) => {\n document.addEventListener(eventType, (event) => {\n const eventInit = createEventInit(event);\n notify(\"windowEvent\", {\n eventType,\n eventClass: eventInit.eventClass,\n eventInitOptions: eventInit.eventInitOptions,\n });\n });\n});\n"],"names":[],"mappings":"AAoBA,MAAM,eAAe,GAAG,IAAI,GAAG,EAQ5B;AAQH,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,KAAK,KAAI;AAC3C,IAAA,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC,IAAI,IAAI,EAAE;IAE1D,IAAI,IAAI,EAAE;QAQR,MAAM,QAAQ,GAAG,qBAAqB,CAAC,GAAG,CAAC,IAAI,CAAC;QAChD,IAAI,QAAQ,EAAE;AACZ,YAAA,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;;;IAIhD,IAAI,EAAE,IAAI,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;AACjC,QAAA,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,eAAe,CAAC,GAAG,CAAC,EAAE,CAAE;AAC7D,QAAA,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC;QAU1B,IAAI,KAAK,EAAE;YACT,MAAM,CAAC,KAAK,CAAC;;aACR;YACL,OAAO,CAAC,MAAM,CAAC;;;AAGrB,CAAC,CAAC;AAoCc,SAAA,MAAM,CAAC,IAAY,EAAE,IAAS,EAAA;AAC5C,IAAA,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE;IAQ9B,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,GAAG,CAAC;AACzC;AAEA,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAAmC;;ACvHxE;AACkB;AAElB;AAKA,SAAS,eAAe,CAAI,KAAQ,EAAA;AAIlC,IAAA,IAAI,KAAK,YAAY,UAAU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C7C,QAAA,MAAM,SAAS,GAAG,eAAe,CAAC,KAAK,CAAC;QACxC,MAAM,CAAC,aAAa,EAAE;YACpB,SAAS;YACT,UAAU,EAAE,SAAS,CAAC,UAAU;YAChC,gBAAgB,EAAE,SAAS,CAAC,gBAAgB;AAC7C,SAAA,CAAC;AACJ,KAAC,CAAC;AACJ,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -7,102 +7,29 @@ interface QueryResult {
7
7
  }[];
8
8
  rows: Record<string, unknown>[];
9
9
  }
10
+ interface TableKey {
11
+ isComposite: boolean;
12
+ toTable: string;
13
+ toSchema: string;
14
+ toColumn: string | string[];
15
+ fromTable: string;
16
+ fromSchema: string;
17
+ fromColumn: string | string[];
18
+ constraintName?: string;
19
+ onUpdate?: string;
20
+ onDelete?: string;
21
+ }
10
22
  type WindowEventClass = "MouseEvent" | "KeyboardEvent" | "PointerEvent" | "Event";
11
23
  type WindowEventInits = MouseEventInit | KeyboardEventInit | PointerEventInit;
12
-
13
- type TabType = string;
14
- type TableFilter = any;
15
- type TableOrView = any;
16
- interface BaseResponse {
17
- id: string;
18
- error?: Error;
19
- }
20
- interface GetTablesResponse extends BaseResponse {
21
- result: {
22
- name: string;
23
- schema?: string;
24
- }[];
25
- }
26
- interface GetColumnsResponse extends BaseResponse {
27
- result: {
28
- name: string;
29
- type: string;
30
- }[];
31
- }
32
- interface GetConnectionInfoResponse extends BaseResponse {
33
- result: {
34
- connectionType: string;
35
- databaseName: string;
36
- defaultSchema?: string;
37
- readOnlyMode: boolean;
38
- };
39
- }
40
- interface GetAllTabsResponse extends BaseResponse {
41
- result: Tab[];
42
- }
43
- interface RunQueryResponse extends BaseResponse {
44
- result: {
45
- results: QueryResult[];
46
- error?: unknown;
47
- };
48
- }
49
- interface ExpandTableResultResponse extends BaseResponse {
50
- result: void;
51
- }
52
- interface SetTabTitleResponse extends BaseResponse {
53
- result: void;
54
- }
55
- interface GetViewStateResponse<T extends unknown> extends BaseResponse {
56
- result: T;
57
- }
58
- interface SetViewStateResponse extends BaseResponse {
59
- result: void;
60
- }
61
- interface OpenExternalResponse extends BaseResponse {
62
- result: void;
63
- }
64
- interface GetDataResponse<T extends unknown> extends BaseResponse {
65
- result: T;
66
- }
67
- interface SetDataResponse extends BaseResponse {
68
- result: void;
69
- }
70
- interface GetEncryptedDataResponse<T extends unknown> extends BaseResponse {
71
- result: T;
72
- }
73
- interface SetEncryptedDataResponse extends BaseResponse {
74
- result: void;
75
- }
76
- interface ClipboardWriteTextResponse extends BaseResponse {
77
- result: void;
78
- }
79
- interface ClipboardReadTextResponse extends BaseResponse {
80
- result: string;
81
- }
82
- type PluginResponseData = GetTablesResponse | GetColumnsResponse | GetConnectionInfoResponse | GetAllTabsResponse | RunQueryResponse | ExpandTableResultResponse | SetTabTitleResponse | GetViewStateResponse<unknown> | SetViewStateResponse | OpenExternalResponse | GetDataResponse<unknown> | SetDataResponse | GetEncryptedDataResponse<unknown> | SetEncryptedDataResponse | ClipboardWriteTextResponse | ClipboardReadTextResponse;
83
- type PluginResponsePayload = PluginResponseData;
84
- type TabResponse = Tab;
85
- type Tab = BaseTabResponse | QueryTabResponse | TableTabResponse;
86
- interface BaseTabResponse {
87
- type: TabType;
88
- id: number;
89
- title: string;
90
- }
91
- interface QueryTabResponse extends BaseTabResponse {
92
- type: "query";
93
- data: {
94
- query: string;
95
- result: unknown;
96
- };
97
- }
98
- interface TableTabResponse extends BaseTabResponse {
99
- type: "table";
100
- data: {
101
- table: TableOrView;
102
- filters: TableFilter[] | string;
103
- result: unknown;
104
- };
105
- }
24
+ type TableFilter$1 = {
25
+ field: string;
26
+ type: "=" | "!=" | "like" | "not like" | "<" | "<=" | ">" | ">=" | "in" | "is" | "is not";
27
+ value?: string | string[];
28
+ op?: 'AND' | 'OR';
29
+ };
30
+ type JsonValue = string | number | boolean | null | JsonValue[] | {
31
+ [key: string]: JsonValue;
32
+ };
106
33
 
107
34
  interface BaseRequest {
108
35
  id: string;
@@ -120,14 +47,21 @@ interface GetColumnsRequest extends BaseRequest {
120
47
  schema?: string;
121
48
  };
122
49
  }
50
+ type GetTableKeysRequest = BaseRequest & {
51
+ name: "getTableKeys";
52
+ args: {
53
+ table: string;
54
+ schema?: string;
55
+ };
56
+ };
57
+ type GetAppInfoRequest = BaseRequest & {
58
+ name: "getAppInfo";
59
+ args: void;
60
+ };
123
61
  interface GetConnectionInfoRequest extends BaseRequest {
124
62
  name: "getConnectionInfo";
125
63
  args: void;
126
64
  }
127
- interface GetAllTabsRequest extends BaseRequest {
128
- name: "getAllTabs";
129
- args: void;
130
- }
131
65
  interface RunQueryRequest extends BaseRequest {
132
66
  name: "runQuery";
133
67
  args: {
@@ -198,34 +132,187 @@ interface ClipboardReadTextRequest extends BaseRequest {
198
132
  name: "clipboard.readText";
199
133
  args: void;
200
134
  }
201
- type PluginRequestData = GetTablesRequest | GetColumnsRequest | GetConnectionInfoRequest | GetAllTabsRequest | RunQueryRequest | ExpandTableResultRequest | SetTabTitleRequest | GetViewStateRequest | SetViewStateRequest<unknown> | OpenExternalRequest | GetDataRequest | SetDataRequest<unknown> | GetEncryptedDataRequest | SetEncryptedDataRequest<unknown> | ClipboardWriteTextRequest | ClipboardReadTextRequest;
135
+ type OpenQueryTabRequest = BaseRequest & {
136
+ name: "openTab";
137
+ args: {
138
+ type: "query";
139
+ query?: string;
140
+ };
141
+ };
142
+ type OpenTableTableTabRequest = BaseRequest & {
143
+ name: "openTab";
144
+ args: {
145
+ type: "tableTable";
146
+ table: string;
147
+ schema?: string;
148
+ filters?: TableFilter$1[];
149
+ database?: string;
150
+ };
151
+ };
152
+ type OpenTableStructureTabRequest = BaseRequest & {
153
+ name: "openTab";
154
+ args: {
155
+ type: "tableStructure";
156
+ table: string;
157
+ schema?: string;
158
+ database?: string;
159
+ };
160
+ };
161
+ type CheckForUpdateRequest = BaseRequest & {
162
+ name: "checkForUpdate";
163
+ args: void;
164
+ };
165
+ type OpenTabRequest = OpenQueryTabRequest | OpenTableTableTabRequest | OpenTableStructureTabRequest;
166
+ type PluginRequestData = GetTablesRequest | GetColumnsRequest | GetTableKeysRequest | GetAppInfoRequest | GetConnectionInfoRequest | RunQueryRequest | ExpandTableResultRequest | SetTabTitleRequest | GetViewStateRequest | SetViewStateRequest<unknown> | OpenExternalRequest | GetDataRequest | SetDataRequest<unknown> | GetEncryptedDataRequest | SetEncryptedDataRequest<unknown> | ClipboardWriteTextRequest | ClipboardReadTextRequest | OpenTabRequest | CheckForUpdateRequest;
202
167
  type PluginRequestPayload = PluginRequestData;
203
168
 
204
- interface ThemeChangedNotification {
169
+ type AppTheme = {
170
+ palette: Record<string, string>;
171
+ cssString: string;
172
+ type: ThemeType;
173
+ };
174
+ type ThemeChangedNotification = {
205
175
  name: "themeChanged";
206
- args: {
207
- palette: Record<string, string>;
208
- cssString: string;
209
- type: ThemeType;
210
- };
211
- }
212
- interface WindowEventNotification {
176
+ args: AppTheme;
177
+ };
178
+ type WindowEventNotification = {
213
179
  name: "windowEvent";
214
180
  args: {
215
181
  eventType: string;
216
182
  eventClass: WindowEventClass;
217
183
  eventInitOptions: WindowEventInits;
218
184
  };
219
- }
220
- interface PluginErrorNotification {
185
+ };
186
+ type PluginErrorNotification = {
221
187
  name: "pluginError";
222
188
  args: {
223
189
  name?: string;
224
190
  message?: string;
225
191
  stack?: string;
226
192
  };
193
+ };
194
+ type BroadcastNotification<Message extends JsonValue = JsonValue> = {
195
+ name: "broadcast";
196
+ args: {
197
+ message: Message;
198
+ };
199
+ };
200
+ type ViewLoadedNotification = {
201
+ name: "viewLoaded";
202
+ args: {
203
+ command: string;
204
+ args?: JsonValue;
205
+ };
206
+ };
207
+ type PluginNotificationData = ThemeChangedNotification | WindowEventNotification | PluginErrorNotification | ViewLoadedNotification | BroadcastNotification;
208
+
209
+ type TabType = string;
210
+ type TableFilter = any;
211
+ type TableOrView = any;
212
+ interface BaseResponse {
213
+ id: string;
214
+ error?: Error;
215
+ }
216
+ interface GetTablesResponse extends BaseResponse {
217
+ result: {
218
+ name: string;
219
+ schema?: string;
220
+ }[];
221
+ }
222
+ interface GetColumnsResponse extends BaseResponse {
223
+ result: {
224
+ name: string;
225
+ type: string;
226
+ }[];
227
+ }
228
+ type GetTableKeysResponse = BaseResponse & {
229
+ result: TableKey[];
230
+ };
231
+ interface GetConnectionInfoResponse extends BaseResponse {
232
+ result: {
233
+ /** @deprecated Use `databaseType` instead */
234
+ connectionType: string;
235
+ databaseType: string;
236
+ databaseTypeDisplayName: string;
237
+ databaseName: string;
238
+ defaultSchema?: string;
239
+ readOnlyMode: boolean;
240
+ };
241
+ }
242
+ type GetAppInfoResponse = BaseResponse & {
243
+ result: {
244
+ version: string;
245
+ theme: AppTheme;
246
+ };
247
+ };
248
+ interface RunQueryResponse extends BaseResponse {
249
+ result: {
250
+ results: QueryResult[];
251
+ error?: unknown;
252
+ };
253
+ }
254
+ interface ExpandTableResultResponse extends BaseResponse {
255
+ result: void;
256
+ }
257
+ interface SetTabTitleResponse extends BaseResponse {
258
+ result: void;
259
+ }
260
+ interface GetViewStateResponse<T extends unknown> extends BaseResponse {
261
+ result: T;
262
+ }
263
+ interface SetViewStateResponse extends BaseResponse {
264
+ result: void;
265
+ }
266
+ interface OpenExternalResponse extends BaseResponse {
267
+ result: void;
268
+ }
269
+ interface GetDataResponse<T extends unknown> extends BaseResponse {
270
+ result: T;
271
+ }
272
+ interface SetDataResponse extends BaseResponse {
273
+ result: void;
274
+ }
275
+ interface GetEncryptedDataResponse<T extends unknown> extends BaseResponse {
276
+ result: T;
277
+ }
278
+ interface SetEncryptedDataResponse extends BaseResponse {
279
+ result: void;
280
+ }
281
+ interface ClipboardWriteTextResponse extends BaseResponse {
282
+ result: void;
283
+ }
284
+ interface ClipboardReadTextResponse extends BaseResponse {
285
+ result: string;
286
+ }
287
+ interface OpenTabResponse extends BaseResponse {
288
+ result: void;
289
+ }
290
+ interface CheckForUpdateResponse extends BaseResponse {
291
+ result: boolean;
292
+ }
293
+ type PluginResponseData = GetTablesResponse | GetColumnsResponse | GetTableKeysResponse | GetConnectionInfoResponse | RunQueryResponse | ExpandTableResultResponse | SetTabTitleResponse | GetViewStateResponse<unknown> | SetViewStateResponse | OpenExternalResponse | GetDataResponse<unknown> | SetDataResponse | GetEncryptedDataResponse<unknown> | SetEncryptedDataResponse | ClipboardWriteTextResponse | ClipboardReadTextResponse | OpenTabResponse | CheckForUpdateResponse;
294
+ type PluginResponsePayload = PluginResponseData;
295
+ type TabResponse = BaseTabResponse | QueryTabResponse | TableTabResponse;
296
+ interface BaseTabResponse {
297
+ type: TabType;
298
+ id: number;
299
+ title: string;
300
+ }
301
+ interface QueryTabResponse extends BaseTabResponse {
302
+ type: "query";
303
+ data: {
304
+ query: string;
305
+ result: unknown;
306
+ };
307
+ }
308
+ interface TableTabResponse extends BaseTabResponse {
309
+ type: "table";
310
+ data: {
311
+ table: TableOrView;
312
+ filters: TableFilter[] | string;
313
+ result: unknown;
314
+ };
227
315
  }
228
- type PluginNotificationData = ThemeChangedNotification | WindowEventNotification | PluginErrorNotification;
229
316
 
230
317
  declare global {
231
318
  interface ImportMeta {
@@ -236,19 +323,80 @@ declare global {
236
323
  }
237
324
  declare function setDebugComms(value: boolean): void;
238
325
  declare function request(raw: any): Promise<any>;
239
- declare function notify(name: string, args: any): void;
240
- declare function addNotificationListener(name: string, handler: (args: any) => void): Promise<void>;
326
+ declare function notify<Message extends JsonValue = JsonValue>(name: BroadcastNotification["name"], args: BroadcastNotification<Message>["args"]): void;
327
+ declare function notify(name: PluginErrorNotification["name"], args: PluginErrorNotification["args"]): void;
328
+ declare function notify(name: WindowEventNotification["name"], args: WindowEventNotification["args"]): void;
329
+ declare function addNotificationListener<Message extends JsonValue = JsonValue>(name: BroadcastNotification["name"], handler: (args: BroadcastNotification<Message>["args"]) => void): void;
330
+ declare function addNotificationListener(name: ViewLoadedNotification["name"], handler: (args: ViewLoadedNotification["args"]) => void): void;
331
+ declare function addNotificationListener(name: ThemeChangedNotification["name"], handler: (args: ThemeChangedNotification["args"]) => void): void;
332
+ declare function removeNotificationListener(name: string, handler: (args: any) => void): void;
241
333
 
334
+ /**
335
+ * Get a list of tables from the current database.
336
+ * @since Beekeeper Studio 5.3.0
337
+ **/
242
338
  declare function getTables(schema?: string): Promise<GetTablesResponse['result']>;
339
+ /**
340
+ * Get a list of columns from a table.
341
+ *
342
+ * @since Beekeeper Studio 5.3.0
343
+ **/
243
344
  declare function getColumns(table: string, schema?: string): Promise<GetColumnsResponse['result']>;
345
+ /** @since Beekeeper Studio 5.4.0 */
346
+ declare function getTableKeys(table: string, schema?: string): Promise<GetTableKeysResponse['result']>;
347
+ /**
348
+ * Get information about the current database connection.
349
+ *
350
+ * @since Beekeeper Studio 5.3.0
351
+ **/
244
352
  declare function getConnectionInfo(): Promise<GetConnectionInfoResponse['result']>;
245
- declare function getAllTabs(): Promise<GetAllTabsResponse['result']>;
353
+ /** @since Beekeeper Studio 5.4.0 */
354
+ declare function getAppInfo(): Promise<GetAppInfoResponse['result']>;
355
+ /**
356
+ * Check if plugin's update is available.
357
+ *
358
+ * @since Beekeeper Studio 5.4.0
359
+ **/
360
+ declare function checkForUpdate(): Promise<CheckForUpdateResponse['result']>;
361
+ /**
362
+ * Execute a SQL query against the current database.
363
+ *
364
+ * WARNING: The query will be executed exactly as provided with no modification
365
+ * or sanitization. Always validate and sanitize user input before including it
366
+ * in queries to prevent unwanted actions.
367
+ *
368
+ * @since Beekeeper Studio 5.3.0
369
+ **/
246
370
  declare function runQuery(query: string): Promise<RunQueryResponse['result']>;
371
+ /**
372
+ * Display query results in the bottom table panel (shell-type tabs only).
373
+ *
374
+ * @since Beekeeper Studio 5.3.0
375
+ **/
247
376
  declare function expandTableResult(results: any[]): Promise<ExpandTableResultResponse['result']>;
377
+ /**
378
+ * Set the title of the current plugin tab.
379
+ *
380
+ * @since Beekeeper Studio 5.3.0
381
+ **/
248
382
  declare function setTabTitle(title: string): Promise<SetTabTitleResponse['result']>;
383
+ /**
384
+ * Get the current state of your view instance.
385
+ *
386
+ * @see {@link https://docs.beekeeperstudio.io/plugin_development/plugin-views/#view-state|View State}
387
+ * @since Beekeeper Studio 5.3.0
388
+ **/
249
389
  declare function getViewState<T>(): Promise<GetViewStateResponse<T>['result']>;
390
+ /**
391
+ * Set the state of your view instance.
392
+ *
393
+ * @see {@link https://docs.beekeeperstudio.io/plugin_development/plugin-views/#view-state|View State}
394
+ * @since Beekeeper Studio 5.3.0
395
+ **/
250
396
  declare function setViewState<T>(state: T): Promise<SetViewStateResponse['result']>;
397
+ /** @since Beekeeper Studio 5.3.0 */
251
398
  declare function openExternal(link: string): Promise<OpenExternalResponse['result']>;
399
+ /** @since Beekeeper Studio 5.3.0 */
252
400
  declare function getData<T>(key?: string): Promise<GetDataResponse<T>['result']>;
253
401
  /**
254
402
  * Store data that can be retrieved later.
@@ -259,9 +407,12 @@ declare function getData<T>(key?: string): Promise<GetDataResponse<T>['result']>
259
407
  *
260
408
  * // Store with default key (equivalent to setData("default", value))
261
409
  * await setData({ name: "John" });
410
+ *
411
+ * @since Beekeeper Studio 5.3.0
262
412
  */
263
413
  declare function setData<T>(key: string, value: T): Promise<SetDataResponse['result']>;
264
414
  declare function setData<T>(value: T): Promise<SetDataResponse['result']>;
415
+ /** @since Beekeeper Studio 5.3.0 */
265
416
  declare function getEncryptedData<T>(key: string): Promise<GetEncryptedDataResponse<T>['result']>;
266
417
  /**
267
418
  * Store encrypted data that can be retrieved later.
@@ -272,9 +423,15 @@ declare function getEncryptedData<T>(key: string): Promise<GetEncryptedDataRespo
272
423
  *
273
424
  * // Store with default key (equivalent to setEncryptedData("default", value))
274
425
  * await setEncryptedData({ token: "abc123" });
426
+ *
427
+ * @since Beekeeper Studio 5.3.0
275
428
  */
276
429
  declare function setEncryptedData<T>(key: string, value: T): Promise<SetEncryptedDataResponse['result']>;
277
430
  declare function setEncryptedData<T>(value: T): Promise<SetEncryptedDataResponse['result']>;
431
+ /** @since Beekeeper Studio 5.4.0 */
432
+ declare function openTab(type: "query", args?: Omit<OpenQueryTabRequest['args'], 'type'>): Promise<OpenTabResponse>;
433
+ declare function openTab(type: "tableTable", args: Omit<OpenTableTableTabRequest['args'], 'type'>): Promise<OpenTabResponse>;
434
+ declare function openTab(type: "tableStructure", args: Omit<OpenTableStructureTabRequest['args'], 'type'>): Promise<OpenTabResponse>;
278
435
  /** Clipboard interface. */
279
436
  declare const clipboard: {
280
437
  /** Write text to the Electron clipboard. */
@@ -283,5 +440,5 @@ declare const clipboard: {
283
440
  readText(): Promise<string>;
284
441
  };
285
442
 
286
- export { addNotificationListener, clipboard, expandTableResult, getAllTabs, getColumns, getConnectionInfo, getData, getEncryptedData, getTables, getViewState, notify, openExternal, request, runQuery, setData, setDebugComms, setEncryptedData, setTabTitle, setViewState };
287
- export type { ClipboardReadTextRequest, ClipboardReadTextResponse, ClipboardWriteTextRequest, ClipboardWriteTextResponse, ExpandTableResultRequest, ExpandTableResultResponse, GetAllTabsRequest, GetAllTabsResponse, GetColumnsRequest, GetColumnsResponse, GetConnectionInfoRequest, GetConnectionInfoResponse, GetDataRequest, GetDataResponse, GetEncryptedDataRequest, GetEncryptedDataResponse, GetTablesRequest, GetTablesResponse, GetViewStateRequest, GetViewStateResponse, OpenExternalRequest, OpenExternalResponse, PluginErrorNotification, PluginNotificationData, PluginRequestData, PluginRequestPayload, PluginResponseData, PluginResponsePayload, QueryResult, RunQueryRequest, RunQueryResponse, SetDataRequest, SetDataResponse, SetEncryptedDataRequest, SetEncryptedDataResponse, SetTabTitleRequest, SetTabTitleResponse, SetViewStateRequest, SetViewStateResponse, TabResponse, ThemeChangedNotification, ThemeType, WindowEventClass, WindowEventInits, WindowEventNotification };
443
+ export { addNotificationListener, checkForUpdate, clipboard, expandTableResult, getAppInfo, getColumns, getConnectionInfo, getData, getEncryptedData, getTableKeys, getTables, getViewState, notify, openExternal, openTab, removeNotificationListener, request, runQuery, setData, setDebugComms, setEncryptedData, setTabTitle, setViewState };
444
+ export type { AppTheme, BroadcastNotification, CheckForUpdateRequest, CheckForUpdateResponse, ClipboardReadTextRequest, ClipboardReadTextResponse, ClipboardWriteTextRequest, ClipboardWriteTextResponse, ExpandTableResultRequest, ExpandTableResultResponse, GetAppInfoRequest, GetAppInfoResponse, GetColumnsRequest, GetColumnsResponse, GetConnectionInfoRequest, GetConnectionInfoResponse, GetDataRequest, GetDataResponse, GetEncryptedDataRequest, GetEncryptedDataResponse, GetTableKeysRequest, GetTableKeysResponse, GetTablesRequest, GetTablesResponse, GetViewStateRequest, GetViewStateResponse, JsonValue, OpenExternalRequest, OpenExternalResponse, OpenQueryTabRequest, OpenTabRequest, OpenTabResponse, OpenTableStructureTabRequest, OpenTableTableTabRequest, PluginErrorNotification, PluginNotificationData, PluginRequestData, PluginRequestPayload, PluginResponseData, PluginResponsePayload, QueryResult, RunQueryRequest, RunQueryResponse, SetDataRequest, SetDataResponse, SetEncryptedDataRequest, SetEncryptedDataResponse, SetTabTitleRequest, SetTabTitleResponse, SetViewStateRequest, SetViewStateResponse, TabResponse, TableFilter$1 as TableFilter, TableKey, ThemeChangedNotification, ThemeType, ViewLoadedNotification, WindowEventClass, WindowEventInits, WindowEventNotification };
package/dist/index.js CHANGED
@@ -83,43 +83,112 @@ function notify(name, args) {
83
83
  window.parent.postMessage(payload, "*");
84
84
  }
85
85
  const notificationListeners = new Map();
86
- async function addNotificationListener(name, handler) {
86
+ function addNotificationListener(name, handler) {
87
87
  if (!notificationListeners.get(name)) {
88
88
  notificationListeners.set(name, []);
89
89
  }
90
90
  notificationListeners.get(name).push(handler);
91
91
  }
92
+ function removeNotificationListener(name, handler) {
93
+ const handlers = notificationListeners.get(name);
94
+ if (handlers) {
95
+ const index = handlers.indexOf(handler);
96
+ if (index > -1) {
97
+ handlers.splice(index, 1);
98
+ }
99
+ }
100
+ }
92
101
 
102
+ /**
103
+ * Get a list of tables from the current database.
104
+ * @since Beekeeper Studio 5.3.0
105
+ **/
93
106
  async function getTables(schema) {
94
107
  return await request({ name: "getTables", args: { schema } });
95
108
  }
109
+ /**
110
+ * Get a list of columns from a table.
111
+ *
112
+ * @since Beekeeper Studio 5.3.0
113
+ **/
96
114
  async function getColumns(table, schema) {
97
115
  return await request({ name: "getColumns", args: { table, schema } });
98
116
  }
117
+ /** @since Beekeeper Studio 5.4.0 */
118
+ async function getTableKeys(table, schema) {
119
+ return await request({ name: "getTableKeys", args: { table, schema } });
120
+ }
121
+ /**
122
+ * Get information about the current database connection.
123
+ *
124
+ * @since Beekeeper Studio 5.3.0
125
+ **/
99
126
  async function getConnectionInfo() {
100
127
  return await request({ name: "getConnectionInfo", args: void 0 });
101
128
  }
102
- async function getAllTabs() {
103
- return await request({ name: "getAllTabs", args: void 0 });
104
- }
129
+ /** @since Beekeeper Studio 5.4.0 */
130
+ async function getAppInfo() {
131
+ return await request({ name: "getAppInfo", args: void 0 });
132
+ }
133
+ /**
134
+ * Check if plugin's update is available.
135
+ *
136
+ * @since Beekeeper Studio 5.4.0
137
+ **/
138
+ async function checkForUpdate() {
139
+ return await request({ name: "checkForUpdate", args: void 0 });
140
+ }
141
+ /**
142
+ * Execute a SQL query against the current database.
143
+ *
144
+ * WARNING: The query will be executed exactly as provided with no modification
145
+ * or sanitization. Always validate and sanitize user input before including it
146
+ * in queries to prevent unwanted actions.
147
+ *
148
+ * @since Beekeeper Studio 5.3.0
149
+ **/
105
150
  async function runQuery(query) {
106
151
  return await request({ name: "runQuery", args: { query } });
107
152
  }
153
+ /**
154
+ * Display query results in the bottom table panel (shell-type tabs only).
155
+ *
156
+ * @since Beekeeper Studio 5.3.0
157
+ **/
108
158
  async function expandTableResult(results) {
109
159
  return await request({ name: "expandTableResult", args: { results } });
110
160
  }
161
+ /**
162
+ * Set the title of the current plugin tab.
163
+ *
164
+ * @since Beekeeper Studio 5.3.0
165
+ **/
111
166
  async function setTabTitle(title) {
112
167
  return await request({ name: "setTabTitle", args: { title } });
113
168
  }
169
+ /**
170
+ * Get the current state of your view instance.
171
+ *
172
+ * @see {@link https://docs.beekeeperstudio.io/plugin_development/plugin-views/#view-state|View State}
173
+ * @since Beekeeper Studio 5.3.0
174
+ **/
114
175
  async function getViewState() {
115
176
  return await request({ name: "getViewState", args: void 0 });
116
177
  }
178
+ /**
179
+ * Set the state of your view instance.
180
+ *
181
+ * @see {@link https://docs.beekeeperstudio.io/plugin_development/plugin-views/#view-state|View State}
182
+ * @since Beekeeper Studio 5.3.0
183
+ **/
117
184
  async function setViewState(state) {
118
185
  return await request({ name: "setViewState", args: { state } });
119
186
  }
187
+ /** @since Beekeeper Studio 5.3.0 */
120
188
  async function openExternal(link) {
121
189
  return await request({ name: "openExternal", args: { link } });
122
190
  }
191
+ /** @since Beekeeper Studio 5.3.0 */
123
192
  async function getData(key = "default") {
124
193
  return await request({ name: "getData", args: { key } });
125
194
  }
@@ -131,6 +200,7 @@ async function setData(keyOrValue, value) {
131
200
  return await request({ name: "setData", args: { key: "default", value: keyOrValue } });
132
201
  }
133
202
  }
203
+ /** @since Beekeeper Studio 5.3.0 */
134
204
  async function getEncryptedData(key) {
135
205
  return await request({ name: "getEncryptedData", args: { key } });
136
206
  }
@@ -142,6 +212,9 @@ async function setEncryptedData(keyOrValue, value) {
142
212
  return await request({ name: "setEncryptedData", args: { key: "default", value: keyOrValue } });
143
213
  }
144
214
  }
215
+ async function openTab(type, args) {
216
+ return await request({ name: "openTab", args: { type, ...args } });
217
+ }
145
218
  /** Clipboard interface. */
146
219
  const clipboard = {
147
220
  /** Write text to the Electron clipboard. */
@@ -162,5 +235,5 @@ const clipboard = {
162
235
  // async read() {},
163
236
  };
164
237
 
165
- export { addNotificationListener, clipboard, expandTableResult, getAllTabs, getColumns, getConnectionInfo, getData, getEncryptedData, getTables, getViewState, notify, openExternal, request, runQuery, setData, setDebugComms, setEncryptedData, setTabTitle, setViewState };
238
+ export { addNotificationListener, checkForUpdate, clipboard, expandTableResult, getAppInfo, getColumns, getConnectionInfo, getData, getEncryptedData, getTableKeys, getTables, getViewState, notify, openExternal, openTab, removeNotificationListener, request, runQuery, setData, setDebugComms, setEncryptedData, setTabTitle, setViewState };
166
239
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/utils.ts","../src/comms.ts","../src/index.ts"],"sourcesContent":["export function generateUUID() {\n const buf = new Uint8Array(16);\n crypto.getRandomValues(buf);\n\n buf[6] = (buf[6] & 0x0f) | 0x40; // version 4\n buf[8] = (buf[8] & 0x3f) | 0x80; // variant\n\n const hex = Array.from(buf, (b) => b.toString(16).padStart(2, \"0\")).join(\"\");\n\n return [\n hex.substring(0, 8),\n hex.substring(8, 12),\n hex.substring(12, 16),\n hex.substring(16, 20),\n hex.substring(20),\n ].join(\"-\");\n}\n","import type { PluginRequestPayload } from \"./requestTypes\";\nimport { generateUUID } from \"./utils\";\n\n// Define a custom import.meta interface for TypeScript\ndeclare global {\n interface ImportMeta {\n env: {\n MODE: string;\n };\n }\n}\n\nconst pendingRequests = new Map<\n string,\n {\n // The whole payload is kept just in case for debugging\n payload: PluginRequestPayload;\n resolve: (value: any) => void;\n reject: (reason?: any) => void;\n }\n>();\n\nlet debugComms = false;\n\nexport function setDebugComms(value: boolean) {\n debugComms = value;\n}\n\nwindow.addEventListener(\"message\", (event) => {\n const { id, name, args, result, error } = event.data || {};\n\n if (name) {\n if (debugComms) {\n const time = new Date().toLocaleTimeString(\"en-GB\");\n console.groupCollapsed(`${time} [NOTIFICATION] ${name}`);\n console.log(\"Args:\", args);\n console.groupEnd();\n }\n\n const handlers = notificationListeners.get(name);\n if (handlers) {\n handlers.forEach((handler) => handler(args));\n }\n }\n\n if (id && pendingRequests.has(id)) {\n const { resolve, reject, payload } = pendingRequests.get(id)!;\n pendingRequests.delete(id);\n\n if (debugComms) {\n const time = new Date().toLocaleTimeString(\"en-GB\");\n console.groupCollapsed(`${time} [RESPONSE] ${payload.name}`);\n console.log(\"Result:\", result);\n if (error) console.error(\"Error:\", error);\n console.groupEnd();\n }\n\n if (error) {\n reject(error);\n } else {\n resolve(result);\n }\n }\n});\n\nexport async function request(raw: any): Promise<any> {\n const payload = { id: generateUUID(), ...raw } as PluginRequestPayload;\n\n if (debugComms) {\n const time = new Date().toLocaleTimeString(\"en-GB\");\n console.groupCollapsed(`${time} [REQUEST] ${payload.name}`);\n console.log(\"id:\", payload.id);\n console.log(\"args:\", payload.args);\n console.log(\"payload:\", payload);\n console.groupEnd();\n }\n\n return new Promise<any>((resolve, reject) => {\n try {\n pendingRequests.set(payload.id, { payload: payload, resolve, reject });\n window.parent.postMessage(payload, \"*\");\n } catch (e) {\n reject(e);\n }\n });\n}\n\nexport function notify(name: string, args: any) {\n const payload = { name, args }\n if (debugComms) {\n const time = new Date().toLocaleTimeString(\"en-GB\");\n console.groupCollapsed(`${time} [NOTIFICATION] ${name}`);\n console.log(\"args:\", args);\n console.log(\"payload:\", payload);\n console.groupEnd();\n }\n window.parent.postMessage(payload, \"*\");\n}\n\nconst notificationListeners = new Map<string, ((args: any) => void)[]>();\n\nexport async function addNotificationListener(\n name: string,\n handler: (args: any) => void,\n) {\n if (!notificationListeners.get(name)) {\n notificationListeners.set(name, []);\n }\n notificationListeners.get(name)!.push(handler);\n}\n","import { request } from \"./comms\";\nimport type {\n GetTablesRequest,\n GetColumnsRequest,\n RunQueryRequest,\n ExpandTableResultRequest,\n SetTabTitleRequest,\n SetViewStateRequest,\n OpenExternalRequest,\n SetDataRequest,\n SetEncryptedDataRequest,\n} from \"./requestTypes\";\nimport type {\n GetTablesResponse,\n GetColumnsResponse,\n GetConnectionInfoResponse,\n GetAllTabsResponse,\n RunQueryResponse,\n ExpandTableResultResponse,\n SetTabTitleResponse,\n GetViewStateResponse,\n SetViewStateResponse,\n OpenExternalResponse,\n GetDataResponse,\n SetDataResponse,\n GetEncryptedDataResponse,\n SetEncryptedDataResponse,\n} from \"./responseTypes\";\n\nexport async function getTables(schema?: string): Promise<GetTablesResponse['result']> {\n return await request({ name: \"getTables\", args: { schema } as GetTablesRequest['args'] });\n}\n\nexport async function getColumns(table: string, schema?: string): Promise<GetColumnsResponse['result']> {\n return await request({ name: \"getColumns\", args: { table, schema } as GetColumnsRequest['args'] });\n}\n\nexport async function getConnectionInfo(): Promise<GetConnectionInfoResponse['result']> {\n return await request({ name: \"getConnectionInfo\", args: void 0 });\n}\n\nexport async function getAllTabs(): Promise<GetAllTabsResponse['result']> {\n return await request({ name: \"getAllTabs\", args: void 0 });\n}\n\nexport async function runQuery(query: string): Promise<RunQueryResponse['result']> {\n return await request({ name: \"runQuery\", args: { query } as RunQueryRequest['args'] });\n}\n\nexport async function expandTableResult(results: any[]): Promise<ExpandTableResultResponse['result']> {\n return await request({ name: \"expandTableResult\", args: { results } as ExpandTableResultRequest['args'] });\n}\n\nexport async function setTabTitle(title: string): Promise<SetTabTitleResponse['result']> {\n return await request({ name: \"setTabTitle\", args: { title } as SetTabTitleRequest['args'] });\n}\n\nexport async function getViewState<T>(): Promise<GetViewStateResponse<T>['result']> {\n return await request({ name: \"getViewState\", args: void 0 });\n}\n\nexport async function setViewState<T>(state: T): Promise<SetViewStateResponse['result']> {\n return await request({ name: \"setViewState\", args: { state } as SetViewStateRequest<T>['args'] });\n}\n\nexport async function openExternal(link: string): Promise<OpenExternalResponse['result']> {\n return await request({ name: \"openExternal\", args: { link } as OpenExternalRequest['args'] });\n}\n\nexport async function getData<T>(key: string = \"default\"): Promise<GetDataResponse<T>['result']> {\n return await request({ name: \"getData\", args: { key } });\n}\n\n/**\n * Store data that can be retrieved later.\n * \n * @example\n * // Store with custom key\n * await setData(\"myKey\", { name: \"John\" });\n * \n * // Store with default key (equivalent to setData(\"default\", value))\n * await setData({ name: \"John\" });\n */\nexport async function setData<T>(key: string, value: T): Promise<SetDataResponse['result']>;\nexport async function setData<T>(value: T): Promise<SetDataResponse['result']>;\nexport async function setData<T>(keyOrValue: string | T, value?: T): Promise<SetDataResponse['result']> {\n if (value !== undefined) {\n return await request({ name: \"setData\", args: { key: keyOrValue as string, value } as SetDataRequest<T>['args'] });\n } else {\n return await request({ name: \"setData\", args: { key: \"default\", value: keyOrValue as T } as SetDataRequest<T>['args'] });\n }\n}\n\nexport async function getEncryptedData<T>(key: string): Promise<GetEncryptedDataResponse<T>['result']> {\n return await request({ name: \"getEncryptedData\", args: { key } });\n}\n\n/**\n * Store encrypted data that can be retrieved later.\n * \n * @example\n * // Store with custom key\n * await setEncryptedData(\"secretKey\", { token: \"abc123\" });\n * \n * // Store with default key (equivalent to setEncryptedData(\"default\", value))\n * await setEncryptedData({ token: \"abc123\" });\n */\nexport async function setEncryptedData<T>(key: string, value: T): Promise<SetEncryptedDataResponse['result']>;\nexport async function setEncryptedData<T>(value: T): Promise<SetEncryptedDataResponse['result']>;\nexport async function setEncryptedData<T>(keyOrValue: string | T, value?: T): Promise<SetEncryptedDataResponse['result']> {\n if (value !== undefined) {\n return await request({ name: \"setEncryptedData\", args: { key: keyOrValue as string, value } as SetEncryptedDataRequest<T>['args'] });\n } else {\n return await request({ name: \"setEncryptedData\", args: { key: \"default\", value: keyOrValue as T } as SetEncryptedDataRequest<T>['args'] });\n }\n}\n\n/** Clipboard interface. */\nexport const clipboard = {\n /** Write text to the Electron clipboard. */\n async writeText(text: string): Promise<void> {\n await request({\n name: \"clipboard.writeText\",\n args: { text },\n });\n },\n /** Read text from the Electron clipboard. */\n async readText(): Promise<string> {\n return await request({\n name: \"clipboard.readText\",\n args: void 0,\n });\n },\n // async write() {},\n // async read() {},\n};\n\nexport * from \"./commonTypes\";\nexport * from \"./requestTypes\";\nexport * from \"./responseTypes\";\nexport * from \"./notificationTypes\";\nexport * from \"./comms\";\n\n"],"names":[],"mappings":"SAAgB,YAAY,GAAA;AAC1B,IAAA,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC;AAC9B,IAAA,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC;AAE3B,IAAA,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC;AAChC,IAAA,GAAG,CAAC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AAE;AACvB,QAAA,OAAO,MAAM,OAAO,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,UAAoB,EAAE,KAAK,EAAwC,EAAE,CAAC;;SAC/H;QACL,OAAO,MAAM,OAAO,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,UAAe,EAAwC,EAAE,CAAC;;AAE9I;AAEA;AACa,MAAA,SAAS,GAAG;;IAEvB,MAAM,SAAS,CAAC,IAAY,EAAA;AAC1B,QAAA,MAAM,OAAO,CAAC;AACZ,YAAA,IAAI,EAAE,qBAAqB;YAC3B,IAAI,EAAE,EAAE,IAAI,EAAE;AACf,SAAA,CAAC;KACH;;AAED,IAAA,MAAM,QAAQ,GAAA;QACZ,OAAO,MAAM,OAAO,CAAC;AACnB,YAAA,IAAI,EAAE,oBAAoB;YAC1B,IAAI,EAAE,MAAM;AACb,SAAA,CAAC;KACH;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/utils.ts","../src/comms.ts","../src/index.ts"],"sourcesContent":["export function generateUUID() {\n const buf = new Uint8Array(16);\n crypto.getRandomValues(buf);\n\n buf[6] = (buf[6] & 0x0f) | 0x40; // version 4\n buf[8] = (buf[8] & 0x3f) | 0x80; // variant\n\n const hex = Array.from(buf, (b) => b.toString(16).padStart(2, \"0\")).join(\"\");\n\n return [\n hex.substring(0, 8),\n hex.substring(8, 12),\n hex.substring(12, 16),\n hex.substring(16, 20),\n hex.substring(20),\n ].join(\"-\");\n}\n","import { JsonValue } from \"./commonTypes\";\nimport {\n BroadcastNotification,\n PluginErrorNotification,\n ThemeChangedNotification,\n ViewLoadedNotification,\n WindowEventNotification,\n} from \"./notificationTypes\";\nimport type { PluginRequestPayload } from \"./requestTypes\";\nimport { generateUUID } from \"./utils\";\n\n// Define a custom import.meta interface for TypeScript\ndeclare global {\n interface ImportMeta {\n env: {\n MODE: string;\n };\n }\n}\n\nconst pendingRequests = new Map<\n string,\n {\n // The whole payload is kept just in case for debugging\n payload: PluginRequestPayload;\n resolve: (value: any) => void;\n reject: (reason?: any) => void;\n }\n>();\n\nlet debugComms = false;\n\nexport function setDebugComms(value: boolean) {\n debugComms = value;\n}\n\nwindow.addEventListener(\"message\", (event) => {\n const { id, name, args, result, error } = event.data || {};\n\n if (name) {\n if (debugComms) {\n const time = new Date().toLocaleTimeString(\"en-GB\");\n console.groupCollapsed(`${time} [NOTIFICATION] ${name}`);\n console.log(\"Args:\", args);\n console.groupEnd();\n }\n\n const handlers = notificationListeners.get(name);\n if (handlers) {\n handlers.forEach((handler) => handler(args));\n }\n }\n\n if (id && pendingRequests.has(id)) {\n const { resolve, reject, payload } = pendingRequests.get(id)!;\n pendingRequests.delete(id);\n\n if (debugComms) {\n const time = new Date().toLocaleTimeString(\"en-GB\");\n console.groupCollapsed(`${time} [RESPONSE] ${payload.name}`);\n console.log(\"Result:\", result);\n if (error) console.error(\"Error:\", error);\n console.groupEnd();\n }\n\n if (error) {\n reject(error);\n } else {\n resolve(result);\n }\n }\n});\n\nexport async function request(raw: any): Promise<any> {\n const payload = { id: generateUUID(), ...raw } as PluginRequestPayload;\n\n if (debugComms) {\n const time = new Date().toLocaleTimeString(\"en-GB\");\n console.groupCollapsed(`${time} [REQUEST] ${payload.name}`);\n console.log(\"id:\", payload.id);\n console.log(\"args:\", payload.args);\n console.log(\"payload:\", payload);\n console.groupEnd();\n }\n\n return new Promise<any>((resolve, reject) => {\n try {\n pendingRequests.set(payload.id, { payload: payload, resolve, reject });\n window.parent.postMessage(payload, \"*\");\n } catch (e) {\n reject(e);\n }\n });\n}\n\nexport function notify<Message extends JsonValue = JsonValue>(\n name: BroadcastNotification[\"name\"],\n args: BroadcastNotification<Message>[\"args\"],\n): void;\nexport function notify(\n name: PluginErrorNotification[\"name\"],\n args: PluginErrorNotification[\"args\"],\n): void;\nexport function notify(\n name: WindowEventNotification[\"name\"],\n args: WindowEventNotification[\"args\"],\n): void;\nexport function notify(name: string, args: any) {\n const payload = { name, args };\n if (debugComms) {\n const time = new Date().toLocaleTimeString(\"en-GB\");\n console.groupCollapsed(`${time} [NOTIFICATION] ${name}`);\n console.log(\"args:\", args);\n console.log(\"payload:\", payload);\n console.groupEnd();\n }\n window.parent.postMessage(payload, \"*\");\n}\n\nconst notificationListeners = new Map<string, ((args: any) => void)[]>();\n\nexport function addNotificationListener<Message extends JsonValue = JsonValue>(\n name: BroadcastNotification[\"name\"],\n handler: (args: BroadcastNotification<Message>[\"args\"]) => void,\n): void;\nexport function addNotificationListener(\n name: ViewLoadedNotification[\"name\"],\n handler: (args: ViewLoadedNotification[\"args\"]) => void,\n): void;\nexport function addNotificationListener(\n name: ThemeChangedNotification[\"name\"],\n handler: (args: ThemeChangedNotification[\"args\"]) => void,\n): void;\nexport function addNotificationListener(\n name: string,\n handler: (args: any) => void,\n) {\n if (!notificationListeners.get(name)) {\n notificationListeners.set(name, []);\n }\n notificationListeners.get(name)!.push(handler);\n}\n\nexport function removeNotificationListener(\n name: string,\n handler: (args: any) => void,\n) {\n const handlers = notificationListeners.get(name);\n if (handlers) {\n const index = handlers.indexOf(handler);\n if (index > -1) {\n handlers.splice(index, 1);\n }\n }\n}\n","import { request } from \"./comms\";\nimport type {\n GetTablesRequest,\n GetColumnsRequest,\n RunQueryRequest,\n ExpandTableResultRequest,\n SetTabTitleRequest,\n SetViewStateRequest,\n OpenExternalRequest,\n SetDataRequest,\n SetEncryptedDataRequest,\n OpenTabRequest,\n OpenQueryTabRequest,\n OpenTableTableTabRequest,\n OpenTableStructureTabRequest,\n GetTableKeysRequest,\n} from \"./requestTypes\";\nimport type {\n GetTablesResponse,\n GetColumnsResponse,\n GetConnectionInfoResponse,\n RunQueryResponse,\n ExpandTableResultResponse,\n SetTabTitleResponse,\n GetViewStateResponse,\n SetViewStateResponse,\n OpenExternalResponse,\n GetDataResponse,\n SetDataResponse,\n GetEncryptedDataResponse,\n SetEncryptedDataResponse,\n OpenTabResponse,\n GetTableKeysResponse,\n GetAppInfoResponse,\n CheckForUpdateResponse,\n} from \"./responseTypes\";\n\n/**\n * Get a list of tables from the current database.\n * @since Beekeeper Studio 5.3.0\n **/\nexport async function getTables(schema?: string): Promise<GetTablesResponse['result']> {\n return await request({ name: \"getTables\", args: { schema } as GetTablesRequest['args'] });\n}\n\n/**\n * Get a list of columns from a table.\n *\n * @since Beekeeper Studio 5.3.0\n **/\nexport async function getColumns(table: string, schema?: string): Promise<GetColumnsResponse['result']> {\n return await request({ name: \"getColumns\", args: { table, schema } as GetColumnsRequest['args'] });\n}\n\n/** @since Beekeeper Studio 5.4.0 */\nexport async function getTableKeys(table: string, schema?: string): Promise<GetTableKeysResponse['result']> {\n return await request({ name: \"getTableKeys\", args: { table, schema } as GetTableKeysRequest['args'] });\n}\n\n/**\n * Get information about the current database connection.\n *\n * @since Beekeeper Studio 5.3.0\n **/\nexport async function getConnectionInfo(): Promise<GetConnectionInfoResponse['result']> {\n return await request({ name: \"getConnectionInfo\", args: void 0 });\n}\n\n/** @since Beekeeper Studio 5.4.0 */\nexport async function getAppInfo(): Promise<GetAppInfoResponse['result']> {\n return await request({ name: \"getAppInfo\", args: void 0 });\n}\n\n/**\n * Check if plugin's update is available.\n *\n * @since Beekeeper Studio 5.4.0\n **/\nexport async function checkForUpdate(): Promise<CheckForUpdateResponse['result']> {\n return await request({ name: \"checkForUpdate\", args: void 0 });\n}\n\n/**\n * Execute a SQL query against the current database.\n *\n * WARNING: The query will be executed exactly as provided with no modification\n * or sanitization. Always validate and sanitize user input before including it\n * in queries to prevent unwanted actions.\n *\n * @since Beekeeper Studio 5.3.0\n **/\nexport async function runQuery(query: string): Promise<RunQueryResponse['result']> {\n return await request({ name: \"runQuery\", args: { query } as RunQueryRequest['args'] });\n}\n\n/**\n * Display query results in the bottom table panel (shell-type tabs only).\n *\n * @since Beekeeper Studio 5.3.0\n **/\nexport async function expandTableResult(results: any[]): Promise<ExpandTableResultResponse['result']> {\n return await request({ name: \"expandTableResult\", args: { results } as ExpandTableResultRequest['args'] });\n}\n\n/**\n * Set the title of the current plugin tab.\n *\n * @since Beekeeper Studio 5.3.0\n **/\nexport async function setTabTitle(title: string): Promise<SetTabTitleResponse['result']> {\n return await request({ name: \"setTabTitle\", args: { title } as SetTabTitleRequest['args'] });\n}\n\n/**\n * Get the current state of your view instance.\n *\n * @see {@link https://docs.beekeeperstudio.io/plugin_development/plugin-views/#view-state|View State}\n * @since Beekeeper Studio 5.3.0\n **/\nexport async function getViewState<T>(): Promise<GetViewStateResponse<T>['result']> {\n return await request({ name: \"getViewState\", args: void 0 });\n}\n\n/**\n * Set the state of your view instance.\n *\n * @see {@link https://docs.beekeeperstudio.io/plugin_development/plugin-views/#view-state|View State}\n * @since Beekeeper Studio 5.3.0\n **/\nexport async function setViewState<T>(state: T): Promise<SetViewStateResponse['result']> {\n return await request({ name: \"setViewState\", args: { state } as SetViewStateRequest<T>['args'] });\n}\n\n/** @since Beekeeper Studio 5.3.0 */\nexport async function openExternal(link: string): Promise<OpenExternalResponse['result']> {\n return await request({ name: \"openExternal\", args: { link } as OpenExternalRequest['args'] });\n}\n\n/** @since Beekeeper Studio 5.3.0 */\nexport async function getData<T>(key: string = \"default\"): Promise<GetDataResponse<T>['result']> {\n return await request({ name: \"getData\", args: { key } });\n}\n\n/**\n * Store data that can be retrieved later.\n * \n * @example\n * // Store with custom key\n * await setData(\"myKey\", { name: \"John\" });\n * \n * // Store with default key (equivalent to setData(\"default\", value))\n * await setData({ name: \"John\" });\n *\n * @since Beekeeper Studio 5.3.0\n */\nexport async function setData<T>(key: string, value: T): Promise<SetDataResponse['result']>;\nexport async function setData<T>(value: T): Promise<SetDataResponse['result']>;\nexport async function setData<T>(keyOrValue: string | T, value?: T): Promise<SetDataResponse['result']> {\n if (value !== undefined) {\n return await request({ name: \"setData\", args: { key: keyOrValue as string, value } as SetDataRequest<T>['args'] });\n } else {\n return await request({ name: \"setData\", args: { key: \"default\", value: keyOrValue as T } as SetDataRequest<T>['args'] });\n }\n}\n\n/** @since Beekeeper Studio 5.3.0 */\nexport async function getEncryptedData<T>(key: string): Promise<GetEncryptedDataResponse<T>['result']> {\n return await request({ name: \"getEncryptedData\", args: { key } });\n}\n\n/**\n * Store encrypted data that can be retrieved later.\n * \n * @example\n * // Store with custom key\n * await setEncryptedData(\"secretKey\", { token: \"abc123\" });\n * \n * // Store with default key (equivalent to setEncryptedData(\"default\", value))\n * await setEncryptedData({ token: \"abc123\" });\n *\n * @since Beekeeper Studio 5.3.0\n */\nexport async function setEncryptedData<T>(key: string, value: T): Promise<SetEncryptedDataResponse['result']>;\nexport async function setEncryptedData<T>(value: T): Promise<SetEncryptedDataResponse['result']>;\nexport async function setEncryptedData<T>(keyOrValue: string | T, value?: T): Promise<SetEncryptedDataResponse['result']> {\n if (value !== undefined) {\n return await request({ name: \"setEncryptedData\", args: { key: keyOrValue as string, value } as SetEncryptedDataRequest<T>['args'] });\n } else {\n return await request({ name: \"setEncryptedData\", args: { key: \"default\", value: keyOrValue as T } as SetEncryptedDataRequest<T>['args'] });\n }\n}\n\n/** @since Beekeeper Studio 5.4.0 */\nexport async function openTab(type: \"query\", args?: Omit<OpenQueryTabRequest['args'], 'type'>): Promise<OpenTabResponse>;\nexport async function openTab(type: \"tableTable\", args: Omit<OpenTableTableTabRequest['args'], 'type'>): Promise<OpenTabResponse>;\nexport async function openTab(type: \"tableStructure\", args: Omit<OpenTableStructureTabRequest['args'], 'type'>): Promise<OpenTabResponse>;\nexport async function openTab(type: OpenTabRequest['args']['type'], args?: Omit<OpenTabRequest['args'], 'type'>): Promise<OpenTabResponse> {\n return await request({ name: \"openTab\", args: { type, ...args } });\n}\n\n/** Clipboard interface. */\nexport const clipboard = {\n /** Write text to the Electron clipboard. */\n async writeText(text: string): Promise<void> {\n await request({\n name: \"clipboard.writeText\",\n args: { text },\n });\n },\n /** Read text from the Electron clipboard. */\n async readText(): Promise<string> {\n return await request({\n name: \"clipboard.readText\",\n args: void 0,\n });\n },\n // async write() {},\n // async read() {},\n};\n\nexport * from \"./commonTypes\";\nexport * from \"./requestTypes\";\nexport * from \"./responseTypes\";\nexport * from \"./notificationTypes\";\nexport * from \"./comms\";\n\n"],"names":[],"mappings":"SAAgB,YAAY,GAAA;AAC1B,IAAA,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC;AAC9B,IAAA,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC;AAE3B,IAAA,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC;AAChC,IAAA,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC;AAEhC,IAAA,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;IAE5E,OAAO;AACL,QAAA,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;AACnB,QAAA,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC;AACpB,QAAA,GAAG,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC;AACrB,QAAA,GAAG,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC;AACrB,QAAA,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;AAClB,KAAA,CAAC,IAAI,CAAC,GAAG,CAAC;AACb;;ACIA,MAAM,eAAe,GAAG,IAAI,GAAG,EAQ5B;AAEH,IAAI,UAAU,GAAG,KAAK;AAEhB,SAAU,aAAa,CAAC,KAAc,EAAA;IAC1C,UAAU,GAAG,KAAK;AACpB;AAEA,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,KA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AAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,UAAoB,EAAE,KAAK,EAAwC,EAAE,CAAC;;SAC/H;QACL,OAAO,MAAM,OAAO,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,UAAe,EAAwC,EAAE,CAAC;;AAE9I;AAMO,eAAe,OAAO,CAAC,IAAoC,EAAE,IAA2C,EAAA;AAC7G,IAAA,OAAO,MAAM,OAAO,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,EAAE,CAAC;AACpE;AAEA;AACa,MAAA,SAAS,GAAG;;IAEvB,MAAM,SAAS,CAAC,IAAY,EAAA;AAC1B,QAAA,MAAM,OAAO,CAAC;AACZ,YAAA,IAAI,EAAE,qBAAqB;YAC3B,IAAI,EAAE,EAAE,IAAI,EAAE;AACf,SAAA,CAAC;KACH;;AAED,IAAA,MAAM,QAAQ,GAAA;QACZ,OAAO,MAAM,OAAO,CAAC;AACnB,YAAA,IAAI,EAAE,oBAAoB;YAC1B,IAAI,EAAE,MAAM;AACb,SAAA,CAAC;KACH;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beekeeperstudio/plugin",
3
- "version": "1.3.1",
3
+ "version": "1.4.0-beta.2",
4
4
  "description": "A simple TypeScript wrapper to send messages from your Beekeeper Studio plugin to the main app.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",