open-index/open-npm huggingface dataset:
npm package: @sealsystems/mongo-notification
Description: An event emitter that uses MongoDB capped collections.
Author: SEAL Systems AG
Latest version: 1.5.25

# @sealsystems/mongo-notification


An event emitter and receiver that uses MongoDB capped collections.

## Installation

```shell
$ npm install @sealsystems/mongo-notification
```

## Quick start

First you need to add a reference to @sealsystems/mongo-notification to your application.

```javascript
const mongoNotification = require('@sealsystems/mongo-notification');
```

Then connect to a MongoDB by calling the function `mongoNotification`. Provide an options object and returns a notification event emitter:

```javascript
const notification = await mongoNotification({
  url: 'mongodb://...',
  topic: 'messages',
  collectionSize: '1MB',
  writeOnly: false
});
```

The options contain:
- `url` mandatory, a connection string,
- `topic` mandatory, the name of a topic collection
- `collectionSize` optional, the size of the capped collection, default: 1MB
- `writeOnly` optional, the open mode, default: false
- Additional [@sealsystems/mongo](https://github.com/sealsystems/node-mongo) options

## Emit events

Call the `emit` function for actually emitting an event:

```javascript
notification.emit('foo', { foo: 'bar' });
```

Optionally you may specify a callback to get notified when the event has been persisted:

```javascript
notification.emit('foo', { foo: 'bar' }, (err) => {
  // ...
});
```

## Receive events

If you want to receive events send by your application use the `on` function:

```javascript
notification.on('foo', (payload) => {
  // ...
});
```

## Write only mode

If you only want to emit events but not receive any you can set the `writeOnly` option to `true` when connecting.

```javascript
const notification = await mongoNotification({
  ...
  writeOnly: true
});
```


## Running the build

To build this module use [roboter](https://www.npmjs.com/package/roboter).

```shell
$ bot
```
npm package: @sealsystems/node-failure
Description: Easy handling of error codes and metadata.
Author: SEAL Systems AG
Latest version: 1.0.0
Deprecated: Please use @sealsystems/failure.

# @sealsystems/failure

Easy handling of error codes and metadata.

## Installation

```bash
npm install @sealsystems/failure
```

## Quick start

First you need to add a reference to @sealsystems/failure within your application.

```javascript
const failure = require('@sealsystems/failure');
```

Then you can create an error object.

```javascript
const err = failure(42, 'Universal error.', { username: 'hugo' });
```

This creates an object of type `Error` with some additional properties:

```javascript
{
  name: 'SealError',
  code: 42,
  message: 'Universal error',
  metadata: {
    username: 'hugo'
  }
  ...
}
```

## API

### Creating an error objects

Create a new object of type `Error`.

```javascript
const error = failure(code, message, metadata);
```

Parameter:
```
code       number   optional    error code
message    string   mandatory   error message
metadata   object   optional    error metadata
```

Result: new error object

### Join metadata

Join metadata and error object metadata into a new metadata object for extended logging.

**Attention**: This function does not alter the errors metadata, it just returns a new metadata object.

```javascript
const joinedMeta = failure.joinMeta(error, metadata);
```

Parameter:
```
error      object   mandatory   previously created error object
metadata   object   mandatory   additional metadata to join
```

Result: new metadata object

### Export plain object

Export a plain new object for return in REST-API.

```javascript
const plainNewObject = failure.httpExport(error);
```

Parameter:
```
error      object   mandatory   previously created error object
```

Result: new plain javascript object of this structure:

```javascript
{
  code: error.code,
  message: error.message,
  metadata: error.metadata
}
```

### Export JSON string

Export plain error object as JSON string for return in REST-API without bodyparser.

```javascript
const stringifiedObject = failure.jsonHttpExport(error);
```

Parameter:
```
error      object   mandatory   previously created error object
```

Result: JSON string of plain object created by `httpExport`
npm package: @sealsystems/odata-mongo
Description: @sealsystems/odata-mongo is a middleware that translates OData to MongoDB queries.
Author: SEAL Systems AG
Latest version: 1.0.0

# @sealsystems/odata-mongo

@sealsystems/odata-mongo is a middleware that translates [OData](http://www.odata.org/) to MongoDB queries. [OData Version 2.0](http://www.odata.org/documentation/odata-version-2-0/uri-conventions/) URI conventions are supported.

## Installation

```bash
npm install @sealsystems/odata-mongo
```

## Quick start

First you need to add a reference to @sealsystems/odata-mongo within your application.

```javascript
const odataMongo = require('@sealsystems/odata-mongo');
```

Then you can enable Express routes to handle incoming OData queries. For that, add the middleware to the appropriate route. Within the route you then can access the `req.mongo.query` and `req.mongo.queryOptions` objects that contain the query and the query options for MongoDB.

```javascript
app.get('/data', odataMongo(), (req, res) => {
  db.collection('...').find(req.mongo.query, req.mongo.queryOptions).toArray((err, docs) => {
    // ...
  });
});
```

In case the client sends an invalid OData expression, the middleware responds with a `400` status code.

### supported OData keys

* `$filter`
* `$top` - limit the result to N elements
* `$skip` - skip N elements of the query
* `$select` - list of result properties
* `$top` - limit the result list to N
* `$select` - list of result properties
* `$inlinecount` - if missing or set to `none` the response is the result array. If set to `allpages` the response is an object with `results` as the result array and `totalCount` with the total count of entries found for this query
* `$orderby` - sort by a field

## Running the build

Builds and releases are triggered on GitHub by dependabot if commit comment starts with `fix:` or `feat:`.
npm package: @sealsystems/pattern-replace-stream
Description: Transform a stream using a replace pattern
Author: SEAL Systems AG
Latest version: 1.0.0

# @sealsystems/pattern-replace-stream

Replaces pattern in a text stream.

**Please note:** This module only modifies one data chunk after another. Patterns that span multiple chunks will not be recognized!

## Installation

```shell
npm install @sealsystems/pattern-replace-stream
```

## Quick start

First you need to add a reference to @sealsystems/pattern-replace-stream within your application.

```javascript
const PatternReplaceStream = require('@sealsystems/pattern-replace-stream');
```

Now, you can create a filter stream and connect it with :

```javascript
const process = require('process');

const PatternReplaceStream = require('@sealsystems/pattern-replace-stream');

// Create stream to replace all occurences of 'a' with '1'
const stream = new PatternReplaceStream({ regexp: /a/g, replacement: '1' })

// Use pipe() to cennect it with input and output streams
process.stdin.pipe(stream).pipe(process.stdout);

// -> Any input via stdin will be modified and printed to stdout
```

If the encoding of incoming text is not specified, UTF-8 will be assumed by default. To change this default, use the option `defaultEncoding`:

```javascript
// Treat data as ASCII text by default
const stream = new PatternReplaceStream({ regexp: /a/g, replacement: '1', defaultEncoding: 'ascii' })
```
npm package: @sealsystems/profiling
Description: Captures profiling data
Author: SEAL Systems AG
Latest version: 1.2.6

# @sealsystems/profiling

[![CircleCI](https://circleci.com/gh/sealsystems/node-profiling.svg?style=svg)](https://circleci.com/gh/sealsystems/node-profiling)
[![AppVeyor](https://ci.appveyor.com/api/projects/status/ekl6ge2ty0edw6qa?svg=true)](https://ci.appveyor.com/project/Plossys/node-profiling)

@sealsystems/profiling captures profiling data.

## Installation

```bash
$ npm install @sealsystems/profiling
```

## Quick Start

First you need to integrate @sealsystems/profiling into your application.

```javascript
const profiling = require('@sealsystems/profiling');
```

It will capture the CPU usage and memory consumption once per minute.

To gather custom values, call `noteValue` with a key and value pair.

```javascript
profiling.noteValue('foo', 23);
```

## Activate profiling

By default, profiling is disabled. To enable it, provide the host and the port of a running [StatsD](https://github.com/etsy/statsd) server using the `STATSD_URL` environment variable.

```bash
export STATSD_URL=udp://localhost:8125
```

 In order to distinguish between different apps, each running instance generates a random UUID and includes it in the path of the keys sent to the StatsD server. To provide a fix identifier, set the `SERVICE_NAME` environment variable.

```bash
export SERVICE_NAME=MyService
```

## Collecting the data

To actually collect profiling data, you need to start a StatsD server. For development purposes, simply run:

```bash
docker run -d --name statsd -p 80:80 -p 2003:2003 -p 8125:8125/udp hopsoft/graphite-statsd
```

You can access the server's web ui via port 80 of your Docker host, e.g. http://localhost/.

To stop the StatsD container again, type:

```bash
docker stop statsd
```

## Running the build

To build this module use [roboter](https://www.npmjs.com/package/roboter).

```bash
$ bot
```
npm package: @sealsystems/release-notes-generator
Description: Generate release notes from commit messages
Author: SEAL Systems AG
Latest version: 0.3.22

# release-notes-generator

Generate release notes from commit messages

## Getting started

Run this app from inside a git repository. You must provide the last and current released version as parameters. It parses all commit messages between these versions and prints the release notes to standard out.

Sample:

```shell
npx @sealsystems/release-notes-generator <previous version> <current version>
```

## Implementation details

**Please note:** This module is part of the build and release infrastructure. In order to prevent endless loops when automatically updating dependencies via Dependabot, devDependencies are not included in the [config file](.dependabot/config.yml).
npm package: @sealsystems/request-service
Description: Makes a request to a service, using consul for discovery and lookup
Author: SEAL Systems AG
Latest version: 4.3.4

# @sealsystems/request-service


Makes a request to a service, using consul for discovery and lookup.

## Installation

```shell
$ npm install @sealsystems/request-service
```

## Quick start

First you need to add a reference to @sealsystems/request-service within your application.

```javascript
const requestService = require('@sealsystems/request-service');
```

**Please note:** A connection to consul must already exist before you can use the module.

To create a HTTP/HTTPS request to an instance of a service use:

```javascript
const consul = require('@sealsystems/consul');
consul.connect(...);

const req = await requestService({ consul, service: 'myService' });

req.on('connect', () => {
  console.log('Connected to service!');
});

req.write('Hello service!');
req.end();
```

The first parameter is an `options` object that can contain the following properties:

| property     | type            | description                                                                              |
|--------------|-----------------|------------------------------------------------------------------------------------------|
| consul       | required object | Consul client for service discovery                                                      |
| service      | required string | Name of the service to access                                                            |
| headers      | optional object | Additional HTTP/HTTPS headers                                                            |
| method       | optional string | HTTP/HTTPS method, default `POST`                                                        |
| path         | optional string | URL-path to access, default `/`                                                          |
| responseType | optional string | Read JSON response and return it as object. Possible value: `json`                       |
| json         | optional object | Only valid together with `responseType`. Send object given in `json` property to service |

Here is an example of a more complete `options` object:

```javascript
const options = {
  consul,
  headers: {
    'content-type': 'application/json'
  },
  method: 'POST',
  path: '/job',
  service: 'myService'
};
```

The return value `req` contains a [http.ClientRequest](https://nodejs.org/api/http.html#http_class_http_clientrequest) object for further use.

## HTTP and HTTPS

The protocol used for a connection depends on the target (the service resides in the local or a remote host) and the value of the environment variable TLS_UNPROTECTED. The TLS certificates provided by `@sealsystems/tlscert` will be used for HTTPS connections. It is not possible to override the chosen protocol.

Used protocol:

| TLS_UNPROTECTED | local service | remote service |
| --------------- | ------------- | -------------- |
| 'world'         | HTTP          | HTTP           |
| 'loopback'      | HTTP          | HTTPS          |
| 'none'          | HTTPS         | HTTPS          |
npm package: @sealsystems/semantic-release
Description: Semantic Release executable and configuration for SEAL Systems
Author: SEAL Systems AG
Latest version: 4.3.12

# semantic-release

Semantic Release executable and configuration for SEAL Systems

## Getting started

First, you have to install the module as a development dependency:

```shell
npm install --save-dev @sealsystems/semantic-release
```

Please note:

- In order to install all dependencies directly in the project's `node_modules` folder, you may need to delete `package-lock.json` before adding this package.

The following release configurations are available:

- Generic release
- Node.js module
- Node.js binary

### Generic release

This configuration is used to create a release on GitHub. It updates the CHANGELOG.md, created a release tag, and publishes the release on the release page.  

To create binary releases, insert the following lines into your package.json:

```
"release": {
  "extends": "@sealsystems/semantic-release/generic",
}
```

### Node.js module

This configuration is used for Node.js modules. It performs the same steps as a binary release. In addition it also uploads the new release to a NPM registry.

To release a Node.js module, insert the following lines into your package.json:

```
"release": {
  "extends": "@sealsystems/semantic-release/node-module"
}
```

### Node.js binary

This configuration is used for Node.js executables (e.g. services). It performs almost the same steps as a module release excapt for publishing it on NPM.

To release a Node.js binary, insert the following lines into your package.json:

```
"release": {
  "extends": "@sealsystems/semantic-release/node-binary"
}
```

## Calling the release script

This module provides an NPM executable that calls `semantic-release`. To use it, add the following to the script section of your `package.json`:

```json
"scripts": {
  "release": "release"
}
```

Now, your CI server can run it:

```bash
npm run release
```

## Implementation details

**Please note:** If you add new JavaScript files to the root folder (or any other than the `lib` folder), you have to update the [.npmignore template](https://github.com/sealsystems/generator-seal-node/blob/master/lib/tasks/oss-module/update/templates/_npmignore) in `generator-seal-node`.
npm package: @sealsystems/semantic-release-config
Description: Configuration for semantic releases at SEAL Systems
Author: SEAL Systems AG
Latest version: 3.3.0

# semantic-release-config

Configuration for semantic releases at SEAL Systems

## Getting started

First, you have to install the module as a development dependency:

```shell
npm install --save-dev @sealsystems/semantic-release-config
```

The following release configurations are available:

- Generic release
- Node.js module
- Node.js binary

### Generic release

This configuration is used to create a release on GitHub. It updates the CHANGELOG.md, created a release tag, and publishes the release on the release page.  

To create binary releases, insert the following lines into your package.json:

```
"release": {
  "extends": "@sealsystems/semantic-release-config/generic",
}
```

### Node.js module

This configuration is used for Node.js modules. It performs the same steps as a binary release. In addition it also uploads the new release to a NPM registry.

To release a Node.js module, insert the following lines into your package.json:

```
"release": {
  "extends": "@sealsystems/semantic-release-config/node-module"
}
```

### Node.js binary

This configuration is used for Node.js executables (e.g. services). It performs almost the same steps as a module release excapt for publishing it on NPM.

To release a Node.js binary, insert the following lines into your package.json:

```
"release": {
  "extends": "@sealsystems/semantic-release-config/node-binary"
}
```

## Calling the release script

This module provides an NPM executable that calls `semantic-release`. To use it, add the following to the script section of your `package.json`:

```json
"scripts": {
  "release": "release",
}
```

Now, your CI server can run it:

```bash
npm run release
```
npm package: @sealsystems/service-protocol
Description: Determine protocol for connecting to service
Author: SEAL Systems AG
Latest version: 2.1.0

# node-service-protocol

Determine protocol for connecting to a service using consul for resolving local hostname if necessary.

The environment variable `TLS_UNPROTECTED` is used with the folowing values:

- `none` No unprotected connections are used and `getProtocol` always returns `https`
- `world` All connections are unprotected and `getProtocol` always returns `http`
- `loopback` (default) Connections to localhost are unprotected and `getProtocol` returns `http`, external connections are protected and `getProtocol` return `https`.

## Installation

```bash
npm install @sealsystems/service-protocol
```

## Usage

```javascript
const serviceProtocol = require('@sealsystems/service-protocol');

const consul = ... // get consul from somewhere

const protocol = serviceProtocol.getProtocol(consul, 'localhost');
// --> 'http'

const isLocal = serviceProtocol.isLocal(consul, 'localhost');
// --> true
```

### getProtocol

```javascript
getProtocol(consul, hostname);
```

Returns the protocol for connection to a service on host `hostname`.

### isLocal

```javascript
isLocal(consul, hostname);
```

Returns `true` if `hostname` is identical to the local host.
npm package: @sealsystems/setenv
Description: Easily setting environment variables without the need to acces process.env
Author: SEAL Systems AG
Latest version: 0.2.4

# @sealsystems/setenv

[![CircleCI](https://circleci.com/gh/sealsystems/node-setenv.svg?style=svg)](https://circleci.com/gh/sealsystems/node-setenv)
[![AppVeyor](https://ci.appveyor.com/api/projects/status/h3vlvdw99f7q83rp?svg=true)](https://ci.appveyor.com/project/Plossys/node-setenv)

Easily setting environment variables without the need to acces process.env

## Installation

```bash
$ npm install @sealsystems/setenv
```

## Quick start

First you need to add a reference to @sealsystems/setenv within your application.

```javascript
const setenv = require('@sealsystems/setenv');
```

### Setting a variables

Call the function to set a new environment variable or overwrite an existing one.

```
setenv (key, value)
```

- `key` mandatory string with name of the environment variable
- `value` value to set. Allowed data types are `string`, `object`, `number`, `boolean`. For all non string types their string representation is used. Objects are converted into JSON format.

Result value is `true` on success, false otherwise.

Example:

```javascript
setenv('MYKEY', 'my value');
```

## Running the build

To build this module use [roboter](https://www.npmjs.com/package/roboter).

```bash
$ bot
```
npm package: @sealsystems/short-id
Description: Creates short human readable job id.
Author: SEAL Systems AG
Latest version: 0.2.0

# @sealsystems/short-id

[![CircleCI](https://circleci.com/gh/sealsystems/node-short-id.svg?style=svg)](https://circleci.com/gh/sealsystems/node-short-id)
[![AppVeyor](https://ci.appveyor.com/api/projects/status/36adtpganxlkcst6?svg=true)](https://ci.appveyor.com/project/Plossys/node-short-id)

Create a short human readable id of type `string`. This is done by concatenating two hash values. The first hash value is a static prefix build of the current data center name determined via `@sealsystems/consul` module. The second hash is built of a counter read from MongoDB by the `@sealsystems/counter-storage` module.

## Installation

```shell
$ npm install @sealsystems/short-id
```

## Quick start

First you need to integrate @sealsystems/short-id into your application:

```javascript
const shortId = require('@sealsystems/short-id');
```

### Get a handler object

Use the required function to get a short id handler. As parameter of `shortId` provide an `options` object which has to contain
**already connected** `@sealsystems/consul` and `@sealsystems/counter-storage` objects as properties:

```javascript
const shortIdHandler = await shortId({ consul, counterStorage });
```

### Get ids

Call the handler's `next` function for each id you want:

```javascript
const id = await shortIdHandler.next();
```

## Running the build

To build this module use [roboter](https://www.npmjs.com/package/roboter).

```shell
$ bot
```
npm package: @sealsystems/stream-as-string
Description: @sealsystems/stream-as-string transforms streams to strings.
Author: SEAL Systems AG
Latest version: 0.2.4

# @sealsystems/stream-as-string

[![CircleCI](https://circleci.com/gh/sealsystems/node-stream-as-string.svg?style=svg)](https://circleci.com/gh/sealsystems/node-stream-as-string)
[![AppVeyor](https://ci.appveyor.com/api/projects/status/4vcs1tw39nx3ieea?svg=true)](https://ci.appveyor.com/project/Plossys/node-stream-as-string)

@sealsystems/stream-as-string transforms streams to strings.

## Installation

```bash
$ npm install @sealsystems/stream-as-string
```

## Quick start

First you need to add a reference to @sealsystems/stream-as-string within your application.

```javascript
const StreamAsString = require('@sealsystems/stream-as-string');
```

Then use the `write` function to add data to the stream. Once you are done, call `end`. Afterwards, you may use the `asString` function to get the stringified stream.

```javascript
const streamAsString = new StreamAsString();

streamAsString.write('foo');
streamAsString.write('bar');
streamAsString.end();

console.log(streamAsString.asString()); // => 'foobar'
```

Alternatively, you may listen to the `as-string` event. It is raised after the stream has been ended.

```javascript
const streamAsString = new StreamAsString();

streamAsString.once('as-string', (asString) => {
  console.log(asString); // => 'foobar'
});

streamAsString.write('foo');
streamAsString.write('bar');
streamAsString.end();
```

## Running the build

To build this module use [roboter](https://www.npmjs.com/package/roboter).

```bash
$ bot
```
npm package: @sealsystems/stream-assembler
Description: Assemble data from multiple read streams into a single write stream.
Author: SEAL Systems AG
Latest version: 1.1.4

# @sealsystems/stream-assembler

Assemble data from multiple read streams into a single write stream.

## Installation

```bash
npm install @sealsystems/stream-assembler
```

## Quick start

First you need to add a reference to `@sealsystems/stream-assembler` within your application.

```javascript
const Assembler = require('@sealsystems/stream-assembler');
```

Then you can create an assembler object.

```javascript
const assembler = new Assembler(readables);
```

## API

### constructor(readables[, options])

- `readables` &lt;array&gt; | &lt;function&gt; Creates an object of type `Assembler`.
- `options` &lt;Object&gt; Pipe options
  - `end` &lt;boolean&gt; End the writer after all readers end. Defaults to true.

The `readables` array has to contain objects implementing the `stream.Readable` interface.

The `readables` function has to be either a synchronous or an `async` function for which the assembler object can `await` for. The function is called without any parameter and has to return the next read stream at each call or null if no read streams left.

### assembler.pipe(writeable)

- `writeable` <stream.Writeable> The destination for writing data.

Throws on error and returns null on success.

The `pipe` function attaches the `writeable` stream to all readable streams one at a time in the order the readable streams are given.

```javascript
const assembler = new Assembler(readables);

await assembler.pipe(writeable);
```
npm package: @sealsystems/streamparser
Description: Generic stream parser for Node.js
Author: SEAL Systems AG
Latest version: 1.1.7

# @sealsystems/streamparser


@sealsystems/streamparser is a generic stream parser for Node.js.

This is module parses streams in a generic way. You can add your own transitions and emit events while the stream is parsed.

## Installation

```bash
$ npm install @sealsystems/streamparser
```

## Quick start

First you need to integrate @sealsystems/streamparser into your application.

```javascript
const StreamParser = require('@sealsystems/streamparser');
```

To use the generic stream parser you may use this code block. Put all your transition code into a directory `transitions` and require all of them with `requireAll`. Tell the stream parser which state to start with.

```javascript
const path = require('path');

const requireAll = require('require-all');
const StreamParser = require('@sealsystems/streamparser');

const transitions = requireAll(path.join(__dirname, 'transitions'));

const streamparser = new StreamParser({ transitions, startWithState: 'ready' });

streamparser.on('myEvent', (data) => {
  console.log('myEvent:', data);
  done();
});
```

In each of your transitions you have to export one function named as you like (e.g transition). Within this function you have to call the `done` function with an object that contains at least the next state and if you have handled bytes the number of handled bytes. In the case that you are in the last state you must not pass an object to the done function.

```javascript
const ready = function (data) {
  this.emit('myEvent', data);
  this.done({
    nextState: 'myNextState',
    bytesHandled: 1
  });
};

module.exports = ready;
```

## Running the build

To build this module use [roboter](https://www.npmjs.com/package/roboter).

```bash
$ bot
```
npm package: @sealsystems/test-config-jest
Description: Test configuration for Jest at SEAL Systems
Author: SEAL Systems AG
Latest version: 1.0.5

# @sealsystems/test-config-mocha

Test configuration for Jest at SEAL Systems

## Installation

```bash
npm install --save-dev @sealsystems/test-config-jest
```

## Quick start

Jest is installed as a dependency of `@sealsystems/test-config-mocha`. So you can call `jest` from the root directory of your project:

```shell
$(npm bin)/jest
```

The package also provides some CLI executables:

- `test-run` runs Jest

- `test-coverage` collects coverage data

- `test-coverage-check` collects coverage data and fails if threshold (80% for all criteria) has not been reached

- `test-report` collect coverage data and opens the generated HTML page

To use these executables, add some scripts to your `package.json`:

```json
...
"scripts": {
  "test": "test-run",
  "test:coverage": "test-coverage",
  "test:coverage:check": "test-coverage-check",
  "test:report": "test-report"
}
...
```

And call them via `npm run`:

```shell
npm run test
npm run test:coverage
npm run test:coverage:check
npm run test:report
```
npm package: @sealsystems/test-config-mocha
Description: Test configuration for Mocha at SEAL Systems
Author: SEAL Systems AG
Latest version: 1.0.5

# @sealsystems/test-config-mocha

Test configuration for Mocha at SEAL Systems

## Installation

```bash
npm install --save-dev @sealsystems/test-config-mocha
```

## Quick start

Mocha is installed as a dependency of `@sealsystems/test-config-mocha`. So you can call `mocha` from the root directory of your project:

```shell
$(npm bin)/mocha
```

The package also provides some CLI executables:

- `test-run` runs Mocha

- `test-coverage` collects coverage data via `nyc` (which is also installed as a dependency)

- `test-coverage-check` collects coverage data and fails if threshold (80% for all criteria) has not been reached

- `test-report` collect coverage data and opens the generated HTML page

Please note:

- Our standard assert librady `assertthat` is also a dependency of this package. So you do not need to include it in your project's `package.json`.

- Mocha runs with the following settings:

  ```
  test/**/*Test.js
  --async-only
  --bail
  --color
  --exit
  --recursive
  --ui tdd
  ```

To use these executables, add some scripts to your `package.json`:

```json
...
"scripts": {
  "test": "test-run",
  "test:coverage": "test-coverage",
  "test:coverage:check": "test-coverage-check",
  "test:report": "test-report"
}
...
```

And call them via `npm run`:

```shell
npm run test
npm run test:coverage
npm run test:coverage:check
npm run test:report
```
npm package: @sealsystems/tlscert
Description: Provides TLS key and certificate
Author: SEAL Systems AG
Latest version: 2.6.10

# @sealsystems/tlscert


@sealsystems/tlscert provides TLS key and certificate.

## Installation

```bash
npm install @sealsystems/tlscert
```

## Quick start

First you need to add a reference to @sealsystems/tlscert within your application.

```javascript
const tlscert = require('@sealsystems/tlscert');
```

To get the content of the certificate and private key from a specific directory, first you need to set the `TLS_DIR` environment variable:

```bash
export TLS_DIR=$(pwd)
```

Then, call the `get` function:

```javascript
const keystore = await tlscert.get();

console.log(keystore);
// => {
//       key: '...',
//       cert: '...',
//       ca: '...'
//       isFallback: true/false
//    }
```

If you do not set the environment variable, a default key and a default certificate will be returned. In this case the property `isFallback` is set to `true`.

```javascript
if (keystore.isFallback) {
  console.log('This is the fallback key and certificate provided by the module.');
}
```

Please note that the files must be called `key.pem`, `cert.pem` and `ca.pem`, and that they have to be stored in PEM format. Having a `ca.pem` file is optional.

## Self-signed certificate

This module uses a self-signed certificate if no other is provided. This certificate is valid for 10 years (3650 days to be exact ;-)). To see the details of the certificate, call:

```bash
npm run show-cert
```

To create a new one (with a new expiration date), run:

```bash
npm run generate-cert
```

Do not forget to release a new version in order to publish the created certificate.

BTW: It should be no problem if a system contains multiple versions of the self-signed certificate as long as they are not expired.

## Running the build

To build this module use [roboter](https://www.npmjs.com/package/roboter).

```bash
$ bot
```
npm package: @sealui/cli
Description: > TODO: description
Author: 听着情歌流泪
Latest version: 1.0.5

# @sealui/cli

## 使用方法

### create
创建一个项目
```
seal create <app-name>
```
### serve
启动开发环境
```
seal serve
```
### open
打开url
```
seal create <url>
```
### random
生成随机数
```
seal random <length>
```
npm package: @sealui/eslint-config-sealui
Description: SealUI ESLint 配置规范
Author: 听着情歌流泪
Latest version: 0.1.8

# eslint-config-sealui

> SealUI ESLint 规则适用于 React/Vue/Typescript 项目的 ESLint 配置规范，而且也是你配置个性化 ESLint 规则的参考。

## 使用方法

### 内置规则
```
npm install --save-dev eslint babel-eslint @sealui/eslint-config-sealui
```
在你的项目的根目录下创建一个 `.eslintrc.js` 文件，并将以下内容复制进去：
```js
module.exports = {
  extends: [
    'sealui',
  ],
  env: {
    // 你的环境变量（包含多个预定义的全局变量）
    //
    // browser: true,
    // node: true,
    // mocha: true,
    // jest: true,
    // jquery: true
  },
  globals: {
    // 你的全局变量（设置为 false 表示它不允许被重新赋值）
    //
    // myGlobal: false
  },
  rules: {
    // 自定义你的规则
  }
};
```

### Vue
```
npm install --save-dev eslint babel-eslint vue-eslint-parser eslint-plugin-vue @sealui/eslint-config-sealui
```
在你的项目的根目录下创建一个 `.eslintrc.js` 文件，并将以下内容复制进去：

```js
module.exports = {
  extends: [
    'sealui',
    'sealui/vue',
  ],
  env: {
    // 你的环境变量（包含多个预定义的全局变量）
    //
    // browser: true,
    // node: true,
    // mocha: true,
    // jest: true,
    // jquery: true
  },
  globals: {
    // 你的全局变量（设置为 false 表示它不允许被重新赋值）
    //
    // myGlobal: false
  },
  rules: {
    // 自定义你的规则
  }
};
```
### TypeScript
```
npm install --save-dev eslint typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin @sealui/eslint-config-sealui
```
在你的项目的根目录下创建一个 `.eslintrc.js` 文件，并将以下内容复制进去：

```js
module.exports = {
  extends: [
    'sealui',
    'sealui/typescript',
  ],
  env: {
    // 你的环境变量（包含多个预定义的全局变量）
    //
    // browser: true,
    // node: true,
    // mocha: true,
    // jest: true,
    // jquery: true
  },
  globals: {
    // 你的全局变量（设置为 false 表示它不允许被重新赋值）
    //
    // myGlobal: false
  },
  rules: {
    // 自定义你的规则
  }
};
```
## VSCode 中的 autoFixOnSave 没有效果
如果需要针对 `.vue、.ts` 和 `.tsx` 文件开启 `ESLint` 的 `autoFix`，则需要配置成：

```json
{
  "eslint.autoFixOnSave": true,
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    {
        "language": "vue",
        "autoFix": true
    },
    {
        "language": "typescript",
        "autoFix": true
    },
    {
        "language": "typescriptreact",
        "autoFix": true
    }
  ]
}
```

## 如何结合 Prettier 使用
下面给出一个 `.prettierrc.js` 配置，仅供参考：

```js
// .prettierrc.js
module.exports = {
  // 一行最多 100 字符
  printWidth: 100,
  // 使用 4 个空格缩进
  tabWidth: 2,
  // 不使用缩进符，而使用空格
  useTabs: false,
  // 行尾需要有分号
  semi: false,
  // 使用单引号
  singleQuote: true,
  // 对象的 key 仅在必要时用引号
  quoteProps: 'as-needed',
  // jsx 不使用单引号，而使用双引号
  jsxSingleQuote: false,
  // 末尾不需要逗号
  trailingComma: 'none',
  // 大括号内的首尾需要空格
  bracketSpacing: true,
  // jsx 标签的反尖括号需要换行
  jsxBracketSameLine: false,
  // 箭头函数，只有一个参数的时候，也需要括号
  arrowParens: 'always',
  // 每个文件格式化的范围是文件的全部内容
  rangeStart: 0,
  rangeEnd: Infinity,
  // 不需要写文件开头的 @prettier
  requirePragma: false,
  // 不需要自动在文件开头插入 @prettier
  insertPragma: false,
  // 使用默认的折行标准
  proseWrap: 'preserve',
  // 根据显示样式决定 html 要不要折行
  htmlWhitespaceSensitivity: 'css',
  // 换行符使用 lf
  endOfLine: 'lf'
};
```
npm package: @seamailer/seamailer-js
Description: Seamailer's Browser SDK
Author: Seamailer Team
Latest version: 0.0.3

# Seamailer JS SDK
For collecting contact information from frontend forms

![NPM Version](https://img.shields.io/npm/v/%40seamailer%2Fseamailer-js)

### if you want to send emails try our Node SDK or use the API
- [Seamailer Node SDK](https://www.npmjs.com/package/seamailer-nodejs)
- [API Documentation](https://developers.seamailer.app)

## Installing
```shell
npm install @seamailer/seamailer-js
```
## Usage

```javascript
import Seamailer from "seamailer-js"

const seamailer = new Seamailer("public api key")

seamailer.contacts.createContact({
    email: "user@myemail.com",
    firstName: "John",
    lastName: "Doe",
    company: "Acme Inc.",
    tags: "tag1, tag2",
    customFields: {
        field1: "value1",
        field2: "value2",
    },
}).then();

```
npm package: @seamapi/logger
Description: This module should be used instead of console.log, it has the following features:
Latest version: 1.9.2

# Seam Typescript Logger

This module should be used instead of console.log,
it has the following features:

- Output for submodules can easily be shown/hidden with `DEBUG=module-name` (by default, `DEBUG=seam-connect`)
- Supports "Context Wrappers" when logging

## Usage

You shouldn't directly call this module when you
want to log, you should create a `lib/logger.ts` file
for each project, this way you can set up a logger
with the correct `DEBUG` flag ("seam-connect") by default.

```ts
import { DatabaseConnection } from "types"
import defaultAxios from "axios"
import { Event } from "types/noiseaware"
import logger from "@seamapi/logger"
import wrappers from "nextjs-middleware-wrappers"

export const getEvents = wrappers(
  logger.withContext("getEvents"),
  async ({ user_token }): Promise<Array<Event>> => {
    logger.addToContext({ user_token })
    const axios = defaultAxios.create({
      baseURL: process.env.NOISEAWARE_PORTAL_BASE_URL,
      headers: {
        Authorization: `Bearer ${user_token}`,
      },
    })
    logger.logAxios(axios)

    const res = await axios.post("/events/list", {
      pageNum: 0,
      perPage: 100,
    })

    logger.debug("Got events", { events: res.data })

    return res.data.data
  }
)

export default getEvents
```

Output format is controlled by the environment variable `SEAM_LOGGER_FORMAT`, which can be set to `pretty` (default, used during development) or `json`.
npm package: @seamapi/next
Description: The React Framework
Latest version: 12.0.7-seve.0

<p align="center">
  <a href="https://nextjs.org">
    <img src="https://assets.vercel.com/image/upload/v1607554385/repositories/next-js/next-logo.png" height="128">
    <h1 align="center">Next.js</h1>
  </a>
</p>

<p align="center">
  <a aria-label="Vercel logo" href="https://vercel.com">
    <img src="https://img.shields.io/badge/MADE%20BY%20Vercel-000000.svg?style=for-the-badge&logo=Vercel&labelColor=000">
  </a>
  <a aria-label="NPM version" href="https://www.npmjs.com/package/next">
    <img alt="" src="https://img.shields.io/npm/v/next.svg?style=for-the-badge&labelColor=000000">
  </a>
  <a aria-label="License" href="https://github.com/vercel/next.js/blob/canary/license.md">
    <img alt="" src="https://img.shields.io/npm/l/next.svg?style=for-the-badge&labelColor=000000">
  </a>
  <a aria-label="Join the community on GitHub" href="https://github.com/vercel/next.js/discussions">
    <img alt="" src="https://img.shields.io/badge/Join%20the%20community-blueviolet.svg?style=for-the-badge&logo=Next.js&labelColor=000000&logoWidth=20">
  </a>
</p>

## Getting Started

Visit <a aria-label="next.js learn" href="https://nextjs.org/learn">https://nextjs.org/learn</a> to get started with Next.js.

## Documentation

Visit [https://nextjs.org/docs](https://nextjs.org/docs) to view the full documentation.

## Who is using Next.js?

Next.js is used by the world's leading companies. Check out the [Next.js Showcase](https://nextjs.org/showcase) to learn more.

## Community

The Next.js community can be found on [GitHub Discussions](https://github.com/vercel/next.js/discussions), where you can ask questions, voice ideas, and share your projects.

To chat with other community members you can join the [Next.js Discord](https://nextjs.org/discord).

Our [Code of Conduct](https://github.com/vercel/next.js/blob/canary/CODE_OF_CONDUCT.md) applies to all Next.js community channels.

## Contributing

Please see our [contributing.md](/contributing.md).

### Good First Issues

We have a list of [good first issues](https://github.com/vercel/next.js/labels/good%20first%20issue) that contain bugs which have a relatively limited scope. This is a great place to get started, gain experience, and get familiar with our contribution process.

## Authors

- Tim Neutkens ([@timneutkens](https://twitter.com/timneutkens)) – [Vercel](https://vercel.com/about/timneutkens)
- Naoyuki Kanezawa ([@nkzawa](https://twitter.com/nkzawa)) – [Vercel](https://vercel.com/about/nkzawa)
- Guillermo Rauch ([@rauchg](https://twitter.com/rauchg)) – [Vercel](https://vercel.com/about/rauchg)
- Arunoda Susiripala ([@arunoda](https://twitter.com/arunoda))
- Tony Kovanen ([@tonykovanen](https://twitter.com/tonykovanen))
- Dan Zajdband ([@impronunciable](https://twitter.com/impronunciable))
npm package: @seamapi/nextjs-exception-middleware
Description: This middleware allows you to throw exceptions in your route handlers that are caught and returned as JSON.
Latest version: 1.1.1

# nextjs-exception-middleware

This middleware allows you to throw exceptions in your route handlers that are caught and returned as JSON.

For example,

```javascript
// Inside a route handler
if (bad_soups.includes(soup_param)) {
  throw new BadRequestException({
    type: "cant_make_soup",
    message: "Soup was too difficult, please specify a different soup",
    data: { soup_param }
  })
}
```

will be returned as
```json
{
  "error": {
    "type": "cant_make_soup",
    "message": "Soup was too difficult, please specify a different soup",
    "data": {
      "soup_param": "tomato"
    }
  }
}
```

with a status code of 400.

## Installation

`yarn add @seamapi/nextjs-exception-middleware` or `npm install @seamapi/nextjs-exception-middleware -s`

## Usage

Wrap your API handlers like so:

```javascript
import { withExceptionHandling } from "@seamapi/nextjs-exception-middleware"

export default withExceptionHandling({
  // all parameters are optional
  addOkStatus: false // add top-level "ok" status key to JSON responses
  okStatusOptions: {
    addIf: (req) => req.method === "GET" // only add "ok" status key if request is GET
  },
  exceptionHandlingOptions: {
    shouldIncludeErrorContext: (req) => req.method === "GET" // only include error stack if request is GET
    getAdditionalErrorContext: (req) => ({
      // add any additional context to returned errors
      "request_id": req.requestId
    })
  }
})(async (req, res) => {
  // ...
})
```
npm package: @seamapi/nextjs-health-endpoint-module
Description: ## Installation
Latest version: 1.0.13

# NextJS Health Endpoint Module

## Installation

```bash
npm install @seamapi/nextjs-health-endpoint-module
```

## Usage

```ts
import healthEndpoint from "@seamapi/nextjs-health-endpoint-module"

const server = await healthEndpoint({ port: 3030 })

// You can now call http://localhost:3030/health

server.close()
```
npm package: @seamapi/nextlove-sdk-generator
Description: Utilities for building NextLove SDK Generators
Author: Seam Labs, Inc.
Latest version: 1.19.10

# Nextlove SDK Generator

> This SDK generator is currently configured to only work with Seam Connect,
> output is also committed directly to the repo for ease of inspection and
> testing

This automatically generates an SDK based on the Seam Connect OpenAPI config.

## Usage

```bash
npm install
npm run generate:python-sdk
npm run generate:ruby-sdk
# output is in "./output/python" and "./output/ruby"
```
npm package: @seamapi/wrappers
Description: For the common use case of wrapping a NextJS endpoint with methods that act as middleware.
Latest version: 1.1.1

# (NextJS) Middleware Wrappers

For the common use case of wrapping a NextJS endpoint with methods that act as middleware.

Wraps a function in layers of other functions, while preserving the input/output
type. The output of wrappers will always have the type of its last parameter
(the wrapped function)

This function turns this type of composition...

```ts
withDatabase(
  logger.withContext("somecontext")(async (a, b) => {
    return a
  })
)
```

Into...

```ts
wrappers(withDatabase, logger.withContext("somecontext"), async (a, b) => {
  return a
})
```

Having this as a utility method helps preserve types, which otherwise can get
messed up by the middlewares. It also can make the code cleaner where there are
multiple wrappers.

## EXAMPLES

In the context of request middleware you might write something like this...

```ts
const withRequestLoggingMiddleware = (next) => async (req, res) => {
  console.log(`GOT REQUEST ${req.method} ${req.path}`)
  return next(req, res)
}
```

Here's an example of a wrapper that takes some parameters...

```ts
const withLoggedArguments =
  (logPrefix: string) =>
  (next) =>
  async (...funcArgs) => {
    console.log(logPrefix, ...funcArgs)
    return next(...funcArgs)
  }
```

## Installation

## Automatic Deploy to NPM

To have your PR be automatically deployed to NPM, make sure to tag your commit messages with the [Angular JS commit message format](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#heading=h.t7ifoyph8bd3).

i.e.
| Commit message | Release type |
| -------------- | ------------ |
| fix(pencil): stop graphite breaking when too much pressure applied | Fix Release |
| feat(pencil): add 'graphiteWidth' option	| Feature Release |
| perf(pencil): remove graphiteWidth option
| BREAKING CHANGE: The graphiteWidth option has been removed. The default graphite width of 10mm is always used for performance reasons. | Breaking Release (Note that the BREAKING CHANGE: token must be in the footer of the commit) |