open-index/open-npm huggingface dataset:
npm package: @naturalatlas/paranoid-request
Description: A paranoid request library
Latest version: 1.1.1

# @naturalatlas/paranoid-request

[![](https://travis-ci.org/naturalatlas/paranoid-request.svg?branch=master)](https://travis-ci.org/naturalatlas/paranoid-request)

An SSRF-preventing wrapper around Node's request module, as well as the
lower-level `http` and `https` modules.

*This is a fork of Uber's [paranoid-request](https://github.com/uber-common/paranoid-request) module that adds Node 7+ support. Feel free to use this fork, though hopefully these changes will be merged upstream.*

```sh
$ npm install @naturalatlas/paranoid-request --save
```

## Overview

Server Side Request Forgery (SSRF) is a vulnerability that appears when an
attacker has the ability to create requests from a vulnerable server.

This can allow the attacker to make requests to localhost,
thereby exposing sensitive internal services that are behind the firewall.

This library prevents this category of attacks by preventing the requests from firing.

For more info on SSRF vulnerabilities, check out
[this article](http://www.acunetix.com/blog/articles/server-side-request-forgery-vulnerability/).

## Usage

Exactly the same as https://www.npmjs.com/package/request, with the addition
that we will emit an 'error' event with an `UnacceptableAddressError` when we
can't find a suitable address.

```javascript
var paranoid = require("@naturalatlas/paranoid-request");

// These two will be blocked
paranoid.get("http://localhost/", function(err, res, body) {
    console.log(err && err.message);
    // All addresses were blacklisted!
});

paranoid.get("http://example.com:9000/", function(err, res, body) {
    console.log(err && err.message);
    // Disallowed port detected
});

// but this is fine
paranoid.get("http://example.com/", function(err, res, body) {
    console.log(res.statusCode);
    // 200
});
```

If you want a custom set of validation rules, you can also roll your
own version of `paranoid-request`:

```javascript
var paranoid = require("@naturalatlas/paranoid-request");

// example.com's IP
var exampleComIp = "93.184.216.34";
var exampleComCIDR = exampleComIp + "/32";
var exampleComIpURL = "http://" + exampleComIp + "/";

// Make a wrapper that blocks example.com's IP by default
var moreParanoid = paranoid.defaults({
  addrValidator: new paranoid.AddrValidator({ipBlacklist: [exampleComCIDR]})
});

// Now requests to example.com's IP should be blocked
moreParanoid.get(exampleComIpURL, function(err, res, body) {
  console.log(err && err.message);
  // All addresses were blacklisted!
});
```

You can also use `paranoid-request`'s paranoid wrappers for the stdlib's `http`
and `https` as well via `require("paranoid-request").httpModule` and
`require("paranoid-request").httpsModule`, respectively. However, I don't recommend it.

## Testing

* `npm install`
* `npm test`

## Development

Develop like any other node module. Please write tests for any new code you add!
npm package: @naturalclar/eslint-config
Description: eslint config for my personal projects
Latest version: 0.0.2

# @naturalclar/eslint-config

Custom eslint config for my personal projects

Includes prettier and eslint-config for typescript project

The config is based of off `@react-native-community/eslint-config` with some modification for my needs.

## Installation

```
yarn add -D eslint @naturalclar/eslint-config
```

## Setup

Create an `.eslintrc.js` in your root directory of the project with the following settings

```js
module.exports = {
  extends: "@naturalclar"
}
```
npm package: @naturalclar/linear-gradient
Description: [![Build Status](https://github.com/reason-react-native/linear-gradient/workflows/Build/badge.svg)](https://github.com/reason-react-native/linear-gradient/actions) [![Version](https://img.shields.io/npm/v/@reason-react-native/linear-gradient.svg)](https:/
Latest version: 2.5.6

# `@reason-react-native/linear-gradient`

[![Build Status](https://github.com/reason-react-native/linear-gradient/workflows/Build/badge.svg)](https://github.com/reason-react-native/linear-gradient/actions)
[![Version](https://img.shields.io/npm/v/@reason-react-native/linear-gradient.svg)](https://www.npmjs.com/@reason-react-native/linear-gradient)
[![Chat](https://img.shields.io/discord/235176658175262720.svg?logo=discord&colorb=blue)](https://reasonml-community.github.io/reason-react-native/discord/)

[ReasonML](https://reasonml.github.io) /
[BuckleScript](https://bucklescript.github.io) bindings for
[`react-native-linear-gradient`](https://github.com/react-native-community/react-native-linear-gradient).

Exposed as `ReactNativeLinearGradient` module.

`@reason-react-native/linear-gradient` X.y._ means it's compatible with
`react-native-linear-gradient` X.y._

## Installation

When
[`react-native-linear-gradient`](https://github.com/react-native-community/react-native-linear-gradient)
is properly installed & configured by following their installation instructions,
you can install the bindings:

```console
npm install @reason-react-native/linear-gradient
# or
yarn add @reason-react-native/linear-gradient
```

`@reason-react-native/linear-gradient` should be added to `bs-dependencies` in
your `bsconfig.json`. Something like

```diff
{
  //...
  "bs-dependencies": [
    "reason-react",
    "reason-react-native",
    // ...
+    "@reason-react-native/linear-gradient"
  ],
  //...
}
```

## Usage

### Types

#### `ReactNativeLinearGradient.t`

---

## Changelog

Check the [changelog](./CHANGELOG.md) for more informations about recent
releases.

---

## Contribute

Read the
[contribution guidelines](https://github.com/reason-react-native/.github/blob/master/CONTRIBUTING.md)
before contributing.

## Code of Conduct

We want this community to be friendly and respectful to each other. Please read
[our full code of conduct](https://github.com/reason-react-native/.github/blob/master/CODE_OF_CONDUCT.md)
so that you can understand what actions will and will not be tolerated.
npm package: @naturalclar/react-native-confetti
Description: Raining confetti made with react native animations
Author: Codeventure
Latest version: 0.2.1

# react-native-confetti
Raining confetti made with react native animations

<p align="left">
  <img src="./demo.gif" width="320" height="282">
</p>

## Installation

```sh
npm i -S react-native-confetti
```

## Usage

```javascript
import React, {Component} from 'react';
import {
  AppRegistry,
  StyleSheet,
  View
} from 'react-native';

import Confetti from 'react-native-confetti';

class RNConfetti extends Component {
  componentDidMount() {
    if(this._confettiView) {
       this._confettiView.startConfetti();
    }
  }

  render() {
    return <View style={styles.container}>
      <Confetti ref={(node) => this._confettiView = node}/>
    </View>
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1
  }
});
```

## Props

Property         | Type     | Default  | Description
---              | ---      | ---      | ---
`confettiCount`  | `Number` |  100     | Number of confetti
`timeout`        | `Number` |  30 (ms)     | Timeout between confetti
`untilStopped`   | `Boolean` | false | Render confetti continuously until `stopConfetti()` is called. This ignores `confettiCount`.
`duration`       | `Number` |  6000 (ms) | Duration until a conffetti reaches the bottom
`colors`       | `Array` |  ["rgb(242.2, 102, 68.8)","rgb(255, 198.9, 91.8)","rgb(122.4, 198.9, 163.2)","rgb(76.5, 193.8, 216.7)","rgb(147.9, 99.4, 140.2)"] | Array of color strings to choose from for the confetti
`size`           | `Number` |   1       | Multiplier for size of confetti (width and heigh)
`bsize`           | `Number` |   1       | Multiplier for radius of confetti (border radius)
npm package: @naturalclar/reason-react-native-template
Description: > This is a React Native application developed in Reason.
Latest version: 0.1.0-beta.4

# Reason React Native HelloWorld

> This is a React Native application developed in Reason.

Please carefully read instructions below in order to enjoy ReasonML development
experience.

## Setup

## Start a Reason React Native project with this template

```console
npx react-native init MyApp --template reason-react-native-template
cd MyApp
```

⚠️ In case you got an error saying it's looking for
`react-native-template-reason-react-native-template`, be sure to have
uninstalled any previous react-native-cli version & rely on `npx`

```console
npm -g uninstall react-native
npm -g uninstall react-native-cli
yarn global remove react-native
yarn global remove react-native-cli
```

Now that you are ready to go, you can check our documentation on
[how to use Reason React Native](https://reasonml-community.github.io/reason-react-native/en/docs/usage/).
npm package: @naturalclar/tbs
Description: my touch-bar shortcuts
Author: Jesse Katsumata
Latest version: 0.4.0

# tbs-dock

[![](https://img.shields.io/npm/v/@naturalclar/tbs.svg)](https://www.npmjs.com/package/@naturalclar/tbs)

A simple dock application with touchbar shortcuts

![](https://user-images.githubusercontent.com/6936373/59969899-8163a380-9594-11e9-84dd-7da861551328.png)

## Install

```sh
yarn global add @naturalclar/tbs
```

## usage

```
npx tbs-dock
```

## Keyboard shortcuts

| Command                     | Description    |
| --------------------------- | -------------- |
| `Control+X`                 | Toggle display |
| `Command+Shift+Left(Right)` | Switch Tabs    |
npm package: @naturalclar/tsconfig
Description: tsconfig for my projects
Author: Jesse Katsumata
Latest version: 0.1.0

# tsconfig

Base Typescript config for my projects

## Usage

First, install the package

```
yarn add -D @naturalclar/tsconfig
```

Then, in your project directory, make a new `tsconfig.json`

```json
{
  "extends": "@naturalclar/tsconfig",
  "compilerOptions": {
    "outDir": "dist",
    "rootDir": "src"
  }
}
```

## License

MIT
npm package: @naturalcycles/backend-lib
Description: Standard library for making Express.js / AppEngine based backend services
Author: Natural Cycles Team
Latest version: 9.59.0

## @naturalcycles/backend-lib

> Standard library for building Node.js / Express backend

[![npm](https://img.shields.io/npm/v/@naturalcycles/backend-lib/latest.svg)](https://www.npmjs.com/package/@naturalcycles/backend-lib)
[![Maintainability](https://api.codeclimate.com/v1/badges/c7aa5ef93894ec0246c4/maintainability)](https://codeclimate.com/github/NaturalCycles/backend-lib/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/c7aa5ef93894ec0246c4/test_coverage)](https://codeclimate.com/github/NaturalCycles/backend-lib/test_coverage)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![Actions](https://github.com/NaturalCycles/backend-lib/workflows/ci/badge.svg)](https://github.com/NaturalCycles/backend-lib/actions)

# [Documentation](https://naturalcycles.github.io/backend-lib/)

## chore-counter

1
npm package: @naturalcycles/cli
Description: CLI utils to be installed globally via 'npm i -g'
Author: Natural Cycles Team
Latest version: 1.9.1

## @naturalcycles/cli

> CLI utils to be installed globally via 'npm i -g'

[![npm](https://img.shields.io/npm/v/@naturalcycles/cli/latest.svg)](https://www.npmjs.com/package/@naturalcycles/cli)
[![install size](https://packagephobia.now.sh/badge?p=@naturalcycles/cli)](https://packagephobia.now.sh/result?p=@naturalcycles/cli)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

# Install

`npm i -g @naturalcycles/cli`

# CLI commands (globally available)

- `tsn`: short alias for `ts-node` with additional parameters
  `-T -r tsconfig-paths/register -r dotenv/config`. Will use `./scripts/tsconfig.json` (file will be
  auto-generated in not present).

Set `TSN_ESBUILD` env variable to enable experimental `esbuild` transpilation, using `esbuild` and
`esbuild-register` instead of `typescript` and `ts-node`.

# Packaging

- `engines.node`: Latest Node.js LTS
- `main: dist/index.js`: commonjs, es2020
npm package: @naturalcycles/cloud-storage-lib
Description: CommonStorage implementation based on Google Cloud Storage
Author: Natural Cycles Team
Latest version: 2.7.0

## @naturalcycles/cloud-storage-lib

> CommonStorage implementation based on Google Cloud Storage

[![npm](https://img.shields.io/npm/v/@naturalcycles/cloud-storage-lib/latest.svg)](https://www.npmjs.com/package/@naturalcycles/cloud-storage-lib)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

Implements:

- `CommonStorage`
- `CommonKeyValueDB`

Exports:

- `CommonStorage`
- `CommonStorageBucket`
- `CloudStorage`
- `CommonStorageKeyValueDB`
- `InMemoryCommonStorage`
npm package: @naturalcycles/common-type
Description: Common Type interface and generator
Author: Natural Cycles Team
Latest version: 1.9.1
Deprecated: project renamed to @naturalcycles/json-schema-lib

## @naturalcycles/common-type

> Common Type interface and generator

[![npm](https://img.shields.io/npm/v/@naturalcycles/common-type/latest.svg)](https://www.npmjs.com/package/@naturalcycles/common-type)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

Allows to generate [JSON Schema](https://json-schema.org/) from a set of Typescript files with
Interfaces (also Types and Enums).

Also, to generate Typescript files from JSON schemas (reverse).

Status: experimental! Everything is subject to change!

# Example

Install `common-type` as your devDependency:

    yarn add -D @naturacycles/common-type

Define a `commonType.cfg.js` in the root of you project:

```js
module.exports = {
  paths: ['src/types/*.ts'],
  outputDir: 'src/schemas',
}
```

Config says to scan all `*.ts` files in `src/types`, parse them, generate JSON schemas, write them
into `src/schemas` folder.

## Similar projects

- https://github.com/YousefED/typescript-json-schema
- https://github.com/vega/ts-json-schema-generator

## Develop

Typescript AST debugging: https://ts-ast-viewer.com/

## Supported

- Schemas from:
  - Interfaces
  - Types
  - Enums
  - Classes
- `string`, `number`, `boolean`
- Literal types, e.g `someString`, 15, `true`
- `null` type
- `object`, `array`
- `tuple`
- `enum` (`string` and `number` values)
- optional/required properties
- Union types (`|`), Intersections (`&`), `extends`
- jsdoc `@validationType` (e.g. `integer`)
- Type references, e.g. `p: Person` (where `Person` is defined elsewhere, can be in another file)
- Parsing a list of files (not necessary for all types to be in 1 file)
- `Partial`, `Required`
- `Record<A, B>`
- Indexed properties (`{ [name: string]: string }`)
- `StringMap` (aka Dictionary)
- jsdoc tags:
  - `validationType` to override `type`, e.g. `@validationType integer`
  - General: `deprecated`, `readOnly`, `writeOnly`, `default`
  - String: `pattern`, `format`, `minLength`, `maxLength`
  - Number: `multipleOf`, `minimum`, `exclusiveMinimum`, `maximum`, `exclusiveMaximum`
  - Object: `additionalProperties`, `minProperties`, `maxProperties`
  - Array: `minItems`, `maxItems`, `uniqueItems`
  - Schema composition: `if`, `then`, `else`, `dependencies`, `dependentRequired`,
    `dependentSchemas`

## Currently NOT supported

- `Omit`, `Pick`
- Generic interfaces, e.g. `interface MyType<T> { current: T, future: T }`
- `typeof`
- `keyof`
- Conditional types
npm package: @naturalcycles/datastore-lib
Description: Opinionated library to work with Google Datastore, implements CommonDB
Author: Natural Cycles Team
Latest version: 4.19.1

## @naturalcycles/datastore-lib

> Opinionated library to work with Google Datastore

[![npm](https://img.shields.io/npm/v/@naturalcycles/datastore-lib/latest.svg)](https://www.npmjs.com/package/@naturalcycles/datastore-lib)
[![](https://circleci.com/gh/NaturalCycles/datastore-lib.svg?style=shield&circle-token=cbb20b471eb9c1d5ed975e28c2a79a45671d78ea)](https://circleci.com/gh/NaturalCycles/datastore-lib)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

# Features

- BaseDao abstract class for extension
- DBM / BM / FM models, conversion, validation
- DB fields convention (`created`, `updated`, `_ver`)
- Simplified ID handling (always String ids)
- Simple and powerful In-Memory Datastore emulator for faster and safer unit testing (!)
- Streaming with RxJS Observable interface
- Anonymization hook to be able to plug your implementation (privacy by design)
- ...

## chore-counter

1
npm package: @naturalcycles/dependency-check
Description: NPM and JAVA dependency analyser
Author: Natural Cycles Team
Latest version: 1.5.3

# Dependency Checker

Analyze NPM and JAVA dependencies that your project depends on. Quickly view a list of open issues
and aggregated data for each open-source package.

Check [this link](https://depchecker.com/blog/analyze-project-deps/) for more information on how
packages are analyzed.

## Running the checker

As dependency checker queries multiple Github sources, set your own github token while/before
running it.

```bash
GITHUB_TOKEN=<my-github-token>
```

## Recommended to run with npx

````bash
GITHUB_TOKEN=<my-github-token> npx @naturalcycles/dependency-check
```

## Development

Clone this repo to your workspace

```bash
git clone https://github.com/NaturalCycles/dependency-check.git
````

add dependencies

```bash
yarn add
```

link this package to be able to use it globally.

```bash
yarn link
```

And finally build it in watch mode

```bash
yarn run watch
```
npm package: @naturalcycles/firestore-lib
Description: Firestore implementation of CommonDB interface
Author: Natural Cycles Team
Latest version: 2.15.0

## @naturalcycles/firestore-lib

> Firestore implementation of CommonDB interface

[![npm](https://img.shields.io/npm/v/@naturalcycles/firestore-lib/latest.svg)](https://www.npmjs.com/package/@naturalcycles/firestore-lib)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

# Features

- ...
npm package: @naturalcycles/frontend-lib
Description: Standard library for Frontend applications
Author: Natural Cycles Team
Latest version: 4.11.0
Deprecated: deprecated, all functions are moved to js-lib

DEPRECATED, all its functions are now moved to
[@naturalcycles/js-lib](https://github.com/NaturalCycles/js-lib)

## @naturalcycles/frontend-lib

> Standard library for Frontend applications

[![npm](https://img.shields.io/npm/v/@naturalcycles/frontend-lib/latest.svg)](https://www.npmjs.com/package/@naturalcycles/frontend-lib)
[![min.gz size](https://badgen.net/bundlephobia/minzip/@naturalcycles/frontend-lib)](https://bundlephobia.com/result?p=@naturalcycles/frontend-lib)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![Actions](https://github.com/NaturalCycles/frontend-lib/workflows/default/badge.svg)](https://github.com/NaturalCycles/frontend-lib/actions)

# [Documentation](https://naturalcycles.github.io/frontend-lib/)
npm package: @naturalcycles/generator-backend-service
Description: Yeoman generator to create a Backend service
Author: Natural Cycles Team
Latest version: 1.5.2

## @naturalcycles/generator-backend-service

> Yeoman generator to create a Backend service

[![npm](https://img.shields.io/npm/v/@naturalcycles/generator-nodejs-lib/latest.svg)](https://www.npmjs.com/package/@naturalcycles/generator-nodejs-lib)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
   
# Global setup

You need to have latest [yeoman](https://github.com/yeoman/yo) globally installed, install it like this:

```shell
npm i -g yo
yo --version
```

Then, globally-install this generator:

```shell
npm i -g @naturalcycles/generator-backend-service
```

# Usage

    mkdir my-lib
    cd my-lib
    yo
    
Then, select the needed generator and run it there!

# todo

[ ] backend.cfg.json
npm package: @naturalcycles/generator-nodejs-lib
Description: Yeoman generator to create a Node.js lib
Author: Natural Cycles Team
Latest version: 1.6.2

## @naturalcycles/generator-nodejs-lib

> Yeoman generator to create a Node.js lib

[![npm](https://img.shields.io/npm/v/@naturalcycles/generator-nodejs-lib/latest.svg)](https://www.npmjs.com/package/@naturalcycles/generator-nodejs-lib)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

# Global setup

You need to have latest [yeoman](https://github.com/yeoman/yo) globally installed, install it like
this:

```shell
npm i -g yo
yo --version
```

Then, globally-install this generator:

```shell
npm i -g @naturalcycles/generator-nodejs-lib
```

# Usage

    mkdir my-lib
    cd my-lib
    yo

Then, select the needed generator and run it there!

# Debug

    mkdir tmp/test-project
    cd tmp/test-project
    yo @naturalcycles/nodejs-lib
npm package: @naturalcycles/github-db
Description: GitHub branch as a Database
Author: Natural Cycles Team
Latest version: 1.3.0

## @naturalcycles/github-db

> GitHub branch as a Database

[![npm](https://img.shields.io/npm/v/@naturalcycles/github-db/latest.svg)](https://www.npmjs.com/package/@naturalcycles/github-db)
[![min.gz size](https://badgen.net/bundlephobia/minzip/@naturalcycles/github-db)](https://bundlephobia.com/result?p=@naturalcycles/github-db)
[![](https://circleci.com/gh/NaturalCycles/github-db.svg?style=shield&circle-token=123)](https://circleci.com/gh/NaturalCycles/github-db)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

# Intro

Store your data for free in GitHub repo branch. Similar to `gh-pages`, but for data.

Implements [CommonDB](https://github.com/NaturalCycles/db-lib) interface.

Store as `*.ndjson` (newline-delimited json), or `*.ndjson.gz` (gzipped), or `*.sqlite` (binary).

Push to preserve git commit history or force-push to reset history and only store the recent state.

# Example

```typescript
const db = new FileDB({
  plugin: new GithubPersistencePlugin({
    token: 'YOUR_GITHUB_TOKEN',
    repo: 'NaturalCycles/github-db',
  }),
})

const items = [
  { id: 'id1', a: 'a1' },
  { id: 'id2', a: 'a2' },
]

await db.saveBatch('TEST_TABLE', items)
```

It will create, commit and push `data/TEST_TABLE.ndjson` file to the repo/branch that you've
specified (branch defaults to `gh-data`, similarly to `gh-pages`).

Next saves will be either new commits, or force-push of new commit over previous (with
`forcePush: true` option).

Currently, it needs some preparation steps to work (create empty branch), described further down.

# Prepare an empty branch to store your data

Replace `git@github.com:NaturalCycles/github-db.git` with your repo.

Replace `gh-data` with the desired branch name (but `gh-data` is the default).

```
mkdir data && cd data
git clone git@github.com:NaturalCycles/github-db.git ./
git checkout --orphan gh-data
git reset --hard
git commit --allow-empty -m "chore: init empty data branch"
git push --set-upstream origin gh-data
```

# TODO

- [ ] .ndjson.gzip option
- [ ] .sqlite option
- [ ] command to vacuum/force-push all commits in gh-data into one
npm package: @naturalcycles/grafana-lib
Description: Exposes CommonDB as Grafana Json Datasource (express middleware)
Author: Natural Cycles Team
Latest version: 1.1.1

## @naturalcycles/grafana-lib

> Exposes CommonDB as [Grafana Json Datasource](https://github.com/simPod/grafana-json-datasource)
> (express middleware)

[![npm](https://img.shields.io/npm/v/@naturalcycles/grafana-lib/latest.svg)](https://www.npmjs.com/package/@naturalcycles/grafana-lib)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

# Example

```typescript
import { createDefaultApp, startServer } from '@naturalcycles/backend-lib'
import { FileDB } from '@naturalcycles/db-lib/dist/adapter/file'
import { GithubPersistencePlugin } from '@naturalcycles/github-db'
import { createGrafanaJsonDatasourceHandler } from '@naturalcycles/grafana-lib'
import { pHang } from '@naturalcycles/js-lib'
import { runScript } from '@naturalcycles/nodejs-lib/dist/script'

runScript(async () => {
  // 1. Have your CommonDB ready
  export const githubDB = new FileDB({
    plugin: new GithubPersistencePlugin({
      repo: 'NaturalCycles/github-db',
      forcePush: false,
    }),
  })

  // 2. Create grafanaHandler
  const grafanaHandler = createGrafanaJsonDatasourceHandler({
    db: githubDB,
  })

  // 3. Run Express server with grafanaHandler on 'http://localhost:8400/'
  await startServer({
    port: 8400,
    expressApp: createDefaultApp({
      resources: [grafanaHandler],
    }),
  })

  await pHang()
})
```

This simple Express server with Grafana middleware allows to connect to it via Grafana UI as "Json
Datasource".

![Grafana Json Datasource](./media/grafana1.png)
npm package: @naturalcycles/js-lib
Description: Standard library for universal (browser + Node.js) javascript
Author: Natural Cycles Team
Latest version: 15.73.1

## @naturalcycles/js-lib

> Standard library for universal (browser + Node.js) javascript

[![npm](https://img.shields.io/npm/v/@naturalcycles/js-lib/latest.svg)](https://www.npmjs.com/package/@naturalcycles/js-lib)
[![min.gz size](https://badgen.net/bundlephobia/minzip/@naturalcycles/js-lib)](https://bundlephobia.com/result?p=@naturalcycles/js-lib)
[![Actions](https://github.com/NaturalCycles/js-lib/workflows/ci/badge.svg)](https://github.com/NaturalCycles/js-lib/actions)
[![loc](https://badgen.net/codeclimate/loc/NaturalCycles/js-lib)](https://github.com/NaturalCycles/js-lib)
[![Maintainability](https://api.codeclimate.com/v1/badges/c2dc8d53bd79f79b1d8b/maintainability)](https://codeclimate.com/github/NaturalCycles/js-lib/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/c2dc8d53bd79f79b1d8b/test_coverage)](https://codeclimate.com/github/NaturalCycles/js-lib/test_coverage)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

# [Documentation](https://naturalcycles.github.io/js-libs/)
npm package: @naturalcycles/json-schema-lib
Description: JSON schema to/from TypeScript parser/generator
Author: Natural Cycles Team
Latest version: 1.11.1

## @naturalcycles/json-schema-lib

> JSON schema to/from TypeScript parser/generator

[![npm](https://img.shields.io/npm/v/@naturalcycles/json-schema-lib/latest.svg)](https://www.npmjs.com/package/@naturalcycles/json-schema-lib)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

Allows to generate [JSON Schema](https://json-schema.org/) from a set of Typescript files with
Interfaces (also Types and Enums).

Also, to generate Typescript files from JSON schemas (reverse).

Status: experimental! Everything is subject to change!

# Example

Install `json-schema-lib` as your devDependency:

    yarn add -D @naturacycles/json-schema-lib

Define a `jsonSchemaGenerator.cfg.js` in the root of you project:

```js
module.exports = {
  paths: ['src/types/*.ts'],
  outputDir: 'resources/schemas',
}
```

Config says to scan all `*.ts` files in `src/types`, parse them, generate JSON schemas, write them
into `resources/schemas` folder.

## Similar projects

- https://github.com/YousefED/typescript-json-schema
- https://github.com/vega/ts-json-schema-generator

## Develop

Typescript AST debugging: https://ts-ast-viewer.com/

## Supported

- Schemas from:
  - Interfaces
  - Types
  - Enums
  - Classes
- `string`, `number`, `boolean`
- Literal types, e.g `someString`, 15, `true`
- `null` type
- `object`, `array`
- `tuple`
- `enum` (`string` and `number` values)
- optional/required properties
- Union types (`|`), Intersections (`&`), `extends`
- jsdoc `@validationType` (e.g. `integer`)
- Type references, e.g. `p: Person` (where `Person` is defined elsewhere, can be in another file)
- Parsing a list of files (not necessary for all types to be in 1 file)
- `Partial`, `Required`
- `Record<A, B>`
- Indexed properties (`{ [name: string]: string }`)
- `StringMap` (aka Dictionary)
- jsdoc tags:
  - `validationType` to override `type`, e.g. `@validationType integer`
  - General: `deprecated`, `readOnly`, `writeOnly`, `default`
  - String: `pattern`, `format`, `minLength`, `maxLength`
  - Number: `multipleOf`, `minimum`, `exclusiveMinimum`, `maximum`, `exclusiveMaximum`
  - Object: `additionalProperties`, `minProperties`, `maxProperties`
  - Array: `minItems`, `maxItems`, `uniqueItems`
  - Schema composition: `if`, `then`, `else`, `dependencies`, `dependentRequired`,
    `dependentSchemas`

## Currently NOT supported

- `Omit`, `Pick`
- Generic interfaces, e.g. `interface MyType<T> { current: T, future: T }`
- `typeof`
- `keyof`
- Conditional types
npm package: @naturalcycles/json2html
Description: Render arbitrary json as human-friendly html. CLI and API.
Author: Natural Cycles Team
Latest version: 1.1.1

## @naturalcycles/json2html

> Render arbitrary json as human-friendly html. CLI and API. Inspired by
> [json.human.js](https://github.com/marianoguerra/json.human.js)

[![npm](https://img.shields.io/npm/v/@naturalcycles/json2html/latest.svg)](https://www.npmjs.com/package/@naturalcycles/json2html)
[![](https://circleci.com/gh/NaturalCycles/json2html.svg?style=shield&circle-token=123)](https://circleci.com/gh/NaturalCycles/json2html)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

# Why

Sometimes you need to render some report to non-technical people, but too lazy to create a custom
html/css template for it. Just throw your json into this library and enjoy the good-enough result.

# Install

    yarn add @naturalcycles/json2html

# Examples

[Sample output](./src/test/mock1.json.html)

```sh

# Render `my.json` to `my.json.html`
json2html my.json

# Render all json files in `someDir`
json2html 'someDir/**/*.json'

```

# Packaging

- `engines.node >= 14.15`: Latest Node.js LTS
- `main: dist/index.js`: commonjs, es2020
- `types: dist/index.d.ts`: typescript types
- `/src` folder with source `*.ts` files included
npm package: @naturalcycles/junit-lib
Description: Convert junit xml to html, merge multiple junit xml reports
Author: Natural Cycles Team
Latest version: 1.2.0

## @naturalcycles/junit-lib

> Convert junit xml to html, merge multiple junit xml reports.

[![npm](https://img.shields.io/npm/v/@naturalcycles/junit-lib/latest.svg)](https://www.npmjs.com/package/@naturalcycles/junit-lib)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

# Why

I didn't find a good working library in npm to convert junit xml report to html.

# Examples

```sh

# Convert `report.xml` into `report.html`
junit2html report.xml --out report.html

# Merge all xml files in `report` dir into one html report
junit2html './reports/**/*.xml' --out report.html

```

# API

- `junit2html`

# Packaging

- `engines.node`: Latest Node.js LTS
- `main: dist/index.js`: commonjs, es2020
- `types: dist/index.d.ts`: typescript types
- `/src` folder with source `*.ts` files included

# JUnit xml specification

- https://llg.cubic.org/docs/junit/
- https://stackoverflow.com/a/26661423/4919972
- https://www.ibm.com/support/knowledgecenter/en/SSUFAU_1.0.0/com.ibm.rsar.analysis.codereview.cobol.doc/topics/cac_useresults_junit.html
npm package: @naturalcycles/ktlint
Description: ktlint, conveniently published to npm registry
Author: Natural Cycles Team
Latest version: 1.16.1

## @naturalcycles/ktlint

> [ktlint](https://github.com/pinterest/ktlint) conveniently published to npm registry

[![npm](https://img.shields.io/npm/v/@naturalcycles/ktlint/latest.svg)](https://www.npmjs.com/package/@naturalcycles/ktlint)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![ktlint](https://img.shields.io/badge/code%20style-%E2%9D%A4-FF4081.svg)](https://ktlint.github.io/)

Current ktlint version: `1.8.0`

# Quick start

Just run it without installation:

```shell
npx @naturalcycles/ktlint --version
```

Or, install it like this:

```shell
yarn add -D @naturalcycles/ktlint
```

Run ktlint (locally installed into `./node_modules`):

```shell
yarn ktlint --version
```

No Step 3!

## API

You can run `ktlint` programmatically via Node.js by calling `ktlintAll()` function exposed by this
module. It returns a Promise (rejects on non-zero code from `ktlint`, resolves on success).

## Development

To update the ktlint version that is shipped here:

- Check the ktlint [release notes](https://github.com/pinterest/ktlint/releases)
- Change it in `scripts/install.ts` to the new version (and in this readme.md too)
- Delete `resources/ktlint`
- Run `pnpm tsx scripts/install.ts`, which will download the new version
- Test it with `pnpm ktlint --version`, it should print the new version
- Test it with `pnpm ktlint -F`
npm package: @naturalcycles/mongo-lib
Description: MongoDB implementation of CommonDB interface
Author: Natural Cycles Team
Latest version: 4.8.0

## @naturalcycles/mongo-lib

> MongoDB implementation of CommonDB interface

[![npm](https://img.shields.io/npm/v/@naturalcycles/mongo-lib/latest.svg)](https://www.npmjs.com/package/@naturalcycles/mongo-lib)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

# Features

- ...

# Packaging

- `engines.node`: Latest Node.js LTS
- `main: dist/index.js`: commonjs, es2019
- `types: dist/index.d.ts`: typescript types
- `/src` folder with source `*.ts` files included
npm package: @naturalcycles/mysql-lib
Description: MySQL client implementing CommonDB interface
Author: Natural Cycles Team
Latest version: 4.8.1

## @naturalcycles/mysql-lib

> MySQL client implementing CommonDB interface

[![npm](https://img.shields.io/npm/v/@naturalcycles/mysql-lib/latest.svg)](https://www.npmjs.com/package/@naturalcycles/mysql-lib)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

# Quick start

todo

# Develop

Install MySQL server+client on Mac:

```shell

brew install mysql

# start

mysql.server start

# secure

mysql_secure_installation

# connect

mysql -uroot

# Default options are read from the following files in the given order:
# /etc/my.cnf /etc/mysql/my.cnf /opt/homebrew/etc/my.cnf ~/.my.cnf

```
npm package: @naturalcycles/nodejs-lib
Description: Standard library for Node.js
Author: Natural Cycles Team
Latest version: 15.107.0

## @naturalcycles/nodejs-lib

> Standard library for Node.js

[![npm](https://img.shields.io/npm/v/@naturalcycles/nodejs-lib/latest.svg)](https://www.npmjs.com/package/@naturalcycles/nodejs-lib)
[![publish size](https://badgen.net/packagephobia/publish/@naturalcycles/nodejs-lib)](https://packagephobia.now.sh/result?p=@naturalcycles/nodejs-lib)
[![install size](https://badgen.net/packagephobia/install/@naturalcycles/nodejs-lib)](https://packagephobia.now.sh/result?p=@naturalcycles/nodejs-lib)
[![Maintainability](https://api.codeclimate.com/v1/badges/119a3b4735c4ed81cf84/maintainability)](https://codeclimate.com/github/NaturalCycles/nodejs-lib/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/119a3b4735c4ed81cf84/test_coverage)](https://codeclimate.com/github/NaturalCycles/nodejs-lib/test_coverage)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![Actions](https://github.com/NaturalCycles/nodejs-lib/workflows/ci/badge.svg)](https://github.com/NaturalCycles/nodejs-lib/actions)

# [Documentation](https://naturalcycles.github.io/nodejs-lib/)
npm package: @naturalcycles/redis-lib
Description: Redis implementation of CommonKeyValueDB interface
Author: Natural Cycles Team
Latest version: 4.4.0

## @naturalcycles/redis-lib

> Redis implementation of CommonKeyValueDB interface

[![npm](https://img.shields.io/npm/v/@naturalcycles/redis-lib/latest.svg)](https://www.npmjs.com/package/@naturalcycles/redis-lib)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

# Features

- ...

# Starting / debugging Redis server on OSX

```shell
brew install redis
brew services start redis
brew services stop redis

redis-server /usr/local/etc/redis.conf

redis-cli ping
redis-cli flushall

# connect and list all keys
redis-cli
scan 0
```

Location and size of local DB:

    ls -l /usr/local/var/db/redis/dump.rdb
npm package: @naturalcycles/semantic-release
Description: semantic-release with some tweaks and default config
Author: Natural Cycles Team
Latest version: 4.1.0

## @naturalcycles/semantic-release

> semantic-release with some tweaks

[![npm](https://img.shields.io/npm/v/@naturalcycles/semantic-release/latest.svg)](https://www.npmjs.com/package/@naturalcycles/semantic-release)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

# Features

- Install as devDependency with `yarn add -D @naturalcycles/semantic-release`
- Will give you `yarn release` command with sensible defaults
- You'll need env variables like `NPM_TOKEN`, `GITHUB_TOKEN` in your CI before calling `yarn release`

See https://github.com/semantic-release/semantic-release
 
# Development

Test it:

```shell
pnpm run release
```
npm package: @naturalcycles/spreadsheet-lib
Description: CommonDB implementation backed by a Google Spreadsheet
Author: Natural Cycles Team
Latest version: 1.1.0

## @naturalcycles/spreadsheet-lib

> [CommonDB](https://github.com/NaturalCycles/db-lib) implementation backed by a Google Spreadsheet

[![npm](https://img.shields.io/npm/v/@naturalcycles/spreadsheet-lib/latest.svg)](https://www.npmjs.com/package/@naturalcycles/spreadsheet-lib)
[![](https://circleci.com/gh/NaturalCycles/spreadsheet-lib.svg?style=shield&circle-token=123)](https://circleci.com/gh/NaturalCycles/spreadsheet-lib)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

# Example

```typescript
// Setup SpreadsheetDB
const db = new SpreadsheetDB({
  gcpServiceAccount: {
    client_email: 'lalala@lololo.iam.gserviceaccount.com'
    private_key: 'verysecret',
  },
  spreadsheetId: '17meRABNrr4Pik9FF5HRQgRxxi4kjY2_dCHg3k2nqGGE',
})

// Use it as CommonDB
const items = await db.getByIds('TEST_TABLE', ['id1', 'id2'])
// ...
```
npm package: @naturalcycles/sqlite-lib
Description: CommonDB implementation based on SQLite
Author: Natural Cycles Team
Latest version: 2.9.0

## @naturalcycles/sqlite-lib

> CommonDB implementation based on SQLite

[![npm](https://img.shields.io/npm/v/@naturalcycles/sqlite-lib/latest.svg)](https://www.npmjs.com/package/@naturalcycles/sqlite-lib)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

# Features

- ...
npm package: @naturalcycles/time-lib
Description: Date/time related API, based on Day.js
Author: Natural Cycles Team
Latest version: 3.5.3
Deprecated: deprecated, use localDate/localTime from js-lib instead

## @naturalcycles/time-lib

> Date/time API, based on Dayjs.

[![npm](https://img.shields.io/npm/v/@naturalcycles/time-lib/latest.svg)](https://www.npmjs.com/package/@naturalcycles/time-lib)
[![min.gz size](https://badgen.net/bundlephobia/minzip/@naturalcycles/time-lib)](https://bundlephobia.com/result?p=@naturalcycles/time-lib)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

# Why

- Fixes TypeScript imports, regardless if esModuleInterop is used or not
- ~~Allows to use it as ESM package with tree-shaking (without breaking your TypeScript again)~~
- Opinionated. Includes "needed" dayjs plugins by default.
- Allows to "just import dayjs" and not worry about:
  - Loading plugins for all of your "entry points", such as `startServer.ts`, `setupJest.ts`, at
    every cron job, etc.
  - That plugins are loaded BEFORE they are used (dependent on import order)
  - That TypeScript types are not loaded with plugins
- Extends dayjs with some useful functions (via Plugin interface)
- Has working `isoWeekday` plugin
- Has `en-gb` locale by default, so, default firstDayOfWeek is Monday

# API

TODO
npm package: @naturalcycles/vue-lib
Description: Useful functions for Vue.js
Author: Natural Cycles Team
Latest version: 1.1.0

## @naturalcycles/vue-lib

> Useful functions for Vue.js 2.x

[![npm](https://img.shields.io/npm/v/@naturalcycles/vue-lib/latest.svg)](https://www.npmjs.com/package/@naturalcycles/vue-lib)
[![min.gz size](https://badgen.net/bundlephobia/minzip/@naturalcycles/vue-lib)](https://bundlephobia.com/result?p=@naturalcycles/vue-lib)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

# Features

## createLocalStoragePlugin

LocalStorage persistence plugin for [Vuex](https://github.com/vuejs/vuex) 3.x (compatible with Vue
2.x).

Works in Nuxt (!).

```ts
interface GlobalState {
  count: number
}

const emptyState: GlobalState = {
  count: 0,
}

export const localStoragePlugin = createLocalStoragePlugin<GlobalState>({
  emptyState,
})

export const store = new Vuex.Store<GlobalState>({
  mutations: {},
  plugins: [localStoragePlugin],
})
```
npm package: @naturalcycles/yeoman-lib
Description: Common generator functions
Author: Natural Cycles Team
Latest version: 1.2.2

## @naturalcycles/yeoman-lib

> Common generator functions

[![npm](https://img.shields.io/npm/v/@naturalcycles/yeoman-lib/latest.svg)](https://www.npmjs.com/package/@naturalcycles/yeoman-lib)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

# Features

- ...

# Packaging

- `engines.node >= Latest LTS`
- `main: dist/index.js`: commonjs, es20202
- `types: dist/index.d.ts`: typescript types