This Typescript package provides a client for the Stencila Hub API. It is automatically generated by the OpenAPI Generator from our OpenAPI Schema.
The following should be supported:
-
Environments
- Node.js
- Webpack
- Browserify
-
Language level
- ES6
-
Module system
- CommonJS
- ES6 module system
Install the package,
npm install @stencila/hub-client
Then, create a configuration containing your API token and pass it to the constructor of each of the API classes e.g.
import { Configuration, ProjectsApi } from '@stencila/hub-client'
// Create a configuration with the user's API token.
const config = new Configuration({
apiKey: `Token ${STENCILA_HUB_TOKEN}`
})
// Pass the configuration to the API class constructor.
const api = new ProjectsApi(config)
// List all projects that are not public and that the user is
// a manager of.
const projects = await api.projectsList({
public: false,
role: 'manager'
})
See tests for more examples.
Both the generation and testing of the client require a local instance of the manager
service to be running. To start that, at the top level of this repo, run
make -C manager run
To regenerate the client, at the top level of this repo, run
make -C clients typescript
There are two primary options for customizing the files this package:
-
Override the Mustache templates and place them in the
templates
folder -
Turn off generation by adding the file to
.openapi-generator-ignore
(as we do for thisREADME.md
in fact!).
Tests run against a local instance of the manager
service. So start that, generate the src
directory, and then run the tests from in this directory,
npm test
This client package is regenerated on each release and published on NPM. Tests of this package are currently not run on each release.