open-index/open-npm huggingface dataset:
npm package: @orzr3/utils
Description: A Vue.js project
Author: zmy
Latest version: 1.0.2

# plugin-sum

> A Vue.js project

## Build Setup

``` bash
# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

# build for production with minification
npm run build
```

For detailed explanation on how things work, consult the [docs for vue-loader](http://vuejs.github.io/vue-loader).
npm package: @os-gurus/dynamodel
Description: Generate typed methods for DynamoDB models. With special sauce for nested props.
Author: Tim Kinnane
Latest version: 2.0.1

# DynaModel

Generate typed methods for DynamoDB models. With special sauce for nested props.

---

![CI](https://github.com/OS-Gurus/dynamodel/actions/workflows/push.yml/badge.svg)
![Release](https://github.com/OS-Gurus/dynamodel/actions/workflows/merge.yml/badge.svg)
[![npm version](https://badge.fury.io/js/%40os-gurus%2Fdynamodel.svg)](https://badge.fury.io/js/%40os-gurus%2Fdynamodel)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)

---

### Updating Nested Properties

DynaModel utility functions are instantiated with your DB connection, table and its items type, e.g.

```ts
import { dynaModel } from '@os-gurus/dynamodel'

const ddb = new DynamoDB.DocumentClient({ region: 'us-east-1' })

type HashKeys = { id: string }
type Props = { address: { country: string } }

const { makeUpdateProperty } = dynaModel<HashKeys, Props>(ddb, 'user-meta')

function updateUserCountry (id: string, country: string) {
  const update = makeUpdateProperty('address.country')
  // property paths are typed and autocomplete ☝️
  return update({ id }, country)
  // returns updated value ☝️ typed as `string`, arguments are also typed
}
```

When making updates to nested properties, first it will attempt to set the value at the given path,
but if the parent doesn't exist it will go recursively upward to create the parent object.

This approach will amortize the cost of requests, as only the first update will result in multiple
requests, subsequent updates will just set the nested property and return.

In the instance of setting `address.country` where no `address` exists on the item, it would update
`address` to `{ country: 'AU' }`. The next request would just set `address.country` to `AU`.

### Examples

```ts
import { dynaModel } from '@os-gurus/dynamodel'

const ddb = new DynamoDB.DocumentClient({ region: 'us-east-1' })
const table = `service-user-data-${process.env.STAGE}`

type UserKeys = {
  userId: string
}
type UserData = {
  name: string
  address: {
    country: string
  }
}

const usersDB = dynaModel<UserKeys, UserData>(ddb, table)

export const userModel = {
  getUser: usersDB.makeGet(),
  getUserName: usersDB.makeGetProperty('name'),
  updateUserName: usersDB.makeUpdateProperty('name'),
  updateUserCountry: usersDB.makeUpdateProperty('address.country'),
  setDefaultCountry: usersDB.makeInsertProperty('address.country')
}
```

### Known Issues

There's a problem with generating the argument type for property paths from a given object type. It ends up creating quite large definition files that are slow to load and deliver type hinting in the IDE. I know there's better solutions out there in some TS utility packages, just need to find the right approach for this usage. For now I've reduced the depth of the `Paths` utility type to make the definition files manageable.

---

That's all the docs I've got time for right now sorry. Try it out. The types are nice.
npm package: @os-team/class-validators
Description: Additional class validators.
Latest version: 1.0.14
Deprecated: No longer used

# @os-team/class-validators [![NPM version](https://img.shields.io/npm/v/@os-team/class-validators)](https://yarnpkg.com/package/@os-team/class-validators) [![BundlePhobia](https://img.shields.io/bundlephobia/minzip/@os-team/class-validators)](https://bundlephobia.com/result?p=@os-team/class-validators)

Additional class validators.

- `@IsEmail()` – Checks if the string is an email.
- `@IsInt()` – Checks if the number is an integer.
- `@IsISO4217()` – Checks if the string is a valid ISO 4217.
- `@IsISO6391()` – Checks if the string is a valid ISO 639-1.
- `@IsNotEmpty()` – Checks if the trimmed string is not empty.
- `@Max(n)` – Checks if the number is not more than given number.
- `@MaxLength(n)` – Checks if the string length is not more than given number.
- `@Max(n)` – Checks if the number is not less than given number.
- `@MinLength(n)` – Checks if the string length is not less than given number.

## Installation

Install the package using the following command:

```
yarn add @os-team/class-validators
```
npm package: @os-team/downloadfile
Description: Downloads a file using JS. Supports: tracking the download progress, aborting the download, changing the name of the downloaded file.
Latest version: 1.2.1

# @os-team/downloadfile [![NPM version](https://img.shields.io/npm/v/@os-team/downloadfile)](https://yarnpkg.com/package/@os-team/downloadfile) [![BundlePhobia](https://img.shields.io/bundlephobia/minzip/@os-team/downloadfile)](https://bundlephobia.com/result?p=@os-team/downloadfile)

Downloads a file using JS. Supports: tracking the download progress, aborting the download, changing the name of the downloaded file.

## Usage

Install the package using the following command:

```
yarn add @os-team/downloadfile
```

Download a file:

```ts
import downloadFile from '@os-team/downloadfile';

downloadFile({ url: 'https://domain.com/file.txt' });
```

## Changing the name of the downloaded file

Usually the names of files that are stored in the storage have a unique ID.

Let's assume that we have a file named `BnmiYu-80Ak`. We can download it using `window.open('https://domain.com/BnmiYu-80Ak')`, but in this case, the name of the downloaded file will be `BnmiYu-80Ak`. This is definitely not what we want. Let's use this library to download the file and rename it:

```ts
downloadFile({
  url: 'https://domain.com/BnmiYu-80Ak',
  name: 'file.txt',
});
```

Now the name of the downloaded file will be `file.txt`.

## Specifying the MIME type

If you know the MIME type of the file, specify it as follows:

```ts
downloadFile({
  url: 'https://domain.com/image',
  mime: 'image/jpeg',
});
```

## Tracking the download progress

If the file is large, then it is necessary to display the download progress bar for a user. This can be done as follows:

```ts
downloadFile({
  url: 'https://domain.com/file.txt',
  onProgress: ({ percent }) => console.log(percent),
});
```

The event has 3 numbers: `loaded`, `total`, `percent`.

## Aborting the download

A user may want to cancel the file download. You can do it as follows:

```ts
const abort = downloadFile({ url: 'https://domain.com/file.txt' });

setTimeout(() => {
  // The user decided to cancel the file download
  abort();
}, 5000);
```
npm package: @os-team/draft-to-html
Description: Converts the Draft.js state (RawDraftContentState) to HTML.
Latest version: 1.2.0

# @os-team/draft-to-html [![NPM version](https://img.shields.io/npm/v/@os-team/draft-to-html)](https://yarnpkg.com/package/@os-team/draft-to-html) [![BundlePhobia](https://img.shields.io/bundlephobia/minzip/@os-team/draft-to-html)](https://bundlephobia.com/result?p=@os-team/draft-to-html)

Converts the Draft.js state (RawDraftContentState) to HTML.

## Usage

Install the package using the following command:

```
yarn add @os-team/draft-to-html
```

### Simple usage

Import the `draftToHtml` function and pass RawDraftContentState to `value`.

```tsx
import draftToHtml from '@os-team/draft-to-html';

const html = draftToHtml({ value: state });
```

### Advanced usage

You can define how to convert any blocks, entities, and inline styles using `blockRenderer`, `entityRenderer`, and `inlineStyleRenderer` respectively.

```tsx
import draftToHtml from '@os-team/draft-to-html';

const html = draftToHtml({
  value: state,
  blockRenderer: (block, children) => {
    // Render paragraphs as div
    if (block.type === 'paragraph') {
      return `<div>${children}</div>`;
    }
    // Render images
    if (block.type === 'atomic:image') {
      return `<img src="${block.data.src}" alt="${block.text}" />`;
    }
    return null;
  },
  entityRenderer: (entity) => {
    // Render links
    if (
      entity.type === 'LINK' &&
      entity.data &&
      typeof entity.data.url === 'string'
    ) {
      return `<a href="${entity.data.url}">${entity.text}</a>`;
    }
    return null;
  },
  inlineStyleRenderer: (inlineStyle) => {
    // Render bold elements as span with the `bold` class name
    if (inlineStyle.style === 'BOLD') {
      return `<span class="bold">${inlineStyle.text}</span>`;
    }
    // Render custom inline style elements
    if (inlineStyle.style === 'CUSTOM') {
      return `<span class="custom">${inlineStyle.text}</span>`;
    }
    return null;
  },
});
```
npm package: @os-team/form-utils
Description: Utils for working with forms.
Latest version: 1.0.32
Deprecated: Use the @os-design/form library to build forms

# @os-team/form-utils [![NPM version](https://img.shields.io/npm/v/@os-team/form-utils)](https://yarnpkg.com/package/@os-team/form-utils) [![BundlePhobia](https://img.shields.io/bundlephobia/minzip/@os-team/form-utils)](https://bundlephobia.com/result?p=@os-team/form-utils)

Utils for working with forms.

The library is compatible with `os-design` and `os-design-mobile`.

## Usage

Install the package using the following command:

```
yarn add @os-team/form-utils
```
npm package: @os-team/google-image-storage
Description: Library for uploading images to the Google Cloud Storage.
Latest version: 1.2.2

# @os-team/google-image-storage [![NPM version](https://img.shields.io/npm/v/@os-team/google-image-storage)](https://yarnpkg.com/package/@os-team/google-image-storage) [![BundlePhobia](https://img.shields.io/bundlephobia/minzip/@os-team/google-image-storage)](https://bundlephobia.com/result?p=@os-team/google-image-storage)

Library for uploading images to the Google Cloud Storage.

Usually when you want to store an image you need:

1. Validate the file type (e.g. allow only JPG, PNG, WEBP image formats). The file type should be detected by the first bytes, not by the file name (e.g. using the [file-type](https://github.com/sindresorhus/file-type) library).
2. Validate the file size.
3. Convert the image to a specific extension (e.g. to JPG).
4. Upload an image in multiple sizes to use them on the frontend side in different places (e.g. a large avatar on the profile page, a small avatar in the header).
5. Crop some sizes of the image to use them, for example, in a list of blog posts.
6. Append a hash to the file name to avoid caching when updating the image.
7. Delete old images that have been replaced with new ones.

This library performs all these steps.

## Usage

Install the package using the following command:

```
yarn add @os-team/google-image-storage @google-cloud/storage
```

### Example

```ts
import { Storage } from '@google-cloud/storage';
import GoogleImageStorage from '@os-team/google-image-storage';

// Initialize the Google Cloud Storage
const storage = new Storage({
  keyFilename: path.resolve(__dirname, './google-cloud-key.json'),
  projectId: 'projectId',
});

// Initialize the Image Storage
const imageStorage = new GoogleImageStorage({
  storage,
  bucket: 'my-bucket',
});

// Upload an image
const { name } = await imageStorage.upload({
  body: createReadStream('my-image.jpg'),
  name: 'name',
});

// Delete the image
await imageStorage.delete(name);
```

This library extends the [@os-team/image-storage](https://gitlab.com/os-team/libs/utils/-/tree/main/packages/image-storage) lib, so see it for more information about uploading and deleting files.
npm package: @os-team/graphql-transformers
Description: The type-graphql decorator to transform arguments. Contains the most used transformers.
Latest version: 1.2.1

# @os-team/graphql-transformers [![NPM version](https://img.shields.io/npm/v/@os-team/graphql-transformers)](https://yarnpkg.com/package/@os-team/graphql-transformers) [![BundlePhobia](https://img.shields.io/bundlephobia/minzip/@os-team/graphql-transformers)](https://bundlephobia.com/result?p=@os-team/graphql-transformers)

The type-graphql decorator to transform arguments. Contains the most used transformers.

## Installation

Install the package using the following command:

```
yarn add @os-team/graphql-transformers
```

It is assumed that the `type-graphql` library is already installed.

## Usage

For example, we have the fox entity and 2 files: `CreateFoxInput.ts` and `FoxResolver.ts`.

### Step 1. Create transformers

```ts
import { Field, InputType } from 'type-graphql';
import { trim, toLowerCase } from '@os-team/graphql-transformers';

@InputType()
class CreateFoxInput {
  @Field()
  name!: string;
}

export const createFoxTransformers = {
  name: [trim, toLowerCase],
};

export default CreateFoxInput;
```

### Step 2. Add the `@TransformArgs` decorator

```ts
import { Arg, Mutation, Resolver } from 'type-graphql';
import { TransformArgs } from '@os-team/graphql-transformers';
import Fox from '../../entities/Fox';
import CreateFoxInput, { createFoxTransformers } from './CreateFoxInput';

@Resolver(() => Fox)
class FoxResolver {
  @TransformArgs(createFoxTransformers, { arg: 'input' })
  @Mutation(() => Fox)
  async createFox(@Arg('input') input: CreateFoxInput): Promise<Fox> {
    // The implementation
  }
}

export default FoxResolver;
```

If you did not specify the `arg` parameter, the `@TransformArgs` decorator will transform all the arguments.
It can be useful, for example, if you want to transform the connection arguments.

```ts
import { Args, Query, Resolver } from 'type-graphql';
import { TransformArgs } from '@os-team/graphql-transformers';
import { ConnectionArgs, createConnectionType } from '@os-team/graphql-utils';
import Fox from '../../entities/Fox';
import FoxConnectionArgs, {
  foxConnectionTransformers,
} from './FoxConnectionArgs';

export const FoxConnection = createConnectionType(Fox);

@Resolver(() => Fox)
class FoxResolver {
  @TransformArgs(foxConnectionTransformers)
  @Query(() => FoxConnection)
  async foxes(@Args() args: FoxConnectionArgs): Promise<Connection<Fox>> {
    // The implementation
  }
}

export default FoxResolver;
```

## Create the custom transformer

You can create your own transformers like this:

```ts
import { Transformer } from '../utils/TransformArgs';

const trim: Transformer<string> = (value) => value.trim();

export default trim;
```

The transformer can only be synchronous.
npm package: @os-team/graphql-utils
Description: Shared utils for GraphQL.
Latest version: 1.3.2

# @os-team/graphql-utils [![NPM version](https://img.shields.io/npm/v/@os-team/graphql-utils)](https://yarnpkg.com/package/@os-team/graphql-utils) [![BundlePhobia](https://img.shields.io/bundlephobia/minzip/@os-team/graphql-utils)](https://bundlephobia.com/result?p=@os-team/graphql-utils)

Shared utils for GraphQL.

## Installation

Install the package using the following command:

```
yarn add @os-team/graphql-utils
```

Install peer dependencies using the following command:

```
npx install-peerdeps @os-team/graphql-utils
```
npm package: @os-team/i18next-express-middleware
Description: Middleware for i18next and express to detect the user's language.
Latest version: 1.0.11
Deprecated: Deprecated in favour of i18next-http-middleware

# @os-team/i18next-express-middleware [![NPM version](https://img.shields.io/npm/v/@os-team/i18next-express-middleware)](https://yarnpkg.com/package/@os-team/i18next-express-middleware) [![BundlePhobia](https://img.shields.io/bundlephobia/minzip/@os-team/i18next-express-middleware)](https://bundlephobia.com/result?p=@os-team/i18next-express-middleware)

Middleware for i18next and express to detect the user's language.

## Usage

Install the package using the following command:

```
yarn add @os-team/i18next-express-middleware
```

Install peer dependencies using the following command:

```
npx install-peerdeps @os-team/i18next-express-middleware
```

### Example

```ts
import express from 'express';
import cookieParser from 'cookie-parser';
import i18next from 'i18next';
import {
  i18nextMiddleware,
  LanguageDetector,
} from '@os-team/i18next-express-middleware';

// Initialize i18next
i18next
  .use(LanguageDetector) // Pass the LanguageDetector middleware
  .init({
    fallbackLng: 'en',

    // Pass the custom options if necessary
    detection: {
      // In what order will the detectors be started
      order: ['cookie', 'header'], // default: ['header']

      // Keys used by the detectors
      cookie: 'custom-cookie', // default: i18next
      header: 'custom-header', // default: Accept-Language
    },
  });

const app = express();
app.use(cookieParser());
app.use(i18nextMiddleware(i18next));
```
npm package: @os-team/i18next-tld-language-detector
Description: The i18next language detector, which is used to detect the user's language by a top-level domain (TLD).
Latest version: 1.4.1

# @os-team/i18next-tld-language-detector [![NPM version](https://img.shields.io/npm/v/@os-team/i18next-tld-language-detector)](https://yarnpkg.com/package/@os-team/i18next-tld-language-detector) [![BundlePhobia](https://img.shields.io/bundlephobia/minzip/@os-team/i18next-tld-language-detector)](https://bundlephobia.com/result?p=@os-team/i18next-tld-language-detector)

The i18next language detector, which is used to detect the user's language by a top-level domain (TLD).

## Usage

Install the package using the following command:

```
yarn add @os-team/i18next-tld-language-detector
```

### Client-side usage example

```ts
import i18next from 'i18next';
import HttpBackend from 'i18next-http-backend';
import LanguageDetector from 'i18next-browser-languagedetector';
import { browserTldLanguageDetector } from '@os-team/i18next-tld-language-detector';
import { initReactI18next } from 'react-i18next';

const languageDetector = new LanguageDetector();
languageDetector.addDetector(browserTldLanguageDetector); // Add tldLanguageDetector

i18next
  .use(HttpBackend)
  .use(languageDetector)
  .use(initReactI18next)
  .init({
    detection: {
      order: ['cookie', 'tld'], // Add tld
      lookupCookie: 'lng',
      caches: ['cookie'],
    },
  });

export default i18next;
```

### Server-side usage example

```ts
import i18next from 'i18next';
import FsBackend from 'i18next-fs-backend';
import { LanguageDetector } from 'i18next-http-middleware';
import { httpTldLanguageDetector } from '@os-team/i18next-tld-language-detector';
import path from 'path';

const languageDetector = new LanguageDetector();
languageDetector.addDetector(httpTldLanguageDetector); // Add tldLanguageDetector

i18next
  .use(FsBackend)
  .use(languageDetector)
  .init({
    fallbackLng: 'en',
    ns: ['validation'],
    backend: {
      loadPath: path.join(__dirname, '../locales/{{lng}}/{{ns}}.json'),
    },
    detection: {
      order: ['tld'], // Add tld
    },
  });
```
npm package: @os-team/mailgun-mailer
Description: The wrapper of the mailgun-js which allows to set the shared mail data.
Latest version: 1.0.14
Deprecated: No longer supported

# @os-team/mailgun-mailer [![NPM version](https://img.shields.io/npm/v/@os-team/mailgun-mailer)](https://yarnpkg.com/package/@os-team/mailgun-mailer) [![BundlePhobia](https://img.shields.io/bundlephobia/minzip/@os-team/mailgun-mailer)](https://bundlephobia.com/result?p=@os-team/mailgun-mailer)

The wrapper of the mailgun-js which allows to set the shared mail data.

## Usage

### Step 1. Install the package

Install the package using the following command:

```
yarn add @os-team/mailgun-mailer
```

### Step 2. Create an instance of MailgunMailer

The shared mail data will be used when sending each email.

```ts
const sharedMailData = {
  from: 'Company <mg@m.domain.com>',
  'o:dkim': true,
  'o:tracking': true,
  'o:tracking-opens': true,
  'o:tracking-clicks': true,
  'h:Reply-To': 'support@domain.com',
};

const mailer = new MailgunMailer(
  {
    apiKey: process.env.MAILGUN_API_KEY,
    domain: 'm.domain.com',
    mute: process.env.NODE_ENV === 'production',
    host: 'api.eu.mailgun.net',
  },
  sharedMailData
);
```

### Step 3. Send an email

```ts
await mailer.send({
  to: 'user@domain.com',
  subject: 'Subject',
  text: 'Message',
});
```

See about sending emails in the [Mailgun documentation](https://documentation.mailgun.com/en/latest/api-sending.html).
npm package: @os-team/password-score
Description: Calculates a password strength score.
Latest version: 1.0.5
Deprecated: Moved to @os-design/input-password-utils

# @os-team/password-score [![NPM version](https://img.shields.io/npm/v/@os-team/password-score)](https://yarnpkg.com/package/@os-team/password-score) [![BundlePhobia](https://img.shields.io/bundlephobia/minzip/@os-team/password-score)](https://bundlephobia.com/result?p=@os-team/password-score)

Calculates a password strength score.

## Usage

### Install the package

Install the package using the following command:

```
yarn add @os-team/password-score
```

### Simple usage

```ts
import getPasswordScore from '@os-team/password-score';

const passwordScore = getPasswordScore('password'); // 38
```

The following thresholds can be used to determine the strength of a password:

- `[score] < 30` – weak.
- `30 ≤ [score] < 60` – good.
- `60 ≤ [score] < 80` – strong.
- `[score] ≥ 80` – powerful.

Based on [this answer](https://stackoverflow.com/a/11268104/8896318).
npm package: @os-team/plural-forms
Description: Declines nouns in the plural form. English and Russian languages are supported.
Latest version: 1.1.1

# @os-team/plural-forms [![NPM version](https://img.shields.io/npm/v/@os-team/plural-forms)](https://yarnpkg.com/package/@os-team/plural-forms) [![BundlePhobia](https://img.shields.io/bundlephobia/minzip/@os-team/plural-forms)](https://bundlephobia.com/result?p=@os-team/plural-forms)

Declines nouns in the plural form. English and Russian languages are supported.

## Usage

Install the package using the following command:

```
yarn add @os-team/plural-forms
```

### Example 1. English language

```ts
const years = 21;
const yearsPluralForm = pluralForms({
  language: 'en',
  forms: ['year', 'years'],
  number: years,
});
console.log(`${years} ${yearsPluralForm}`); // 21 years
```

### Example 2. Russian language

```ts
const years = 21;
const yearsPluralForm = pluralForms({
  language: 'ru',
  forms: ['год', 'года', 'лет'],
  number: years,
});
console.log(`${years} ${yearsPluralForm}`); // 21 год
```
npm package: @os-team/prettier-config
Description: Prettier config.
Latest version: 1.4.1

# @os-team/prettier-config [![NPM version](https://img.shields.io/npm/v/@os-team/prettier-config)](https://yarnpkg.com/package/@os-team/prettier-config)

Prettier config.

## Installation

### Prerequisites

Install the exact version (-E) of `prettier` in devDependencies (-D) using the following command:

```
yarn add -DE prettier
```

### Step 1. Install the package

Install the exact version (-E) of the package in devDependencies (-D) using the following command:

```
yarn add -DE @os-team/prettier-config
```

### Step 2. Add the config

The way you add the prettier config to your project depends on whether you want to override some properties or not.

#### Option 1. Using the default config

Create the `.prettierrc` file with the following content

```json
"@os-team/prettier-config"
```

#### Option 2. Overriding some properties

Create the `.prettierrc.js` file with the following content

```js
module.exports = {
  ...require('@os-team/prettier-config'),
  semi: false,
};
```

In this example, you are overriding the `semi` property.
npm package: @os-team/pretty-size
Description: A tiny converter of number of bytes into a human-readable string. Support for all measures up to petabyte.
Latest version: 1.2.1

# @os-team/pretty-size [![NPM version](https://img.shields.io/npm/v/@os-team/pretty-size)](https://yarnpkg.com/package/@os-team/pretty-size) [![BundlePhobia](https://img.shields.io/bundlephobia/minzip/@os-team/pretty-size)](https://bundlephobia.com/result?p=@os-team/pretty-size)

A tiny converter of number of bytes into a human-readable string. Support for all measures up to petabyte.

## Usage

Install the package using the following command:

```
yarn add @os-team/pretty-size
```

Convert the file size as follows:

```ts
import prettySize from '@os-team/pretty-size';

const size = prettySize(1.123 * 10 ** 6); // 1.1 MB
```

By defualt, the precision is `1`. You can set your own value as follows:

```ts
const size = prettySize(1.123 * 10 ** 3, {
  precision: 2,
}); // 1.12 KB
```

By default, the base of the number is `10`. You can set your own value as follows:

```ts
const size = prettySize(1.123 * 2 ** 10, {
  base: 2,
}); // 1.1 KB
```
npm package: @os-team/relay-network-mw-credentials
Description: The middleware for @os-team/relay-network-creator to include credentials in each request.
Latest version: 1.1.17
Deprecated: The package @os-team/relay-network-creator includes credentials by default

# @os-team/relay-network-mw-credentials [![NPM version](https://img.shields.io/npm/v/@os-team/relay-network-mw-credentials)](https://yarnpkg.com/package/@os-team/relay-network-mw-credentials) [![BundlePhobia](https://img.shields.io/bundlephobia/minzip/@os-team/relay-network-mw-credentials)](https://bundlephobia.com/result?p=@os-team/relay-network-mw-credentials)

The middleware for @os-team/relay-network-creator to include credentials in each request.

## Usage

### Step 1. Install the package

Install the package using the following command:

```
yarn add @os-team/relay-network-mw-credentials
```

### Step 2. Add the middleware

To add this middleware, pass it as the second parameter in the `createRelayNetwork` function:

```ts
import { createRelayNetwork } from '@os-team/relay-network-creator';
import credentials from '@os-team/relay-network-mw-credentials';

createRelayNetwork('https://api.domain.com', [credentials]);
```
npm package: @os-team/relay-network-mw-timeout
Description: The middleware for @os-team/relay-network-creator to abort a request if it takes more than N ms.
Latest version: 1.0.15
Deprecated: The timeout feature is availiable in the package @os-team/relay-network-creator

# @os-team/relay-network-mw-timeout [![NPM version](https://img.shields.io/npm/v/@os-team/relay-network-mw-timeout)](https://yarnpkg.com/package/@os-team/relay-network-mw-timeout) [![BundlePhobia](https://img.shields.io/bundlephobia/minzip/@os-team/relay-network-mw-timeout)](https://bundlephobia.com/result?p=@os-team/relay-network-mw-timeout)

The middleware for @os-team/relay-network-creator to abort a request if it takes more than N ms.

## Usage

### Step 1. Install the package

Install the package using the following command:

```
yarn add @os-team/relay-network-mw-timeout
```

### Step 2. Add the middleware

To add this middleware, pass it as the second parameter in the `createRelayNetwork` function:

```ts
import { createRelayNetwork } from '@os-team/relay-network-creator';
import timeout from '@os-team/relay-network-mw-timeout';

createRelayNetwork('https://api.domain.com', [timeout(30000)]);
```
npm package: @os-team/relay-network-mw-upload
Description: The middleware for @os-team/relay-network-creator to transform each request by [GraphQL multipart request specification](https://github.com/jaydenseric/graphql-multipart-request-spec) for file uploads.
Latest version: 1.3.2

# @os-team/relay-network-mw-upload [![NPM version](https://img.shields.io/npm/v/@os-team/relay-network-mw-upload)](https://yarnpkg.com/package/@os-team/relay-network-mw-upload) [![BundlePhobia](https://img.shields.io/bundlephobia/minzip/@os-team/relay-network-mw-upload)](https://bundlephobia.com/result?p=@os-team/relay-network-mw-upload)

The middleware for @os-team/relay-network-creator to transform each request by [GraphQL multipart request specification](https://github.com/jaydenseric/graphql-multipart-request-spec) for file uploads.

## Usage

### Step 1. Install the package

Install the package using the following command:

```
yarn add @os-team/relay-network-mw-upload
```

### Step 2. Add the middleware

```ts
import createRelayNetwork from '@os-team/relay-network-creator';
import upload from '@os-team/relay-network-mw-upload';

createRelayNetwork({
  url: 'https://api.domain.com/graphql',
  middlewares: [upload],
});
```
npm package: @os-team/sendgrid-mailer
Description: The wrapper of the @sendgrid/mail which allows to set the shared mail data.
Latest version: 1.0.19
Deprecated: No longer supported

# @os-team/sendgrid-mailer [![NPM version](https://img.shields.io/npm/v/@os-team/sendgrid-mailer)](https://yarnpkg.com/package/@os-team/sendgrid-mailer) [![BundlePhobia](https://img.shields.io/bundlephobia/minzip/@os-team/sendgrid-mailer)](https://bundlephobia.com/result?p=@os-team/sendgrid-mailer)

The wrapper of the @sendgrid/mail which allows to set the shared mail data.

## Usage

### Step 1. Install the package

Install the package using the following command:

```
yarn add @os-team/sendgrid-mailer
```

### Step 2. Create an instance of SendGridMailer

The shared mail data will be used when sending each email.

```ts
const mailer = new SendGridMailer({
  apiKey: process.env.SENDGRID_API_KEY,
  from: 'Company <mg@m.domain.com>',
  replyTo: 'support@domain.com',
});
```

### Step 3. Send an email

```ts
await mailer.send({
  to: 'user@domain.com',
  subject: 'Subject',
  text: 'Message',
});
```

See about sending emails in the [SendGrid documentation](https://sendgrid.api-docs.io/v3.0/mail-send/v3-mail-send).
npm package: @os-team/stream-length
Description: Gets and validates the length of a stream.
Latest version: 1.2.0

# @os-team/stream-length [![NPM version](https://img.shields.io/npm/v/@os-team/stream-length)](https://yarnpkg.com/package/@os-team/stream-length) [![BundlePhobia](https://img.shields.io/bundlephobia/minzip/@os-team/stream-length)](https://bundlephobia.com/result?p=@os-team/stream-length)

Gets and validates the length of a stream.

## Usage

Install the package using the following command:

```
yarn add @os-team/stream-length
```

Get the length of a stream as follows:

```ts
import streamLength from '@os-team/stream-length';

(async () => {
  const stream = streamLength(createReadableStream());
  await consumeReadableStream(stream);
  const fileSize = stream.length; // It is important to get the length after the stream has beed consumed
})();
```

If you want to validate the length of a stream, specify the `maxLength` option:

```ts
const stream = streamLength(createReadableStream(), {
  maxLength: 100,
});
```

To change the error message, specify the `errorMessage` option:

```ts
const stream = streamLength(createReadableStream(), {
  maxLength: 100,
  errorMessage: 'The file must be no larger than 100 bytes',
});
```
npm package: @os-team/tinkoff-oplata
Description: Tinkoff Oplata API. All methods described in the [official documentation](https://oplata.tinkoff.ru/develop/api/) are implemented.
Latest version: 1.2.1

# @os-team/tinkoff-oplata [![NPM version](https://img.shields.io/npm/v/@os-team/tinkoff-oplata)](https://yarnpkg.com/package/@os-team/tinkoff-oplata) [![BundlePhobia](https://img.shields.io/bundlephobia/minzip/@os-team/tinkoff-oplata)](https://bundlephobia.com/result?p=@os-team/tinkoff-oplata)

Tinkoff Oplata API. All methods described in the [official documentation](https://oplata.tinkoff.ru/develop/api/) are implemented.

## Example

```ts
const client = new TinkoffOplataClient({
  terminalKey: 'terminalKey',
  password: 'password',
});

const res = await client.init({
  Amount: 100,
  OrderId: '1',
  Description: 'Тестовый платеж',
  DATA: {
    Phone: '+71234567890',
    Email: 'name@domain.com',
  },
  Receipt: {
    Email: 'name@domain.com',
    Phone: '+71234567890',
    EmailCompany: 'name@company.com',
    Taxation: 'osn',
    Items: [
      {
        Name: 'Наименование товара',
        Price: 30000,
        Quantity: 3.0,
        Amount: 90000,
        Tax: 'vat10',
      },
    ],
  },
});
```
npm package: @os-team/typeorm-seeder
Description: Simple seeder for seeding data in tests using TypeORM.
Latest version: 1.0.17
Deprecated: Unsupported. Migrated to slonik. See @os-team/slonik-seeder.

# @os-team/typeorm-seeder [![NPM version](https://img.shields.io/npm/v/@os-team/typeorm-seeder)](https://yarnpkg.com/package/@os-team/typeorm-seeder)

Simple seeder for seeding data in tests using TypeORM.

## Usage

Install the package in devDependencies (-D) using the following command:

```
yarn add -D @os-team/typeorm-seeder
```

### Example of test

```ts
import 'reflect-metadata';
import { Connection, createConnection } from 'typeorm';
import createSeeder, { Seeder } from '@os-team/typeorm-seeder';
import User from '../../entities/User';
import Payment from '../../entities/Payment';

let connection: Connection;
let seeder: Seeder;

beforeEach(async () => {
  connection = await createConnection();
  seeder = createSeeder(connection.manager); // Create the seeder
});

afterEach(async () => {
  await connection.close();
});

it('Should change the payment status to succeeded', async () => {
  // Seed a user
  const userData = {
    id: 1,
    name: 'name',
  };
  await seeder.seed(User, userData);

  // Seed payments
  await seeder.seed(Payment, [
    {
      id: 1,
      amount: 1000,
      status: 'pending',
      user: { id: userData.id },
    },
    {
      id: 2,
      amount: 2000,
      status: 'pending',
      user: { id: userData.id },
    },
  ]);

  // ...
});
```

Most likely you will use multiple test files (e.g. one test file for testing one API method).
In this case:

1. Put `beforeEach`, `afterEach` and global variables (connection, seeder) to a separate file. Export the `seeder` variable to use it in any test file.
1. Add the path to this file to [setupFilesAfterEnv](https://jestjs.io/docs/en/configuration#setupfilesafterenv-array). Jest will run this code before each test file in the suite is executed.
1. Set the `dropSchema` option in the TypeORM config to `true` **ONLY** in the test environment. TypeORM drops the schema each time connection is being established (before each test file). See more about [TypeORM connection options](https://github.com/typeorm/typeorm/blob/master/docs/connection-options.md).
npm package: @os-team/typeorm-utils
Description: Additional functions to work with databases using TypeORM.
Latest version: 1.0.28
Deprecated: Unsupported.

# @os-team/typeorm-utils [![NPM version](https://img.shields.io/npm/v/@os-team/typeorm-utils)](https://yarnpkg.com/package/@os-team/typeorm-utils) [![BundlePhobia](https://img.shields.io/bundlephobia/minzip/@os-team/typeorm-utils)](https://bundlephobia.com/result?p=@os-team/typeorm-utils)

Additional functions to work with databases using TypeORM.

- `createDatabaseIfNotExists` – Creates a new database if not exists.
- `dropDatabaseIfExists` – Drops a database if exists.
- `getConnectionByDatabase` – Creates a new connection by the database name. Creates database if not exists.
- `getDatabaseNameByHost` – Transforms a host to use it in the database name.
- `getNameByHost` – Transforms a host to the second-level domain name.
- `hasDatabase` – Check if a database exists.

## Installation

Install the package using the following command:

```
yarn add @os-team/typeorm-utils
```
npm package: @os-team/use-load-next
Description: The React hook that performs pagination in Relay.
Latest version: 1.0.16
Deprecated: Moved to @os-design/use-load-next

# @os-team/use-load-next [![NPM version](https://img.shields.io/npm/v/@os-team/use-load-next)](https://yarnpkg.com/package/@os-team/use-load-next) [![BundlePhobia](https://img.shields.io/bundlephobia/minzip/@os-team/use-load-next)](https://bundlephobia.com/result?p=@os-team/use-load-next)

The React hook that performs pagination in Relay.

The `usePaginationFragment` provides you the `loadNext` function that you need to call when the user scrolls to the end of the page.
The `useLoadNext` hook allows you to do this in the simplest way possible.

## Usage

Install the package using the following command:

```
yarn add @os-team/use-load-next
```

Example:

```ts
const { data, ...loadProps } = usePaginationFragment(
  videoListFragment,
  props.videos
);

useLoadNext(loadProps);
```

You can load the specified number of items on the next page by passing the `count` parameter.

```ts
useLoadNext(loadProps, { count: 10 });
```

Also, you can load the next page before the user reaches the threshold (in px) to the end of the page.

```ts
useLoadNext(loadProps, { threshold: 1000 });
```

By default, the `threshold` parameter equals 500.
npm package: @os-team/yandex-checkout
Description: Yandex.Checkout API v3. All methods described in the [official documentation](https://yookassa.ru/en/developers/api) are implemented (payments, refunds and receipts).
Latest version: 1.0.1
Deprecated: Moved to @os-team/yoo-money

# @os-team/yandex-checkout

Yandex.Checkout API v3. All methods described in the [official documentation](https://yookassa.ru/en/developers/api) are implemented (payments, refunds and receipts).

## Examples

### Create a payment

```ts
const yandexCheckout = new YandexCheckout({
  shopId: 'shopId',
  secretKey: 'secretKey',
});

const payment = await yandexCheckout.payments.create(
  {
    amount: {
      value: '2.00',
      currency: 'RUB',
    },
    payment_method_data: {
      type: 'bank_card',
    },
    confirmation: {
      type: 'redirect',
      return_url: 'https://www.merchant-website.com/return_url',
    },
    description: 'Order No. 1',
  },
  'idempotenceKey'
);
```

### Create a recurring payment

```ts
// Create a payment and save a payment method
const firstPayment = await yandexCheckout.payments.create(
  {
    amount: {
      value: '2.00',
      currency: 'RUB',
    },
    payment_method_data: {
      type: 'bank_card',
    },
    confirmation: {
      type: 'redirect',
      return_url: 'https://www.merchant-website.com/return_url',
    },
    description: 'Order No. 1',
    save_payment_method: true,
    capture: true,
  },
  'idempotenceKey'
);

// Using the saved payment method, create a recurring payment
const secondPayment = await yandexCheckout.payments.create(
  {
    amount: {
      value: '2.00',
      currency: 'RUB',
    },
    payment_method_id: firstPayment.payment_method.id,
    description: 'Order No. 2',
    capture: true,
  },
  'idempotenceKey'
);
```

## Supported methods

- payments.create
- payments.list
- payments.get
- payments.capture
- payments.cancel
- refunds.create
- refunds.list
- refunds.get
- receipts.create
- receipts.list
- receipts.get
npm package: @os-team/yandex-image-storage
Description: Library for uploading images to the Yandex Cloud Storage.
Latest version: 1.2.2

# @os-team/yandex-image-storage [![NPM version](https://img.shields.io/npm/v/@os-team/yandex-image-storage)](https://yarnpkg.com/package/@os-team/yandex-image-storage) [![BundlePhobia](https://img.shields.io/bundlephobia/minzip/@os-team/yandex-image-storage)](https://bundlephobia.com/result?p=@os-team/yandex-image-storage)

Library for uploading images to the Yandex Cloud Storage.

Usually when you want to store an image you need:

1. Validate the file type (e.g. allow only JPG, PNG, WEBP image formats). The file type should be detected by the first bytes, not by the file name (e.g. using the [file-type](https://github.com/sindresorhus/file-type) library).
2. Validate the file size.
3. Convert the image to a specific extension (e.g. to JPG).
4. Upload an image in multiple sizes to use them on the frontend side in different places (e.g. a large avatar on the profile page, a small avatar in the header).
5. Crop some sizes of the image to use them, for example, in a list of blog posts.
6. Append a hash to the file name to avoid caching when updating the image.
7. Delete old images that have been replaced with new ones.

This library performs all these steps.

## Usage

Install the package using the following command:

```
yarn add @os-team/yandex-image-storage @os-team/yc-storage
```

### Example

```ts
import YandexStorage from '@os-team/yc-storage';
import YandexImageStorage from '@os-team/yandex-image-storage';

// Initialize the Yandex Cloud Storage
const storage = new YandexStorage({
  accessKeyId: 'accessKeyId',
  secretAccessKey: 'secretAccessKey',
  region: 'ru-central1-a',
});

// Initialize the Image Storage
const imageStorage = new YandexImageStorage({
  storage,
  bucket: 'my-bucket',
});

// Upload an image
const { name } = await imageStorage.upload({
  body: createReadStream('my-image.jpg'),
  name: 'name',
});

// Delete the image
await imageStorage.delete(name);
```

This library extends the [@os-team/image-storage](https://gitlab.com/os-team/libs/utils/-/tree/main/packages/image-storage) lib, so see it for more information about uploading and deleting files.
npm package: @os-team/yoo-money
Description: YooMoney API v3. All methods described in the [official documentation](https://yookassa.ru/en/developers/api) are implemented (payments, refunds and receipts).
Latest version: 1.2.1

# @os-team/yoo-money [![NPM version](https://img.shields.io/npm/v/@os-team/yoo-money)](https://yarnpkg.com/package/@os-team/yoo-money) [![BundlePhobia](https://img.shields.io/bundlephobia/minzip/@os-team/yoo-money)](https://bundlephobia.com/result?p=@os-team/yoo-money)

YooMoney API v3. All methods described in the [official documentation](https://yookassa.ru/en/developers/api) are implemented (payments, refunds and receipts).

## Examples

### Create a payment

```ts
const yooMoney = new YooMoney({
  shopId: 'shopId',
  secretKey: 'secretKey',
});

const payment = await yooMoney.payments.create(
  {
    amount: {
      value: '2.00',
      currency: 'RUB',
    },
    payment_method_data: {
      type: 'bank_card',
    },
    confirmation: {
      type: 'redirect',
      return_url: 'https://www.merchant-website.com/return_url',
    },
    description: 'Order No. 1',
  },
  'idempotenceKey'
);
```

### Create a recurring payment

```ts
// Create a payment and save a payment method
const firstPayment = await yooMoney.payments.create(
  {
    amount: {
      value: '2.00',
      currency: 'RUB',
    },
    payment_method_data: {
      type: 'bank_card',
    },
    confirmation: {
      type: 'redirect',
      return_url: 'https://www.merchant-website.com/return_url',
    },
    description: 'Order No. 1',
    save_payment_method: true,
    capture: true,
  },
  'idempotenceKey'
);

// Using the saved payment method, create a recurring payment
const secondPayment = await yooMoney.payments.create(
  {
    amount: {
      value: '2.00',
      currency: 'RUB',
    },
    payment_method_id: firstPayment.payment_method.id,
    description: 'Order No. 2',
    capture: true,
  },
  'idempotenceKey'
);
```

## Supported methods

- payments.create
- payments.list
- payments.get
- payments.capture
- payments.cancel
- refunds.create
- refunds.list
- refunds.get
- receipts.create
- receipts.list
- receipts.get
npm package: @os-theme/darwin-arm64
Description: os-theme prebuilt binary for macOS ARM64
Latest version: 0.0.8

# @os-theme/darwin-arm64

Prebuilt macOS ARM64 binary for [os-theme](https://github.com/basiclines/os-theme).

This package is automatically installed as an optional dependency of `os-theme`. You should not need to install it directly.
npm package: @os-theme/linux-x64
Description: os-theme prebuilt binary for Linux x64
Latest version: 0.0.8

# @os-theme/linux-x64

Prebuilt Linux x64 binary for [os-theme](https://github.com/basiclines/os-theme).

This package is automatically installed as an optional dependency of `os-theme`. You should not need to install it directly.
npm package: @os-theme/win32-x64
Description: os-theme prebuilt binary for Windows x64
Latest version: 0.0.8

# @os-theme/win32-x64

Prebuilt Windows x64 binary for [os-theme](https://github.com/basiclines/os-theme).

This package is automatically installed as an optional dependency of `os-theme`. You should not need to install it directly.
npm package: @os-utils/graphql-test-client
Description: The wrapper of the superagent to make GraphQL queries in tests.
Latest version: 0.0.12
Deprecated: Moved to @os-team/graphql-test-client

# @os-utils/graphql-test-client

The wrapper of the superagent to make GraphQL queries in tests.

Unlike apollo-boost and apollo-client, superagent saves cookies in the Node.js environment.

## Examples
### Base request

```typescript
import TestClient from '@os-utils/graphql-test-client'

// Example of mutation
const signInMutation = `
  mutation SignInMutation($input: SignInInput!) {
    signIn(input: $input) {
      ok
    }
  }
`

it('Should make a request successfully', async () => {
  // Example of input data
  const input = {
    email: 'name@domain.com',
    password: 'password',
  }

  // Create an instance of TestClient ans pass the GraphQL url
  const client = new TestClient({
    url: 'http://localhost:4000/graphql',
  })

  // Make a GraphQL request and pass the variables
  const res = await client.query({
    query: signInMutation,
    variables: { input },
  })

  expect(res.body.errors).toBeUndefined()
  expect(res.body.data).toBeDefined()
})
```

### Request with cookies
```typescript
import TestClient from '@os-utils/graphql-test-client'

const signInMutation = `
  mutation SignInMutation($input: SignInInput!) {
    signIn(input: $input) {
      ok
    }
  }
`

const profileQuery = `
  query profileQuery {
    profile {
      email
      firstName
      lastName
    }
  }
`

it('Should sign in successfully', async () => {
  const input = {
    email: 'name@domain.com',
    password: 'password',
  }

  const client = new TestClient({
    url: 'http://localhost:4000/graphql',
    saveCookies: true,
  })

  await client.query({
    query: signInMutation,
    variables: { input },
  })

  const res = await client.query({
    query: profileQuery,
  })
  
  expect(res.body.errors).toBeUndefined()
  expect(res.body.data).toBeDefined()
})
```
npm package: @os-utils/i18next-express-middleware
Description: Middleware for `i18next` and `express` to detect the language. Supports TypeScript.
Latest version: 0.0.15
Deprecated: Moved to @os-team/i18next-express-middleware

# @os-utils/i18next-express-middleware

Middleware for `i18next` and `express` to detect the language. Supports TypeScript.

## Getting started
### Installation
```
yarn add @os-utils/i18next-express-middleware
```
Also install [cookie-parser](https://github.com/expressjs/cookie-parser) if you need to detect the language from a cookie.

### Usage Example
```ts
import express from 'express'
import cookieParser from 'cookie-parser'
import i18next from 'i18next'
import { i18nextMiddleware, LanguageDetector } from '@os-utils/i18next-express-middleware'

// Initialize i18next
i18next
  .use(LanguageDetector) // Pass the LanguageDetector middleware
  .init({
    fallbackLng: 'en',

    // Pass the custom options if necessary
    detection: {
      // In what order will the detectors be started
      order: ['cookie', 'header'], // default: ['header']
      
      // Keys used by the detectors
      cookie: 'custom-cookie', // default: i18next
      header: 'custom-header', // default: Accept-Language
    },
  })


const app = express()
app.use(cookieParser())
app.use(i18nextMiddleware(i18next))
```
npm package: @os-utils/tinkoff-oplata
Description: Реализация API Tinkoff Oplata. Все методы описаны в [документации](https://oplata.tinkoff.ru/develop/api/).
Latest version: 0.0.3
Deprecated: Moved to @os-team/tinkoff-oplata

# @os-utils/tinkoff-oplata

Реализация API Tinkoff Oplata.
Все методы описаны в [документации](https://oplata.tinkoff.ru/develop/api/).

## Пример использования
```js
const client = new TinkoffOplataClient({
  terminalKey: 'terminalKey',
  password: 'password',
})

const res = await client.init({
  Amount: 100,
  OrderId: '1',
  Description: 'Тестовый платеж',
  DATA: {
    Phone: '+71234567890',
    Email: 'name@domain.com',
  },
  Receipt: {
    Email: 'name@domain.com',
    Phone: '+71234567890',
    EmailCompany: 'name@company.com',
    Taxation: 'osn',
    Items: [
      {
        Name: 'Наименование товара',
        Price: 30000,
        Quantity: 3.00,
        Amount: 90000,
        Tax: 'vat10',
      },
    ],
  },
})
```