@beekeeperstudio/plugin 1.5.0 → 1.7.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/eventForwarder.js.map +1 -1
- package/dist/index.d.ts +104 -24
- package/dist/index.js +93 -20
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +65 -3
- 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,MAA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,CAAC,OAAO;YACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,WAAW,EAAE,KAAK,CAAC,WAAW;SAC/B;QAED,OAAO;AACL,YAAA,UAAU,EAAE,eAAe;YAC3B,gBAAgB;SACjB;;IAGH,OAAO;AACL,QAAA,UAAU,EAAE,OAAO;AACnB,QAAA,gBAAgB,EAAE,EAAE;KACrB;AACH;AAEA,MAAM,eAAe,GAAG;IACtB,aAAa;IACb,OAAO;IACP,UAAU;IACV,eAAe;IACf,aAAa;IACb,cAAc;IACd,cAAc;IACd,aAAa;IACb,YAAY;IACZ,aAAa;IACb,WAAW;IACX,WAAW;IACX,YAAY;IACZ,YAAY;IACZ,WAAW;IACX,UAAU;IACV,WAAW;IACX,SAAS;IACT,SAAS;IACT,UAAU;IACV,OAAO;CACC;AAEV,eAAe,CAAC,OAAO,CAAC,CAAC,SAAS,KAAI;IACpC,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,KAAK,KAAI;AAC7C,QAAA,MAAM,SAAS,GAAG,eAAe,CAAC,KAAK,CAAC;QACxC,MAAM,CAAC,aAAa,EAAE;YACpB,SAAS;YACT,UAAU,EAAE,SAAS,CAAC,UAAU;YAChC,gBAAgB,EAAE,SAAS,CAAC,gBAAgB;AAC7C,SAAA,CAAC;AACJ,KAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"eventForwarder.js","sources":["../src/index.ts","../src/eventForwarder.ts"],"sourcesContent":["import type {\n AppInfo,\n AppTheme,\n Column,\n ConfirmOptions,\n ConnectionInfo,\n JsonValue,\n OpenQueryTabOptions,\n OpenTableStructureTabOptions,\n OpenTableTableTabOptions,\n PluginErrorObject,\n PluginViewContext,\n PrimaryKey,\n QueryResult,\n RequestFileSaveOptions,\n RunQueryResult,\n Table,\n TableIndex,\n TableKey,\n WindowEventObject,\n WorkspaceInfo,\n} 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(\n table: string,\n schema?: string,\n): Promise<Column[]> {\n return await request({ name: \"getColumns\", args: { table, schema } });\n}\n\n/** @since Beekeeper Studio 5.4.0 */\nexport async function getTableKeys(\n table: string,\n schema?: string,\n): Promise<TableKey[]> {\n return await request({ name: \"getTableKeys\", args: { table, schema } });\n}\n\n/** @since Beekeeper Studio 5.5.0 */\nexport async function getTableIndexes(\n table: string,\n schema?: string,\n): Promise<TableIndex[]> {\n return await request({ name: \"getTableIndexes\", args: { table, schema } });\n}\n\nexport async function getPrimaryKeys(\n table: string,\n schema?: string,\n): Promise<PrimaryKey[]> {\n return await request({ name: \"getPrimaryKeys\", args: { table, schema } });\n}\n\nexport async function getIncomingKeys(\n table: string,\n schema?: string,\n): Promise<TableKey[]> {\n return await request({ name: \"getIncomingKeys\", args: { table, schema } });\n}\n\nexport async function getOutgoingKeys(\n table: string,\n schema?: string,\n): 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/**\n * Get information about the current workspace.\n *\n * @since Beekeeper Studio 5.5.?\n **/\nexport async function getWorkspaceInfo(): Promise<WorkspaceInfo> {\n return await request({ name: \"getWorkspaceInfo\", 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<\n \"5.3\" | (string & { __brand?: never })\n> {\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 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>(\n key: string,\n value: T,\n): Promise<void>;\nexport async function setEncryptedData<T = unknown>(value: T): Promise<void>;\nexport async function setEncryptedData<T = unknown>(\n keyOrValue: string | T,\n value?: T,\n): Promise<void> {\n if (value !== undefined) {\n return await request({\n name: \"setEncryptedData\",\n args: { key: keyOrValue as string, value },\n });\n } else {\n return await request({\n name: \"setEncryptedData\",\n args: { key: \"default\", value: keyOrValue as T },\n });\n }\n}\n\n/** @since Beekeeper Studio 5.4.0 */\nexport async function openTab(\n type: \"query\",\n options?: OpenQueryTabOptions,\n): Promise<void>;\nexport async function openTab(\n type: \"tableTable\",\n options: OpenTableTableTabOptions,\n): Promise<void>;\nexport async function openTab(\n type: \"tableStructure\",\n options: OpenTableStructureTabOptions,\n): 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(\n options: RequestFileSaveOptions,\n): 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(\n title?: string,\n message?: string,\n options?: ConfirmOptions,\n): 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\nclass PluginLog {\n error(err: string | Error): void {\n const logStack = new Error().stack!;\n\n if (typeof err === \"string\") {\n return notify(\"pluginError\", {\n name: \"Error\",\n message: err,\n stack: logStack,\n logStack,\n });\n }\n return notify(\"pluginError\", {\n name: err.name || \"Error\",\n message: err.message,\n stack: err.stack,\n logStack,\n });\n }\n}\n\n/** @since Beekeeper Studio 5.3.0 */\nexport const log = new PluginLog();\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/**\n * Similar to `localStorage`, `appStorage` is a persistent storage that persists\n * across sessions. The data is stored in the local database of the app and\n * scoped to the plugin.\n *\n * @since Beekeeper Studio 5.3.0\n **/\nexport const appStorage = {\n async getItem<T = unknown>(key: string): Promise<T | null> {\n return await request({ name: \"getData\", args: { key } });\n },\n async setItem<T = unknown>(key: string, value: T): Promise<void> {\n return await request({ name: \"setData\", args: { key, value } });\n },\n // TODO\n // async removeItem(key: string): Promise<void> {},\n // async clear(): Promise<void> {},\n};\n\nexport const workspaceConnectionStorage = {\n async getItem<T = unknown>(key: string): Promise<T | null> {\n return await request({\n name: \"workspaceConnectionStorage.getItem\",\n args: { key },\n });\n },\n async setItem<T = unknown>(key: string, value: T): Promise<void> {\n return await request({\n name: \"workspaceConnectionStorage.setItem\",\n args: { key, value },\n });\n },\n // TODO\n // async removeItem(key: string): Promise<void> {},\n // async clear(): Promise<void> {},\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: \"dataPollSucceeded\",\n handler: () => 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<\n Message extends JsonValue = JsonValue,\n>(name: \"broadcast\", handler: (args: any) => void): 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>(raw: {\n name: T;\n 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","/** 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":"AA8bgB,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;AAoDA,MAAM,eAAe,GAAG,IAAI,GAAG,EAQ5B;AA2BH,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAAmC;AAExE,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;;ACpkBF;AACkB;AAElB;AAKA,SAAS,eAAe,CAAI,KAAQ,EAAA;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AC,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
|
@@ -21,7 +21,7 @@ interface TableKey {
|
|
|
21
21
|
}
|
|
22
22
|
type IndexColumn = {
|
|
23
23
|
name: string;
|
|
24
|
-
order?:
|
|
24
|
+
order?: "ASC" | "DESC" | "2d" | "2dsphere" | "text" | "geoHaystack" | "hashed" | number;
|
|
25
25
|
/** MySQL Only */
|
|
26
26
|
prefix?: number | null;
|
|
27
27
|
};
|
|
@@ -109,7 +109,7 @@ type PluginViewContext = {
|
|
|
109
109
|
command: string;
|
|
110
110
|
params?: CellMenuParams | ColumnMenuParams | RowMenuParams | CornerMenuParams;
|
|
111
111
|
};
|
|
112
|
-
type DatabaseType =
|
|
112
|
+
type DatabaseType = "postgresql" | "mysql" | "mariadb" | "sqlite" | "sqlserver" | "oracle" | "mongodb" | "cassandra" | "clickhouse" | "firebird" | "bigquery" | "redshift" | "duckdb" | "libsql" | "redis" | "surrealdb" | "trino";
|
|
113
113
|
type ConnectionInfo = {
|
|
114
114
|
/** @alias databaseType */
|
|
115
115
|
connectionType: string;
|
|
@@ -163,15 +163,26 @@ type RequestFileSaveOptions = {
|
|
|
163
163
|
}[];
|
|
164
164
|
};
|
|
165
165
|
type PluginErrorObject = {
|
|
166
|
-
name
|
|
166
|
+
name: string;
|
|
167
167
|
message: string;
|
|
168
168
|
stack?: string;
|
|
169
|
+
logStack: string;
|
|
169
170
|
};
|
|
170
171
|
type WindowEventObject = {
|
|
171
172
|
eventType: string;
|
|
172
173
|
eventClass: WindowEventClass;
|
|
173
174
|
eventInitOptions: WindowEventInits;
|
|
174
175
|
};
|
|
176
|
+
type ConfirmOptions = {
|
|
177
|
+
confirmLabel?: string;
|
|
178
|
+
cancelLabel?: string;
|
|
179
|
+
};
|
|
180
|
+
type WorkspaceInfo = {
|
|
181
|
+
id: number;
|
|
182
|
+
type: "local" | "cloud";
|
|
183
|
+
name: string;
|
|
184
|
+
isOwner: boolean;
|
|
185
|
+
};
|
|
175
186
|
|
|
176
187
|
type RequestMap = {
|
|
177
188
|
getSchemas: {
|
|
@@ -230,6 +241,10 @@ type RequestMap = {
|
|
|
230
241
|
args: void;
|
|
231
242
|
return: ConnectionInfo;
|
|
232
243
|
};
|
|
244
|
+
getWorkspaceInfo: {
|
|
245
|
+
args: void;
|
|
246
|
+
return: WorkspaceInfo;
|
|
247
|
+
};
|
|
233
248
|
getAppInfo: {
|
|
234
249
|
args: void;
|
|
235
250
|
return: AppInfo;
|
|
@@ -322,6 +337,17 @@ type RequestMap = {
|
|
|
322
337
|
};
|
|
323
338
|
return: void;
|
|
324
339
|
};
|
|
340
|
+
confirm: {
|
|
341
|
+
args: {
|
|
342
|
+
title?: string;
|
|
343
|
+
message?: string;
|
|
344
|
+
options?: {
|
|
345
|
+
confirmLabel?: string;
|
|
346
|
+
cancelLabel?: string;
|
|
347
|
+
};
|
|
348
|
+
};
|
|
349
|
+
return: boolean;
|
|
350
|
+
};
|
|
325
351
|
"clipboard.writeText": {
|
|
326
352
|
args: {
|
|
327
353
|
text: string;
|
|
@@ -338,6 +364,43 @@ type RequestMap = {
|
|
|
338
364
|
args: void;
|
|
339
365
|
return: string;
|
|
340
366
|
};
|
|
367
|
+
"workspaceConnectionStorage.setItem": {
|
|
368
|
+
args: {
|
|
369
|
+
key: string;
|
|
370
|
+
value: any;
|
|
371
|
+
};
|
|
372
|
+
return: void;
|
|
373
|
+
};
|
|
374
|
+
"workspaceConnectionStorage.getItem": {
|
|
375
|
+
args: {
|
|
376
|
+
key: string;
|
|
377
|
+
};
|
|
378
|
+
return: any;
|
|
379
|
+
};
|
|
380
|
+
"noty.success": {
|
|
381
|
+
args: {
|
|
382
|
+
message: string;
|
|
383
|
+
};
|
|
384
|
+
return: void;
|
|
385
|
+
};
|
|
386
|
+
"noty.error": {
|
|
387
|
+
args: {
|
|
388
|
+
message: string;
|
|
389
|
+
};
|
|
390
|
+
return: void;
|
|
391
|
+
};
|
|
392
|
+
"noty.info": {
|
|
393
|
+
args: {
|
|
394
|
+
message: string;
|
|
395
|
+
};
|
|
396
|
+
return: void;
|
|
397
|
+
};
|
|
398
|
+
"noty.warning": {
|
|
399
|
+
args: {
|
|
400
|
+
message: string;
|
|
401
|
+
};
|
|
402
|
+
return: void;
|
|
403
|
+
};
|
|
341
404
|
};
|
|
342
405
|
|
|
343
406
|
/**
|
|
@@ -371,6 +434,12 @@ declare function getOutgoingKeys(table: string, schema?: string): Promise<TableK
|
|
|
371
434
|
* @since Beekeeper Studio 5.3.0
|
|
372
435
|
**/
|
|
373
436
|
declare function getConnectionInfo(): Promise<ConnectionInfo>;
|
|
437
|
+
/**
|
|
438
|
+
* Get information about the current workspace.
|
|
439
|
+
*
|
|
440
|
+
* @since Beekeeper Studio 5.5.?
|
|
441
|
+
**/
|
|
442
|
+
declare function getWorkspaceInfo(): Promise<WorkspaceInfo>;
|
|
374
443
|
/** @since Beekeeper Studio 5.4.0 */
|
|
375
444
|
declare function getAppInfo(): Promise<AppInfo>;
|
|
376
445
|
/**
|
|
@@ -436,22 +505,6 @@ declare function setViewState<T = unknown>(state: T): Promise<void>;
|
|
|
436
505
|
/** @since Beekeeper Studio 5.3.0 */
|
|
437
506
|
declare function openExternal(link: string): Promise<void>;
|
|
438
507
|
/** @since Beekeeper Studio 5.3.0 */
|
|
439
|
-
declare function getData<T = unknown>(key?: string): Promise<T>;
|
|
440
|
-
/**
|
|
441
|
-
* Store data that can be retrieved later.
|
|
442
|
-
*
|
|
443
|
-
* @example
|
|
444
|
-
* // Store with custom key
|
|
445
|
-
* await setData("myKey", { name: "John" });
|
|
446
|
-
*
|
|
447
|
-
* // Store with default key (equivalent to setData("default", value))
|
|
448
|
-
* await setData({ name: "John" });
|
|
449
|
-
*
|
|
450
|
-
* @since Beekeeper Studio 5.3.0
|
|
451
|
-
*/
|
|
452
|
-
declare function setData<T = unknown>(key: string, value: T): Promise<void>;
|
|
453
|
-
declare function setData<T = unknown>(value: T): Promise<void>;
|
|
454
|
-
/** @since Beekeeper Studio 5.3.0 */
|
|
455
508
|
declare function getEncryptedData<T>(key: string): Promise<T>;
|
|
456
509
|
/**
|
|
457
510
|
* Store encrypted data that can be retrieved later.
|
|
@@ -474,16 +527,20 @@ declare function openTab(type: "tableStructure", options: OpenTableStructureTabO
|
|
|
474
527
|
declare function requestFileSave(options: RequestFileSaveOptions): Promise<void>;
|
|
475
528
|
declare function showStatusBarUI(): Promise<void>;
|
|
476
529
|
declare function hideStatusBarUI(): Promise<void>;
|
|
530
|
+
/** @since Beekeeper Studio 5.5.? */
|
|
477
531
|
declare function toggleStatusBarUI(): Promise<void>;
|
|
532
|
+
/** @since Beekeeper Studio 5.5.? */
|
|
533
|
+
declare function confirm(title?: string, message?: string, options?: ConfirmOptions): Promise<boolean>;
|
|
478
534
|
/** @since Beekeeper Studio 5.4.0 */
|
|
479
535
|
declare const broadcast: {
|
|
480
536
|
post<T extends JsonValue = JsonValue>(message: T): void;
|
|
481
537
|
on<T extends JsonValue = JsonValue>(handler: (message: T) => void): void;
|
|
482
538
|
};
|
|
483
|
-
|
|
484
|
-
declare const log: {
|
|
539
|
+
declare class PluginLog {
|
|
485
540
|
error(err: string | Error): void;
|
|
486
|
-
}
|
|
541
|
+
}
|
|
542
|
+
/** @since Beekeeper Studio 5.3.0 */
|
|
543
|
+
declare const log: PluginLog;
|
|
487
544
|
/** Clipboard interface. */
|
|
488
545
|
declare const clipboard: {
|
|
489
546
|
/** Write text to the Electron clipboard.
|
|
@@ -496,6 +553,28 @@ declare const clipboard: {
|
|
|
496
553
|
* @since Beekeeper Studio 5.5.0 */
|
|
497
554
|
writeImage(data: string): Promise<void>;
|
|
498
555
|
};
|
|
556
|
+
/**
|
|
557
|
+
* Similar to `localStorage`, `appStorage` is a persistent storage that persists
|
|
558
|
+
* across sessions. The data is stored in the local database of the app and
|
|
559
|
+
* scoped to the plugin.
|
|
560
|
+
*
|
|
561
|
+
* @since Beekeeper Studio 5.3.0
|
|
562
|
+
**/
|
|
563
|
+
declare const appStorage: {
|
|
564
|
+
getItem<T = unknown>(key: string): Promise<T | null>;
|
|
565
|
+
setItem<T = unknown>(key: string, value: T): Promise<void>;
|
|
566
|
+
};
|
|
567
|
+
declare const workspaceConnectionStorage: {
|
|
568
|
+
getItem<T = unknown>(key: string): Promise<T | null>;
|
|
569
|
+
setItem<T = unknown>(key: string, value: T): Promise<void>;
|
|
570
|
+
};
|
|
571
|
+
/** @since Beekeeper Studio 5.5.? */
|
|
572
|
+
declare const noty: {
|
|
573
|
+
success(message: string): Promise<void>;
|
|
574
|
+
info(message: string): Promise<void>;
|
|
575
|
+
warning(message: string): Promise<void>;
|
|
576
|
+
error(message: string): Promise<void>;
|
|
577
|
+
};
|
|
499
578
|
declare function setDebugComms(enabled: boolean): void;
|
|
500
579
|
declare function notify<Message extends JsonValue = JsonValue>(name: "broadcast", args: {
|
|
501
580
|
message: Message;
|
|
@@ -507,6 +586,7 @@ declare function addNotificationListener<Message extends JsonValue = JsonValue>(
|
|
|
507
586
|
message: Message;
|
|
508
587
|
}) => void): void;
|
|
509
588
|
declare function addNotificationListener(name: "themeChanged", handler: (args: AppTheme) => void): void;
|
|
589
|
+
declare function addNotificationListener(name: "dataPollSucceeded", handler: () => void): void;
|
|
510
590
|
declare function removeNotificationListener(name: "tablesChanged", handler: (args: any) => void): void;
|
|
511
591
|
declare function removeNotificationListener<Message extends JsonValue = JsonValue>(name: "broadcast", handler: (args: any) => void): void;
|
|
512
592
|
declare function removeNotificationListener(name: "themeChanged", handler: (args: any) => void): void;
|
|
@@ -515,5 +595,5 @@ declare function request<T extends keyof RequestMap>(raw: {
|
|
|
515
595
|
args: RequestMap[T]["args"];
|
|
516
596
|
}): Promise<RequestMap[T]["return"]>;
|
|
517
597
|
|
|
518
|
-
export { addNotificationListener, broadcast, checkForUpdate, clipboard, expandTableResult, getAppInfo, getAppVersion, getColumns, getConnectionInfo,
|
|
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 };
|
|
598
|
+
export { addNotificationListener, appStorage, broadcast, checkForUpdate, clipboard, confirm, expandTableResult, getAppInfo, getAppVersion, getColumns, getConnectionInfo, getEncryptedData, getIncomingKeys, getOutgoingKeys, getPrimaryKeys, getSchemas, getTableIndexes, getTableKeys, getTables, getViewContext, getViewState, getWorkspaceInfo, hideStatusBarUI, log, notify, noty, openExternal, openTab, removeNotificationListener, request, requestFileSave, runQuery, setDebugComms, setEncryptedData, setTabTitle, setViewState, showStatusBarUI, toggleStatusBarUI, workspaceConnectionStorage };
|
|
599
|
+
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, WorkspaceInfo };
|
package/dist/index.js
CHANGED
|
@@ -47,6 +47,14 @@ async function getOutgoingKeys(table, schema) {
|
|
|
47
47
|
async function getConnectionInfo() {
|
|
48
48
|
return await request({ name: "getConnectionInfo", args: void 0 });
|
|
49
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Get information about the current workspace.
|
|
52
|
+
*
|
|
53
|
+
* @since Beekeeper Studio 5.5.?
|
|
54
|
+
**/
|
|
55
|
+
async function getWorkspaceInfo() {
|
|
56
|
+
return await request({ name: "getWorkspaceInfo", args: void 0 });
|
|
57
|
+
}
|
|
50
58
|
/** @since Beekeeper Studio 5.4.0 */
|
|
51
59
|
async function getAppInfo() {
|
|
52
60
|
return await request({ name: "getAppInfo", args: void 0 });
|
|
@@ -139,27 +147,21 @@ async function openExternal(link) {
|
|
|
139
147
|
return await request({ name: "openExternal", args: { link } });
|
|
140
148
|
}
|
|
141
149
|
/** @since Beekeeper Studio 5.3.0 */
|
|
142
|
-
async function getData(key = "default") {
|
|
143
|
-
return await request({ name: "getData", args: { key } });
|
|
144
|
-
}
|
|
145
|
-
async function setData(keyOrValue, value) {
|
|
146
|
-
if (value !== undefined) {
|
|
147
|
-
return await request({ name: "setData", args: { key: keyOrValue, value } });
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
return await request({ name: "setData", args: { key: "default", value: keyOrValue } });
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
/** @since Beekeeper Studio 5.3.0 */
|
|
154
150
|
async function getEncryptedData(key) {
|
|
155
151
|
return await request({ name: "getEncryptedData", args: { key } });
|
|
156
152
|
}
|
|
157
153
|
async function setEncryptedData(keyOrValue, value) {
|
|
158
154
|
if (value !== undefined) {
|
|
159
|
-
return await request({
|
|
155
|
+
return await request({
|
|
156
|
+
name: "setEncryptedData",
|
|
157
|
+
args: { key: keyOrValue, value },
|
|
158
|
+
});
|
|
160
159
|
}
|
|
161
160
|
else {
|
|
162
|
-
return await request({
|
|
161
|
+
return await request({
|
|
162
|
+
name: "setEncryptedData",
|
|
163
|
+
args: { key: "default", value: keyOrValue },
|
|
164
|
+
});
|
|
163
165
|
}
|
|
164
166
|
}
|
|
165
167
|
async function openTab(type, options) {
|
|
@@ -174,9 +176,14 @@ async function showStatusBarUI() {
|
|
|
174
176
|
async function hideStatusBarUI() {
|
|
175
177
|
return await request({ name: "toggleStatusBarUI", args: { force: false } });
|
|
176
178
|
}
|
|
179
|
+
/** @since Beekeeper Studio 5.5.? */
|
|
177
180
|
async function toggleStatusBarUI() {
|
|
178
181
|
return await request({ name: "toggleStatusBarUI", args: void 0 });
|
|
179
182
|
}
|
|
183
|
+
/** @since Beekeeper Studio 5.5.? */
|
|
184
|
+
async function confirm(title, message, options) {
|
|
185
|
+
return await request({ name: "confirm", args: { title, message, options } });
|
|
186
|
+
}
|
|
180
187
|
/** @since Beekeeper Studio 5.4.0 */
|
|
181
188
|
const broadcast = {
|
|
182
189
|
post(message) {
|
|
@@ -188,23 +195,27 @@ const broadcast = {
|
|
|
188
195
|
});
|
|
189
196
|
},
|
|
190
197
|
};
|
|
191
|
-
|
|
192
|
-
const log = {
|
|
198
|
+
class PluginLog {
|
|
193
199
|
error(err) {
|
|
200
|
+
const logStack = new Error().stack;
|
|
194
201
|
if (typeof err === "string") {
|
|
195
202
|
return notify("pluginError", {
|
|
196
203
|
name: "Error",
|
|
197
204
|
message: err,
|
|
198
|
-
stack:
|
|
205
|
+
stack: logStack,
|
|
206
|
+
logStack,
|
|
199
207
|
});
|
|
200
208
|
}
|
|
201
209
|
return notify("pluginError", {
|
|
202
210
|
name: err.name || "Error",
|
|
203
211
|
message: err.message,
|
|
204
212
|
stack: err.stack,
|
|
213
|
+
logStack,
|
|
205
214
|
});
|
|
206
|
-
}
|
|
207
|
-
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
/** @since Beekeeper Studio 5.3.0 */
|
|
218
|
+
const log = new PluginLog();
|
|
208
219
|
/** Clipboard interface. */
|
|
209
220
|
const clipboard = {
|
|
210
221
|
/** Write text to the Electron clipboard.
|
|
@@ -234,6 +245,68 @@ const clipboard = {
|
|
|
234
245
|
// async write() {},
|
|
235
246
|
// async read() {},
|
|
236
247
|
};
|
|
248
|
+
/**
|
|
249
|
+
* Similar to `localStorage`, `appStorage` is a persistent storage that persists
|
|
250
|
+
* across sessions. The data is stored in the local database of the app and
|
|
251
|
+
* scoped to the plugin.
|
|
252
|
+
*
|
|
253
|
+
* @since Beekeeper Studio 5.3.0
|
|
254
|
+
**/
|
|
255
|
+
const appStorage = {
|
|
256
|
+
async getItem(key) {
|
|
257
|
+
return await request({ name: "getData", args: { key } });
|
|
258
|
+
},
|
|
259
|
+
async setItem(key, value) {
|
|
260
|
+
return await request({ name: "setData", args: { key, value } });
|
|
261
|
+
},
|
|
262
|
+
// TODO
|
|
263
|
+
// async removeItem(key: string): Promise<void> {},
|
|
264
|
+
// async clear(): Promise<void> {},
|
|
265
|
+
};
|
|
266
|
+
const workspaceConnectionStorage = {
|
|
267
|
+
async getItem(key) {
|
|
268
|
+
return await request({
|
|
269
|
+
name: "workspaceConnectionStorage.getItem",
|
|
270
|
+
args: { key },
|
|
271
|
+
});
|
|
272
|
+
},
|
|
273
|
+
async setItem(key, value) {
|
|
274
|
+
return await request({
|
|
275
|
+
name: "workspaceConnectionStorage.setItem",
|
|
276
|
+
args: { key, value },
|
|
277
|
+
});
|
|
278
|
+
},
|
|
279
|
+
// TODO
|
|
280
|
+
// async removeItem(key: string): Promise<void> {},
|
|
281
|
+
// async clear(): Promise<void> {},
|
|
282
|
+
};
|
|
283
|
+
/** @since Beekeeper Studio 5.5.? */
|
|
284
|
+
const noty = {
|
|
285
|
+
async success(message) {
|
|
286
|
+
return await request({
|
|
287
|
+
name: "noty.success",
|
|
288
|
+
args: { message },
|
|
289
|
+
});
|
|
290
|
+
},
|
|
291
|
+
async info(message) {
|
|
292
|
+
return await request({
|
|
293
|
+
name: "noty.info",
|
|
294
|
+
args: { message },
|
|
295
|
+
});
|
|
296
|
+
},
|
|
297
|
+
async warning(message) {
|
|
298
|
+
return await request({
|
|
299
|
+
name: "noty.warning",
|
|
300
|
+
args: { message },
|
|
301
|
+
});
|
|
302
|
+
},
|
|
303
|
+
async error(message) {
|
|
304
|
+
return await request({
|
|
305
|
+
name: "noty.error",
|
|
306
|
+
args: { message },
|
|
307
|
+
});
|
|
308
|
+
},
|
|
309
|
+
};
|
|
237
310
|
let debugComms = false;
|
|
238
311
|
function setDebugComms(enabled) {
|
|
239
312
|
debugComms = enabled;
|
|
@@ -334,5 +407,5 @@ function generateUUID() {
|
|
|
334
407
|
].join("-");
|
|
335
408
|
}
|
|
336
409
|
|
|
337
|
-
export { addNotificationListener, broadcast, checkForUpdate, clipboard, expandTableResult, getAppInfo, getAppVersion, getColumns, getConnectionInfo,
|
|
410
|
+
export { addNotificationListener, appStorage, broadcast, checkForUpdate, clipboard, confirm, expandTableResult, getAppInfo, getAppVersion, getColumns, getConnectionInfo, getEncryptedData, getIncomingKeys, getOutgoingKeys, getPrimaryKeys, getSchemas, getTableIndexes, getTableKeys, getTables, getViewContext, getViewState, getWorkspaceInfo, hideStatusBarUI, log, notify, noty, openExternal, openTab, removeNotificationListener, request, requestFileSave, runQuery, setDebugComms, setEncryptedData, setTabTitle, setViewState, showStatusBarUI, toggleStatusBarUI, workspaceConnectionStorage };
|
|
338
411
|
//# 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,eAA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AU,CAAC,EAAE,CAAC;AAC9B,IAAA,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC;AAE3B,IAAA,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC;AAChC,IAAA,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC;AAEhC,IAAA,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;IAE5E,OAAO;AACL,QAAA,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;AACnB,QAAA,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC;AACpB,QAAA,GAAG,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC;AACrB,QAAA,GAAG,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC;AACrB,QAAA,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;AAClB,KAAA,CAAC,IAAI,CAAC,GAAG,CAAC;AACb;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import type {\n AppInfo,\n AppTheme,\n Column,\n ConfirmOptions,\n ConnectionInfo,\n JsonValue,\n OpenQueryTabOptions,\n OpenTableStructureTabOptions,\n OpenTableTableTabOptions,\n PluginErrorObject,\n PluginViewContext,\n PrimaryKey,\n QueryResult,\n RequestFileSaveOptions,\n RunQueryResult,\n Table,\n TableIndex,\n TableKey,\n WindowEventObject,\n WorkspaceInfo,\n} 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(\n table: string,\n schema?: string,\n): Promise<Column[]> {\n return await request({ name: \"getColumns\", args: { table, schema } });\n}\n\n/** @since Beekeeper Studio 5.4.0 */\nexport async function getTableKeys(\n table: string,\n schema?: string,\n): Promise<TableKey[]> {\n return await request({ name: \"getTableKeys\", args: { table, schema } });\n}\n\n/** @since Beekeeper Studio 5.5.0 */\nexport async function getTableIndexes(\n table: string,\n schema?: string,\n): Promise<TableIndex[]> {\n return await request({ name: \"getTableIndexes\", args: { table, schema } });\n}\n\nexport async function getPrimaryKeys(\n table: string,\n schema?: string,\n): Promise<PrimaryKey[]> {\n return await request({ name: \"getPrimaryKeys\", args: { table, schema } });\n}\n\nexport async function getIncomingKeys(\n table: string,\n schema?: string,\n): Promise<TableKey[]> {\n return await request({ name: \"getIncomingKeys\", args: { table, schema } });\n}\n\nexport async function getOutgoingKeys(\n table: string,\n schema?: string,\n): 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/**\n * Get information about the current workspace.\n *\n * @since Beekeeper Studio 5.5.?\n **/\nexport async function getWorkspaceInfo(): Promise<WorkspaceInfo> {\n return await request({ name: \"getWorkspaceInfo\", 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<\n \"5.3\" | (string & { __brand?: never })\n> {\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 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>(\n key: string,\n value: T,\n): Promise<void>;\nexport async function setEncryptedData<T = unknown>(value: T): Promise<void>;\nexport async function setEncryptedData<T = unknown>(\n keyOrValue: string | T,\n value?: T,\n): Promise<void> {\n if (value !== undefined) {\n return await request({\n name: \"setEncryptedData\",\n args: { key: keyOrValue as string, value },\n });\n } else {\n return await request({\n name: \"setEncryptedData\",\n args: { key: \"default\", value: keyOrValue as T },\n });\n }\n}\n\n/** @since Beekeeper Studio 5.4.0 */\nexport async function openTab(\n type: \"query\",\n options?: OpenQueryTabOptions,\n): Promise<void>;\nexport async function openTab(\n type: \"tableTable\",\n options: OpenTableTableTabOptions,\n): Promise<void>;\nexport async function openTab(\n type: \"tableStructure\",\n options: OpenTableStructureTabOptions,\n): 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(\n options: RequestFileSaveOptions,\n): 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(\n title?: string,\n message?: string,\n options?: ConfirmOptions,\n): 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\nclass PluginLog {\n error(err: string | Error): void {\n const logStack = new Error().stack!;\n\n if (typeof err === \"string\") {\n return notify(\"pluginError\", {\n name: \"Error\",\n message: err,\n stack: logStack,\n logStack,\n });\n }\n return notify(\"pluginError\", {\n name: err.name || \"Error\",\n message: err.message,\n stack: err.stack,\n logStack,\n });\n }\n}\n\n/** @since Beekeeper Studio 5.3.0 */\nexport const log = new PluginLog();\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/**\n * Similar to `localStorage`, `appStorage` is a persistent storage that persists\n * across sessions. The data is stored in the local database of the app and\n * scoped to the plugin.\n *\n * @since Beekeeper Studio 5.3.0\n **/\nexport const appStorage = {\n async getItem<T = unknown>(key: string): Promise<T | null> {\n return await request({ name: \"getData\", args: { key } });\n },\n async setItem<T = unknown>(key: string, value: T): Promise<void> {\n return await request({ name: \"setData\", args: { key, value } });\n },\n // TODO\n // async removeItem(key: string): Promise<void> {},\n // async clear(): Promise<void> {},\n};\n\nexport const workspaceConnectionStorage = {\n async getItem<T = unknown>(key: string): Promise<T | null> {\n return await request({\n name: \"workspaceConnectionStorage.getItem\",\n args: { key },\n });\n },\n async setItem<T = unknown>(key: string, value: T): Promise<void> {\n return await request({\n name: \"workspaceConnectionStorage.setItem\",\n args: { key, value },\n });\n },\n // TODO\n // async removeItem(key: string): Promise<void> {},\n // async clear(): Promise<void> {},\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: \"dataPollSucceeded\",\n handler: () => 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<\n Message extends JsonValue = JsonValue,\n>(name: \"broadcast\", handler: (args: any) => void): 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>(raw: {\n name: T;\n 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"],"names":[],"mappings":"AA0BA;;;;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,CAC9B,KAAa,EACb,MAAe,EAAA;AAEf,IAAA,OAAO,MAAM,OAAO,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC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,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC;AAEhC,IAAA,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;IAE5E,OAAO;AACL,QAAA,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;AACnB,QAAA,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC;AACpB,QAAA,GAAG,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC;AACrB,QAAA,GAAG,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC;AACrB,QAAA,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;AAClB,KAAA,CAAC,IAAI,CAAC,GAAG,CAAC;AACb;;;;"}
|
package/dist/internal.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ interface TableKey {
|
|
|
21
21
|
}
|
|
22
22
|
type IndexColumn = {
|
|
23
23
|
name: string;
|
|
24
|
-
order?:
|
|
24
|
+
order?: "ASC" | "DESC" | "2d" | "2dsphere" | "text" | "geoHaystack" | "hashed" | number;
|
|
25
25
|
/** MySQL Only */
|
|
26
26
|
prefix?: number | null;
|
|
27
27
|
};
|
|
@@ -59,7 +59,7 @@ type TableFilter = {
|
|
|
59
59
|
type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
60
60
|
[key: string]: JsonValue;
|
|
61
61
|
};
|
|
62
|
-
type DatabaseType =
|
|
62
|
+
type DatabaseType = "postgresql" | "mysql" | "mariadb" | "sqlite" | "sqlserver" | "oracle" | "mongodb" | "cassandra" | "clickhouse" | "firebird" | "bigquery" | "redshift" | "duckdb" | "libsql" | "redis" | "surrealdb" | "trino";
|
|
63
63
|
type ConnectionInfo = {
|
|
64
64
|
/** @alias databaseType */
|
|
65
65
|
connectionType: string;
|
|
@@ -113,15 +113,22 @@ type RequestFileSaveOptions = {
|
|
|
113
113
|
}[];
|
|
114
114
|
};
|
|
115
115
|
type PluginErrorObject = {
|
|
116
|
-
name
|
|
116
|
+
name: string;
|
|
117
117
|
message: string;
|
|
118
118
|
stack?: string;
|
|
119
|
+
logStack: string;
|
|
119
120
|
};
|
|
120
121
|
type WindowEventObject = {
|
|
121
122
|
eventType: string;
|
|
122
123
|
eventClass: WindowEventClass;
|
|
123
124
|
eventInitOptions: WindowEventInits;
|
|
124
125
|
};
|
|
126
|
+
type WorkspaceInfo = {
|
|
127
|
+
id: number;
|
|
128
|
+
type: "local" | "cloud";
|
|
129
|
+
name: string;
|
|
130
|
+
isOwner: boolean;
|
|
131
|
+
};
|
|
125
132
|
|
|
126
133
|
type RequestMap = {
|
|
127
134
|
getSchemas: {
|
|
@@ -180,6 +187,10 @@ type RequestMap = {
|
|
|
180
187
|
args: void;
|
|
181
188
|
return: ConnectionInfo;
|
|
182
189
|
};
|
|
190
|
+
getWorkspaceInfo: {
|
|
191
|
+
args: void;
|
|
192
|
+
return: WorkspaceInfo;
|
|
193
|
+
};
|
|
183
194
|
getAppInfo: {
|
|
184
195
|
args: void;
|
|
185
196
|
return: AppInfo;
|
|
@@ -272,6 +283,17 @@ type RequestMap = {
|
|
|
272
283
|
};
|
|
273
284
|
return: void;
|
|
274
285
|
};
|
|
286
|
+
confirm: {
|
|
287
|
+
args: {
|
|
288
|
+
title?: string;
|
|
289
|
+
message?: string;
|
|
290
|
+
options?: {
|
|
291
|
+
confirmLabel?: string;
|
|
292
|
+
cancelLabel?: string;
|
|
293
|
+
};
|
|
294
|
+
};
|
|
295
|
+
return: boolean;
|
|
296
|
+
};
|
|
275
297
|
"clipboard.writeText": {
|
|
276
298
|
args: {
|
|
277
299
|
text: string;
|
|
@@ -288,6 +310,43 @@ type RequestMap = {
|
|
|
288
310
|
args: void;
|
|
289
311
|
return: string;
|
|
290
312
|
};
|
|
313
|
+
"workspaceConnectionStorage.setItem": {
|
|
314
|
+
args: {
|
|
315
|
+
key: string;
|
|
316
|
+
value: any;
|
|
317
|
+
};
|
|
318
|
+
return: void;
|
|
319
|
+
};
|
|
320
|
+
"workspaceConnectionStorage.getItem": {
|
|
321
|
+
args: {
|
|
322
|
+
key: string;
|
|
323
|
+
};
|
|
324
|
+
return: any;
|
|
325
|
+
};
|
|
326
|
+
"noty.success": {
|
|
327
|
+
args: {
|
|
328
|
+
message: string;
|
|
329
|
+
};
|
|
330
|
+
return: void;
|
|
331
|
+
};
|
|
332
|
+
"noty.error": {
|
|
333
|
+
args: {
|
|
334
|
+
message: string;
|
|
335
|
+
};
|
|
336
|
+
return: void;
|
|
337
|
+
};
|
|
338
|
+
"noty.info": {
|
|
339
|
+
args: {
|
|
340
|
+
message: string;
|
|
341
|
+
};
|
|
342
|
+
return: void;
|
|
343
|
+
};
|
|
344
|
+
"noty.warning": {
|
|
345
|
+
args: {
|
|
346
|
+
message: string;
|
|
347
|
+
};
|
|
348
|
+
return: void;
|
|
349
|
+
};
|
|
291
350
|
};
|
|
292
351
|
type RequestPayload = {
|
|
293
352
|
[K in keyof RequestMap]: {
|
|
@@ -321,6 +380,9 @@ type NotificationMap = {
|
|
|
321
380
|
pluginError: {
|
|
322
381
|
args: PluginErrorObject;
|
|
323
382
|
};
|
|
383
|
+
dataPollSucceeded: {
|
|
384
|
+
args: void;
|
|
385
|
+
};
|
|
324
386
|
};
|
|
325
387
|
|
|
326
388
|
export type { NotificationMap, RequestMap, RequestPayload, ResponsePayload };
|
package/package.json
CHANGED