Skip to content

Commit 3403e4d

Browse files
committed
add noty and confirm
1 parent d4430cb commit 3403e4d

File tree

3 files changed

+75
-1
lines changed

3 files changed

+75
-1
lines changed

src/index.ts

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { AppInfo, AppTheme, Column, ConnectionInfo, JsonValue, OpenQueryTabOptions, OpenTableStructureTabOptions, OpenTableTableTabOptions, PluginErrorObject, PluginViewContext, PrimaryKey, QueryResult, RequestFileSaveOptions, RunQueryResult, Table, TableIndex, TableKey, WindowEventObject } from "./types";
1+
import type { AppInfo, AppTheme, Column, ConfirmOptions, ConnectionInfo, JsonValue, OpenQueryTabOptions, OpenTableStructureTabOptions, OpenTableTableTabOptions, PluginErrorObject, PluginViewContext, PrimaryKey, QueryResult, RequestFileSaveOptions, RunQueryResult, Table, TableIndex, TableKey, WindowEventObject } from "./types";
22
import type { RequestMap } from "./internal";
33

44
export * from "./types";
@@ -241,10 +241,16 @@ export async function hideStatusBarUI(): Promise<void> {
241241
return await request({ name: "toggleStatusBarUI", args: { force: false } });
242242
}
243243

244+
/** @since Beekeeper Studio 5.5.? */
244245
export async function toggleStatusBarUI(): Promise<void> {
245246
return await request({ name: "toggleStatusBarUI", args: void 0 });
246247
}
247248

249+
/** @since Beekeeper Studio 5.5.? */
250+
export async function confirm(title?: string, message?: string, options?: ConfirmOptions): Promise<boolean> {
251+
return await request({ name: "confirm", args: { title, message, options } });
252+
}
253+
248254
/** @since Beekeeper Studio 5.4.0 */
249255
export const broadcast = {
250256
post<T extends JsonValue = JsonValue>(message: T): void {
@@ -305,6 +311,34 @@ export const clipboard = {
305311
// async read() {},
306312
};
307313

314+
/** @since Beekeeper Studio 5.5.? */
315+
export const noty = {
316+
async success(message: string): Promise<void> {
317+
return await request({
318+
name: "noty.success",
319+
args: { message },
320+
});
321+
},
322+
async info(message: string): Promise<void> {
323+
return await request({
324+
name: "noty.info",
325+
args: { message },
326+
});
327+
},
328+
async warning(message: string): Promise<void> {
329+
return await request({
330+
name: "noty.warning",
331+
args: { message },
332+
});
333+
},
334+
async error(message: string): Promise<void> {
335+
return await request({
336+
name: "noty.error",
337+
args: { message },
338+
});
339+
},
340+
}
341+
308342
let debugComms = false;
309343

310344
export function setDebugComms(enabled: boolean) {

src/internal.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,17 @@ export type RequestMap = {
144144
args: { force?: boolean };
145145
return: void;
146146
};
147+
confirm: {
148+
args: {
149+
title?: string;
150+
message?: string;
151+
options?: {
152+
confirmLabel?: string;
153+
cancelLabel?: string;
154+
};
155+
};
156+
return: boolean;
157+
},
147158
"clipboard.writeText": {
148159
args: {
149160
text: string;
@@ -160,6 +171,30 @@ export type RequestMap = {
160171
args: void;
161172
return: string;
162173
};
174+
"noty.success": {
175+
args: {
176+
message: string;
177+
};
178+
return: void;
179+
};
180+
"noty.error": {
181+
args: {
182+
message: string;
183+
};
184+
return: void;
185+
};
186+
"noty.info": {
187+
args: {
188+
message: string;
189+
};
190+
return: void;
191+
};
192+
"noty.warning": {
193+
args: {
194+
message: string;
195+
};
196+
return: void;
197+
};
163198
};
164199

165200
export type RequestPayload = {

src/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,3 +225,8 @@ export type WindowEventObject = {
225225
eventClass: WindowEventClass;
226226
eventInitOptions: WindowEventInits;
227227
}
228+
229+
export type ConfirmOptions = {
230+
confirmLabel?: string;
231+
cancelLabel?: string;
232+
}

0 commit comments

Comments
 (0)