open-index/open-npm huggingface dataset:
npm package: @softkit/swagger-utils
Description: This is a wrapper on top of nestjs-swagger library, that provides automatic configuration and config classes to use in your apps.
Latest version: 0.1.6

# Swagger Utils Library

This is a wrapper on top of nestjs-swagger library, that provides automatic configuration and config classes to use in your apps.

It's used explicitly in @softkit/bootstrap library, but you can use it in your apps as well.


Features: 

- It provides a default configuration for swagger
- It will write an open-api.json file to your assets folder, that will be used for generators, to create HTTP client for your app. (*this usually should be disabled in upper environments, and used only locally*). To disable it just remove `docsOutputPath` from your config in all profiles except dev.

## Installation

```bash
yarn add @softkit/swagger-utils
```

## Usage

### Default configuration in your main.ts

```typescript
const swaggerSetup = setupSwagger(swaggerConfig, app);
```

### Ensuring Correct Swagger Path Configuration
The `setupSwagger` function facilitates the accurate configuration of the swagger path, accommodating optional API route prefixes. When an `appPrefix` is provided, the function concatenates it with the swagger path, ensuring the Swagger UI reflects your API's prefixed route structure.

Without an `appPrefix`, the Swagger UI defaults to the standard swagger path.

Example usage with an API prefix 'api/app':

```typescript
const appPrefix = 'api/app'; 
const swaggerSetup = setupSwagger(swaggerConfig, app, appPrefix);
```

### Default configuration in your root config class

```typescript
import { SwaggerConfig } from '@softkit/swagger-utils';

export class RootConfig {
  @Type(() => SwaggerConfig)
  @ValidateNested()
  public readonly swagger!: SwaggerConfig;
}
```

### .env.yaml file

```yaml
swagger:
  title: 'some useful name'
  swaggerPath: /swagger
  enabled: true
  description: 'some useful description'
  version: 1.0.0
  contactName: 'John Doe'
  contactEmail: 'john.doe@softkit.dev'
  contactUrl: https://www.softkit.dev/
  servers:
    - { url: 'http://localhost:9999', description: 'local server' }
```
npm package: @softkit/test-utils
Description: This library provides some useful functions for testing.
Latest version: 0.3.0

# Test utils library

This library provides some useful functions for testing.

## Installation

```bash
yarn add @softkit/test-utils
```

## Features

- `startDb` - starts a docker container with postgres database using testcontainers
- `additional asserts` - some additional asserts for jest, like `expectNotNullAndGet`
npm package: @softkit/typeorm-service
Description: This library has some useful utilities for @softkit/typeorm library, that expose useful base services to use in your application.
Latest version: 0.1.2

# Typeorm Service Library

This library has some useful utilities for @softkit/typeorm library, that expose useful base services to use in your application.

This library is also throwing standard exceptions from @softkit/exceptions library. So interceptors can handle everything properly.

## Installation

```bash
yarn add @softkit/typeorm-service
```

## Examples:

- `BaseEntityService` - it has basic methods for creating, finding, updating, archiving, deleting entities. Simple CRUD based operations, and you can also extend it with your own methods.

```typescript
import { Injectable } from '@nestjs/common';
import { Transactional } from 'typeorm-transactional';
import { CustomUserRoleRepository } from '../../repositories';
import { BaseEntityService } from '@softkit/typeorm-service';
import { IsNull } from 'typeorm';

@Injectable()
export class CustomUserRoleService extends BaseEntityService<CustomUserRole, CustomUserRoleRepository> {
  constructor(repository: CustomUserRoleRepository) {
    super(repository);
  }

  @Transactional()
  async findDefaultRole() {
    return await this.repository.findOne({
      where: {
        roleType: RoleType.REGULAR_USER,
        tenantId: IsNull(),
      },
    });
  }
}
```

- `BaseTenantEntityService` - it has basic methods for creating, finding, updating, archiving, deleting tenant base entities. Simple CRUD based operations, and you can also extend it with your own methods.

```typescript
@Injectable()
export class CustomUserRoleTenantService extends BaseTenantEntityService<CustomUserRole, CustomUserRoleTenantRepository> {
  constructor(repository: CustomUserRoleTenantRepository) {
    super(repository);
  }
}
```

Tip:

Each of these services has additional parameter in generics, after repository type, that is used for excluding auto generated types,
to keep service type safe and do not annoy you with type errors.

Example (_This will exclude 5 fields from base methods and types, because it will be populated by subscribers_):

```typescript
@Injectable()
export class CustomUserRoleTenantService extends BaseTenantEntityService<CustomUserRole, CustomUserRoleTenantRepository, Pick<CustomUserRole, 'id' | 'createdAt' | 'updatedAt' | 'deletedAt' | 'userId'>> {
  constructor(repository: CustomUserRoleTenantRepository) {
    super(repository);
  }
}
```
npm package: @softkit/validation
Description: ### We need this wrapper because of few reasons:
Latest version: 0.5.2


# Validation Wrapper around class-validator

### We need this wrapper because of few reasons: 

- class-validator is a nice library, but it's not actively supported anymore, and we consider forking it and maintaining it by ourselves. 
- there are plenty of alternatives for class-validator, but it is the most convenient one that we've ever used, and a lot of other libraries are using it as well. So having a single validator for everything is a good idea.
- class-validator stopped supporting dynamic validation schema, and in this library we implemented it for our needs and with our structures
- we also tight it with [nestjs-i18n](https://www.npmjs.com/package/@softkit/i18n), so we can easily override default translations 
- also we're providing better transformers for types like date and boolean, default class-validator transformers are not working properly with these and other types
- providing additional useful decorators like `@Match`, to check if one field match another, and other commonly requested decorators that missed in class-validator, or proper @IsEmailLocalized validator and they are localized 


### Validation rules for methods, can be found [here](https://github.com/mikeerickson/validatorjs/blob/master/src/rules.js)

### Installation

```bash
yarn add @softkit/validation
```

### Usage

Usage is as simple as with plain [class-validator](https://github.com/typestack/class-validator)

### Dynamic validator usage

- This example will throw the appropriate exception that will be handled by our filter and return RFC7807 error response if value doesn't match validator schema

```typescript
import { IsEnumValidatorDefinition, validateAndThrow } from '@softkit/validators';

validateAndThrow(
  IsEnumValidatorDefinition,
  'fieldName',
  'fieldValue',
  ['enumValue1', 'enumValue2'],
);
```

- This example will throw exception if value doesn't match constraint 

```typescript
import { MatchesRegexpValidatorDefinition, validateAndThrow } from '@softkit/validators';

const constraint = /^-?(?!0\d)\d+$/;

validateAndThrow(
  MatchesRegexpValidatorDefinition,
  params.key,
  value as string,
  constraint,
  i18nString('validation.INTEGER'),
);

```

-- If you don't need to throw exception immediately you can use `validateAndReturnError` method, that returns `ValidationError` object, that you can use later

```typescript
import { IsEnumValidatorDefinition, validateAndThrow } from '@softkit/validators';

const error = validateAndReturnError(
  IsEnumValidatorDefinition,
  'fieldName',
  'fieldValue',
  ['enumValue1', 'enumValue2'],
);

console.log(error);

```