# oute-services-flow-utility-sdk

> - Initialization

Latest version **0.0.86** (published 2024-06-27) · 0 weekly downloads

## Install

```sh
npm install oute-services-flow-utility-sdk
pnpm add oute-services-flow-utility-sdk
yarn add oute-services-flow-utility-sdk
bun add oute-services-flow-utility-sdk
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.86 |
| Published | 2024-06-27 |
| First published | 2024-02-12 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 168.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |

## Links

- npm: https://www.npmjs.com/package/oute-services-flow-utility-sdk
- npm.io page: https://npm.io/package/oute-services-flow-utility-sdk

## Dependencies (3)

- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [oute-services-utility-sdk](https://npm.io/package/oute-services-utility-sdk.md) ^0.0.64
- [oute-services-constants-sdk](https://npm.io/package/oute-services-constants-sdk.md) ^0.0.27

## Recent versions

- 0.0.86 (latest) — 2024-06-27
- 0.0.85 — 2024-06-26
- 0.0.84 — 2024-06-25
- 0.0.83 — 2024-06-24
- 0.0.82 — 2024-06-24
- 0.0.81 — 2024-06-21
- 0.0.80 — 2024-06-21
- 0.0.79 — 2024-06-19
- 0.0.78 — 2024-06-18
- 0.0.77 — 2024-06-17
- 0.0.76 — 2024-06-17
- 0.0.75 — 2024-06-17
- 0.0.74 — 2024-06-14
- 0.0.73 — 2024-06-10
- 0.0.72 — 2024-06-10
- … 70 more at https://npm.io/package/oute-services-flow-utility-sdk/versions

## README

# This module expose helper functions

- Initialization

```js
  var flow_utility_instance = require("oute-services-flow-utility-sdk")
```

- Clean unwanted keys from json

```js
  data = {
    key_config: {},
    a: 1
  }
  unwanted_keys = ["key_config", "task_obj"]
  result = flow_utility_instance.cleanUnwantedKeys(data, unwanted_keys)
```

- Evaluate fx block

```js
  state = {
    "1707301123322": {
      status_code: 200
    }
  }
  fx_block = {
    "type": "fx",
    "blocks": []
  }
  flow_utility_instance.fxBlock(state, fx_block)
```

- Evaluate variable

```js
  data = {
    "a": {
      "b": 1
    }
  }
  flatten_key = "\#{{a.b}}#"
  case_type = null
  nested_evaluation = true //This will decide if need to nest for the eval, default is false
  flow_utility_instance.getValue(data, flatten_key, case_type)
```

- Resolve value based on type

```js
  data = {
    "a": {
      "b": 1
    }
  }
  value = { "type": "fx", "blocks": [ { "type": "PRIMITIVES", "value": "7" }]}
  default_value = 9
  type = "INT"
  key = "id"
  case_type = null //lower, upper, caseless
  flow_utility_instance.resolveValue(data, key, value, type, default_value, case_type)
```

- Parse and validate flow inputs

```js
  input = {
    "key": "start_var1",
    "value": "sdf==>",
    "default": null,
    "type": "STRING",
    "required": false,
    "regex": null,
    "location": null
  }
  flow_utility_instance.parseAndValidate(input)
```

- get default value based on type

```js
  type = "ARRAY"
  flow_utility_instance.getDefaultValueByType(type)
```

- Parse flow inputs/outputs and generate the object

```js
  state = {
    headers: {a: 1, "content-type": "application/json"},
    body: {b: 2}
  }
  inputs = [
    {
      "key": "start_var1",
      "value": "\#{{body.b}}#",
      "default": null,
      "type": "STRING",
      "required": false,
      "regex": null,
      "location": null
    }
  ]
  update_key_by_alias = false
  flow_utility_instance.parseIO(state, inputs, update_key_by_alias)
```

- Generate state from request

```js
  req = {
    headers: {a: 1, "content-type": "application/json"},
    body: {b: 2}
  }
  inputs = [
    {
      "key": "start_var1",
      "value": "\#{{body.b}}#",
      "default": null,
      "type": "STRING",
      "required": false,
      "regex": null,
      "location": null
    }
  ]
  variables = {a: 234}
  result = flow_utility_instance.requestToStateTF(req, inputs, variables)
```

- Parse db filter for orm

```js
  state = {}
  filter = {}
  orm_type = "sequelize"
  db_type = "postgres"
  operators = Op //Sequelize operators
  flow_utility_instance.generateWhereClause(state, filter, orm_type, db_type, operators)
```

- generate order by for orm

```js
  state = {}
  inputs = [{"column": "key", "sort_by": "ASCENDING"}]
  orm_type = "sequelize"
  db_type = "postgres"
  flow_utility_instance.generateOrderByClause(state, inputs, orm_type, db_type)
```

- generate group by for orm

```js
  state = {}
  inputs = [{"column": "key"}]
  orm_type = "sequelize"
  db_type = "postgres"
  flow_utility_instance.generateGroupByClause(state, inputs, orm_type, db_type)
```

- get values using dot anotation

```js
  state = {
    "a": {
      "b": [1]
    }
  }
  flatten_key = "a.b.0"
  case_type = "caseless"
  flow_utility_instance.getValueByFlattenKeys(state, flatten_key, case_type)
```

---
_Source: https://npm.io/package/oute-services-flow-utility-sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
