muranode2

1.0.0 • Public • Published

Intro

This is a nodejs module can use in code and also a Murano CLI project compatible CLI.

Install

git clone https://westpharmaceutical@dev.azure.com/westpharmaceutical/D%20and%20T_Digital%20Product%20Development/_git/Platform.muranode
cd Platform.muranode
npm link

CLI Usage

muranode --help

Module Usage

Promise

const {
  api: { Biz },
} = require("muranode");

const host = "bizapi.hosted.diagnostic.westpharma.com";
const email = "";
const password = "";
const applicationId = "l42uof33r6bk00000";
const productId = "k2klu6p63jki00000";

const biz = Biz({ host, applicationId, productId });

biz
  .token({ email, password })
  .toPromise()
  .then(() =>
    Promise.all([
      biz.device2.listIdentities({ limit: 1 }).toPromise(),
      biz.user.listUsers({ limit: 1 }).toPromise(),
    ])
  )
  .then(console.log)
  .catch(console.log);

Observable

const { combineLatest } = require("rxjs");
const { switchMap } = require("rxjs/operators");
const {
  api: { Biz },
} = require("muranode");

const host = "bizapi.hosted.diagnostic.westpharma.com";
const email = "";
const password = "";
const applicationId = "l42uof33r6bk00000";
const productId = "k2klu6p63jki00000";

const biz = Biz({ host, applicationId, productId });

biz
  .token({ email, password })
  .pipe(
    switchMap(() =>
      combineLatest(
        biz.device2.listIdentities({ limit: 1 }),
        biz.user.listUsers({ limit: 1 })
      )
    )
  )
  .subscribe(
    (x) => console.log("next", x),
    (e) => console.log("error", e),
    () => console.log("complete")
  );

CLI

const { combineLatest, zip } = require("rxjs");
const { map, switchMap } = require("rxjs/operators");
const {
  api: { Biz },
  cli: { host, applicationId, productId, token },
} = require("muranode");

zip(host, applicationId, productId, token)
  .pipe(
    map(([host, applicationId, productId, token]) =>
      Biz({ host, applicationId, productId, token })
    ),
    switchMap((biz) =>
      combineLatest(
        biz.device2.listIdentities({ limit: 1 }),
        biz.user.listUsers({ limit: 1 })
      )
    )
  )
  .subscribe(
    (x) => console.log("next", x),
    (e) => console.log("error", e),
    () => console.log("complete")
  );

Uninstall

npm unlink
cd ..
rm -r Platform.muranode

Readme

Keywords

Package Sidebar

Install

npm i muranode2

Weekly Downloads

3

Version

1.0.0

License

none

Unpacked Size

34.4 kB

Total Files

19

Last publish

Collaborators

  • qimatluo_west