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

worksmith

v1.0.0

Published

A purely functional workflow engine

Downloads

104

Readme

worksmith

A seriously functional workflow library, that lets you build composable and configurable process definitions for various reasons.

npm i worksmith --save

For a step by step tutorial click here

Release notes

##Worksmith activities / task types

Worksmith comes with an extensible task library built up from the core and the extension modules.

Core activities

| group | activities | description | | ----- | ---------- | ----------- |

  • Control flow: sequence , parallel and warezSequence
  • IO: log,sql/pg
  • Tansformation: map, regex, set
  • Extensibitly: code activity , create custom task types by creating files in the tasks folder

Extension modules

| name | description | | --- | ----------- | | worksmith_salesforce | Interact with salesforce in a workflow | | worksmith_etcd | Use network based locking via etcd service | | coming | soon | | worksmith_postgres | Execute SQL statements as part of the workflow, supports transactions | | worksmith_assert | An assertion library to be used conventional workflows or workflows built for testing | | worksmith_fs | Read/write files from a workflow |

  • with worksmith you can build a complex async process chain from functional steps (tasks) - yet keep the application easy to understand and each functional step easy to developer and maintain. forget if(err) return next(err)
  • workflow steps are unaware about each other - they communicate over a shared context. WorkSmith provides an intuitive expression syntax for working with the context in a workflow definitions

usage

A workflow definition:

This can be in a config file, or as part of your js code as a variable.

{ "task": "sequence",
  "items": [
        {
            task:"log", message:"hello workflow"
        },
        {
            task: "map",
            ">insertParams": ["@req.params.id", 1, 1]
        },
        {
            task:"sql/pg",
            connection: "@connection",
            command:  "insert into order (order_id, version, type) \
                       values ($1, $2, $3) returning id",
            params:  "@insertParams",
            resultTo: "insertResult"
        },
        {...}
  ]
}

The code:


var worksmith = require('worksmith')

var workflow = worksmith('./workflow.json')


var context = {
    connection:"postgres://login:pw@host/db",
    other:"data"
}

workflow(context, function(err, result) {
    console.log("workflow completed, %", context.insertResult)
})

How to create your own activity

worksmith lets you build your activities on a super easy way Place the following code as "hello-world.js" in the tasks folder

var utils = require('worksmith')
module.exports = function (node) {
    //use the node variable to access workflow params
    return function(context) {
    //use the context to access workflow execution state
        return function(done) {
        //set done when your acitivity finished its job
        //read and write data from the context
            console.log("Hello world", context.get(node.inParam))
            context.set("myresult","myvalue")
            done();
        }
    }

}

Now you can use it the same way as the core activities

var wf = workflow( {"task":"hello-world", "inParam":"some thing"} );

var ctx = {"some":"value"};
wf(ctx, function(err) {
    console.log(ctx)
})

List of core activities

log

Write a log to the console

options

message

delay

Waits a bit

options

duration

insertDbRecord

Like the name suggests

options

table data connection resultTo

softDeleteDbRecord

deleteDbRecord

parallel

Execute sub tasks in parallel

options

items array

sequence

Execute sub tasks in sequence

options

items array

warezSequence

Define a sequence on a patching compatible way

options

items array

set

Set variable on the workflow context

options

name value