# @huma-shan/request-logic

> Main package for the Request Network logic layer.

Latest version **0.31.0** (published 2023-02-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install @huma-shan/request-logic
pnpm add @huma-shan/request-logic
yarn add @huma-shan/request-logic
bun add @huma-shan/request-logic
```

## Health

**Score 40/100 (D)** — status: abandoned.

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

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.31.0 |
| Published | 2023-02-12 |
| First published | 2022-11-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=16.0.0 |
| Dependencies | 6 |
| Unpacked size | 213.8 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 385 |
| Maintainers | huma-shan |
| Keywords | requestnetwork, request-logic |

## Links

- npm: https://www.npmjs.com/package/@huma-shan/request-logic
- Repository: https://github.com/RequestNetwork/requestNetwork
- Homepage: https://github.com/RequestNetwork/requestNetwork/tree/master/packages/request-logic#readme
- Issues: https://github.com/RequestNetwork/requestNetwork/issues
- npm.io page: https://npm.io/package/@huma-shan/request-logic

## Dependencies (6)

- [tslib](https://npm.io/package/tslib.md) 2.5.0
- [semver](https://npm.io/package/semver.md) 5.6.0
- [@huma-shan/types](https://npm.io/package/@huma-shan/types.md) 0.40.0
- [@huma-shan/utils](https://npm.io/package/@huma-shan/utils.md) 0.40.0
- [@huma-shan/multi-formatt](https://npm.io/package/@huma-shan/multi-formatt.md) 0.19.0
- [@huma-shan/advanced-logic](https://npm.io/package/@huma-shan/advanced-logic.md) 0.39.0

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 0.31.0 (latest) — 2023-02-12
- 0.30.0 — 2023-02-09
- 0.29.0 — 2023-02-07
- 0.28.8 — 2023-02-07
- 0.28.7 — 2023-02-07
- 0.28.6 — 2023-02-06
- 0.28.5 — 2023-02-03
- 0.28.4 — 2022-12-14
- 0.28.3 — 2022-12-08
- 0.28.2 — 2022-11-18
- 0.28.1 — 2022-11-18
- 0.28.0 — 2022-11-18

## README

# @huma-shan/request-logic

`@huma-shan/request-logic` is a typescript library part of the [Request Network protocol](https://github.com/RequestNetwork/requestNetwork).
It is the default implementation of the Request Logic layer. This layer is responsible for the business logic: properties and actions of requests.

Request logic creates actions, that are signed and sends them to the layer below, Transaction.

## Installation

```bash
npm install @huma-shan/request-logic
```

## Usage

See [packages/usage-examples/request-logic.ts](`packages/usage-examples/src/request-logic.ts`).

## Features

- `createRequest` : create a request
- `createEncryptedRequest` : create an encrypted request
- `acceptRequest` : accept a request
- `cancelRequest` : cancel a request
- `increaseExpectedAmountRequest` : increase the amount of a request
- `reduceExpectedAmountRequest` : reduce the amount of a request
- `getFirstRequestFromTopic` : get the first request from the actions indexed by a topic (should be used with requestId)
- `getRequestsByTopic` : get all the requests for a topic
- `computeRequestId` : compute the ID of a request before actually creating it.

## Action topics

When an action is sent to the Transaction layer, strings named topics can be attached to it. These topics are used to index the action and, therefore, allow to retrieve it later in order to reconstruct the request.

Every action has at least its request id as a topic.

When creating a request, arbitrary topics can be attached to the `createRequest` action to index the request. For example, it can be the identity of the request creator in order to be able, later, to retrieve every request created by a user. Other actions than `createRequest` doesn't need additional topics since it contains the request id that can be linked to the corresponding `createRequest` action of the request.

## Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
[Read the contributing guide](/CONTRIBUTING.md)

## License

[MIT](/LICENSE)

---
_Source: https://npm.io/package/@huma-shan/request-logic · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
