open-index/open-npm huggingface dataset:
npm package: @mimik/metrics-helper
Description: Metrics helper for microservices
Author: mimik technology inc
Latest version: 2.1.1

<a name="module_metricsHelper"></a>

## metricsHelper
Importing this module automatically starts collecting default Node.js metrics
(event loop, GC, heap, etc.) via `prom-client.collectDefaultMetrics()`.

**Example**  
```js
import { Prometheus, APIRequestDuration, HTTPRequestDuration, EventCounter } from '@mimik/metrics-helper';
// or
import metricsHelper from '@mimik/metrics-helper';
```

* [metricsHelper](#module_metricsHelper)
    * [~register](#module_metricsHelper..register)
    * [~APIRequestDuration](#module_metricsHelper..APIRequestDuration)
    * [~HTTPRequestDuration](#module_metricsHelper..HTTPRequestDuration)
    * [~EventCounter](#module_metricsHelper..EventCounter)
    * _sync_
        * [~Prometheus()](#module_metricsHelper..Prometheus)

<a name="module_metricsHelper..register"></a>

### metricsHelper~register
Register to accumulate all the results

**Kind**: inner constant of [<code>metricsHelper</code>](#module_metricsHelper)  
<a name="module_metricsHelper..APIRequestDuration"></a>

### metricsHelper~APIRequestDuration
Histogram metrics for API calls. The buckets are [5, 10, 20, 60, 150, 400, 1000] in ms.

**Kind**: inner constant of [<code>metricsHelper</code>](#module_metricsHelper)  
<a name="module_metricsHelper..HTTPRequestDuration"></a>

### metricsHelper~HTTPRequestDuration
Histogram metrics for HTTP requests. The buckets are [50, 150, 300, 600, 1200, 2000, 2800, 3600] in ms.

**Kind**: inner constant of [<code>metricsHelper</code>](#module_metricsHelper)  
<a name="module_metricsHelper..EventCounter"></a>

### metricsHelper~EventCounter
Counter for the events sent to the topic associated with the process.

**Kind**: inner constant of [<code>metricsHelper</code>](#module_metricsHelper)  
<a name="module_metricsHelper..Prometheus"></a>

### metricsHelper~Prometheus()
The prom-client module. Use to create custom metrics (e.g. new Prometheus.Gauge(...)).

**Kind**: inner method of [<code>metricsHelper</code>](#module_metricsHelper)  
**Category**: sync
npm package: @mimik/pagination-helper
Description: Pagination helper for microservices
Author: mimik technology inc
Latest version: 3.1.3

<a name="module_pagination-helper"></a>

## pagination-helper
**Example**  
```js
import { setUrlOnPaginatedResult, validatePaginationOptions } from '@mimik/pagination-helper';
```
**Example**  
```js
import paginationHelper from '@mimik/pagination-helper';
```

* [pagination-helper](#module_pagination-helper)
    * [~setUrlOnPaginatedResult(data, options, basePath, serverSettings)](#module_pagination-helper..setUrlOnPaginatedResult) ⇒ <code>object</code>
    * [~validatePaginationOptions(options)](#module_pagination-helper..validatePaginationOptions) ⇒ <code>boolean</code>

<a name="module_pagination-helper..setUrlOnPaginatedResult"></a>

### pagination-helper~setUrlOnPaginatedResult(data, options, basePath, serverSettings) ⇒ <code>object</code>
The response is an object of the following format:
``` javascript
 {
   "data": "an array of items result of paginated search.",
   "count": "a number. Present if provided.",
   "nextPageUrl": "a URL to point to the next page. Present if the data length is greater than or equal to the given pageSize and lastRecordId is provided."
 }
```

**Kind**: inner method of [<code>pagination-helper</code>](#module_pagination-helper)  
**Returns**: <code>object</code> - The response object with `data` (array), optional `count` (number), and optional `nextPageUrl` (string). Present when `data.length >= pageSize` and `lastRecordId` is provided.  
**Category**: sync  
**Requires**: <code>module:@mimik/address-helper</code>  

| Param | Type | Description |
| --- | --- | --- |
| data | <code>array</code> | data to include in the response. |
| options | <code>object</code> | options to setup the response. Includes `count`, `lastRecordId` and `pageSize`. |
| basePath | <code>string</code> | url base path in order to build the `nextPageUrl`. Can include queries. |
| serverSettings | <code>object</code> | Server settings to build the `nextPageUrl`. |

<a name="module_pagination-helper..validatePaginationOptions"></a>

### pagination-helper~validatePaginationOptions(options) ⇒ <code>boolean</code>
Validating the pagination params.

**Kind**: inner method of [<code>pagination-helper</code>](#module_pagination-helper)  
**Returns**: <code>boolean</code> - `true`.  
**Category**: sync  
**Throws**:

- <code>object</code> An error (vError) with statusCode `400`.

**Requires**: <code>module:@mimik/response-helper</code>  

| Param | Type | Description |
| --- | --- | --- |
| options | <code>object</code> | options to validate. Includes `startAfter` and `pageSize`. |
npm package: @mimik/rediser
Description: Redis connection helper for mimik microservices
Author: mimik technology inc
Latest version: 2.1.3

<a name="module_rediser"></a>

## rediser
**Example**  
```js
import rediser from '@mimik/rediser';
```

* [rediser](#module_rediser)
    * [module.exports(set, config)](#exp_module_rediser--module.exports) ⇒ <code>object</code> ⏏
        * _async_
            * [~validate()](#module_rediser--module.exports..validate) ⇒ <code>Promise</code>
        * _sync_
            * [~initializeSync()](#module_rediser--module.exports..initializeSync) ⇒ <code>object</code> \| <code>null</code>

<a name="exp_module_rediser--module.exports"></a>

### module.exports(set, config) ⇒ <code>object</code> ⏏
Creates a Redis connection manager.

**Kind**: Exported function  
**Returns**: <code>object</code> - An object with `initializeSync` and `validate` methods.  

| Param | Type | Description |
| --- | --- | --- |
| set | <code>string</code> | Whether redis is enabled ('on' or 'off'). |
| config | <code>object</code> | The application configuration object. |
| config.redisSettings | <code>object</code> | Redis-specific settings. |

<a name="module_rediser--module.exports..validate"></a>

#### module.exports~validate() ⇒ <code>Promise</code>
Database connection validation.

**Kind**: inner method of [<code>module.exports</code>](#exp_module_rediser--module.exports)  
**Returns**: <code>Promise</code> - Resolves with null on success.  
**Category**: async  
**Throws**:

- <code>Error</code> Will throw an error if the database connection is not `connected` and is not `disconnected`.

Will exit 1 if the connection request times out and the connection state is not `connected`.

**Requires**: <code>module:@mimik/sumologic-winston-logger</code>  
**Fulfil**:  Return `null`.  
<a name="module_rediser--module.exports..initializeSync"></a>

#### module.exports~initializeSync() ⇒ <code>object</code> \| <code>null</code>
Database initialization.

**Kind**: inner method of [<code>module.exports</code>](#exp_module_rediser--module.exports)  
**Returns**: <code>object</code> \| <code>null</code> - The database client, or null if cache is not enabled.  
**Category**: sync  
**Requires**: <code>module:@mimik/sumologic-winston-logger</code>
npm package: @mimik/request-helper
Description: HTTP request helper for mimik microservices
Author: mimik technology inc
Latest version: 2.0.7

<a name="module_request-helper"></a>

## request-helper
**Example**  
```js
// default import
import requestHelper from '@mimik/request-helper';
```
**Example**  
```js
// named imports
import { getCorrelationId, getUserAgent, setUserAgent } from '@mimik/request-helper';
```

* [request-helper](#module_request-helper)
    * [~getCorrelationId([request])](#module_request-helper..getCorrelationId) ⇒ <code>string</code>
    * [~getUserAgent(request)](#module_request-helper..getUserAgent) ⇒ <code>string</code> \| <code>null</code>
    * [~setUserAgent()](#module_request-helper..setUserAgent) ⇒ <code>string</code>

<a name="module_request-helper..getCorrelationId"></a>

### request-helper~getCorrelationId([request]) ⇒ <code>string</code>
Extract or generate a correlationId in the format `uuid@step/date`.
Reads the `x-correlation-id` or `X-Correlation-Id` header from the request and increments the step.
If no correlationId exists, generates a new one with step 0 and the current timestamp.
If the step is not a number, it is reset to 0.

**Kind**: inner method of [<code>request-helper</code>](#module_request-helper)  
**Returns**: <code>string</code> - The correlationId in `uuid@step/date` format.  
**Category**: sync  

| Param | Type | Description |
| --- | --- | --- |
| [request] | <code>object</code> \| <code>string</code> | The request object with headers, or a correlationId string. Other types generate a new correlationId. |

<a name="module_request-helper..getUserAgent"></a>

### request-helper~getUserAgent(request) ⇒ <code>string</code> \| <code>null</code>
Extract the `user-agent` header from the request.

**Kind**: inner method of [<code>request-helper</code>](#module_request-helper)  
**Returns**: <code>string</code> \| <code>null</code> - The user-agent string, or null if not available.  
**Category**: sync  

| Param | Type | Description |
| --- | --- | --- |
| request | <code>object</code> | The request object containing headers. |

<a name="module_request-helper..setUserAgent"></a>

### request-helper~setUserAgent() ⇒ <code>string</code>
Build a user-agent string identifying this server instance.
Returns a string in the format `mimik-type/version/id (platform; arch; runtime)`.

The following environment variables are optionally used:

| Env variable name | Description | Default | Comments |
| ----------------- | ----------- | ------- | -------- |
| SERVER_TYPE | type of the server instance that makes the call | genericType | for defining the agent
| SERVER_VERSION | version of the server instance that makes the call | 1.0 | for defining the agent
| SERVER_ID | id of the server instance that makes the call | generic | for defining the agent

**Kind**: inner method of [<code>request-helper</code>](#module_request-helper)  
**Returns**: <code>string</code> - The user-agent string to be added to outgoing requests.  
**Category**: sync
npm package: @mimik/swagger-mw-codegen
Description: contains a template-driven engine to generate an express-like middleware for mimOE mims
Author: mimik technology inc
Latest version: 2.1.1

# swagger-mw-codegen [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE) [![npm version](https://badge.fury.io/js/%40mimik%2Fswagger-mw-codegen.svg)](https://www.npmjs.com/package/@mimik/swagger-mw-codegen)


## Overview
contains a template-driven engine to generate a express-like middleware for edgeSDK serverless microservice

[Learn how to use in your own project](https://developer.mimik.com).

## Quick Start
- Use the config/example.yml to create a default.yml
- "name" from the default.yml is the name of the API
- "swagger" from the default.yml is the location of the API.  If it is hosted on the cloud, you can use https://api.swaggerhub.com/apis/mimik/mCommunities/1.0.0
- npm install
- node index.js
- the generated middleware will be in the same folder as the index.js

## Supports
- https://developer.mimik.com

## License
[MIT licensed](./LICENSE).
npm package: @mimik/systeminfo-filters
Description: filter definition for systemInfo
Author: mimik technology inc
Latest version: 2.1.1

<a name="module_systeminfo-filters"></a>

## systeminfo-filters
**Example** *(Default import)*  
```js
import systeminfoFilters from '@mimik/systeminfo-filters';
```
**Example** *(Named import)*  
```js
import { configFilter } from '@mimik/systeminfo-filters';
```
<a name="module_systeminfo-filters..configFilter"></a>

### systeminfo-filters~configFilter : <code>Array.&lt;String&gt;</code>
Array of JSONPath strings defining sensitive configuration fields to mask in logs.
Used by `@mimik/lib-filters` `logs()` to replace matched values with a mask.

**Kind**: inner constant of [<code>systeminfo-filters</code>](#module_systeminfo-filters)
npm package: @mimik/user-filters
Description: filter definitions for user
Author: mimik technology inc
Latest version: 2.1.0

<a name="module_user-filters"></a>

## user-filters
**Example**  
```js
import { userDefinitions, validateDetail } from '@mimik/user-filters';
// or
import userFilters from '@mimik/user-filters';
```

* [user-filters](#module_user-filters)
    * _static_
        * [.userDefinitions](#module_user-filters.userDefinitions) : <code>Object.&lt;string, UserDefinition&gt;</code>
        * _sync_
            * [.validateDetail](#module_user-filters.validateDetail) ⇒ <code>string</code>
    * _inner_
        * [~UserDefinition](#module_user-filters..UserDefinition) : <code>object</code>

<a name="module_user-filters.userDefinitions"></a>

### user-filters.userDefinitions : <code>Object.&lt;string, UserDefinition&gt;</code>
Predefined user filter definitions keyed by detail level.

**Kind**: static constant of [<code>user-filters</code>](#module_user-filters)  
**Properties**

| Name | Type | Description |
| --- | --- | --- |
| all | <code>UserDefinition</code> | All user attributes and properties including name and location. |
| basic | <code>UserDefinition</code> | Basic user attributes and properties. |
| references | <code>UserDefinition</code> | Basic user attributes and properties plus references. |

<a name="module_user-filters.validateDetail"></a>

### user-filters.validateDetail ⇒ <code>string</code>
Validate the user detail.

**Kind**: static constant of [<code>user-filters</code>](#module_user-filters)  
**Returns**: <code>string</code> - The selected detail.  
**Category**: sync  
**Throws**:

- Will throw an error if definitions is not an object or the detail is invalid.


| Param | Type | Description |
| --- | --- | --- |
| definitions | <code>Object.&lt;string, UserDefinition&gt;</code> | Predefined user filter definitions keyed by detail level. |
| detail | <code>string</code> | Detail selected for the user (e.g. 'all', 'basic', 'references'). |

<a name="module_user-filters..UserDefinition"></a>

### user-filters~UserDefinition : <code>object</code>
Configuration for the user filter.

**Kind**: inner typedef of [<code>user-filters</code>](#module_user-filters)  
**Properties**

| Name | Type | Description |
| --- | --- | --- |
| attributes | <code>Array.&lt;string&gt;</code> | User attributes to include (e.g. 'nickname', 'firstname', 'lastname'). |
| properties | <code>Array.&lt;string&gt;</code> | User properties to include (e.g. 'nickName', 'displayName', 'email'). |
npm package: @mimik/userlib
Description: user library for mimik services
Author: mimik technology inc
Latest version: 2.1.1

<a name="module_userlib"></a>

## userlib
**Example**  
```js
import { partialUser } from '@mimik/userlib';
// or
import UserLib from '@mimik/userlib';
```
<a name="module_userlib..partialUser"></a>

### userlib~partialUser(user, selectedUser) ⇒ <code>Object</code>
Get partial user.

**Kind**: inner method of [<code>userlib</code>](#module_userlib)  
**Returns**: <code>Object</code> - The partial user with matched properties and filtered attributes.  
**Category**: sync

Note: The &#x60;attributes&#x60; key is always handled via &#x60;selectedUser.attributes&#x60;, never via &#x60;selectedUser.properties&#x60;.  

| Param | Type | Description |
| --- | --- | --- |
| user | <code>object</code> | The user to filter. |
| user.attributes | <code>Array.&lt;{name: string, value: string}&gt;</code> | The user's attributes. |
| selectedUser | <code>object</code> | The filter to apply on the `user`. |
| selectedUser.properties | <code>Array.&lt;string&gt;</code> | The top-level property names to include. |
| selectedUser.attributes | <code>Array.&lt;string&gt;</code> | The attribute names to include. |