0.0.0-alpha.5 • Published 5 years ago

@opctl/sdk v0.0.0-alpha.5

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

Build Status Coverage

Be advised: this project is currently at Major version zero. Per the semantic versioning spec: "Major version zero (0.y.z) is for initial development. Anything may change at any time. The public API should not be considered stable."

Javascript SDK for opctl

Supported runtimes

This library is isomorphic & should be consumable from either nodejs or web browsers.

Installation

npm install --save @opctl/sdk

Typescript

This library is written in typescript. The package published to NPM targets ES2015 and includes type declarations.

Usage

API client

import {
  eventStreamGet,
  livenessGet,
  opKill,
  opStart
} from '@opctl/sdk/dist/api/client'

// opctl api available from nodes via localhost:42224/api
const apiBaseUrl = 'localhost:42224/api'

// get the liveness of the api
await livenessGet(
  apiBaseUrl
)

// start an op
const rootOpId = await opStart(
  apiBaseUrl,
  {
    rawValue: {
      string: 'hello base64 url encoded world!',
    },
  },
  {
    ref: 'github.com/opctl-pkgs/base64url.encode#1.0.0',
  }
)

// kill the op we started
await opKill(
  apiBaseUrl,
  rootOpId
)

// replay events from our op via stream
await eventStreamGet(
  apiBaseUrl,
  {
    filter: {
      roots: [rootOpId],
    },
    onEvent: event => console.log(`received op event: ${JSON.stringify(event)}`),
    onError: err => console.log(`error streaming op events; error was: ${JSON.stringify(err)}`),
  }
)

Support

join us on Slack or open an issue

Releases

releases are versioned according to semver 2.0.0 and tagged; see CHANGELOG.md for release notes

Contributing

see CONTRIBUTING.md