Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 1 addition & 80 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,80 +1 @@
![][header-image]

[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/sammarks/workflow/Build%20and%20Release)
[![Coveralls](https://img.shields.io/coveralls/sammarks/workflow.svg)](https://coveralls.io/github/sammarks/workflow)
[![Dev Dependencies](https://david-dm.org/sammarks/workflow/dev-status.svg)](https://david-dm.org/sammarks/workflow?type=dev)
[![Donate](https://img.shields.io/badge/donate-paypal-blue.svg)](https://paypal.me/sammarks15)

`workflow` is a Node JS library designed to facilitate the execution of simple workflows with
rollback support. This allows you to take small units of code and combine them together into
a larger workflow to accomplish a single large task.

See [the documentation](https://sammarks.github.io/workflow/) for more details.

## Get Started

```sh
npm install @sammarks/workflow
yarn add @sammarks/workflow
```

```typescript
import { execute } from '@sammarks/workflow'

interface WorkflowContext {
firstStepRun: boolean
secondStepRun: boolean
test: string
}

const workflow = [
{
name: 'first',
run: async (context: WorkflowContext): Promise<void> => {
context.firstStepRun = true
},
revert: async (context: WorkflowContext): Promise<void> => {
context.firstStepRun = false
}
},
{
name: 'second',
run: async (context: WorkflowContext): Promise<void> => {
context.secondStepRun = true
},
revert: async (context: WorkflowContext): Promise<void> => {
context.secondStepRun = false
}
}
]

const result = await execute<WorkflowContext>('test-workflow', workflow, { test: 'foo' })
console.log(result)

// {
// firstStepRun: true,
// secondStepRun: true,
// test: 'foo'
// }
```

## Features

- Define steps in a simple, typed, array-object format.
- Steps and workflows are given names for debugging support.
- Rollback support in case a step fails.
- Predictable and documented error handling in case something goes wrong.

## Why use this?

Breaking the large task into smaller units of code allows a less complicated end result, and greater
unit testing abilities since each step in the workflow is broken into its own function.

Rollback support allows a transactional nature for executing workflows. If one step in the process
fails to execute, all previously-executed steps with a configured rollback are executed.

`workflow` provides TypeScript hinting and a predictable error interface to handle issues when they
arise.

[header-image]: https://raw.githubusercontent.com/sammarks/art/master/workflow/header.jpg
This is a fork of [@sammarks/workflow](https://www.npmjs.com/package/@sammarks/workflow).
15 changes: 15 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import eslint from '@eslint/js'
import tseslint from 'typescript-eslint'

export default tseslint.config(
{ ignores: ['coverage/**', 'dist/**', 'docs/**'] },
eslint.configs.recommended,
...tseslint.configs.recommended,
{
files: ['src/**/*.ts', 'test/**/*.ts'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
},
}
)
4 changes: 0 additions & 4 deletions jest.config.js

This file was deleted.

Loading