@beekeeperstudio/plugin 1.7.1-beta.0 → 1.7.1-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 +8 -6
- package/dist/index.js +15 -13
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
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.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>(\n key: string,\n options?: {\n encrypted: boolean;\n },\n ): Promise<T | null> {\n if (options?.encrypted) {\n return await request({\n name: \"getEncryptedData\",\n args: { key },\n });\n }\n return await request({ name: \"getData\", args: { key } });\n },\n async setItem<T = unknown>(\n key: string,\n value: T,\n options?: {\n encrypted: boolean;\n },\n ): Promise<void> {\n if (options?.encrypted) {\n return await request({\n name: \"setEncryptedData\",\n args: { key, value },\n });\n }\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":"AA8agB,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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ACC;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.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>(\n key: string,\n options?: {\n encrypted: boolean;\n },\n ): Promise<T | null> {\n if (options?.encrypted) {\n return await request({\n name: \"getEncryptedData\",\n args: { key },\n });\n }\n return await request({ name: \"getData\", args: { key } });\n },\n async setItem<T = unknown>(\n key: string,\n value: T,\n options?: {\n encrypted: boolean;\n },\n ): Promise<void> {\n if (options?.encrypted) {\n return await request({\n name: \"setEncryptedData\",\n args: { key, value },\n });\n }\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 cloudStorage = {\n connection: {\n async getItem<T = unknown>(key: string): Promise<T | null> {\n return await request({\n name: \"cloudStorage.connection.getItem\",\n args: { key },\n });\n },\n async setItem<T = unknown>(key: string, value: T): Promise<void> {\n return await request({\n name: \"cloudStorage.connection.setItem\",\n args: { key, value },\n });\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":"AAgbgB,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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Z,WAAW;IACX,UAAU;IACV,WAAW;IACX,SAAS;IACT,SAAS;IACT,UAAU;IACV,OAAO;CACC;AAEV,eAAe,CAAC,OAAO,CAAC,CAAC,SAAS,KAAI;IACpC,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,KAAK,KAAI;AAC7C,QAAA,MAAM,SAAS,GAAG,eAAe,CAAC,KAAK,CAAC;QACxC,MAAM,CAAC,aAAa,EAAE;YACpB,SAAS;YACT,UAAU,EAAE,SAAS,CAAC,UAAU;YAChC,gBAAgB,EAAE,SAAS,CAAC,gBAAgB;AAC7C,SAAA,CAAC;AACJ,KAAC,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -364,14 +364,14 @@ type RequestMap = {
|
|
|
364
364
|
args: void;
|
|
365
365
|
return: string;
|
|
366
366
|
};
|
|
367
|
-
"
|
|
367
|
+
"cloudStorage.connection.setItem": {
|
|
368
368
|
args: {
|
|
369
369
|
key: string;
|
|
370
370
|
value: any;
|
|
371
371
|
};
|
|
372
372
|
return: void;
|
|
373
373
|
};
|
|
374
|
-
"
|
|
374
|
+
"cloudStorage.connection.getItem": {
|
|
375
375
|
args: {
|
|
376
376
|
key: string;
|
|
377
377
|
};
|
|
@@ -552,9 +552,11 @@ declare const appStorage: {
|
|
|
552
552
|
encrypted: boolean;
|
|
553
553
|
}): Promise<void>;
|
|
554
554
|
};
|
|
555
|
-
declare const
|
|
556
|
-
|
|
557
|
-
|
|
555
|
+
declare const cloudStorage: {
|
|
556
|
+
connection: {
|
|
557
|
+
getItem<T = unknown>(key: string): Promise<T | null>;
|
|
558
|
+
setItem<T = unknown>(key: string, value: T): Promise<void>;
|
|
559
|
+
};
|
|
558
560
|
};
|
|
559
561
|
/** @since Beekeeper Studio 5.5.? */
|
|
560
562
|
declare const noty: {
|
|
@@ -583,5 +585,5 @@ declare function request<T extends keyof RequestMap>(raw: {
|
|
|
583
585
|
args: RequestMap[T]["args"];
|
|
584
586
|
}): Promise<RequestMap[T]["return"]>;
|
|
585
587
|
|
|
586
|
-
export { addNotificationListener, appStorage, broadcast, checkForUpdate, clipboard, confirm, expandTableResult, getAppInfo, getAppVersion, getColumns, getConnectionInfo, getIncomingKeys, getOutgoingKeys, getPrimaryKeys, getSchemas, getTableIndexes, getTableKeys, getTables, getViewContext, getViewState, getWorkspaceInfo, hideStatusBarUI, log, notify, noty, openExternal, openTab, removeNotificationListener, request, requestFileSave, runQuery, setDebugComms, setTabTitle, setViewState, showStatusBarUI, toggleStatusBarUI
|
|
588
|
+
export { addNotificationListener, appStorage, broadcast, checkForUpdate, clipboard, cloudStorage, confirm, expandTableResult, getAppInfo, getAppVersion, getColumns, getConnectionInfo, getIncomingKeys, getOutgoingKeys, getPrimaryKeys, getSchemas, getTableIndexes, getTableKeys, getTables, getViewContext, getViewState, getWorkspaceInfo, hideStatusBarUI, log, notify, noty, openExternal, openTab, removeNotificationListener, request, requestFileSave, runQuery, setDebugComms, setTabTitle, setViewState, showStatusBarUI, toggleStatusBarUI };
|
|
587
589
|
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
|
@@ -257,18 +257,20 @@ const appStorage = {
|
|
|
257
257
|
// async removeItem(key: string): Promise<void> {},
|
|
258
258
|
// async clear(): Promise<void> {},
|
|
259
259
|
};
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
260
|
+
const cloudStorage = {
|
|
261
|
+
connection: {
|
|
262
|
+
async getItem(key) {
|
|
263
|
+
return await request({
|
|
264
|
+
name: "cloudStorage.connection.getItem",
|
|
265
|
+
args: { key },
|
|
266
|
+
});
|
|
267
|
+
},
|
|
268
|
+
async setItem(key, value) {
|
|
269
|
+
return await request({
|
|
270
|
+
name: "cloudStorage.connection.setItem",
|
|
271
|
+
args: { key, value },
|
|
272
|
+
});
|
|
273
|
+
},
|
|
272
274
|
},
|
|
273
275
|
// TODO
|
|
274
276
|
// async removeItem(key: string): Promise<void> {},
|
|
@@ -401,5 +403,5 @@ function generateUUID() {
|
|
|
401
403
|
].join("-");
|
|
402
404
|
}
|
|
403
405
|
|
|
404
|
-
export { addNotificationListener, appStorage, broadcast, checkForUpdate, clipboard, confirm, expandTableResult, getAppInfo, getAppVersion, getColumns, getConnectionInfo, getIncomingKeys, getOutgoingKeys, getPrimaryKeys, getSchemas, getTableIndexes, getTableKeys, getTables, getViewContext, getViewState, getWorkspaceInfo, hideStatusBarUI, log, notify, noty, openExternal, openTab, removeNotificationListener, request, requestFileSave, runQuery, setDebugComms, setTabTitle, setViewState, showStatusBarUI, toggleStatusBarUI
|
|
406
|
+
export { addNotificationListener, appStorage, broadcast, checkForUpdate, clipboard, cloudStorage, confirm, expandTableResult, getAppInfo, getAppVersion, getColumns, getConnectionInfo, getIncomingKeys, getOutgoingKeys, getPrimaryKeys, getSchemas, getTableIndexes, getTableKeys, getTables, getViewContext, getViewState, getWorkspaceInfo, hideStatusBarUI, log, notify, noty, openExternal, openTab, removeNotificationListener, request, requestFileSave, runQuery, setDebugComms, setTabTitle, setViewState, showStatusBarUI, toggleStatusBarUI };
|
|
405
407
|
//# 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 {\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.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>(\n key: string,\n options?: {\n encrypted: boolean;\n },\n ): Promise<T | null> {\n if (options?.encrypted) {\n return await request({\n name: \"getEncryptedData\",\n args: { key },\n });\n }\n return await request({ name: \"getData\", args: { key } });\n },\n async setItem<T = unknown>(\n key: string,\n value: T,\n options?: {\n encrypted: boolean;\n },\n ): Promise<void> {\n if (options?.encrypted) {\n return await request({\n name: \"setEncryptedData\",\n args: { key, value },\n });\n }\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;AACvE;AAEA;AACO,eAAe,YAAY,CAChC,KAAa,EAC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AC,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.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>(\n key: string,\n options?: {\n encrypted: boolean;\n },\n ): Promise<T | null> {\n if (options?.encrypted) {\n return await request({\n name: \"getEncryptedData\",\n args: { key },\n });\n }\n return await request({ name: \"getData\", args: { key } });\n },\n async setItem<T = unknown>(\n key: string,\n value: T,\n options?: {\n encrypted: boolean;\n },\n ): Promise<void> {\n if (options?.encrypted) {\n return await request({\n name: \"setEncryptedData\",\n args: { key, value },\n });\n }\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 cloudStorage = {\n connection: {\n async getItem<T = unknown>(key: string): Promise<T | null> {\n return await request({\n name: \"cloudStorage.connection.getItem\",\n args: { key },\n });\n },\n async setItem<T = unknown>(key: string, value: T): Promise<void> {\n return await request({\n name: \"cloudStorage.connection.setItem\",\n args: { key, value },\n });\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,E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A;AACnB,IAAA,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC;AAC9B,IAAA,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC;AAE3B,IAAA,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC;AAChC,IAAA,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC;AAEhC,IAAA,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;IAE5E,OAAO;AACL,QAAA,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;AACnB,QAAA,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC;AACpB,QAAA,GAAG,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC;AACrB,QAAA,GAAG,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC;AACrB,QAAA,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;AAClB,KAAA,CAAC,IAAI,CAAC,GAAG,CAAC;AACb;;;;"}
|
package/dist/internal.d.ts
CHANGED
|
@@ -310,14 +310,14 @@ type RequestMap = {
|
|
|
310
310
|
args: void;
|
|
311
311
|
return: string;
|
|
312
312
|
};
|
|
313
|
-
"
|
|
313
|
+
"cloudStorage.connection.setItem": {
|
|
314
314
|
args: {
|
|
315
315
|
key: string;
|
|
316
316
|
value: any;
|
|
317
317
|
};
|
|
318
318
|
return: void;
|
|
319
319
|
};
|
|
320
|
-
"
|
|
320
|
+
"cloudStorage.connection.getItem": {
|
|
321
321
|
args: {
|
|
322
322
|
key: string;
|
|
323
323
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beekeeperstudio/plugin",
|
|
3
|
-
"version": "1.7.1-beta.
|
|
3
|
+
"version": "1.7.1-beta.2",
|
|
4
4
|
"description": "A simple TypeScript wrapper to send messages from your Beekeeper Studio plugin to the main app.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|