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

@avatao/tfwsdk

v1.0.3

Published

This package is part of our next-gen Tutorial Framework (which just an additional abstraction layer). The purpose of the project is to decrease the learning curve of creating tutorial exercises.

Downloads

232

Readme

TFW SDK for JavaScript developers

GitHub GitHub package.json version

This package is part of our next-gen Tutorial Framework (which just an additional abstraction layer). The purpose of the project is to decrease the learning curve of creating tutorial exercises.

Installation

Install the SDK:

npm i @avatao/tfwsdk

Usage

In your solvable container you should prepare an eventHandlers.js like this:

// The SDK object
const { sdk } = require("@avatao/tfwsdk");
// The base class for more complex event handler creation
const { EventHandlerBase } = require("@avatao/tfwsdk");

function onDeployStart(currentState, completeMessage) {
  sdk.sendChatMessage(`Deploy clicked in state ${currentState}`);
  sdk.restartProcess("webservice");
  // Do some tests, etc...
  sdk.finishDeploy(); // Call with an error message to signal a failed deploy
}

function onMessageButtonClick(currentState, btnValue, completeMessage) {
  sdk.sendChatMessage(`Clicked: ${btnValue} in state ${currentState}`);
  btnValue === "yes"
    ? sdk.stepFsm(2) // Step if possible
    : sdk.stepFsm(1, {force: true}); // Force the step
}

function onIdeWrite(currentState, fileName, content, completeMessage) {
  sdk.queueChatMessages([
    `File ${fileName} was written in state ${currentState}`,
    `Content:<br>${content}`,
  ]);
}

function onTerminalCommand(currentState, command, completeMessage) {
  sdk.sendChatMessage(
    `Command \`${command}\` executed in state ${currentState}`
  );
}

// Set callbacks for the desired event key
const callbacks = {
  "deploy.start": onDeployStart,
  "message.button.click": onMessageButtonClick,
  "ide.write": onIdeWrite,
  "history.bash": onTerminalCommand,
};
sdk.start(callbacks); // Start sdk event handling

class FsmUpdateHandler extends EventHandlerBase {
  constructor() {
    super(["fsm.update"]); // Call super with the list of the keys
  }

  handleMessage(message) {
    // Implement the abstract message handler function
    if (message.key == "fsm.update" && "current_state" in message) {
      sdk.sendChatMessage(`The FSM stepped to state ${message.current_state}`);
    }
  }
}
sdk.subscribeEventHandler(new FsmUpdateHandler()); // Subscribe the eventhandler

The SDK is running in the background (with supervisor) and executes the above functions on corresponding events. Also, it provides some really useful functions to communicate with the TFW.

Contributing

Create a fork, implement your changes and open a PR for review.

Please use the conventional commit formats while contributing. We are using the Angular preset.