Skip to content

Commit

Permalink
Update user-facing Extensions docs
Browse files Browse the repository at this point in the history
- Added information about how Auth is passed to the application
- Added image showing Extensions in the Navbar
- Deferred to the API docs rather for extension managing rather than duplicating information
  • Loading branch information
Mythicaeda committed Oct 17, 2023
1 parent 3b0e428 commit ebd7b50
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 45 deletions.
64 changes: 19 additions & 45 deletions docs/planning/advanced-extensions.mdx
Original file line number Diff line number Diff line change
@@ -1,64 +1,38 @@
import extensions from './assets/extensions-navbar.png';

# Advanced - Extensions

Extensions are external tools that can be invoked directly from inside of Aerie. If there are not any extensions defined the button to view them will be hidden. When an Extension is called, the following values are passed along in the request body:
Extensions are external tools that can be invoked directly from inside of Aerie. When an Extension is called, the following values are passed along in the request body:

- `gateway` - The URL for the current instance's Gateway server.
- `hasura` - The URL for the current instance's Hasura server.
- `planId` - The id of the plan the user is looking at.
- `selectedActivityDirectiveId` - The id of the selected activity directive (if applicable).
- `simulationDatasetId` - The id of the last run simulation (if applicable).

After the Extension is ran, it is expecting the following response:
Additionally, the user's current session information will be passed to the Extension via the `Authorization` and `x-hasura-role` headers.

```json
{
"message": "",
"success": true,
"url": ""
}
```
Extensions **must** return a response of the following form:

The message will be displayed as a Toast inside of Aerie. `success` can be true or false to indicate if the Extension ran successfully or not. The `url` is optional and can be a link to a file or another webpage that will be opened in a new tab if provided.
- `message`: the message to be displayed as a notification inside of Aerie
- `success`: a boolean indicating whether the Extension ran successfully
- `url`: an optional link to a file or website. if provided, it will be opened in a new tab

There isn't currently a way to insert an extension through the UI, but we can use Hasura to create them with an API call.
## Managing Extensions

```graphql
mutation InsertExtension($extension: extensions_insert_input!) {
insert_extension_one(object: $extension) {
id
}
}
```
Extensions may only be managed via the [GraphQL API](/api/examples/extensions).

The `$extentsion` query variable has the following type definition:
## Using Extensions

```ts
type Extension = {
description: string;
extension_roles: ExtensionRole[];
id: number;
label: string;
updated_at: string;
url: string;
};
```
When looking at a plan in Aerie, all registered Extensions can be found under the Navbar entry between Scheduling and View.
If there are no any extensions registered, this entry will be hidden.

After creating an Extension, you need to define the roles that are allowed to access it through the following Hasura mutation:
Hovering over extensions will bring up the list of registered Extensions.
To run an extension, click on its entry in the list.

```graphql
mutation InsertExtensionRole($extensionRole: extension_roles_insert_input!) {
insert_extension_roles_one(object: $extensionRole) {
id
}
}
```
<figure align="center">
<img alt="Aerie Planning Navbar - Extensions" src={extensions} />
<figcaption>Figure 1: Aerie Planning Navbar - Extensions</figcaption>
</figure>

THe `$extensionRole` query variable has the following type definition:

```ts
type ExtensionRole = {
extension_id: number;
id: number;
role: string;
};
```
3 changes: 3 additions & 0 deletions docs/planning/assets/extensions-navbar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ebd7b50

Please sign in to comment.