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

@actyx/os-sdk

v0.3.1

Published

ActyxOS Javascript/Typescript SDK

Downloads

4

Readme

This is a JavaScript and TypeScript SDK for building ActyxOS apps. Currently, it wraps the ActyxOS Event Service and Console Service APIs in a simple client that can be used from within JavaScript and TypeScript apps.

ActyxOS

For more information about ActyxOS, please check out our developer documentation at https://developer.actyx.com/.

Examples

Event Service

Subscribe to event streams

import { Client, Subscription } from '@actyx/os-sdk'

const ActyxOS = Client()

// callback style
ActyxOS.eventService.subscribe({
  subscriptions: Subscription.everything(),
  onEvent: event => {
    console.log('got event', event)
  }
})

// stream style
const eventStream = ActyxOS.eventService.subscribeStream({
  subscriptions: Subscription.everything(),
})
for await (const event of eventStream) {
  console.log('got event', event)
}

Publish events

import { Client, EventDraft } from '@actyx/os-sdk'

const ActyxOS = Client()

// callback style
ActyxOS.eventService.publish({
  eventDrafts: EventDraft.make('mySemantics', 'myName', { foo: 'bar' }),
  onDone: () => {
    console.log(`Published`)
  }
})

// promise style
await ActyxOS.eventService.publishPromise({
  eventDrafts: EventDraft.make('mySemantics', 'myName', { foo: 'bar' }),
})

Console Service

Simple logging

For simple logging needs, use the SimpleLogger which you can configure once and then use to log messages and, optionally, additional data:

import { Client } from '@actyx/os-sdk'

const ActyxOS = Client()

const logger: SimpleLogger = ActyxOS.consoleService.SimpleLogger({
  logName: 'myLogger',
  producerName: 'com.example.app1',
  producerVersion: '1.0.0'
})

logger.debug('this is a DEBUG message')
logger.warn('this is a WARNING message')
logger.info('this is an INFO message')
logger.error('this is an ERROR message')

logger.debug('This is a message with additional data', {foo: 'bar'})

Advanced (custom) logging

For more advanced, custom logging needs, use the log function directly:

import { Client } from '@actyx/os-sdk'

const ActyxOS = Client()

ActyxOS.consoleService.log({
  entry: {
    logName: 'myCustomLogger',
    message: 'this is a WARNING message',
    severity: LogSeverity.WARN,
    producer: {
      name: 'com.example.app1',
      version: '1.0.0'
    },
    additionalData: {
      foo: 'bar',
      bar: {
        foo: true,
      }
    },
    labels: {
      'com.example.app1.auth.username': 'john.doe',
      'com.example.app1.model.events': '10000',
    }
  },
  // Callback on successful logging
  onLogged: () => {
    // Do something
  },
  // Callback on error logging
  onError: err => {
    console.error(`error logging: ${err}`)
  }
})

There also is a corresponding version that returns a Promise:

import { Client } from '@actyx/os-sdk'

const ActyxOS = Client()

await ActyxOS.consoleService.logPromise({ /* log entry */ })

Usage

Installation

Install via npm using

npm install @actyx/os-sdk

Documentation

You can access the Typedoc documentation at https://developer.actyx.com/@actyx/os-sdk/.

Getting help

If you have questions about or issues with the ActyxOS SDK, join our Discord chat or email us at [email protected].

Advanced

Overriding the default client options

You can override the default client options by passing options (ApiClientOpts) when creating the client. If you only want to override specific options, use the default options (DefaultClientOpts) as shown in the following example:

import { Client, DefaultClientOpts } from '@actyx/os-sdk'

const clientOpts = DefaultClientOpts()
clientOpts.Endpoints.EventService.BaseUrl = 'http://10.2.3.23:4454/api'

const CustomActyxOS = Client(clientOpts)

Development

  • Build with npm run build
  • Run tests with npm run test
  • Run test including integration tests with RUN_INTEGRATION_TESTS=1 npm run test
  • Run lint / lint fix with npm run lint and npm run lint:fix
  • Publish with npm publish