# domain-workflow

> Human readable workflows with error handling made easy

Latest version **0.0.3** (published 2021-09-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install domain-workflow
pnpm add domain-workflow
yarn add domain-workflow
bun add domain-workflow
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2021-09-15 |
| First published | 2021-09-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 14.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Bartosz Michalkiewicz |
| Maintainers | bmichalkiewicz |
| Keywords | ddd, domain driven development, workflow, error handling, functional programming, typescript |

## Links

- npm: https://www.npmjs.com/package/domain-workflow
- Repository: https://github.com/b-michalkiewicz/domain-workflow
- Homepage: https://github.com/b-michalkiewicz/domain-workflow#readme
- Issues: https://github.com/b-michalkiewicz/domain-workflow/issues
- npm.io page: https://npm.io/package/domain-workflow

## Dependencies (1)

- [exceptionout](https://npm.io/package/exceptionout.md) ^0.0.7

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.0.3 (latest) — 2021-09-15

## README

# domain-workflow

## Human readable workflows with error handling made easy.

Express your workflows in explicit form so anyone can understand and/or write them:

```typescript
type ParseStringToNumberError = {
    message: string;
};

type ParseStringToNumber = (_: string) => Either<ParseStringToNumberError, number>;
type NumberProcessor = (_: number) => number;
type NumberFormatter = (_: number) => string;

type FancyWorkflow = Workflow<[ParseStringToNumber, NumberProcessor, NumberFormatter]>;
```

-   `FancyWorkflow` is statically validated and it's result will be `Either<ParseStringToNumberError, string>`.
-   If we mess up your stages inputs and outputs or mix `sync`/`async` type your workflow will have `never` type so you cannot do anything with it.

Write the implementation of the stages elsewhere not to scare/bore the business team then run your workflow by:

```typescript
const fancyWorkflow: FancyWorkflow = [parseStringToNumber, numberProcessor, numberFormatter];
const fancyWorkflowResult = runWorkflow(fancyWorkflow)("42");
// fancyWorkflowResult is type is Either<ParseStringToNumberError, string>
```

Don't need to worry if the previous step is an async operation or can fail as all of these are handled automatically so you can focus on writing your stages in separation.

### Notes

Read [this](https://github.com/b-michalkiewicz/exceptionout#Either) to understand how `Either` type works.

This library was inspired by [Domain Modeling Made Functional](https://pragprog.com/titles/swdddf/domain-modeling-made-functional/) and [The Pragmatic Programmer](https://pragprog.com/titles/tpp20/the-pragmatic-programmer-20th-anniversary-edition/) (part about `Transforming Programming`) books.

---
_Source: https://npm.io/package/domain-workflow · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
