@waylay/client

2.31.0

Waylay SDK

The Javascript SDK that lets you use the Waylay REST Services.

Waylay

Waylay
Parameters
options (Object?) configuration options for this waylay client
Name Description
options.clientID string? the clientID (apiKey) to authenticate this client
options.secret string? the secret (apiSecret) to authenticate this client
options.domain string? the tenant domain used by this client (for authentication and as default endpoint). Note that any domain in the token takes precedence.
options.token string? the jwt token to authenticate this client (alternative to clientId, secret, domain arguments).
options.globalSettings Object? the organisation settings to use for this client (see withSettings ).
Properties
data (Data?) : the data service
resources (Resources?) : the resources service
alarms (Alarms?) : the alarms service
types (Types?) : the types service
constraints (Constraints?) : the constraints service
transformers (Transformers?) : the transformers service
tasks (Tasks?) : the tasks service
templates (Templates?) : the templates service
sensors (Sensors?) : the sensors service
actuators (Actuators?) : the actuators service
converter (Converter?) : the converter service
webscripts (Webscripts?) : the webscripts service
byoml (Byoml?) : the byoml service
storage (Storage?) : the storage service
analytics (Analytics?) : the analytics service
vault (Vault?) : the vault service
stats (Stats?) : the stats service
users (Users?) : the users service
policies (Policies?) : the policies service
tenants (Tenants?) : the tenants service
roles (Roles?) : the roles service
predefinedRoles (PredefinedRoles?) : the predefinedRoles service
permissions (Permissions?) : the permissions service
twoFA (TwoFA?) : the twoFA service
hoard (Hoard?) : the hoard service
Example
const Waylay = require('@waylay/client')
// initialise with apiKey/apiSecret
const waylay = new Waylay({ domain: 'my-org.waylay.io', clientID: myApiKey, secret: myApiSecret })
// ... or login with username/password
const waylay = new Waylay({ domain: 'my-org.waylay.io' })
await waylay.login(username, password)
// ... or initialise with token
const waylay = new Waylay({ token: myStoredWaylayJwtToken})
// configure waylay endpoints from tenant configuration automatically
const waylay = await new Waylay(<credentials>).loadSettings()
// ... or provide the tenant organisation settings yourself
const waylay = new Waylay(<credentials>).withSettings(myOrgSettings)
Instance Members
token
token
domain
domain
login(username, password)
ping()
me()
loadSettings()
withSettings(settings?)
settings()
baseUrl

Waylay Services

The Waylay client gives acces to the following REST Resources.

Data

Data

Extends Resource

Instance Members
getSeries(resource, params)
postSeries(message, params)
postSeries(resource, message, params)
getMetricSeries(resource, metric, options)
getLastDatapointsForMetric(resource, metric, options?)
getDatapointsForMetricRaw(resource, metric, options?)
queryTimeSeries(query)
queryMessages(query)
getLastMetric(resource, metric)
getLatestDocument(resource)
getLatestMessages(resource, filter?)
remove(resource, params?)

Resources

Resources
Static Members
batch
Instance Members
data
create(resource)
get(id, opts)
children(id, params)
parent(id)
references(id)
update(id, resource)
replace(id, resource)
remove(id)
search(params, opts)
executeCommand(resource, command, properties)
commandLogs(resource, opts)
changelog(resource, query)

Types

Types
Static Members
batch
Instance Members
baseUrl
create(type)
remove(id, The)
update(id, type)
patch(id, data)
list(qs)
get(id)
constraints(id, options)
revalidate(id)
changelog(id, query)

Constraints

Constraints
Instance Members
baseUrl
list(params)
get(id)
create(constraint)
update(id, constraint)
remove(id)

Alarms

Alarms
Static Members
batch
Instance Members
create(alarm)
get(id)
search(query)
timeline(resourceIds, from?, to?)
update(id, alarm)
remove(id)
removeAll(filter)

Transformers

Transformers

Extends Resource

Instance Members
execute(name, version, body)
list(query)
get(name, version, params)
create(transformer)
remove(name, params)
getScript(name, version)
getVersions(name, params)

Tasks

Tasks
Static Members
batch
Instance Members
create(task)
update(id, task)
list(filter?, params, options)
remove(id)
batchRemove(taskIdList)
get(id, params, options)
start(id)
stop(id)
stopAndRemove(id)
log(options)
pushState(id, node, state)

Templates

Templates

Extends Resource

Instance Members
create(template)
update(name, template)
list(filter?, params, options)
get(name, params)
remove(id)
variables(graph)

Sensors

Sensors
Instance Members
execute(name, version, body)
list(query)
get(name, version, params)
create(sensor)
remove(name, params, force)
getScript(name, version)
getVersions(name, params)

Actuators

Actuators
Instance Members
execute(name, version, body)
list(query)
get(name, version, params)
create(actuator)
remove(name, params, force)
getScript(name, version)
getVersions(name, params)

Converter

Configure and test converter configurations for channels

Converter
Instance Members
getAll()
get(converterName)
create(converterName, type, template)
update(converterName, type, template)
delete(converterName)
convert(converterName, payload, params, forward)
test(type, template, payload)

Webscripts

Webscripts

Extends Resource

Instance Members
call(namespace, name, version, body)
list()
exists(name)
get(name, version)
create(webscript)
remove(name)
update(name, webscript)
log(name, version)

Byoml

Byoml
Instance Members
list()
get(name)
exampleInput(name)
predict(name, payload)
regress(name, payload)
classify(name, payload)
remove(name)

Analytics

Analytics allows you to calculate anomalies and predict future values of timeseries

Analytics
Instance Members
fit(resource, tsaConfig, options, useConfig, urlParams)
anomaly(resource, tsaConfig, options, useConfig, urlParams)
predict(resource, tsaConfig, options, useConfig, urlParams)
validate(resource, tsaConfig, options, useConfig, urlParams)
config(resource, configId)
replaceConfig(resource, configId, config)
updateConfig(resource, configId, config)
createConfig(resource, configId, config)
removeConfig(resource, configId)
configs(resource)
getQuery(queryName)
removeQuery(queryName)
createQuery(queryName, query)
replaceQuery(queryName, query)
getQueries(options = {})
getQueryData(queryName, options)

Storage

The waylay Storage service that interacts with file storage objects.

new Storage(options: any, client: any)
Parameters
options (any)
client (any)
Properties
bucket (StorageBucket?) : Manage the buckets using the /bucket/ API.
object (StorageObject?) : Manage the file objects using the /bucket/{bucket}/{object_path} API.
folder (StorageFolder?) : Manage the folder objects using the /bucket/{bucket}/{folder_path}/ API.
content (StorageContent?) : Access and modify the actual content of file objects, using signed urls.
subscription (StorageSubscription?) : Manage the subscriptions of the storage service using the /subscription API.

StorageObject

Storage API methods on a file object.

A file object represents a single storage location with a bucket, comparable to a file.

new StorageObject()

Extends Resource

Instance Members
list(bucket, path, options)
get(bucket, path, options)
signGet(bucket, path, options)
signPut(bucket, path, options)
signPost(bucket, path, options)
remove(bucket, path, options)
removeAll(bucket, path, options)

StorageFolder

Storage API methods on a folder object.

A folder object is a shared path for storage objects, comparable to a folder on a file system. Note that folder in an object store is only a virtual concept: a folder corresponds with a prefix of stored objects ending in a '/'. Waylay Storage creates an empty folder by registering a hidden empty object named .folder.

new StorageFolder()

Extends Resource

Instance Members
list(bucket, path, options)
get(bucket, path, options)
signPost(bucket, path, options)
create(bucket, path, options)
remove(bucket, path, options)
removeAll(bucket, path, options)

StorageBucket

Storage API methods on a bucket.

A bucket is a top-level container for file objects having its own authorization policy. On default deployments, buckets named assets, public, etl-import and etl-export are present.

new StorageBucket()

Extends Resource

Instance Members
list(options)
get(bucket, options)

StorageContent

Upload and download the actual content of the file objects.

Uses the signed urls produced by object.signPost and folder.signPost.

Data content for uploads can be provided as

  • string, plain object, ArrayBuffer
  • (in browser) FormData, File, Blob
  • (on node scripts) Stream, Buffer
new StorageContent(options: any, client: any)
Parameters
options (any)
client (any)
Instance Members
get(bucket, path, options)
getSigned(signGetResponse)
put(bucket, path, data, options)
putSigned(signPutResponse, data, options)
post(bucket, path, data, options)
postSigned(signPostResponse, data, options)

StorageSubscription

Storage API methods on _subscriptions.

A notification subscription is a rule that ties changes on file objects (upload, delete) to invocations of a Waylay webscript.

Once a subscription is created, any upload or delete to an object that fits the subscription.filters, will trigger the invocation of a webscript, as specified in subscription.channel.name.

new StorageSubscription()

Extends Resource

Instance Members
list(bucket, options)
get(bucket, id, options)
create(bucket, subscription, options)
replace(bucket, id, subscription, options)
remove(bucket, id, options)
removeAll(bucket, options)

Administrative Services

The following services manage users, authorizations and settings for the Waylay platform.

OrganisationSettings

Allows you to manage your organisation's settings

OrganisationSettings
Instance Members
list()
set(key, value)
remove(key)

Vault

Vault allows you to store encrypted data

Vault
Instance Members
set(key, data)
get(key)
remove(key)
keys()

Users

Users
Instance Members
list(params)
get(id)
create(user)
update(id, user)
delete(id)
addRole(id, role, tenant)
removeRole(id, role, tenant)
resetPassword(id)

Policies

Policies
Instance Members
list()
get(id)
create(policy)
update(id, policy)
patch(id, policy)
remove(id)

Tenants

Tenants
Instance Members
branding(query)

Roles

Roles
Instance Members
list(params)
get(id)
create(role)
update(id, role)
delete(id)
addPermission(id, permission)
removePermission(id, permissionId, permission)
addUser(id, user, tenant)
removeUser(id, user, tenant)

PredefinedRoles

PredefinedRoles
Instance Members
list()

Permissions

Permissions
Instance Members
list()
get(id)
concepts()

TwoFA

TwoFA
Instance Members
status(user, tenant)
enableTwoFAEnforcement(tenant)
disableTwoFAEnforcement(tenant)

Hoard

Hoard
Instance Members
getTokens(provider, options)
getAllTokens(options)
provider(provider, options)
providers(options)
remove(provider, options)
removeAll(options)

Stats

Allows you to retrieve Waylay application statistics

Stats
Instance Members
getMetrics(params, optional)
getMetric(name, params, optional)

Messages

Supporting object definitions for request and response messages.

Messages
Static Members
StorageBucketEntity
StorageObjectEntity
StorageStoreEntity
StorageSubscriptionEntity
SubscriptionChannel
SubscriptionFilter
StorageNotification
HALResponse
PagedListResponse
PagedRemoveResponse

getBaseUrl

baseUrl abstraction to make sure that this entity first falls back to the api/engine config

getBaseUrl()