@beekeeperstudio/plugin 1.4.0-beta.1 → 1.4.0-beta.3
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.
- package/dist/eventForwarder.js.map +1 -1
- package/dist/index.d.ts +217 -44
- package/dist/index.js +75 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -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,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"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,q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V,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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,8 +7,75 @@ 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;
|
|
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
|
+
};
|
|
33
|
+
type ActiveRange = {
|
|
34
|
+
rows: number[];
|
|
35
|
+
columns: string[];
|
|
36
|
+
value: JsonValue[][];
|
|
37
|
+
};
|
|
38
|
+
type CellMenuTarget = {
|
|
39
|
+
type: "cell";
|
|
40
|
+
row: number;
|
|
41
|
+
column: string;
|
|
42
|
+
value: JsonValue;
|
|
43
|
+
};
|
|
44
|
+
type ColumnMenuTarget = {
|
|
45
|
+
type: "column";
|
|
46
|
+
column: string;
|
|
47
|
+
rows: number[];
|
|
48
|
+
value: JsonValue[];
|
|
49
|
+
};
|
|
50
|
+
type RowMenuTarget = {
|
|
51
|
+
type: "row";
|
|
52
|
+
row: number;
|
|
53
|
+
columns: string[];
|
|
54
|
+
value: JsonValue[];
|
|
55
|
+
};
|
|
56
|
+
type CornerMenuTarget = {
|
|
57
|
+
type: "corner";
|
|
58
|
+
rows: number[];
|
|
59
|
+
columns: string[];
|
|
60
|
+
value: JsonValue[][];
|
|
61
|
+
};
|
|
62
|
+
type CellMenuParams = {
|
|
63
|
+
target: CellMenuTarget;
|
|
64
|
+
activeRange: ActiveRange;
|
|
65
|
+
};
|
|
66
|
+
type ColumnMenuParams = {
|
|
67
|
+
target: ColumnMenuTarget;
|
|
68
|
+
activeRange: ActiveRange;
|
|
69
|
+
};
|
|
70
|
+
type RowMenuParams = {
|
|
71
|
+
target: RowMenuTarget;
|
|
72
|
+
activeRange: ActiveRange;
|
|
73
|
+
};
|
|
74
|
+
type CornerMenuParams = {
|
|
75
|
+
target: CornerMenuTarget;
|
|
76
|
+
activeRange: ActiveRange;
|
|
77
|
+
};
|
|
78
|
+
type LoadViewParams = CornerMenuParams | RowMenuParams | ColumnMenuParams | CellMenuParams;
|
|
12
79
|
|
|
13
80
|
interface BaseRequest {
|
|
14
81
|
id: string;
|
|
@@ -26,14 +93,21 @@ interface GetColumnsRequest extends BaseRequest {
|
|
|
26
93
|
schema?: string;
|
|
27
94
|
};
|
|
28
95
|
}
|
|
96
|
+
type GetTableKeysRequest = BaseRequest & {
|
|
97
|
+
name: "getTableKeys";
|
|
98
|
+
args: {
|
|
99
|
+
table: string;
|
|
100
|
+
schema?: string;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
type GetAppInfoRequest = BaseRequest & {
|
|
104
|
+
name: "getAppInfo";
|
|
105
|
+
args: void;
|
|
106
|
+
};
|
|
29
107
|
interface GetConnectionInfoRequest extends BaseRequest {
|
|
30
108
|
name: "getConnectionInfo";
|
|
31
109
|
args: void;
|
|
32
110
|
}
|
|
33
|
-
interface GetAllTabsRequest extends BaseRequest {
|
|
34
|
-
name: "getAllTabs";
|
|
35
|
-
args: void;
|
|
36
|
-
}
|
|
37
111
|
interface RunQueryRequest extends BaseRequest {
|
|
38
112
|
name: "runQuery";
|
|
39
113
|
args: {
|
|
@@ -108,7 +182,7 @@ type OpenQueryTabRequest = BaseRequest & {
|
|
|
108
182
|
name: "openTab";
|
|
109
183
|
args: {
|
|
110
184
|
type: "query";
|
|
111
|
-
query
|
|
185
|
+
query?: string;
|
|
112
186
|
};
|
|
113
187
|
};
|
|
114
188
|
type OpenTableTableTabRequest = BaseRequest & {
|
|
@@ -117,6 +191,8 @@ type OpenTableTableTabRequest = BaseRequest & {
|
|
|
117
191
|
type: "tableTable";
|
|
118
192
|
table: string;
|
|
119
193
|
schema?: string;
|
|
194
|
+
filters?: TableFilter$1[];
|
|
195
|
+
database?: string;
|
|
120
196
|
};
|
|
121
197
|
};
|
|
122
198
|
type OpenTableStructureTabRequest = BaseRequest & {
|
|
@@ -125,12 +201,57 @@ type OpenTableStructureTabRequest = BaseRequest & {
|
|
|
125
201
|
type: "tableStructure";
|
|
126
202
|
table: string;
|
|
127
203
|
schema?: string;
|
|
204
|
+
database?: string;
|
|
128
205
|
};
|
|
129
206
|
};
|
|
207
|
+
type CheckForUpdateRequest = BaseRequest & {
|
|
208
|
+
name: "checkForUpdate";
|
|
209
|
+
args: void;
|
|
210
|
+
};
|
|
130
211
|
type OpenTabRequest = OpenQueryTabRequest | OpenTableTableTabRequest | OpenTableStructureTabRequest;
|
|
131
|
-
type PluginRequestData = GetTablesRequest | GetColumnsRequest |
|
|
212
|
+
type PluginRequestData = GetTablesRequest | GetColumnsRequest | GetTableKeysRequest | GetAppInfoRequest | GetConnectionInfoRequest | RunQueryRequest | ExpandTableResultRequest | SetTabTitleRequest | GetViewStateRequest | SetViewStateRequest<unknown> | OpenExternalRequest | GetDataRequest | SetDataRequest<unknown> | GetEncryptedDataRequest | SetEncryptedDataRequest<unknown> | ClipboardWriteTextRequest | ClipboardReadTextRequest | OpenTabRequest | CheckForUpdateRequest;
|
|
132
213
|
type PluginRequestPayload = PluginRequestData;
|
|
133
214
|
|
|
215
|
+
type AppTheme = {
|
|
216
|
+
palette: Record<string, string>;
|
|
217
|
+
cssString: string;
|
|
218
|
+
type: ThemeType;
|
|
219
|
+
};
|
|
220
|
+
type ThemeChangedNotification = {
|
|
221
|
+
name: "themeChanged";
|
|
222
|
+
args: AppTheme;
|
|
223
|
+
};
|
|
224
|
+
type WindowEventNotification = {
|
|
225
|
+
name: "windowEvent";
|
|
226
|
+
args: {
|
|
227
|
+
eventType: string;
|
|
228
|
+
eventClass: WindowEventClass;
|
|
229
|
+
eventInitOptions: WindowEventInits;
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
type PluginErrorNotification = {
|
|
233
|
+
name: "pluginError";
|
|
234
|
+
args: {
|
|
235
|
+
name?: string;
|
|
236
|
+
message?: string;
|
|
237
|
+
stack?: string;
|
|
238
|
+
};
|
|
239
|
+
};
|
|
240
|
+
type BroadcastNotification<Message extends JsonValue = JsonValue> = {
|
|
241
|
+
name: "broadcast";
|
|
242
|
+
args: {
|
|
243
|
+
message: Message;
|
|
244
|
+
};
|
|
245
|
+
};
|
|
246
|
+
type ViewLoadedNotification = {
|
|
247
|
+
name: "viewLoaded";
|
|
248
|
+
args: {
|
|
249
|
+
command: string;
|
|
250
|
+
params?: CellMenuParams | ColumnMenuParams | RowMenuParams | CornerMenuParams;
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
type PluginNotificationData = ThemeChangedNotification | WindowEventNotification | PluginErrorNotification | ViewLoadedNotification | BroadcastNotification;
|
|
254
|
+
|
|
134
255
|
type TabType = string;
|
|
135
256
|
type TableFilter = any;
|
|
136
257
|
type TableOrView = any;
|
|
@@ -150,17 +271,26 @@ interface GetColumnsResponse extends BaseResponse {
|
|
|
150
271
|
type: string;
|
|
151
272
|
}[];
|
|
152
273
|
}
|
|
274
|
+
type GetTableKeysResponse = BaseResponse & {
|
|
275
|
+
result: TableKey[];
|
|
276
|
+
};
|
|
153
277
|
interface GetConnectionInfoResponse extends BaseResponse {
|
|
154
278
|
result: {
|
|
279
|
+
/** @deprecated Use `databaseType` instead */
|
|
155
280
|
connectionType: string;
|
|
281
|
+
databaseType: string;
|
|
282
|
+
databaseTypeDisplayName: string;
|
|
156
283
|
databaseName: string;
|
|
157
284
|
defaultSchema?: string;
|
|
158
285
|
readOnlyMode: boolean;
|
|
159
286
|
};
|
|
160
287
|
}
|
|
161
|
-
|
|
162
|
-
result:
|
|
163
|
-
|
|
288
|
+
type GetAppInfoResponse = BaseResponse & {
|
|
289
|
+
result: {
|
|
290
|
+
version: string;
|
|
291
|
+
theme: AppTheme;
|
|
292
|
+
};
|
|
293
|
+
};
|
|
164
294
|
interface RunQueryResponse extends BaseResponse {
|
|
165
295
|
result: {
|
|
166
296
|
results: QueryResult[];
|
|
@@ -203,10 +333,12 @@ interface ClipboardReadTextResponse extends BaseResponse {
|
|
|
203
333
|
interface OpenTabResponse extends BaseResponse {
|
|
204
334
|
result: void;
|
|
205
335
|
}
|
|
206
|
-
|
|
336
|
+
interface CheckForUpdateResponse extends BaseResponse {
|
|
337
|
+
result: boolean;
|
|
338
|
+
}
|
|
339
|
+
type PluginResponseData = GetTablesResponse | GetColumnsResponse | GetTableKeysResponse | GetConnectionInfoResponse | RunQueryResponse | ExpandTableResultResponse | SetTabTitleResponse | GetViewStateResponse<unknown> | SetViewStateResponse | OpenExternalResponse | GetDataResponse<unknown> | SetDataResponse | GetEncryptedDataResponse<unknown> | SetEncryptedDataResponse | ClipboardWriteTextResponse | ClipboardReadTextResponse | OpenTabResponse | CheckForUpdateResponse;
|
|
207
340
|
type PluginResponsePayload = PluginResponseData;
|
|
208
|
-
type TabResponse =
|
|
209
|
-
type Tab = BaseTabResponse | QueryTabResponse | TableTabResponse;
|
|
341
|
+
type TabResponse = BaseTabResponse | QueryTabResponse | TableTabResponse;
|
|
210
342
|
interface BaseTabResponse {
|
|
211
343
|
type: TabType;
|
|
212
344
|
id: number;
|
|
@@ -228,32 +360,6 @@ interface TableTabResponse extends BaseTabResponse {
|
|
|
228
360
|
};
|
|
229
361
|
}
|
|
230
362
|
|
|
231
|
-
interface ThemeChangedNotification {
|
|
232
|
-
name: "themeChanged";
|
|
233
|
-
args: {
|
|
234
|
-
palette: Record<string, string>;
|
|
235
|
-
cssString: string;
|
|
236
|
-
type: ThemeType;
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
interface WindowEventNotification {
|
|
240
|
-
name: "windowEvent";
|
|
241
|
-
args: {
|
|
242
|
-
eventType: string;
|
|
243
|
-
eventClass: WindowEventClass;
|
|
244
|
-
eventInitOptions: WindowEventInits;
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
interface PluginErrorNotification {
|
|
248
|
-
name: "pluginError";
|
|
249
|
-
args: {
|
|
250
|
-
name?: string;
|
|
251
|
-
message?: string;
|
|
252
|
-
stack?: string;
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
type PluginNotificationData = ThemeChangedNotification | WindowEventNotification | PluginErrorNotification;
|
|
256
|
-
|
|
257
363
|
declare global {
|
|
258
364
|
interface ImportMeta {
|
|
259
365
|
env: {
|
|
@@ -263,19 +369,80 @@ declare global {
|
|
|
263
369
|
}
|
|
264
370
|
declare function setDebugComms(value: boolean): void;
|
|
265
371
|
declare function request(raw: any): Promise<any>;
|
|
266
|
-
declare function notify(name:
|
|
267
|
-
declare function
|
|
372
|
+
declare function notify<Message extends JsonValue = JsonValue>(name: BroadcastNotification["name"], args: BroadcastNotification<Message>["args"]): void;
|
|
373
|
+
declare function notify(name: PluginErrorNotification["name"], args: PluginErrorNotification["args"]): void;
|
|
374
|
+
declare function notify(name: WindowEventNotification["name"], args: WindowEventNotification["args"]): void;
|
|
375
|
+
declare function addNotificationListener<Message extends JsonValue = JsonValue>(name: BroadcastNotification["name"], handler: (args: BroadcastNotification<Message>["args"]) => void): void;
|
|
376
|
+
declare function addNotificationListener(name: ViewLoadedNotification["name"], handler: (args: ViewLoadedNotification["args"]) => void): void;
|
|
377
|
+
declare function addNotificationListener(name: ThemeChangedNotification["name"], handler: (args: ThemeChangedNotification["args"]) => void): void;
|
|
378
|
+
declare function removeNotificationListener(name: string, handler: (args: any) => void): void;
|
|
268
379
|
|
|
380
|
+
/**
|
|
381
|
+
* Get a list of tables from the current database.
|
|
382
|
+
* @since Beekeeper Studio 5.3.0
|
|
383
|
+
**/
|
|
269
384
|
declare function getTables(schema?: string): Promise<GetTablesResponse['result']>;
|
|
385
|
+
/**
|
|
386
|
+
* Get a list of columns from a table.
|
|
387
|
+
*
|
|
388
|
+
* @since Beekeeper Studio 5.3.0
|
|
389
|
+
**/
|
|
270
390
|
declare function getColumns(table: string, schema?: string): Promise<GetColumnsResponse['result']>;
|
|
391
|
+
/** @since Beekeeper Studio 5.4.0 */
|
|
392
|
+
declare function getTableKeys(table: string, schema?: string): Promise<GetTableKeysResponse['result']>;
|
|
393
|
+
/**
|
|
394
|
+
* Get information about the current database connection.
|
|
395
|
+
*
|
|
396
|
+
* @since Beekeeper Studio 5.3.0
|
|
397
|
+
**/
|
|
271
398
|
declare function getConnectionInfo(): Promise<GetConnectionInfoResponse['result']>;
|
|
272
|
-
|
|
399
|
+
/** @since Beekeeper Studio 5.4.0 */
|
|
400
|
+
declare function getAppInfo(): Promise<GetAppInfoResponse['result']>;
|
|
401
|
+
/**
|
|
402
|
+
* Check if plugin's update is available.
|
|
403
|
+
*
|
|
404
|
+
* @since Beekeeper Studio 5.4.0
|
|
405
|
+
**/
|
|
406
|
+
declare function checkForUpdate(): Promise<CheckForUpdateResponse['result']>;
|
|
407
|
+
/**
|
|
408
|
+
* Execute a SQL query against the current database.
|
|
409
|
+
*
|
|
410
|
+
* WARNING: The query will be executed exactly as provided with no modification
|
|
411
|
+
* or sanitization. Always validate and sanitize user input before including it
|
|
412
|
+
* in queries to prevent unwanted actions.
|
|
413
|
+
*
|
|
414
|
+
* @since Beekeeper Studio 5.3.0
|
|
415
|
+
**/
|
|
273
416
|
declare function runQuery(query: string): Promise<RunQueryResponse['result']>;
|
|
417
|
+
/**
|
|
418
|
+
* Display query results in the bottom table panel (shell-type tabs only).
|
|
419
|
+
*
|
|
420
|
+
* @since Beekeeper Studio 5.3.0
|
|
421
|
+
**/
|
|
274
422
|
declare function expandTableResult(results: any[]): Promise<ExpandTableResultResponse['result']>;
|
|
423
|
+
/**
|
|
424
|
+
* Set the title of the current plugin tab.
|
|
425
|
+
*
|
|
426
|
+
* @since Beekeeper Studio 5.3.0
|
|
427
|
+
**/
|
|
275
428
|
declare function setTabTitle(title: string): Promise<SetTabTitleResponse['result']>;
|
|
429
|
+
/**
|
|
430
|
+
* Get the current state of your view instance.
|
|
431
|
+
*
|
|
432
|
+
* @see {@link https://docs.beekeeperstudio.io/plugin_development/plugin-views/#view-state|View State}
|
|
433
|
+
* @since Beekeeper Studio 5.3.0
|
|
434
|
+
**/
|
|
276
435
|
declare function getViewState<T>(): Promise<GetViewStateResponse<T>['result']>;
|
|
436
|
+
/**
|
|
437
|
+
* Set the state of your view instance.
|
|
438
|
+
*
|
|
439
|
+
* @see {@link https://docs.beekeeperstudio.io/plugin_development/plugin-views/#view-state|View State}
|
|
440
|
+
* @since Beekeeper Studio 5.3.0
|
|
441
|
+
**/
|
|
277
442
|
declare function setViewState<T>(state: T): Promise<SetViewStateResponse['result']>;
|
|
443
|
+
/** @since Beekeeper Studio 5.3.0 */
|
|
278
444
|
declare function openExternal(link: string): Promise<OpenExternalResponse['result']>;
|
|
445
|
+
/** @since Beekeeper Studio 5.3.0 */
|
|
279
446
|
declare function getData<T>(key?: string): Promise<GetDataResponse<T>['result']>;
|
|
280
447
|
/**
|
|
281
448
|
* Store data that can be retrieved later.
|
|
@@ -286,9 +453,12 @@ declare function getData<T>(key?: string): Promise<GetDataResponse<T>['result']>
|
|
|
286
453
|
*
|
|
287
454
|
* // Store with default key (equivalent to setData("default", value))
|
|
288
455
|
* await setData({ name: "John" });
|
|
456
|
+
*
|
|
457
|
+
* @since Beekeeper Studio 5.3.0
|
|
289
458
|
*/
|
|
290
459
|
declare function setData<T>(key: string, value: T): Promise<SetDataResponse['result']>;
|
|
291
460
|
declare function setData<T>(value: T): Promise<SetDataResponse['result']>;
|
|
461
|
+
/** @since Beekeeper Studio 5.3.0 */
|
|
292
462
|
declare function getEncryptedData<T>(key: string): Promise<GetEncryptedDataResponse<T>['result']>;
|
|
293
463
|
/**
|
|
294
464
|
* Store encrypted data that can be retrieved later.
|
|
@@ -299,10 +469,13 @@ declare function getEncryptedData<T>(key: string): Promise<GetEncryptedDataRespo
|
|
|
299
469
|
*
|
|
300
470
|
* // Store with default key (equivalent to setEncryptedData("default", value))
|
|
301
471
|
* await setEncryptedData({ token: "abc123" });
|
|
472
|
+
*
|
|
473
|
+
* @since Beekeeper Studio 5.3.0
|
|
302
474
|
*/
|
|
303
475
|
declare function setEncryptedData<T>(key: string, value: T): Promise<SetEncryptedDataResponse['result']>;
|
|
304
476
|
declare function setEncryptedData<T>(value: T): Promise<SetEncryptedDataResponse['result']>;
|
|
305
|
-
|
|
477
|
+
/** @since Beekeeper Studio 5.4.0 */
|
|
478
|
+
declare function openTab(type: "query", args?: Omit<OpenQueryTabRequest['args'], 'type'>): Promise<OpenTabResponse>;
|
|
306
479
|
declare function openTab(type: "tableTable", args: Omit<OpenTableTableTabRequest['args'], 'type'>): Promise<OpenTabResponse>;
|
|
307
480
|
declare function openTab(type: "tableStructure", args: Omit<OpenTableStructureTabRequest['args'], 'type'>): Promise<OpenTabResponse>;
|
|
308
481
|
/** Clipboard interface. */
|
|
@@ -313,5 +486,5 @@ declare const clipboard: {
|
|
|
313
486
|
readText(): Promise<string>;
|
|
314
487
|
};
|
|
315
488
|
|
|
316
|
-
export { addNotificationListener, clipboard, expandTableResult,
|
|
317
|
-
export type { ClipboardReadTextRequest, ClipboardReadTextResponse, ClipboardWriteTextRequest, ClipboardWriteTextResponse, ExpandTableResultRequest, ExpandTableResultResponse,
|
|
489
|
+
export { addNotificationListener, checkForUpdate, clipboard, expandTableResult, getAppInfo, getColumns, getConnectionInfo, getData, getEncryptedData, getTableKeys, getTables, getViewState, notify, openExternal, openTab, removeNotificationListener, request, runQuery, setData, setDebugComms, setEncryptedData, setTabTitle, setViewState };
|
|
490
|
+
export type { ActiveRange, AppTheme, BroadcastNotification, CellMenuParams, CellMenuTarget, CheckForUpdateRequest, CheckForUpdateResponse, ClipboardReadTextRequest, ClipboardReadTextResponse, ClipboardWriteTextRequest, ClipboardWriteTextResponse, ColumnMenuParams, ColumnMenuTarget, CornerMenuParams, CornerMenuTarget, ExpandTableResultRequest, ExpandTableResultResponse, GetAppInfoRequest, GetAppInfoResponse, GetColumnsRequest, GetColumnsResponse, GetConnectionInfoRequest, GetConnectionInfoResponse, GetDataRequest, GetDataResponse, GetEncryptedDataRequest, GetEncryptedDataResponse, GetTableKeysRequest, GetTableKeysResponse, GetTablesRequest, GetTablesResponse, GetViewStateRequest, GetViewStateResponse, JsonValue, LoadViewParams, OpenExternalRequest, OpenExternalResponse, OpenQueryTabRequest, OpenTabRequest, OpenTabResponse, OpenTableStructureTabRequest, OpenTableTableTabRequest, PluginErrorNotification, PluginNotificationData, PluginRequestData, PluginRequestPayload, PluginResponseData, PluginResponsePayload, QueryResult, RowMenuParams, RowMenuTarget, 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
|
-
|
|
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
|
-
|
|
103
|
-
|
|
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
|
}
|
|
@@ -165,5 +235,5 @@ const clipboard = {
|
|
|
165
235
|
// async read() {},
|
|
166
236
|
};
|
|
167
237
|
|
|
168
|
-
export { addNotificationListener, clipboard, expandTableResult,
|
|
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 };
|
|
169
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 OpenTabRequest,\n OpenQueryTabRequest,\n OpenTableTableTabRequest,\n OpenTableStructureTabRequest,\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 OpenTabResponse,\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\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\";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AE,KAAK,EAAE,UAAe,EAA+B,EAAE,CAAC;;AAE5H;AAEO,eAAe,gBAAgB,CAAI,GAAW,EAAA;AACnD,IAAA,OAAO,MAAM,OAAO,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC;AACnE;AAcO,eAAe,gBAAgB,CAAI,UAAsB,EAAE,KAAS,EAAA;AACzE,IAAA,IAAI,KAAK,KAAK,SAAS,EAAE;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;AAKO,eAAe,OAAO,CAAC,IAAoC,EAAE,IAA0C,EAAA;AAC5G,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;;;;;;;"}
|
|
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,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b,SAAA,CAAC;KACH;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beekeeperstudio/plugin",
|
|
3
|
-
"version": "1.4.0-beta.
|
|
3
|
+
"version": "1.4.0-beta.3",
|
|
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",
|