Skip to content

Commit

Permalink
GRAL-4068 add new GET_METADATA command
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasSaltsberg committed Nov 24, 2024
1 parent f9aa1c0 commit e3dbfa6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

- New `GET_METADATA` command

## [0.10.3] - 2024-10-10

### Changed
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Learn more about custom UI extensions from [Developer documentation](https://pip
- [Hide floating window](#hide-floating-window)
- [Set notification](#set-notification)
- [Set focus mode](#set-focus-mode)
- [Get metadata](#get-metadata)
- [Events](#events)
- [Visibility](#visibility)
- [Close custom modal](#close-custom-modal)
Expand Down Expand Up @@ -518,6 +519,23 @@ visible before using this command.
await sdk.execute(Command.SET_FOCUS_MODE, true);
```

### Get metadata

Retrieves metadata information about the main window.

**Response**

| Parameter | Type | Description | Notes |
|--------------|--------|---------------------------------|-------|
| windowHeight | Number | Height of the main window (px). | |
| windowWidth | Number | Width of the main window (px). | |

**Example**

```javascript
const { windowWidth, windowHeight } = await sdk.execute(Command.GET_METADATA);
```

## Events

Subscribe to events triggered by users.
Expand Down
8 changes: 8 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export enum Command {
HIDE_FLOATING_WINDOW = 'hide_floating_window',
SET_NOTIFICATION = 'set_notification',
SET_FOCUS_MODE = 'set_focus_mode',
GET_METADATA = 'get_metadata',
}

export enum Event {
Expand Down Expand Up @@ -142,6 +143,11 @@ export type UserSettings = {
theme: UserSettingsTheme;
};

export type Metadata = {
windowHeight: number,
windowWidth: number,
}

export type Args<T extends Command> = {
[Command.INITIALIZE]: InitializationOptions;
[Command.SHOW_SNACKBAR]: {
Expand Down Expand Up @@ -170,6 +176,7 @@ export type Args<T extends Command> = {
number?: number;
};
[Command.SET_FOCUS_MODE]: boolean;
[Command.GET_METADATA]: void;
}[T];

export type CommandResponse<T extends Command> = {
Expand All @@ -192,6 +199,7 @@ export type CommandResponse<T extends Command> = {
[Command.HIDE_FLOATING_WINDOW]: void;
[Command.SET_NOTIFICATION]: void;
[Command.SET_FOCUS_MODE]: void;
[Command.GET_METADATA]: Metadata,
}[T];

export type MessageChannelCommandResponse<T extends Command> = {
Expand Down

0 comments on commit e3dbfa6

Please sign in to comment.