0.1.1 • Published 3 years ago

validaus-js v0.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Validaus NPM Module

This is a Javascript/Typescript wrapper around Validaus API calls. See below for examples. The code below can also be dynamically generated for you in the Code Integration tab of the Validaus UI.

Instantiate Validaus

import Validaus from "validaus-js";

const validaus = new Validaus({
  validausURL: "http://localhost:4001,
  app: "my-app-id",
  apiKey: "2b94d049-28ed-4476-a544-8bd9034cab53"
});

Pull Mode (i.e. "Build Health" in the UI)

Use the code below to run a regression test on multiple facts, and get a full validation report from Validaus. This is most suitable to integrate into your CI.

// First, get all Facts that this App is subscribed to
const facts = await validaus.getFacts({
  metric: "my-metric-id"
});

// Next, run your own code here.
// Plug the params for each fact into your code,
// and save the resulting value. You'll submit
// these to Validaus in the final step.

// Finally, stream all Facts to Validaus with your code's values.
// Validaus will return an object with information on your
// data accuracy across all subscribed playbooks.
const resp = await validaus.validateFacts(
  metric: "my-metric-id",
  facts: [
    {
      paramValues: [
        { name: "a", value: YOUR_PARAM_NUMERIC_VALUE },
        { name: "b", value: YOUR_PARAM_NUMERIC_VALUE }
      ],
      value: YOUR_FACT_NUMERIC_VALUE
    },
    {
      paramValues: [
        { name: "a", value: YOUR_PARAM_NUMERIC_VALUE },
        { name: "b", value: YOUR_PARAM_NUMERIC_VALUE }
      ],
      value: YOUR_FACT_NUMERIC_VALUE
    }
  ]
});

Push Mode (i.e. "Live Health" in the UI)

In Push mode, stream a Fact to Validaus in any environment, and receive reports and alerts about any errors. This is most suitable for catching live errors, typically in production.

// Stream a Fact to Validaus - put this code snippet in the part
// of your code that is producing the data you want to validate.
validaus.publishFact({
  metric: "my-metric-id",
  fact: {
    paramValues: [
      { name: "a", value: YOUR_PARAM_NUMERIC_VALUE },
      { name: "b", value: YOUR_PARAM_NUMERIC_VALUE }
    ],
    value: YOUR_FACT_NUMERIC_VALUE
  }
});