Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: Include Feature discovery in documentation. #1722

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 57 additions & 2 deletions docs/src/develop/plugins/server_plugin_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,67 @@

# Server API for plugins

SignalK server provides an interface to allow plugins to access / update the full data model, operations and send / receive deltas (updates).
SignalK server provides an interface to allow plugins to:
- Discover Features.
- Access / update the full data model
- send / receive deltas (updates)
- Interact with APIs
- Expose HTTP endpoints

These functions are available via the `app` passed to the plugin when it is invoked.

These functions are available via the `app` object passed to the plugin when it is invoked.

---

### Discover Features

#### `app.getFeatures(enabedOnly)`

Returns an object detailing the available APIs and Plugins.

The `enabledOnly` parameter is optional and has the following values:
- `undefined` (not provided): list all features
- `true`: list only enabled features
- `false`: list only disabled features

_Example:_
```javascript
let baseStations = app.getFeatures();

{
"apis": [
"resources","course"
],
"plugins": [
{
"id": "anchoralarm",
"name": "Anchor Alarm",
"version": "1.13.0",
"enabled": true
},
{
"id": "autopilot",
"name": "Autopilot Control",
"version": "1.4.0",
"enabled": false
},
{
"id": "sk-to-nmea2000",
"name": "Signal K to NMEA 2000",
"version": "2.17.0",
"enabled": false
},
{
"id": "udp-nmea-sender",
"name": "UDP NMEA0183 Sender",
"version": "2.0.0",
"enabled": false
}
]
}
```


### Accessing the Data Model

#### `app.getPath(path)`
Expand Down
49 changes: 49 additions & 0 deletions docs/src/develop/webapps.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,55 @@ GET /signalk/v1/applicationData/user/my-application
[ "1.0", "1.1"]
```

## Discovering Server Features

To assist in tailoring a WebApps UI, it can "discover" the features supported by the server by sending a request to `/signalk/v2/features`.

The response wil contain an object detailing the available APIs and Plugins.

You can use the `enabled` parameter to specify to only return enabled or disabled features.

To list only enabled features:
`/signalk/v2/features?enable=1`

To list only disabled features:
`/signalk/v2/features?enable=0`

_Example response:_
```JSON
{
"apis": [
"resources","course"
],
"plugins": [
{
"id": "anchoralarm",
"name": "Anchor Alarm",
"version": "1.13.0",
"enabled": true
},
{
"id": "autopilot",
"name": "Autopilot Control",
"version": "1.4.0",
"enabled": false
},
{
"id": "sk-to-nmea2000",
"name": "Signal K to NMEA 2000",
"version": "2.17.0",
"enabled": false
},
{
"id": "udp-nmea-sender",
"name": "UDP NMEA0183 Sender",
"version": "2.0.0",
"enabled": false
}
]
}
```

## Embedded Components and Admin UI / Server interfaces

Embedded components are implemented using [Webpack Federated Modules](https://webpack.js.org/concepts/module-federation/) and [React Code Splitting](https://reactjs.org/docs/code-splitting.html).
Expand Down