@beekeeperstudio/plugin 1.5.0 → 1.6.0
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 +51 -2
- package/dist/index.js +33 -1
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +35 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventForwarder.js","sources":["../src/index.ts","../src/eventForwarder.ts"],"sourcesContent":["import type { AppInfo, AppTheme, Column, ConnectionInfo, JsonValue, OpenQueryTabOptions, OpenTableStructureTabOptions, OpenTableTableTabOptions, PluginErrorObject, PluginViewContext, PrimaryKey, QueryResult, RequestFileSaveOptions, RunQueryResult, Table, TableIndex, TableKey, WindowEventObject } from \"./types\";\nimport type { RequestMap } from \"./internal\";\n\nexport * from \"./types\";\n\n/**\n * Get a list of schemas from the current database.\n *\n * @since Beekeeper Studio 5.5.0\n **/\nexport async function getSchemas(): Promise<string[]> {\n return await request({ name: \"getSchemas\", args: void 0 });\n}\n\n/**\n * Get a list of tables from the current database.\n *\n * @since Beekeeper Studio 5.3.0\n **/\nexport async function getTables(schema?: string): Promise<Table[]> {\n return await request({ name: \"getTables\", args: { schema } });\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<Column[]> {\n return await request({ name: \"getColumns\", args: { table, schema } });\n}\n\n/** @since Beekeeper Studio 5.4.0 */\nexport async function getTableKeys(table: string, schema?: string): Promise<TableKey[]> {\n return await request({ name: \"getTableKeys\", args: { table, schema } });\n}\n\n/** @since Beekeeper Studio 5.5.0 */\nexport async function getTableIndexes(table: string, schema?: string): Promise<TableIndex[]> {\n return await request({ name: \"getTableIndexes\", args: { table, schema } });\n}\n\nexport async function getPrimaryKeys(table: string, schema?: string): Promise<PrimaryKey[]> {\n return await request({ name: \"getPrimaryKeys\", args: { table, schema } });\n}\n\nexport async function getIncomingKeys(table: string, schema?: string): Promise<TableKey[]> {\n return await request({ name: \"getIncomingKeys\", args: { table, schema } });\n}\n\nexport async function getOutgoingKeys(table: string, schema?: string): Promise<TableKey[]> {\n return await request({ name: \"getOutgoingKeys\", args: { table, schema } });\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<ConnectionInfo> {\n return await request({ name: \"getConnectionInfo\", args: void 0 });\n}\n\n/** @since Beekeeper Studio 5.4.0 */\nexport async function getAppInfo(): Promise<AppInfo> {\n return await request({ name: \"getAppInfo\", args: void 0 });\n}\n\n/**\n * Get the version of Beekeeper Studio\n * @since Beekeeper Studio 5.3.0\n **/\nexport async function getAppVersion(): Promise<\"5.3\" | (string & { __brand?: never })> {\n try {\n const appInfo = await getAppInfo();\n return appInfo.version;\n } catch (e) {\n if (e instanceof Error && e.message.includes(\"Unknown request\")) {\n return \"5.3\";\n }\n throw e;\n }\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<boolean> {\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<RunQueryResult> {\n return await request({ name: \"runQuery\", args: { query } });\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: QueryResult[]): Promise<void> {\n return await request({ name: \"expandTableResult\", args: { results } });\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<void> {\n return await request({ name: \"setTabTitle\", args: { title } });\n}\n\n/**\n * Get the current view context.\n *\n * A view context describes how this plugin view was opened and what data is\n * available for it. It always includes the static `command` from your\n * `manifest.json`, and may also include dynamic `params` depending on where\n * the menu was invoked.\n *\n * @since Beekeeper Studio 5.4.0\n **/\nexport async function getViewContext(): Promise<PluginViewContext> {\n return await request({ name: \"getViewContext\", args: void 0 });\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 = unknown>(): Promise<T> {\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 = unknown>(state: T): Promise<void> {\n return await request({ name: \"setViewState\", args: { state } });\n}\n\n/** @since Beekeeper Studio 5.3.0 */\nexport async function openExternal(link: string): Promise<void> {\n return await request({ name: \"openExternal\", args: { link } });\n}\n\n/** @since Beekeeper Studio 5.3.0 */\nexport async function getData<T = unknown>(key: string = \"default\"): Promise<T> {\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 = unknown>(key: string, value: T): Promise<void>;\nexport async function setData<T = unknown>(value: T): Promise<void>;\nexport async function setData<T = unknown>(keyOrValue: string | T, value?: T): Promise<void> {\n if (value !== undefined) {\n return await request({ name: \"setData\", args: { key: keyOrValue as string, value } });\n } else {\n return await request({ name: \"setData\", args: { key: \"default\", value: keyOrValue as T } });\n }\n}\n\n/** @since Beekeeper Studio 5.3.0 */\nexport async function getEncryptedData<T>(key: string): Promise<T> {\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 = unknown>(key: string, value: T): Promise<void>;\nexport async function setEncryptedData<T = unknown>(value: T): Promise<void>;\nexport async function setEncryptedData<T = unknown>(keyOrValue: string | T, value?: T): Promise<void> {\n if (value !== undefined) {\n return await request({ name: \"setEncryptedData\", args: { key: keyOrValue as string, value } });\n } else {\n return await request({ name: \"setEncryptedData\", args: { key: \"default\", value: keyOrValue as T } });\n }\n}\n\n/** @since Beekeeper Studio 5.4.0 */\nexport async function openTab(type: \"query\", options?: OpenQueryTabOptions): Promise<void>;\nexport async function openTab(type: \"tableTable\", options: OpenTableTableTabOptions): Promise<void>;\nexport async function openTab(type: \"tableStructure\", options: OpenTableStructureTabOptions): Promise<void>;\nexport async function openTab(\n type: \"query\" | \"tableTable\" | \"tableStructure\",\n options?:\n OpenQueryTabOptions\n | OpenTableTableTabOptions\n | OpenTableStructureTabOptions\n): Promise<void> {\n return await request({ name: \"openTab\", args: { type, ...options } });\n}\n\nexport async function requestFileSave(options: RequestFileSaveOptions): Promise<void> {\n return await request({ name: \"requestFileSave\", args: options });\n}\n\nexport async function showStatusBarUI(): Promise<void> {\n return await request({ name: \"toggleStatusBarUI\", args: { force: true } });\n}\n\nexport async function hideStatusBarUI(): Promise<void> {\n return await request({ name: \"toggleStatusBarUI\", args: { force: false } });\n}\n\nexport async function toggleStatusBarUI(): Promise<void> {\n return await request({ name: \"toggleStatusBarUI\", args: void 0 });\n}\n\n/** @since Beekeeper Studio 5.4.0 */\nexport const broadcast = {\n post<T extends JsonValue = JsonValue>(message: T): void {\n return notify(\"broadcast\", { message });\n },\n on<T extends JsonValue = JsonValue>(handler: (message: T) => void): void {\n addNotificationListener<T>(\"broadcast\", (params) => {\n handler(params.message);\n });\n },\n}\n\n/** @since Beekeeper Studio 5.3.0 */\nexport const log = {\n error(err: string | Error): void {\n if (typeof err === \"string\") {\n return notify(\"pluginError\", {\n name: \"Error\",\n message: err,\n stack: undefined,\n });\n }\n return notify(\"pluginError\", {\n name: err.name || \"Error\",\n message: err.message,\n stack: err.stack,\n });\n },\n}\n\n/** Clipboard interface. */\nexport const clipboard = {\n /** Write text to the Electron clipboard.\n * @since Beekeeper Studio 5.3.0 */\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 * @since Beekeeper Studio 5.3.0 */\n async readText(): Promise<string> {\n return await request({\n name: \"clipboard.readText\",\n args: void 0,\n });\n },\n /** @param data - Base64 encoded image data.\n * @since Beekeeper Studio 5.5.0 */\n async writeImage(data: string) {\n await request({\n name: \"clipboard.writeImage\",\n args: { data },\n });\n },\n // async write() {},\n // async read() {},\n};\n\nlet debugComms = false;\n\nexport function setDebugComms(enabled: boolean) {\n debugComms = enabled;\n}\n\nexport function notify<Message extends JsonValue = JsonValue>(\n name: \"broadcast\",\n args: { message: Message; }\n): void;\nexport function notify(name: \"pluginError\", args: PluginErrorObject): void;\nexport function notify(name: \"windowEvent\", args: WindowEventObject): 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\nexport function addNotificationListener(\n name: \"tablesChanged\",\n handler: () => void,\n): void;\nexport function addNotificationListener<Message extends JsonValue = JsonValue>(\n name: \"broadcast\",\n handler: (args: { message: Message; }) => void,\n): void;\nexport function addNotificationListener(\n name: \"themeChanged\",\n handler: (args: AppTheme) => 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: \"tablesChanged\",\n handler: (args: any) => void\n): void;\nexport function removeNotificationListener<Message extends JsonValue = JsonValue>(\n name: \"broadcast\",\n handler: (args: any) => void\n): void;\nexport function removeNotificationListener(\n name: \"themeChanged\",\n handler: (args: any) => void\n): void;\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\nconst pendingRequests = new Map<\n string,\n {\n // The whole payload is kept just in case for debugging\n payload: any;\n resolve: (value: any) => void;\n reject: (reason?: any) => void;\n }\n>();\n\nexport async function request<T extends keyof RequestMap>(\n raw: { name: T; args: RequestMap[T][\"args\"] }\n): Promise<RequestMap[T][\"return\"]> {\n const payload = { id: generateUUID(), ...raw };\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\nconst notificationListeners = new Map<string, ((args: any) => void)[]>();\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\nfunction 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\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 \".\";\nimport { WindowEventInits, WindowEventClass } from \"./types\";\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":"AA+TgB,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;AAiDA,MAAM,eAAe,GAAG,IAAI,GAAG,EAQ5B;AA0BH,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAAmC;AAExE,MAAM,CAA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,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/index.ts","../src/eventForwarder.ts"],"sourcesContent":["import type { AppInfo, AppTheme, Column, ConfirmOptions, ConnectionInfo, JsonValue, OpenQueryTabOptions, OpenTableStructureTabOptions, OpenTableTableTabOptions, PluginErrorObject, PluginViewContext, PrimaryKey, QueryResult, RequestFileSaveOptions, RunQueryResult, Table, TableIndex, TableKey, WindowEventObject } from \"./types\";\nimport type { RequestMap } from \"./internal\";\n\nexport * from \"./types\";\n\n/**\n * Get a list of schemas from the current database.\n *\n * @since Beekeeper Studio 5.5.0\n **/\nexport async function getSchemas(): Promise<string[]> {\n return await request({ name: \"getSchemas\", args: void 0 });\n}\n\n/**\n * Get a list of tables from the current database.\n *\n * @since Beekeeper Studio 5.3.0\n **/\nexport async function getTables(schema?: string): Promise<Table[]> {\n return await request({ name: \"getTables\", args: { schema } });\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<Column[]> {\n return await request({ name: \"getColumns\", args: { table, schema } });\n}\n\n/** @since Beekeeper Studio 5.4.0 */\nexport async function getTableKeys(table: string, schema?: string): Promise<TableKey[]> {\n return await request({ name: \"getTableKeys\", args: { table, schema } });\n}\n\n/** @since Beekeeper Studio 5.5.0 */\nexport async function getTableIndexes(table: string, schema?: string): Promise<TableIndex[]> {\n return await request({ name: \"getTableIndexes\", args: { table, schema } });\n}\n\nexport async function getPrimaryKeys(table: string, schema?: string): Promise<PrimaryKey[]> {\n return await request({ name: \"getPrimaryKeys\", args: { table, schema } });\n}\n\nexport async function getIncomingKeys(table: string, schema?: string): Promise<TableKey[]> {\n return await request({ name: \"getIncomingKeys\", args: { table, schema } });\n}\n\nexport async function getOutgoingKeys(table: string, schema?: string): Promise<TableKey[]> {\n return await request({ name: \"getOutgoingKeys\", args: { table, schema } });\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<ConnectionInfo> {\n return await request({ name: \"getConnectionInfo\", args: void 0 });\n}\n\n/** @since Beekeeper Studio 5.4.0 */\nexport async function getAppInfo(): Promise<AppInfo> {\n return await request({ name: \"getAppInfo\", args: void 0 });\n}\n\n/**\n * Get the version of Beekeeper Studio\n * @since Beekeeper Studio 5.3.0\n **/\nexport async function getAppVersion(): Promise<\"5.3\" | (string & { __brand?: never })> {\n try {\n const appInfo = await getAppInfo();\n return appInfo.version;\n } catch (e) {\n if (e instanceof Error && e.message.includes(\"Unknown request\")) {\n return \"5.3\";\n }\n throw e;\n }\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<boolean> {\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<RunQueryResult> {\n return await request({ name: \"runQuery\", args: { query } });\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: QueryResult[]): Promise<void> {\n return await request({ name: \"expandTableResult\", args: { results } });\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<void> {\n return await request({ name: \"setTabTitle\", args: { title } });\n}\n\n/**\n * Get the current view context.\n *\n * A view context describes how this plugin view was opened and what data is\n * available for it. It always includes the static `command` from your\n * `manifest.json`, and may also include dynamic `params` depending on where\n * the menu was invoked.\n *\n * @since Beekeeper Studio 5.4.0\n **/\nexport async function getViewContext(): Promise<PluginViewContext> {\n return await request({ name: \"getViewContext\", args: void 0 });\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 = unknown>(): Promise<T> {\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 = unknown>(state: T): Promise<void> {\n return await request({ name: \"setViewState\", args: { state } });\n}\n\n/** @since Beekeeper Studio 5.3.0 */\nexport async function openExternal(link: string): Promise<void> {\n return await request({ name: \"openExternal\", args: { link } });\n}\n\n/** @since Beekeeper Studio 5.3.0 */\nexport async function getData<T = unknown>(key: string = \"default\"): Promise<T> {\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 = unknown>(key: string, value: T): Promise<void>;\nexport async function setData<T = unknown>(value: T): Promise<void>;\nexport async function setData<T = unknown>(keyOrValue: string | T, value?: T): Promise<void> {\n if (value !== undefined) {\n return await request({ name: \"setData\", args: { key: keyOrValue as string, value } });\n } else {\n return await request({ name: \"setData\", args: { key: \"default\", value: keyOrValue as T } });\n }\n}\n\n/** @since Beekeeper Studio 5.3.0 */\nexport async function getEncryptedData<T>(key: string): Promise<T> {\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 = unknown>(key: string, value: T): Promise<void>;\nexport async function setEncryptedData<T = unknown>(value: T): Promise<void>;\nexport async function setEncryptedData<T = unknown>(keyOrValue: string | T, value?: T): Promise<void> {\n if (value !== undefined) {\n return await request({ name: \"setEncryptedData\", args: { key: keyOrValue as string, value } });\n } else {\n return await request({ name: \"setEncryptedData\", args: { key: \"default\", value: keyOrValue as T } });\n }\n}\n\n/** @since Beekeeper Studio 5.4.0 */\nexport async function openTab(type: \"query\", options?: OpenQueryTabOptions): Promise<void>;\nexport async function openTab(type: \"tableTable\", options: OpenTableTableTabOptions): Promise<void>;\nexport async function openTab(type: \"tableStructure\", options: OpenTableStructureTabOptions): Promise<void>;\nexport async function openTab(\n type: \"query\" | \"tableTable\" | \"tableStructure\",\n options?:\n OpenQueryTabOptions\n | OpenTableTableTabOptions\n | OpenTableStructureTabOptions\n): Promise<void> {\n return await request({ name: \"openTab\", args: { type, ...options } });\n}\n\nexport async function requestFileSave(options: RequestFileSaveOptions): Promise<void> {\n return await request({ name: \"requestFileSave\", args: options });\n}\n\nexport async function showStatusBarUI(): Promise<void> {\n return await request({ name: \"toggleStatusBarUI\", args: { force: true } });\n}\n\nexport async function hideStatusBarUI(): Promise<void> {\n return await request({ name: \"toggleStatusBarUI\", args: { force: false } });\n}\n\n/** @since Beekeeper Studio 5.5.? */\nexport async function toggleStatusBarUI(): Promise<void> {\n return await request({ name: \"toggleStatusBarUI\", args: void 0 });\n}\n\n/** @since Beekeeper Studio 5.5.? */\nexport async function confirm(title?: string, message?: string, options?: ConfirmOptions): Promise<boolean> {\n return await request({ name: \"confirm\", args: { title, message, options } });\n}\n\n/** @since Beekeeper Studio 5.4.0 */\nexport const broadcast = {\n post<T extends JsonValue = JsonValue>(message: T): void {\n return notify(\"broadcast\", { message });\n },\n on<T extends JsonValue = JsonValue>(handler: (message: T) => void): void {\n addNotificationListener<T>(\"broadcast\", (params) => {\n handler(params.message);\n });\n },\n}\n\n/** @since Beekeeper Studio 5.3.0 */\nexport const log = {\n error(err: string | Error): void {\n if (typeof err === \"string\") {\n return notify(\"pluginError\", {\n name: \"Error\",\n message: err,\n stack: undefined,\n });\n }\n return notify(\"pluginError\", {\n name: err.name || \"Error\",\n message: err.message,\n stack: err.stack,\n });\n },\n}\n\n/** Clipboard interface. */\nexport const clipboard = {\n /** Write text to the Electron clipboard.\n * @since Beekeeper Studio 5.3.0 */\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 * @since Beekeeper Studio 5.3.0 */\n async readText(): Promise<string> {\n return await request({\n name: \"clipboard.readText\",\n args: void 0,\n });\n },\n /** @param data - Base64 encoded image data.\n * @since Beekeeper Studio 5.5.0 */\n async writeImage(data: string) {\n await request({\n name: \"clipboard.writeImage\",\n args: { data },\n });\n },\n // async write() {},\n // async read() {},\n};\n\n/** @since Beekeeper Studio 5.5.? */\nexport const noty = {\n async success(message: string): Promise<void> {\n return await request({\n name: \"noty.success\",\n args: { message },\n });\n },\n async info(message: string): Promise<void> {\n return await request({\n name: \"noty.info\",\n args: { message },\n });\n },\n async warning(message: string): Promise<void> {\n return await request({\n name: \"noty.warning\",\n args: { message },\n });\n },\n async error(message: string): Promise<void> {\n return await request({\n name: \"noty.error\",\n args: { message },\n });\n },\n}\n\nlet debugComms = false;\n\nexport function setDebugComms(enabled: boolean) {\n debugComms = enabled;\n}\n\nexport function notify<Message extends JsonValue = JsonValue>(\n name: \"broadcast\",\n args: { message: Message; }\n): void;\nexport function notify(name: \"pluginError\", args: PluginErrorObject): void;\nexport function notify(name: \"windowEvent\", args: WindowEventObject): 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\nexport function addNotificationListener(\n name: \"tablesChanged\",\n handler: () => void,\n): void;\nexport function addNotificationListener<Message extends JsonValue = JsonValue>(\n name: \"broadcast\",\n handler: (args: { message: Message; }) => void,\n): void;\nexport function addNotificationListener(\n name: \"themeChanged\",\n handler: (args: AppTheme) => 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: \"tablesChanged\",\n handler: (args: any) => void\n): void;\nexport function removeNotificationListener<Message extends JsonValue = JsonValue>(\n name: \"broadcast\",\n handler: (args: any) => void\n): void;\nexport function removeNotificationListener(\n name: \"themeChanged\",\n handler: (args: any) => void\n): void;\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\nconst pendingRequests = new Map<\n string,\n {\n // The whole payload is kept just in case for debugging\n payload: any;\n resolve: (value: any) => void;\n reject: (reason?: any) => void;\n }\n>();\n\nexport async function request<T extends keyof RequestMap>(\n raw: { name: T; args: RequestMap[T][\"args\"] }\n): Promise<RequestMap[T][\"return\"]> {\n const payload = { id: generateUUID(), ...raw };\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\nconst notificationListeners = new Map<string, ((args: any) => void)[]>();\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\nfunction 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\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 \".\";\nimport { WindowEventInits, WindowEventClass } from \"./types\";\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":"AAiWgB,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;AAiDA,MAAM,eAAe,GAAG,IAAI,GAAG,EAQ5B;AA0BH,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAAmC;AAExE,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,KAAK,KAAI;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xB,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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -172,6 +172,10 @@ type WindowEventObject = {
|
|
|
172
172
|
eventClass: WindowEventClass;
|
|
173
173
|
eventInitOptions: WindowEventInits;
|
|
174
174
|
};
|
|
175
|
+
type ConfirmOptions = {
|
|
176
|
+
confirmLabel?: string;
|
|
177
|
+
cancelLabel?: string;
|
|
178
|
+
};
|
|
175
179
|
|
|
176
180
|
type RequestMap = {
|
|
177
181
|
getSchemas: {
|
|
@@ -322,6 +326,17 @@ type RequestMap = {
|
|
|
322
326
|
};
|
|
323
327
|
return: void;
|
|
324
328
|
};
|
|
329
|
+
confirm: {
|
|
330
|
+
args: {
|
|
331
|
+
title?: string;
|
|
332
|
+
message?: string;
|
|
333
|
+
options?: {
|
|
334
|
+
confirmLabel?: string;
|
|
335
|
+
cancelLabel?: string;
|
|
336
|
+
};
|
|
337
|
+
};
|
|
338
|
+
return: boolean;
|
|
339
|
+
};
|
|
325
340
|
"clipboard.writeText": {
|
|
326
341
|
args: {
|
|
327
342
|
text: string;
|
|
@@ -338,6 +353,30 @@ type RequestMap = {
|
|
|
338
353
|
args: void;
|
|
339
354
|
return: string;
|
|
340
355
|
};
|
|
356
|
+
"noty.success": {
|
|
357
|
+
args: {
|
|
358
|
+
message: string;
|
|
359
|
+
};
|
|
360
|
+
return: void;
|
|
361
|
+
};
|
|
362
|
+
"noty.error": {
|
|
363
|
+
args: {
|
|
364
|
+
message: string;
|
|
365
|
+
};
|
|
366
|
+
return: void;
|
|
367
|
+
};
|
|
368
|
+
"noty.info": {
|
|
369
|
+
args: {
|
|
370
|
+
message: string;
|
|
371
|
+
};
|
|
372
|
+
return: void;
|
|
373
|
+
};
|
|
374
|
+
"noty.warning": {
|
|
375
|
+
args: {
|
|
376
|
+
message: string;
|
|
377
|
+
};
|
|
378
|
+
return: void;
|
|
379
|
+
};
|
|
341
380
|
};
|
|
342
381
|
|
|
343
382
|
/**
|
|
@@ -474,7 +513,10 @@ declare function openTab(type: "tableStructure", options: OpenTableStructureTabO
|
|
|
474
513
|
declare function requestFileSave(options: RequestFileSaveOptions): Promise<void>;
|
|
475
514
|
declare function showStatusBarUI(): Promise<void>;
|
|
476
515
|
declare function hideStatusBarUI(): Promise<void>;
|
|
516
|
+
/** @since Beekeeper Studio 5.5.? */
|
|
477
517
|
declare function toggleStatusBarUI(): Promise<void>;
|
|
518
|
+
/** @since Beekeeper Studio 5.5.? */
|
|
519
|
+
declare function confirm(title?: string, message?: string, options?: ConfirmOptions): Promise<boolean>;
|
|
478
520
|
/** @since Beekeeper Studio 5.4.0 */
|
|
479
521
|
declare const broadcast: {
|
|
480
522
|
post<T extends JsonValue = JsonValue>(message: T): void;
|
|
@@ -496,6 +538,13 @@ declare const clipboard: {
|
|
|
496
538
|
* @since Beekeeper Studio 5.5.0 */
|
|
497
539
|
writeImage(data: string): Promise<void>;
|
|
498
540
|
};
|
|
541
|
+
/** @since Beekeeper Studio 5.5.? */
|
|
542
|
+
declare const noty: {
|
|
543
|
+
success(message: string): Promise<void>;
|
|
544
|
+
info(message: string): Promise<void>;
|
|
545
|
+
warning(message: string): Promise<void>;
|
|
546
|
+
error(message: string): Promise<void>;
|
|
547
|
+
};
|
|
499
548
|
declare function setDebugComms(enabled: boolean): void;
|
|
500
549
|
declare function notify<Message extends JsonValue = JsonValue>(name: "broadcast", args: {
|
|
501
550
|
message: Message;
|
|
@@ -515,5 +564,5 @@ declare function request<T extends keyof RequestMap>(raw: {
|
|
|
515
564
|
args: RequestMap[T]["args"];
|
|
516
565
|
}): Promise<RequestMap[T]["return"]>;
|
|
517
566
|
|
|
518
|
-
export { addNotificationListener, broadcast, checkForUpdate, clipboard, expandTableResult, getAppInfo, getAppVersion, getColumns, getConnectionInfo, getData, getEncryptedData, getIncomingKeys, getOutgoingKeys, getPrimaryKeys, getSchemas, getTableIndexes, getTableKeys, getTables, getViewContext, getViewState, hideStatusBarUI, log, notify, openExternal, openTab, removeNotificationListener, request, requestFileSave, runQuery, setData, setDebugComms, setEncryptedData, setTabTitle, setViewState, showStatusBarUI, toggleStatusBarUI };
|
|
519
|
-
export type { ActiveRange, AppInfo, AppTheme, CellMenuParams, CellMenuTarget, Column, ColumnMenuParams, ColumnMenuTarget, ConnectionInfo, CornerMenuParams, CornerMenuTarget, DatabaseType, IndexColumn, JsonValue, LoadViewParams, OpenQueryTabOptions, OpenTableStructureTabOptions, OpenTableTableTabOptions, PluginErrorObject, PluginViewContext, PrimaryKey, QueryResult, RequestFileSaveOptions, RowMenuParams, RowMenuTarget, RunQueryResult, Table, TableFilter, TableIndex, TableKey, ThemeType, WindowEventClass, WindowEventInits, WindowEventObject };
|
|
567
|
+
export { addNotificationListener, broadcast, checkForUpdate, clipboard, confirm, expandTableResult, getAppInfo, getAppVersion, getColumns, getConnectionInfo, getData, getEncryptedData, getIncomingKeys, getOutgoingKeys, getPrimaryKeys, getSchemas, getTableIndexes, getTableKeys, getTables, getViewContext, getViewState, hideStatusBarUI, log, notify, noty, openExternal, openTab, removeNotificationListener, request, requestFileSave, runQuery, setData, setDebugComms, setEncryptedData, setTabTitle, setViewState, showStatusBarUI, toggleStatusBarUI };
|
|
568
|
+
export type { ActiveRange, AppInfo, AppTheme, CellMenuParams, CellMenuTarget, Column, ColumnMenuParams, ColumnMenuTarget, ConfirmOptions, ConnectionInfo, CornerMenuParams, CornerMenuTarget, DatabaseType, IndexColumn, JsonValue, LoadViewParams, OpenQueryTabOptions, OpenTableStructureTabOptions, OpenTableTableTabOptions, PluginErrorObject, PluginViewContext, PrimaryKey, QueryResult, RequestFileSaveOptions, RowMenuParams, RowMenuTarget, RunQueryResult, Table, TableFilter, TableIndex, TableKey, ThemeType, WindowEventClass, WindowEventInits, WindowEventObject };
|
package/dist/index.js
CHANGED
|
@@ -174,9 +174,14 @@ async function showStatusBarUI() {
|
|
|
174
174
|
async function hideStatusBarUI() {
|
|
175
175
|
return await request({ name: "toggleStatusBarUI", args: { force: false } });
|
|
176
176
|
}
|
|
177
|
+
/** @since Beekeeper Studio 5.5.? */
|
|
177
178
|
async function toggleStatusBarUI() {
|
|
178
179
|
return await request({ name: "toggleStatusBarUI", args: void 0 });
|
|
179
180
|
}
|
|
181
|
+
/** @since Beekeeper Studio 5.5.? */
|
|
182
|
+
async function confirm(title, message, options) {
|
|
183
|
+
return await request({ name: "confirm", args: { title, message, options } });
|
|
184
|
+
}
|
|
180
185
|
/** @since Beekeeper Studio 5.4.0 */
|
|
181
186
|
const broadcast = {
|
|
182
187
|
post(message) {
|
|
@@ -234,6 +239,33 @@ const clipboard = {
|
|
|
234
239
|
// async write() {},
|
|
235
240
|
// async read() {},
|
|
236
241
|
};
|
|
242
|
+
/** @since Beekeeper Studio 5.5.? */
|
|
243
|
+
const noty = {
|
|
244
|
+
async success(message) {
|
|
245
|
+
return await request({
|
|
246
|
+
name: "noty.success",
|
|
247
|
+
args: { message },
|
|
248
|
+
});
|
|
249
|
+
},
|
|
250
|
+
async info(message) {
|
|
251
|
+
return await request({
|
|
252
|
+
name: "noty.info",
|
|
253
|
+
args: { message },
|
|
254
|
+
});
|
|
255
|
+
},
|
|
256
|
+
async warning(message) {
|
|
257
|
+
return await request({
|
|
258
|
+
name: "noty.warning",
|
|
259
|
+
args: { message },
|
|
260
|
+
});
|
|
261
|
+
},
|
|
262
|
+
async error(message) {
|
|
263
|
+
return await request({
|
|
264
|
+
name: "noty.error",
|
|
265
|
+
args: { message },
|
|
266
|
+
});
|
|
267
|
+
},
|
|
268
|
+
};
|
|
237
269
|
let debugComms = false;
|
|
238
270
|
function setDebugComms(enabled) {
|
|
239
271
|
debugComms = enabled;
|
|
@@ -334,5 +366,5 @@ function generateUUID() {
|
|
|
334
366
|
].join("-");
|
|
335
367
|
}
|
|
336
368
|
|
|
337
|
-
export { addNotificationListener, broadcast, checkForUpdate, clipboard, expandTableResult, getAppInfo, getAppVersion, getColumns, getConnectionInfo, getData, getEncryptedData, getIncomingKeys, getOutgoingKeys, getPrimaryKeys, getSchemas, getTableIndexes, getTableKeys, getTables, getViewContext, getViewState, hideStatusBarUI, log, notify, openExternal, openTab, removeNotificationListener, request, requestFileSave, runQuery, setData, setDebugComms, setEncryptedData, setTabTitle, setViewState, showStatusBarUI, toggleStatusBarUI };
|
|
369
|
+
export { addNotificationListener, broadcast, checkForUpdate, clipboard, confirm, expandTableResult, getAppInfo, getAppVersion, getColumns, getConnectionInfo, getData, getEncryptedData, getIncomingKeys, getOutgoingKeys, getPrimaryKeys, getSchemas, getTableIndexes, getTableKeys, getTables, getViewContext, getViewState, hideStatusBarUI, log, notify, noty, openExternal, openTab, removeNotificationListener, request, requestFileSave, runQuery, setData, setDebugComms, setEncryptedData, setTabTitle, setViewState, showStatusBarUI, toggleStatusBarUI };
|
|
338
370
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import type { AppInfo, AppTheme, Column, ConnectionInfo, JsonValue, OpenQueryTabOptions, OpenTableStructureTabOptions, OpenTableTableTabOptions, PluginErrorObject, PluginViewContext, PrimaryKey, QueryResult, RequestFileSaveOptions, RunQueryResult, Table, TableIndex, TableKey, WindowEventObject } from \"./types\";\nimport type { RequestMap } from \"./internal\";\n\nexport * from \"./types\";\n\n/**\n * Get a list of schemas from the current database.\n *\n * @since Beekeeper Studio 5.5.0\n **/\nexport async function getSchemas(): Promise<string[]> {\n return await request({ name: \"getSchemas\", args: void 0 });\n}\n\n/**\n * Get a list of tables from the current database.\n *\n * @since Beekeeper Studio 5.3.0\n **/\nexport async function getTables(schema?: string): Promise<Table[]> {\n return await request({ name: \"getTables\", args: { schema } });\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<Column[]> {\n return await request({ name: \"getColumns\", args: { table, schema } });\n}\n\n/** @since Beekeeper Studio 5.4.0 */\nexport async function getTableKeys(table: string, schema?: string): Promise<TableKey[]> {\n return await request({ name: \"getTableKeys\", args: { table, schema } });\n}\n\n/** @since Beekeeper Studio 5.5.0 */\nexport async function getTableIndexes(table: string, schema?: string): Promise<TableIndex[]> {\n return await request({ name: \"getTableIndexes\", args: { table, schema } });\n}\n\nexport async function getPrimaryKeys(table: string, schema?: string): Promise<PrimaryKey[]> {\n return await request({ name: \"getPrimaryKeys\", args: { table, schema } });\n}\n\nexport async function getIncomingKeys(table: string, schema?: string): Promise<TableKey[]> {\n return await request({ name: \"getIncomingKeys\", args: { table, schema } });\n}\n\nexport async function getOutgoingKeys(table: string, schema?: string): Promise<TableKey[]> {\n return await request({ name: \"getOutgoingKeys\", args: { table, schema } });\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<ConnectionInfo> {\n return await request({ name: \"getConnectionInfo\", args: void 0 });\n}\n\n/** @since Beekeeper Studio 5.4.0 */\nexport async function getAppInfo(): Promise<AppInfo> {\n return await request({ name: \"getAppInfo\", args: void 0 });\n}\n\n/**\n * Get the version of Beekeeper Studio\n * @since Beekeeper Studio 5.3.0\n **/\nexport async function getAppVersion(): Promise<\"5.3\" | (string & { __brand?: never })> {\n try {\n const appInfo = await getAppInfo();\n return appInfo.version;\n } catch (e) {\n if (e instanceof Error && e.message.includes(\"Unknown request\")) {\n return \"5.3\";\n }\n throw e;\n }\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<boolean> {\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<RunQueryResult> {\n return await request({ name: \"runQuery\", args: { query } });\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: QueryResult[]): Promise<void> {\n return await request({ name: \"expandTableResult\", args: { results } });\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<void> {\n return await request({ name: \"setTabTitle\", args: { title } });\n}\n\n/**\n * Get the current view context.\n *\n * A view context describes how this plugin view was opened and what data is\n * available for it. It always includes the static `command` from your\n * `manifest.json`, and may also include dynamic `params` depending on where\n * the menu was invoked.\n *\n * @since Beekeeper Studio 5.4.0\n **/\nexport async function getViewContext(): Promise<PluginViewContext> {\n return await request({ name: \"getViewContext\", args: void 0 });\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 = unknown>(): Promise<T> {\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 = unknown>(state: T): Promise<void> {\n return await request({ name: \"setViewState\", args: { state } });\n}\n\n/** @since Beekeeper Studio 5.3.0 */\nexport async function openExternal(link: string): Promise<void> {\n return await request({ name: \"openExternal\", args: { link } });\n}\n\n/** @since Beekeeper Studio 5.3.0 */\nexport async function getData<T = unknown>(key: string = \"default\"): Promise<T> {\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 = unknown>(key: string, value: T): Promise<void>;\nexport async function setData<T = unknown>(value: T): Promise<void>;\nexport async function setData<T = unknown>(keyOrValue: string | T, value?: T): Promise<void> {\n if (value !== undefined) {\n return await request({ name: \"setData\", args: { key: keyOrValue as string, value } });\n } else {\n return await request({ name: \"setData\", args: { key: \"default\", value: keyOrValue as T } });\n }\n}\n\n/** @since Beekeeper Studio 5.3.0 */\nexport async function getEncryptedData<T>(key: string): Promise<T> {\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 = unknown>(key: string, value: T): Promise<void>;\nexport async function setEncryptedData<T = unknown>(value: T): Promise<void>;\nexport async function setEncryptedData<T = unknown>(keyOrValue: string | T, value?: T): Promise<void> {\n if (value !== undefined) {\n return await request({ name: \"setEncryptedData\", args: { key: keyOrValue as string, value } });\n } else {\n return await request({ name: \"setEncryptedData\", args: { key: \"default\", value: keyOrValue as T } });\n }\n}\n\n/** @since Beekeeper Studio 5.4.0 */\nexport async function openTab(type: \"query\", options?: OpenQueryTabOptions): Promise<void>;\nexport async function openTab(type: \"tableTable\", options: OpenTableTableTabOptions): Promise<void>;\nexport async function openTab(type: \"tableStructure\", options: OpenTableStructureTabOptions): Promise<void>;\nexport async function openTab(\n type: \"query\" | \"tableTable\" | \"tableStructure\",\n options?:\n OpenQueryTabOptions\n | OpenTableTableTabOptions\n | OpenTableStructureTabOptions\n): Promise<void> {\n return await request({ name: \"openTab\", args: { type, ...options } });\n}\n\nexport async function requestFileSave(options: RequestFileSaveOptions): Promise<void> {\n return await request({ name: \"requestFileSave\", args: options });\n}\n\nexport async function showStatusBarUI(): Promise<void> {\n return await request({ name: \"toggleStatusBarUI\", args: { force: true } });\n}\n\nexport async function hideStatusBarUI(): Promise<void> {\n return await request({ name: \"toggleStatusBarUI\", args: { force: false } });\n}\n\nexport async function toggleStatusBarUI(): Promise<void> {\n return await request({ name: \"toggleStatusBarUI\", args: void 0 });\n}\n\n/** @since Beekeeper Studio 5.4.0 */\nexport const broadcast = {\n post<T extends JsonValue = JsonValue>(message: T): void {\n return notify(\"broadcast\", { message });\n },\n on<T extends JsonValue = JsonValue>(handler: (message: T) => void): void {\n addNotificationListener<T>(\"broadcast\", (params) => {\n handler(params.message);\n });\n },\n}\n\n/** @since Beekeeper Studio 5.3.0 */\nexport const log = {\n error(err: string | Error): void {\n if (typeof err === \"string\") {\n return notify(\"pluginError\", {\n name: \"Error\",\n message: err,\n stack: undefined,\n });\n }\n return notify(\"pluginError\", {\n name: err.name || \"Error\",\n message: err.message,\n stack: err.stack,\n });\n },\n}\n\n/** Clipboard interface. */\nexport const clipboard = {\n /** Write text to the Electron clipboard.\n * @since Beekeeper Studio 5.3.0 */\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 * @since Beekeeper Studio 5.3.0 */\n async readText(): Promise<string> {\n return await request({\n name: \"clipboard.readText\",\n args: void 0,\n });\n },\n /** @param data - Base64 encoded image data.\n * @since Beekeeper Studio 5.5.0 */\n async writeImage(data: string) {\n await request({\n name: \"clipboard.writeImage\",\n args: { data },\n });\n },\n // async write() {},\n // async read() {},\n};\n\nlet debugComms = false;\n\nexport function setDebugComms(enabled: boolean) {\n debugComms = enabled;\n}\n\nexport function notify<Message extends JsonValue = JsonValue>(\n name: \"broadcast\",\n args: { message: Message; }\n): void;\nexport function notify(name: \"pluginError\", args: PluginErrorObject): void;\nexport function notify(name: \"windowEvent\", args: WindowEventObject): 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\nexport function addNotificationListener(\n name: \"tablesChanged\",\n handler: () => void,\n): void;\nexport function addNotificationListener<Message extends JsonValue = JsonValue>(\n name: \"broadcast\",\n handler: (args: { message: Message; }) => void,\n): void;\nexport function addNotificationListener(\n name: \"themeChanged\",\n handler: (args: AppTheme) => 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: \"tablesChanged\",\n handler: (args: any) => void\n): void;\nexport function removeNotificationListener<Message extends JsonValue = JsonValue>(\n name: \"broadcast\",\n handler: (args: any) => void\n): void;\nexport function removeNotificationListener(\n name: \"themeChanged\",\n handler: (args: any) => void\n): void;\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\nconst pendingRequests = new Map<\n string,\n {\n // The whole payload is kept just in case for debugging\n payload: any;\n resolve: (value: any) => void;\n reject: (reason?: any) => void;\n }\n>();\n\nexport async function request<T extends keyof RequestMap>(\n raw: { name: T; args: RequestMap[T][\"args\"] }\n): Promise<RequestMap[T][\"return\"]> {\n const payload = { id: generateUUID(), ...raw };\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\nconst notificationListeners = new Map<string, ((args: any) => void)[]>();\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\nfunction 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\n"],"names":[],"mappings":"AAKA;;;;AAII;AACG,eAAe,UAAU,GAAA;AAC9B,IAAA,OAAO,MAAM,OAAO,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC5D;AAEA;;;;AAII;AACG,eAAe,SAAS,CAAC,MAAe,EAAA;AAC7C,IAAA,OAAO,MAAM,OAAO,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC;AAC/D;AAEA;;;;AAII;AACG,eAAe,UAAU,CAAC,KAAa,EAAE,MAAe,EAAA;AAC7D,IAAA,OAAO,MAAM,OAAO,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC;AACvE;AAEA;AACO,eAAe,YAAY,CAAC,KAAa,EAAE,MAAe,EAAA;AAC/D,IAAA,OAAO,MAAM,OAAO,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC;AACzE;AAEA;AACO,eAAe,eAAe,CAAC,KAAa,EAAE,MAAe,EAAA;AAClE,IAAA,OAAO,MAAM,OAAO,CAAC,EAAE,IAAI,EAAE,iBA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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;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import type { AppInfo, AppTheme, Column, ConfirmOptions, ConnectionInfo, JsonValue, OpenQueryTabOptions, OpenTableStructureTabOptions, OpenTableTableTabOptions, PluginErrorObject, PluginViewContext, PrimaryKey, QueryResult, RequestFileSaveOptions, RunQueryResult, Table, TableIndex, TableKey, WindowEventObject } from \"./types\";\nimport type { RequestMap } from \"./internal\";\n\nexport * from \"./types\";\n\n/**\n * Get a list of schemas from the current database.\n *\n * @since Beekeeper Studio 5.5.0\n **/\nexport async function getSchemas(): Promise<string[]> {\n return await request({ name: \"getSchemas\", args: void 0 });\n}\n\n/**\n * Get a list of tables from the current database.\n *\n * @since Beekeeper Studio 5.3.0\n **/\nexport async function getTables(schema?: string): Promise<Table[]> {\n return await request({ name: \"getTables\", args: { schema } });\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<Column[]> {\n return await request({ name: \"getColumns\", args: { table, schema } });\n}\n\n/** @since Beekeeper Studio 5.4.0 */\nexport async function getTableKeys(table: string, schema?: string): Promise<TableKey[]> {\n return await request({ name: \"getTableKeys\", args: { table, schema } });\n}\n\n/** @since Beekeeper Studio 5.5.0 */\nexport async function getTableIndexes(table: string, schema?: string): Promise<TableIndex[]> {\n return await request({ name: \"getTableIndexes\", args: { table, schema } });\n}\n\nexport async function getPrimaryKeys(table: string, schema?: string): Promise<PrimaryKey[]> {\n return await request({ name: \"getPrimaryKeys\", args: { table, schema } });\n}\n\nexport async function getIncomingKeys(table: string, schema?: string): Promise<TableKey[]> {\n return await request({ name: \"getIncomingKeys\", args: { table, schema } });\n}\n\nexport async function getOutgoingKeys(table: string, schema?: string): Promise<TableKey[]> {\n return await request({ name: \"getOutgoingKeys\", args: { table, schema } });\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<ConnectionInfo> {\n return await request({ name: \"getConnectionInfo\", args: void 0 });\n}\n\n/** @since Beekeeper Studio 5.4.0 */\nexport async function getAppInfo(): Promise<AppInfo> {\n return await request({ name: \"getAppInfo\", args: void 0 });\n}\n\n/**\n * Get the version of Beekeeper Studio\n * @since Beekeeper Studio 5.3.0\n **/\nexport async function getAppVersion(): Promise<\"5.3\" | (string & { __brand?: never })> {\n try {\n const appInfo = await getAppInfo();\n return appInfo.version;\n } catch (e) {\n if (e instanceof Error && e.message.includes(\"Unknown request\")) {\n return \"5.3\";\n }\n throw e;\n }\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<boolean> {\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<RunQueryResult> {\n return await request({ name: \"runQuery\", args: { query } });\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: QueryResult[]): Promise<void> {\n return await request({ name: \"expandTableResult\", args: { results } });\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<void> {\n return await request({ name: \"setTabTitle\", args: { title } });\n}\n\n/**\n * Get the current view context.\n *\n * A view context describes how this plugin view was opened and what data is\n * available for it. It always includes the static `command` from your\n * `manifest.json`, and may also include dynamic `params` depending on where\n * the menu was invoked.\n *\n * @since Beekeeper Studio 5.4.0\n **/\nexport async function getViewContext(): Promise<PluginViewContext> {\n return await request({ name: \"getViewContext\", args: void 0 });\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 = unknown>(): Promise<T> {\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 = unknown>(state: T): Promise<void> {\n return await request({ name: \"setViewState\", args: { state } });\n}\n\n/** @since Beekeeper Studio 5.3.0 */\nexport async function openExternal(link: string): Promise<void> {\n return await request({ name: \"openExternal\", args: { link } });\n}\n\n/** @since Beekeeper Studio 5.3.0 */\nexport async function getData<T = unknown>(key: string = \"default\"): Promise<T> {\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 = unknown>(key: string, value: T): Promise<void>;\nexport async function setData<T = unknown>(value: T): Promise<void>;\nexport async function setData<T = unknown>(keyOrValue: string | T, value?: T): Promise<void> {\n if (value !== undefined) {\n return await request({ name: \"setData\", args: { key: keyOrValue as string, value } });\n } else {\n return await request({ name: \"setData\", args: { key: \"default\", value: keyOrValue as T } });\n }\n}\n\n/** @since Beekeeper Studio 5.3.0 */\nexport async function getEncryptedData<T>(key: string): Promise<T> {\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 = unknown>(key: string, value: T): Promise<void>;\nexport async function setEncryptedData<T = unknown>(value: T): Promise<void>;\nexport async function setEncryptedData<T = unknown>(keyOrValue: string | T, value?: T): Promise<void> {\n if (value !== undefined) {\n return await request({ name: \"setEncryptedData\", args: { key: keyOrValue as string, value } });\n } else {\n return await request({ name: \"setEncryptedData\", args: { key: \"default\", value: keyOrValue as T } });\n }\n}\n\n/** @since Beekeeper Studio 5.4.0 */\nexport async function openTab(type: \"query\", options?: OpenQueryTabOptions): Promise<void>;\nexport async function openTab(type: \"tableTable\", options: OpenTableTableTabOptions): Promise<void>;\nexport async function openTab(type: \"tableStructure\", options: OpenTableStructureTabOptions): Promise<void>;\nexport async function openTab(\n type: \"query\" | \"tableTable\" | \"tableStructure\",\n options?:\n OpenQueryTabOptions\n | OpenTableTableTabOptions\n | OpenTableStructureTabOptions\n): Promise<void> {\n return await request({ name: \"openTab\", args: { type, ...options } });\n}\n\nexport async function requestFileSave(options: RequestFileSaveOptions): Promise<void> {\n return await request({ name: \"requestFileSave\", args: options });\n}\n\nexport async function showStatusBarUI(): Promise<void> {\n return await request({ name: \"toggleStatusBarUI\", args: { force: true } });\n}\n\nexport async function hideStatusBarUI(): Promise<void> {\n return await request({ name: \"toggleStatusBarUI\", args: { force: false } });\n}\n\n/** @since Beekeeper Studio 5.5.? */\nexport async function toggleStatusBarUI(): Promise<void> {\n return await request({ name: \"toggleStatusBarUI\", args: void 0 });\n}\n\n/** @since Beekeeper Studio 5.5.? */\nexport async function confirm(title?: string, message?: string, options?: ConfirmOptions): Promise<boolean> {\n return await request({ name: \"confirm\", args: { title, message, options } });\n}\n\n/** @since Beekeeper Studio 5.4.0 */\nexport const broadcast = {\n post<T extends JsonValue = JsonValue>(message: T): void {\n return notify(\"broadcast\", { message });\n },\n on<T extends JsonValue = JsonValue>(handler: (message: T) => void): void {\n addNotificationListener<T>(\"broadcast\", (params) => {\n handler(params.message);\n });\n },\n}\n\n/** @since Beekeeper Studio 5.3.0 */\nexport const log = {\n error(err: string | Error): void {\n if (typeof err === \"string\") {\n return notify(\"pluginError\", {\n name: \"Error\",\n message: err,\n stack: undefined,\n });\n }\n return notify(\"pluginError\", {\n name: err.name || \"Error\",\n message: err.message,\n stack: err.stack,\n });\n },\n}\n\n/** Clipboard interface. */\nexport const clipboard = {\n /** Write text to the Electron clipboard.\n * @since Beekeeper Studio 5.3.0 */\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 * @since Beekeeper Studio 5.3.0 */\n async readText(): Promise<string> {\n return await request({\n name: \"clipboard.readText\",\n args: void 0,\n });\n },\n /** @param data - Base64 encoded image data.\n * @since Beekeeper Studio 5.5.0 */\n async writeImage(data: string) {\n await request({\n name: \"clipboard.writeImage\",\n args: { data },\n });\n },\n // async write() {},\n // async read() {},\n};\n\n/** @since Beekeeper Studio 5.5.? */\nexport const noty = {\n async success(message: string): Promise<void> {\n return await request({\n name: \"noty.success\",\n args: { message },\n });\n },\n async info(message: string): Promise<void> {\n return await request({\n name: \"noty.info\",\n args: { message },\n });\n },\n async warning(message: string): Promise<void> {\n return await request({\n name: \"noty.warning\",\n args: { message },\n });\n },\n async error(message: string): Promise<void> {\n return await request({\n name: \"noty.error\",\n args: { message },\n });\n },\n}\n\nlet debugComms = false;\n\nexport function setDebugComms(enabled: boolean) {\n debugComms = enabled;\n}\n\nexport function notify<Message extends JsonValue = JsonValue>(\n name: \"broadcast\",\n args: { message: Message; }\n): void;\nexport function notify(name: \"pluginError\", args: PluginErrorObject): void;\nexport function notify(name: \"windowEvent\", args: WindowEventObject): 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\nexport function addNotificationListener(\n name: \"tablesChanged\",\n handler: () => void,\n): void;\nexport function addNotificationListener<Message extends JsonValue = JsonValue>(\n name: \"broadcast\",\n handler: (args: { message: Message; }) => void,\n): void;\nexport function addNotificationListener(\n name: \"themeChanged\",\n handler: (args: AppTheme) => 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: \"tablesChanged\",\n handler: (args: any) => void\n): void;\nexport function removeNotificationListener<Message extends JsonValue = JsonValue>(\n name: \"broadcast\",\n handler: (args: any) => void\n): void;\nexport function removeNotificationListener(\n name: \"themeChanged\",\n handler: (args: any) => void\n): void;\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\nconst pendingRequests = new Map<\n string,\n {\n // The whole payload is kept just in case for debugging\n payload: any;\n resolve: (value: any) => void;\n reject: (reason?: any) => void;\n }\n>();\n\nexport async function request<T extends keyof RequestMap>(\n raw: { name: T; args: RequestMap[T][\"args\"] }\n): Promise<RequestMap[T][\"return\"]> {\n const payload = { id: generateUUID(), ...raw };\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\nconst notificationListeners = new Map<string, ((args: any) => void)[]>();\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\nfunction 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\n"],"names":[],"mappings":"AAKA;;;;AAII;AACG,eAAe,UAAU,GAAA;AAC9B,IAAA,OAAO,MAAM,OAAO,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC5D;AAEA;;;;AAII;AACG,eAAe,SAAS,CAAC,MAAe,EAAA;AAC7C,IAAA,OAAO,MAAM,OAAO,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC;AAC/D;AAEA;;;;AAII;AACG,eAAe,UAAU,CAAC,KAAa,EAAE,MAAe,EAAA;AAC7D,IAAA,OAAO,MAAM,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AAE,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;;;;"}
|
package/dist/internal.d.ts
CHANGED
|
@@ -272,6 +272,17 @@ type RequestMap = {
|
|
|
272
272
|
};
|
|
273
273
|
return: void;
|
|
274
274
|
};
|
|
275
|
+
confirm: {
|
|
276
|
+
args: {
|
|
277
|
+
title?: string;
|
|
278
|
+
message?: string;
|
|
279
|
+
options?: {
|
|
280
|
+
confirmLabel?: string;
|
|
281
|
+
cancelLabel?: string;
|
|
282
|
+
};
|
|
283
|
+
};
|
|
284
|
+
return: boolean;
|
|
285
|
+
};
|
|
275
286
|
"clipboard.writeText": {
|
|
276
287
|
args: {
|
|
277
288
|
text: string;
|
|
@@ -288,6 +299,30 @@ type RequestMap = {
|
|
|
288
299
|
args: void;
|
|
289
300
|
return: string;
|
|
290
301
|
};
|
|
302
|
+
"noty.success": {
|
|
303
|
+
args: {
|
|
304
|
+
message: string;
|
|
305
|
+
};
|
|
306
|
+
return: void;
|
|
307
|
+
};
|
|
308
|
+
"noty.error": {
|
|
309
|
+
args: {
|
|
310
|
+
message: string;
|
|
311
|
+
};
|
|
312
|
+
return: void;
|
|
313
|
+
};
|
|
314
|
+
"noty.info": {
|
|
315
|
+
args: {
|
|
316
|
+
message: string;
|
|
317
|
+
};
|
|
318
|
+
return: void;
|
|
319
|
+
};
|
|
320
|
+
"noty.warning": {
|
|
321
|
+
args: {
|
|
322
|
+
message: string;
|
|
323
|
+
};
|
|
324
|
+
return: void;
|
|
325
|
+
};
|
|
291
326
|
};
|
|
292
327
|
type RequestPayload = {
|
|
293
328
|
[K in keyof RequestMap]: {
|
package/package.json
CHANGED