Skip to content

Commit ee19c29

Browse files
committed
add getAppVersion
1 parent db6d600 commit ee19c29

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 2
9+
trim_trailing_whitespace = true

src/index.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,22 @@ export async function getAppInfo(): Promise<GetAppInfoResponse['result']> {
7373
return await request({ name: "getAppInfo", args: void 0 });
7474
}
7575

76+
/**
77+
* Get the version of Beekeeper Studio
78+
* @since Beekeeper Studio 5.3.0
79+
**/
80+
export async function getAppVersion(): Promise<"5.3" | (string & { __brand?: never })> {
81+
try {
82+
const appInfo = await getAppInfo();
83+
return appInfo.version;
84+
} catch (e){
85+
if (e instanceof Error && e.message.includes("Unknown request")) {
86+
return "5.3";
87+
}
88+
throw e;
89+
}
90+
}
91+
7692
/**
7793
* Check if plugin's update is available.
7894
*
@@ -159,11 +175,11 @@ export async function getData<T>(key: string = "default"): Promise<GetDataRespon
159175

160176
/**
161177
* Store data that can be retrieved later.
162-
*
178+
*
163179
* @example
164180
* // Store with custom key
165181
* await setData("myKey", { name: "John" });
166-
*
182+
*
167183
* // Store with default key (equivalent to setData("default", value))
168184
* await setData({ name: "John" });
169185
*
@@ -186,11 +202,11 @@ export async function getEncryptedData<T>(key: string): Promise<GetEncryptedData
186202

187203
/**
188204
* Store encrypted data that can be retrieved later.
189-
*
205+
*
190206
* @example
191207
* // Store with custom key
192208
* await setEncryptedData("secretKey", { token: "abc123" });
193-
*
209+
*
194210
* // Store with default key (equivalent to setEncryptedData("default", value))
195211
* await setEncryptedData({ token: "abc123" });
196212
*

0 commit comments

Comments
 (0)