npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@waterclick/waterlyconnect-nodejs-client

v0.0.3

Published

## Required Values

Downloads

122

Readme

WaterlyConnect NodeJS Client

Required Values

You will need 3 specific values provided by the Waterly team to proceed:

  • url: The endpoint URL to submit data to
  • clientToken: The client "secret" for the API client
  • clientDeviceId: A unique identifier for the API client

Installation

yarn add @waterclick/waterlyconnect-nodejs-client

Usage

import {
  TagDatum,
  WaterlyConnectApiClient,
  WaterlyConnectApiClientConfig
} from "@waterclick/waterlyconnect-nodejs-client";

const config: WaterlyConnectApiClientConfig = {
  url: "https://foo.bar/connect/submit",
  clientToken: "abcpdqxyz123",
  clientDevice: {
    id: "my-fancy-device",
    type: "SCADACo",
  },
};

const c = new WaterlyConnectApiClient(config);

const data: TagDatum[] = [
  // Note that timestamps must be in *seconds* since the epoch, not milliseconds
  { name: "TagName", value: "123.2", last_change_timestamp: Math.floor(new Date().getTime() / 1000) },
];

c.submitData(data)
  .then(() => console.log("Success!"))
  .catch((err) => console.error("Failed to submit data", err));

API

WaterlyConnectApiClient

constructor

The WaterlyConnectApiClient requires one argument: an object of WaterlyConnectApiClientConfig. Please see the type documentation below for specifics of how it may be configured.

submitData

submitData is an async method with a void value. You must resolve calls to function with either then()/catch() syntax or async/await.

This function will throw an error that you must catch in your code if data was unable to be accepted by the WaterlyConnect service for any reason, or will complete silently when successful.


Types

WaterlyConnectApiClientConfig

WaterlyConnectApiClientConfig is used to configure the api client.

| Property | Required | Description | |----------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | url | true | The endpoint URL for the WaterlyConnect service, provided by the Waterly team. A typical value would end in /connect/submit like: https://host.name/connect/submit | | clientToken | true | The unique client secret WaterlyConnect service, provided by the Waterly team. It is usually a 32 character string. Please use secure transmission and storage methods to manage this value. | | clientDevice | true | See the section describing ClientDeviceInfo for more information | | proxy | false | If your API client is behind a firewall, it may be configured here. This object is an Axios Proxy configuration object. You may find more details on it here. |

ClientDeviceInfo

ClientDeviceInfo is used to describe the API client to the Waterly Connect service.

| Property | Required | Description | |-----------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | id | true | An identifier for the API client, assigned by the Waterly team. | | type | true | A simple string describing the type of system connecting to Waterly Connect. For instance, it may be a device type (e..g, Ewon Flexy) or a system name. You are free to choose this value. | | lan_ip | false | (Optional) The internal IP address of the client device or system | | wan_ip | false | (Optional) The external IP address of the client device or system | | serial | false | (Optional) A serial number for the client device or system | | uptime_millis | false | (Optional) A number representing the epoch time, represented in milliseconds that they client device or system has been "up" (or since last boot). |

TagDatum

TagDatum represents the actual tagged data to be submitted to WaterlyConnect

| Property | Required | Description | |-------------------------|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------| | name | true | The client-assigned tag name for the value. It may be any string, but must be unique within the submission. | | value | true | The actual data value being measured. While WaterlyConnect only accepts numeric values, this value must be encoded a string. For instance: "123.2" | | last_change_timestamp | true | The timestamp that the value was recorded, measured in seconds since the epoch. | | type | false | (Optional)(Legacy) A historical value used to track the type of data being submitted. | | unit | false | (Optional)(Legacy) Typically unused, this value was used to track the unit type of the submitted data. |