-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added some basic extension documentation (#87)
* Added some basic extension documentation
- Loading branch information
Showing
3 changed files
with
129 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Advanced - Extensions | ||
|
||
## Creating an Extension | ||
|
||
```graphql | ||
mutation InsertExtensions($object: extensions_insert_input!) { | ||
insert_extensions( | ||
objects: { description: "", label: "My External Application", url: "https://externalapp/api/test" } | ||
) { | ||
returning { | ||
id | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Creating an Extension Role | ||
|
||
This is an example query that would allow the `viewer` role the ability to execute the extension with id `1`. Only defined roles will be able to call the extension through the UI. | ||
|
||
```graphql | ||
mutation InsertExtensionRoles($object: extension_roles_insert_input!) { | ||
insert_extension_roles(objects: { extension_id: 1, role: "viewer" }) { | ||
returning { | ||
id | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Deleting an Extension | ||
|
||
The following query will delete an extension and cascade to delete any assigned roles for that extension as well. | ||
|
||
```graphql | ||
mutation DeleteExtension($extension_id: Int!) { | ||
delete_extensions_by_pk(id: $extension_id) { | ||
id | ||
} | ||
} | ||
``` | ||
|
||
## Get Extensions With Roles | ||
|
||
```graphql | ||
query GetExtensions { | ||
extensions { | ||
description | ||
extension_roles { | ||
id | ||
role | ||
} | ||
id | ||
label | ||
url | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# 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: | ||
|
||
- `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: | ||
|
||
```json | ||
{ | ||
"message": "", | ||
"success": true, | ||
"url": "" | ||
} | ||
``` | ||
|
||
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. | ||
|
||
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. | ||
|
||
```graphql | ||
mutation InsertExtension($extension: extensions_insert_input!) { | ||
insert_extension_one(object: $extension) { | ||
id | ||
} | ||
} | ||
``` | ||
|
||
The `$extentsion` query variable has the following type definition: | ||
|
||
```ts | ||
type Extension = { | ||
description: string; | ||
extension_roles: ExtensionRole[]; | ||
id: number; | ||
label: string; | ||
updated_at: string; | ||
url: string; | ||
}; | ||
``` | ||
|
||
After creating an Extension, you need to define the roles that are allowed to access it through the following Hasura mutation: | ||
|
||
```graphql | ||
mutation InsertExtensionRole($extensionRole: extension_roles_insert_input!) { | ||
insert_extension_roles_one(object: $extensionRole) { | ||
id | ||
} | ||
} | ||
``` | ||
|
||
THe `$extensionRole` query variable has the following type definition: | ||
|
||
```ts | ||
type ExtensionRole = { | ||
extension_id: number; | ||
id: number; | ||
role: string; | ||
}; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters