Skip to content

Commit 2140e90

Browse files
committed
add getWorkspaceInfo
1 parent a540cdb commit 2140e90

3 files changed

Lines changed: 82 additions & 35 deletions

File tree

src/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import type {
1818
TableIndex,
1919
TableKey,
2020
WindowEventObject,
21+
WorkspaceInfo,
2122
} from "./types";
2223
import type { RequestMap } from "./internal";
2324

@@ -99,6 +100,15 @@ export async function getConnectionInfo(): Promise<ConnectionInfo> {
99100
return await request({ name: "getConnectionInfo", args: void 0 });
100101
}
101102

103+
/**
104+
* Get information about the current workspace.
105+
*
106+
* @since Beekeeper Studio 5.5.?
107+
**/
108+
export async function getWorkspaceInfo(): Promise<WorkspaceInfo> {
109+
return await request({ name: "getWorkspaceInfo", args: void 0 });
110+
}
111+
102112
/** @since Beekeeper Studio 5.4.0 */
103113
export async function getAppInfo(): Promise<AppInfo> {
104114
return await request({ name: "getAppInfo", args: void 0 });

src/internal.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
TableIndex,
1919
TableKey,
2020
WindowEventObject,
21+
WorkspaceInfo,
2122
} from "./types";
2223

2324
export type RequestMap = {
@@ -77,6 +78,10 @@ export type RequestMap = {
7778
args: void;
7879
return: ConnectionInfo;
7980
};
81+
getWorkspaceInfo: {
82+
args: void;
83+
return: WorkspaceInfo;
84+
};
8085
getAppInfo: {
8186
args: void;
8287
return: AppInfo;

src/types.ts

Lines changed: 67 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -23,38 +23,46 @@ export interface TableKey {
2323
}
2424

2525
export type IndexColumn = {
26-
name: string
27-
order?: 'ASC' | 'DESC' | '2d' | '2dsphere' | 'text' | 'geoHaystack' | 'hashed' | number // after DESC is for mongo only
26+
name: string;
27+
order?:
28+
| "ASC"
29+
| "DESC"
30+
| "2d"
31+
| "2dsphere"
32+
| "text"
33+
| "geoHaystack"
34+
| "hashed"
35+
| number; // after DESC is for mongo only
2836
/** MySQL Only */
29-
prefix?: number | null
30-
}
37+
prefix?: number | null;
38+
};
3139

3240
export type PrimaryKey = {
3341
columnName: string;
3442
position: number;
35-
}
43+
};
3644

3745
export type TableIndex = {
38-
id: string
39-
table: string
40-
schema: string
41-
name: string
42-
columns: IndexColumn[]
43-
unique: boolean
44-
primary: boolean
46+
id: string;
47+
table: string;
48+
schema: string;
49+
name: string;
50+
columns: IndexColumn[];
51+
unique: boolean;
52+
primary: boolean;
4553
/** for postgres 15 and above https://www.postgresql.org/about/featurematrix/detail/392/ */
46-
nullsNotDistinct?: boolean
47-
}
54+
nullsNotDistinct?: boolean;
55+
};
4856

4957
export type Table = {
5058
name: string;
5159
schema?: string;
52-
}
60+
};
5361

5462
export type Column = {
5563
name: string;
5664
type: string;
57-
}
65+
};
5866

5967
export type WindowEventClass =
6068
| "MouseEvent"
@@ -70,17 +78,17 @@ export type WindowEventInits =
7078
export type TableFilter = {
7179
field: string;
7280
type:
73-
| "="
74-
| "!="
75-
| "like"
76-
| "not like"
77-
| "<"
78-
| "<="
79-
| ">"
80-
| ">="
81-
| "in"
82-
| "is"
83-
| "is not";
81+
| "="
82+
| "!="
83+
| "like"
84+
| "not like"
85+
| "<"
86+
| "<="
87+
| ">"
88+
| ">="
89+
| "in"
90+
| "is"
91+
| "is not";
8492
value?: string | string[];
8593
op?: "AND" | "OR";
8694
};
@@ -155,7 +163,24 @@ export type PluginViewContext = {
155163
params?: CellMenuParams | ColumnMenuParams | RowMenuParams | CornerMenuParams;
156164
};
157165

158-
export type DatabaseType = 'postgresql' | 'mysql' | 'mariadb' | 'sqlite' | 'sqlserver' | 'oracle' | 'mongodb' | 'cassandra' | 'clickhouse' | 'firebird' | 'bigquery' | 'redshift' | 'duckdb' | 'libsql' | 'redis' | 'surrealdb' | 'trino';
166+
export type DatabaseType =
167+
| "postgresql"
168+
| "mysql"
169+
| "mariadb"
170+
| "sqlite"
171+
| "sqlserver"
172+
| "oracle"
173+
| "mongodb"
174+
| "cassandra"
175+
| "clickhouse"
176+
| "firebird"
177+
| "bigquery"
178+
| "redshift"
179+
| "duckdb"
180+
| "libsql"
181+
| "redis"
182+
| "surrealdb"
183+
| "trino";
159184

160185
export type ConnectionInfo = {
161186
/** @alias databaseType */
@@ -171,12 +196,12 @@ export type ConnectionInfo = {
171196
databaseName: string;
172197
defaultSchema?: string;
173198
readOnlyMode: boolean;
174-
}
199+
};
175200

176201
export type AppInfo = {
177202
version: string;
178203
theme: AppTheme;
179-
}
204+
};
180205

181206
export type AppTheme = {
182207
palette: Record<string, string>;
@@ -187,7 +212,7 @@ export type AppTheme = {
187212
export type RunQueryResult = {
188213
results: QueryResult[];
189214
error?: unknown;
190-
}
215+
};
191216

192217
export type OpenQueryTabOptions = {
193218
query?: string;
@@ -212,22 +237,29 @@ export type RequestFileSaveOptions = {
212237
/** @default "utf8" */
213238
encoding?: "utf8" | "base64";
214239
filters?: { name: string; extensions: string[] }[];
215-
}
240+
};
216241

217242
export type PluginErrorObject = {
218243
name: string;
219244
message: string;
220245
stack?: string;
221246
logStack: string;
222-
}
247+
};
223248

224249
export type WindowEventObject = {
225250
eventType: string;
226251
eventClass: WindowEventClass;
227252
eventInitOptions: WindowEventInits;
228-
}
253+
};
229254

230255
export type ConfirmOptions = {
231256
confirmLabel?: string;
232257
cancelLabel?: string;
233-
}
258+
};
259+
260+
export type WorkspaceInfo = {
261+
id: number;
262+
type: "local" | "cloud";
263+
name: string;
264+
isOwner: boolean;
265+
};

0 commit comments

Comments
 (0)