This documentation is likely to remain sparse, as it is for internal use and under development!
For additional documentation see our endpoint documentation
Table of Contents
The @ospin/nexus exposes a set of conveniences methods wrapping calls to the OSPIN AWS backend, JSON serving, rest-like, API. Unless a method is explicitly labeled as using a public endpoint, or otherwise stated, all nexus consumers must do the following before using the methods provided:
const nexus = require('@ospin/nexus')
nexus.connect({
ENV: <oneOf['dev', 'staging', 'prod']>), // default: 'prod'
AWS_REGION, // default: 'eu-central-1'
})
// -> { result, config }
// if you'd like to inspect the configuration object that `connect` is ultimately using:
nexus.createConfig() // <- returns the default configuration
nexus.createConfig({ ENV, AWS_REGION }) // <- returns a custom configuration
With the nexus configured, a user can authenticate as their OSPIN AWS Cognito user:
const nexus = require('@ospin/nexus')
nexus.auth.signIn(<username>, <password>)
With the nexus configured, a device can authenticate using its certificate:
const nexus = require('@ospin/nexus')
nexus.createConfig()
nexus.connect()
nexus.deviceAPI.authentication.setCredentials({
deviceId: <deviceId>,
pathToCert: <pathToCert>
})
nexus.deviceAPI.validateAuthorization()
nexus
├── auth
│ ├── signIn(<username>, <password>)
│ ├── signOut()
│ ├── globalSignOut()
│ └── getCurrentSession()
├── user
│ ├── get(<userId>)
│ ├── list()
│ ├── createDeletionRequest(<userId>)
│ ├── update(<userId>, <userParamsObj>)
│ └── notifications
│ └── putAll(<notificationObj>)
├── command
│ └── device
│ └── process
│ └── startProcess(<deviceId>, <processId>)
├── datapoints
│ └── get(<processId>, <reporterFctId>, <params>)
├── device
│ ├── list()
│ ├── create(<deviceParamsObj>)
│ ├── createHeidolphCoreGateway(<deviceParamsObj>)
│ └── certificate
│ └── get(<deviceId>)
├── log
| └── device
| └── deleteMany(<deviceId>)
├── process
| ├── functionality
| │ └── image
| │ ├── create(<processId>, <fctId>, <body>)
| │ └── list(<processId>, <fctId>, <opts>)
| └── annotation
│ ├── create({ processId: <processId>, data: <dataObject> })
│ ├── delete({ processId: <processId>, annotationId: <annotationId> })
│ └── update({ processId: <processId>, annotationId: <annotationId>, data: <dataObject> })
└── deviceAPI
├── authentication
| ├── setCredentials({ deviceId, pathToCert })
| └── validateAuthorization()
└── process
├── get(<processId>)
└── functionality
└── image
├── createFromUri(<processId>, <fctId>, <body>)
└── createFromFile(<processId>, <fctId>, <body>)
All methods above return a standardized response object, e.g.:
const nexus = require('@ospin/nexus')
const {
success: <boolean>,
status: <100 - 500>, // HTTP response status code
data: {}, // JSON safe object
error: <errObj>, // the error if the request failed
errorMsg: <string>, // a conveniently parsed error message
} = nexus.user.list()
nexus
├── createConfig(connectionOpts)
└── connect(connectionOpts)
const nexus = require('@ospin/nexus')
nexus.connect()
const username = 'Nero Claudius Caesar Augustus Germanicus'
const password = 'BurnRomeToMakeANewPalace@Good-Plan-&-Ok-Password',
nexus.auth.signIn(username, password)
const {
success: listDevicesWasSuccessful,
data: devicesList,
errorMsg: listDevicesErrorMsg,
error: listDevicesError
} = nexus.device.list()
if (listDevicesWasSuccessful) {
console.log(deviceList)
} else {
console.error(errorMsg)
throw listDevicesError
}
This repo employs the github action semantic-release, which, on approved PRs to main
, sniffs the PR title/commit message to automatically bump the semantic versioning and publish the package to NPM.
All PRs to the main
branch should indicate the semantic version change via the following options:
Available types:
- feat: A new feature
- fix: A bug fix
- docs: Documentation only changes (unclear if this bumps version)
- style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
- refactor: A code change that neither fixes a bug nor adds a feature
- perf: A code change that improves performance
- test: Adding missing tests or correcting existing tests
- build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
- ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
- chore: Other changes that don't modify src or test files
- revert: Reverts a previous commit