@danilolima/smjs
This project is aiming to help those who need to make a simple and maintainable state/pipeline workflow. We are at the very begging steps yet, come help us to accomplish this.
Last updated 3 months ago by danilolima .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @danilolima/smjs 
SYNC missed versions from official npm registry.

About

This project is aiming to help those who need to make a simple and maintainable state/pipeline workflow. We are at the very begging steps yet, come help us to accomplish this.

Summary

  1. Installation
  2. States Example
  3. Usage
  • CLI Command
  • Class usage
  1. Viewing the states flow
  2. State definition
  3. Task definition
  4. Choices
  5. Parameters
  6. Built-In Tasks
  • countState
  • execFile
  • httpRequest
  • printState
  • printValue
  • wait

Installation

npm install @danilolima/smjs -g

States Example (states.json)

{
    "name": "states-example",
    "initialState": "fetch-random-user",
    "parameters": {
        "NAME": "Danilo"
    },
    "tasksDir": "./tasks",
    "verbose": true,
    "states": [
        {
            "type": "Task",
            "id": "fetch-random-user",
            "task": "httpRequest",
            "httpOptions": {
                "method": "get",
                "dataType": "json",
                "url": "https://randomuser.me/api/"
            },
            "nextState": "print-value",
            "nextStateError": "print-state"
        },
        {
            "type": "Task",
            "id": "print-value",
            "task": "printValue",
            "variablePath": "$.result.data.results[0].dob.age",
            "nextState": "is-over-50"
        },
        {
            "type": "Task",
            "id": "count-retries",
            "task": "countState",
            "nextState": "wait-and-try-another-user"
        },
        {
            "type": "Choice",
            "id": "is-over-50",
            "choices": [
                {
                    "variablePath": "$.countRetries",
                    "condition": "equals",
                    "expect": 10,
                    "nextState": "max-retries-reached",
                    "label": "maxRetries"
                },
                {
                    "variablePath": "$.result.data.results[0].dob.age",
                    "condition": "lessThan",
                    "expect": 50,
                    "nextState": "count-retries"
                },
                {
                    "variablePath": "$.result.data.results[0].dob.age",
                    "condition": "greaterThanOrEqual",
                    "expect": 50,
                    "nextState": "finish"
                }
            ]
        },
        {
            "type": "Wait",
            "id": "wait-and-try-another-user",
            "nextState": "fetch-random-user",
            "timeout": 1000
        },
        {
            "type": "Task",
            "id": "max-retries-reached",
            "nextState": "finish"
        },
        {
            "type": "Task",
            "id": "print-state",
            "task": "printState",
            "nextState": "finish"
        },
        {
            "type": "Task",
            "id": "finish",
            "end": true
        }
    ]
}

Usage

smjs run states.json

ExampleConsole

View

smjs view states.json

Diagram

Built-In Tasks

wait

Field Description
timeout Set timeout value

Current Tags

  • 0.1.8-beta                                ...           latest (3 months ago)

7 Versions

  • 0.1.8-beta                                ...           3 months ago
  • 0.1.7-beta                                ...           3 months ago
  • 0.1.6-beta                                ...           3 months ago
  • 0.1.4-beta                                ...           a year ago
  • 0.1.3-beta                                ...           a year ago
  • 0.1.2-beta                                ...           a year ago
  • 0.1.1-beta                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 7
Last Day 0
Last Week 7
Last Month 0
Dependencies (11)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |